summaryrefslogtreecommitdiffstats
path: root/application/controllers
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-07-13 22:30:54 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-07-13 22:58:07 +0200
commitcabec2e1c8e468279f17bee9fb87f1676e8cec9a (patch)
tree9caf931dbf8edd67470a778493ac2740049c3c90 /application/controllers
parent2015e32e3bd6922d0697a875ecdc810243c887f0 (diff)
Add profile page to allow changing the upload id limits
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers')
-rw-r--r--application/controllers/file.php6
-rw-r--r--application/controllers/user.php59
2 files changed, 63 insertions, 2 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 01836258a..fcb8717c5 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -542,7 +542,8 @@ class File extends CI_Controller {
return;
}
- $id = $this->mfile->new_id();
+ $limits = $this->muser->get_upload_id_limits();
+ $id = $this->mfile->new_id($limits[0], $limits[1]);
$hash = md5($content);
$folder = $this->mfile->folder($hash);
@@ -612,7 +613,8 @@ class File extends CI_Controller {
}
foreach ($files as $key => $file) {
- $id = $this->mfile->new_id();
+ $limits = $this->muser->get_upload_id_limits();
+ $id = $this->mfile->new_id($limits[0], $limits[1]);
$hash = md5_file($file['tmp_name']);
// work around a curl bug and allow the client to send the real filename base64 encoded
diff --git a/application/controllers/user.php b/application/controllers/user.php
index 79e54e84a..abbb846a3 100644
--- a/application/controllers/user.php
+++ b/application/controllers/user.php
@@ -317,6 +317,65 @@ class User extends CI_Controller {
$this->load->view('footer', $this->data);
}
+ function profile()
+ {
+ $this->muser->require_access();
+
+ $this->data["profile_data"] = $this->muser->get_profile_data();
+
+ $this->load->view('header', $this->data);
+ $this->load->view($this->var->view_dir.'profile', $this->data);
+ $this->load->view('footer', $this->data);
+ }
+
+ function save_profile()
+ {
+ $this->muser->require_access();
+
+ /*
+ * Key = name of the form field
+ * Value = function that sanatizes the value and returns it
+ * TODO: some kind of error handling that doesn't loose correctly filled out fields
+ */
+ $value_processor = array();
+
+ $value_processor["upload_id_limits"] = function($value) {
+ $values = explode("-", $value);
+
+ if (!is_array($values) || count($values) != 2) {
+ show_error("Invalid upload id limit value");
+ }
+
+ $lower = intval($values[0]);
+ $upper = intval($values[1]);
+
+ if ($lower > $upper) {
+ show_error("lower limit > upper limit");
+ }
+
+ if ($lower < 3 || $upper > 64) {
+ show_error("upper or lower limit out of bounds (3-64)");
+ }
+
+ return $lower."-".$upper;
+ };
+
+ $data = array();
+ foreach (array_keys($value_processor) as $field) {
+ $value = $this->input->post($field);
+
+ if ($value !== false) {
+ $data[$field] = $value_processor[$field]($value);
+ }
+ }
+
+ if (!empty($data)) {
+ $this->muser->update_profile($data);
+ }
+
+ redirect("user/profile");
+ }
+
function logout()
{
$this->muser->logout();