Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
#899 restrict custom field file uploads to images and pdfs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieron committed Feb 23, 2016
1 parent 8871a7f commit 70b6af5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
17 changes: 3 additions & 14 deletions anchor/models/extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,10 @@ public static function files() {
}

public static function upload($file) {
$storage = PATH . 'content' . DS;
$uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
$filepath = $uploader->upload($file);

if(!is_dir($storage)) mkdir($storage);

$ext = pathinfo($file['name'], PATHINFO_EXTENSION);

// Added rtrim to remove file extension before adding again
$filename = slug(rtrim($file['name'], '.' . $ext)) . '.' . $ext;
$filepath = $storage . $filename;

if(move_uploaded_file($file['tmp_name'], $filepath)) {
return $filepath;
}

return false;
return $filepath;
}

public static function process_image($extend) {
Expand Down
1 change: 0 additions & 1 deletion anchor/routes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@
Upload an image
*/
Route::post('admin/upload', array('before' => 'auth', 'main' => function() {

$uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
$filepath = $uploader->upload($_FILES['file']);

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

define('DS', DIRECTORY_SEPARATOR);
define('ENV', getenv('APP_ENV'));
define('VERSION', '0.10');
define('VERSION', '0.11');

define('PATH', dirname(__FILE__) . DS);
define('APP', PATH . 'anchor' . DS);
Expand Down
File renamed without changes.

0 comments on commit 70b6af5

Please sign in to comment.