From f4778699fc52c045f60d72e20bebc000d9f6bda8 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 26 Jun 2009 08:19:06 -0700 Subject: Change the movie controller to set the page type to "movie". Ticket #467 --- modules/gallery/controllers/movies.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 86b0f177..d8cca825 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -44,7 +44,7 @@ class Movies_Controller extends Items_Controller { ->where("id <=", $photo->id) ->count_all(); - $template = new Theme_View("page.html", "photo"); + $template = new Theme_View("page.html", "movie"); $template->set_global("item", $photo); $template->set_global("children", array()); $template->set_global("children_count", $photo->children_count()); -- cgit v1.2.3 From 11f08ee4399c62cc1d2c36457a214c6db693db06 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 26 Jun 2009 21:42:02 -0700 Subject: Implement the combined javascript controller. --- modules/gallery/controllers/javascript.php | 64 ++++++++++++++++++++++++++++++ modules/gallery/libraries/Theme_View.php | 29 ++++++++++++-- 2 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 modules/gallery/controllers/javascript.php (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/javascript.php b/modules/gallery/controllers/javascript.php new file mode 100644 index 00000000..d3c0ded5 --- /dev/null +++ b/modules/gallery/controllers/javascript.php @@ -0,0 +1,64 @@ +scripts)); + $key = ""; foreach (array_keys($this->scripts) as $file) { - $links[] = html::script($file); + $path = DOCROOT . $file; + if (file_exists($path)) { + $stats = stat($path); + $links[] = $path; + // 7 == size, 9 == mtime, see http://php.net/stat + $key = "{$key}$file $stats[7] $stats[9],"; + } else { + Kohana::log("warn", "Javascript file missing: " . $file); + } + } + + $key = md5($key); + $file = "tmp/CombinedJavascript_$key"; + if (!file_exists(VARPATH . $file)) { + $contents = ''; + foreach ($links as $link) { + $contents .= file_get_contents($link); + } + file_put_contents(VARPATH . $file, $contents); + if (function_exists("gzencode")) { + file_put_contents(VARPATH . "{$file}_gzip", gzencode($contents, 9, FORCE_GZIP)); + } } - return empty($links) ? "" : implode("\n", $links); + + return ""; } /** -- cgit v1.2.3 From bf26ca727e615e61a8f61a2bbf1a83572cfa5c20 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 28 Jun 2009 15:30:13 -0700 Subject: Change the combined javascript to use the new caching functionality and respect the HTTP_IF_MODIFIED_SINCE header request. --- modules/gallery/controllers/javascript.php | 37 +++++++++++++++++------------- modules/gallery/libraries/Theme_View.php | 11 +++++---- 2 files changed, 28 insertions(+), 20 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/javascript.php b/modules/gallery/controllers/javascript.php index d3c0ded5..bc231e0a 100644 --- a/modules/gallery/controllers/javascript.php +++ b/modules/gallery/controllers/javascript.php @@ -20,30 +20,35 @@ class Javascript_Controller extends Controller { public function combined($key) { if (preg_match('/[^0-9a-f]/', $key)) { - /* The key can't contain non-hex, so just terminate early */ + // The key can't contain non-hex, so just terminate early Kohana::show_404(); } // We don't need to save the session for this request Session::abort_save(); - Kohana::log("error", Kohana::debug($_SERVER)); // Dump out the javascript file - $ext = strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ? "_gzip" : ""; - $file = VARPATH . "tmp/CombinedJavascript_$key{$ext}"; + $cache = Cache::instance(); - if (!file_exists($file)) { - Kohana::show_404(); + $modified = $cache->get("{$key}_modified"); + if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && !empty($modified)) { + header('HTTP/1.0 304 Not Modified'); + return; } - $stats = stat($file); - if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && - $stats[9] <= $_SERVER["HTTP_IF_MODIFIED_SINCE"]) { - header("HTTP/1.0 304 Not Modified"); - return; + $content = ""; + if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ) { + $content = $cache->get("{$key}_gz"); + } + + if (empty($content)) { + $content = $cache->get($key); + } + + if (empty($content)) { + Kohana::show_404(); } - Kohana::log("error", Kohana::debug($_SERVER)); if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) { header("Content-Encoding: gzip"); header("Cache-Control: private, x-gzip-ok=\"public\""); @@ -52,13 +57,13 @@ class Javascript_Controller extends Controller { header("Content-Type: text/javascript; charset=UTF-8"); header("Expires: " . gmdate(21474383647)); - header("Last-Modified: " . gmdate($stats[9])); + header("Last-Modified: " . $modified); Kohana::close_buffers(false); - $fd = fopen($file, "rb"); - fpassthru($fd); - fclose($fd); + $handle = fopen("php://output", "wb"); + fwrite($handle, $content); + fclose($handle); } } diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 167f8a8d..f55cb55a 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -188,18 +188,21 @@ class Theme_View_Core extends View { } $key = md5($key); - $file = "tmp/CombinedJavascript_$key"; - if (!file_exists(VARPATH . $file)) { + $contents = Cache::instance()->get($key); + if (empty($contents)) { $contents = ''; foreach ($links as $link) { $contents .= file_get_contents($link); } - file_put_contents(VARPATH . $file, $contents); + Cache::instance()->set($key, $contents, array("javascript"), 84600); if (function_exists("gzencode")) { - file_put_contents(VARPATH . "{$file}_gzip", gzencode($contents, 9, FORCE_GZIP)); + Cache::instance()->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP), + array("javascript", "gzip"), 84600); } + Cache::instance()->set("{$key}_modified", time(), array("javascript", "modified"), 84600); } + // Handcraft the script link because html::script will add a .js extenstion return ""; } -- cgit v1.2.3 From aa31e1f0090522c3cfb3a44b947ad8c33a275979 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 28 Jun 2009 16:24:51 -0700 Subject: Tweak the cache implementation 1) Drop the *_modified key, we don't really need it. The modification date is not relevant to our browser caching strategy. 2) Fix multiple issues with the Expires header and just hardcode it to the biggest possibly value for code clarity. 3) print the $content out directly instead of using fwrite 4) Minor cleanups in the installer. --- modules/gallery/controllers/javascript.php | 21 ++++++------------ modules/gallery/helpers/gallery_installer.php | 32 +++++++++++++-------------- modules/gallery/libraries/Theme_View.php | 16 +++++++++----- 3 files changed, 33 insertions(+), 36 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/javascript.php b/modules/gallery/controllers/javascript.php index bc231e0a..ba5cbf4b 100644 --- a/modules/gallery/controllers/javascript.php +++ b/modules/gallery/controllers/javascript.php @@ -27,16 +27,13 @@ class Javascript_Controller extends Controller { // We don't need to save the session for this request Session::abort_save(); - // Dump out the javascript file - $cache = Cache::instance(); - - $modified = $cache->get("{$key}_modified"); - if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && !empty($modified)) { + // Our data is immutable, so if they already have a copy then it needs no updating. + if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { header('HTTP/1.0 304 Not Modified'); return; } - $content = ""; + $cache = Cache::instance(); if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ) { $content = $cache->get("{$key}_gz"); } @@ -51,19 +48,15 @@ class Javascript_Controller extends Controller { if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) { header("Content-Encoding: gzip"); - header("Cache-Control: private, x-gzip-ok=\"public\""); + header("Cache-Control: public"); } header("Content-Type: text/javascript; charset=UTF-8"); - - header("Expires: " . gmdate(21474383647)); - header("Last-Modified: " . $modified); + header("Expires: Tue, 19 Jan 2038 00:00:00 GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time())); Kohana::close_buffers(false); - - $handle = fopen("php://output", "wb"); - fwrite($handle, $content); - fclose($handle); + print $content; } } diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 8ccbd51b..d0bfa629 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -32,6 +32,15 @@ class gallery_installer { PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {caches} ( + `id` varchar(255) NOT NULL, + `tags` varchar(255), + `expiration` int(9) NOT NULL, + `cache` longblob, + PRIMARY KEY (`id`), + KEY (`tags`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {graphics_rules} ( `id` int(9) NOT NULL auto_increment, `active` BOOLEAN default 0, @@ -181,15 +190,6 @@ class gallery_installer { UNIQUE KEY(`module_name`, `name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {caches} ( - `id` varchar(255) NOT NULL, - `tags` varchar(255), - `expiration` int(9) NOT NULL, - `cache` longblob, - PRIMARY KEY (`id`), - KEY (`tags`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) { @mkdir(VARPATH . $dir); } @@ -278,13 +278,13 @@ class gallery_installer { if ($version == 3) { $db->query("CREATE TABLE {caches} ( - `id` varchar(255) NOT NULL, - `tags` varchar(255), - `expiration` int(9) NOT NULL, - `cache` text, - PRIMARY KEY (`id`), - KEY (`tags`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + `id` varchar(255) NOT NULL, + `tags` varchar(255), + `expiration` int(9) NOT NULL, + `cache` text, + PRIMARY KEY (`id`), + KEY (`tags`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); module::set_version("gallery", $version = 4); } if ($version == 4) { diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index f55cb55a..c3acfeb3 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -172,6 +172,10 @@ class Theme_View_Core extends View { $this->scripts[$file] = 1; } + /** + * Combine a series of Javascript files into a single one and cache it in the database, then + * return a single "; } -- cgit v1.2.3 From 6ec293dfe70665c528d803b78a2bb295633496ec Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 29 Jun 2009 08:24:42 -0700 Subject: *Note* work in progress. Implement the combined css functionality. Local url references and replace with absolute urls instead of relative. --- modules/gallery/controllers/combined.php | 46 +++++++++++++++++++++++++++++ modules/gallery/libraries/Gallery_View.php | 47 ++++++++++++++++++++++++++++-- themes/default/views/page.html.php | 2 +- 3 files changed, 91 insertions(+), 4 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php index 510482db..50fe77c4 100644 --- a/modules/gallery/controllers/combined.php +++ b/modules/gallery/controllers/combined.php @@ -58,5 +58,51 @@ class Combined_Controller extends Controller { Kohana::close_buffers(false); print $content; } + + public function css($key) { + if (preg_match('/[^0-9a-f]/', $key)) { + // The key can't contain non-hex, so just terminate early + Kohana::show_404(); + } + + // We don't need to save the session for this request + Session::abort_save(); + + // Our data is immutable, so if they already have a copy then it needs no updating. + if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { + header('HTTP/1.0 304 Not Modified'); + return; + } + + $cache = Cache::instance(); + if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ) { + $content = $cache->get("{$key}_gz"); + } + + if (empty($content)) { + $content = $cache->get($key); + } + + if (empty($content)) { + Kohana::show_404(); + } + + if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) { + header("Content-Encoding: gzip"); + header("Cache-Control: public"); + } + + header("Content-Type: text/css; charset=UTF-8"); + header("Expires: Tue, 19 Jan 2038 00:00:00 GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time())); + + Kohana::close_buffers(false); + print $content; + } + + public function __call($function, $args) { + array_unshift($args, $function); + print ""; + } } diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 7000d3de..1c1dec38 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -113,12 +113,53 @@ class Gallery_View_Core extends View { protected function combine_css() { $links = array(); $key = ""; + static $PATTERN = "#url\(\s*['|\"]{0,1}(.*?)['|\"]{0,1}\s*\)#"; + foreach (array_keys($this->css) as $file) { - $links[] = ""; + $path = DOCROOT . $file; + if (file_exists($path)) { + $stats = stat($path); + $links[] = $path; + // 7 == size, 9 == mtime, see http://php.net/stat + $key = "{$key}$file $stats[7] $stats[9],"; + } else { + Kohana::log("alert", "CSS file missing: " . $file); + } + } + $key = md5($key); + $cache = Cache::instance(); + $contents = $cache->get($key); + $docroot_length = strlen(DOCROOT); + + if (empty($contents)) { + $contents = ""; + foreach ($links as $link) { + $css = file_get_contents($link); + if (preg_match_all($PATTERN, $css, $matches, PREG_SET_ORDER)) { + $search = $replace = array(); + foreach ($matches as $match) { + $relative = substr(realpath(dirname($link) . "/$match[1]"), $docroot_length); + if (!empty($relative)) { + $search[] = $match[1]; + $replace[] = url::abs_file($relative); + } else { + Kohana::log("alert", sprintf("Missing URL reference '%s' in CSS file '%s' ", + $match[1], $link)); + } + } + $css = str_replace($search, $replace, $css); + } + $contents .= $css; + } + $cache->set($key, $contents, array("css"), 30 * 84600); + if (function_exists("gzencode")) { + $cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP), + array("css", "gzip"), 30 * 84600); + } } - return implode("\n", $links); + return ""; } } \ No newline at end of file diff --git a/themes/default/views/page.html.php b/themes/default/views/page.html.php index f6984958..2e68f571 100644 --- a/themes/default/views/page.html.php +++ b/themes/default/views/page.html.php @@ -25,8 +25,8 @@ " type="image/x-icon" /> css("lib/yui/reset-fonts-grids.css") ?> - css("lib/themeroller/ui.base.css") ?> css("lib/superfish/css/superfish.css") ?> + css("lib/themeroller/ui.base.css") ?> theme_css("css/screen.css") ?> "; - } } diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index 01496c0d..5e0d5feb 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -99,6 +99,7 @@ class Admin_View_Core extends Gallery_View { } if ($function == "admin_head") { + array_unshift($blocks, $this->combine_css()); array_unshift($blocks, $this->combine_script()); } diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 1c1dec38..b4cfde46 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -113,7 +113,6 @@ class Gallery_View_Core extends View { protected function combine_css() { $links = array(); $key = ""; - static $PATTERN = "#url\(\s*['|\"]{0,1}(.*?)['|\"]{0,1}\s*\)#"; foreach (array_keys($this->css) as $file) { $path = DOCROOT . $file; @@ -130,27 +129,12 @@ class Gallery_View_Core extends View { $key = md5($key); $cache = Cache::instance(); $contents = $cache->get($key); - $docroot_length = strlen(DOCROOT); + $contents = ""; if (empty($contents)) { $contents = ""; foreach ($links as $link) { - $css = file_get_contents($link); - if (preg_match_all($PATTERN, $css, $matches, PREG_SET_ORDER)) { - $search = $replace = array(); - foreach ($matches as $match) { - $relative = substr(realpath(dirname($link) . "/$match[1]"), $docroot_length); - if (!empty($relative)) { - $search[] = $match[1]; - $replace[] = url::abs_file($relative); - } else { - Kohana::log("alert", sprintf("Missing URL reference '%s' in CSS file '%s' ", - $match[1], $link)); - } - } - $css = str_replace($search, $replace, $css); - } - $contents .= $css; + $contents .= $this->process_css($link); } $cache->set($key, $contents, array("css"), 30 * 84600); if (function_exists("gzencode")) { @@ -162,4 +146,38 @@ class Gallery_View_Core extends View { url::site("combined/css/$key") . "\" />"; } + private function process_css($css_file) { + static $PATTERN = "#url\(\s*['|\"]{0,1}(.*?)['|\"]{0,1}\s*\)#"; + $docroot_length = strlen(DOCROOT); + + $css = file_get_contents($css_file); + if (preg_match_all($PATTERN, $css, $matches, PREG_SET_ORDER)) { + $search = $replace = array(); + foreach ($matches as $match) { + $relative = substr(realpath(dirname($css_file) . "/$match[1]"), $docroot_length); + if (!empty($relative)) { + $search[] = $match[0]; + $replace[] = "url('" . url::abs_file($relative) . "')"; + } else { + Kohana::log("alert", sprintf("Missing URL reference '%s' in CSS file '%s' ", + $match[1], $css_file)); + } + } + $css = str_replace($search, $replace, $css); + } + $imports = preg_match_all("#@import\s*['|\"]{0,1}(.*?)['|\"]{0,1};#", + $css, $matches, PREG_SET_ORDER); + + if ($imports) { + $search = $replace = array(); + foreach ($matches as $match) { + Kohana::log("error", dirname($css_file) . "/$match[1]"); + $search[] = $match[0]; + $replace[] = $this->process_css(dirname($css_file) . "/$match[1]"); + } + $css = str_replace($search, $replace, $css); + } + + return $css; + } } \ No newline at end of file -- cgit v1.2.3 From 006b63030a364677143799c7ce41eabb10c86eee Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 29 Jun 2009 15:38:55 -0700 Subject: Combine the Combined::javascript and Combined::css into a single method implemented by the magic method __call. The first parameter is the content type for text/xxxx and the 2nd parameter is the key of the combined file. --- modules/gallery/controllers/combined.php | 46 ++++---------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php index 399a60f4..8a157e6b 100644 --- a/modules/gallery/controllers/combined.php +++ b/modules/gallery/controllers/combined.php @@ -18,48 +18,11 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Combined_Controller extends Controller { - public function javascript($key) { - if (preg_match('/[^0-9a-f]/', $key)) { - // The key can't contain non-hex, so just terminate early - Kohana::show_404(); - } - - // We don't need to save the session for this request - Session::abort_save(); - - // Our data is immutable, so if they already have a copy then it needs no updating. - if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { - header('HTTP/1.0 304 Not Modified'); - return; - } - - $cache = Cache::instance(); - if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ) { - $content = $cache->get("{$key}_gz"); - } - - if (empty($content)) { - $content = $cache->get($key); - } - - if (empty($content)) { + public function __call($type, $key) { + if (empty($key)) { Kohana::show_404(); } - - if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) { - header("Content-Encoding: gzip"); - header("Cache-Control: public"); - } - - header("Content-Type: text/javascript; charset=UTF-8"); - header("Expires: Tue, 19 Jan 2038 00:00:00 GMT"); - header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time())); - - Kohana::close_buffers(false); - print $content; - } - - public function css($key) { + $key = $key[0]; if (preg_match('/[^0-9a-f]/', $key)) { // The key can't contain non-hex, so just terminate early Kohana::show_404(); @@ -92,12 +55,13 @@ class Combined_Controller extends Controller { header("Cache-Control: public"); } - header("Content-Type: text/css; charset=UTF-8"); + header("Content-Type: text/$type; charset=UTF-8"); header("Expires: Tue, 19 Jan 2038 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time())); Kohana::close_buffers(false); print $content; } + } -- cgit v1.2.3 From 3080317d6e5e4ea9e56b1fd5444c4bcf5852c362 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 29 Jun 2009 17:44:02 -0700 Subject: Refactor combined controller a bit 1) Create public javascript() and css() functions and turn __call() into a private function to protect us against having some random type show up in there. Otherwise anything you put in the 2nd argument gets emitted in the header which is a security hole. 2) Fix a bug ("$key = $key[0]") which was breaking functionality. Eliminate the hex check, it's not really necessary in the majority case and doesn't hurt us in edge cases. 3) Convert some empty() calls to !, no need for a function call there. 4) Add phpDoc. --- modules/gallery/controllers/combined.php | 41 ++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php index 8a157e6b..f6c6d60b 100644 --- a/modules/gallery/controllers/combined.php +++ b/modules/gallery/controllers/combined.php @@ -18,35 +18,49 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Combined_Controller extends Controller { - public function __call($type, $key) { - if (empty($key)) { - Kohana::show_404(); - } - $key = $key[0]; - if (preg_match('/[^0-9a-f]/', $key)) { - // The key can't contain non-hex, so just terminate early - Kohana::show_404(); - } + /** + * Return the combined Javascript bundle associated with the given key. + */ + public function javascript($key) { + return $this->_emit("javascript", $key); + } - // We don't need to save the session for this request - Session::abort_save(); + /** + * Return the combined CSS bundle associated with the given key. + */ + public function css($key) { + return $this->_emit("css", $key); + } + /** + * Print out a cached entry. + * @param string the combined entry type (either "javascript" or "css") + * @param string the key (typically an md5 sum) + */ + private function _emit($type, $key) { // Our data is immutable, so if they already have a copy then it needs no updating. if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { header('HTTP/1.0 304 Not Modified'); return; } + if (empty($key)) { + Kohana::show_404(); + } + + // We don't need to save the session for this request + Session::abort_save(); + $cache = Cache::instance(); if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ) { $content = $cache->get("{$key}_gz"); } - if (empty($content)) { + if (!$content) { $content = $cache->get($key); } - if (empty($content)) { + if (!$content) { Kohana::show_404(); } @@ -55,6 +69,7 @@ class Combined_Controller extends Controller { header("Cache-Control: public"); } + // $type is either 'javascript' or 'css' header("Content-Type: text/$type; charset=UTF-8"); header("Expires: Tue, 19 Jan 2038 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time())); -- cgit v1.2.3 From fa8ca2f7ad21980f0b45e7acc67be4be296f9f87 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 29 Jun 2009 18:12:53 -0700 Subject: Refactor combine_xxx() functions together into combine_files() and use html functions to generate the resulting elements. Add phpdoc. --- modules/gallery/controllers/combined.php | 2 + modules/gallery/libraries/Admin_View.php | 6 +-- modules/gallery/libraries/Gallery_View.php | 81 ++++++++++-------------------- modules/gallery/libraries/Theme_View.php | 4 +- 4 files changed, 34 insertions(+), 59 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php index f6c6d60b..9df74638 100644 --- a/modules/gallery/controllers/combined.php +++ b/modules/gallery/controllers/combined.php @@ -22,6 +22,7 @@ class Combined_Controller extends Controller { * Return the combined Javascript bundle associated with the given key. */ public function javascript($key) { + $key = substr($key, 0, strlen($key) - 3); // strip off the trailing .js return $this->_emit("javascript", $key); } @@ -29,6 +30,7 @@ class Combined_Controller extends Controller { * Return the combined CSS bundle associated with the given key. */ public function css($key) { + $key = substr($key, 0, strlen($key) - 4); // strip off the trailing .css return $this->_emit("css", $key); } diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index 5e0d5feb..f7de96bf 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -98,9 +98,9 @@ class Admin_View_Core extends Gallery_View { } } - if ($function == "admin_head") { - array_unshift($blocks, $this->combine_css()); - array_unshift($blocks, $this->combine_script()); + if ($function == "head") { + array_unshift($blocks, $this->combine_files($this->css, "css")); + array_unshift($blocks, $this->combine_files($this->css, "javascript")); } if (Session::instance()->get("debug")) { diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 9d4fe5c0..48cf8089 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -49,45 +49,6 @@ class Gallery_View_Core extends View { return $absolute_url ? url::abs_file($arg) : url::file($arg); } - /** - * Combine a series of Javascript files into a single one and cache it in the database, then - * return a single "; - } - /** * Add a css file to the combined css list. * @param $file the relative path to a script from the gallery3 directory @@ -107,12 +68,11 @@ class Gallery_View_Core extends View { } /** - * Combine a series of Javascript files into a single one and cache it in the database, then - * return a single
- p::clean($item->title))) ?> + p::purify($item->title))) ?>
diff --git a/modules/search/views/search.html.php b/modules/search/views/search.html.php index 5db07bad..d173f734 100644 --- a/modules/search/views/search.html.php +++ b/modules/search/views/search.html.php @@ -31,10 +31,10 @@ id") ?>"> thumb_img() ?>

- title) ?> + title) ?>

- description) ?> + description) ?>
diff --git a/themes/default/views/album.html.php b/themes/default/views/album.html.php index 46b0d29a..273b8a4e 100644 --- a/themes/default/views/album.html.php +++ b/themes/default/views/album.html.php @@ -2,8 +2,8 @@
album_top() ?> -

title) ?>

-
description) ?>
+

title) ?>

+
description) ?>
    diff --git a/themes/default/views/header.html.php b/themes/default/views/header.html.php index 51f55b41..5428d9fd 100644 --- a/themes/default/views/header.html.php +++ b/themes/default/views/header.html.php @@ -19,10 +19,10 @@
  • id}?show=$item->id") ?>"> - title) ?> + title) ?>
  • -
  • title) ?>
  • +
  • title) ?>
diff --git a/themes/default/views/movie.html.php b/themes/default/views/movie.html.php index c2fb0e30..2cd9806f 100644 --- a/themes/default/views/movie.html.php +++ b/themes/default/views/movie.html.php @@ -15,8 +15,8 @@ movie_img(array("class" => "gMovie", "id" => "gMovieId-{$item->id}")) ?>
-

title) ?>

-
description) ?>
+

title) ?>

+
description) ?>
+
+

name ?>

+
+
get_task_log()) ?>
+
+ + +
diff --git a/themes/admin_default/css/screen.css b/themes/admin_default/css/screen.css index e68620a5..d408acf0 100644 --- a/themes/admin_default/css/screen.css +++ b/themes/admin_default/css/screen.css @@ -400,6 +400,20 @@ li.gDefaultGroup h4, li.gDefaultGroup .gUser { float: left; } +#gTaskLogDialog h1 { + font-size: 1.1em; +} + +.gTaskLog { + border: 1pt solid; + font-size: .9em; + height: 400px; + margin: .5em 0; + overflow: auto; + padding: .5em +} + + /** ******************************************************************* * 7) Server Add *********************************************************************/ -- cgit v1.2.3 From 493fb27825327e14168c3c0b133c338a53457e0e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Mon, 6 Jul 2009 22:20:04 -0700 Subject: Cleanup remove task processing. Change Task_Model::delete to call parent::delete instead of parent::save. :-) Also change admin_maintenance_controller to delete via looping over all of the completed tasks and delete individually, so we can delete the associated cache entries at the same time. --- modules/gallery/controllers/admin_maintenance.php | 9 ++++++++- modules/gallery/models/task.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php index a65bd770..37cc5222 100644 --- a/modules/gallery/controllers/admin_maintenance.php +++ b/modules/gallery/controllers/admin_maintenance.php @@ -161,7 +161,14 @@ class Admin_Maintenance_Controller extends Admin_Controller { public function remove_finished_tasks() { access::verify_csrf(); - Database::instance()->delete("tasks", array("done" => 1)); + + // Do it the long way so we can call delete and remove the cache. + $finished = ORM::factory("task") + ->where(array("done" => 1)) + ->find_all(); + foreach ($finished as $task) { + task::remove($task->id); + } message::success(t("All finished tasks removed")); url::redirect("admin/maintenance"); } diff --git a/modules/gallery/models/task.php b/modules/gallery/models/task.php index 2e77a7a6..012b88cf 100644 --- a/modules/gallery/models/task.php +++ b/modules/gallery/models/task.php @@ -42,7 +42,7 @@ class Task_Model extends ORM { public function delete() { Cache::instance()->delete($this->_cache_key()); - return parent::save(); + return parent::delete(); } public function owner() { -- cgit v1.2.3 From 5d9e334fe6d7c7c1cf6d39a12684e215e797b4b3 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 7 Jul 2009 12:49:21 -0700 Subject: Added a wee bit of phpDoc. Changed the name of the method get_task_log to get_log Changed the default name of the file when the log is downloaded to gallery3_task_log.txt --- modules/gallery/controllers/admin_maintenance.php | 4 ++-- modules/gallery/models/task.php | 14 +++++++++++++- modules/gallery/views/admin_maintenance.html.php | 2 +- modules/gallery/views/admin_maintenance_show_log.html.php | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php index 37cc5222..543961a1 100644 --- a/modules/gallery/controllers/admin_maintenance.php +++ b/modules/gallery/controllers/admin_maintenance.php @@ -119,8 +119,8 @@ class Admin_Maintenance_Controller extends Admin_Controller { } header("Content-Type: application/text"); - header("Content-Disposition: filename=g2_import.txt"); - print $task->get_task_log(); + header("Content-Disposition: filename=gallery3_task_log.txt"); + print $task->get_log(); } /** diff --git a/modules/gallery/models/task.php b/modules/gallery/models/task.php index 55bb8e21..b7e255a2 100644 --- a/modules/gallery/models/task.php +++ b/modules/gallery/models/task.php @@ -49,6 +49,10 @@ class Task_Model extends ORM { return user::lookup($this->owner_id); } + /** + * Log a message to the task log. + * @params $msg mixed a string or array of strings + */ public function log($msg) { $key = $this->_cache_key(); $log = Cache::instance()->get($key); @@ -63,11 +67,19 @@ class Task_Model extends ORM { array("task", "log", "import"), 2592000); } - public function get_task_log() { + /** + * Retrieve the cached log information for this task. + * @returns the log data or null if there is no log data + */ + public function get_log() { $log_data = Cache::instance()->get($this->_cache_key()); return $log_data !== null ? $log_data : false; } + /** + * Build the task cache key + * @returns the key to use in access the cache + */ private function _cache_key() { return md5("$this->id; $this->name; $this->callback"); } diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index f50c95dd..eecc045c 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -164,7 +164,7 @@ id?csrf=$csrf") ?>"> - get_task_log()): ?> + get_log()): ?> id?csrf=$csrf") ?>"> diff --git a/modules/gallery/views/admin_maintenance_show_log.html.php b/modules/gallery/views/admin_maintenance_show_log.html.php index afd988bb..9d850986 100644 --- a/modules/gallery/views/admin_maintenance_show_log.html.php +++ b/modules/gallery/views/admin_maintenance_show_log.html.php @@ -12,7 +12,7 @@ appendTo('body').submit().remove();

name ?>

-
get_task_log()) ?>
+
get_log()) ?>
-- cgit v1.2.3 From 09c9b1a75561881a40ada71f02710355923602e2 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 11:35:28 -0700 Subject: Added the upload::required validation in order to insure that failed uploads are not treated as successful. Log any exceptions to the Kohana log and return the error message --- modules/gallery/controllers/simple_uploader.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index 713e30af..a059f986 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -1,3 +1,4 @@ + add_rules( - "Filedata", "upload::valid", "upload::type[gif,jpg,jpeg,png,flv,mp4]"); + "Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4]"); if ($file_validation->validate()) { // SimpleUploader.swf does not yet call /start directly, so simulate it here for now. if (!batch::in_progress()) { @@ -54,7 +55,7 @@ class Simple_Uploader_Controller extends Controller { try { $name = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds $title = item::convert_filename_to_title($name); - $path_info = pathinfo($temp_filename); + $path_info = @pathinfo($temp_filename); if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { $movie = movie::create($album, $temp_filename, $name, $title); @@ -66,12 +67,20 @@ class Simple_Uploader_Controller extends Controller { html::anchor("photos/$photo->id", t("view photo"))); } } catch (Exception $e) { - unlink($temp_filename); - throw $e; + Kohana::log("alert", $e->__toString()); + if (file_exists($temp_filename)) { + unlink($temp_filename); + } + header("HTTP/1.1 500 Internal Server Error"); + print "ERROR:" . $e->getMessage(); + return; } unlink($temp_filename); + print "FILEID: $photo->id"; + } else { + header("HTTP/1.1 400 Bad Request"); + print "ERROR: Invalid Upload"; } - print "File Received"; } public function finish() { -- cgit v1.2.3 From 6281ed03d54a010efdee3988a893cfcd7f3663b5 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 05:36:31 -0700 Subject: Turn off extended inserts when creating install.sql so that it's easier to see what's changed. --- installer/install.sql | 49 ++++++++++++++++++++++++++------ modules/gallery/controllers/packager.php | 4 +-- 2 files changed, 43 insertions(+), 10 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/installer/install.sql b/installer/install.sql index d719d49d..bda576d1 100755 --- a/installer/install.sql +++ b/installer/install.sql @@ -88,7 +88,8 @@ CREATE TABLE {graphics_rules} ( PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','resize',100,'thumb'),(2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:480;s:6:\"master\";i:2;}','gallery','resize',100,'resize'); +INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','resize',100,'thumb'); +INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:480;s:6:\"master\";i:2;}','gallery','resize',100,'resize'); DROP TABLE IF EXISTS {groups}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -100,7 +101,8 @@ CREATE TABLE {groups} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {groups} VALUES (1,'Everybody',1),(2,'Registered Users',1); +INSERT INTO {groups} VALUES (1,'Everybody',1); +INSERT INTO {groups} VALUES (2,'Registered Users',1); DROP TABLE IF EXISTS {groups_users}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -111,7 +113,9 @@ CREATE TABLE {groups_users} ( UNIQUE KEY `user_id` (`user_id`,`group_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {groups_users} VALUES (1,1),(1,2),(2,2); +INSERT INTO {groups_users} VALUES (1,1); +INSERT INTO {groups_users} VALUES (1,2); +INSERT INTO {groups_users} VALUES (2,2); DROP TABLE IF EXISTS {incoming_translations}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -221,7 +225,15 @@ CREATE TABLE {modules} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {modules} VALUES (1,1,'gallery',6),(2,1,'user',1),(3,1,'comment',2),(4,1,'organize',1),(5,1,'info',1),(6,1,'rss',1),(7,1,'search',1),(8,1,'slideshow',1),(9,1,'tag',1); +INSERT INTO {modules} VALUES (1,1,'gallery',6); +INSERT INTO {modules} VALUES (2,1,'user',1); +INSERT INTO {modules} VALUES (3,1,'comment',2); +INSERT INTO {modules} VALUES (4,1,'organize',1); +INSERT INTO {modules} VALUES (5,1,'info',1); +INSERT INTO {modules} VALUES (6,1,'rss',1); +INSERT INTO {modules} VALUES (7,1,'search',1); +INSERT INTO {modules} VALUES (8,1,'slideshow',1); +INSERT INTO {modules} VALUES (9,1,'tag',1); DROP TABLE IF EXISTS {outgoing_translations}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -248,7 +260,10 @@ CREATE TABLE {permissions} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {permissions} VALUES (1,'View','view'),(2,'View Full Size','view_full'),(3,'Edit','edit'),(4,'Add','add'); +INSERT INTO {permissions} VALUES (1,'View','view'); +INSERT INTO {permissions} VALUES (2,'View Full Size','view_full'); +INSERT INTO {permissions} VALUES (3,'Edit','edit'); +INSERT INTO {permissions} VALUES (4,'Add','add'); DROP TABLE IF EXISTS {search_records}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -313,7 +328,8 @@ CREATE TABLE {themes} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {themes} VALUES (1,'default',1),(2,'admin_default',1); +INSERT INTO {themes} VALUES (1,'default',1); +INSERT INTO {themes} VALUES (2,'admin_default',1); DROP TABLE IF EXISTS {users}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -335,7 +351,8 @@ CREATE TABLE {users} ( UNIQUE KEY `hash` (`hash`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL),(2,'admin','Gallery Administrator','',0,0,NULL,1,0,NULL,NULL,NULL); +INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL); +INSERT INTO {users} VALUES (2,'admin','Gallery Administrator','',0,0,NULL,1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -348,4 +365,20 @@ CREATE TABLE {vars} ( UNIQUE KEY `module_name` (`module_name`,`name`) ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 pre beta 2 (git)'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','date_format','Y-M-d'),(20,'gallery','date_time_format','Y-M-d H:i:s'),(21,'gallery','time_format','H:i:s'),(22,'gallery','show_credits','1'),(23,'gallery','credits','Powered by Gallery %version'),(25,'comment','spam_caught','0'); +INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'); +INSERT INTO {vars} VALUES (2,'gallery','active_admin_theme','admin_default'); +INSERT INTO {vars} VALUES (3,'gallery','page_size','9'); +INSERT INTO {vars} VALUES (4,'gallery','thumb_size','200'); +INSERT INTO {vars} VALUES (5,'gallery','resize_size','640'); +INSERT INTO {vars} VALUES (6,'gallery','default_locale','en_US'); +INSERT INTO {vars} VALUES (7,'gallery','image_quality','75'); +INSERT INTO {vars} VALUES (9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'); +INSERT INTO {vars} VALUES (14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'); +INSERT INTO {vars} VALUES (17,'gallery','version','3.0 pre beta 2 (git)'); +INSERT INTO {vars} VALUES (18,'gallery','choose_default_tookit','1'); +INSERT INTO {vars} VALUES (19,'gallery','date_format','Y-M-d'); +INSERT INTO {vars} VALUES (20,'gallery','date_time_format','Y-M-d H:i:s'); +INSERT INTO {vars} VALUES (21,'gallery','time_format','H:i:s'); +INSERT INTO {vars} VALUES (22,'gallery','show_credits','1'); +INSERT INTO {vars} VALUES (23,'gallery','credits','Powered by Gallery %version'); +INSERT INTO {vars} VALUES (25,'comment','spam_caught','0'); diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php index da0a7983..7b4d68f6 100644 --- a/modules/gallery/controllers/packager.php +++ b/modules/gallery/controllers/packager.php @@ -98,7 +98,7 @@ class Packager_Controller extends Controller { print "$sql_file is not writeable"; return; } - $command = "mysqldump --compact --add-drop-table -h{$conn['host']} " . + $command = "mysqldump --compact --skip-extended-insert --add-drop-table -h{$conn['host']} " . "-u{$conn['user']} $pass {$conn['database']} > $sql_file"; exec($command, $output, $status); if ($status) { @@ -153,7 +153,7 @@ class Packager_Controller extends Controller { $paths[] = "VARPATH . \"" . substr($name, strlen(VARPATH)) . "\""; } else { // @todo: serialize non-directories - print "Unknown file: $name"; + print "IGNORING FILE: $name\n"; return; } } -- cgit v1.2.3 From 4d0099e7165a4a1508eea58613cdc75e116464ff Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 06:24:10 -0700 Subject: Fix a bug where we're referring to $photo when we just uploaded a $movie, that causes the simpler uploader to throw an error for all movies. --- modules/gallery/controllers/simple_uploader.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index a059f986..75a7b810 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -58,13 +58,13 @@ class Simple_Uploader_Controller extends Controller { $path_info = @pathinfo($temp_filename); if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { - $movie = movie::create($album, $temp_filename, $name, $title); + $item = movie::create($album, $temp_filename, $name, $title); log::success("content", t("Added a movie"), - html::anchor("movies/$movie->id", t("view movie"))); + html::anchor("movies/$item->id", t("view movie"))); } else { - $photo = photo::create($album, $temp_filename, $name, $title); + $item = photo::create($album, $temp_filename, $name, $title); log::success("content", t("Added a photo"), - html::anchor("photos/$photo->id", t("view photo"))); + html::anchor("photos/$item->id", t("view photo"))); } } catch (Exception $e) { Kohana::log("alert", $e->__toString()); @@ -76,7 +76,7 @@ class Simple_Uploader_Controller extends Controller { return; } unlink($temp_filename); - print "FILEID: $photo->id"; + print "FILEID: $item->id"; } else { header("HTTP/1.1 400 Bad Request"); print "ERROR: Invalid Upload"; -- cgit v1.2.3 From e2967aa1c1a0232e1a1f162db46e6f6db7154dac Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:45:41 -0700 Subject: Fix a problem in delete() where we were referencing $parent without saving its value before $item got deleted. Further fix for #528. --- modules/gallery/controllers/quick.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 53af2ba6..de027c1b 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -127,6 +127,7 @@ class Quick_Controller extends Controller { $msg = t("Deleted photo %title", array("title" => p::purify($item->title))); } + $parent = $item->parent(); $item->delete(); message::success($msg); -- cgit v1.2.3 From 980923839930fde45120872dcadd437abfbbc09d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 19:17:12 -0700 Subject: Unescape ' also (single quote) --- modules/gallery/controllers/file_proxy.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 0d64bcd9..03303d66 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -32,8 +32,9 @@ class File_Proxy_Controller extends Controller { $request_uri = $this->input->server("REQUEST_URI"); $request_uri = preg_replace("/\?.*/", "", $request_uri); - // Unescape %7E ("~") and %20 (" ") - $request_uri = str_replace(array("%7E", "%20"), array("~", " "), $request_uri); + // Unescape %7E (~), %20 ( ) and ' (') + // @todo: figure out why we have to do this and unescape everything appropriate + $request_uri = str_replace(array("%7E", "%20", "'"), array("~", " ", "'"), $request_uri); // var_uri: http://example.com/gallery3/var/ $var_uri = url::file("var/"); -- cgit v1.2.3 From 9588e8604d46e548dc4ac8788589f9f89b1992ab Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 12 Jul 2009 20:08:02 -0700 Subject: Use %27 instead of ' (the latter is the wrong form of escaping for urls). --- modules/gallery/controllers/file_proxy.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 03303d66..c5b34033 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -32,9 +32,9 @@ class File_Proxy_Controller extends Controller { $request_uri = $this->input->server("REQUEST_URI"); $request_uri = preg_replace("/\?.*/", "", $request_uri); - // Unescape %7E (~), %20 ( ) and ' (') + // Unescape %7E (~), %20 ( ) and %27 (') // @todo: figure out why we have to do this and unescape everything appropriate - $request_uri = str_replace(array("%7E", "%20", "'"), array("~", " ", "'"), $request_uri); + $request_uri = str_replace(array("%7E", "%20", "%27"), array("~", " ", "'"), $request_uri); // var_uri: http://example.com/gallery3/var/ $var_uri = url::file("var/"); -- cgit v1.2.3 From 2cba5d93956ce38f6d08ca350124d9bd21270be6 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 15 Jul 2009 07:56:52 +0800 Subject: Fix 542 by changing the wording from you to your, thanks Floridave Signed-off-by: Tim Almdal --- modules/gallery/controllers/admin_languages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php index 4639de89..d1b805da 100644 --- a/modules/gallery/controllers/admin_languages.php +++ b/modules/gallery/controllers/admin_languages.php @@ -119,7 +119,7 @@ class Admin_Languages_Controller extends Admin_Controller { private function _share_translations_form() { $form = new Forge("admin/languages/share", "", "post", array("id" => "gShareTranslationsForm")); $group = $form->group("sharing") - ->label(t("Sharing you own translations with the Gallery community is easy. Please do!")); + ->label(t("Sharing your own translations with the Gallery community is easy. Please do!")); $api_key = l10n_client::api_key(); $server_link = l10n_client::server_api_key_url(); $group->input("api_key") -- cgit v1.2.3 From c4fce2cc680c3257cf6ea7844b8ee9e61c02db09 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 15 Jul 2009 20:32:53 -0700 Subject: Remove a completed @todo. --- modules/gallery/controllers/albums.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index d141d157..e6d01b90 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -181,10 +181,6 @@ class Albums_Controller extends Items_Controller { } } - // @todo - // @todo we need to make sure that filename / dirname components can't contain a / - // @todo - if ($valid) { $orig = clone $album; $album->title = $form->edit_album->title->value; -- cgit v1.2.3