summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/controllers/file.php2
-rw-r--r--application/models/mfile.php28
2 files changed, 17 insertions, 13 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 571a4272f..85cef5490 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -687,7 +687,7 @@ class File extends MY_Controller {
assert($item["user"] === $user);
$item["data_id"] = $item['hash']."-".$item['storage_id'];
$query[$key]["data_id"] = $item["data_id"];
- if (!$this->mfile->valid_id($item["id"])) {
+ if (!$this->mfile->valid_filedata($item)) {
unset($query[$key]);
continue;
}
diff --git a/application/models/mfile.php b/application/models/mfile.php
index 32ec224f0..5139a2eee 100644
--- a/application/models/mfile.php
+++ b/application/models/mfile.php
@@ -9,10 +9,19 @@
class Mfile extends CI_Model {
+ private $upload_path;
+
function __construct()
{
parent::__construct();
$this->load->model("muser");
+
+ $this->upload_path = $this->config->item('upload_path');
+ $this->id_validation_config = array(
+ "upload_max_age" => $this->config->item("upload_max_age"),
+ "small_upload_size" => $this->config->item("small_upload_size"),
+ "sess_expiration" => $this->config->item("sess_expiration"),
+ );
}
// Returns an unused ID
@@ -85,7 +94,7 @@ class Mfile extends CI_Model {
// return the folder in which the file with $data_id is stored
function folder($data_id) {
- return $this->config->item('upload_path').'/'.substr($data_id, 0, 3);
+ return $this->upload_path.'/'.substr($data_id, 0, 3);
}
// Returns the full path to the file with $data_id
@@ -119,20 +128,15 @@ class Mfile extends CI_Model {
}
// remove old/invalid/broken IDs
- function valid_id($id)
+ public function valid_id($id)
{
$filedata = $this->get_filedata($id);
- if (!$filedata) {
- return false;
- }
-
- $config = array(
- "upload_max_age" => $this->config->item("upload_max_age"),
- "small_upload_size" => $this->config->item("small_upload_size"),
- "sess_expiration" => $this->config->item("sess_expiration"),
- );
+ return \service\files::valid_id($filedata, $this->id_validation_config, $this, time());
+ }
- return \service\files::valid_id($filedata, $config, $this, time());
+ public function valid_filedata($filedata)
+ {
+ return \service\files::valid_id($filedata, $this->id_validation_config, $this, time());
}
public function file_exists($file)