summaryrefslogtreecommitdiff
path: root/modules/gallery/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/tests')
-rw-r--r--modules/gallery/tests/Access_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Albums_Controller_Test.php2
-rw-r--r--modules/gallery/tests/Breadcrumb_Test.php2
-rw-r--r--modules/gallery/tests/Cache_Test.php2
-rw-r--r--modules/gallery/tests/Controller_Auth_Test.php7
-rw-r--r--modules/gallery/tests/Data_Rest_Helper_Test.php111
-rw-r--r--modules/gallery/tests/Database_Test.php8
-rw-r--r--modules/gallery/tests/Dir_Helper_Test.php2
-rw-r--r--modules/gallery/tests/DrawForm_Test.php2
-rw-r--r--modules/gallery/tests/File_Proxy_Controller_Test.php130
-rw-r--r--modules/gallery/tests/File_Structure_Test.php52
-rw-r--r--modules/gallery/tests/Gallery_Filters.php8
-rw-r--r--modules/gallery/tests/Gallery_Graphics_Helper_Test.php137
-rw-r--r--modules/gallery/tests/Gallery_I18n_Test.php2
-rw-r--r--modules/gallery/tests/Gallery_Installer_Test.php2
-rw-r--r--modules/gallery/tests/Graphics_Helper_Test.php158
-rw-r--r--modules/gallery/tests/Html_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Input_Library_Test.php2
-rw-r--r--modules/gallery/tests/Item_Helper_Test.php20
-rw-r--r--modules/gallery/tests/Item_Model_Test.php385
-rw-r--r--modules/gallery/tests/Item_Rest_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Items_Rest_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Kohana_Exception_Test.php2
-rw-r--r--modules/gallery/tests/Legal_File_Helper_Test.php153
-rw-r--r--modules/gallery/tests/Locales_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Menu_Test.php2
-rw-r--r--modules/gallery/tests/Movie_Helper_Test.php105
-rw-r--r--modules/gallery/tests/Num_Helper_Test.php2
-rw-r--r--modules/gallery/tests/ORM_MPTT_Test.php2
-rw-r--r--modules/gallery/tests/Photo_Helper_Test.php70
-rw-r--r--modules/gallery/tests/Photos_Controller_Test.php2
-rw-r--r--modules/gallery/tests/SafeString_Test.php2
-rw-r--r--modules/gallery/tests/Sendmail_Test.php2
-rw-r--r--modules/gallery/tests/System_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Url_Security_Test.php2
-rw-r--r--modules/gallery/tests/Valid_Test.php2
-rw-r--r--modules/gallery/tests/Var_Test.php2
-rw-r--r--modules/gallery/tests/Xss_Security_Test.php2
-rw-r--r--modules/gallery/tests/controller_auth_data.txt2
-rw-r--r--modules/gallery/tests/xss_data.txt118
40 files changed, 1313 insertions, 201 deletions
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php
index df7de595..ffb62d98 100644
--- a/modules/gallery/tests/Access_Helper_Test.php
+++ b/modules/gallery/tests/Access_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Albums_Controller_Test.php b/modules/gallery/tests/Albums_Controller_Test.php
index 625d9525..6fdc9df3 100644
--- a/modules/gallery/tests/Albums_Controller_Test.php
+++ b/modules/gallery/tests/Albums_Controller_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Breadcrumb_Test.php b/modules/gallery/tests/Breadcrumb_Test.php
index 65a853a8..b7667594 100644
--- a/modules/gallery/tests/Breadcrumb_Test.php
+++ b/modules/gallery/tests/Breadcrumb_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Cache_Test.php b/modules/gallery/tests/Cache_Test.php
index ce91ebae..b1f56d7f 100644
--- a/modules/gallery/tests/Cache_Test.php
+++ b/modules/gallery/tests/Cache_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Controller_Auth_Test.php b/modules/gallery/tests/Controller_Auth_Test.php
index 5131fae0..e1ca0a7b 100644
--- a/modules/gallery/tests/Controller_Auth_Test.php
+++ b/modules/gallery/tests/Controller_Auth_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,8 +20,9 @@
class Controller_Auth_Test extends Gallery_Unit_Test_Case {
public function find_missing_auth_test() {
$found = array();
- $controllers = explode("\n", `git ls-files '*/*/controllers/*.php'`);
- $feeds = explode("\n", `git ls-files '*/*/helpers/*_rss.php'`);
+ $git_ignores = explode("\n", `git ls-files -o -i --exclude-standard`);
+ $controllers = array_diff(glob("*/*/controllers/*.php"), $git_ignores);
+ $feeds = array_diff(glob("*/*/helpers/*_rss.php"), $git_ignores);
foreach (array_merge($controllers, $feeds) as $controller) {
if (preg_match("{modules/(gallery_)?unit_test/}", $controller)) {
continue;
diff --git a/modules/gallery/tests/Data_Rest_Helper_Test.php b/modules/gallery/tests/Data_Rest_Helper_Test.php
new file mode 100644
index 00000000..e6a94864
--- /dev/null
+++ b/modules/gallery/tests/Data_Rest_Helper_Test.php
@@ -0,0 +1,111 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Data_Rest_Helper_Test extends Gallery_Unit_Test_Case {
+ public function teardown() {
+ identity::set_active_user(identity::admin_user());
+ }
+
+ public function resolve_test() {
+ $photo = test::random_photo();
+ $resolved = rest::resolve(rest::url("data", $photo, 640));
+ $this->assert_equal($photo->id, $resolved->id);
+ }
+
+ public function resolve_needs_permission_test() {
+ $album = test::random_album();
+ $photo = test::random_photo($album);
+ $album->reload(); // new photo changed the album in the db
+
+ access::deny(identity::everybody(), "view", $album);
+ identity::set_active_user(identity::guest());
+
+ try {
+ data_rest::resolve($photo->id);
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ // pass
+ }
+ }
+
+ public function basic_get_test() {
+ $photo = test::random_photo();
+
+ $request = new stdClass();
+ $request->url = rest::url("data", $photo, "thumb");
+ $request->params = new stdClass();
+
+ $request->params->size = "thumb";
+ $this->assert_same($photo->thumb_path(), data_rest::get($request));
+
+ $request->params->size = "resize";
+ $this->assert_same($photo->resize_path(), data_rest::get($request));
+
+ $request->params->size = "full";
+ $this->assert_same($photo->file_path(), data_rest::get($request));
+ }
+
+ public function illegal_access_test() {
+ $album = test::random_album();
+ $photo = test::random_photo($album);
+ $album->reload();
+
+ access::deny(identity::everybody(), "view", $album);
+ identity::set_active_user(identity::guest());
+
+ $request = new stdClass();
+ $request->url = rest::url("data", $photo, "thumb");
+ $request->params = new stdClass();
+ $request->params->size = "thumb";
+
+ try {
+ data_rest::get($request);
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ // pass
+ }
+ }
+
+ public function missing_file_test() {
+ $photo = test::random_photo();
+
+ $request = new stdClass();
+ $request->url = rest::url("data", $photo, "thumb");
+ $request->params = new stdClass();
+ $request->params->size = "thumb";
+
+ unlink($photo->thumb_path()); // oops!
+
+ try {
+ data_rest::get($request);
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ // pass
+ }
+ }
+
+ public function cache_buster_test() {
+ $photo = test::random_photo();
+
+ $this->assert_same(
+ url::abs_site("rest/data/{$photo->id}?size=thumb&m=" . filemtime($photo->thumb_path())),
+ data_rest::url($photo, "thumb"));
+ }
+}
+
diff --git a/modules/gallery/tests/Database_Test.php b/modules/gallery/tests/Database_Test.php
index fa9e5370..106062f5 100644
--- a/modules/gallery/tests/Database_Test.php
+++ b/modules/gallery/tests/Database_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -147,6 +147,12 @@ class Database_Test extends Gallery_Unit_Test_Case {
$sql = str_replace("\n", " ", $sql);
$this->assert_same("UPDATE [test_tables] SET [name] = [Test Name] WHERE [1] = [1]", $sql);
}
+
+ function escape_for_like_test() {
+ // Note: literal double backslash is written as \\\
+ $this->assert_same('basic\_test', Database::escape_for_like("basic_test"));
+ $this->assert_same('\\\100\%\_test/', Database::escape_for_like('\100%_test/'));
+ }
}
class Database_Mock extends Database {
diff --git a/modules/gallery/tests/Dir_Helper_Test.php b/modules/gallery/tests/Dir_Helper_Test.php
index a9decb88..228b5c21 100644
--- a/modules/gallery/tests/Dir_Helper_Test.php
+++ b/modules/gallery/tests/Dir_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/DrawForm_Test.php b/modules/gallery/tests/DrawForm_Test.php
index 04163525..19177a3a 100644
--- a/modules/gallery/tests/DrawForm_Test.php
+++ b/modules/gallery/tests/DrawForm_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/File_Proxy_Controller_Test.php b/modules/gallery/tests/File_Proxy_Controller_Test.php
new file mode 100644
index 00000000..562100e4
--- /dev/null
+++ b/modules/gallery/tests/File_Proxy_Controller_Test.php
@@ -0,0 +1,130 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class File_Proxy_Controller_Test extends Gallery_Unit_Test_Case {
+ public function setup() {
+ $this->_save = array($_SERVER);
+ }
+
+ public function teardown() {
+ list($_SERVER) = $this->_save;
+ identity::set_active_user(identity::admin_user());
+ }
+
+ public function basic_test() {
+ $photo = test::random_photo();
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}");
+ $controller = new File_Proxy_Controller();
+ $this->assert_same($photo->file_path(), $controller->__call("", array()));
+ }
+
+ public function query_params_are_ignored_test() {
+ $photo = test::random_photo();
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}?a=1&b=2");
+ $controller = new File_Proxy_Controller();
+ $this->assert_same($photo->file_path(), $controller->__call("", array()));
+ }
+
+ public function file_must_be_in_var_test() {
+ $_SERVER["REQUEST_URI"] = url::file("index.php");
+ $controller = new File_Proxy_Controller();
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(1, $e->test_fail_code);
+ }
+ }
+
+ public function file_must_be_in_albums_thumbs_or_resizes_test() {
+ $_SERVER["REQUEST_URI"] = url::file("var/test/var/uploads/.htaccess");
+ $controller = new File_Proxy_Controller();
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(2, $e->test_fail_code);
+ }
+ }
+
+ public function movie_thumbnails_are_jpgs_test() {
+ $movie = test::random_movie();
+ $name = legal_file::change_extension($movie->name, "jpg");
+ $_SERVER["REQUEST_URI"] = url::file("var/thumbs/{$movie->name}");
+ $controller = new File_Proxy_Controller();
+ $this->assert_same($movie->thumb_path(), $controller->__call("", array()));
+ }
+
+ public function invalid_item_test() {
+ $photo = test::random_photo();
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/x_{$photo->name}");
+ $controller = new File_Proxy_Controller();
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(3, $e->test_fail_code);
+ }
+ }
+
+ public function need_view_full_permission_to_view_original_test() {
+ $album = test::random_album();
+ $photo = test::random_photo($album);
+ $album = $album->reload(); // adding the photo changed the album in the db
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/{$album->name}/{$photo->name}");
+ $controller = new File_Proxy_Controller();
+
+ access::deny(identity::everybody(), "view_full", $album);
+ identity::set_active_user(identity::guest());
+
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(5, $e->test_fail_code);
+ }
+ }
+
+ public function cant_proxy_an_album_test() {
+ $album = test::random_album();
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/{$album->name}");
+ $controller = new File_Proxy_Controller();
+
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(6, $e->test_fail_code);
+ }
+ }
+
+ public function missing_file_test() {
+ $photo = test::random_photo();
+ $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}");
+ unlink($photo->file_path());
+ $controller = new File_Proxy_Controller();
+
+ try {
+ $controller->__call("", array());
+ $this->assert_true(false);
+ } catch (Kohana_404_Exception $e) {
+ $this->assert_same(7, $e->test_fail_code);
+ }
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php
index 3d2079e5..ce75ea13 100644
--- a/modules/gallery/tests/File_Structure_Test.php
+++ b/modules/gallery/tests/File_Structure_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -132,7 +132,7 @@ class File_Structure_Test extends Gallery_Unit_Test_Case {
"<?php defined(\"SYSPATH\") or die(\"No direct script access.\");",
"/**",
" * Gallery - a web based photo album viewer and editor",
- " * Copyright (C) 2000-2012 Bharat Mediratta",
+ " * Copyright (C) 2000-2013 Bharat Mediratta",
" *",
" * This program is free software; you can redistribute it and/or modify",
" * it under the terms of the GNU General Public License as published by",
@@ -283,4 +283,52 @@ class File_Structure_Test extends Gallery_Unit_Test_Case {
$this->assert_true(false, $errors);
}
}
+
+ public function all_public_functions_in_test_files_end_in_test() {
+ // Who tests the tests? :-) (ref: http://www.xkcd.com/1163)
+ $dir = new PhpCodeFilterIterator(
+ new GalleryCodeFilterIterator(
+ new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator(DOCROOT))));
+ foreach ($dir as $file) {
+ $scan = 0;
+ if (basename(dirname($file)) == "tests") {
+ foreach (file($file) as $line) {
+ if (!substr($file, -9, 9) == "_Test.php") {
+ continue;
+ }
+
+ if (preg_match("/class.*extends.*Gallery_Unit_Test_Case/", $line)) {
+ $scan = 1;
+ } else if (preg_match("/class.*extends/", $line)) {
+ $scan = 0;
+ }
+
+ if ($scan) {
+ if (preg_match("/^\s*public\s+function/", $line)) {
+ $this->assert_true(
+ preg_match("/^\s*public\s+function (setup|teardown|.*_test)\(\) {/", $line),
+ "public functions must end in _test:\n$file\n$line\n");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public function no_extra_spaces_at_end_of_line_test() {
+ $dir = new GalleryCodeFilterIterator(
+ new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT)));
+ $errors = "";
+ foreach ($dir as $file) {
+ if (preg_match("/\.(php|css|html|js)$/", $file)) {
+ foreach (file($file) as $line_num => $line) {
+ if ((substr($line, -2) == " \n") || (substr($line, -1) == " ")) {
+ $errors .= "$file at line " . ($line_num + 1) . "\n";
+ }
+ }
+ }
+ }
+ $this->assert_true(empty($errors), "Extra spaces at end of line found at:\n$errors");
+ }
}
diff --git a/modules/gallery/tests/Gallery_Filters.php b/modules/gallery/tests/Gallery_Filters.php
index 73bc6284..6c2a6aa3 100644
--- a/modules/gallery/tests/Gallery_Filters.php
+++ b/modules/gallery/tests/Gallery_Filters.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@ class PhpCodeFilterIterator extends FilterIterator {
class GalleryCodeFilterIterator extends FilterIterator {
public function accept() {
- // Skip anything that we didn"t write
+ // Skip anything that we didn't write
$path_name = $this->getInnerIterator()->getPathName();
$file_name = $this->getInnerIterator()->getFileName();
return !(
@@ -47,6 +47,10 @@ class GalleryCodeFilterIterator extends FilterIterator {
strpos($path_name, SYSPATH) !== false ||
strpos($path_name, MODPATH . "gallery/libraries/HTMLPurifier") !== false ||
strpos($path_name, MODPATH . "gallery/vendor/joomla") !== false ||
+ strpos($path_name, MODPATH . "organize/vendor/ext") !== false ||
+ strpos($path_name, DOCROOT . "lib") !== false ||
+ strpos($path_name, DOCROOT . "themes/admin_wind/css/themeroller") !== false ||
+ strpos($path_name, DOCROOT . "themes/wind/css/themeroller") !== false ||
substr($path_name, -1, 1) == "~");
}
}
diff --git a/modules/gallery/tests/Gallery_Graphics_Helper_Test.php b/modules/gallery/tests/Gallery_Graphics_Helper_Test.php
new file mode 100644
index 00000000..20096b23
--- /dev/null
+++ b/modules/gallery/tests/Gallery_Graphics_Helper_Test.php
@@ -0,0 +1,137 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Gallery_Graphics_Helper_Test extends Gallery_Unit_Test_Case {
+ public function rotate_jpg_test() {
+ // Input is a 1024x768 jpg, output is rotated 90 degrees
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ $options = array("degrees" => 90);
+ gallery_graphics::rotate($input_file, $output_file, $options, null);
+
+ // Output is rotated to 768x1024 jpg
+ $this->assert_equal(array(768, 1024, "image/jpeg", "jpg"), photo::get_file_metadata($output_file));
+ }
+
+ public function rotate_jpg_without_options_test() {
+ // Input is a 1024x768 jpg, output options undefined
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ gallery_graphics::rotate($input_file, $output_file, null, null);
+
+ // Output is not rotated, still a 1024x768 jpg
+ $this->assert_equal(array(1024, 768, "image/jpeg", "jpg"), photo::get_file_metadata($output_file));
+ }
+
+ public function rotate_bad_jpg_test() {
+ // Input is a garbled jpg, output is jpg autofit to 300x300
+ $input_file = TMPPATH . test::random_name() . ".jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ $options = array("degrees" => 90);
+ file_put_contents($input_file, test::lorem_ipsum(200));
+
+ // Should get passed to Image library and throw an exception
+ try {
+ gallery_graphics::rotate($input_file, $output_file, $options, null);
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function resize_jpg_test() {
+ // Input is a 1024x768 jpg, output is jpg autofit to 300x300
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ $options = array("width" => 300, "height" => 300, "master" => Image::AUTO);
+ gallery_graphics::resize($input_file, $output_file, $options, null);
+
+ // Output is resized to 300x225 jpg
+ $this->assert_equal(array(300, 225, "image/jpeg", "jpg"), photo::get_file_metadata($output_file));
+ }
+
+ public function resize_jpg_to_png_test() {
+ // Input is a 1024x768 jpg, output is png autofit to 300x300
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".png";
+ $options = array("width" => 300, "height" => 300, "master" => Image::AUTO);
+ gallery_graphics::resize($input_file, $output_file, $options, null);
+
+ // Output is resized to 300x225 png
+ $this->assert_equal(array(300, 225, "image/png", "png"), photo::get_file_metadata($output_file));
+ }
+
+ public function resize_jpg_with_no_upscale_test() {
+ // Input is a 1024x768 jpg, output is jpg autofit to 1200x1200 - should not upscale
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ $options = array("width" => 1200, "height" => 1200, "master" => Image::AUTO);
+ gallery_graphics::resize($input_file, $output_file, $options, null);
+
+ // Output is copied directly from input
+ $this->assert_equal(file_get_contents($input_file), file_get_contents($output_file));
+ }
+
+ public function resize_jpg_to_png_with_no_upscale_test() {
+ // Input is a 1024x768 jpg, output is png autofit to 1200x1200 - should not upscale
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".png";
+ $options = array("width" => 1200, "height" => 1200, "master" => Image::AUTO);
+ gallery_graphics::resize($input_file, $output_file, $options, null);
+
+ // Output is converted from input without resize
+ $this->assert_equal(array(1024, 768, "image/png", "png"), photo::get_file_metadata($output_file));
+ }
+
+ public function resize_jpg_without_options_test() {
+ // Input is a 1024x768 jpg, output is jpg without options - should not attempt resize
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ gallery_graphics::resize($input_file, $output_file, null, null);
+
+ // Output is copied directly from input
+ $this->assert_equal(file_get_contents($input_file), file_get_contents($output_file));
+ }
+
+ public function resize_jpg_to_png_without_options_test() {
+ // Input is a 1024x768 jpg, output is png without options - should not attempt resize
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".png";
+ gallery_graphics::resize($input_file, $output_file, null, null);
+
+ // Output is converted from input without resize
+ $this->assert_equal(array(1024, 768, "image/png", "png"), photo::get_file_metadata($output_file));
+ }
+
+ public function resize_bad_jpg_test() {
+ // Input is a garbled jpg, output is jpg autofit to 300x300
+ $input_file = TMPPATH . test::random_name() . ".jpg";
+ $output_file = TMPPATH . test::random_name() . ".jpg";
+ $options = array("width" => 300, "height" => 300, "master" => Image::AUTO);
+ file_put_contents($input_file, test::lorem_ipsum(200));
+
+ // Should get passed to Image library and throw an exception
+ try {
+ gallery_graphics::resize($input_file, $output_file, $options, null);
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/tests/Gallery_I18n_Test.php b/modules/gallery/tests/Gallery_I18n_Test.php
index c54f324f..e255c4b9 100644
--- a/modules/gallery/tests/Gallery_I18n_Test.php
+++ b/modules/gallery/tests/Gallery_I18n_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Gallery_Installer_Test.php b/modules/gallery/tests/Gallery_Installer_Test.php
index f5043fb0..0764a4fa 100644
--- a/modules/gallery/tests/Gallery_Installer_Test.php
+++ b/modules/gallery/tests/Gallery_Installer_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Graphics_Helper_Test.php b/modules/gallery/tests/Graphics_Helper_Test.php
new file mode 100644
index 00000000..2cf5caa7
--- /dev/null
+++ b/modules/gallery/tests/Graphics_Helper_Test.php
@@ -0,0 +1,158 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Graphics_Helper_Test extends Gallery_Unit_Test_Case {
+ public function generate_photo_test() {
+ $photo = test::random_photo();
+ // Check that the images were correctly resized
+ $this->assert_equal(array(640, 480, "image/jpeg", "jpg"),
+ photo::get_file_metadata($photo->resize_path()));
+ $this->assert_equal(array(200, 150, "image/jpeg", "jpg"),
+ photo::get_file_metadata($photo->thumb_path()));
+ // Check that the items table got updated
+ $this->assert_equal(array(640, 480), array($photo->resize_width, $photo->resize_height));
+ $this->assert_equal(array(200, 150), array($photo->thumb_width, $photo->thumb_height));
+ // Check that the images are not marked dirty
+ $this->assert_equal(0, $photo->resize_dirty);
+ $this->assert_equal(0, $photo->thumb_dirty);
+ }
+
+ public function generate_movie_test() {
+ $movie = test::random_movie();
+ // Check that the image was correctly resized
+ $this->assert_equal(array(200, 160, "image/jpeg", "jpg"),
+ photo::get_file_metadata($movie->thumb_path()));
+ // Check that the items table got updated
+ $this->assert_equal(array(200, 160), array($movie->thumb_width, $movie->thumb_height));
+ // Check that the image is not marked dirty
+ $this->assert_equal(0, $movie->thumb_dirty);
+ }
+
+ public function generate_album_cover_test() {
+ $album = test::random_album();
+ $photo = test::random_unique_photo($album);
+ $album->reload();
+ // Check that the image was copied directly from item thumb
+ $this->assert_equal(file_get_contents($photo->thumb_path()),
+ file_get_contents($album->thumb_path()));
+ // Check that the items table got updated
+ $this->assert_equal(array(200, 150), array($album->thumb_width, $album->thumb_height));
+ // Check that the image is not marked dirty
+ $this->assert_equal(0, $album->thumb_dirty);
+ }
+
+ public function generate_album_cover_from_png_test() {
+ $input_file = MODPATH . "gallery/tests/test.jpg";
+ $output_file = TMPPATH . test::random_name() . ".png";
+ gallery_graphics::resize($input_file, $output_file, null, null);
+
+ $album = test::random_album();
+ $photo = test::random_photo_unsaved($album);
+ $photo->set_data_file($output_file);
+ $photo->name = "album_cover_from_png.png";
+ $photo->save();
+ $album->reload();
+ // Check that the image was correctly resized and converted to jpg
+ $this->assert_equal(array(200, 150, "image/jpeg", "jpg"),
+ photo::get_file_metadata($album->thumb_path()));
+ // Check that the items table got updated
+ $this->assert_equal(array(200, 150), array($album->thumb_width, $album->thumb_height));
+ // Check that the image is not marked dirty
+ $this->assert_equal(0, $album->thumb_dirty);
+ }
+
+ public function generate_album_cover_for_empty_album_test() {
+ $album = test::random_album();
+ // Check that the album cover is the missing image placeholder
+ $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_album_cover.jpg"),
+ file_get_contents($album->thumb_path()));
+ // Check that the items table got updated with new metadata
+ $this->assert_equal(array(200, 200), array($album->thumb_width, $album->thumb_height));
+ // Check that the image is *not* marked as dirty
+ $this->assert_equal(0, $album->thumb_dirty);
+ }
+
+ public function generate_bad_photo_test() {
+ $photo = test::random_photo();
+ // At this point, the photo is valid and has a valid resize and thumb. Make it garble.
+ file_put_contents($photo->file_path(), test::lorem_ipsum(200));
+ // Regenerate
+ $photo->resize_dirty = 1;
+ $photo->thumb_dirty = 1;
+ try {
+ graphics::generate($photo);
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // Exception expected
+ }
+ // Check that the images got replaced with missing image placeholders
+ $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_photo.jpg"),
+ file_get_contents($photo->resize_path()));
+ $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_photo.jpg"),
+ file_get_contents($photo->thumb_path()));
+ // Check that the items table got updated with new metadata
+ $this->assert_equal(array(200, 200), array($photo->resize_width, $photo->resize_height));
+ $this->assert_equal(array(200, 200), array($photo->thumb_width, $photo->thumb_height));
+ // Check that the images are marked as dirty
+ $this->assert_equal(1, $photo->resize_dirty);
+ $this->assert_equal(1, $photo->thumb_dirty);
+ }
+
+ public function generate_bad_movie_test() {
+ // Unlike photos, its ok to have missing movies - no thrown exceptions, thumb_dirty can be reset.
+ $movie = test::random_movie();
+ // At this point, the movie is valid and has a valid thumb. Make it garble.
+ file_put_contents($movie->file_path(), test::lorem_ipsum(200));
+ // Regenerate
+ $movie->thumb_dirty = 1;
+ graphics::generate($movie);
+ // Check that the image got replaced with a missing image placeholder
+ $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_movie.jpg"),
+ file_get_contents($movie->thumb_path()));
+ // Check that the items table got updated with new metadata
+ $this->assert_equal(array(200, 200), array($movie->thumb_width, $movie->thumb_height));
+ // Check that the image is *not* marked as dirty
+ $this->assert_equal(0, $movie->thumb_dirty);
+ }
+
+ public function generate_album_cover_from_bad_photo_test() {
+ $album = test::random_album();
+ $photo = test::random_photo($album);
+ $album->reload();
+ // At this point, the photo is valid and has a valid resize and thumb. Make it garble.
+ file_put_contents($photo->file_path(), test::lorem_ipsum(200));
+ // Regenerate album from garbled photo.
+ $photo->thumb_dirty = 1;
+ $photo->save();
+ $album->thumb_dirty = 1;
+ try {
+ graphics::generate($album);
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // Exception expected
+ }
+ // Check that the image got replaced with a missing image placeholder
+ $this->assert_same(file_get_contents(MODPATH . "gallery/images/missing_photo.jpg"),
+ file_get_contents($album->thumb_path()));
+ // Check that the items table got updated with new metadata
+ $this->assert_equal(array(200, 200), array($album->thumb_width, $album->thumb_height));
+ // Check that the images are marked as dirty
+ $this->assert_equal(1, $album->thumb_dirty);
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/tests/Html_Helper_Test.php b/modules/gallery/tests/Html_Helper_Test.php
index 09168e41..476faa5a 100644
--- a/modules/gallery/tests/Html_Helper_Test.php
+++ b/modules/gallery/tests/Html_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Input_Library_Test.php b/modules/gallery/tests/Input_Library_Test.php
index 135c6647..039644ad 100644
--- a/modules/gallery/tests/Input_Library_Test.php
+++ b/modules/gallery/tests/Input_Library_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index 818c9a73..f5b99bec 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -235,4 +235,22 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
$level3b->id,
item::find_by_relative_url("{$level1->slug}/{$level2b->slug}/{$level3b->slug}")->id);
}
+
+ public function resequence_child_weights_test() {
+ $album = test::random_album_unsaved();
+ $album->sort_column = "id";
+ $album->save();
+
+ $photo1 = test::random_photo($album);
+ $photo2 = test::random_photo($album);
+ $this->assert_true($photo2->weight > $photo1->weight);
+
+ $album->reload();
+ $album->sort_order = "DESC";
+ $album->save();
+ item::resequence_child_weights($album);
+
+ $this->assert_equal(2, $photo1->reload()->weight);
+ $this->assert_equal(1, $photo2->reload()->weight);
+ }
}
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 8ae8a5dd..fcb5c2ad 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -66,12 +66,12 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
}
public function rename_photo_test() {
- $item = test::random_photo();
+ $item = test::random_unique_photo();
$original_name = $item->name;
- file_put_contents($item->thumb_path(), "thumb");
- file_put_contents($item->resize_path(), "resize");
- file_put_contents($item->file_path(), "file");
+ $thumb_file = file_get_contents($item->thumb_path());
+ $resize_file = file_get_contents($item->resize_path());
+ $fullsize_file = file_get_contents($item->file_path());
// Now rename it
$item->name = ($new_name = test::random_name($item));
@@ -82,19 +82,19 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_equal($new_name, basename($item->file_path()));
$this->assert_equal($new_name, basename($item->thumb_path()));
$this->assert_equal($new_name, basename($item->resize_path()));
- $this->assert_equal("thumb", file_get_contents($item->thumb_path()));
- $this->assert_equal("resize", file_get_contents($item->resize_path()));
- $this->assert_equal("file", file_get_contents($item->file_path()));
+ $this->assert_equal($thumb_file, file_get_contents($item->thumb_path()));
+ $this->assert_equal($resize_file, file_get_contents($item->resize_path()));
+ $this->assert_equal($fullsize_file, file_get_contents($item->file_path()));
}
public function rename_album_test() {
$album = test::random_album();
- $photo = test::random_photo($album);
+ $photo = test::random_unique_photo($album);
$album->reload();
- file_put_contents($photo->thumb_path(), "thumb");
- file_put_contents($photo->resize_path(), "resize");
- file_put_contents($photo->file_path(), "file");
+ $thumb_file = file_get_contents($photo->thumb_path());
+ $resize_file = file_get_contents($photo->resize_path());
+ $fullsize_file = file_get_contents($photo->file_path());
$original_album_name = $album->name;
$original_photo_name = $photo->name;
@@ -119,44 +119,26 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(test::starts_with($photo->thumb_path(), dirname($album->thumb_path())));
$this->assert_true(test::starts_with($photo->resize_path(), dirname($album->resize_path())));
- $this->assert_equal("thumb", file_get_contents($photo->thumb_path()));
- $this->assert_equal("resize", file_get_contents($photo->resize_path()));
- $this->assert_equal("file", file_get_contents($photo->file_path()));
+ $this->assert_equal($thumb_file, file_get_contents($photo->thumb_path()));
+ $this->assert_equal($resize_file, file_get_contents($photo->resize_path()));
+ $this->assert_equal($fullsize_file, file_get_contents($photo->file_path()));
}
public function item_rename_wont_accept_slash_test() {
$item = test::random_photo();
- try {
- $item->name = test::random_name() . "/";
- $item->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_equal(array("name" => "no_slashes"), $e->validation->errors());
- return;
- }
- $this->assert_true(false, "Shouldn't get here");
- }
-
- public function item_rename_over_existing_name_gets_uniqified_test() {
- // Create a test photo
- $item = test::random_photo();
- $item2 = test::random_photo();
-
- $item->name = $item2->name;
+ $item->name = "/no_slashes/allowed/";
$item->save();
-
- // foo.jpg should become foo-####.jpg
- $this->assert_true(
- preg_match("/" . str_replace(".jpg", "", $item2->name) . "-\d+\.jpg/", $item->name));
+ $this->assert_equal("no_slashes_allowed.jpg", $item->name);
}
public function move_album_test() {
$album2 = test::random_album();
$album1 = test::random_album($album2);
- $photo = test::random_photo($album1);
+ $photo = test::random_unique_photo($album1);
- file_put_contents($photo->thumb_path(), "thumb");
- file_put_contents($photo->resize_path(), "resize");
- file_put_contents($photo->file_path(), "file");
+ $thumb_file = file_get_contents($photo->thumb_path());
+ $resize_file = file_get_contents($photo->resize_path());
+ $fullsize_file = file_get_contents($photo->file_path());
// Now move the album
$album1->parent_id = item::root()->id;
@@ -173,20 +155,20 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(test::starts_with($photo->thumb_path(), dirname($album1->thumb_path())));
$this->assert_true(test::starts_with($photo->resize_path(), dirname($album1->resize_path())));
- $this->assert_equal("thumb", file_get_contents($photo->thumb_path()));
- $this->assert_equal("resize", file_get_contents($photo->resize_path()));
- $this->assert_equal("file", file_get_contents($photo->file_path()));
+ $this->assert_equal($thumb_file, file_get_contents($photo->thumb_path()));
+ $this->assert_equal($resize_file, file_get_contents($photo->resize_path()));
+ $this->assert_equal($fullsize_file, file_get_contents($photo->file_path()));
}
public function move_photo_test() {
$album1 = test::random_album();
- $photo = test::random_photo($album1);
+ $photo = test::random_unique_photo($album1);
$album2 = test::random_album();
- file_put_contents($photo->thumb_path(), "thumb");
- file_put_contents($photo->resize_path(), "resize");
- file_put_contents($photo->file_path(), "file");
+ $thumb_file = file_get_contents($photo->thumb_path());
+ $resize_file = file_get_contents($photo->resize_path());
+ $fullsize_file = file_get_contents($photo->file_path());
// Now move the photo
$photo->parent_id = $album2->id;
@@ -200,12 +182,12 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(test::starts_with($photo->thumb_path(), dirname($album2->thumb_path())));
$this->assert_true(test::starts_with($photo->resize_path(), dirname($album2->resize_path())));
- $this->assert_equal("thumb", file_get_contents($photo->thumb_path()));
- $this->assert_equal("resize", file_get_contents($photo->resize_path()));
- $this->assert_equal("file", file_get_contents($photo->file_path()));
+ $this->assert_equal($thumb_file, file_get_contents($photo->thumb_path()));
+ $this->assert_equal($resize_file, file_get_contents($photo->resize_path()));
+ $this->assert_equal($fullsize_file, file_get_contents($photo->file_path()));
}
- public function move_album_with_conflicting_target_gets_uniqified_test() {
+ public function move_album_with_conflicting_target_gets_uniquified_test() {
$album = test::random_album();
$source = test::random_album_unsaved($album);
$source->name = $album->name;
@@ -217,9 +199,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$source->parent_id = item::root()->id;
$source->save();
- // foo should become foo-####
- $this->assert_true(preg_match("/{$album->name}-\d+/", $source->name));
- $this->assert_true(preg_match("/{$album->slug}-\d+/", $source->slug));
+ // foo should become foo-01
+ $this->assert_same("{$album->name}-01", $source->name);
+ $this->assert_same("{$album->slug}-01", $source->slug);
}
public function move_album_fails_wrong_target_type_test() {
@@ -239,7 +221,7 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(false, "Shouldn't get here");
}
- public function move_photo_with_conflicting_target_gets_uniqified_test() {
+ public function move_photo_with_conflicting_target_gets_uniquified_test() {
$photo1 = test::random_photo();
$album = test::random_album();
$photo2 = test::random_photo_unsaved($album);
@@ -247,17 +229,16 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$photo2->save();
// $photo1 and $photo2 have the same name, so if we move $photo1 into the root they should
- // conflict and get uniqified.
+ // conflict and get uniquified.
$photo2->parent_id = item::root()->id;
$photo2->save();
- // foo.jpg should become foo-####.jpg
- $this->assert_true(
- preg_match("/" . str_replace(".jpg", "", $photo1->name) . "-\d+\.jpg/", $photo2->name));
+ // foo.jpg should become foo-01.jpg
+ $this->assert_same(pathinfo($photo1->name, PATHINFO_FILENAME) . "-01.jpg", $photo2->name);
- // foo should become foo
- $this->assert_true(preg_match("/{$photo1->slug}/", $photo2->name));
+ // foo should become foo-01
+ $this->assert_same("{$photo1->slug}-01", $photo2->slug);
}
public function move_album_inside_descendent_fails_test() {
@@ -342,30 +323,17 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
}
public function photo_files_must_have_an_extension_test() {
- try {
- $photo = test::random_photo_unsaved();
- $photo->mime_type = "image/jpeg";
- $photo->name = "no_extension";
- $photo->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_same(array("name" => "illegal_data_file_extension"), $e->validation->errors());
- return; // pass
- }
- $this->assert_true(false, "Shouldn't get here");
+ $photo = test::random_photo_unsaved();
+ $photo->name = "no_extension_photo";
+ $photo->save();
+ $this->assert_equal("no_extension_photo.jpg", $photo->name);
}
public function movie_files_must_have_an_extension_test() {
- try {
- $movie = test::random_photo_unsaved();
- $movie->type = "movie";
- $movie->mime_type = "video/x-flv";
- $movie->name = "no_extension";
- $movie->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_same(array("name" => "illegal_data_file_extension"), $e->validation->errors());
- return; // pass
- }
- $this->assert_true(false, "Shouldn't get here");
+ $movie = test::random_movie_unsaved();
+ $movie->name = "no_extension_movie";
+ $movie->save();
+ $this->assert_equal("no_extension_movie.flv", $movie->name);
}
public function cant_delete_root_album_test() {
@@ -399,7 +367,16 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_false($response["can_edit"]);
}
- public function first_photo_becomes_album_cover() {
+ public function as_restful_array_with_add_bit_test() {
+ $response = item::root()->as_restful_array();
+ $this->assert_true($response["can_add"]);
+
+ identity::set_active_user(identity::guest());
+ $response = item::root()->as_restful_array();
+ $this->assert_false($response["can_add"]);
+ }
+
+ public function first_photo_becomes_album_cover_test() {
$album = test::random_album();
$photo = test::random_photo($album);
$album->reload();
@@ -450,8 +427,21 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$photo->set_data_file(MODPATH . "gallery/tests/Item_Model_Test.php");
$photo->save();
} catch (ORM_Validation_Exception $e) {
- $this->assert_same(array("mime_type" => "invalid", "name" => "illegal_data_file_extension"),
- $e->validation->errors());
+ $this->assert_same(array("name" => "invalid_data_file"), $e->validation->errors());
+ return; // pass
+ }
+ $this->assert_true(false, "Shouldn't get here");
+ }
+
+ public function unsafe_data_file_replacement_with_valid_extension_test() {
+ $temp_file = TMPPATH . "masquerading_php.jpg";
+ copy(MODPATH . "gallery/tests/Item_Model_Test.php", $temp_file);
+ try {
+ $photo = test::random_photo();
+ $photo->set_data_file($temp_file);
+ $photo->save();
+ } catch (ORM_Validation_Exception $e) {
+ $this->assert_same(array("name" => "invalid_data_file"), $e->validation->errors());
return; // pass
}
$this->assert_true(false, "Shouldn't get here");
@@ -469,55 +459,72 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
preg_match("|http://./var/albums/name_\w+\.jpg\?m=\d+|", $photo->file_url()),
$photo->file_url() . " is malformed");
- // Albums have special thumbnails. Empty album has cachebuster of 0 since it has no thumbnail
$album = test::random_album();
$this->assert_true(
- preg_match("|http://./var/thumbs/name_\w+/\.album\.jpg\?m=0|", $album->thumb_url()),
+ preg_match("|http://./var/thumbs/name_\w+/\.album\.jpg\?m=\d+|", $album->thumb_url()),
$album->thumb_url() . " is malformed");
$photo = test::random_photo($album);
$this->assert_true(
preg_match("|http://./var/thumbs/name_\w+/\.album\.jpg\?m=\d+|", $album->thumb_url()),
$album->thumb_url() . " is malformed");
+
+ // If the file does not exist, we should return a cache buster of m=0.
+ unlink($album->thumb_path());
+ $this->assert_true(
+ preg_match("|http://./var/thumbs/name_\w+/\.album\.jpg\?m=0|", $album->thumb_url()),
+ $album->thumb_url() . " is malformed");
}
- public function legal_extension_test() {
- foreach (array("test.gif", "test.GIF", "test.Gif", "test.jpeg", "test.JPG") as $name) {
+ public function legal_extension_that_does_match_gets_used_test() {
+ foreach (array("jpg", "JPG", "Jpg", "jpeg") as $extension) {
$photo = test::random_photo_unsaved(item::root());
- $photo->name = $name;
+ $photo->name = test::random_name() . ".{$extension}";
$photo->save();
+ // Should get renamed with the correct jpg extension of the data file.
+ $this->assert_equal($extension, pathinfo($photo->name, PATHINFO_EXTENSION));
}
}
public function illegal_extension_test() {
foreach (array("test.php", "test.PHP", "test.php5", "test.php4",
"test.pl", "test.php.png") as $name) {
- try {
- $photo = test::random_photo_unsaved(item::root());
- $photo->name = $name;
- $photo->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_equal(array("name" => "illegal_data_file_extension"),
- $e->validation->errors());
- continue;
- }
- $this->assert_true(false, "Shouldn't get here");
+ $photo = test::random_photo_unsaved(item::root());
+ $photo->name = $name;
+ $photo->save();
+ // Should get renamed with the correct jpg extension of the data file.
+ $this->assert_equal("jpg", pathinfo($photo->name, PATHINFO_EXTENSION));
}
}
public function cant_rename_to_illegal_extension_test() {
foreach (array("test.php.test", "test.php", "test.PHP",
"test.php5", "test.php4", "test.pl") as $name) {
- try {
- $photo = test::random_photo(item::root());
- $photo->name = $name;
- $photo->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_equal(array("name" => "illegal_data_file_extension"),
- $e->validation->errors());
- continue;
- }
- $this->assert_true(false, "Shouldn't get here");
+ $photo = test::random_photo(item::root());
+ $photo->name = $name;
+ $photo->save();
+ // Should get renamed with the correct jpg extension of the data file.
+ $this->assert_equal("jpg", pathinfo($photo->name, PATHINFO_EXTENSION));
+ }
+ }
+
+ public function legal_extension_that_doesnt_match_gets_fixed_test() {
+ foreach (array("test.png", "test.mp4", "test.GIF") as $name) {
+ $photo = test::random_photo_unsaved(item::root());
+ $photo->name = $name;
+ $photo->save();
+ // Should get renamed with the correct jpg extension of the data file.
+ $this->assert_equal("jpg", pathinfo($photo->name, PATHINFO_EXTENSION));
+ }
+ }
+
+ public function rename_to_legal_extension_that_doesnt_match_gets_fixed_test() {
+ foreach (array("test.png", "test.mp4", "test.GIF") as $name) {
+ $photo = test::random_photo(item::root());
+ $photo->name = $name;
+ $photo->save();
+ // Should get renamed with the correct jpg extension of the data file.
+ $this->assert_equal("jpg", pathinfo($photo->name, PATHINFO_EXTENSION));
}
}
@@ -526,4 +533,164 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$album->name = $album->name . ".foo.bar";
$album->save();
}
+
+ public function no_conflict_when_parents_different_test() {
+ $parent1 = test::random_album();
+ $parent2 = test::random_album();
+ $photo1 = test::random_photo($parent1);
+ $photo2 = test::random_photo($parent2);
+
+ $photo2->name = $photo1->name;
+ $photo2->slug = $photo1->slug;
+ $photo2->save();
+
+ // photo2 has same name and slug as photo1 but different parent - no conflict.
+ $this->assert_same($photo1->name, $photo2->name);
+ $this->assert_same($photo1->slug, $photo2->slug);
+ }
+
+ public function fix_conflict_when_names_identical_test() {
+ $parent = test::random_album();
+ $photo1 = test::random_photo($parent);
+ $photo2 = test::random_photo($parent);
+
+ $photo1_orig_base = pathinfo($photo1->name, PATHINFO_FILENAME);
+ $photo2_orig_slug = $photo2->slug;
+
+ $photo2->name = $photo1->name;
+ $photo2->save();
+
+ // photo2 has same name as photo1 - conflict resolved by renaming with -01.
+ $this->assert_same("{$photo1_orig_base}-01.jpg", $photo2->name);
+ $this->assert_same("{$photo2_orig_slug}-01", $photo2->slug);
+ }
+
+ public function fix_conflict_when_slugs_identical_test() {
+ $parent = test::random_album();
+ $photo1 = test::random_photo($parent);
+ $photo2 = test::random_photo($parent);
+
+ $photo2_orig_base = pathinfo($photo2->name, PATHINFO_FILENAME);
+
+ $photo2->slug = $photo1->slug;
+ $photo2->save();
+
+ // photo2 has same slug as photo1 - conflict resolved by renaming with -01.
+ $this->assert_same("{$photo2_orig_base}-01.jpg", $photo2->name);
+ $this->assert_same("{$photo1->slug}-01", $photo2->slug);
+ }
+
+ public function no_conflict_when_parents_different_for_albums_test() {
+ $parent1 = test::random_album();
+ $parent2 = test::random_album();
+ $album1 = test::random_album($parent1);
+ $album2 = test::random_album($parent2);
+
+ $album2->name = $album1->name;
+ $album2->slug = $album1->slug;
+ $album2->save();
+
+ // album2 has same name and slug as album1 but different parent - no conflict.
+ $this->assert_same($album1->name, $album2->name);
+ $this->assert_same($album1->slug, $album2->slug);
+ }
+
+ public function fix_conflict_when_names_identical_for_albums_test() {
+ $parent = test::random_album();
+ $album1 = test::random_album($parent);
+ $album2 = test::random_album($parent);
+
+ $album2_orig_slug = $album2->slug;
+
+ $album2->name = $album1->name;
+ $album2->save();
+
+ // album2 has same name as album1 - conflict resolved by renaming with -01.
+ $this->assert_same("{$album1->name}-01", $album2->name);
+ $this->assert_same("{$album2_orig_slug}-01", $album2->slug);
+ }
+
+ public function fix_conflict_when_slugs_identical_for_albums_test() {
+ $parent = test::random_album();
+ $album1 = test::random_album($parent);
+ $album2 = test::random_album($parent);
+
+ $album2_orig_name = $album2->name;
+
+ $album2->slug = $album1->slug;
+ $album2->save();
+
+ // album2 has same slug as album1 - conflict resolved by renaming with -01.
+ $this->assert_same("{$album2_orig_name}-01", $album2->name);
+ $this->assert_same("{$album1->slug}-01", $album2->slug);
+ }
+
+ public function no_conflict_when_base_names_identical_between_album_and_photo_test() {
+ $parent = test::random_album();
+ $album = test::random_album($parent);
+ $photo = test::random_photo($parent);
+
+ $photo_orig_slug = $photo->slug;
+
+ $photo->name = "{$album->name}.jpg";
+ $photo->save();
+
+ // photo has same base name as album - no conflict.
+ $this->assert_same("{$album->name}.jpg", $photo->name);
+ $this->assert_same($photo_orig_slug, $photo->slug);
+ }
+
+ public function fix_conflict_when_full_names_identical_between_album_and_photo_test() {
+ $parent = test::random_album();
+ $photo = test::random_photo($parent);
+ $album = test::random_album($parent);
+
+ $album_orig_slug = $album->slug;
+
+ $album->name = $photo->name;
+ $album->save();
+
+ // album has same full name as album - conflict resolved by renaming with -01.
+ $this->assert_same("{$photo->name}-01", $album->name);
+ $this->assert_same("{$album_orig_slug}-01", $album->slug);
+ }
+
+ public function fix_conflict_when_slugs_identical_between_album_and_photo_test() {
+ $parent = test::random_album();
+ $album = test::random_album($parent);
+ $photo = test::random_photo($parent);
+
+ $photo_orig_base = pathinfo($photo->name, PATHINFO_FILENAME);
+
+ $photo->slug = $album->slug;
+ $photo->save();
+
+ // photo has same slug as album - conflict resolved by renaming with -01.
+ $this->assert_same("{$photo_orig_base}-01.jpg", $photo->name);
+ $this->assert_same("{$album->slug}-01", $photo->slug);
+ }
+
+ public function fix_conflict_when_base_names_identical_between_jpg_png_flv_test() {
+ $parent = test::random_album();
+ $item1 = test::random_photo($parent);
+ $item2 = test::random_photo($parent);
+ $item3 = test::random_movie($parent);
+
+ $item1_orig_base = pathinfo($item1->name, PATHINFO_FILENAME);
+ $item2_orig_slug = $item2->slug;
+ $item3_orig_slug = $item3->slug;
+
+ $item2->set_data_file(MODPATH . "gallery/images/graphicsmagick.png");
+ $item2->name = "{$item1_orig_base}.png";
+ $item2->save();
+
+ $item3->name = "{$item1_orig_base}.flv";
+ $item3->save();
+
+ // item2 and item3 have same base name as item1 - conflict resolved by renaming with -01 and -02.
+ $this->assert_same("{$item1_orig_base}-01.png", $item2->name);
+ $this->assert_same("{$item2_orig_slug}-01", $item2->slug);
+ $this->assert_same("{$item1_orig_base}-02.flv", $item3->name);
+ $this->assert_same("{$item3_orig_slug}-02", $item3->slug);
+ }
}
diff --git a/modules/gallery/tests/Item_Rest_Helper_Test.php b/modules/gallery/tests/Item_Rest_Helper_Test.php
index 376f5c81..1823420b 100644
--- a/modules/gallery/tests/Item_Rest_Helper_Test.php
+++ b/modules/gallery/tests/Item_Rest_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php
index a719db70..9d8ee8a5 100644
--- a/modules/gallery/tests/Items_Rest_Helper_Test.php
+++ b/modules/gallery/tests/Items_Rest_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Kohana_Exception_Test.php b/modules/gallery/tests/Kohana_Exception_Test.php
index f8a89c0f..4836d0dd 100644
--- a/modules/gallery/tests/Kohana_Exception_Test.php
+++ b/modules/gallery/tests/Kohana_Exception_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Legal_File_Helper_Test.php b/modules/gallery/tests/Legal_File_Helper_Test.php
index d80bcafe..7ed5214b 100644
--- a/modules/gallery/tests/Legal_File_Helper_Test.php
+++ b/modules/gallery/tests/Legal_File_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,6 +18,85 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Legal_File_Helper_Test extends Gallery_Unit_Test_Case {
+ public function get_photo_types_by_extension_test() {
+ $this->assert_equal("image/jpeg", legal_file::get_photo_types_by_extension("jpg")); // regular
+ $this->assert_equal("image/jpeg", legal_file::get_photo_types_by_extension("JPG")); // all caps
+ $this->assert_equal("image/png", legal_file::get_photo_types_by_extension("Png")); // some caps
+ $this->assert_equal(null, legal_file::get_photo_types_by_extension("php")); // invalid
+ $this->assert_equal(null, legal_file::get_photo_types_by_extension("php.jpg")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(4, count(legal_file::get_photo_types_by_extension()));
+ }
+
+ public function get_movie_types_by_extension_test() {
+ $this->assert_equal("video/x-flv", legal_file::get_movie_types_by_extension("flv")); // regular
+ $this->assert_equal("video/x-flv", legal_file::get_movie_types_by_extension("FLV")); // all caps
+ $this->assert_equal("video/mp4", legal_file::get_movie_types_by_extension("Mp4")); // some caps
+ $this->assert_equal(null, legal_file::get_movie_types_by_extension("php")); // invalid
+ $this->assert_equal(null, legal_file::get_movie_types_by_extension("php.flv")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(3, count(legal_file::get_movie_types_by_extension()));
+ }
+
+ public function get_types_by_extension_test() {
+ $this->assert_equal("image/jpeg", legal_file::get_types_by_extension("jpg")); // photo
+ $this->assert_equal("video/x-flv", legal_file::get_types_by_extension("FLV")); // movie
+ $this->assert_equal(null, legal_file::get_types_by_extension("php")); // invalid
+ $this->assert_equal(null, legal_file::get_types_by_extension("php.flv")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(7, count(legal_file::get_types_by_extension()));
+ }
+
+ public function get_photo_extensions_test() {
+ $this->assert_equal(true, legal_file::get_photo_extensions("jpg")); // regular
+ $this->assert_equal(true, legal_file::get_photo_extensions("JPG")); // all caps
+ $this->assert_equal(true, legal_file::get_photo_extensions("Png")); // some caps
+ $this->assert_equal(false, legal_file::get_photo_extensions("php")); // invalid
+ $this->assert_equal(false, legal_file::get_photo_extensions("php.jpg")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(4, count(legal_file::get_photo_extensions()));
+ }
+
+ public function get_movie_extensions_test() {
+ $this->assert_equal(true, legal_file::get_movie_extensions("flv")); // regular
+ $this->assert_equal(true, legal_file::get_movie_extensions("FLV")); // all caps
+ $this->assert_equal(true, legal_file::get_movie_extensions("Mp4")); // some caps
+ $this->assert_equal(false, legal_file::get_movie_extensions("php")); // invalid
+ $this->assert_equal(false, legal_file::get_movie_extensions("php.jpg")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(3, count(legal_file::get_movie_extensions()));
+ }
+
+ public function get_extensions_test() {
+ $this->assert_equal(true, legal_file::get_extensions("jpg")); // photo
+ $this->assert_equal(true, legal_file::get_extensions("FLV")); // movie
+ $this->assert_equal(false, legal_file::get_extensions("php")); // invalid
+ $this->assert_equal(false, legal_file::get_extensions("php.jpg")); // invalid w/ .
+
+ // No extension returns full array
+ $this->assert_equal(7, count(legal_file::get_extensions()));
+ }
+
+ public function get_filters_test() {
+ // All 7 extensions both uppercase and lowercase
+ $this->assert_equal(14, count(legal_file::get_filters()));
+ }
+
+ public function get_photo_types_test() {
+ // Note that this is one *less* than photo extensions since jpeg and jpg have the same mime.
+ $this->assert_equal(3, count(legal_file::get_photo_types()));
+ }
+
+ public function get_movie_types_test() {
+ // Note that this is one *more* than movie extensions since video/flv is added.
+ $this->assert_equal(4, count(legal_file::get_movie_types()));
+ }
+
public function change_extension_test() {
$this->assert_equal("foo.jpg", legal_file::change_extension("foo.png", "jpg"));
}
@@ -36,13 +115,83 @@ class Legal_File_Helper_Test extends Gallery_Unit_Test_Case {
legal_file::change_extension("/website/foo.com/VID_20120513_105421.mp4", "jpg"));
}
+ public function change_extension_path_containing_dots_and_no_extension_test() {
+ $this->assert_equal(
+ "/website/foo.com/VID_20120513_105421.jpg",
+ legal_file::change_extension("/website/foo.com/VID_20120513_105421", "jpg"));
+ }
+
+ public function change_extension_path_containing_dots_and_dot_extension_test() {
+ $this->assert_equal(
+ "/website/foo.com/VID_20120513_105421.jpg",
+ legal_file::change_extension("/website/foo.com/VID_20120513_105421.", "jpg"));
+ }
+
+ public function change_extension_path_containing_dots_and_non_standard_chars_test() {
+ $this->assert_equal(
+ "/j'écris@un#nom/bizarre(mais quand.même/ça_passe.jpg",
+ legal_file::change_extension("/j'écris@un#nom/bizarre(mais quand.même/ça_passe.\$ÇÀ@€#_", "jpg"));
+ }
+
public function smash_extensions_test() {
$this->assert_equal("foo_bar.jpg", legal_file::smash_extensions("foo.bar.jpg"));
$this->assert_equal("foo_bar_baz.jpg", legal_file::smash_extensions("foo.bar.baz.jpg"));
- $this->assert_equal("foo_bar_baz.jpg", legal_file::smash_extensions("foo.bar.baz.jpg"));
$this->assert_equal("foo_bar_baz.jpg", legal_file::smash_extensions("...foo...bar..baz...jpg"));
$this->assert_equal("/path/to/foo_bar.jpg", legal_file::smash_extensions("/path/to/foo.bar.jpg"));
$this->assert_equal("/path/to.to/foo_bar.jpg", legal_file::smash_extensions("/path/to.to/foo.bar.jpg"));
$this->assert_equal("foo_bar-12345678.jpg", legal_file::smash_extensions("foo.bar-12345678.jpg"));
}
+
+ public function smash_extensions_pass_thru_names_without_extensions_test() {
+ $this->assert_equal("foo", legal_file::smash_extensions("foo"));
+ $this->assert_equal("foo.", legal_file::smash_extensions("foo."));
+ $this->assert_equal(".foo", legal_file::smash_extensions(".foo"));
+ $this->assert_equal(".", legal_file::smash_extensions("."));
+ $this->assert_equal("", legal_file::smash_extensions(""));
+ $this->assert_equal(null, legal_file::smash_extensions(null));
+ }
+
+ public function sanitize_filename_with_no_rename_test() {
+ $this->assert_equal("foo.jpeg", legal_file::sanitize_filename("foo.jpeg", "jpg", "photo"));
+ $this->assert_equal("foo.jpg", legal_file::sanitize_filename("foo.jpg", "jpeg", "photo"));
+ $this->assert_equal("foo.MP4", legal_file::sanitize_filename("foo.MP4", "mp4", "movie"));
+ $this->assert_equal("foo.mp4", legal_file::sanitize_filename("foo.mp4", "MP4", "movie"));
+ }
+
+ public function sanitize_filename_with_corrected_extension_test() {
+ $this->assert_equal("foo.jpg", legal_file::sanitize_filename("foo.png", "jpg", "photo"));
+ $this->assert_equal("foo.MP4", legal_file::sanitize_filename("foo.jpg", "MP4", "movie"));
+ $this->assert_equal("foo.jpg", legal_file::sanitize_filename("foo.php", "jpg", "photo"));
+ }
+
+ public function sanitize_filename_with_non_standard_chars_and_dots_test() {
+ $this->assert_equal("foo.jpg", legal_file::sanitize_filename("foo", "jpg", "photo"));
+ $this->assert_equal("foo.mp4", legal_file::sanitize_filename("foo.", "mp4", "movie"));
+ $this->assert_equal("foo.jpeg", legal_file::sanitize_filename(".foo.jpeg", "jpg", "photo"));
+ $this->assert_equal("foo_2013_02_10.jpeg",
+ legal_file::sanitize_filename("foo.2013/02/10.jpeg", "jpg", "photo"));
+ $this->assert_equal("foo_bar_baz.jpg",
+ legal_file::sanitize_filename("...foo...bar..baz...png", "jpg", "photo"));
+ $this->assert_equal("j'écris@un#nom_bizarre(mais quand_même_ça_passe.jpg",
+ legal_file::sanitize_filename("/j'écris@un#nom/bizarre(mais quand.même/ça_passe.\$ÇÀ@€#_", "jpg", "photo"));
+ }
+
+ public function sanitize_filename_with_no_base_name_test() {
+ $this->assert_equal("photo.jpg", legal_file::sanitize_filename(".png", "jpg", "photo"));
+ $this->assert_equal("movie.mp4", legal_file::sanitize_filename("__..__", "mp4", "movie"));
+ $this->assert_equal("photo.jpg", legal_file::sanitize_filename(".", "jpg", "photo"));
+ $this->assert_equal("movie.mp4", legal_file::sanitize_filename(null, "mp4", "movie"));
+ }
+
+ public function sanitize_filename_with_invalid_arguments_test() {
+ foreach (array("flv" => "photo", "jpg" => "movie", "php" => "photo",
+ null => "movie", "jpg" => "album", "jpg" => null) as $extension => $type) {
+ try {
+ legal_file::sanitize_filename("foo.jpg", $extension, $type);
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/modules/gallery/tests/Locales_Helper_Test.php b/modules/gallery/tests/Locales_Helper_Test.php
index 1d27312e..ff5b05d4 100644
--- a/modules/gallery/tests/Locales_Helper_Test.php
+++ b/modules/gallery/tests/Locales_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Menu_Test.php b/modules/gallery/tests/Menu_Test.php
index 85ada63b..1e251c1f 100644
--- a/modules/gallery/tests/Menu_Test.php
+++ b/modules/gallery/tests/Menu_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Movie_Helper_Test.php b/modules/gallery/tests/Movie_Helper_Test.php
new file mode 100644
index 00000000..03fa2da9
--- /dev/null
+++ b/modules/gallery/tests/Movie_Helper_Test.php
@@ -0,0 +1,105 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Movie_Helper_Test extends Gallery_Unit_Test_Case {
+ public function seconds_to_hhmmssdd_test() {
+ $times = array("00:00:00.50" => 0.5,
+ "00:00:06.00" => 6,
+ "00:00:59.99" => 59.999,
+ "00:01:00.00" => 60.001,
+ "00:07:00.00" => 7 * 60,
+ "00:45:19.00" => 45 * 60 + 19,
+ "03:45:19.00" => 3 * 3600 + 45 * 60 + 19,
+ "126:45:19.00" => 126 * 3600 + 45 * 60 + 19);
+ foreach ($times as $hhmmssdd => $seconds) {
+ $this->assert_equal($hhmmssdd, movie::seconds_to_hhmmssdd($seconds));
+ }
+ }
+
+ public function hhmmssdd_to_seconds_test() {
+ $times = array("0:00:00.01" => 0.01,
+ "00:00:00.50" => 0.5,
+ "00:00:06.00" => 6,
+ "00:00:59.99" => 59.99,
+ "00:01:00.00" => 60.00,
+ "00:07:00.00" => 7 * 60,
+ "00:45:19.00" => 45 * 60 + 19,
+ "03:45:19.00" => 3 * 3600 + 45 * 60 + 19,
+ "126:45:19.00" => 126 * 3600 + 45 * 60 + 19);
+ foreach ($times as $hhmmssdd => $seconds) {
+ $this->assert_equal($seconds, movie::hhmmssdd_to_seconds($hhmmssdd));
+ }
+ }
+
+ public function get_file_metadata_test() {
+ $movie = test::random_movie();
+ $this->assert_equal(array(360, 288, "video/x-flv", "flv", 6.00),
+ movie::get_file_metadata($movie->file_path()));
+ }
+
+ public function get_file_metadata_with_non_existent_file_test() {
+ try {
+ $metadata = movie::get_file_metadata(MODPATH . "gallery/tests/this_does_not_exist");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_no_extension_test() {
+ copy(MODPATH . "gallery/tests/test.flv", TMPPATH . "test_flv_with_no_extension");
+ // Since mime type and extension are based solely on the filename, this is considered invalid.
+ try {
+ $metadata = movie::get_file_metadata(TMPPATH . "test_flv_with_no_extension");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_illegal_extension_test() {
+ try {
+ $metadata = movie::get_file_metadata(MODPATH . "gallery/tests/Movie_Helper_Test.php");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_illegal_extension_but_valid_file_contents_test() {
+ copy(MODPATH . "gallery/tests/test.flv", TMPPATH . "test_flv_with_php_extension.php");
+ // Since mime type and extension are based solely on the filename, this is considered invalid.
+ try {
+ $metadata = movie::get_file_metadata(TMPPATH . "test_flv_with_php_extension.php");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_valid_extension_but_illegal_file_contents_test() {
+ copy(MODPATH . "gallery/tests/Photo_Helper_Test.php", TMPPATH . "test_php_with_flv_extension.flv");
+ // Since mime type and extension are based solely on the filename, this is considered valid.
+ // Of course, FFmpeg cannot extract width, height, or duration from the file. Note that this
+ // isn't a really a security problem, since the filename doesn't have a php extension and
+ // therefore will never be executed.
+ $this->assert_equal(array(0, 0, "video/x-flv", "flv", 0),
+ movie::get_file_metadata(TMPPATH . "test_php_with_flv_extension.flv"));
+ }
+}
diff --git a/modules/gallery/tests/Num_Helper_Test.php b/modules/gallery/tests/Num_Helper_Test.php
index a12e3fa3..2158d231 100644
--- a/modules/gallery/tests/Num_Helper_Test.php
+++ b/modules/gallery/tests/Num_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/ORM_MPTT_Test.php b/modules/gallery/tests/ORM_MPTT_Test.php
index 8f4e9fb1..7547f2a7 100644
--- a/modules/gallery/tests/ORM_MPTT_Test.php
+++ b/modules/gallery/tests/ORM_MPTT_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Photo_Helper_Test.php b/modules/gallery/tests/Photo_Helper_Test.php
new file mode 100644
index 00000000..79b5ccfd
--- /dev/null
+++ b/modules/gallery/tests/Photo_Helper_Test.php
@@ -0,0 +1,70 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Photo_Helper_Test extends Gallery_Unit_Test_Case {
+ public function get_file_metadata_test() {
+ $photo = test::random_photo();
+ $this->assert_equal(array(1024, 768, "image/jpeg", "jpg"),
+ photo::get_file_metadata($photo->file_path()));
+ }
+
+ public function get_file_metadata_with_non_existent_file_test() {
+ try {
+ $metadata = photo::get_file_metadata(MODPATH . "gallery/tests/this_does_not_exist");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_no_extension_test() {
+ copy(MODPATH . "gallery/tests/test.jpg", TMPPATH . "test_jpg_with_no_extension");
+ $this->assert_equal(array(1024, 768, "image/jpeg", "jpg"),
+ photo::get_file_metadata(TMPPATH . "test_jpg_with_no_extension"));
+ }
+
+ public function get_file_metadata_with_illegal_extension_test() {
+ try {
+ $metadata = photo::get_file_metadata(MODPATH . "gallery/tests/Photo_Helper_Test.php");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+
+ public function get_file_metadata_with_illegal_extension_but_valid_file_contents_test() {
+ // This ensures that we correctly "re-type" files with invalid extensions if the contents
+ // themselves are valid. This is needed to ensure that issues similar to those corrected by
+ // ticket #1855, where an image that looked valid (header said jpg) with a php extension was
+ // previously accepted without changing its extension, do not arise and cause security issues.
+ copy(MODPATH . "gallery/tests/test.jpg", TMPPATH . "test_jpg_with_php_extension.php");
+ $this->assert_equal(array(1024, 768, "image/jpeg", "jpg"),
+ photo::get_file_metadata(TMPPATH . "test_jpg_with_php_extension.php"));
+ }
+
+ public function get_file_metadata_with_valid_extension_but_illegal_file_contents_test() {
+ copy(MODPATH . "gallery/tests/Photo_Helper_Test.php", TMPPATH . "test_php_with_jpg_extension.jpg");
+ try {
+ $metadata = photo::get_file_metadata(TMPPATH . "test_php_with_jpg_extension.jpg");
+ $this->assert_true(false, "Shouldn't get here");
+ } catch (Exception $e) {
+ // pass
+ }
+ }
+}
diff --git a/modules/gallery/tests/Photos_Controller_Test.php b/modules/gallery/tests/Photos_Controller_Test.php
index 1587ebd7..a9c6a152 100644
--- a/modules/gallery/tests/Photos_Controller_Test.php
+++ b/modules/gallery/tests/Photos_Controller_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/SafeString_Test.php b/modules/gallery/tests/SafeString_Test.php
index fb4180e4..946410d4 100644
--- a/modules/gallery/tests/SafeString_Test.php
+++ b/modules/gallery/tests/SafeString_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Sendmail_Test.php b/modules/gallery/tests/Sendmail_Test.php
index 84d24083..9a687602 100644
--- a/modules/gallery/tests/Sendmail_Test.php
+++ b/modules/gallery/tests/Sendmail_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php
index d3295008..4ac12fde 100644
--- a/modules/gallery/tests/System_Helper_Test.php
+++ b/modules/gallery/tests/System_Helper_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Url_Security_Test.php b/modules/gallery/tests/Url_Security_Test.php
index ad07191b..3eb6276c 100644
--- a/modules/gallery/tests/Url_Security_Test.php
+++ b/modules/gallery/tests/Url_Security_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Valid_Test.php b/modules/gallery/tests/Valid_Test.php
index 82001b94..fc54547f 100644
--- a/modules/gallery/tests/Valid_Test.php
+++ b/modules/gallery/tests/Valid_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Var_Test.php b/modules/gallery/tests/Var_Test.php
index 6b050be6..97bccc35 100644
--- a/modules/gallery/tests/Var_Test.php
+++ b/modules/gallery/tests/Var_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/Xss_Security_Test.php b/modules/gallery/tests/Xss_Security_Test.php
index 4420b40c..6f78bb6f 100644
--- a/modules/gallery/tests/Xss_Security_Test.php
+++ b/modules/gallery/tests/Xss_Security_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt
index e35708c0..9473f9f6 100644
--- a/modules/gallery/tests/controller_auth_data.txt
+++ b/modules/gallery/tests/controller_auth_data.txt
@@ -25,6 +25,7 @@ modules/gallery/controllers/user_profile.php send
modules/gallery/controllers/welcome_message.php index DIRTY_AUTH
modules/organize/controllers/organize.php tree DIRTY_CSRF
modules/organize/controllers/organize.php delete DIRTY_AUTH
+modules/organize/controllers/organize.php tag DIRTY_AUTH
modules/rest/controllers/rest.php index DIRTY_CSRF|DIRTY_AUTH
modules/rest/controllers/rest.php reset_api_key_confirm DIRTY_AUTH
modules/rest/controllers/rest.php reset_api_key DIRTY_AUTH
@@ -35,6 +36,7 @@ modules/server_add/controllers/admin_server_add.php autocomplete
modules/server_add/controllers/server_add.php children DIRTY_CSRF
modules/tag/controllers/admin_tags.php index DIRTY_CSRF
modules/tag/controllers/tag.php __call DIRTY_CSRF|DIRTY_AUTH
+modules/tag/controllers/tag_name.php __call DIRTY_AUTH
modules/tag/controllers/tags.php autocomplete DIRTY_CSRF|DIRTY_AUTH
modules/user/controllers/admin_users.php index DIRTY_CSRF
modules/user/controllers/password.php reset DIRTY_AUTH
diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt
index 2bfacb47..51347f86 100644
--- a/modules/gallery/tests/xss_data.txt
+++ b/modules/gallery/tests/xss_data.txt
@@ -46,7 +46,6 @@ modules/exif/views/exif_dialog.html.php 21 DIRTY $detai
modules/g2_import/views/admin_g2_import.html.php 7 DIRTY_JS url::site("__ARGS__")
modules/g2_import/views/admin_g2_import.html.php 52 DIRTY $form
modules/gallery/views/admin_advanced_settings.html.php 21 DIRTY_ATTR text::alternate("g-odd","g-even")
-modules/gallery/views/admin_advanced_settings.html.php 22 DIRTY $var->module_name
modules/gallery/views/admin_block_log_entries.html.php 4 DIRTY_ATTR log::severity_class($entry->severity)
modules/gallery/views/admin_block_log_entries.html.php 8 DIRTY_JS user_profile::url($entry->user->id)
modules/gallery/views/admin_block_log_entries.html.php 10 DIRTY gallery::date_time($entry->timestamp)
@@ -223,10 +222,13 @@ modules/gallery/views/menu_dialog.html.php 5 DIRTY_JS $menu-
modules/gallery/views/menu_link.html.php 3 DIRTY $menu->css_id?"id='{$menu->css_id}'":""
modules/gallery/views/menu_link.html.php 4 DIRTY_ATTR $menu->css_class
modules/gallery/views/menu_link.html.php 5 DIRTY_JS $menu->url
-modules/gallery/views/movieplayer.html.php 2 DIRTY html::anchor($item->file_url(true),"",$attrs)
-modules/gallery/views/movieplayer.html.php 5 DIRTY_JS $attrs["id"]
-modules/gallery/views/movieplayer.html.php 7 DIRTY_JS url::abs_file("lib/flowplayer.swf")
-modules/gallery/views/movieplayer.html.php 17 DIRTY_JS url::abs_file("lib/flowplayer.pseudostreaming.swf")
+modules/gallery/views/movieplayer.html.php 2 DIRTY html::anchor($url,"",$attrs)
+modules/gallery/views/movieplayer.html.php 4 DIRTY_JS $attrs["id"]
+modules/gallery/views/movieplayer.html.php 5 DIRTY_JS $max_size
+modules/gallery/views/movieplayer.html.php 23 DIRTY_JS url::abs_file("lib/flowplayer.swf")
+modules/gallery/views/movieplayer.html.php 30 DIRTY_JS url::abs_file("lib/flowplayer.pseudostreaming-byterange.swf")
+modules/gallery/views/movieplayer.html.php 48 DIRTY_JS $width
+modules/gallery/views/movieplayer.html.php 48 DIRTY_JS $height
modules/gallery/views/permissions_browse.html.php 3 DIRTY_JS url::site("permissions/form/__ITEM__")
modules/gallery/views/permissions_browse.html.php 16 DIRTY_JS url::site("permissions/change/__CMD__/__GROUP__/__PERM__/__ITEM__?csrf=$csrf")
modules/gallery/views/permissions_browse.html.php 43 DIRTY_ATTR $parent->id
@@ -293,19 +295,21 @@ modules/organize/views/organize_frame.html.php 12 DIRTY_JS url::f
modules/organize/views/organize_frame.html.php 56 DIRTY_JS url::site("organize/album_info/__ID__")
modules/organize/views/organize_frame.html.php 94 DIRTY_JS access::csrf_token()
modules/organize/views/organize_frame.html.php 96 DIRTY_JS url::site("organize/set_sort/__ID__")
-modules/organize/views/organize_frame.html.php 116 DIRTY_JS url::site("organize/delete")
-modules/organize/views/organize_frame.html.php 125 DIRTY_JS access::csrf_token()
-modules/organize/views/organize_frame.html.php 238 DIRTY_JS url::site("organize/rearrange")
-modules/organize/views/organize_frame.html.php 249 DIRTY_JS access::csrf_token()
-modules/organize/views/organize_frame.html.php 287 DIRTY_JS $key
-modules/organize/views/organize_frame.html.php 410 DIRTY_JS url::site("organize/tree/{$album->id}")
-modules/organize/views/organize_frame.html.php 468 DIRTY_JS url::site("organize/reparent")
-modules/organize/views/organize_frame.html.php 491 DIRTY_JS access::csrf_token()
-modules/organize/views/organize_frame.html.php 507 DIRTY_JS access::can("edit",item::root())
-modules/organize/views/organize_frame.html.php 509 DIRTY_JS html::clean(item::root()->title)
-modules/organize/views/organize_frame.html.php 511 DIRTY_JS item::root()->id
-modules/organize/views/organize_frame.html.php 519 DIRTY_JS $album->id
-modules/organize/views/organize_frame.html.php 520 DIRTY_JS $album->id
+modules/organize/views/organize_frame.html.php 116 DIRTY_JS url::site("organize/tag")
+modules/organize/views/organize_frame.html.php 126 DIRTY_JS access::csrf_token()
+modules/organize/views/organize_frame.html.php 140 DIRTY_JS url::site("organize/delete")
+modules/organize/views/organize_frame.html.php 149 DIRTY_JS access::csrf_token()
+modules/organize/views/organize_frame.html.php 264 DIRTY_JS url::site("organize/rearrange")
+modules/organize/views/organize_frame.html.php 275 DIRTY_JS access::csrf_token()
+modules/organize/views/organize_frame.html.php 314 DIRTY_JS $key
+modules/organize/views/organize_frame.html.php 476 DIRTY_JS url::site("organize/tree/{$album->id}")
+modules/organize/views/organize_frame.html.php 534 DIRTY_JS url::site("organize/reparent")
+modules/organize/views/organize_frame.html.php 557 DIRTY_JS access::csrf_token()
+modules/organize/views/organize_frame.html.php 573 DIRTY_JS access::can("edit",item::root())
+modules/organize/views/organize_frame.html.php 575 DIRTY_JS html::clean(item::root()->title)
+modules/organize/views/organize_frame.html.php 577 DIRTY_JS item::root()->id
+modules/organize/views/organize_frame.html.php 585 DIRTY_JS $album->id
+modules/organize/views/organize_frame.html.php 586 DIRTY_JS $album->id
modules/recaptcha/views/admin_recaptcha.html.php 11 DIRTY $form
modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY_JS $public_key
modules/recaptcha/views/form_recaptcha.html.php 3 DIRTY_ATTR request::protocol()
@@ -338,11 +342,13 @@ modules/rss/views/feed.mrss.php 67 DIRTY_ATTR $ite
modules/rss/views/feed.mrss.php 68 DIRTY_ATTR $item->height
modules/rss/views/feed.mrss.php 69 DIRTY_ATTR $item->width
modules/rss/views/rss_block.html.php 6 DIRTY_JS rss::url($url)
-modules/search/views/search.html.php 27 DIRTY_ATTR $item_class
-modules/search/views/search.html.php 28 DIRTY_JS $item->url()
-modules/search/views/search.html.php 29 DIRTY $item->thumb_img(array("class"=>"g-thumbnail"))
-modules/search/views/search.html.php 31 DIRTY_ATTR $item_class
-modules/search/views/search.html.php 41 DIRTY $theme->paginator()
+modules/search/views/search.html.php 39 DIRTY_ATTR $item_class
+modules/search/views/search.html.php 40 DIRTY_JS $item->url()
+modules/search/views/search.html.php 41 DIRTY $item->thumb_img(array("class"=>"g-thumbnail"))
+modules/search/views/search.html.php 43 DIRTY_ATTR $item_class
+modules/search/views/search.html.php 53 DIRTY $theme->paginator()
+modules/search/views/search_link.html.php 14 DIRTY_ATTR $item->id
+modules/search/views/search_link.html.php 16 DIRTY_ATTR $item->parent_id
modules/server_add/views/admin_server_add.html.php 8 DIRTY_JS url::site("__ARGS__")
modules/server_add/views/admin_server_add.html.php 19 DIRTY $form
modules/server_add/views/admin_server_add.html.php 30 DIRTY_ATTR $id
@@ -378,22 +384,22 @@ modules/user/views/admin_users_group.html.php 24 DIRTY_JS $group
modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $width
modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $height
modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $url
-themes/admin_wind/views/admin.html.php 5 DIRTY $theme->html_attributes()
-themes/admin_wind/views/admin.html.php 35 DIRTY $theme->admin_head()
-themes/admin_wind/views/admin.html.php 47 DIRTY_JS $theme->url()
-themes/admin_wind/views/admin.html.php 52 DIRTY $theme->get_combined("css")
-themes/admin_wind/views/admin.html.php 55 DIRTY $theme->get_combined("script")
-themes/admin_wind/views/admin.html.php 59 DIRTY $theme->admin_page_top()
-themes/admin_wind/views/admin.html.php 67 DIRTY $theme->admin_header_top()
-themes/admin_wind/views/admin.html.php 68 DIRTY_JS item::root()->url()
-themes/admin_wind/views/admin.html.php 71 DIRTY $theme->user_menu()
-themes/admin_wind/views/admin.html.php 74 DIRTY $theme->admin_menu()
-themes/admin_wind/views/admin.html.php 77 DIRTY $theme->admin_header_bottom()
-themes/admin_wind/views/admin.html.php 84 DIRTY $content
-themes/admin_wind/views/admin.html.php 90 DIRTY $sidebar
-themes/admin_wind/views/admin.html.php 95 DIRTY $theme->admin_footer()
-themes/admin_wind/views/admin.html.php 98 DIRTY $theme->admin_credits()
-themes/admin_wind/views/admin.html.php 103 DIRTY $theme->admin_page_bottom()
+themes/admin_wind/views/admin.html.php 4 DIRTY $theme->html_attributes()
+themes/admin_wind/views/admin.html.php 34 DIRTY $theme->admin_head()
+themes/admin_wind/views/admin.html.php 46 DIRTY_JS $theme->url()
+themes/admin_wind/views/admin.html.php 51 DIRTY $theme->get_combined("css")
+themes/admin_wind/views/admin.html.php 54 DIRTY $theme->get_combined("script")
+themes/admin_wind/views/admin.html.php 58 DIRTY $theme->admin_page_top()
+themes/admin_wind/views/admin.html.php 66 DIRTY $theme->admin_header_top()
+themes/admin_wind/views/admin.html.php 67 DIRTY_JS item::root()->url()
+themes/admin_wind/views/admin.html.php 70 DIRTY $theme->user_menu()
+themes/admin_wind/views/admin.html.php 73 DIRTY $theme->admin_menu()
+themes/admin_wind/views/admin.html.php 76 DIRTY $theme->admin_header_bottom()
+themes/admin_wind/views/admin.html.php 83 DIRTY $content
+themes/admin_wind/views/admin.html.php 89 DIRTY $sidebar
+themes/admin_wind/views/admin.html.php 94 DIRTY $theme->admin_footer()
+themes/admin_wind/views/admin.html.php 97 DIRTY $theme->admin_credits()
+themes/admin_wind/views/admin.html.php 102 DIRTY $theme->admin_page_bottom()
themes/admin_wind/views/block.html.php 3 DIRTY_ATTR $anchor
themes/admin_wind/views/block.html.php 5 DIRTY $id
themes/admin_wind/views/block.html.php 5 DIRTY_ATTR $css_id
@@ -423,23 +429,23 @@ themes/wind/views/dynamic.html.php 17 DIRTY_ATTR $chi
themes/wind/views/dynamic.html.php 29 DIRTY $theme->paginator()
themes/wind/views/movie.html.php 5 DIRTY $theme->paginator()
themes/wind/views/movie.html.php 9 DIRTY $item->movie_img(array("class"=>"g-movie","id"=>"g-item-id-{$item->id}"))
-themes/wind/views/page.html.php 5 DIRTY $theme->html_attributes()
-themes/wind/views/page.html.php 11 DIRTY $page_title
-themes/wind/views/page.html.php 33 DIRTY $new_width
-themes/wind/views/page.html.php 34 DIRTY $new_height
-themes/wind/views/page.html.php 35 DIRTY $thumb_proportion
-themes/wind/views/page.html.php 75 DIRTY_JS $theme->url()
-themes/wind/views/page.html.php 80 DIRTY $theme->get_combined("css")
-themes/wind/views/page.html.php 83 DIRTY $theme->get_combined("script")
-themes/wind/views/page.html.php 93 DIRTY $header_text
-themes/wind/views/page.html.php 95 DIRTY_JS item::root()->url()
-themes/wind/views/page.html.php 99 DIRTY $theme->user_menu()
-themes/wind/views/page.html.php 114 DIRTY_ATTR $breadcrumb->last?"g-active":""
-themes/wind/views/page.html.php 115 DIRTY_ATTR $breadcrumb->first?"g-first":""
-themes/wind/views/page.html.php 116 DIRTY_JS $breadcrumb->url
-themes/wind/views/page.html.php 129 DIRTY $content
-themes/wind/views/page.html.php 135 DIRTY newView("sidebar.html")
-themes/wind/views/page.html.php 142 DIRTY $footer_text
+themes/wind/views/page.html.php 4 DIRTY $theme->html_attributes()
+themes/wind/views/page.html.php 10 DIRTY $page_title
+themes/wind/views/page.html.php 32 DIRTY $new_width
+themes/wind/views/page.html.php 33 DIRTY $new_height
+themes/wind/views/page.html.php 34 DIRTY $thumb_proportion
+themes/wind/views/page.html.php 74 DIRTY_JS $theme->url()
+themes/wind/views/page.html.php 79 DIRTY $theme->get_combined("css")
+themes/wind/views/page.html.php 82 DIRTY $theme->get_combined("script")
+themes/wind/views/page.html.php 92 DIRTY $header_text
+themes/wind/views/page.html.php 94 DIRTY_JS item::root()->url()
+themes/wind/views/page.html.php 98 DIRTY $theme->user_menu()
+themes/wind/views/page.html.php 113 DIRTY_ATTR $breadcrumb->last?"g-active":""
+themes/wind/views/page.html.php 114 DIRTY_ATTR $breadcrumb->first?"g-first":""
+themes/wind/views/page.html.php 115 DIRTY_JS $breadcrumb->url
+themes/wind/views/page.html.php 128 DIRTY $content
+themes/wind/views/page.html.php 134 DIRTY newView("sidebar.html")
+themes/wind/views/page.html.php 141 DIRTY $footer_text
themes/wind/views/paginator.html.php 33 DIRTY_JS $first_page_url
themes/wind/views/paginator.html.php 42 DIRTY_JS $previous_page_url
themes/wind/views/paginator.html.php 70 DIRTY_JS $next_page_url