From c7c35b8b5a64e44f01e7557a43d13e518dc62aa8 Mon Sep 17 00:00:00 2001 From: "M.Dent" Date: Sun, 28 Oct 2018 17:20:29 -0400 Subject: DB Updates to prep for pconfig timestamps. --- Zotlabs/Update/_1225.php | 26 ++++++++++++++++++++++++++ boot.php | 2 +- vendor/composer/autoload_static.php | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Update/_1225.php diff --git a/Zotlabs/Update/_1225.php b/Zotlabs/Update/_1225.php new file mode 100644 index 000000000..a7d866154 --- /dev/null +++ b/Zotlabs/Update/_1225.php @@ -0,0 +1,26 @@ + __DIR__ . '/../..' . '/Zotlabs/Update/_1222.php', 'Zotlabs\\Update\\_1223' => __DIR__ . '/../..' . '/Zotlabs/Update/_1223.php', 'Zotlabs\\Update\\_1224' => __DIR__ . '/../..' . '/Zotlabs/Update/_1224.php', + 'Zotlabs\\Update\\_1225' => __DIR__ . '/../..' . '/Zotlabs/Update/_1225.php', 'Zotlabs\\Web\\CheckJS' => __DIR__ . '/../..' . '/Zotlabs/Web/CheckJS.php', 'Zotlabs\\Web\\Controller' => __DIR__ . '/../..' . '/Zotlabs/Web/Controller.php', 'Zotlabs\\Web\\HTTPHeaders' => __DIR__ . '/../..' . '/Zotlabs/Web/HTTPHeaders.php', -- cgit v1.2.3 From 3ab0ef1902a9ff1f33cf5540a866745dc98a11a9 Mon Sep 17 00:00:00 2001 From: "M.Dent" Date: Sun, 28 Oct 2018 17:23:31 -0400 Subject: Add timestamp and associated logic to pconfig --- Zotlabs/Lib/PConfig.php | 65 ++++++++++++++++++++++++++++++++++++++++--------- include/config.php | 4 +-- include/zot.php | 37 ++++++++++++++++++++++++++-- 3 files changed, 90 insertions(+), 16 deletions(-) diff --git a/Zotlabs/Lib/PConfig.php b/Zotlabs/Lib/PConfig.php index ec0792ce1..31c0ee87b 100644 --- a/Zotlabs/Lib/PConfig.php +++ b/Zotlabs/Lib/PConfig.php @@ -57,6 +57,7 @@ class PConfig { \App::$config[$uid][$c]['config_loaded'] = true; } \App::$config[$uid][$c][$k] = $rr['v']; + \App::$config[$uid][$c]['pcfgud:'.$k] = $rr['updated']; } } } @@ -113,7 +114,7 @@ class PConfig { * The value to store * @return mixed Stored $value or false */ - static public function Set($uid, $family, $key, $value) { + static public function Set($uid, $family, $key, $value, $updated=NULL) { // this catches subtle errors where this function has been called // with local_channel() when not logged in (which returns false) @@ -130,27 +131,43 @@ class PConfig { $dbvalue = ((is_array($value)) ? serialize($value) : $value); $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); + if (! $updated) { + $updated = datetime_convert(); + } + + if(self::Get($uid, $family, $key) === false) { if(! array_key_exists($uid, \App::$config)) \App::$config[$uid] = array(); if(! array_key_exists($family, \App::$config[$uid])) \App::$config[$uid][$family] = array(); - $ret = q("INSERT INTO pconfig ( uid, cat, k, v ) VALUES ( %d, '%s', '%s', '%s' ) ", + $ret = q("INSERT INTO pconfig ( uid, cat, k, v, updated ) VALUES ( %d, '%s', '%s', '%s', '%s' ) ", intval($uid), dbesc($family), dbesc($key), - dbesc($dbvalue) + dbesc($dbvalue), + dbesc($updated) ); + + \App::$config[$uid][$family]['pcfgud:'.$key] = $updated; + } else { - - $ret = q("UPDATE pconfig SET v = '%s' WHERE uid = %d and cat = '%s' AND k = '%s'", - dbesc($dbvalue), - intval($uid), - dbesc($family), - dbesc($key) - ); + $new = (\App::$config[$uid][$family]['pcfgud:'.$key] < $updated); + + if ($new) { + $ret = q("UPDATE pconfig SET v = '%s' WHERE uid = %d and cat = '%s' AND k = '%s' AND updated = '%s'", + dbesc($dbvalue), + intval($uid), + dbesc($family), + dbesc($key), + dbesc($updated) + ); + } else { + logger('Refusing to update pconfig with outdated info.', LOGGER_NORMAL, LOG_ERR); + return self::Get($uid, $family, $key); + } } // keep a separate copy for all variables which were @@ -163,7 +180,11 @@ class PConfig { \App::$config[$uid]['transient'][$family] = array(); \App::$config[$uid][$family][$key] = $value; - \App::$config[$uid]['transient'][$family][$key] = $value; + + if ($new) { + \App::$config[$uid]['transient'][$family][$key] = $value; + \App::$config[$uid]['transient'][$family]['pcfgud:'.$key] = $updated; + } if($ret) return $value; @@ -186,11 +207,20 @@ class PConfig { * The configuration key to delete * @return mixed */ - static public function Delete($uid, $family, $key) { + static public function Delete($uid, $family, $key, $updated = NULL) { if(is_null($uid) || $uid === false) return false; + $updated = ($updated) ? $updated : datetime_convert(); + + $newer = (\App::$config[$uid][$family]['pcfgud:'.$key] < $updated); + + if (! $newer) { + logger('Refusing to delete pconfig with outdated delete request.', LOGGER_NORMAL, LOG_ERR); + return false; + } + $ret = false; if(array_key_exists($uid,\App::$config) @@ -205,6 +235,17 @@ class PConfig { dbesc($key) ); + // Synchronize delete with clones. + + if(! array_key_exists('transient', \App::$config[$uid])) + \App::$config[$uid]['transient'] = array(); + if(! array_key_exists($family, \App::$config[$uid]['transient'])) + \App::$config[$uid]['transient'][$family] = array(); + + if ($new) { + \App::$config[$uid]['transient'][$family]['pcfgdel:'.$key] = $updated; + } + return $ret; } diff --git a/include/config.php b/include/config.php index 0be791715..ec3547a82 100644 --- a/include/config.php +++ b/include/config.php @@ -59,8 +59,8 @@ function set_pconfig($uid, $family, $key, $value) { return Zlib\PConfig::Set($uid,$family,$key,$value); } -function del_pconfig($uid, $family, $key) { - return Zlib\PConfig::Delete($uid,$family,$key); +function del_pconfig($uid, $family, $key, $updated = NULL) { + return Zlib\PConfig::Delete($uid,$family,$key,$updated); } function load_xconfig($xchan) { diff --git a/include/zot.php b/include/zot.php index 1a632cf87..a5202d01b 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3507,8 +3507,41 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('config',$arr) && is_array($arr['config']) && count($arr['config'])) { foreach($arr['config'] as $cat => $k) { - foreach($arr['config'][$cat] as $k => $v) - set_pconfig($channel['channel_id'],$cat,$k,$v); + + $pconfig_updated = []; + $pconfig_del = []; + + foreach($arr['config'][$cat] as $k => $v) { + + if (strpos($k,'pcfgud:')==0) { + + $realk = substr($k,7); + $pconfig_updated[$realk] = $v; + unset($arr['config'][$cat][$k]); + + } + + if (strpos($k,'pcfgdel:')==0) { + $realk = substr($k,8); + $pconfig_del[$realk] = $v; + unset($arr['config'][$cat][$k]); + } + } + + foreach($arr['config'][$cat] as $k => $v) { + + if (!isset($pconfig_updated[$k])) { + $pconfig_updated[$k] = NULL; + } + + set_pconfig($channel['channel_id'],$cat,$k,$v,$pconfig_updated[$k]); + + } + + foreach($pconfig_del as $k => $updated) { + del_pconfig($channel['channel_id'],$cat,$k,$updated); + } + } } -- cgit v1.2.3 From 1241e778f9073b5ba50d966eea20b28b9400339b Mon Sep 17 00:00:00 2001 From: "M.Dent" Date: Sun, 28 Oct 2018 17:30:22 -0400 Subject: Fix to set update time in pconfig on update --- Zotlabs/Lib/PConfig.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Zotlabs/Lib/PConfig.php b/Zotlabs/Lib/PConfig.php index 31c0ee87b..8bc5681f0 100644 --- a/Zotlabs/Lib/PConfig.php +++ b/Zotlabs/Lib/PConfig.php @@ -157,12 +157,12 @@ class PConfig { $new = (\App::$config[$uid][$family]['pcfgud:'.$key] < $updated); if ($new) { - $ret = q("UPDATE pconfig SET v = '%s' WHERE uid = %d and cat = '%s' AND k = '%s' AND updated = '%s'", + $ret = q("UPDATE pconfig SET v = '%s', updated = '%s' WHERE uid = %d and cat = '%s' AND k = '%s' ", dbesc($dbvalue), + dbesc($updated), intval($uid), dbesc($family), - dbesc($key), - dbesc($updated) + dbesc($key) ); } else { logger('Refusing to update pconfig with outdated info.', LOGGER_NORMAL, LOG_ERR); -- cgit v1.2.3 From 0060f88c4599c5cda1c6d5a7f6eb345a496e382f Mon Sep 17 00:00:00 2001 From: "M.Dent" Date: Mon, 29 Oct 2018 23:04:13 -0400 Subject: Add tracking of deleted pconfig variables --- Zotlabs/Lib/PConfig.php | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Lib/PConfig.php b/Zotlabs/Lib/PConfig.php index 8bc5681f0..b9384cf6b 100644 --- a/Zotlabs/Lib/PConfig.php +++ b/Zotlabs/Lib/PConfig.php @@ -135,6 +135,16 @@ class PConfig { $updated = datetime_convert(); } + $hash = hash('sha256',$family.':'.$key); + + if (self::Get($uid, 'hz_delpconfig', $hash) !== false) { + if (Get($uid, 'hz_delpconfig', $hash) > $updated) { + logger('Refusing to update pconfig with outdated info (Item deleted more recently).', LOGGER_NORMAL, LOG_ERR); + return self::Get($uid,$family,$key); + } else { + self::Delete($uid,'hz_delpconfig',$hash); + } + } if(self::Get($uid, $family, $key) === false) { if(! array_key_exists($uid, \App::$config)) @@ -142,6 +152,7 @@ class PConfig { if(! array_key_exists($family, \App::$config[$uid])) \App::$config[$uid][$family] = array(); + $ret = q("INSERT INTO pconfig ( uid, cat, k, v, updated ) VALUES ( %d, '%s', '%s', '%s', '%s' ) ", intval($uid), dbesc($family), @@ -150,6 +161,14 @@ class PConfig { dbesc($updated) ); + // There is a possible race condition if another process happens + // to insert something after this thread has Loaded and now. We should + // at least make a note of it if it happens. + + if (!$ret) { + logger("Error: Insert to pconfig failed.",LOGGER_NORMAL, LOG_ERR); + } + \App::$config[$uid][$family]['pcfgud:'.$key] = $updated; } @@ -157,6 +176,12 @@ class PConfig { $new = (\App::$config[$uid][$family]['pcfgud:'.$key] < $updated); if ($new) { + + // @NOTE There is still a possible race condition under limited circumstances + // where a value will be updated by another thread with more current data than + // we have. At this point there is no easy way to test for it, so we update + // and hope for the best. + $ret = q("UPDATE pconfig SET v = '%s', updated = '%s' WHERE uid = %d and cat = '%s' AND k = '%s' ", dbesc($dbvalue), dbesc($updated), @@ -164,12 +189,16 @@ class PConfig { dbesc($family), dbesc($key) ); + + \App::$config[$uid][$family]['pcfgud:'.$key] = $updated; + } else { logger('Refusing to update pconfig with outdated info.', LOGGER_NORMAL, LOG_ERR); return self::Get($uid, $family, $key); } } + // keep a separate copy for all variables which were // set in the life of this page. We need this to // synchronise channel clones. @@ -223,11 +252,13 @@ class PConfig { $ret = false; - if(array_key_exists($uid,\App::$config) - && is_array(\App::$config['uid']) - && array_key_exists($family,\App::$config['uid']) - && array_key_exists($key, \App::$config[$uid][$family])) + if (isset(\App::$config[$uid][$family][$key])) { unset(\App::$config[$uid][$family][$key]); + } + + if (isset(\App::$config[$uid][$family]['pcfgud:'.$key])) { + unset(\App::$config[$uid][$family]['pcfgud:'.$key]); + } $ret = q("DELETE FROM pconfig WHERE uid = %d AND cat = '%s' AND k = '%s'", intval($uid), @@ -235,6 +266,11 @@ class PConfig { dbesc($key) ); + if ($family != 'hz_delpconfig') { + $hash = hash('sha256',$family.':'.$key); + set_pconfig($uid,'hz_delpconfig',$hash,$updated); + } + // Synchronize delete with clones. if(! array_key_exists('transient', \App::$config[$uid])) -- cgit v1.2.3 From 346a4f593332009014fc8b3595bd56c6ca9ff9b5 Mon Sep 17 00:00:00 2001 From: "M.Dent" Date: Thu, 1 Nov 2018 20:23:22 -0400 Subject: strpos needs to test with ===0 not ==0 --- include/zot.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/zot.php b/include/zot.php index a5202d01b..49fc89e33 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3513,7 +3513,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { foreach($arr['config'][$cat] as $k => $v) { - if (strpos($k,'pcfgud:')==0) { + if (strpos($k,'pcfgud:')===0) { $realk = substr($k,7); $pconfig_updated[$realk] = $v; @@ -3521,9 +3521,9 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { } - if (strpos($k,'pcfgdel:')==0) { + if (strpos($k,'pcfgdel:')===0) { $realk = substr($k,8); - $pconfig_del[$realk] = $v; + $pconfig_del[$realk] = datetime_convert(); unset($arr['config'][$cat][$k]); } } -- cgit v1.2.3 From de32b0bba55d8570214546df5d3f50397308001f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 3 Nov 2018 20:53:23 +0100 Subject: more fixes for forum notifications handling: do not count likes/dislikes if likes notifications are disabled and also do not show like activities when clicking a forum notification and like notifications are disabled --- Zotlabs/Module/Network.php | 6 +++++- Zotlabs/Module/Ping.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 294e11c52..b93faa612 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -258,6 +258,10 @@ class Network extends \Zotlabs\Web\Controller { } elseif($pf && $unseen && $nouveau) { + $vnotify = get_pconfig(local_channel(), 'system', 'vnotify'); + if(! ($vnotify & VNOTIFY_LIKE)) + $likes_sql = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + // This is for nouveau view public forum cid queries (if a forum notification is clicked) $p = q("SELECT oid AS parent FROM term WHERE uid = %d AND ttype = %d AND term = '%s'", intval(local_channel()), @@ -269,7 +273,7 @@ class Network extends \Zotlabs\Web\Controller { if($p_str) $p_sql = " OR item.parent IN ( $p_str ) "; - $sql_extra = " AND ( owner_xchan = '" . protect_sprintf(dbesc($cid_r[0]['abook_xchan'])) . "' OR owner_xchan = '" . protect_sprintf(dbesc($cid_r[0]['abook_xchan'])) . "' $p_sql ) AND item_unseen = 1 "; + $sql_extra = " AND ( owner_xchan = '" . protect_sprintf(dbesc($cid_r[0]['abook_xchan'])) . "' OR owner_xchan = '" . protect_sprintf(dbesc($cid_r[0]['abook_xchan'])) . "' $p_sql ) AND item_unseen = 1 $likes_sql "; } else { // This is for threaded view cid queries (e.g. if a forum is selected from the forum filter) diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index cf5b2e004..f660c3b55 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -650,7 +650,7 @@ class Ping extends \Zotlabs\Web\Controller { $p_sql = (($p_str) ? "OR parent IN ( $p_str )" : ''); $r = q("select count(id) as unseen from item - where uid = %d and ( owner_xchan = '%s' OR author_xchan = '%s' $p_sql ) and item_unseen = 1 $item_normal", + where uid = %d and ( owner_xchan = '%s' OR author_xchan = '%s' $p_sql ) and item_unseen = 1 $item_normal $sql_extra", intval(local_channel()), dbesc($forums[$x]['xchan_hash']), dbesc($forums[$x]['xchan_hash']) -- cgit v1.2.3 From 4320f047dbdabc11d606374c8120affc7f662de4 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 5 Nov 2018 10:22:56 +0100 Subject: update changelog and bump version --- CHANGELOG | 14 ++++++++++++++ boot.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 272f839fb..c3e280963 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,17 @@ +Hubzilla 3.8.3 (2018-11-05) + - Do not count likes in forum notifications if likes notifications are disabled + - Fix typo in spanish translation which broke javascript + - Improve linkinfo charset handling and image detection + - Fix wrong image resize for some external images + - Move blueimp upload lib to composer and update to version 9.25 + - Remove primary/clone counts from admin summary until we have a mechanism to update the fixed counts + - Fix html2markdown() and re-enable previously failing tests + - Improve look of oembed content for Hubzilla links + - Fix forum notifications count not correct + - Fix gallery addon which broke mod apps in some situations + - Fix wiki_list widget not working on every page respectively level + + Hubzilla 3.8.2 (2018-10-29) - Merge unmerged changes from dev into master - Fix issues with forum handling in mod network and ping diff --git a/boot.php b/boot.php index 9b6047fc0..e4d90a820 100755 --- a/boot.php +++ b/boot.php @@ -50,7 +50,7 @@ require_once('include/attach.php'); require_once('include/bbcode.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); -define ( 'STD_VERSION', '3.9.3' ); +define ( 'STD_VERSION', '3.9.4' ); define ( 'ZOT_REVISION', '6.0a' ); -- cgit v1.2.3 From 2dd124d09e05dad1f640f25dc8c3cd8abdfd1aad Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 5 Nov 2018 21:25:08 +0100 Subject: Use modern get_config() syntax --- Zotlabs/Module/Photo.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 8efc00707..41a145ae1 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -240,10 +240,8 @@ class Photo extends \Zotlabs\Web\Controller { // This has performance considerations but we highly recommend you // leave it alone. - $cache = get_config('system','photo_cache_time'); - if(! $cache) - $cache = (3600 * 24); // 1 day - + $cache = get_config('system','photo_cache_time', 3600); + header("Expires: " . gmdate("D, d M Y H:i:s", time() + $cache) . " GMT"); header("Cache-Control: max-age=" . $cache); -- cgit v1.2.3 From f7ce374a28c2d5ad1ff8d8c81a544855d2bf5127 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 5 Nov 2018 21:26:10 +0100 Subject: Update Photo.php --- Zotlabs/Module/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 41a145ae1..f01909ff5 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -240,7 +240,7 @@ class Photo extends \Zotlabs\Web\Controller { // This has performance considerations but we highly recommend you // leave it alone. - $cache = get_config('system','photo_cache_time', 3600); + $cache = get_config('system','photo_cache_time', 86400); // 1 day by default header("Expires: " . gmdate("D, d M Y H:i:s", time() + $cache) . " GMT"); header("Cache-Control: max-age=" . $cache); -- cgit v1.2.3 From e116b90116b3d61548ce2bcf8949deee5feb6b98 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 13:37:50 +0100 Subject: 'Last-Modified' and 'Content-Length' HTTP headers added for better image caching --- Zotlabs/Module/Photo.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index f01909ff5..14def3a62 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -33,8 +33,6 @@ class Photo extends \Zotlabs\Web\Controller { $observer_xchan = get_observer_hash(); - $default = z_root() . '/' . get_default_profile_photo(); - if(isset($type)) { /** @@ -44,22 +42,24 @@ class Photo extends \Zotlabs\Web\Controller { if($type === 'profile') { switch($res) { - case 'm': $resolution = 5; - $default = z_root() . '/' . get_default_profile_photo(80); + $default = get_default_profile_photo(80); break; case 's': $resolution = 6; - $default = z_root() . '/' . get_default_profile_photo(48); + $default = get_default_profile_photo(48); break; case 'l': default: $resolution = 4; + $default = get_default_profile_photo(); break; } } + $modified = filemtime($default); + $default = z_root() . '/' . $default; $uid = $person; $d = [ 'imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => '' ]; @@ -78,11 +78,13 @@ class Photo extends \Zotlabs\Web\Controller { intval(PHOTO_PROFILE) ); if($r) { + $modified = strtotime($r[0]['edited']); $data = dbunescbin($r[0]['content']); $mimetype = $r[0]['mimetype']; } - if(intval($r[0]['os_storage'])) + if(intval($r[0]['os_storage'])) { $data = file_get_contents($data); + } } if(! $data) { $data = fetch_image_from_url($default,$mimetype); @@ -164,6 +166,7 @@ class Photo extends \Zotlabs\Web\Controller { if($exists && $allowed) { $data = dbunescbin($e[0]['content']); $mimetype = $e[0]['mimetype']; + $modified = strtotime($e[0]['edited']); if(intval($e[0]['os_storage'])) { $streaming = $data; } @@ -183,7 +186,6 @@ class Photo extends \Zotlabs\Web\Controller { if(! isset($data)) { if(isset($resolution)) { switch($resolution) { - case 4: $data = fetch_image_from_url(z_root() . '/' . get_default_profile_photo(),$mimetype); break; @@ -210,10 +212,14 @@ class Photo extends \Zotlabs\Web\Controller { } } + // @FIXME Seems never invoked // Writing in cachefile - if (isset($cachefile) && $cachefile != '') + if (isset($cachefile) && $cachefile != '') { file_put_contents($cachefile, $data); - + $modified = filemtime($cachefile); + } + + if(function_exists('header_remove')) { header_remove('Pragma'); header_remove('pragma'); @@ -247,6 +253,7 @@ class Photo extends \Zotlabs\Web\Controller { } + // If it's a file resource, stream it. if($streaming && $channel) { @@ -262,6 +269,8 @@ class Photo extends \Zotlabs\Web\Controller { } } else { + header("Last-Modified: " . gmdate("D, d M Y H:i:s", $modified) . " GMT"); + header("Content-Length: " . strlen($data)); echo $data; } -- cgit v1.2.3 From c26f45b7c20c870fcc77258a0c282440ec3e0b5a Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 13:39:36 +0100 Subject: Update Photo.php --- Zotlabs/Module/Photo.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 14def3a62..8f85bdd69 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -39,7 +39,9 @@ class Photo extends \Zotlabs\Web\Controller { * Profile photos - Access controls on default profile photos are not honoured since they need to be exchanged with remote sites. * */ - + + $default = get_default_profile_photo(); + if($type === 'profile') { switch($res) { case 'm': @@ -53,7 +55,6 @@ class Photo extends \Zotlabs\Web\Controller { case 'l': default: $resolution = 4; - $default = get_default_profile_photo(); break; } } -- cgit v1.2.3 From 1828b6daab88041dbc85f11cc4e04efede6c993b Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 13:41:41 +0100 Subject: Update Photo.php --- Zotlabs/Module/Photo.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 8f85bdd69..07443bb83 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -83,9 +83,8 @@ class Photo extends \Zotlabs\Web\Controller { $data = dbunescbin($r[0]['content']); $mimetype = $r[0]['mimetype']; } - if(intval($r[0]['os_storage'])) { + if(intval($r[0]['os_storage'])) $data = file_get_contents($data); - } } if(! $data) { $data = fetch_image_from_url($default,$mimetype); @@ -168,9 +167,8 @@ class Photo extends \Zotlabs\Web\Controller { $data = dbunescbin($e[0]['content']); $mimetype = $e[0]['mimetype']; $modified = strtotime($e[0]['edited']); - if(intval($e[0]['os_storage'])) { + if(intval($e[0]['os_storage'])) $streaming = $data; - } } else { if(! $allowed) { -- cgit v1.2.3 From 3491c488d340b7d5b4e0610398427cb52c05bf8e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 13:51:01 +0100 Subject: Update Photo.php --- Zotlabs/Module/Photo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 07443bb83..d76fca278 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -252,6 +252,8 @@ class Photo extends \Zotlabs\Web\Controller { } + header("Last-Modified: " . gmdate("D, d M Y H:i:s", $modified) . " GMT"); + header("Content-Length: " . strlen($data)); // If it's a file resource, stream it. @@ -268,8 +270,6 @@ class Photo extends \Zotlabs\Web\Controller { } } else { - header("Last-Modified: " . gmdate("D, d M Y H:i:s", $modified) . " GMT"); - header("Content-Length: " . strlen($data)); echo $data; } -- cgit v1.2.3 From af1ea7f4953505b5827255c0ff6fd826445b9ced Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:48:58 +0100 Subject: New plural function for JavaScript compatibility --- view/de-de/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/de-de/hmessages.po b/view/de-de/hmessages.po index 8af9dce6b..c5f670dd4 100644 --- a/view/de-de/hmessages.po +++ b/view/de-de/hmessages.po @@ -35,7 +35,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Plural-Forms: nplurals=2; plural=(n != 1 ? 0 : 1);\n" #: ../../Zotlabs/Access/Permissions.php:56 msgid "Can view my channel stream and posts" -- cgit v1.2.3 From cc06250bf8466d6c68f212fbdb91db7bd22f4530 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:50:37 +0100 Subject: New fr plural function for JavaScript compatibility --- view/fr/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/fr/hmessages.po b/view/fr/hmessages.po index c5263c2df..85e739666 100644 --- a/view/fr/hmessages.po +++ b/view/fr/hmessages.po @@ -22,7 +22,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Plural-Forms: nplurals=2; plural=(n > 1 ? 0 : 1);\n" #: ../../Zotlabs/Access/Permissions.php:56 msgid "Can view my channel stream and posts" -- cgit v1.2.3 From f1f5107282383785bf9d8a9c5b5c108f00644afa Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:52:23 +0100 Subject: New es plural function for JavaScript compatibility --- view/es-es/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/es-es/hmessages.po b/view/es-es/hmessages.po index f2c1ccf79..3b42394b1 100644 --- a/view/es-es/hmessages.po +++ b/view/es-es/hmessages.po @@ -22,7 +22,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: es_ES\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Plural-Forms: nplurals=2; plural=(n != 1 ? 1 : 0);\n" #: ../../Zotlabs/Access/Permissions.php:56 msgid "Can view my channel stream and posts" -- cgit v1.2.3 From dbe10c7965e08f99c295151839da3004c21d0b93 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:52:58 +0100 Subject: New fi plural function for JavaScript compatibility --- view/sv/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/sv/hmessages.po b/view/sv/hmessages.po index 4486a8630..249dbd8be 100644 --- a/view/sv/hmessages.po +++ b/view/sv/hmessages.po @@ -17,7 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: sv\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Plural-Forms: nplurals=2; plural=(n != 1 ? 1 : 0);\n" #: ../../include/dba/dba_driver.php:142 #, php-format -- cgit v1.2.3 From 7c49688e1bab53eb20d51095d26ae8d9e5a34a7d Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:53:29 +0100 Subject: New he plural function for JavaScript compatibility --- view/he/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/he/hmessages.po b/view/he/hmessages.po index 991b7f64f..837dfabd0 100644 --- a/view/he/hmessages.po +++ b/view/he/hmessages.po @@ -17,7 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: he\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Plural-Forms: nplurals=2; plural=(n != 1 ? 1 : 0);\n" #: ../../Zotlabs/Storage/Browser.php:107 ../../Zotlabs/Storage/Browser.php:239 msgid "parent" -- cgit v1.2.3 From aa78640491f214f0247484498fa69e1dd9351190 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:54:06 +0100 Subject: New it plural function for JavaScript compatibility --- view/it/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/it/hmessages.po b/view/it/hmessages.po index 94911bc20..8c1dc08d7 100644 --- a/view/it/hmessages.po +++ b/view/it/hmessages.po @@ -18,7 +18,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: it\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Plural-Forms: nplurals=2; plural=(n != 1 ? 1 : 0);\n" #: ../../Zotlabs/Access/Permissions.php:56 msgid "Can view my channel stream and posts" -- cgit v1.2.3 From c2da8c3fd4362ee1104201bd1bc1ce6589d75229 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:54:49 +0100 Subject: New nb-no plural function for JavaScript compatibility --- view/nb-no/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/nb-no/hmessages.po b/view/nb-no/hmessages.po index bcb926d90..0f7f2e8c5 100644 --- a/view/nb-no/hmessages.po +++ b/view/nb-no/hmessages.po @@ -16,7 +16,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: nb_NO\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Plural-Forms: nplurals=2; plural=(n != 1 ? 1 : 0);\n" #: ../../Zotlabs/Storage/Browser.php:107 ../../Zotlabs/Storage/Browser.php:239 msgid "parent" -- cgit v1.2.3 From 812c5a314f0b44c8485c8e3f42bf7ab55e8caf25 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:55:21 +0100 Subject: New nl plural function for JavaScript compatibility --- view/nl/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/nl/hmessages.po b/view/nl/hmessages.po index c98121122..c672e534e 100644 --- a/view/nl/hmessages.po +++ b/view/nl/hmessages.po @@ -18,7 +18,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: nl\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Plural-Forms: nplurals=2; plural=(n != 1 ? 1 : 0);\n" #: ../../Zotlabs/Access/Permissions.php:56 msgid "Can view my channel stream and posts" -- cgit v1.2.3 From 3302012c02e7404a7895445e7b5ce123f0a382cd Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:55:58 +0100 Subject: New pt-br plural function for JavaScript compatibility --- view/pt-br/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/pt-br/hmessages.po b/view/pt-br/hmessages.po index 029642f9b..2645cc9bd 100644 --- a/view/pt-br/hmessages.po +++ b/view/pt-br/hmessages.po @@ -25,7 +25,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Plural-Forms: nplurals=2; plural=(n > 1 ? 1 : 0);\n" #: ../../include/dba/dba_driver.php:50 #, php-format -- cgit v1.2.3 From 4760a3f3e875c1f5864cf682240088f7a2d3c79c Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:57:12 +0100 Subject: Update hmessages.po --- view/de-de/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/de-de/hmessages.po b/view/de-de/hmessages.po index c5f670dd4..4eaec3629 100644 --- a/view/de-de/hmessages.po +++ b/view/de-de/hmessages.po @@ -35,7 +35,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de\n" -"Plural-Forms: nplurals=2; plural=(n != 1 ? 0 : 1);\n" +"Plural-Forms: nplurals=2; plural=(n != 1 ? 1 : 0);\n" #: ../../Zotlabs/Access/Permissions.php:56 msgid "Can view my channel stream and posts" -- cgit v1.2.3 From 009044b71e6ebb8406a27b2b17fa6d6cc4c2e9db Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 14:58:06 +0100 Subject: Update hmessages.po --- view/fr/hmessages.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/fr/hmessages.po b/view/fr/hmessages.po index 85e739666..0c89da139 100644 --- a/view/fr/hmessages.po +++ b/view/fr/hmessages.po @@ -22,7 +22,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" -"Plural-Forms: nplurals=2; plural=(n > 1 ? 0 : 1);\n" +"Plural-Forms: nplurals=2; plural=(n > 1 ? 1 : 0);\n" #: ../../Zotlabs/Access/Permissions.php:56 msgid "Can view my channel stream and posts" -- cgit v1.2.3 From 40d9277ef38ef1200db59cd2f8c6b9e2a80bc332 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 6 Nov 2018 16:22:34 +0100 Subject: remove 'Expiries' HTTP header --- Zotlabs/Module/Photo.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index d76fca278..0f47ee103 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -246,8 +246,7 @@ class Photo extends \Zotlabs\Web\Controller { // leave it alone. $cache = get_config('system','photo_cache_time', 86400); // 1 day by default - - header("Expires: " . gmdate("D, d M Y H:i:s", time() + $cache) . " GMT"); + header("Cache-Control: max-age=" . $cache); } -- cgit v1.2.3 From a5a77d1e7c3ae190e01848c0cc4567fcdb3edfb1 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 7 Nov 2018 08:41:32 +0100 Subject: Revert "remove 'Expiries' HTTP header" This reverts commit 40d9277ef38ef1200db59cd2f8c6b9e2a80bc332 --- Zotlabs/Module/Photo.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 0f47ee103..d76fca278 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -246,7 +246,8 @@ class Photo extends \Zotlabs\Web\Controller { // leave it alone. $cache = get_config('system','photo_cache_time', 86400); // 1 day by default - + + header("Expires: " . gmdate("D, d M Y H:i:s", time() + $cache) . " GMT"); header("Cache-Control: max-age=" . $cache); } -- cgit v1.2.3