diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/controllers/api/v1/file.php | 3 | ||||
-rw-r--r-- | application/controllers/api/v2/file.php | 3 | ||||
-rw-r--r-- | application/controllers/file.php | 12 | ||||
-rw-r--r-- | application/models/mfile.php | 4 | ||||
-rw-r--r-- | application/service/files.php | 12 |
5 files changed, 19 insertions, 15 deletions
diff --git a/application/controllers/api/v1/file.php b/application/controllers/api/v1/file.php index 784f42555..6536335cb 100644 --- a/application/controllers/api/v1/file.php +++ b/application/controllers/api/v1/file.php @@ -30,11 +30,12 @@ class file extends \controllers\api\api_controller { \service\files::verify_uploaded_files($files); $limits = $this->muser->get_upload_id_limits(); + $userid = $this->muser->get_userid(); $urls = array(); foreach ($files as $file) { $id = $this->mfile->new_id($limits[0], $limits[1]); - \service\files::add_uploaded_file($id, $file["tmp_name"], $file["name"]); + \service\files::add_uploaded_file($userid, $id, $file["tmp_name"], $file["name"]); $ids[] = $id; $urls[] = site_url($id).'/'; } diff --git a/application/controllers/api/v2/file.php b/application/controllers/api/v2/file.php index ebe717f73..79da1c4b8 100644 --- a/application/controllers/api/v2/file.php +++ b/application/controllers/api/v2/file.php @@ -30,11 +30,12 @@ class file extends \controllers\api\api_controller { \service\files::verify_uploaded_files($files); $limits = $this->muser->get_upload_id_limits(); + $userid = $this->muser->get_userid(); $urls = array(); foreach ($files as $file) { $id = $this->mfile->new_id($limits[0], $limits[1]); - \service\files::add_uploaded_file($id, $file["tmp_name"], $file["name"]); + \service\files::add_uploaded_file($userid, $id, $file["tmp_name"], $file["name"]); $ids[] = $id; $urls[] = site_url($id).'/'; } diff --git a/application/controllers/file.php b/application/controllers/file.php index d882b9334..d432386ab 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -921,11 +921,12 @@ class File extends MY_Controller { if (!empty($files)) { $limits = $this->muser->get_upload_id_limits(); + $userid = $this->muser->get_userid(); service\files::verify_uploaded_files($files); foreach ($files as $key => $file) { $id = $this->mfile->new_id($limits[0], $limits[1]); - service\files::add_uploaded_file($id, $file["tmp_name"], $file["name"]); + service\files::add_uploaded_file($userid, $id, $file["tmp_name"], $file["name"]); $ids[] = $id; } } @@ -950,6 +951,8 @@ class File extends MY_Controller { } $limits = $this->muser->get_upload_id_limits(); + $userid = $this->muser->get_userid(); + foreach ($contents as $key => $content) { $filename = "stdin"; if (isset($filenames[$key]) && $filenames[$key] != "") { @@ -957,7 +960,7 @@ class File extends MY_Controller { } $id = $this->mfile->new_id($limits[0], $limits[1]); - service\files::add_file_data($id, $content, $filename); + service\files::add_file_data($userid, $id, $content, $filename); $ids[] = $id; } @@ -986,6 +989,8 @@ class File extends MY_Controller { service\files::verify_uploaded_files($files); $limits = $this->muser->get_upload_id_limits(); + $userid = $this->muser->get_userid(); + foreach ($files as $key => $file) { $id = $this->mfile->new_id($limits[0], $limits[1]); @@ -1003,12 +1008,11 @@ class File extends MY_Controller { $filename = trim($filename, "\r\n\0\t\x0B"); - service\files::add_uploaded_file($id, $file["tmp_name"], $filename); + service\files::add_uploaded_file($userid, $id, $file["tmp_name"], $filename); $ids[] = $id; } if ($multipaste !== false) { - $userid = $this->muser->get_userid(); $ids[] = \service\files::create_multipaste($ids, $userid, $limits)["url_id"]; } diff --git a/application/models/mfile.php b/application/models/mfile.php index 10f4f542e..6b7b38d41 100644 --- a/application/models/mfile.php +++ b/application/models/mfile.php @@ -103,10 +103,8 @@ class Mfile extends CI_Model { } // Add a file to the DB - function add_file($id, $filename, $storage_id) + function add_file($userid, $id, $filename, $storage_id) { - $userid = $this->muser->get_userid(); - $this->db->insert("files", array( "id" => $id, "filename" => $filename, diff --git a/application/service/files.php b/application/service/files.php index 9202c7f31..54b1f85af 100644 --- a/application/service/files.php +++ b/application/service/files.php @@ -94,12 +94,12 @@ class files { return $multipaste_info; } - static public function add_file_data($id, $content, $filename) + static public function add_file_data($userid, $id, $content, $filename) { $f = new \libraries\Tempfile(); $file = $f->get_file(); file_put_contents($file, $content); - self::add_file_callback($id, $file, $filename); + self::add_file_callback($userid, $id, $file, $filename); } /** @@ -140,12 +140,12 @@ class files { return implode("\n", $lines); } - static public function add_uploaded_file($id, $file, $filename) + static public function add_uploaded_file($userid, $id, $file, $filename) { - self::add_file_callback($id, $file, $filename); + self::add_file_callback($userid, $id, $file, $filename); } - static private function add_file_callback($id, $new_file, $filename) + static private function add_file_callback($userid, $id, $new_file, $filename) { $CI =& get_instance(); $hash = md5_file($new_file); @@ -191,7 +191,7 @@ class files { rename($new_file, $tmpfile); $dest->commit(); - $CI->mfile->add_file($id, $filename, $storage_id); + $CI->mfile->add_file($userid, $id, $filename, $storage_id); } static public function verify_uploaded_files($files) |