aboutsummaryrefslogtreecommitdiffstats
path: root/include/photo/photo_driver.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/photo/photo_driver.php')
-rw-r--r--include/photo/photo_driver.php25
1 files changed, 20 insertions, 5 deletions
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index b7ace4f37..14408ea50 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -85,6 +85,10 @@ function guess_image_type($filename, $data = '') {
$hdrs = [];
$h = explode("\n", $headers);
foreach ($h as $l) {
+ if (strpos($l, ':') === false) {
+ continue;
+ }
+
list($k, $v) = array_map('trim', explode(':', trim($l), 2));
$hdrs[strtolower($k)] = $v;
}
@@ -251,20 +255,31 @@ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) {
$hdrs = [];
$h = explode("\n", $result['header']);
foreach ($h as $l) {
+ if (strpos($l, ':') === false) {
+ continue;
+ }
+
list($t,$v) = array_map("trim", explode(":", trim($l), 2));
$hdrs[strtolower($t)] = $v;
}
+ $expires = time() + 86400;
+
if(array_key_exists('expires', $hdrs))
$expires = strtotime($hdrs['expires']);
- if($expires - 60 < time())
- $expires = time() + 60;
+
+ if($expires - 60 < time()) {
+ $expires = time() + 60;
+ }
else {
$cc = '';
- if(array_key_exists('cache-control', $hdrs))
+ if(array_key_exists('cache-control', $hdrs)) {
$cc = $hdrs['cache-control'];
- if(strpos($cc, 'no-cache'))
+ }
+
+ if(strpos($cc, 'no-cache')) {
$expires = time() + 60;
+ }
else {
$ttl = (preg_match('/max-age=(\d+)/i', $cc, $o) ? intval($o[1]) : 86400);
$expires = time() + $ttl;
@@ -289,7 +304,7 @@ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) {
$micro = z_root() . '/photo/' . $hash . '-6';
if(isset($result))
q("UPDATE photo SET expires = '%s' WHERE xchan = '%s' and photo_usage = %d and imgscale IN (4, 5, 6)",
- dbescdate(gmdate('Y-m-d H:i:s', (isset($expires) ? $expires : time() + 86400))),
+ dbescdate(gmdate('Y-m-d H:i:s', $expires)),
dbesc($xchan),
intval(PHOTO_XCHAN)
);