From 4a35d5693a65c05e34abf1f9a01b8ff638bc907e Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 11 Sep 2011 19:15:07 +0200 Subject: properly initialize $lengths array Signed-off-by: Florian Pritz --- application/controllers/file.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/application/controllers/file.php b/application/controllers/file.php index 07bc56dd7..7b2d70cbf 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -104,11 +104,15 @@ class File extends CI_Controller { $data = array(); $query = array(); $lengths = array(); + $fields = array("id", "filename", "mimetype", "date", "hash"); $data['title'] = 'Upload history'; + foreach($fields as $length_key) { + $lengths[$length_key] = 0; + } if ($password != "NULL") { $query = $this->db->query(" - SELECT id, filename, mimetype, date, hash + SELECT ".implode(",", $fields)." FROM files WHERE password = ? ORDER BY date @@ -118,10 +122,7 @@ class File extends CI_Controller { foreach($query as $key => $item) { $query[$key]["date"] = date("r", $item["date"]); // Keep track of longest string to pad plaintext output correctly - foreach(array("id", "filename", "mimetype", "date", "hash") as $length_key) { - if (!isset($lengths[$length_key])) { - $lengths[$length_key] = 0; - } + foreach($fields as $length_key) { $len = mb_strlen($query[$key][$length_key]); if ($len > $lengths[$length_key]) { $lengths[$length_key] = $len; -- cgit v1.2.3-24-g4f1b