diff options
author | Florian Pritz <bluewind@xinu.at> | 2012-04-09 00:05:06 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2012-04-09 20:48:02 +0200 |
commit | 58bb9bb7cbee7d9d01f35aaca88d14fce8e39270 (patch) | |
tree | 931bbfcbcdcd41fa9f479847c5c8c40f1fdc9b77 | |
parent | 383b8ebad2792297600a5b34c5c7a8b2b44d2265 (diff) |
fix missing $username when including header from file_mod
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | application/models/file_mod.php | 51 | ||||
-rw-r--r-- | application/views/file/header.php | 2 |
2 files changed, 28 insertions, 25 deletions
diff --git a/application/models/file_mod.php b/application/models/file_mod.php index 68755cc54..2b4142890 100644 --- a/application/models/file_mod.php +++ b/application/models/file_mod.php @@ -9,9 +9,14 @@ class File_mod extends CI_Model { + var $data = array(); + function __construct() { parent::__construct(); + $this->load->model("muser"); + $this->data["title"] = "FileBin"; + $this->data["username"] = $this->muser->get_username(); } // Returns an unused ID @@ -91,13 +96,12 @@ class File_mod extends CI_Model { function show_url($id, $mode) { - $data = array(); $redirect = false; if ($mode) { - $data['url'] = site_url($id).'/'.$mode; + $this->data['url'] = site_url($id).'/'.$mode; } else { - $data['url'] = site_url($id).'/'; + $this->data['url'] = site_url($id).'/'; $filedata = $this->get_filedata($id); $file = $this->file($filedata['hash']); @@ -115,21 +119,21 @@ class File_mod extends CI_Model { $redirect = false; } if ($redirect) { - redirect($data['url'], "location", 303); + redirect($this->data['url'], "location", 303); } else { - $this->load->view($this->var->view_dir.'/header', $data); - $this->load->view($this->var->view_dir.'/show_url', $data); - $this->load->view($this->var->view_dir.'/footer', $data); + $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view($this->var->view_dir.'/show_url', $this->data); + $this->load->view($this->var->view_dir.'/footer', $this->data); } } function non_existent() { - $data["title"] .= " - Not Found"; + $this->data["title"] .= " - Not Found"; $this->output->set_status_header(404); - $this->load->view($this->var->view_dir.'/header', $data); - $this->load->view($this->var->view_dir.'/non_existent', $data); - $this->load->view($this->var->view_dir.'/footer', $data); + $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view($this->var->view_dir.'/non_existent', $this->data); + $this->load->view($this->var->view_dir.'/footer', $this->data); } // remove old/invalid/broken IDs @@ -175,7 +179,6 @@ class File_mod extends CI_Model { // TODO: make smaller function download() { - $data = array(); $id = $this->uri->segment(1); $mode = $this->uri->segment(2); @@ -256,25 +259,25 @@ class File_mod extends CI_Model { exit(); } - $data['title'] = htmlspecialchars($filedata['filename']); - $data['raw_link'] = site_url($id); - $data['new_link'] = site_url(); - $data['plain_link'] = site_url($id.'/plain'); - $data['auto_link'] = site_url($id).'/'; - $data['rmd_link'] = site_url($id.'/rmd'); - $data['delete_link'] = site_url("file/delete/".$id); + $this->data['title'] = htmlspecialchars($filedata['filename']); + $this->data['raw_link'] = site_url($id); + $this->data['new_link'] = site_url(); + $this->data['plain_link'] = site_url($id.'/plain'); + $this->data['auto_link'] = site_url($id).'/'; + $this->data['rmd_link'] = site_url($id.'/rmd'); + $this->data['delete_link'] = site_url("file/delete/".$id); header("Content-Type: text/html\n"); - $data['current_highlight'] = htmlspecialchars($mode); + $this->data['current_highlight'] = htmlspecialchars($mode); if (filesize($file) > $this->config->item("small_upload_size")) { - $data['timeout'] = date("r", $filedata["date"] + $this->config->item("upload_max_age")); + $this->data['timeout'] = date("r", $filedata["date"] + $this->config->item("upload_max_age")); } else { - $data['timeout'] = "never"; + $this->data['timeout'] = "never"; } - echo $this->load->view($this->var->view_dir.'/html_header', $data, true); + echo $this->load->view($this->var->view_dir.'/html_header', $this->data, true); // highlight the file and chache the result $this->load->library("MemcacheLibrary"); @@ -302,7 +305,7 @@ class File_mod extends CI_Model { } echo $cached; - echo $this->load->view($this->var->view_dir.'/html_footer', $data, true); + echo $this->load->view($this->var->view_dir.'/html_footer', $this->data, true); exit(); } diff --git a/application/views/file/header.php b/application/views/file/header.php index 176dd5a25..526a9bca4 100644 --- a/application/views/file/header.php +++ b/application/views/file/header.php @@ -13,7 +13,7 @@ <?php echo anchor('file/index', 'New'); ?> <div class="right"> - <?php if($username) { ?> + <?php if(isset($username) && $username) { ?> <?=anchor("user/logout", "Logout"); ?> <?php } else { ?> <?=form_open("user/login"); ?> |