aboutsummaryrefslogtreecommitdiffstats
path: root/i.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2012-01-08 19:25:52 +0000
committerrvelices <rv-github@modusoptimus.com>2012-01-08 19:25:52 +0000
commit225b45f2b88d3193ec4012a589749c5814c42205 (patch)
treeebd032867780475a5e41df5a4e0301d3518393e4 /i.php
parent028729f0690f3ffd4e116eecc49d58db08625d63 (diff)
feature 2548 multisize - added a page to build missing derivatives
- browser driven, chained ws calls to retrieve urls, visual feedback of progress through slideshow git-svn-id: http://piwigo.org/svn/trunk@12865 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'i.php')
-rw-r--r--i.php47
1 files changed, 32 insertions, 15 deletions
diff --git a/i.php b/i.php
index 5ab032c90..fb2dbc93a 100644
--- a/i.php
+++ b/i.php
@@ -108,6 +108,10 @@ function parse_request()
else
{
$req = $_SERVER["QUERY_STRING"];
+ if ($pos=strpos($req, '&'))
+ {
+ $req = substr($req, 0, $pos);
+ }
/*foreach (array_keys($_GET) as $keynum => $key)
{
$req = $key;
@@ -167,12 +171,20 @@ function parse_request()
{
try
{
- $page['derivative_params'] = DerivativeParams::from_url_tokens($deriv);
+ $params = $page['derivative_params'] = DerivativeParams::from_url_tokens($deriv);
}
catch (Exception $e)
{
ierror($e->getMessage(), 400);
}
+ if ($params->sizing->ideal_size[0] < 20 or $params->sizing->ideal_size[1] < 20)
+ {
+ ierror('Invalid size', 400);
+ }
+ if ($params->sizing->max_crop < 0 or $params->sizing->max_crop > 1)
+ {
+ ierror('Invalid crop', 400);
+ }
}
if ($req[0]!='g' && $req[0]!='u')
@@ -224,14 +236,6 @@ parse_request();
//var_export($page);
$params = $page['derivative_params'];
-if ($params->sizing->ideal_size[0] < 20 or $params->sizing->ideal_size[1] < 20)
-{
- ierror('Invalid size', 400);
-}
-if ($params->sizing->max_crop < 0 or $params->sizing->max_crop > 1)
-{
- ierror('Invalid crop', 400);
-}
$src_mtime = @filemtime($page['src_path']);
if ($src_mtime === false)
@@ -250,7 +254,12 @@ if ($derivative_mtime === false or
$expires=false;
$now = time();
-if ( $now > (max($src_mtime, $params->last_mod_time) + 24*3600) )
+if ( isset($_GET['b']) )
+{
+ $expires = $now + 100;
+ header("Cache-control: no-store, max-age=100");
+}
+elseif ( $now > (max($src_mtime, $params->last_mod_time) + 24*3600) )
{// somehow arbitrary - if derivative params or src didn't change for the last 24 hours, we send an expire header for several days
$expires = $now + 10*24*3600;
}
@@ -267,6 +276,10 @@ if (!$need_generate)
send_derivative($expires);
}
+if (!mkgetdir(dirname($page['derivative_path'])))
+{
+ ierror("dir create error", 500);
+}
include_once(PHPWG_ROOT_PATH . 'admin/include/image.class.php');
@@ -275,11 +288,6 @@ set_time_limit(0);
$image = new pwg_image($page['src_path']);
-if (!mkgetdir(dirname($page['derivative_path'])))
-{
- ierror("dir create error", 500);
-}
-
$changes = 0;
// todo rotate
@@ -325,6 +333,15 @@ if ($params->use_watermark)
if ($wm->xrepeat)
{
// todo
+ $pad = $wm_size[0] + max(30, round($wm_size[0]/4));
+ for($i=-$wm->xrepeat; $i<=$wm->xrepeat; $i++)
+ {
+ if (!$i) continue;
+ $x2 = $x + $i * $pad;
+ if ($x2>=0 && $x2+$wm_size[0]<$d_size[0])
+ if (!$image->compose($wm_image, $x2, $y, $wm->opacity))
+ break;
+ }
}
}
$wm_image->destroy();