From 31ba081b793141ca36866a6dd349cd2eac5af68e Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Thu, 21 Apr 2011 02:06:53 -0600 Subject: Add an event that will collect all valid filename extensions. --- modules/gallery/controllers/uploader.php | 2 +- modules/gallery/libraries/Form_Uploadify.php | 1 + modules/gallery/models/item.php | 9 +++++---- modules/gallery/views/form_uploadify.html.php | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php index 6b1455e4..12180893 100644 --- a/modules/gallery/controllers/uploader.php +++ b/modules/gallery/controllers/uploader.php @@ -51,7 +51,7 @@ class Uploader_Controller extends Controller { $file_validation = new Validation($_FILES); $file_validation->add_rules( "Filedata", "upload::valid", "upload::required", - "upload::type[gif,jpg,jpeg,png,flv,mp4,m4v]"); + "upload::type[" . implode(",", upload::get_upload_extensions()) . "]"); if ($form->validate() && $file_validation->validate()) { $temp_filename = upload::save("Filedata"); diff --git a/modules/gallery/libraries/Form_Uploadify.php b/modules/gallery/libraries/Form_Uploadify.php index 27ab9684..ca189f0b 100644 --- a/modules/gallery/libraries/Form_Uploadify.php +++ b/modules/gallery/libraries/Form_Uploadify.php @@ -47,6 +47,7 @@ class Form_Uploadify_Core extends Form_Input { $v->script_data = $this->data["script_data"]; $v->simultaneous_upload_limit = module::get_var("gallery", "simultaneous_upload_limit"); $v->movies_allowed = (bool) movie::find_ffmpeg(); + $v->extensions = upload::get_upload_filters(); $v->suhosin_session_encrypt = (bool) ini_get("suhosin.session.encrypt"); return $v; } diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 8f4bc5e4..aaca832a 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -787,9 +787,10 @@ class Item_Model_Core extends ORM_MPTT { return; } - if ($this->is_movie() && !preg_match("/^(flv|mp4|m4v)$/i", $ext)) { - $v->add_error("name", "illegal_data_file_extension"); - } else if ($this->is_photo() && !preg_match("/^(gif|jpg|jpeg|png)$/i", $ext)) { + if (($this->is_movie() || $this->is_photo()) && + !preg_match("/^(" . + implode("|", array_map("preg_quote", upload::get_upload_extensions())) . + ")\$/i", $ext)) { $v->add_error("name", "illegal_data_file_extension"); } } @@ -881,7 +882,7 @@ class Item_Model_Core extends ORM_MPTT { if ($this->is_movie()) { $legal_values = array("video/flv", "video/x-flv", "video/mp4"); } if ($this->is_photo()) { - $legal_values = array("image/jpeg", "image/gif", "image/png"); + $legal_values = array("image/jpeg", "image/gif", "image/png", "image/tiff"); } break; diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index 77b6d493..db90b733 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -28,7 +28,7 @@ uploader: "", script: "id}") ?>", scriptData: , - fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.GIF;*.JPG;*.JPEG;*.PNG;*.flv;*.mp4;*.m4v;*.FLV;*.MP4;*.M4V", + fileExt: "", fileDesc: for_js() ?>, cancelImg: "", simUploadLimit: , -- cgit v1.2.3