summaryrefslogtreecommitdiffstats
path: root/application/models/mfile.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/models/mfile.php')
-rw-r--r--application/models/mfile.php43
1 files changed, 18 insertions, 25 deletions
diff --git a/application/models/mfile.php b/application/models/mfile.php
index f0a594609..bf6d0f9dc 100644
--- a/application/models/mfile.php
+++ b/application/models/mfile.php
@@ -130,36 +130,29 @@ class Mfile extends CI_Model {
if (!$filedata) {
return false;
}
- $file = $this->file($filedata['hash']);
- if (!file_exists($file)) {
- $this->delete_hash($filedata["hash"]);
- return false;
- }
-
- // 0 age disables age checks
- if ($this->config->item('upload_max_age') == 0) return true;
+ $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"),
+ );
- // small files don't expire
- if (filesize($file) <= $this->config->item("small_upload_size")) {
- return true;
- }
+ return \service\files::valid_id($filedata, $config, $this, time());
+ }
- // files older than this should be removed
- $remove_before = (time()-$this->config->item('upload_max_age'));
+ public function file_exists($file)
+ {
+ return file_exists($file);
+ }
- if ($filedata["date"] < $remove_before) {
- // if the file has been uploaded multiple times the mtime is the time
- // of the last upload
- if (filemtime($file) < $remove_before) {
- $this->delete_hash($filedata["hash"]);
- } else {
- $this->delete_id($id);
- }
- return false;
- }
+ public function filemtime($file)
+ {
+ return filemtime($file);
+ }
- return true;
+ public function filesize($file)
+ {
+ return filesize($file);
}
public function get_timeout($id)