summaryrefslogtreecommitdiffstats
path: root/system/application
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-02-07 17:34:35 +0100
committerFlorian Pritz <bluewind@xssn.at>2010-02-07 17:34:35 +0100
commited37021577c01f14f3f4d6f3b5da18f6b56d5be4 (patch)
tree2b79977fdad9f3666471a5fc05b28a37a8c3dd4e /system/application
parent9e9d77b4072de4f8c73e8bbade07a8f27734e4bd (diff)
add function to generate file paths
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'system/application')
-rw-r--r--system/application/controllers/file.php8
-rw-r--r--system/application/models/file_mod.php6
2 files changed, 8 insertions, 6 deletions
diff --git a/system/application/controllers/file.php b/system/application/controllers/file.php
index d22cb9dfe..fb114ee7b 100644
--- a/system/application/controllers/file.php
+++ b/system/application/controllers/file.php
@@ -68,7 +68,7 @@ class File extends Controller {
$file_name = $_FILES['userfile']['name'];
$folder = $this->file_mod->folder($file_hash);
file_exists($folder) || mkdir ($folder);
- $file = $folder.'/'.$file_hash;
+ $file = $this->file_mod->file($file_hash);
$sql = '
INSERT INTO `files` (`hash`, `id`, `filename`, `password`, `date`)
@@ -118,9 +118,7 @@ class File extends Controller {
$mode = $this->uri->segment(4);
$filedata = $this->file_mod->get_filedata($id);
-
- $folder = $this->file_mod->folder($filedata['hash']);
- $file = $folder.'/'.$filedata['hash'];
+ $file = $this->file_mod->file($filedata['hash']);
if ($this->file_mod->id_exists($id) && file_exists($file)) {
// MODIFIED SINCE SUPPORT -- START
@@ -216,7 +214,7 @@ class File extends Controller {
array($oldest_time));
foreach($query->result_array() as $row) {
- $file = $this->config->item('upload_path').'/'.substr($row['hash'], 0, 3).'/'.$row['hash'];
+ $file = $this->file_mod->file($row['hash']);
if(filemtime($file) < $oldest_time) {
unlink($file);
$this->db->query('DELETE FROM files WHERE hash = ?', array($row['hash']));
diff --git a/system/application/models/file_mod.php b/system/application/models/file_mod.php
index 96415bc2f..445ccdce4 100644
--- a/system/application/models/file_mod.php
+++ b/system/application/models/file_mod.php
@@ -60,6 +60,10 @@ class File_mod extends Model {
return $this->config->item('upload_path').'/'.substr($hash, 0, 3);
}
+ function file($hash) {
+ return $this->folder($hash).'/'.$hash;
+ }
+
function hash_password($password)
{
// TODO: move salt to config
@@ -95,7 +99,7 @@ class File_mod extends Model {
$query = $this->db->query($sql, array($id, $password));
if($this->unused_file($filedata['hash'])) {
- unlink($this->config->item('upload_path').'/'.substr($filedata['hash'], 0, 3).'/'.$filedata['hash']);
+ unlink($this->file(substr($filedata['hash'])));
// TODO: remove empty folders
}
}