summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-04-08 23:31:32 +0200
committerFlorian Pritz <bluewind@xinu.at>2012-04-09 20:47:37 +0200
commit35b45a559472a660dc08a3bc518161e7ab400175 (patch)
tree0a20dba59f2cb671b344eb5194835c0dec0f8aaa
parent3f01ddce9dff69a49493541882de85854cbcebe5 (diff)
more user changes
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--application/controllers/file.php88
-rw-r--r--application/controllers/user.php2
-rw-r--r--application/models/muser.php1
-rw-r--r--application/views/file/header.php20
-rw-r--r--data/default.css5
5 files changed, 60 insertions, 56 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index a363edc00..3f75835bb 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -57,7 +57,6 @@ class File extends CI_Controller {
}
$this->data['username'] = $this->muser->get_username();
-
}
function index()
@@ -79,22 +78,22 @@ class File extends CI_Controller {
function client()
{
- $data['title'] = 'Client';
+ $this->data['title'] = 'Client';
if ($this->var->latest_client) {
- $data['client_link'] = base_url().'data/client/fb-'.$this->var->latest_client.'.tar.gz';
+ $this->data['client_link'] = base_url().'data/client/fb-'.$this->var->latest_client.'.tar.gz';
} else {
- $data['client_link'] = false;
+ $this->data['client_link'] = false;
}
- $data['client_link_dir'] = base_url().'data/client/';
- $data['client_link_deb'] = base_url().'data/client/deb/';
- $data['client_link_slackware'] = base_url().'data/client/slackware/';
+ $this->data['client_link_dir'] = base_url().'data/client/';
+ $this->data['client_link_deb'] = base_url().'data/client/deb/';
+ $this->data['client_link_slackware'] = base_url().'data/client/slackware/';
if (!$this->var->cli_client) {
- $this->load->view($this->var->view_dir.'/header', $data);
+ $this->load->view($this->var->view_dir.'/header', $this->data);
}
- $this->load->view($this->var->view_dir.'/client', $data);
+ $this->load->view($this->var->view_dir.'/client', $this->data);
if (!$this->var->cli_client) {
- $this->load->view($this->var->view_dir.'/footer', $data);
+ $this->load->view($this->var->view_dir.'/footer', $this->data);
}
}
@@ -102,21 +101,20 @@ class File extends CI_Controller {
{
$this->muser->require_access();
- $data = array();
- $data['title'] = 'Upload';
- $data['small_upload_size'] = $this->config->item('small_upload_size');
- $data['max_upload_size'] = $this->config->item('upload_max_size');
- $data['upload_max_age'] = $this->config->item('upload_max_age')/60/60/24;
- $data['contact_me_url'] = $this->config->item('contact_me_url');
+ $this->data['title'] = 'Upload';
+ $this->data['small_upload_size'] = $this->config->item('small_upload_size');
+ $this->data['max_upload_size'] = $this->config->item('upload_max_size');
+ $this->data['upload_max_age'] = $this->config->item('upload_max_age')/60/60/24;
+ $this->data['contact_me_url'] = $this->config->item('contact_me_url');
- $data['username'] = $this->muser->get_username();
+ $this->data['username'] = $this->muser->get_username();
- $this->load->view($this->var->view_dir.'/header', $data);
- $this->load->view($this->var->view_dir.'/upload_form', $data);
+ $this->load->view($this->var->view_dir.'/header', $this->data);
+ $this->load->view($this->var->view_dir.'/upload_form', $this->data);
if ($this->var->cli_client) {
$this->client();
}
- $this->load->view($this->var->view_dir.'/footer', $data);
+ $this->load->view($this->var->view_dir.'/footer', $this->data);
}
// Allow CLI clients to query the server for the maxium filesize so they can
@@ -134,11 +132,10 @@ class File extends CI_Controller {
$this->load->library("MemcacheLibrary");
if (! $cached = $this->memcachelibrary->get("history_".$this->var->view_dir."_".$user)) {
- $data = array();
$query = array();
$lengths = array();
$fields = array("id", "filename", "mimetype", "date", "hash");
- $data['title'] = 'Upload history';
+ $this->data['title'] = 'Upload history';
foreach($fields as $length_key) {
$lengths[$length_key] = 0;
}
@@ -163,13 +160,13 @@ class File extends CI_Controller {
}
}
- $data["query"] = $query;
- $data["lengths"] = $lengths;
+ $this->data["query"] = $query;
+ $this->data["lengths"] = $lengths;
$cached = "";
- $cached .= $this->load->view($this->var->view_dir.'/header', $data, true);
- $cached .= $this->load->view($this->var->view_dir.'/upload_history', $data, true);
- $cached .= $this->load->view($this->var->view_dir.'/footer', $data, true);
+ $cached .= $this->load->view($this->var->view_dir.'/header', $this->data, true);
+ $cached .= $this->load->view($this->var->view_dir.'/upload_history', $this->data, true);
+ $cached .= $this->load->view($this->var->view_dir.'/footer', $this->data, true);
$this->memcachelibrary->set('history_'.$this->var->view_dir."_".$user, $cached, 42);
}
@@ -181,37 +178,36 @@ class File extends CI_Controller {
{
$this->muser->require_access();
- $data = array();
$id = $this->uri->segment(3);
- $data["title"] = "Delete";
- $data["id"] = $id;
+ $this->data["title"] = "Delete";
+ $this->data["id"] = $id;
$process = $this->input->post("process");
if ($this->var->cli_client) {
$process = true;
}
- $data["filedata"] = $this->file_mod->get_filedata($id);
- if ($data["filedata"]) {
- $data["filedata"]["size"] = filesize($this->file_mod->file($data["filedata"]["hash"]));
+ $this->data["filedata"] = $this->file_mod->get_filedata($id);
+ if ($this->data["filedata"]) {
+ $this->data["filedata"]["size"] = filesize($this->file_mod->file($this->data["filedata"]["hash"]));
}
if ($id && !$this->file_mod->id_exists($id)) {
$this->output->set_status_header(404);
- $data["msg"] = "Unknown ID.";
+ $this->data["msg"] = "Unknown ID.";
} elseif ($process) {
if ($this->file_mod->delete_id($id)) {
- $this->load->view($this->var->view_dir.'/header', $data);
- $this->load->view($this->var->view_dir.'/deleted', $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.'/deleted', $this->data);
+ $this->load->view($this->var->view_dir.'/footer', $this->data);
return;
} else {
- $data["msg"] = "Deletion failed. Do you really own that file?";
+ $this->data["msg"] = "Deletion failed. Do you really own that file?";
}
}
- $this->load->view($this->var->view_dir.'/header', $data);
- $this->load->view($this->var->view_dir.'/delete_form', $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.'/delete_form', $this->data);
+ $this->load->view($this->var->view_dir.'/footer', $this->data);
}
// Handles uploaded files
@@ -219,8 +215,6 @@ class File extends CI_Controller {
{
$this->muser->require_access();
- $data = array();
-
if ($this->uri->segment(3)) {
exit;
}
@@ -236,9 +230,9 @@ class File extends CI_Controller {
4=>"No file was uploaded",
6=>"Missing a temporary folder"
);
- $data["msg"] = $errors[$_FILES['file']['error']];
- $this->load->view($this->var->view_dir.'/header', $data);
- $this->load->view($this->var->view_dir.'/upload_error', $data);
+ $this->data["msg"] = $errors[$_FILES['file']['error']];
+ $this->load->view($this->var->view_dir.'/header', $this->data);
+ $this->load->view($this->var->view_dir.'/upload_error', $this->data);
$this->load->view($this->var->view_dir.'/footer');
return;
}
@@ -246,7 +240,7 @@ class File extends CI_Controller {
$filesize = filesize($_FILES['file']['tmp_name']);
if ($filesize > $this->config->item('upload_max_size')) {
$this->output->set_status_header(413);
- $this->load->view($this->var->view_dir.'/header', $data);
+ $this->load->view($this->var->view_dir.'/header', $this->data);
$this->load->view($this->var->view_dir.'/too_big');
$this->load->view($this->var->view_dir.'/footer');
return;
diff --git a/application/controllers/user.php b/application/controllers/user.php
index 4dc92bea2..c4085a8f6 100644
--- a/application/controllers/user.php
+++ b/application/controllers/user.php
@@ -16,6 +16,7 @@ class User extends CI_Controller {
$this->load->helper('form');
$this->var->view_dir = "user/";
+ $this->data['username'] = $this->muser->get_username();
}
function index()
@@ -47,6 +48,7 @@ class User extends CI_Controller {
if ($uri) {
redirect($uri);
} else {
+ $this->data['username'] = $this->muser->get_username();
$this->load->view($this->var->view_dir.'header', $this->data);
$this->load->view($this->var->view_dir.'login_successful', $this->data);
$this->load->view($this->var->view_dir.'footer', $this->data);
diff --git a/application/models/muser.php b/application/models/muser.php
index 0b3d26be7..81fd1eb10 100644
--- a/application/models/muser.php
+++ b/application/models/muser.php
@@ -33,6 +33,7 @@ class Muser extends CI_Model {
{
$this->session->unset_userdata('logged_in');
$this->session->unset_userdata('username');
+ $this->session->sess_destroy();
}
function get_username()
diff --git a/application/views/file/header.php b/application/views/file/header.php
index 578ebe428..176dd5a25 100644
--- a/application/views/file/header.php
+++ b/application/views/file/header.php
@@ -12,15 +12,17 @@
<div class="top">
<?php echo anchor('file/index', 'New'); ?>
- <?php if (!isset($username)) { ?>
- <div style="float: right">
- <?=form_open("user/login"); ?>
- <input type="text" name="username" />
- <input type="password" name="password" />
- <input type="submit" value="Login" name="process" />
- </form>
- </div>
- <?php } ?>
+ <div class="right">
+ <?php if($username) { ?>
+ <?=anchor("user/logout", "Logout"); ?>
+ <?php } else { ?>
+ <?=form_open("user/login"); ?>
+ <input type="text" name="username" />
+ <input type="password" name="password" />
+ <input type="submit" value="Login" name="process" />
+ </form>
+ <?php } ?>
+ </div>
</div>
<div class="content">
diff --git a/data/default.css b/data/default.css
index e807456f8..4774a6a29 100644
--- a/data/default.css
+++ b/data/default.css
@@ -39,6 +39,11 @@ body {
border-bottom: 3px double gray;
}
+.top .right {
+ float: right;
+ padding-right: 10px;
+}
+
.top a {
color: lightblue;
}