summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.build_number2
-rw-r--r--installer/installer.php10
-rw-r--r--modules/digibug/controllers/digibug.php6
-rw-r--r--modules/g2_import/controllers/g2.php4
-rw-r--r--modules/g2_import/helpers/g2_import.php7
-rw-r--r--modules/gallery/config/locale.php7
-rw-r--r--modules/gallery/helpers/graphics.php22
-rw-r--r--modules/gallery/helpers/legal_file.php39
-rw-r--r--modules/gallery/helpers/system.php13
-rw-r--r--modules/gallery/images/missing_photo.pngbin0 -> 1570 bytes
-rw-r--r--modules/gallery/models/item.php15
-rw-r--r--modules/gallery/tests/System_Helper_Test.php25
-rw-r--r--themes/wind/js/ui.init.js2
13 files changed, 93 insertions, 59 deletions
diff --git a/.build_number b/.build_number
index 1bdd507d..190e1781 100644
--- a/.build_number
+++ b/.build_number
@@ -3,4 +3,4 @@
; process. You don't need to edit it. In fact..
;
; DO NOT EDIT THIS FILE BY HAND!
-build_number=147
+build_number=153
diff --git a/installer/installer.php b/installer/installer.php
index c23d918f..0bef57ae 100644
--- a/installer/installer.php
+++ b/installer/installer.php
@@ -191,8 +191,10 @@ class installer {
$errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the <a href=\"http://php.net/mysql\">MySQL</a> or the <a href=\"http://php.net/mysqli\">MySQLi</a> extension.";
}
- if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) {
- $errors[] = "PHP is missing <a href=\"http://php.net/pcre\">Perl-Compatible Regular Expression</a> support.";
+ if (!preg_match("/^.$/u", "ñ")) {
+ $errors[] = "PHP is missing <a href=\"http://php.net/pcre\">Perl-Compatible Regular Expression</a> with UTF-8 support.";
+ } else if (!preg_match("/^\pL$/u", "ñ")) {
+ $errors[] = "PHP is missing <a href=\"http://php.net/pcre\">Perl-Compatible Regular Expression</a> with Unicode support.";
}
if (!(function_exists("spl_autoload_register"))) {
@@ -211,6 +213,10 @@ class installer {
$errors[] = "PHP is missing the <a href=\"http://php.net/iconv\">iconv extension</a>";
}
+ if (!(extension_loaded("xml"))) {
+ $errors[] = "PHP is missing the <a href=\"http://php.net/xml\">XML Parser extension</a>";
+ }
+
if (!(extension_loaded("simplexml"))) {
$errors[] = "PHP is missing the <a href=\"http://php.net/simplexml\">SimpleXML extension</a>";
}
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php
index 4acb6513..672afe57 100644
--- a/modules/digibug/controllers/digibug.php
+++ b/modules/digibug/controllers/digibug.php
@@ -33,8 +33,8 @@ class Digibug_Controller extends Controller {
$proxy->uuid = random::hash();
$proxy->item_id = $item->id;
$proxy->save();
- $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid");
- $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid");
+ $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid/$item->id");
+ $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid/$item->id");
}
$v = new View("digibug_form.html");
@@ -114,7 +114,7 @@ class Digibug_Controller extends Controller {
private function _clean_expired() {
db::build()
->delete("digibug_proxies")
- ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 10 DAY)"))
+ ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 90 DAY)"))
->limit(20)
->execute();
}
diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php
index 6e60bed0..90984e84 100644
--- a/modules/g2_import/controllers/g2.php
+++ b/modules/g2_import/controllers/g2.php
@@ -41,7 +41,9 @@ class G2_Controller extends Controller {
// (bbcode, embedding) people are using the id style URLs although URL rewriting is enabled.
$where = array(array("g2_id", "=", $id));
$view = $input->get("g2_view");
- if ($view) {
+ if ($view == "core.DownloadItem") {
+ $where[] = array("resource_type", "IN", array("file", "resize", "thumbnail", "full"));
+ } else if ($view) {
$where[] = array("g2_url", "like", "%g2_view=$view%");
} // else: Assuming that the first search hit is sufficiently good.
} else if ($path) {
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 3606c7ef..c79a8d36 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -560,7 +560,7 @@ class g2_import_Core {
$table = g2(GalleryCoreApi::fetchThumbnailsByItemIds(array($g2_album_id)));
if (isset($table[$g2_album_id])) {
// Backtrack the source id to an item
- $g2_source = $table[$g2_album_id];
+ $orig_g2_source = $g2_source = $table[$g2_album_id];
while (GalleryUtilities::isA($g2_source, "GalleryDerivative")) {
$g2_source = g2(GalleryCoreApi::loadEntitiesById($g2_source->getDerivativeSourceId()));
}
@@ -584,6 +584,11 @@ class g2_import_Core {
array("name" => $g3_album->name)),
$e);
}
+
+ self::set_map(
+ $orig_g2_source->getId(), $g3_album->id,
+ "thumbnail",
+ self::g2_url(array("view" => "core.DownloadItem", "itemId" => $orig_g2_source->getId())));
}
}
}
diff --git a/modules/gallery/config/locale.php b/modules/gallery/config/locale.php
index 13de9098..bce7fb49 100644
--- a/modules/gallery/config/locale.php
+++ b/modules/gallery/config/locale.php
@@ -32,7 +32,12 @@ $config['language'] = array('en_US', 'English_United States');
* Locale timezone. Set in 'Advanced' settings, falling back to the server's zone.
* @see http://php.net/timezones
*/
-$config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get());
+if (file_exists(VARPATH . "database.php")) {
+ $config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get());
+} else {
+ // Gallery3 is not installed yet -- don't make module::get_var() calls.
+ $config['timezone'] = date_default_timezone_get();
+}
// i18n settings
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index acb11bfb..3b9769de 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -170,23 +170,37 @@ class graphics_Core {
foreach (self::_get_rules($target) as $rule) {
$args = array($working_file, $output_file, unserialize($rule->args), $item);
- call_user_func_array($rule->operation, $args);
- $working_file = $output_file;
+ try {
+ call_user_func_array($rule->operation, $args);
+ $working_file = $output_file;
+ } catch (Exception $e) {
+ // Ignore this filter and move on.
+ Kohana_Log::add("error", "Caught exception filtering image: {$item->title}\n" .
+ $e->getMessage() . "\n" . $e->getTraceAsString());
+ }
}
}
if (!empty($ops["thumb"])) {
+ if (file_exists($item->thumb_path())) {
+ $item->thumb_dirty = 0;
+ } else {
+ copy(MODPATH . "gallery/images/missing_photo.png", $item->thumb_path());
+ }
$dims = getimagesize($item->thumb_path());
$item->thumb_width = $dims[0];
$item->thumb_height = $dims[1];
- $item->thumb_dirty = 0;
}
if (!empty($ops["resize"])) {
+ if (file_exists($item->resize_path())) {
+ $item->resize_dirty = 0;
+ } else {
+ copy(MODPATH . "gallery/images/missing_photo.png", $item->resize_path());
+ }
$dims = getimagesize($item->resize_path());
$item->resize_width = $dims[0];
$item->resize_height = $dims[1];
- $item->resize_dirty = 0;
}
$item->save();
} catch (Exception $e) {
diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php
index 2cb0fb25..0d3e9728 100644
--- a/modules/gallery/helpers/legal_file.php
+++ b/modules/gallery/helpers/legal_file.php
@@ -18,22 +18,51 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class legal_file_Core {
- static function get_extensions() {
+ static function get_photo_extensions() {
// Create a default list of allowed extensions and then let modules modify it.
$extensions_wrapper = new stdClass();
$extensions_wrapper->extensions = array("gif", "jpg", "jpeg", "png");
+ module::event("legal_photo_extensions", $extensions_wrapper);
+ return $extensions_wrapper->extensions;
+ }
+
+ static function get_movie_extensions() {
+ // Create a default list of allowed extensions and then let modules modify it.
+ $extensions_wrapper = new stdClass();
+ $extensions_wrapper->extensions = array("flv", "mp4", "m4v");
+ module::event("legal_movie_extensions", $extensions_wrapper);
+ return $extensions_wrapper->extensions;
+ }
+
+ static function get_extensions() {
+ $extensions = legal_file::get_photo_extensions();
if (movie::find_ffmpeg()) {
- array_push($extensions_wrapper->extensions, "flv", "mp4", "m4v");
+ $extensions = array_merge($extensions, legal_file::get_movie_extensions());
}
- module::event("legal_file_extensions", $extensions_wrapper);
- return $extensions_wrapper->extensions;
+ return $extensions;
}
static function get_filters() {
$filters = array();
- foreach (self::get_extensions() as $extension) {
+ foreach (legal_file::get_extensions() as $extension) {
array_push($filters, "*." . $extension, "*." . strtoupper($extension));
}
return $filters;
}
+
+ static function get_photo_types() {
+ // Create a default list of allowed types and then let modules modify it.
+ $types_wrapper = new stdClass();
+ $types_wrapper->types = array("image/jpeg", "image/gif", "image/png");
+ module::event("legal_photo_types", $types_wrapper);
+ return $types_wrapper->types;
+ }
+
+ static function get_movie_types() {
+ // Create a default list of allowed types and then let modules modify it.
+ $types_wrapper = new stdClass();
+ $types_wrapper->types = array("video/flv", "video/x-flv", "video/mp4");
+ module::event("legal_movie_types", $types_wrapper);
+ return $types_wrapper->types;
+ }
}
diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php
index 9815d588..4110b4ed 100644
--- a/modules/gallery/helpers/system.php
+++ b/modules/gallery/helpers/system.php
@@ -47,20 +47,13 @@ class system_Core {
* It allows the caller to specify a prefix and an extension.
* It always places the file in TMPPATH.
*/
- static function temp_filename($prefix = "", $extension = "") {
- return self::_tempnam(TMPPATH, $prefix, ".$extension", "tempnam");
- }
-
- /**
- * This helper provides a dependency-injected implementation of tempnam.
- */
- static function _tempnam($dir, $prefix, $postfix, $builtin) {
+ static function temp_filename($prefix="", $extension="") {
do {
- $basename = call_user_func($builtin, $dir, $prefix);
+ $basename = tempnam(TMPPATH, $prefix);
if (!$basename) {
return false;
}
- $filename = $basename . $postfix;
+ $filename = "$basename.$extension";
$success = !file_exists($filename) && @rename($basename, $filename);
if (!$success) {
@unlink($basename);
diff --git a/modules/gallery/images/missing_photo.png b/modules/gallery/images/missing_photo.png
new file mode 100644
index 00000000..67786275
--- /dev/null
+++ b/modules/gallery/images/missing_photo.png
Binary files differ
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 6eb93cfa..4a0c8e38 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -813,10 +813,13 @@ class Item_Model_Core extends ORM_MPTT {
return;
}
- if (($this->is_movie() || $this->is_photo()) &&
+ if ($this->is_photo() &&
!preg_match("/^(" .
- implode("|", array_map("preg_quote",
- legal_file::get_extensions())) .
+ implode("|", array_map("preg_quote", legal_file::get_photo_extensions())) .
+ ")\$/i", $ext) ||
+ $this->is_movie() &&
+ !preg_match("/^(" .
+ implode("|", array_map("preg_quote", legal_file::get_movie_extensions())) .
")\$/i", $ext)) {
$v->add_error("name", "illegal_data_file_extension");
}
@@ -896,9 +899,9 @@ class Item_Model_Core extends ORM_MPTT {
switch($field) {
case "mime_type":
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", "image/tiff");
+ $legal_values = legal_file::get_movie_types();
+ } else if ($this->is_photo()) {
+ $legal_values = legal_file::get_photo_types();
}
break;
diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php
index dfe5d9ab..3d56c516 100644
--- a/modules/gallery/tests/System_Helper_Test.php
+++ b/modules/gallery/tests/System_Helper_Test.php
@@ -18,33 +18,10 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class System_Helper_Test extends Gallery_Unit_Test_Case {
- public function temp_filename_random_test() {
+ public function temp_filename_test() {
$filename = system::temp_filename("file", "ext");
$this->assert_true(file_exists($filename), "File not created");
unlink($filename);
$this->assert_pattern($filename, "|/file.*\\.ext$|");
}
-
- public function tempnam_collision_test() {
- require_once('Mock_Built_In.php');
- $existing = TMPPATH . "/file1.ext";
- $available = TMPPATH . "/file2.ext";
- touch($existing);
- $filename = system::_tempnam(TMPPATH, "file", ".ext",
- array(new Mock_Built_In("1", "2"), "_tempnam"));
- unlink($existing);
- $this->assert_true(file_exists($filename), "File not created");
- unlink($filename);
- $this->assert_equal($available, $filename, "Incorrect filename created");
- }
-
- public function tempnam_abort_test() {
- require_once('Mock_Built_In.php');
- $filename = system::_tempnam(TMPPATH, "file", ".ext",
- array(new Mock_Built_In(), "_tempnam"));
- if ($filename) {
- @unlink($filename);
- }
- $this->assert_false($filename, "Operation not aborted");
- }
}
diff --git a/themes/wind/js/ui.init.js b/themes/wind/js/ui.init.js
index 2c67bf3a..3ee3e32e 100644
--- a/themes/wind/js/ui.init.js
+++ b/themes/wind/js/ui.init.js
@@ -82,7 +82,7 @@ $(document).ready(function() {
} else {
var sib_height = $(this).prev().height();
}
- if ($.browser.msie && $.browser.version >= 8) {
+ if ($.browser.msie && $.browser.version <= 8) {
sib_height = sib_height + 1;
}
$(this).css("height", sib_height);