Files
gallery3/modules/gallery/helpers/graphics.php
Chad Parry 97c3ded2ba Better validation for uploaded files, especially where third-party modules might make a mistake.
Squashed commit of the following:

commit f2336a5aaa
Author: Chad Parry <github@chad.parry.org>
Date:   Wed May 18 21:56:10 2011 -0600

    Behave reasonably if the image cannot be resized.

commit e06b20738d
Author: Chad Parry <github@chad.parry.org>
Date:   Wed May 18 21:10:08 2011 -0600

    Adding an image representing a broken thumbnail.
    This image was derived from the equivalent Gallery2 icon. It uses the same washed-out gray color scheme as the Gallery3 missing_movie icon.

commit 4e3964527b
Author: Chad Parry <github@chad.parry.org>
Date:   Wed May 18 20:30:28 2011 -0600

    Initialize legal file arrays correctly.

commit e9862d8fbc
Author: Chad Parry <github@chad.parry.org>
Date:   Wed May 18 20:20:19 2011 -0600

    Correction for the merge conflict markers I accidentally committed.

commit 5e62d327a8
Author: Chad Parry <github@chad.parry.org>
Date:   Wed May 18 20:17:36 2011 -0600

    Expand the legal_file events to include separate photo and movie events, and to support MIME types.

commit f0bfd1fef0
Merge: 72f3fc4 db73413
Author: Chad Parry <github@chad.parry.org>
Date:   Wed May 18 19:49:25 2011 -0600

    Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto

    Conflicts:
    	modules/gallery/helpers/system.php
    	modules/gallery/tests/System_Helper_Test.php

commit db734130c5
Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com>
Date:   Mon May 16 21:38:07 2011 -0700

    Automated update of .build_number to 153 for branch master
    Last update: 9aeb824aa1 (1 commits ago)

commit 8549ba30ca
Author: Chad Kieffer <ckieffer@gmail.com>
Date:   Mon May 16 22:37:09 2011 -0600

    Stop IE 9 album grid craziness. Thanks floridave. Fixes #1430.

commit 9aeb824aa1
Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com>
Date:   Sun May 8 11:43:38 2011 -0700

    Automated update of .build_number to 152 for branch master
    Last update: 7c80e6ef84 (1 commits ago)

commit 57f7e42a12
Author: Bharat Mediratta <bharat@menalto.com>
Date:   Sun May 8 11:42:40 2011 -0700

    Add the item id to the print_proxy line so that we have a little more info
    about what the original was, and extend the timeout to 90 days from 10.
    Fixes #1733.

commit 7c80e6ef84
Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com>
Date:   Fri May 6 11:48:43 2011 -0700

    Automated update of .build_number to 151 for branch master
    Last update: 5d09cbff04 (1 commits ago)

commit 80dda6f64f
Merge: 5d09cbf 46da011
Author: Bharat Mediratta <bharat@menalto.com>
Date:   Fri May 6 11:48:13 2011 -0700

    Merge pull request #52 from chadparry/tempnam

    Fixes #1732

commit 5d09cbff04
Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com>
Date:   Thu May 5 21:53:39 2011 -0700

    Automated update of .build_number to 150 for branch master
    Last update: 011eaa6480 (1 commits ago)

commit d5a31ceede
Author: Tim Almdal <tnalmdal@shaw.ca>
Date:   Thu May 5 21:53:10 2011 -0700

    Fix for ticket 1275. Do the same checking as Kohana uses and don't worry about calling the utf8_encode routine.
    Corrected the error messages and also added a check to insure the XML Parser extension is loaded as we still need the utf8_encode function from it.

commit 011eaa6480
Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com>
Date:   Thu May 5 14:53:06 2011 -0700

    Automated update of .build_number to 149 for branch master
    Last update: 05ecfda36b (1 commits ago)

commit 5bae21864f
Author: Bharat Mediratta <bharat@menalto.com>
Date:   Thu May 5 14:52:47 2011 -0700

    Follow-on to 6f916e49d5 -- don't make
    database calls if Gallery isn't installed, else we fail to bounce the
    user to the installer on fresh packages.  #1637.

commit 46da011bf6
Author: Chad Parry <github@chad.parry.org>
Date:   Wed May 4 17:51:00 2011 -0600

    Remove a newline I accidentally introduced.

commit 5c6c71ffcd
Merge: d2331bf 05ecfda
Author: Chad Parry <github@chad.parry.org>
Date:   Wed May 4 17:49:42 2011 -0600

    Merge branch 'master' into tempnam

commit d2331bf434
Author: Chad Parry <github@chad.parry.org>
Date:   Wed May 4 17:48:25 2011 -0600

    Simplified the temp_filename implementation and removed the mocks.

commit 72f3fc46f6
Author: Chad Parry <github@chad.parry.org>
Date:   Wed May 4 17:22:15 2011 -0600

    Avoid "self::" because Kohana can't override it.

commit 05ecfda36b
Author: Automatic Build Number Updater <bharat+gallery3_build_number_updater@menalto.com>
Date:   Mon May 2 21:38:50 2011 -0700

    Automated update of .build_number to 148 for branch master
    Last update: 97400b7815 (2 commits ago)

commit 229bfc5c7c
Author: Bharat Mediratta <bharat@menalto.com>
Date:   Mon May 2 21:37:04 2011 -0700

    Track and redirect core.DownloadItem requests properly.  This can
    happen if the G2 was imported with rewrite on, so the g2_url in the
    g2_map table has a shortened url, but then rewrite is disabled and the
    .htaccess mod_rewrite rules are sending over a &g2_view=core.DownloadItem
    request.  Fixes #1728.

commit 68370b92f5
Author: Bharat Mediratta <bharat@menalto.com>
Date:   Mon May 2 21:36:17 2011 -0700

    Map the G2 album highlight thumbnail derivative id to the G3 album's
    thumbnail.  Fixes #1729.

commit 13dbd3515b
Merge: f0f094c 97400b7
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 30 20:33:02 2011 -0600

    Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto

commit f0f094c3f7
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 30 20:22:49 2011 -0600

    Explain the conditional rename in item::save() with a comment.

commit 1b3a6b85c1
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 30 18:29:34 2011 -0600

    Improve the comment explaining why the data_file extension is important.

commit c3e8c1e3b5
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 30 18:12:56 2011 -0600

    The data_file field is public, so we don't need to supply an accessor method.

commit 0e844766ba
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 30 16:40:55 2011 -0600

    Change the signature of system::tempnam to something more appropriate for Gallery.

commit 5c9a3b3f39
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 23 21:19:47 2011 -0600

    Create a tempnam substitute that safely creates files with a given extension.

commit 2375a02e2c
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 30 16:40:55 2011 -0600

    Change the signature of system::tempnam to something more appropriate for Gallery.

commit a8ca9dcf9e
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 30 16:10:06 2011 -0600

    Change the name of the extensions helper to legal_file.

commit 7e61a01a96
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 30 16:08:49 2011 -0600

    Change the name of the extensions helper to legal_file.

commit 4c2b2ebd3f
Author: Chad Parry <github@chad.parry.org>
Date:   Wed Apr 27 20:52:35 2011 -0600

    Remove a newline at the end of the file that I accidentally introduced.

commit 6d564f185e
Merge: 7ff485f 4060640
Author: Chad Parry <github@chad.parry.org>
Date:   Wed Apr 27 20:35:58 2011 -0600

    Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto

commit 7ff485fa48
Author: Chad Parry <github@chad.parry.org>
Date:   Wed Apr 27 20:29:06 2011 -0600

    Move the extensions helpers out of the Kohana system directory and into their own Gallery Extensions class.

commit 26585fed03
Merge: 809567f c8f90e8
Author: Chad Parry <github@chad.parry.org>
Date:   Sun Apr 24 08:28:39 2011 -0600

    Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto

commit 809567f128
Author: Chad Parry <github@chad.parry.org>
Date:   Sun Apr 24 08:10:04 2011 -0600

    Expose the data file field.

commit fcb06bf175
Author: Chad Parry <github@chad.parry.org>
Date:   Sun Apr 24 00:45:12 2011 -0600

    Don't assign to the item->name field if the name is unchanged, because the save method will crash.

commit c6ef706d70
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 23 22:55:59 2011 -0600

    Preserve old data files long enough for them to be available to event handlers.

commit 0d6a3a3cfc
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 23 21:19:47 2011 -0600

    Create a tempnam substitute that safely creates files with a given extension.

commit e149cf7238
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 23 16:39:25 2011 -0600

    Support data files that change their extension and MIME type.

commit 6702104f57
Author: Chad Parry <github@chad.parry.org>
Date:   Sat Apr 23 16:35:00 2011 -0600

    Resolve an infinite recursion that happens when the path caches are updated during saving.

commit 944cb72eea
Merge: 567522b 5af74d4
Author: Chad Parry <github@chad.parry.org>
Date:   Fri Apr 22 14:10:42 2011 -0600

    Merge remote branch 'origin/master' into rawphoto

commit 567522bfa0
Author: Chad Parry <github@chad.parry.org>
Date:   Thu Apr 21 20:12:32 2011 -0600

    Add an event for when a new graphics toolkit is chosen.

commit 31ba081b79
Author: Chad Parry <github@chad.parry.org>
Date:   Thu Apr 21 02:06:53 2011 -0600

    Add an event that will collect all valid filename extensions.
2011-05-18 22:01:51 -06:00

461 lines
16 KiB
PHP

<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class graphics_Core {
private static $init;
private static $_rules_cache = array();
/**
* Add a new graphics rule.
*
* Rules are applied to targets (thumbnails and resizes) in priority order. Rules are functions
* in the graphics class. So for example, the following rule:
*
* graphics::add_rule("gallery", "thumb", "gallery_graphics::resize",
* array("width" => 200, "height" => 200, "master" => Image::AUTO), 100);
*
* Specifies that "gallery" is adding a rule to resize thumbnails down to a max of 200px on
* the longest side. The gallery module adds default rules at a priority of 100. You can set
* higher and lower priorities to perform operations before or after this fires.
*
* @param string $module_name the module that added the rule
* @param string $target the target for this operation ("thumb" or "resize")
* @param string $operation the name of the operation (<defining class>::method)
* @param array $args arguments to the operation
* @param integer $priority the priority for this rule (lower priorities are run first)
*/
static function add_rule($module_name, $target, $operation, $args, $priority) {
$rule = ORM::factory("graphics_rule");
$rule->module_name = $module_name;
$rule->target = $target;
$rule->operation = $operation;
$rule->priority = $priority;
$rule->args = serialize($args);
$rule->active = true;
$rule->save();
graphics::mark_dirty($target == "thumb", $target == "resize");
}
/**
* Remove any matching graphics rules
* @param string $module_name the module that added the rule
* @param string $target the target for this operation ("thumb" or "resize")
* @param string $operation the name of the operation(<defining class>::method)
*/
static function remove_rule($module_name, $target, $operation) {
db::build()
->delete("graphics_rules")
->where("module_name", "=", $module_name)
->where("target", "=", $target)
->where("operation", "=", $operation)
->execute();
graphics::mark_dirty($target == "thumb", $target == "resize");
}
/**
* Remove all rules for this module
* @param string $module_name
*/
static function remove_rules($module_name) {
$status = db::build()
->delete("graphics_rules")
->where("module_name", "=", $module_name)
->execute();
if (count($status)) {
graphics::mark_dirty(true, true);
}
}
/**
* Activate the rules for this module, typically done when the module itself is deactivated.
* Note that this does not mark images as dirty so that if you deactivate and reactivate a
* module it won't cause all of your images to suddenly require a rebuild.
*/
static function activate_rules($module_name) {
db::build()
->update("graphics_rules")
->set("active", true)
->where("module_name", "=", $module_name)
->execute();
}
/**
* Deactivate the rules for this module, typically done when the module itself is deactivated.
* Note that this does not mark images as dirty so that if you deactivate and reactivate a
* module it won't cause all of your images to suddenly require a rebuild.
*/
static function deactivate_rules($module_name) {
db::build()
->update("graphics_rules")
->set("active", false)
->where("module_name", "=", $module_name)
->execute();
}
/**
* Rebuild the thumb and resize for the given item.
* @param Item_Model $item
*/
static function generate($item) {
if ($item->is_album()) {
if (!$cover = $item->album_cover()) {
// This album has no cover; there's nothing to generate. Because of an old bug, it's
// possible that there's an album cover item id that points to an invalid item. In that
// case, just null out the album cover item id. It's not optimal to do that at this low
// level, but it's not trivial to find these cases quickly in an upgrade script and if we
// 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
if ($item->album_cover_item_id) {
$item->album_cover_item_id = null;
$item->save();
}
return;
}
$input_file = $cover->file_path();
$input_item = $cover;
} else {
$input_file = $item->file_path();
$input_item = $item;
}
if ($item->thumb_dirty) {
$ops["thumb"] = $item->thumb_path();
}
if ($item->resize_dirty && !$item->is_album() && !$item->is_movie()) {
$ops["resize"] = $item->resize_path();
}
if (empty($ops)) {
$item->thumb_dirty = 0;
$item->resize_dirty = 0;
$item->save();
return;
}
try {
foreach ($ops as $target => $output_file) {
if ($input_item->is_movie()) {
// Convert the movie to a JPG first
$output_file = preg_replace("/...$/", "jpg", $output_file);
try {
movie::extract_frame($input_file, $output_file);
} catch (Exception $e) {
// Assuming this is MISSING_FFMPEG for now
copy(MODPATH . "gallery/images/missing_movie.png", $output_file);
}
$working_file = $output_file;
} else {
$working_file = $input_file;
}
foreach (self::_get_rules($target) as $rule) {
$args = array($working_file, $output_file, unserialize($rule->args), $item);
try {
call_user_func_array($rule->operation, $args);
$working_file = $output_file;
} catch (Exception $e) {
// Ignore this filter and move on.
Kohana_Log::add("error", "Caught exception filtering image: {$item->title}\n" .
$e->getMessage() . "\n" . $e->getTraceAsString());
}
}
}
if (!empty($ops["thumb"])) {
if (file_exists($item->thumb_path())) {
$item->thumb_dirty = 0;
} else {
copy(MODPATH . "gallery/images/missing_photo.png", $item->thumb_path());
}
$dims = getimagesize($item->thumb_path());
$item->thumb_width = $dims[0];
$item->thumb_height = $dims[1];
}
if (!empty($ops["resize"])) {
if (file_exists($item->resize_path())) {
$item->resize_dirty = 0;
} else {
copy(MODPATH . "gallery/images/missing_photo.png", $item->resize_path());
}
$dims = getimagesize($item->resize_path());
$item->resize_width = $dims[0];
$item->resize_height = $dims[1];
}
$item->save();
} catch (Exception $e) {
// Something went wrong rebuilding the image. Leave it dirty and move on.
// @todo we should handle this better.
Kohana_Log::add("error", "Caught exception rebuilding image: {$item->title}\n" .
$e->getMessage() . "\n" . $e->getTraceAsString());
throw $e;
}
}
private static function _get_rules($target) {
if (empty(self::$_rules_cache[$target])) {
$rules = array();
foreach (ORM::factory("graphics_rule")
->where("target", "=", $target)
->where("active", "=", true)
->order_by("priority", "asc")
->find_all() as $rule) {
$rules[] = (object)$rule->as_array();
}
self::$_rules_cache[$target] = $rules;
}
return self::$_rules_cache[$target];
}
/**
* Return a query result that locates all items with dirty images.
* @return Database_Result Query result
*/
static function find_dirty_images_query() {
return db::build()
->from("items")
->and_open()
->and_open()
->where("thumb_dirty", "=", 1)
->and_open()
->where("type", "<>", "album")
->or_where("album_cover_item_id", "IS NOT", null)
->close()
->or_open()
->where("resize_dirty", "=", 1)
->where("type", "=", "photo")
->close()
->close()
->where("id", "<>", 1)
->close();
}
/**
* Mark thumbnails and resizes as dirty. They will have to be rebuilt.
*/
static function mark_dirty($thumbs, $resizes) {
if ($thumbs || $resizes) {
$db = db::build()
->update("items");
if ($thumbs) {
$db->set("thumb_dirty", 1);
}
if ($resizes) {
$db->set("resize_dirty", 1);
}
$db->execute();
}
$count = graphics::find_dirty_images_query()->count_records();
if ($count) {
site_status::warning(
t2("One of your photos is out of date. <a %attrs>Click here to fix it</a>",
"%count of your photos are out of date. <a %attrs>Click here to fix them</a>",
$count,
array("attrs" => html::mark_clean(sprintf(
'href="%s" class="g-dialog-link"',
url::site("admin/maintenance/start/gallery_task::rebuild_dirty_images?csrf=__CSRF__"))))),
"graphics_dirty");
}
}
/**
* Detect which graphics toolkits are available on this system. Return an array of key value
* pairs where the key is one of gd, imagemagick, graphicsmagick and the value is information
* about that toolkit. For GD we return the version string, and for ImageMagick and
* GraphicsMagick we return the path to the directory containing the appropriate binaries.
*/
static function detect_toolkits() {
$toolkits = new stdClass();
$toolkits->gd = new stdClass();
$toolkits->imagemagick = new stdClass();
$toolkits->graphicsmagick = new stdClass();
// GD is special, it doesn't use exec()
$gd = function_exists("gd_info") ? gd_info() : array();
$toolkits->gd->name = "GD";
if (!isset($gd["GD Version"])) {
$toolkits->gd->installed = false;
$toolkits->gd->error = t("GD is not installed");
} else {
$toolkits->gd->installed = true;
$toolkits->gd->version = $gd["GD Version"];
$toolkits->gd->rotate = function_exists("imagerotate");
$toolkits->gd->sharpen = function_exists("imageconvolution");
$toolkits->gd->binary = "";
$toolkits->gd->dir = "";
if (!$toolkits->gd->rotate && !$toolkits->gd->sharpen) {
$toolkits->gd->error =
t("You have GD version %version, but it lacks image rotation and sharpening.",
array("version" => $gd["GD Version"]));
} else if (!$toolkits->gd->rotate) {
$toolkits->gd->error =
t("You have GD version %version, but it lacks image rotation.",
array("version" => $gd["GD Version"]));
} else if (!$toolkits->gd->sharpen) {
$toolkits->gd->error =
t("You have GD version %version, but it lacks image sharpening.",
array("version" => $gd["GD Version"]));
}
}
if (!function_exists("exec")) {
$toolkits->imagemagick->installed = false;
$toolkits->imagemagick->error = t("ImageMagick requires the <b>exec</b> function");
$toolkits->graphicsmagick->installed = false;
$toolkits->graphicsmagick->error = t("GraphicsMagick requires the <b>exec</b> function");
} else {
// ImageMagick & GraphicsMagick
$magick_kits = array(
"imagemagick" => array(
"name" => "ImageMagick", "binary" => "convert", "version_arg" => "-v",
"version_regex" => "/Version: \S+ (\S+)/"),
"graphicsmagick" => array(
"name" => "GraphicsMagick", "binary" => "gm", "version_arg" => "version",
"version_regex" => "/\S+ (\S+)/"));
// Loop through the kits
foreach ($magick_kits as $index => $settings) {
$path = system::find_binary(
$settings["binary"], module::get_var("gallery", "graphics_toolkit_path"));
$toolkits->$index->name = $settings["name"];
if ($path) {
if (@is_file($path) &&
preg_match(
$settings["version_regex"], shell_exec($path . " " . $settings["version_arg"]), $matches)) {
$version = $matches[1];
$toolkits->$index->installed = true;
$toolkits->$index->version = $version;
$toolkits->$index->binary = $path;
$toolkits->$index->dir = dirname($path);
$toolkits->$index->rotate = true;
$toolkits->$index->sharpen = true;
} else {
$toolkits->$index->installed = false;
$toolkits->$index->error =
t("%toolkit_name is installed, but PHP's open_basedir restriction prevents Gallery from using it.",
array("toolkit_name" => $settings["name"]));
}
} else {
$toolkits->$index->installed = false;
$toolkits->$index->error =
t("We could not locate %toolkit_name on your system.",
array("toolkit_name" => $settings["name"]));
}
}
}
return $toolkits;
}
/**
* This needs to be run once, after the initial install, to choose a graphics toolkit.
*/
static function choose_default_toolkit() {
// Detect a graphics toolkit
$toolkits = graphics::detect_toolkits();
foreach (array("imagemagick", "graphicsmagick", "gd") as $tk) {
if ($toolkits->$tk->installed) {
module::set_var("gallery", "graphics_toolkit", $tk);
module::set_var("gallery", "graphics_toolkit_path", $toolkits->$tk->dir);
break;
}
}
if (!module::get_var("gallery", "graphics_toolkit")) {
site_status::warning(
t("Graphics toolkit missing! Please <a href=\"%url\">choose a toolkit</a>",
array("url" => html::mark_clean(url::site("admin/graphics")))),
"missing_graphics_toolkit");
}
}
/**
* Choose which driver the Kohana Image library uses.
*/
static function init_toolkit() {
if (self::$init) {
return;
}
switch(module::get_var("gallery", "graphics_toolkit")) {
case "gd":
Kohana_Config::instance()->set("image.driver", "GD");
break;
case "imagemagick":
Kohana_Config::instance()->set("image.driver", "ImageMagick");
Kohana_Config::instance()->set(
"image.params.directory", module::get_var("gallery", "graphics_toolkit_path"));
break;
case "graphicsmagick":
Kohana_Config::instance()->set("image.driver", "GraphicsMagick");
Kohana_Config::instance()->set(
"image.params.directory", module::get_var("gallery", "graphics_toolkit_path"));
break;
}
self::$init = 1;
}
/**
* Verify that a specific graphics function is available with the active toolkit.
* @param string $func (eg rotate, sharpen)
* @return boolean
*/
static function can($func) {
if (module::get_var("gallery", "graphics_toolkit") == "gd") {
switch ($func) {
case "rotate":
return function_exists("imagerotate");
case "sharpen":
return function_exists("imageconvolution");
}
}
return true;
}
/**
* Return the max file size that this graphics toolkit can handle.
*/
static function max_filesize() {
if (module::get_var("gallery", "graphics_toolkit") == "gd") {
$memory_limit = trim(ini_get("memory_limit"));
$memory_limit_bytes = num::convert_to_bytes($memory_limit);
// GD expands images in memory and uses 4 bytes of RAM for every byte
// in the file.
$max_filesize = $memory_limit_bytes / 4;
$max_filesize_human_readable = num::convert_to_human_readable($max_filesize);
return array($max_filesize, $max_filesize_human_readable);
}
// Some arbitrarily large size
return array(1000000000, "1G");
}
}