summaryrefslogtreecommitdiffstats
path: root/system/application
diff options
context:
space:
mode:
Diffstat (limited to 'system/application')
-rwxr-xr-xsystem/application/config/example/config.php4
-rw-r--r--system/application/controllers/file.php16
2 files changed, 16 insertions, 4 deletions
diff --git a/system/application/config/example/config.php b/system/application/config/example/config.php
index b9ce20468..af54fb383 100755
--- a/system/application/config/example/config.php
+++ b/system/application/config/example/config.php
@@ -341,6 +341,10 @@ $config['upload_path'] = FCPATH.'data/uploads';
$config['upload_max_size'] = 256*1024*1024;
$config['upload_max_text_size'] = 2*1024*1024;
$config['upload_max_age'] = 60*60*24*5; // 5 days
+
+// won't be deleted
+$config['small_upload_size'] = 1024*10; // 10KB
+
$config['passwordsalt'] = ''; // just enter any string you want here
/* End of file config.php */
diff --git a/system/application/controllers/file.php b/system/application/controllers/file.php
index d772a3478..a07debc40 100644
--- a/system/application/controllers/file.php
+++ b/system/application/controllers/file.php
@@ -131,16 +131,24 @@ class File extends Controller {
function cron()
{
$oldest_time = (time()-$this->config->item('upload_max_age'));
+ $small_upload_size = $this->config->item('small_upload_size');
$query = $this->db->query('SELECT hash, id FROM files WHERE date < ?',
array($oldest_time));
foreach($query->result_array() as $row) {
$file = $this->file_mod->file($row['hash']);
- if(file_exists($file) && filemtime($file) < $oldest_time) {
- unlink($file);
- $this->db->query('DELETE FROM files WHERE hash = ?', array($row['hash']));
- } else {
+ if (!file_exists($file)) {
$this->db->query('DELETE FROM files WHERE id = ? LIMIT 1', array($row['id']));
+ continue;
+ }
+
+ if (filesize($file) > $small_upload_size) {
+ if (filemtime($file) < $oldest_time) {
+ unlink($file);
+ $this->db->query('DELETE FROM files WHERE hash = ?', array($row['hash']));
+ } else {
+ $this->db->query('DELETE FROM files WHERE id = ? LIMIT 1', array($row['id']));
+ }
}
}
}