From 7454aa005fad6d13aac8e097c25ead5d065a4c28 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Fri, 11 Sep 2015 17:26:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B5?= =?UTF-8?q?=20=D0=BA=D0=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BE=D0=BA=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=81=D1=82=D0=B0=D1=82=D0=B5=D0=B9;=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D1=80=D1=83=D0=B6=D0=B0=D0=B5=D0=BC=D1=8B=D1=85=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=D0=BE=D0=B2-=D0=BA=D0=B0=D1=80=D1=82=D0=B8=D0=BD?= =?UTF-8?q?=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ground/controllers/ImagesController.php | 8 +++- ground/views/articles/edit.php | 53 ++++++++++++++----------- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/ground/controllers/ImagesController.php b/ground/controllers/ImagesController.php index 81f9f8e..28671d9 100644 --- a/ground/controllers/ImagesController.php +++ b/ground/controllers/ImagesController.php @@ -52,7 +52,13 @@ class ImagesController extends Controller $uploaddir = App::getBasedir() . '../public/photos/articles/'; $fileName = (string)$_FILES['photo']['name']; $temp = pathinfo($fileName); - $extension = strtolower($temp['extension']) ? strtolower($temp['extension']) : 'jpg'; + $extension = strtolower($temp['extension']); + + if (array_search($extension, array('jpg','jpeg','png')) === FALSE || getimagesize($_FILES['photo']['tmp_name']) === false) { + print 'error'; + die; + } + $photo = $userId . strtolower('_' . substr(md5($fileName . time()), 0, 5) . '.' . $extension); if (move_uploaded_file($_FILES['photo']['tmp_name'], $uploaddir . $photo)) { ArticlePhotos::model()->add(array( diff --git a/ground/views/articles/edit.php b/ground/views/articles/edit.php index 3cd0638..05a483d 100644 --- a/ground/views/articles/edit.php +++ b/ground/views/articles/edit.php @@ -1,5 +1,10 @@
@@ -76,10 +81,10 @@ function insertAtCursor(myField, myValue) {
- +
- - + +
@@ -90,6 +95,6 @@ function insertAtCursor(myField, myValue) {
- +