diff options
author | Bharat Mediratta <bharat@menalto.com> | 2013-02-16 23:53:58 -0500 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2013-02-16 23:53:58 -0500 |
commit | cc45e2e33b07cd27a87300f5d239394a14569308 (patch) | |
tree | 874bf217675634692ac0a43e4641d58cc1abbf13 | |
parent | 4203ecc0b3c482e7dd687d70aa326fe7ad9365b0 (diff) | |
parent | 87d20c63af02ae573853da2cb82d7323a56677b5 (diff) |
Merge branch 'master' into jquery_190
-rw-r--r-- | .build_number | 2 | ||||
-rwxr-xr-x | bin/.htaccess | 8 | ||||
-rw-r--r-- | bin/README | 5 | ||||
-rw-r--r-- | index.php | 7 | ||||
-rw-r--r-- | installer/installer.php | 5 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 33 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_task.php | 6 | ||||
-rw-r--r-- | modules/gallery/views/admin_movies.html.php | 2 |
8 files changed, 54 insertions, 14 deletions
diff --git a/.build_number b/.build_number index 6f2a9ebc..d2d451a0 100644 --- a/.build_number +++ b/.build_number @@ -3,4 +3,4 @@ ; process. You don't need to edit it. In fact.. ; ; DO NOT EDIT THIS FILE BY HAND! -build_number=347 +build_number=352 diff --git a/bin/.htaccess b/bin/.htaccess new file mode 100755 index 00000000..a3815526 --- /dev/null +++ b/bin/.htaccess @@ -0,0 +1,8 @@ +DirectoryIndex .htaccess +SetHandler Gallery_Security_Do_Not_Remove +Options None +<IfModule mod_rewrite.c> +RewriteEngine off +</IfModule> +Order allow,deny +Deny from all diff --git a/bin/README b/bin/README new file mode 100644 index 00000000..ec09639f --- /dev/null +++ b/bin/README @@ -0,0 +1,5 @@ +This directory contains utility software that Gallery uses to perform +image manipulation and other useful functions. It should not be +accessible from a web browser, and by default it's empty. Gallery +will instruct you when it's appropriate to download software and +install it here. @@ -29,13 +29,6 @@ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { exit("Gallery is not supported on Windows (PHP reports that you're using: " . PHP_OS . ")"); } -// Gallery doesn't use Zend Guard code obfuscation, and Kohana 2.4 will not work if level is 3+. -if (function_exists("zend_current_obfuscation_level") && (zend_current_obfuscation_level() >= 3)) { - exit("Gallery doesn't use Zend Guard code obfuscation, and is incompatible if it's running " . - "with a level of 3 or higher. For Gallery to run, please edit your main php.ini file and " . - "change/add the following line: 'zend_loader.obfuscation_level_support = 2'"); -} - // PHP 5.4 requires a timezone - if one isn't set date functions aren't going to work properly. // We'll log this once the logging system is initialized (in the gallery_event::gallery_ready). if (!ini_get("date.timezone")) { diff --git a/installer/installer.php b/installer/installer.php index 2b0f1452..4ce80ee7 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -243,11 +243,6 @@ class installer { $errors[] = "Gallery cannot function when PHP is in <a href=\"http://php.net/manual/en/features.safe-mode.php\">Safe Mode</a>. Please disable safe mode."; } - if (function_exists("zend_current_obfuscation_level") && (zend_current_obfuscation_level() >= 3)) { - $errors[] = "Gallery doesn't use <a href=\"http://www.zend.com/en/products/guard\">Zend Guard code obfuscation</a>, and is incompatible if it's running " . - "with a level of 3 or higher. Please edit your main php.ini file and change/add the following line: 'zend_loader.obfuscation_level_support = 2'"; - } - return @$errors; } diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 54c60296..26432ef5 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -36,6 +36,39 @@ class gallery_event_Core { locales::set_request_locale(); } + static function gallery_shutdown() { + // Every 500th request, do a pass over var/logs and var/tmp and delete old files. + // Limit ourselves to deleting a single file so that we don't spend too much CPU + // time on it. As long as servers call this at least twice a day they'll eventually + // wind up with a clean var/logs directory because we only create 1 file a day there. + // var/tmp might be stickier because theoretically we could wind up spamming that + // dir with a lot of files. But let's start with this and refine as we go. + if (!(rand() % 500)) { + // Note that this code is roughly duplicated in gallery_event::gallery_shutdown + $threshold = time() - 1209600; // older than 2 weeks + foreach(array("logs", "tmp") as $dir) { + $dir = VARPATH . $dir; + if ($dh = opendir($dir)) { + while (($file = readdir($dh)) !== false) { + if ($file[0] == ".") { + continue; + } + + // Ignore directories for now, but we should really address them in the long term. + if (is_dir("$dir/$file")) { + continue; + } + + if (filemtime("$dir/$file") <= $threshold) { + unlink("$dir/$file"); + break; + } + } + } + } + } + } + static function user_deleted($user) { $admin = identity::admin_user(); if (!empty($admin)) { // could be empty if there is not identity provider diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 856d2639..a79cb2d5 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -281,6 +281,7 @@ class gallery_task_Core { switch ($task->get("mode", "init")) { case "init": $threshold = time() - 1209600; // older than 2 weeks + // Note that this code is roughly duplicated in gallery_event::gallery_shutdown foreach(array("logs", "tmp") as $dir) { $dir = VARPATH . $dir; if ($dh = opendir($dir)) { @@ -289,6 +290,11 @@ class gallery_task_Core { continue; } + // Ignore directories for now, but we should really address them in the long term. + if (is_dir("$dir/$file")) { + continue; + } + if (filemtime("$dir/$file") <= $threshold) { $files[] = "$dir/$file"; } diff --git a/modules/gallery/views/admin_movies.html.php b/modules/gallery/views/admin_movies.html.php index e7810711..242a4349 100644 --- a/modules/gallery/views/admin_movies.html.php +++ b/modules/gallery/views/admin_movies.html.php @@ -8,7 +8,7 @@ <p> <?= t("Although popular, FFmpeg is not installed on all Linux systems.") ?> <?= t("To use FFmpeg without fully installing it, download a pre-compiled, <b>static build</b> of FFmpeg from one of the links <a href=\"%url\">here</a>.", array("url" => "http://ffmpeg.org/download.html")) ?> - <?= t("Then, put the \"ffmpeg\" file in Gallery's \"bin\" directory (e.g. \"/gallery/bin\"), where Gallery will auto-detect it.") ?> + <?= t("Then, put the \"ffmpeg\" file in Gallery's \"bin\" directory (e.g. \"/gallery3/bin\"), where Gallery will auto-detect it.") ?> </p> <p> <?= t("Movies will work without FFmpeg, but their thumbnails will be placeholders.") ?> |