From d04080c7be7c8a06bd81a9747943600812339f40 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 17 Jan 2013 15:05:46 -0500 Subject: Follow-on to 94b26e506c339f50b8d094057bffc1877a79afa9 - make the new legal_file functions more robust when passed an unknown extension. Fixes Item_Model_Test. --- modules/gallery/helpers/legal_file.php | 14 +++++++++++--- modules/gallery/tests/Item_Model_Test.php | 2 +- modules/gallery_unit_test/helpers/test.php | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php index b3622764..e6f4cb54 100644 --- a/modules/gallery/helpers/legal_file.php +++ b/modules/gallery/helpers/legal_file.php @@ -19,7 +19,7 @@ */ class legal_file_Core { /** - * Create a default list of allowed photo MIME types paired with their extensions and then let + * Create a default list of allowed photo MIME types paired with their extensions and then let * modules modify it. This is an ordered map, mapping extensions to their MIME types. * Extensions cannot be duplicated, but MIMEs can (e.g. jpeg and jpg both map to image/jpeg). * @@ -32,7 +32,11 @@ class legal_file_Core { module::event("photo_types_by_extension", $types_by_extension_wrapper); if ($extension) { // return matching MIME type - return $types_by_extension_wrapper->types_by_extension[$extension]; + if (isset($types_by_extension_wrapper->types_by_extension[$extension])) { + return $types_by_extension_wrapper->types_by_extension[$extension]; + } else { + return null; + } } else { // return complete array return $types_by_extension_wrapper->types_by_extension; @@ -53,7 +57,11 @@ class legal_file_Core { module::event("movie_types_by_extension", $types_by_extension_wrapper); if ($extension) { // return matching MIME type - return $types_by_extension_wrapper->types_by_extension[$extension]; + if (isset($types_by_extension_wrapper->types_by_extension[$extension])) { + return $types_by_extension_wrapper->types_by_extension[$extension]; + } else { + return null; + } } else { // return complete array return $types_by_extension_wrapper->types_by_extension; diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index 8ae8a5dd..a3929e62 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -356,7 +356,7 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { public function movie_files_must_have_an_extension_test() { try { - $movie = test::random_photo_unsaved(); + $movie = test::random_movie_unsaved(); $movie->type = "movie"; $movie->mime_type = "video/x-flv"; $movie->name = "no_extension"; diff --git a/modules/gallery_unit_test/helpers/test.php b/modules/gallery_unit_test/helpers/test.php index 7fba0eda..8a2044a9 100644 --- a/modules/gallery_unit_test/helpers/test.php +++ b/modules/gallery_unit_test/helpers/test.php @@ -33,6 +33,21 @@ class test_Core { return test::random_album_unsaved($parent)->save()->reload(); } + static function random_movie_unsaved($parent=null) { + $rand = test::random_string(6); + $photo = ORM::factory("item"); + $photo->type = "movie"; + $photo->parent_id = $parent ? $parent->id : 1; + $photo->set_data_file(MODPATH . "gallery/tests/test.flv"); + $photo->name = "name_$rand.flv"; + $photo->title = "title_$rand"; + return $photo; + } + + static function random_movie($parent=null) { + return test::random_movie_unsaved($parent)->save()->reload(); + } + static function random_photo_unsaved($parent=null) { $rand = test::random_string(6); $photo = ORM::factory("item"); -- cgit v1.2.3 From 61724f78da98d192cc86db6b3a12cdac506a916e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 17 Jan 2013 15:22:50 -0500 Subject: Update golden files. --- modules/gallery/tests/controller_auth_data.txt | 1 + modules/gallery/tests/xss_data.txt | 90 ++++++++++++++------------ 2 files changed, 48 insertions(+), 43 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt index e35708c0..a7bc28dd 100644 --- a/modules/gallery/tests/controller_auth_data.txt +++ b/modules/gallery/tests/controller_auth_data.txt @@ -35,6 +35,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..7d77645d 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 @@ -338,11 +340,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 +382,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 +427,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 -- cgit v1.2.3 From 3a9009492e6d05fe657e3aacf34cf40ca3495db5 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Fri, 18 Jan 2013 20:06:05 +0100 Subject: #1943 - Make legal_file::change_extension more robust. Previously would fail with dots in the directory but no extension. Added unit tests to verify the new change works. --- modules/gallery/helpers/legal_file.php | 9 +++------ modules/gallery/tests/Legal_File_Helper_Test.php | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php index e6f4cb54..e24aca36 100644 --- a/modules/gallery/helpers/legal_file.php +++ b/modules/gallery/helpers/legal_file.php @@ -137,15 +137,12 @@ class legal_file_Core { } /** - * Convert the extension of a filename. If the original filename has no + * Change the extension of a filename. If the original filename has no * extension, add the new one to the end. */ static function change_extension($filename, $new_ext) { - if (strpos($filename, ".") === false) { - return "{$filename}.{$new_ext}"; - } else { - return preg_replace("/\.[^\.]*?$/", ".{$new_ext}", $filename); - } + $filename_no_ext = preg_replace("/\.[^\.\/]*?$/", "", $filename); + return "{$filename_no_ext}.{$new_ext}"; } /** diff --git a/modules/gallery/tests/Legal_File_Helper_Test.php b/modules/gallery/tests/Legal_File_Helper_Test.php index d80bcafe..d2813633 100644 --- a/modules/gallery/tests/Legal_File_Helper_Test.php +++ b/modules/gallery/tests/Legal_File_Helper_Test.php @@ -36,6 +36,24 @@ 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")); -- cgit v1.2.3 From e2a2a5ce812c249b46d56ed2f738162e3f4cd09b Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sat, 19 Jan 2013 00:52:13 +0100 Subject: #1944 - Fix possible warnings in legal_file::get_photo_types_by_extension and legal_file::get_movie_types_by_extension. Added unit tests for these two functions, too. --- modules/gallery/helpers/legal_file.php | 6 ++-- modules/gallery/tests/Legal_File_Helper_Test.php | 37 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php index e24aca36..70c07065 100644 --- a/modules/gallery/helpers/legal_file.php +++ b/modules/gallery/helpers/legal_file.php @@ -25,13 +25,14 @@ class legal_file_Core { * * @param string $extension (opt.) - return MIME of extension; if not given, return complete array */ - static function get_photo_types_by_extension($extension=NULL) { + static function get_photo_types_by_extension($extension=null) { $types_by_extension_wrapper = new stdClass(); $types_by_extension_wrapper->types_by_extension = array( "jpg" => "image/jpeg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png"); module::event("photo_types_by_extension", $types_by_extension_wrapper); if ($extension) { // return matching MIME type + $extension = strtolower($extension); if (isset($types_by_extension_wrapper->types_by_extension[$extension])) { return $types_by_extension_wrapper->types_by_extension[$extension]; } else { @@ -50,13 +51,14 @@ class legal_file_Core { * * @param string $extension (opt.) - return MIME of extension; if not given, return complete array */ - static function get_movie_types_by_extension($extension=NULL) { + static function get_movie_types_by_extension($extension=null) { $types_by_extension_wrapper = new stdClass(); $types_by_extension_wrapper->types_by_extension = array( "flv" => "video/x-flv", "mp4" => "video/mp4", "m4v" => "video/x-m4v"); module::event("movie_types_by_extension", $types_by_extension_wrapper); if ($extension) { // return matching MIME type + $extension = strtolower($extension); if (isset($types_by_extension_wrapper->types_by_extension[$extension])) { return $types_by_extension_wrapper->types_by_extension[$extension]; } else { diff --git a/modules/gallery/tests/Legal_File_Helper_Test.php b/modules/gallery/tests/Legal_File_Helper_Test.php index d2813633..66a5cc68 100644 --- a/modules/gallery/tests/Legal_File_Helper_Test.php +++ b/modules/gallery/tests/Legal_File_Helper_Test.php @@ -18,6 +18,43 @@ * 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() { + // Valid extensions return their corresponding mimes, invalid extensions return null + $tests = array("jpg" => "image/jpeg", + "JPG" => "image/jpeg", + "jpeg" => "image/jpeg", + "png" => "image/png", + "Png" => "image/png", + "gif" => "image/gif", + "tif" => null, + "mp4" => null, + "php" => null, + "php.jpg" => null); + foreach ($tests as $extension => $mime_type) { + $this->assert_equal($mime_type, legal_file::get_photo_types_by_extension($extension)); + } + // 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() { + // Valid extensions return their corresponding mimes, invalid extensions return null + $tests = array("flv" => "video/x-flv", + "FLV" => "video/x-flv", + "mp4" => "video/mp4", + "Mp4" => "video/mp4", + "m4v" => "video/x-m4v", + "avi" => null, + "jpg" => null, + "php" => null, + "php.flv" => null); + foreach ($tests as $extension => $mime_type) { + $this->assert_equal($mime_type, legal_file::get_movie_types_by_extension($extension)); + } + // No extension returns full array + $this->assert_equal(3, count(legal_file::get_movie_types_by_extension())); + } + public function change_extension_test() { $this->assert_equal("foo.jpg", legal_file::change_extension("foo.png", "jpg")); } -- cgit v1.2.3 From ea8219e1d462362985b526260cd71230a5db2afb Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sat, 19 Jan 2013 00:59:55 +0100 Subject: #1941, 1948 - Fix possible warnings in movie and graphics helpers, add functions to convert between seconds and hh:mm:ss.dd. Also add unit tests for new movie helper functions. --- modules/gallery/helpers/graphics.php | 2 +- modules/gallery/helpers/movie.php | 35 ++++++++++++++++----- modules/gallery/tests/Movie_Helper_Test.php | 49 +++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 modules/gallery/tests/Movie_Helper_Test.php (limited to 'modules') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index e7c5da68..c840b920 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -157,7 +157,7 @@ class graphics_Core { if ($input_item->is_movie()) { // Convert the movie filename to a JPG first, delete anything that might already be there $output_file = legal_file::change_extension($output_file, "jpg"); - unlink($output_file); + @unlink($output_file); // Run movie_extract_frame events, which can either: // - generate an output file, bypassing the ffmpeg-based movie::extract_frame // - add to the options sent to movie::extract_frame (e.g. change frame extract time, diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 6d70ab2d..3524a8f9 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -66,7 +66,7 @@ class movie_Core { * @param string $output_file * @param array $movie_options (optional) */ - static function extract_frame($input_file, $output_file, $movie_options=NULL) { + static function extract_frame($input_file, $output_file, $movie_options=null) { $ffmpeg = movie::find_ffmpeg(); if (empty($ffmpeg)) { throw new Exception("@todo MISSING_FFMPEG"); @@ -74,17 +74,17 @@ class movie_Core { list($width, $height, $mime_type, $extension, $duration) = movie::get_file_metadata($input_file); - if (is_numeric($movie_options["start_time"])) { + if (isset($movie_options["start_time"]) && is_numeric($movie_options["start_time"])) { $start_time = max(0, $movie_options["start_time"]); // ensure it's non-negative } else { $start_time = module::get_var("gallery", "movie_extract_frame_time", 3); // use default } // extract frame at start_time, unless movie is too short $start_time_arg = ($duration >= $start_time + 0.1) ? - "-ss " . date("H:i:s", mktime(0,0,$start_time,0,0,0,0)) : ""; + "-ss " . movie::seconds_to_hhmmssdd($start_time) : ""; - $input_args = $movie_options["input_args"] ? $movie_options["input_args"] : ""; - $output_args = $movie_options["output_args"] ? $movie_options["output_args"] : ""; + $input_args = isset($movie_options["input_args"]) ? $movie_options["input_args"] : ""; + $output_args = isset($movie_options["output_args"]) ? $movie_options["output_args"] : ""; $cmd = escapeshellcmd($ffmpeg) . " $input_args -i " . escapeshellarg($input_file) . " -an $start_time_arg -an -r 1 -vframes 1" . @@ -149,8 +149,8 @@ class movie_Core { $mime_type = legal_file::get_movie_types_by_extension($extension); $mime_type = $mime_type ? $mime_type : "video/x-flv"; // No MIME found? Default to video/x-flv. - if (preg_match("/Duration: (\d+):(\d+):(\d+\.\d+)/", $result, $matches)) { - $duration = 3600 * $matches[1] + 60 * $matches[2] + $matches[3]; + if (preg_match("/Duration: (\d+:\d+:\d+\.\d+)/", $result, $matches)) { + $duration = movie::hhmmssdd_to_seconds($matches[1]); } else if (preg_match("/duration.*?:.*?(\d+)/", $result, $matches)) { $duration = $matches[1]; } else { @@ -160,4 +160,25 @@ class movie_Core { return array($width, $height, $mime_type, $extension, $duration); } + /** + * Return the time/duration formatted in hh:mm:ss.dd from a number of seconds. + * Useful for inputs to ffmpeg. + * + * Note that this is similar to date("H:i:s", mktime(0,0,$seconds,0,0,0,0)), but unlike this + * approach avoids potential issues with time zone and DST mismatch and/or using deprecated + * features (the last argument of mkdate above, which disables DST, is deprecated as of PHP 5.3). + */ + static function seconds_to_hhmmssdd($seconds) { + return sprintf("%02d:%02d:%05.2f", floor($seconds / 3600), floor(($seconds % 3600) / 60), + floor(100 * $seconds % 6000) / 100); + } + + /** + * Return the number of seconds from a time/duration formatted in hh:mm:ss.dd. + * Useful for outputs from ffmpeg. + */ + static function hhmmssdd_to_seconds($hhmmssdd) { + preg_match("/(\d+):(\d+):(\d+\.\d+)/", $hhmmssdd, $matches); + return 3600 * $matches[1] + 60 * $matches[2] + $matches[3]; + } } diff --git a/modules/gallery/tests/Movie_Helper_Test.php b/modules/gallery/tests/Movie_Helper_Test.php new file mode 100644 index 00000000..78ac21a1 --- /dev/null +++ b/modules/gallery/tests/Movie_Helper_Test.php @@ -0,0 +1,49 @@ + 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)); + } + } +} -- cgit v1.2.3 From 592eff0e5a8af6f74eff4806dc6e7de56ca02761 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sat, 19 Jan 2013 08:40:19 +0100 Subject: #1942 - Make data_rest and file_proxy more consistent - several minor documentation/formatting changes. No actual functionality changed here. --- modules/gallery/controllers/file_proxy.php | 3 +++ modules/gallery/helpers/data_rest.php | 20 +++++++------------- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index b9ff7df1..9af58c0c 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -100,6 +100,9 @@ class File_Proxy_Controller extends Controller { throw new Kohana_404_Exception(); } + // Note: this code is roughly duplicated in data_rest, so if you modify this, please look to + // see if you should make the same change there as well. + if ($type == "albums") { $file = $item->file_path(); } else if ($type == "resizes") { diff --git a/modules/gallery/helpers/data_rest.php b/modules/gallery/helpers/data_rest.php index 343975f6..abd4638e 100644 --- a/modules/gallery/helpers/data_rest.php +++ b/modules/gallery/helpers/data_rest.php @@ -32,27 +32,21 @@ class data_rest_Core { throw new Rest_Exception("Bad Request", 400, array("errors" => array("size" => "invalid"))); } - switch ($p->size) { - case "thumb": - $file = $item->thumb_path(); - break; - - case "resize": - $file = $item->resize_path(); - break; + // Note: this code is roughly duplicated in file_proxy, so if you modify this, please look to + // see if you should make the same change there as well. - case "full": + if ($p->size == "full") { $file = $item->file_path(); - break; + } else if ($p->size == "resize") { + $file = $item->resize_path(); + } else { + $file = $item->thumb_path(); } if (!file_exists($file)) { throw new Kohana_404_Exception(); } - // Note: this code is roughly duplicated in data_rest, so if you modify this, please look to - // see if you should make the same change there as well. - // // We don't have a cache buster in the url, so don't set cache headers here. // We don't need to save the session for this request Session::instance()->abort_save(); -- cgit v1.2.3 From 3a71813f35857faf1f8a6a68cc8dd3e8d6982a7e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jan 2013 00:24:08 -0500 Subject: Change the logic for finding controllers to use glob() but drop anything that we can find is git-ignore'd. --- modules/gallery/tests/Controller_Auth_Test.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/Controller_Auth_Test.php b/modules/gallery/tests/Controller_Auth_Test.php index 5131fae0..76027cf6 100644 --- a/modules/gallery/tests/Controller_Auth_Test.php +++ b/modules/gallery/tests/Controller_Auth_Test.php @@ -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; -- cgit v1.2.3 From a06abe32b0d12b83a5b1b1d5bd10b112a1e50465 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jan 2013 00:39:58 -0500 Subject: Simplify get_photo_types_by_extension_test and get_movie_types_by_extension_test. --- modules/gallery/tests/Legal_File_Helper_Test.php | 39 ++++++++---------------- 1 file changed, 12 insertions(+), 27 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/Legal_File_Helper_Test.php b/modules/gallery/tests/Legal_File_Helper_Test.php index 66a5cc68..041c5d1f 100644 --- a/modules/gallery/tests/Legal_File_Helper_Test.php +++ b/modules/gallery/tests/Legal_File_Helper_Test.php @@ -19,38 +19,23 @@ */ class Legal_File_Helper_Test extends Gallery_Unit_Test_Case { public function get_photo_types_by_extension_test() { - // Valid extensions return their corresponding mimes, invalid extensions return null - $tests = array("jpg" => "image/jpeg", - "JPG" => "image/jpeg", - "jpeg" => "image/jpeg", - "png" => "image/png", - "Png" => "image/png", - "gif" => "image/gif", - "tif" => null, - "mp4" => null, - "php" => null, - "php.jpg" => null); - foreach ($tests as $extension => $mime_type) { - $this->assert_equal($mime_type, legal_file::get_photo_types_by_extension($extension)); - } + $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() { - // Valid extensions return their corresponding mimes, invalid extensions return null - $tests = array("flv" => "video/x-flv", - "FLV" => "video/x-flv", - "mp4" => "video/mp4", - "Mp4" => "video/mp4", - "m4v" => "video/x-m4v", - "avi" => null, - "jpg" => null, - "php" => null, - "php.flv" => null); - foreach ($tests as $extension => $mime_type) { - $this->assert_equal($mime_type, legal_file::get_movie_types_by_extension($extension)); - } + $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())); } -- cgit v1.2.3 From 1927dd00e42062a98855d121ec8427b25d74d015 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sun, 20 Jan 2013 08:34:12 +0100 Subject: #1949 - Fix album thumb mime types given by data_rest and file_proxy Correct result: always "image/jpeg" Old data_rest result: mime of cover item Old file_proxy result: mime of album item (null) --- modules/gallery/controllers/file_proxy.php | 4 ++-- modules/gallery/helpers/data_rest.php | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 9af58c0c..b2120455 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -126,8 +126,8 @@ class File_Proxy_Controller extends Controller { expires::set(2592000, $item->updated); // 30 days - // Dump out the image. If the item is a movie, then its thumbnail will be a JPG. - if ($item->is_movie() && $type != "albums") { + // Dump out the image. If the item is a movie or album, then its thumbnail will be a JPG. + if (($item->is_movie() || $item->is_album()) && $type == "thumbs") { header("Content-Type: image/jpeg"); } else { header("Content-Type: $item->mime_type"); diff --git a/modules/gallery/helpers/data_rest.php b/modules/gallery/helpers/data_rest.php index abd4638e..ef4f17e7 100644 --- a/modules/gallery/helpers/data_rest.php +++ b/modules/gallery/helpers/data_rest.php @@ -57,13 +57,11 @@ class data_rest_Core { return; } - // Dump out the image. If the item is a movie, then its thumbnail will be a JPG. - if ($item->is_movie() && $p->size == "thumb") { + // Dump out the image. If the item is a movie or album, then its thumbnail will be a JPG. + if (($item->is_movie() || $item->is_album()) && $p->size == "thumb") { header("Content-Type: image/jpeg"); - } else if ($item->is_album()) { - header("Content-Type: " . $item->album_cover()->mime_type); } else { - header("Content-Type: {$item->mime_type}"); + header("Content-Type: $item->mime_type"); } Kohana::close_buffers(false); -- cgit v1.2.3 From 14b02a5b1215ced4e4ef1d536f0301c6bfb3a845 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sun, 20 Jan 2013 10:01:41 +0100 Subject: #1950 - Replace bogus file overwrites from item model unit test. - modified rename_photo_test, rename_album_test, move_album_test, move_photo_test - unit tests still test file system integrity and pass --- modules/gallery/tests/Item_Model_Test.php | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index a3929e62..52c3d64d 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -69,9 +69,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $item = test::random_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,9 +82,9 @@ 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() { @@ -92,9 +92,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $photo = test::random_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,9 +119,9 @@ 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() { @@ -154,9 +154,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $album1 = test::random_album($album2); $photo = test::random_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,9 +173,9 @@ 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() { @@ -184,9 +184,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $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,9 +200,9 @@ 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() { -- cgit v1.2.3 From f1d2a8e871327d250574d2dd7cacbb21ea3ae995 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jan 2013 23:54:01 -0500 Subject: Add a long overdue test for File_Proxy_Controller that tests all the various edge case behaviors. It doesn't cover the various headers, but it does cover the permission based code paths. --- modules/gallery/controllers/file_proxy.php | 34 ++++-- .../gallery/tests/File_Proxy_Controller_Test.php | 130 +++++++++++++++++++++ 2 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 modules/gallery/tests/File_Proxy_Controller_Test.php (limited to 'modules') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index b2120455..df1f7908 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -49,7 +49,9 @@ class File_Proxy_Controller extends Controller { // Make sure that the request is for a file inside var $offset = strpos(rawurldecode($request_uri), $var_uri); if ($offset !== 0) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 1; + throw $e; } // file_uri: albums/foo/bar.jpg @@ -59,7 +61,9 @@ class File_Proxy_Controller extends Controller { // path: foo/bar.jpg list ($type, $path) = explode("/", $file_uri, 2); if ($type != "resizes" && $type != "albums" && $type != "thumbs") { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 2; + throw $e; } // If the last element is .album.jpg, pop that off since it's not a real item @@ -82,22 +86,30 @@ class File_Proxy_Controller extends Controller { } if (!$item->loaded()) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 3; + throw $e; } // Make sure we have access to the item if (!access::can("view", $item)) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 4; + throw $e; } // Make sure we have view_full access to the original if ($type == "albums" && !access::can("view_full", $item)) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 5; + throw $e; } // Don't try to load a directory if ($type == "albums" && $item->is_album()) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 6; + throw $e; } // Note: this code is roughly duplicated in data_rest, so if you modify this, please look to @@ -112,7 +124,9 @@ class File_Proxy_Controller extends Controller { } if (!file_exists($file)) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 7; + throw $e; } header("Content-Length: " . filesize($file)); @@ -146,6 +160,10 @@ class File_Proxy_Controller extends Controller { } } - readfile($file); + if (TEST_MODE) { + return $file; + } else { + readfile($file); + } } } 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..dab2b8f3 --- /dev/null +++ b/modules/gallery/tests/File_Proxy_Controller_Test.php @@ -0,0 +1,130 @@ +_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 -- cgit v1.2.3 From 8dc34dade882768feb8100d7041d94c7d446b818 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 21 Jan 2013 00:51:31 -0500 Subject: Add unit tests for data_rest. While I'm in there, get rid of the clause that returns nothing when the album has no album cover - we'll fail before that if the album's thumbnail is missing, and if it's not missing then we'll have something to serve even if it's out of date. --- modules/gallery/helpers/data_rest.php | 12 ++- modules/gallery/tests/Data_Rest_Helper_Test.php | 102 ++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 modules/gallery/tests/Data_Rest_Helper_Test.php (limited to 'modules') diff --git a/modules/gallery/helpers/data_rest.php b/modules/gallery/helpers/data_rest.php index ef4f17e7..ad369037 100644 --- a/modules/gallery/helpers/data_rest.php +++ b/modules/gallery/helpers/data_rest.php @@ -51,12 +51,6 @@ class data_rest_Core { // We don't need to save the session for this request Session::instance()->abort_save(); - if ($item->is_album() && !$item->album_cover_item_id) { - // No thumbnail. Return nothing. - // @todo: what should we do here? - return; - } - // Dump out the image. If the item is a movie or album, then its thumbnail will be a JPG. if (($item->is_movie() || $item->is_album()) && $p->size == "thumb") { header("Content-Type: image/jpeg"); @@ -68,7 +62,11 @@ class data_rest_Core { if (isset($p->encoding) && $p->encoding == "base64") { print base64_encode(file_get_contents($file)); } else { - readfile($file); + if (TEST_MODE) { + return $file; + } else { + readfile($file); + } } // We must exit here to keep the regular REST framework reply code from adding more bytes on 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..feec6d32 --- /dev/null +++ b/modules/gallery/tests/Data_Rest_Helper_Test.php @@ -0,0 +1,102 @@ +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 + } + } +} -- cgit v1.2.3 From d45a73777935c86fc5131955831833d7465b5e9d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 21 Jan 2013 01:22:01 -0500 Subject: Update copyright to 2013. Fixes #1953. --- application/Bootstrap.php | 2 +- application/config/config.php | 2 +- index.php | 2 +- installer/cli.php | 2 +- installer/index.php | 2 +- installer/installer.php | 2 +- installer/web.php | 2 +- modules/akismet/controllers/admin_akismet.php | 2 +- modules/akismet/helpers/akismet.php | 2 +- modules/akismet/helpers/akismet_event.php | 2 +- modules/akismet/helpers/akismet_installer.php | 2 +- modules/akismet/tests/Akismet_Helper_Test.php | 2 +- modules/comment/controllers/admin_comments.php | 2 +- modules/comment/controllers/admin_manage_comments.php | 2 +- modules/comment/controllers/comments.php | 2 +- modules/comment/helpers/comment.php | 2 +- modules/comment/helpers/comment_block.php | 2 +- modules/comment/helpers/comment_event.php | 2 +- modules/comment/helpers/comment_installer.php | 2 +- modules/comment/helpers/comment_rest.php | 2 +- modules/comment/helpers/comment_rss.php | 2 +- modules/comment/helpers/comment_theme.php | 2 +- modules/comment/helpers/comments_rest.php | 2 +- modules/comment/helpers/item_comments_rest.php | 2 +- modules/comment/models/comment.php | 2 +- modules/comment/tests/Comment_Event_Test.php | 2 +- modules/comment/tests/Comment_Helper_Test.php | 2 +- modules/comment/tests/Comment_Model_Test.php | 2 +- modules/digibug/config/digibug.php | 2 +- modules/digibug/controllers/admin_digibug.php | 2 +- modules/digibug/controllers/digibug.php | 2 +- modules/digibug/helpers/digibug_event.php | 2 +- modules/digibug/helpers/digibug_installer.php | 2 +- modules/digibug/helpers/digibug_theme.php | 2 +- modules/digibug/models/digibug_proxy.php | 2 +- modules/digibug/tests/Digibug_Controller_Test.php | 2 +- modules/exif/controllers/exif.php | 2 +- modules/exif/helpers/exif.php | 2 +- modules/exif/helpers/exif_event.php | 2 +- modules/exif/helpers/exif_installer.php | 2 +- modules/exif/helpers/exif_task.php | 2 +- modules/exif/helpers/exif_theme.php | 2 +- modules/exif/models/exif_key.php | 2 +- modules/exif/models/exif_record.php | 2 +- modules/exif/tests/Exif_Test.php | 2 +- modules/g2_import/controllers/admin_g2_import.php | 2 +- modules/g2_import/controllers/g2.php | 2 +- modules/g2_import/helpers/g2_import.php | 2 +- modules/g2_import/helpers/g2_import_event.php | 2 +- modules/g2_import/helpers/g2_import_installer.php | 2 +- modules/g2_import/helpers/g2_import_task.php | 2 +- modules/g2_import/libraries/G2_Import_Exception.php | 2 +- modules/g2_import/models/g2_map.php | 2 +- modules/gallery/config/cache.php | 2 +- modules/gallery/config/cookie.php | 2 +- modules/gallery/config/database.php | 2 +- modules/gallery/config/locale.php | 2 +- modules/gallery/config/log_file.php | 2 +- modules/gallery/config/routes.php | 2 +- modules/gallery/config/session.php | 2 +- modules/gallery/config/upload.php | 2 +- modules/gallery/config/user_agents.php | 2 +- modules/gallery/controllers/admin.php | 2 +- modules/gallery/controllers/admin_advanced_settings.php | 2 +- modules/gallery/controllers/admin_dashboard.php | 2 +- modules/gallery/controllers/admin_graphics.php | 2 +- modules/gallery/controllers/admin_languages.php | 2 +- modules/gallery/controllers/admin_maintenance.php | 2 +- modules/gallery/controllers/admin_modules.php | 2 +- modules/gallery/controllers/admin_sidebar.php | 2 +- modules/gallery/controllers/admin_theme_options.php | 2 +- modules/gallery/controllers/admin_themes.php | 2 +- modules/gallery/controllers/admin_upgrade_checker.php | 2 +- modules/gallery/controllers/albums.php | 2 +- modules/gallery/controllers/combined.php | 2 +- modules/gallery/controllers/file_proxy.php | 2 +- modules/gallery/controllers/items.php | 2 +- modules/gallery/controllers/l10n_client.php | 2 +- modules/gallery/controllers/login.php | 2 +- modules/gallery/controllers/logout.php | 2 +- modules/gallery/controllers/movies.php | 2 +- modules/gallery/controllers/packager.php | 2 +- modules/gallery/controllers/permissions.php | 2 +- modules/gallery/controllers/photos.php | 2 +- modules/gallery/controllers/quick.php | 2 +- modules/gallery/controllers/reauthenticate.php | 2 +- modules/gallery/controllers/upgrader.php | 2 +- modules/gallery/controllers/uploader.php | 2 +- modules/gallery/controllers/user_profile.php | 2 +- modules/gallery/controllers/welcome_message.php | 2 +- modules/gallery/helpers/MY_html.php | 2 +- modules/gallery/helpers/MY_num.php | 2 +- modules/gallery/helpers/MY_remote.php | 2 +- modules/gallery/helpers/MY_url.php | 2 +- modules/gallery/helpers/MY_valid.php | 2 +- modules/gallery/helpers/access.php | 2 +- modules/gallery/helpers/ajax.php | 2 +- modules/gallery/helpers/album.php | 2 +- modules/gallery/helpers/auth.php | 2 +- modules/gallery/helpers/batch.php | 2 +- modules/gallery/helpers/block_manager.php | 2 +- modules/gallery/helpers/data_rest.php | 2 +- modules/gallery/helpers/dir.php | 2 +- modules/gallery/helpers/encoding.php | 2 +- modules/gallery/helpers/gallery.php | 2 +- modules/gallery/helpers/gallery_block.php | 2 +- modules/gallery/helpers/gallery_error.php | 2 +- modules/gallery/helpers/gallery_event.php | 2 +- modules/gallery/helpers/gallery_graphics.php | 2 +- modules/gallery/helpers/gallery_installer.php | 2 +- modules/gallery/helpers/gallery_rss.php | 2 +- modules/gallery/helpers/gallery_task.php | 2 +- modules/gallery/helpers/gallery_theme.php | 2 +- modules/gallery/helpers/graphics.php | 2 +- modules/gallery/helpers/identity.php | 2 +- modules/gallery/helpers/item.php | 2 +- modules/gallery/helpers/item_rest.php | 2 +- modules/gallery/helpers/items_rest.php | 2 +- modules/gallery/helpers/json.php | 2 +- modules/gallery/helpers/l10n_client.php | 2 +- modules/gallery/helpers/l10n_scanner.php | 2 +- modules/gallery/helpers/legal_file.php | 2 +- modules/gallery/helpers/locales.php | 2 +- modules/gallery/helpers/log.php | 2 +- modules/gallery/helpers/message.php | 2 +- modules/gallery/helpers/model_cache.php | 2 +- modules/gallery/helpers/module.php | 2 +- modules/gallery/helpers/movie.php | 2 +- modules/gallery/helpers/photo.php | 2 +- modules/gallery/helpers/random.php | 2 +- modules/gallery/helpers/site_status.php | 2 +- modules/gallery/helpers/system.php | 2 +- modules/gallery/helpers/task.php | 2 +- modules/gallery/helpers/theme.php | 2 +- modules/gallery/helpers/tree_rest.php | 2 +- modules/gallery/helpers/upgrade_checker.php | 2 +- modules/gallery/helpers/user_profile.php | 2 +- modules/gallery/helpers/xml.php | 2 +- modules/gallery/hooks/init_gallery.php | 2 +- modules/gallery/libraries/Admin_View.php | 2 +- modules/gallery/libraries/Block.php | 2 +- modules/gallery/libraries/Breadcrumb.php | 2 +- modules/gallery/libraries/Form_Script.php | 2 +- modules/gallery/libraries/Form_Uploadify.php | 2 +- modules/gallery/libraries/Form_Uploadify_buttons.php | 2 +- modules/gallery/libraries/Gallery_I18n.php | 2 +- modules/gallery/libraries/Gallery_View.php | 2 +- modules/gallery/libraries/IdentityProvider.php | 2 +- modules/gallery/libraries/InPlaceEdit.php | 2 +- modules/gallery/libraries/MY_Database.php | 2 +- modules/gallery/libraries/MY_Forge.php | 2 +- modules/gallery/libraries/MY_Input.php | 2 +- modules/gallery/libraries/MY_Kohana_Exception.php | 2 +- modules/gallery/libraries/MY_ORM.php | 2 +- modules/gallery/libraries/MY_View.php | 2 +- modules/gallery/libraries/Menu.php | 2 +- modules/gallery/libraries/ORM_MPTT.php | 2 +- modules/gallery/libraries/SafeString.php | 2 +- modules/gallery/libraries/Sendmail.php | 2 +- modules/gallery/libraries/Task_Definition.php | 2 +- modules/gallery/libraries/Theme_View.php | 2 +- modules/gallery/libraries/drivers/Cache/Database.php | 2 +- modules/gallery/libraries/drivers/IdentityProvider.php | 2 +- modules/gallery/models/access_cache.php | 2 +- modules/gallery/models/access_intent.php | 2 +- modules/gallery/models/cache.php | 2 +- modules/gallery/models/failed_auth.php | 2 +- modules/gallery/models/graphics_rule.php | 2 +- modules/gallery/models/incoming_translation.php | 2 +- modules/gallery/models/item.php | 2 +- modules/gallery/models/log.php | 2 +- modules/gallery/models/message.php | 2 +- modules/gallery/models/module.php | 2 +- modules/gallery/models/outgoing_translation.php | 2 +- modules/gallery/models/permission.php | 2 +- modules/gallery/models/task.php | 2 +- modules/gallery/models/theme.php | 2 +- modules/gallery/models/var.php | 2 +- modules/gallery/tests/Access_Helper_Test.php | 2 +- modules/gallery/tests/Albums_Controller_Test.php | 2 +- modules/gallery/tests/Breadcrumb_Test.php | 2 +- modules/gallery/tests/Cache_Test.php | 2 +- modules/gallery/tests/Controller_Auth_Test.php | 2 +- modules/gallery/tests/Data_Rest_Helper_Test.php | 2 +- modules/gallery/tests/Database_Test.php | 2 +- modules/gallery/tests/Dir_Helper_Test.php | 2 +- modules/gallery/tests/DrawForm_Test.php | 2 +- modules/gallery/tests/File_Proxy_Controller_Test.php | 2 +- modules/gallery/tests/File_Structure_Test.php | 4 ++-- modules/gallery/tests/Gallery_Filters.php | 2 +- modules/gallery/tests/Gallery_I18n_Test.php | 2 +- modules/gallery/tests/Gallery_Installer_Test.php | 2 +- modules/gallery/tests/Html_Helper_Test.php | 2 +- modules/gallery/tests/Input_Library_Test.php | 2 +- modules/gallery/tests/Item_Helper_Test.php | 2 +- modules/gallery/tests/Item_Model_Test.php | 2 +- modules/gallery/tests/Item_Rest_Helper_Test.php | 2 +- modules/gallery/tests/Items_Rest_Helper_Test.php | 2 +- modules/gallery/tests/Kohana_Exception_Test.php | 2 +- modules/gallery/tests/Legal_File_Helper_Test.php | 2 +- modules/gallery/tests/Locales_Helper_Test.php | 2 +- modules/gallery/tests/Menu_Test.php | 2 +- modules/gallery/tests/Movie_Helper_Test.php | 2 +- modules/gallery/tests/Num_Helper_Test.php | 2 +- modules/gallery/tests/ORM_MPTT_Test.php | 2 +- modules/gallery/tests/Photos_Controller_Test.php | 2 +- modules/gallery/tests/SafeString_Test.php | 2 +- modules/gallery/tests/Sendmail_Test.php | 2 +- modules/gallery/tests/System_Helper_Test.php | 2 +- modules/gallery/tests/Url_Security_Test.php | 2 +- modules/gallery/tests/Valid_Test.php | 2 +- modules/gallery/tests/Var_Test.php | 2 +- modules/gallery/tests/Xss_Security_Test.php | 2 +- modules/gallery_unit_test/controllers/gallery_unit_test.php | 2 +- modules/gallery_unit_test/helpers/MY_request.php | 2 +- modules/gallery_unit_test/helpers/test.php | 2 +- modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php | 2 +- modules/image_block/controllers/image_block.php | 2 +- modules/image_block/helpers/image_block_block.php | 2 +- modules/image_block/helpers/image_block_installer.php | 2 +- modules/info/helpers/info_block.php | 2 +- modules/info/helpers/info_installer.php | 2 +- modules/info/helpers/info_theme.php | 2 +- modules/kohana23_compat/config/pagination.php | 2 +- modules/kohana23_compat/libraries/MY_Database_Builder.php | 2 +- modules/kohana23_compat/libraries/Pagination.php | 2 +- modules/notification/controllers/notification.php | 2 +- modules/notification/helpers/notification.php | 2 +- modules/notification/helpers/notification_event.php | 2 +- modules/notification/helpers/notification_installer.php | 2 +- modules/notification/models/pending_notification.php | 2 +- modules/notification/models/subscription.php | 2 +- modules/organize/controllers/organize.php | 2 +- modules/organize/helpers/organize_event.php | 2 +- modules/organize/helpers/organize_installer.php | 2 +- modules/recaptcha/controllers/admin_recaptcha.php | 2 +- modules/recaptcha/helpers/recaptcha.php | 2 +- modules/recaptcha/helpers/recaptcha_event.php | 2 +- modules/recaptcha/helpers/recaptcha_installer.php | 2 +- modules/recaptcha/helpers/recaptcha_theme.php | 2 +- modules/recaptcha/libraries/Form_Recaptcha.php | 2 +- modules/rest/controllers/rest.php | 2 +- modules/rest/helpers/registry_rest.php | 2 +- modules/rest/helpers/rest.php | 2 +- modules/rest/helpers/rest_event.php | 2 +- modules/rest/helpers/rest_installer.php | 2 +- modules/rest/libraries/Rest_Exception.php | 2 +- modules/rest/models/user_access_key.php | 2 +- modules/rest/tests/Rest_Controller_Test.php | 2 +- modules/rss/controllers/rss.php | 2 +- modules/rss/helpers/rss.php | 2 +- modules/rss/helpers/rss_block.php | 2 +- modules/search/controllers/search.php | 2 +- modules/search/helpers/search.php | 2 +- modules/search/helpers/search_event.php | 2 +- modules/search/helpers/search_installer.php | 2 +- modules/search/helpers/search_task.php | 2 +- modules/search/helpers/search_theme.php | 2 +- modules/search/models/search_record.php | 2 +- modules/server_add/controllers/admin_server_add.php | 2 +- modules/server_add/controllers/server_add.php | 2 +- modules/server_add/helpers/server_add.php | 2 +- modules/server_add/helpers/server_add_event.php | 2 +- modules/server_add/helpers/server_add_installer.php | 2 +- modules/server_add/helpers/server_add_theme.php | 2 +- modules/server_add/models/server_add_entry.php | 2 +- modules/slideshow/helpers/slideshow_event.php | 2 +- modules/slideshow/helpers/slideshow_installer.php | 2 +- modules/slideshow/helpers/slideshow_theme.php | 2 +- modules/tag/controllers/admin_tags.php | 2 +- modules/tag/controllers/tag.php | 2 +- modules/tag/controllers/tag_name.php | 2 +- modules/tag/controllers/tags.php | 2 +- modules/tag/helpers/item_tags_rest.php | 2 +- modules/tag/helpers/tag.php | 2 +- modules/tag/helpers/tag_block.php | 2 +- modules/tag/helpers/tag_event.php | 2 +- modules/tag/helpers/tag_installer.php | 2 +- modules/tag/helpers/tag_item_rest.php | 2 +- modules/tag/helpers/tag_items_rest.php | 2 +- modules/tag/helpers/tag_rest.php | 2 +- modules/tag/helpers/tag_rss.php | 2 +- modules/tag/helpers/tag_task.php | 2 +- modules/tag/helpers/tag_theme.php | 2 +- modules/tag/helpers/tags_rest.php | 2 +- modules/tag/models/tag.php | 2 +- modules/tag/tests/Tag_Item_Rest_Helper_Test.php | 2 +- modules/tag/tests/Tag_Rest_Helper_Test.php | 2 +- modules/tag/tests/Tag_Test.php | 2 +- modules/tag/tests/Tags_Rest_Helper_Test.php | 2 +- modules/user/config/identity.php | 2 +- modules/user/controllers/admin_users.php | 2 +- modules/user/controllers/password.php | 2 +- modules/user/controllers/users.php | 2 +- modules/user/helpers/group.php | 2 +- modules/user/helpers/user.php | 2 +- modules/user/helpers/user_event.php | 2 +- modules/user/helpers/user_installer.php | 2 +- modules/user/helpers/user_theme.php | 2 +- modules/user/libraries/drivers/IdentityProvider/Gallery.php | 2 +- modules/user/models/group.php | 2 +- modules/user/models/user.php | 2 +- modules/user/tests/No_Direct_ORM_Access_Test.php | 2 +- modules/user/tests/User_Groups_Test.php | 2 +- modules/user/tests/User_Installer_Test.php | 2 +- modules/watermark/controllers/admin_watermarks.php | 2 +- modules/watermark/helpers/watermark.php | 2 +- modules/watermark/helpers/watermark_event.php | 2 +- modules/watermark/helpers/watermark_installer.php | 2 +- 309 files changed, 310 insertions(+), 310 deletions(-) (limited to 'modules') diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 183705d9..93353b47 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -1,7 +1,7 @@ Date: Mon, 21 Jan 2013 10:45:34 +0100 Subject: #1954 - Skip buffer calls for unit tests of file_proxy and data_rest. Moved the "if (TEST_MODE)" statement before the buffer calls in file_proxy and data_rest. This has no impact on normal use, but will make the unit tests more compatible with different server/PHP configurations. Note: We do not have to skip setting the headers, which means we can build unit tests around them if we wish. --- modules/gallery/controllers/file_proxy.php | 25 ++++++++++++------------- modules/gallery/helpers/data_rest.php | 11 ++++++----- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index f29cdf98..a9e98ce1 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -147,22 +147,21 @@ class File_Proxy_Controller extends Controller { header("Content-Type: $item->mime_type"); } - // Don't use Kohana::close_buffers(false) here because that only closes all the buffers - // that Kohana started. We want to close *all* buffers at this point because otherwise we're - // going to buffer up whatever file we're proxying (and it may be very large). This may - // affect embedding or systems with PHP's output_buffering enabled. - while (ob_get_level()) { - Kohana_Log::add("error","".print_r(ob_get_level(),1)); - if (!@ob_end_clean()) { - // ob_end_clean() can return false if the buffer can't be removed for some reason - // (zlib output compression buffers sometimes cause problems). - break; - } - } - if (TEST_MODE) { return $file; } else { + // Don't use Kohana::close_buffers(false) here because that only closes all the buffers + // that Kohana started. We want to close *all* buffers at this point because otherwise we're + // going to buffer up whatever file we're proxying (and it may be very large). This may + // affect embedding or systems with PHP's output_buffering enabled. + while (ob_get_level()) { + Kohana_Log::add("error","".print_r(ob_get_level(),1)); + if (!@ob_end_clean()) { + // ob_end_clean() can return false if the buffer can't be removed for some reason + // (zlib output compression buffers sometimes cause problems). + break; + } + } readfile($file); } } diff --git a/modules/gallery/helpers/data_rest.php b/modules/gallery/helpers/data_rest.php index 8a3a159d..dc213510 100644 --- a/modules/gallery/helpers/data_rest.php +++ b/modules/gallery/helpers/data_rest.php @@ -57,13 +57,14 @@ class data_rest_Core { } else { header("Content-Type: $item->mime_type"); } - Kohana::close_buffers(false); - if (isset($p->encoding) && $p->encoding == "base64") { - print base64_encode(file_get_contents($file)); + if (TEST_MODE) { + return $file; } else { - if (TEST_MODE) { - return $file; + Kohana::close_buffers(false); + + if (isset($p->encoding) && $p->encoding == "base64") { + print base64_encode(file_get_contents($file)); } else { readfile($file); } -- cgit v1.2.3 From 49f6ce2d94194220213edb108e4ac372acd2eabb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 22 Jan 2013 18:39:24 -0500 Subject: gallery.menalto.com -> galleryproject.org codex.gallery2.org -> codex.galleryproject.org Fixes #1957. --- README | 12 ++++++------ index.php | 2 +- installer/cli.php | 4 ++-- installer/views/install.html.php | 4 ++-- modules/akismet/module.info | 6 +++--- modules/comment/module.info | 6 +++--- modules/digibug/module.info | 6 +++--- modules/exif/module.info | 6 +++--- modules/g2_import/module.info | 6 +++--- modules/gallery/helpers/gallery_block.php | 2 +- modules/gallery/helpers/gallery_theme.php | 2 +- modules/gallery/helpers/graphics.php | 2 +- modules/gallery/helpers/l10n_client.php | 2 +- modules/gallery/helpers/upgrade_checker.php | 2 +- modules/gallery/module.info | 6 +++--- modules/gallery/views/admin_graphics.html.php | 2 +- modules/gallery/views/admin_languages.html.php | 2 +- modules/gallery/views/admin_modules.html.php | 2 +- modules/gallery/views/admin_themes.html.php | 6 +++--- modules/gallery/views/error_admin.html.php | 2 +- modules/gallery/views/form_uploadify.html.php | 4 ++-- modules/gallery/views/upgrader.html.php | 4 ++-- modules/gallery/views/welcome_message.html.php | 4 ++-- modules/image_block/module.info | 6 +++--- modules/info/module.info | 6 +++--- modules/notification/module.info | 6 +++--- modules/organize/module.info | 6 +++--- modules/recaptcha/module.info | 6 +++--- modules/rest/module.info | 6 +++--- modules/rss/module.info | 6 +++--- modules/search/module.info | 6 +++--- modules/server_add/module.info | 6 +++--- modules/slideshow/module.info | 6 +++--- modules/tag/module.info | 6 +++--- modules/user/module.info | 6 +++--- modules/watermark/module.info | 6 +++--- themes/admin_wind/theme.info | 6 +++--- themes/wind/theme.info | 6 +++--- 38 files changed, 92 insertions(+), 92 deletions(-) (limited to 'modules') diff --git a/README b/README index 11256921..b50186d2 100644 --- a/README +++ b/README @@ -15,14 +15,14 @@ welcome theme and module developers to play with this release and start turning out slick new designs for our happy users. If you have questions or problems, you can get help in the Gallery forums: - http://gallery.menalto.com/forum/96 + http://galleryproject.org/forum/96 SECURITY: We've contracted a professional security audit, received their results and resolved all the issues they found. -Did you find a security flaw? Please email security@gallery.menalto.com +Did you find a security flaw? Please email security@galleryproject.org with the details and we'll fix it ASAP! @@ -34,12 +34,12 @@ SUPPORTED CONFIGURATION: - Database: MySQL 5 and newer. For complete system requirements, please refer to: - http://codex.gallery2.org/Gallery3:Requirements + http://codex.galleryproject.org/Gallery3:Requirements INSTALLING AND UPGRADING INSTRUCTIONS: For comprehensive instructions, The online User Guide is your best resource: - http://codex.gallery2.org/Gallery3:User_guide + http://codex.galleryproject.org/Gallery3:User_guide There are also simple instructions below. NOTE: You can upgrade from beta 1 and beyond, but not from alpha releases. @@ -68,7 +68,7 @@ and log in with your SourceForge username and password, then click the QUESTIONS, PROBLEMS: - - Check out the gallery3 FAQ http://codex.gallery2.org/Gallery3:FAQ - - Post to the Gallery 3 forums: http://gallery.menalto.com/forum/96 + - Check out the gallery3 FAQ http://codex.galleryproject.org/Gallery3:FAQ + - Post to the Gallery 3 forums: http://galleryproject.org/forum/96 - Email gallery-devel@lists.sourceforge.net diff --git a/index.php b/index.php index 763cfbbd..9ff8e3b4 100644 --- a/index.php +++ b/index.php @@ -39,7 +39,7 @@ if (!ini_get("date.timezone")) { !ini_get("short_open_tag") and exit("Gallery requires short_open_tag to be on."); // Suppress errors. For information on how to debug Gallery 3, see: -// http://codex.gallery2.org/Gallery3:FAQ#How_do_I_see_debug_information.3F +// http://codex.galleryproject.org/Gallery3:FAQ#How_do_I_see_debug_information.3F error_reporting(0); // Disabling display_errors will effectively disable Kohana error display diff --git a/installer/cli.php b/installer/cli.php index 93699ba9..f5a9e260 100644 --- a/installer/cli.php +++ b/installer/cli.php @@ -78,8 +78,8 @@ function oops($message) { print "==> " . $message; print "\n"; print "For help you can try:\n"; - print " * The Gallery 3 FAQ - http://codex.gallery2.org/Gallery3:FAQ\n"; - print " * The Gallery Forums - http://gallery.menalto.com/forum\n"; + print " * The Gallery 3 FAQ - http://codex.galleryproject.org/Gallery3:FAQ\n"; + print " * The Gallery Forums - http://galleryproject.org/forum\n"; print "\n\n** INSTALLATION FAILED **\n"; exit(1); } diff --git a/installer/views/install.html.php b/installer/views/install.html.php index a0eddaf3..7a30561a 100644 --- a/installer/views/install.html.php +++ b/installer/views/install.html.php @@ -13,9 +13,9 @@ diff --git a/modules/akismet/module.info b/modules/akismet/module.info index 63473468..263b7b82 100644 --- a/modules/akismet/module.info +++ b/modules/akismet/module.info @@ -2,6 +2,6 @@ name = "Akismet" description = "Filter comments through the Akismet web service to detect and eliminate spam (http://akismet.com). You'll need a WordPress.com API key to use it." version = 1 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:akismet" -discuss_url = "http://gallery.menalto.com/forum_module_akismet" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:akismet" +discuss_url = "http://galleryproject.org/forum_module_akismet" diff --git a/modules/comment/module.info b/modules/comment/module.info index 97e8a73b..b69379fa 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -2,6 +2,6 @@ name = "Comments" description = "Allows users and guests to leave comments on photos and albums." version = 7 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:comment" -discuss_url = "http://gallery.menalto.com/forum_module_comment" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:comment" +discuss_url = "http://galleryproject.org/forum_module_comment" diff --git a/modules/digibug/module.info b/modules/digibug/module.info index 781d5f01..5e5ca10f 100644 --- a/modules/digibug/module.info +++ b/modules/digibug/module.info @@ -2,6 +2,6 @@ name = "Digibug" description = "Digibug Photo Printing Module" version = 2 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:digibug" -discuss_url = "http://gallery.menalto.com/forum_module_digibug" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:digibug" +discuss_url = "http://galleryproject.org/forum_module_digibug" diff --git a/modules/exif/module.info b/modules/exif/module.info index e266e20e..9bbda957 100644 --- a/modules/exif/module.info +++ b/modules/exif/module.info @@ -2,6 +2,6 @@ name = "Exif Data" description = "Extract Exif data and display it on photo pages." version = 1 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:exif" -discuss_url = "http://gallery.menalto.com/forum_module_exif" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:exif" +discuss_url = "http://galleryproject.org/forum_module_exif" diff --git a/modules/g2_import/module.info b/modules/g2_import/module.info index 6b03d097..32af27d0 100644 --- a/modules/g2_import/module.info +++ b/modules/g2_import/module.info @@ -2,6 +2,6 @@ name = "Gallery 2 Import" description = "Import your Gallery 2 content into Gallery 3" version = 2 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:g2_import" -discuss_url = "http://gallery.menalto.com/forum_module_g2_import" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:g2_import" +discuss_url = "http://galleryproject.org/forum_module_g2_import" diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index 5ab811de..5ac4d74d 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -78,7 +78,7 @@ class gallery_block_Core { $block->css_id = "g-project-news"; $block->title = t("Gallery project news"); $block->content = new View("admin_block_news.html"); - $block->content->feed = feed::parse("http://gallery.menalto.com/node/feed", 3); + $block->content->feed = feed::parse("http://galleryproject.org/node/feed", 3); break; case "block_adder": diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index e592db53..f94b9ecd 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -134,7 +134,7 @@ class gallery_theme_Core { 'Gallery ' . gallery::version_string() . ''); return "
  • " . t(module::get_var("gallery", "credits"), - array("url" => "http://gallery.menalto.com", + array("url" => "http://galleryproject.org", "gallery_version" => $version_string)) . "
  • "; } diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index b8735120..51437d4b 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -124,7 +124,7 @@ class graphics_Core { // don't do this, the album may be permanently marked as "needs rebuilding" // // ref: http://sourceforge.net/apps/trac/gallery/ticket/1172 - // http://gallery.menalto.com/node/96926 + // http://galleryproject.org/node/96926 if ($item->album_cover_item_id) { $item->album_cover_item_id = null; $item->save(); diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 5954865d..2a1be2f9 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -21,7 +21,7 @@ class l10n_client_Core { private static function _server_url($path) { - return "http://gallery.menalto.com/translations/$path"; + return "http://galleryproject.org/translations/$path"; } static function server_api_key_url() { diff --git a/modules/gallery/helpers/upgrade_checker.php b/modules/gallery/helpers/upgrade_checker.php index 5059e619..492f72e9 100644 --- a/modules/gallery/helpers/upgrade_checker.php +++ b/modules/gallery/helpers/upgrade_checker.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class upgrade_checker_Core { - const CHECK_URL = "http://gallery.menalto.com/versioncheck/gallery3"; + const CHECK_URL = "http://galleryproject.org/versioncheck/gallery3"; const AUTO_CHECK_INTERVAL = 604800; // 7 days in seconds /** diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 64cad0a7..566ca2eb 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -2,6 +2,6 @@ name = "Gallery 3" description = "Gallery core application" version = 53 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:gallery" -discuss_url = "http://gallery.menalto.com/forum_module_gallery" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:gallery" +discuss_url = "http://galleryproject.org/forum_module_gallery" diff --git a/modules/gallery/views/admin_graphics.html.php b/modules/gallery/views/admin_graphics.html.php index ae76f1e1..1f45bb14 100644 --- a/modules/gallery/views/admin_graphics.html.php +++ b/modules/gallery/views/admin_graphics.html.php @@ -16,7 +16,7 @@

    - We can help!", array("url" => "http://codex.gallery2.org/Gallery3:Choosing_A_Graphics_Toolkit")) ?> + We can help!", array("url" => "http://codex.galleryproject.org/Gallery3:Choosing_A_Graphics_Toolkit")) ?>

    diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php index eef087e1..d6a9c225 100644 --- a/modules/gallery/views/admin_languages.html.php +++ b/modules/gallery/views/admin_languages.html.php @@ -80,7 +80,7 @@

    - for_html_attr() ?>"> diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index 03993bb2..5a7f7b6c 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -43,7 +43,7 @@

    - adding more modules! Each module provides new cool features.", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Modules")) ?> + adding more modules! Each module provides new cool features.", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Modules")) ?>

    diff --git a/modules/gallery/views/admin_themes.html.php b/modules/gallery/views/admin_themes.html.php index 9d53779f..547f27d2 100644 --- a/modules/gallery/views/admin_themes.html.php +++ b/modules/gallery/views/admin_themes.html.php @@ -10,7 +10,7 @@

    - with a new theme! There are separate themes for the regular site and for the administration interface. Click a theme below to preview and activate it.", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Themes")) ?> + with a new theme! There are separate themes for the regular site and for the administration interface. Click a theme below to preview and activate it.", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Themes")) ?>

    @@ -48,7 +48,7 @@

    - Download one now!", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Themes")) ?> + Download one now!", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Themes")) ?>

    @@ -88,7 +88,7 @@

    - Download one now!", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Themes")) ?> + Download one now!", array("url" => "http://codex.galleryproject.org/Category:Gallery_3:Themes")) ?>

    diff --git a/modules/gallery/views/error_admin.html.php b/modules/gallery/views/error_admin.html.php index 3e7c286e..cd1bd569 100644 --- a/modules/gallery/views/error_admin.html.php +++ b/modules/gallery/views/error_admin.html.php @@ -170,7 +170,7 @@

    There's an error message below and you can find more details in gallery3/var/logs (look for the file with the most recent - date on it). Stuck? Stop by the Gallery 3 + date on it). Stuck? Stop by the Gallery 3 Forums and ask for help. You can also look at our list of open tickets to see if the problem you're seeing has been diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index c1f985c3..4426514a 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -89,7 +89,7 @@ .replace("__INFO__", errorObj.info) .replace("__TYPE__", errorObj.type); } - msg = " - " + + msg = " - " + error_msg + ""; $("#g-add-photos-status ul").append( @@ -131,7 +131,7 @@ admin && !$movies_allowed): ?>

    - ffmpeg on your system. Movie uploading disabled. Help!", array("help_url" => "http://codex.gallery2.org/Gallery3:FAQ#Why_does_it_say_I.27m_missing_ffmpeg.3F")) ?> + ffmpeg on your system. Movie uploading disabled. Help!", array("help_url" => "http://codex.galleryproject.org/Gallery3:FAQ#Why_does_it_say_I.27m_missing_ffmpeg.3F")) ?>

    diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index 70d37dd1..edfaf720 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -144,8 +144,8 @@

    FAQ or ask in the Gallery forums.", - array("faq_url" => "http://codex.gallery2.org/Gallery3:FAQ", - "forums_url" => "http://gallery.menalto.com/forum")) ?> + array("faq_url" => "http://codex.galleryproject.org/Gallery3:FAQ", + "forums_url" => "http://galleryproject.org/forum")) ?>

    diff --git a/modules/gallery/views/welcome_message.html.php b/modules/gallery/views/welcome_message.html.php index 1fcca971..bb6b4a83 100644 --- a/modules/gallery/views/welcome_message.html.php +++ b/modules/gallery/views/welcome_message.html.php @@ -27,10 +27,10 @@

    - Gallery website has news and information about the Gallery project and community.", array("url" => "http://gallery.menalto.com")) ?> + Gallery website has news and information about the Gallery project and community.", array("url" => "http://galleryproject.org")) ?>

    - documentation site or you can ask for help in the forums!", array("codex_url" => "http://codex.gallery2.org/Main_Page", "forum_url" => "http://gallery.menalto.com/forum")) ?> + documentation site or you can ask for help in the forums!", array("codex_url" => "http://codex.galleryproject.org/Main_Page", "forum_url" => "http://galleryproject.org/forum")) ?>

    diff --git a/modules/image_block/module.info b/modules/image_block/module.info index 6722cc8f..25b89e6a 100644 --- a/modules/image_block/module.info +++ b/modules/image_block/module.info @@ -2,6 +2,6 @@ name = "Image Block" description = "Display a random image in the sidebar" version = 3 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:image_block" -discuss_url = "http://gallery.menalto.com/forum_module_image_block" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:image_block" +discuss_url = "http://galleryproject.org/forum_module_image_block" diff --git a/modules/info/module.info b/modules/info/module.info index f8964a78..0f35c922 100644 --- a/modules/info/module.info +++ b/modules/info/module.info @@ -2,6 +2,6 @@ name = "Info" description = "Display extra information about photos and albums" version = 2 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:info" -discuss_url = "http://gallery.menalto.com/forum_module_info" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:info" +discuss_url = "http://galleryproject.org/forum_module_info" diff --git a/modules/notification/module.info b/modules/notification/module.info index 84be8f99..0e2cdb65 100644 --- a/modules/notification/module.info +++ b/modules/notification/module.info @@ -2,6 +2,6 @@ name = "Notification" description = "Send notifications to users when changes are made to watched albums." version = 2 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:notification" -discuss_url = "http://gallery.menalto.com/forum_module_notification" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:notification" +discuss_url = "http://galleryproject.org/forum_module_notification" diff --git a/modules/organize/module.info b/modules/organize/module.info index 07b9dc38..4d4560b9 100644 --- a/modules/organize/module.info +++ b/modules/organize/module.info @@ -2,6 +2,6 @@ name = "Organize" description = "Visually rearrange and move photos in your gallery" version = 4 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:organize" -discuss_url = "http://gallery.menalto.com/forum_module_organize" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:organize" +discuss_url = "http://galleryproject.org/forum_module_organize" diff --git a/modules/recaptcha/module.info b/modules/recaptcha/module.info index ebaff7de..6806bb91 100644 --- a/modules/recaptcha/module.info +++ b/modules/recaptcha/module.info @@ -2,6 +2,6 @@ name = "reCAPTCHA" description = "reCAPTCHA displays a graphical verification that protects the input form from abuse from 'bots,' or automated programs usually written to generate spam (http://recaptcha.net)." version = 1 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:recaptcha" -discuss_url = "http://gallery.menalto.com/forum_module_recaptcha" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:recaptcha" +discuss_url = "http://galleryproject.org/forum_module_recaptcha" diff --git a/modules/rest/module.info b/modules/rest/module.info index 33c9f1cf..93a7873b 100644 --- a/modules/rest/module.info +++ b/modules/rest/module.info @@ -3,6 +3,6 @@ description = "A REST-based API that allows desktop clients and other apps to in version = 3 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:rest" -discuss_url = "http://gallery.menalto.com/forum_module_rest" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:rest" +discuss_url = "http://galleryproject.org/forum_module_rest" diff --git a/modules/rss/module.info b/modules/rss/module.info index cd13c1b0..5f32387e 100644 --- a/modules/rss/module.info +++ b/modules/rss/module.info @@ -2,6 +2,6 @@ name = "RSS" description = "Provides RSS feeds" version = 1 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:rss" -discuss_url = "http://gallery.menalto.com/forum_module_rss" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:rss" +discuss_url = "http://galleryproject.org/forum_module_rss" diff --git a/modules/search/module.info b/modules/search/module.info index 1389798d..f1bb1fab 100644 --- a/modules/search/module.info +++ b/modules/search/module.info @@ -2,6 +2,6 @@ name = "Search" description = "Allows users to search their Gallery" version = 1 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:search" -discuss_url = "http://gallery.menalto.com/forum_module_search" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:search" +discuss_url = "http://galleryproject.org/forum_module_search" diff --git a/modules/server_add/module.info b/modules/server_add/module.info index 4ce0a97d..dc455c71 100644 --- a/modules/server_add/module.info +++ b/modules/server_add/module.info @@ -2,6 +2,6 @@ name = "Server Add" description = "Allows authorized users to load images directly from your web server" version = 4 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:server_add" -discuss_url = "http://gallery.menalto.com/forum_module_server_add" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:server_add" +discuss_url = "http://galleryproject.org/forum_module_server_add" diff --git a/modules/slideshow/module.info b/modules/slideshow/module.info index 8c9a3176..2d71f710 100644 --- a/modules/slideshow/module.info +++ b/modules/slideshow/module.info @@ -2,6 +2,6 @@ name = "Slideshow" description = "Allows users to view a slideshow of photos" version = 2 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:slideshow" -discuss_url = "http://gallery.menalto.com/forum_module_slideshow" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:slideshow" +discuss_url = "http://galleryproject.org/forum_module_slideshow" diff --git a/modules/tag/module.info b/modules/tag/module.info index 75d16bf0..19fbdb45 100644 --- a/modules/tag/module.info +++ b/modules/tag/module.info @@ -2,6 +2,6 @@ name = "Tags" description = "Allows users to tag photos and albums" version = 3 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:tag" -discuss_url = "http://gallery.menalto.com/forum_module_tag" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:tag" +discuss_url = "http://galleryproject.org/forum_module_tag" diff --git a/modules/user/module.info b/modules/user/module.info index 503bcd0d..d5128db4 100644 --- a/modules/user/module.info +++ b/modules/user/module.info @@ -3,6 +3,6 @@ description = "Gallery 3 user and group management" version = 4 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:user" -discuss_url = "http://gallery.menalto.com/forum_module_user" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:user" +discuss_url = "http://galleryproject.org/forum_module_user" diff --git a/modules/watermark/module.info b/modules/watermark/module.info index 58efa43f..e5003cda 100644 --- a/modules/watermark/module.info +++ b/modules/watermark/module.info @@ -2,6 +2,6 @@ name = "Watermarks" description = "Allows users to watermark their photos" version = 2 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Modules:watermark" -discuss_url = "http://gallery.menalto.com/forum_module_watermark" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Modules:watermark" +discuss_url = "http://galleryproject.org/forum_module_watermark" diff --git a/themes/admin_wind/theme.info b/themes/admin_wind/theme.info index 466d8e43..e2be9284 100644 --- a/themes/admin_wind/theme.info +++ b/themes/admin_wind/theme.info @@ -5,6 +5,6 @@ author = "Gallery Team" admin = 1 site = 0 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Themes:admin_wind" -discuss_url = "http://gallery.menalto.com/forum_theme_admin_wind" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Themes:admin_wind" +discuss_url = "http://galleryproject.org/forum_theme_admin_wind" diff --git a/themes/wind/theme.info b/themes/wind/theme.info index e0be78b9..b00e56d7 100644 --- a/themes/wind/theme.info +++ b/themes/wind/theme.info @@ -5,6 +5,6 @@ author = "Gallery Team" site = 1 admin = 0 author_name = "Gallery Team" -author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Themes:wind" -discuss_url = "http://gallery.menalto.com/forum_theme_wind" +author_url = "http://codex.galleryproject.org/Gallery:Team" +info_url = "http://codex.galleryproject.org/Gallery3:Themes:wind" +discuss_url = "http://galleryproject.org/forum_theme_wind" -- cgit v1.2.3 From eefc9d555374678665f79275d0c6b6a70b7d443e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 23 Jan 2013 14:03:44 -0500 Subject: Use the thumb proportion from the first item in an album if the album has children. Fixes #1958. --- modules/gallery/libraries/Theme_View.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules') diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 1dfa72a0..8d69f23b 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -63,6 +63,13 @@ class Theme_View_Core extends Gallery_View { * @return int */ public function thumb_proportion($item=null) { + // If the item is an album with children, grab the first item in that album instead. We're + // interested in the size of the thumbnails in this album, not the thumbnail of the + // album itself. + if ($item && $item->is_album() && $item->children_count()) { + $item = $item->children(1)->current(); + } + // By default we have a globally fixed thumbnail size In core code, we just return a fixed // proportion based on the global thumbnail size, but since modules can override that, we // return the actual proportions when we have them. -- cgit v1.2.3 From 80d6a895edb1cfc3dd0bcacd0d2c63b40c04670c Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Wed, 23 Jan 2013 21:59:02 +0200 Subject: #1952 Add bulk tagging to the Organize module. Allow a user to highlight one or more items (images, videos, or albums), and enter a tag (or tags, comma delimited) and apply it to all of the selected items. The code is based on the batchtag module. If the tags module is not enabled, no changes to the Organize UI will be shown. --- modules/organize/controllers/organize.php | 22 +++++++++ modules/organize/views/organize_frame.html.php | 68 +++++++++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index b0c13e7d..b0158278 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -182,6 +182,28 @@ class Organize_Controller extends Controller { json::reply(null); } + function tag() { + access::verify_csrf(); + $input = Input::instance(); + + foreach (explode(",", $input->post("item_ids")) as $item_id) { + $item = ORM::factory("item", $item_id); + if (access::can("edit", $item)) { + // Assuming the user can view/edit the current item, loop + // through each tag that was submitted and apply it to + // the current item. + foreach (explode(",", $input->post("tag_names")) as $tag_name) { + $tag_name = trim($tag_name); + if ($tag_name) { + tag::add($item, $tag_name); + } + } + } + } + + json::reply(null); + } + private function _get_tree($item, $selected) { $tree = array(); $children = $item->viewable() diff --git a/modules/organize/views/organize_frame.html.php b/modules/organize/views/organize_frame.html.php index 51d49104..c33b7607 100644 --- a/modules/organize/views/organize_frame.html.php +++ b/modules/organize/views/organize_frame.html.php @@ -104,9 +104,33 @@ }); } + var tag_selected_items = function(tag) { + var nodes = thumb_data_view.getSelectedNodes(); + var item_ids = []; + for (var i = 0; i != nodes.length; i++) { + var node = Ext.fly(nodes[i]); + item_ids.push(get_id_from_node(node)); + } + start_busy(for_js() ?>); + Ext.Ajax.request({ + url: '', + method: "post", + success: function() { + stop_busy(); + reload_album_data(); + }, + failure: show_generic_error, + params: { + item_ids: item_ids.join(","), + tag_names: tag, + csrf: '' + } + }); + }; + var delete_selected_items = function() { var nodes = thumb_data_view.getSelectedNodes(); - item_ids = []; + var item_ids = []; for (var i = 0; i != nodes.length; i++) { var node = Ext.fly(nodes[i]); item_ids.push(get_id_from_node(node)); @@ -254,6 +278,7 @@ }); }, "selectionchange": function(v, selections) { + tag_button.setDisabled(!selections.length || !current_album_editable || !tag_textfield.getValue()); delete_button.setDisabled(!selections.length || !current_album_editable); } }, @@ -330,6 +355,31 @@ displayField: "value" }); + var tag_textfield = new Ext.form.TextField({ + flex: 4, + enableKeyEvents: true, + listeners: { + "keyup": function(v, e) { + var nodes = thumb_data_view.getSelectedNodes(); + tag_button.setDisabled(!nodes.length || !current_album_editable || !tag_textfield.getValue()); + } + } + }); + + var tag_button = new Ext.Button({ + flex: 2, + text: for_js() ?>, + cls: "x-btn-text-icon", + id: "tag-button", + disabled: true, + listeners: { + "click": function() { + tag_selected_items(tag_textfield.getValue()); + return true; + } + } + }); + var delete_button = new Ext.Button({ flex: 2, text: for_js() ?>, @@ -375,10 +425,24 @@ sort_column_combobox, sort_order_combobox ] - }, { + }, + + { + xtype: "spacer", + flex: 3 + }, + tag_textfield, + tag_button, + { + xtype: "spacer", + flex: 1 + }, + + { xtype: "spacer", flex: 10 }, + delete_button, { xtype: "button", -- cgit v1.2.3 From a1a66004571c2f6161335f9413b39d255190f153 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 23 Jan 2013 18:03:09 -0500 Subject: Enable the profiler and debug output if var/PROFILE exists. This provides a quick/easy way for server admins to provide profile output. Fixes #1959. --- modules/gallery/helpers/gallery.php | 8 ++++++++ modules/gallery/helpers/gallery_theme.php | 4 ++-- modules/gallery/libraries/MY_Database.php | 3 +++ modules/rest/helpers/rest.php | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 38002b58..725a710d 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -214,4 +214,12 @@ class gallery_Core { } return null; } + + /** + * Return true if we should show the profiler at the bottom of the page. Note that this + * function is called at database setup time so it cannot rely on the database. + */ + static function show_profiler() { + return file_exists(VARPATH . "PROFILE"); + } } \ No newline at end of file diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index f94b9ecd..3c6d71e9 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -71,7 +71,7 @@ class gallery_theme_Core { static function page_bottom($theme) { $session = Session::instance(); - if ($session->get("profiler", false)) { + if (gallery::show_profiler()) { Profiler::enable(); $profiler = new Profiler(); $profiler->render(); @@ -96,7 +96,7 @@ class gallery_theme_Core { static function admin_page_bottom($theme) { $session = Session::instance(); - if ($session->get("profiler", false)) { + if (gallery::show_profiler()) { Profiler::enable(); $profiler = new Profiler(); $profiler->render(); diff --git a/modules/gallery/libraries/MY_Database.php b/modules/gallery/libraries/MY_Database.php index 604b6484..aae0bb79 100644 --- a/modules/gallery/libraries/MY_Database.php +++ b/modules/gallery/libraries/MY_Database.php @@ -32,6 +32,9 @@ abstract class Database extends Database_Core { $config["connection"]["params"] = null; } parent::__construct($config); + if (gallery::show_profiler()) { + $this->config['benchmark'] = true; + } } /** diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php index eeedff2a..9b367feb 100644 --- a/modules/rest/helpers/rest.php +++ b/modules/rest/helpers/rest.php @@ -54,7 +54,7 @@ class rest_Core { $html = t("Empty response"); } print "
    $html
    "; - if (Session::instance()->get("profiler", false)) { + if (gallery::show_profiler()) { Profiler::enable(); $profiler = new Profiler(); $profiler->render(); -- cgit v1.2.3 From 9ba9f3953132c5c5de9efb0a4724c7b9300dc9ea Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 23 Jan 2013 18:24:31 -0500 Subject: Add a "can_add" permission bit similar to the "can_edit" bit to the RESTful array representation of Item_Model. Fixes #1903. --- modules/gallery/models/item.php | 12 ++++++++---- modules/gallery/tests/Item_Model_Test.php | 11 ++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 85aca2c1..bbfeee47 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -663,7 +663,7 @@ class Item_Model_Core extends ORM_MPTT { } /** - * Return a view for movies. By default this is a Flowplayer v3