From 70b6af59bf868bad7fce2b356effc8ec71696e78 Mon Sep 17 00:00:00 2001 From: Kieron Date: Tue, 23 Feb 2016 09:28:20 +0000 Subject: [PATCH] #899 restrict custom field file uploads to images and pdfs --- anchor/models/extend.php | 17 +++-------------- anchor/routes/admin.php | 1 - index.php | 2 +- LICENSE => license.md | 0 4 files changed, 4 insertions(+), 16 deletions(-) rename LICENSE => license.md (100%) diff --git a/anchor/models/extend.php b/anchor/models/extend.php index 5af3e4ea3..cd9e5a1e3 100755 --- a/anchor/models/extend.php +++ b/anchor/models/extend.php @@ -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) { diff --git a/anchor/routes/admin.php b/anchor/routes/admin.php index 86627a66e..0cd476677 100755 --- a/anchor/routes/admin.php +++ b/anchor/routes/admin.php @@ -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']); diff --git a/index.php b/index.php index 6b243e44d..851eacee9 100755 --- a/index.php +++ b/index.php @@ -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); diff --git a/LICENSE b/license.md similarity index 100% rename from LICENSE rename to license.md