diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-06-24 11:25:20 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-06-24 11:25:20 +0200 |
commit | c8ae04a96a38b7351c2ac506c836bb9b1734d58e (patch) | |
tree | b15646cc7746f8b18dc844a9d7c8836c29bc7896 /include | |
parent | 39b14b6b811ec65f8c8a812397f9ee04877cd53d (diff) | |
parent | c809b6f95e0c9717cba9cfad62b74104fbcc878d (diff) | |
download | volse-hubzilla-c8ae04a96a38b7351c2ac506c836bb9b1734d58e.tar.gz volse-hubzilla-c8ae04a96a38b7351c2ac506c836bb9b1734d58e.tar.bz2 volse-hubzilla-c8ae04a96a38b7351c2ac506c836bb9b1734d58e.zip |
Merge branch 'dev' into sabre32
Diffstat (limited to 'include')
-rw-r--r-- | include/cache.php | 44 | ||||
-rw-r--r-- | include/channel.php | 2 | ||||
-rw-r--r-- | include/config.php | 16 | ||||
-rwxr-xr-x | include/oembed.php | 6 | ||||
-rw-r--r-- | include/photos.php | 65 | ||||
-rw-r--r-- | include/text.php | 28 | ||||
-rw-r--r-- | include/zot.php | 5 |
7 files changed, 62 insertions, 104 deletions
diff --git a/include/cache.php b/include/cache.php deleted file mode 100644 index 4a3f453e1..000000000 --- a/include/cache.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php /** @file */ - - /** - * cache api - */ - - class Cache { - public static function get($key){ - $r = q("SELECT v FROM cache WHERE k = '%s' limit 1", - dbesc($key) - ); - - if ($r) - return $r[0]['v']; - return null; - } - - public static function set($key,$value) { - - $r = q("SELECT * FROM cache WHERE k = '%s' limit 1", - dbesc($key) - ); - if($r) { - q("UPDATE cache SET v = '%s', updated = '%s' WHERE k = '%s'", - dbesc($value), - dbesc(datetime_convert()), - dbesc($key)); - } - else { - q("INSERT INTO cache ( k, v, updated) VALUES ('%s','%s','%s')", - dbesc($key), - dbesc($value), - dbesc(datetime_convert())); - } - } - - - public static function clear(){ - q("DELETE FROM cache WHERE updated < '%s'", - dbesc(datetime_convert('UTC','UTC',"now - 30 days"))); - } - - } - diff --git a/include/channel.php b/include/channel.php index a0424ee39..a7624f060 100644 --- a/include/channel.php +++ b/include/channel.php @@ -516,7 +516,7 @@ function identity_basic_export($channel_id, $items = false) { for($x = 0; $x < count($ret['abook']); $x ++) { $xchans[] = $ret['abook'][$x]['abook_chan']; - $abconfig = load_abconfig($ret['channel']['channel_hash'],$ret['abook'][$x]['abook_xchan']); + $abconfig = load_abconfig($channel_id,$ret['abook'][$x]['abook_xchan']); if($abconfig) $ret['abook'][$x]['abconfig'] = $abconfig; } diff --git a/include/config.php b/include/config.php index 65199283d..ece22793f 100644 --- a/include/config.php +++ b/include/config.php @@ -98,20 +98,20 @@ function del_aconfig($account_id, $family, $key) { } -function load_abconfig($chash,$xhash) { - Zlib\AbConfig::Load($chash,$xhash); +function load_abconfig($chan,$xhash) { + Zlib\AbConfig::Load($chan,$xhash); } -function get_abconfig($chash,$xhash,$family,$key) { - return Zlib\AbConfig::Get($chash,$xhash,$family,$key); +function get_abconfig($chan,$xhash,$family,$key) { + return Zlib\AbConfig::Get($chan,$xhash,$family,$key); } -function set_abconfig($chash,$xhash,$family,$key,$value) { - return Zlib\AbConfig::Set($chash,$xhash,$family,$key,$value); +function set_abconfig($chan,$xhash,$family,$key,$value) { + return Zlib\AbConfig::Set($chan,$xhash,$family,$key,$value); } -function del_abconfig($chash,$xhash,$family,$key) { - return Zlib\AbConfig::Delete($chash,$xhash,$family,$key); +function del_abconfig($chan,$xhash,$family,$key) { + return Zlib\AbConfig::Delete($chan,$xhash,$family,$key); } function load_iconfig(&$item) { diff --git a/include/oembed.php b/include/oembed.php index 08363e488..f1d9bd7d2 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -1,6 +1,8 @@ <?php /** @file */ +use Zotlabs\Lib as Zlib; + function oembed_replacecb($matches){ $embedurl=$matches[1]; @@ -130,7 +132,7 @@ function oembed_fetch_url($embedurl){ $txt = null; if($action !== 'block') { - $txt = Cache::get(App::$videowidth . $embedurl); + $txt = Zlib\Cache::get('[' . App::$videowidth . '] ' . $embedurl); if(strstr($txt,'youtu') && strstr(z_root(),'https:')) { $txt = str_replace('http:','https:',$txt); @@ -199,7 +201,7 @@ function oembed_fetch_url($embedurl){ //save in cache if(! get_config('system','oembed_cache_disable')) - Cache::set(App::$videowidth . $embedurl,$txt); + Zlib\Cache::set('[' . App::$videowidth . '] ' . $embedurl,$txt); } diff --git a/include/photos.php b/include/photos.php index da6118b38..c70478146 100644 --- a/include/photos.php +++ b/include/photos.php @@ -707,40 +707,65 @@ function gps2Num($coordPart) { return floatval($parts[0]) / floatval($parts[1]); } -function profile_photo_set_profile_perms($profileid = '') { +function profile_photo_set_profile_perms($uid, $profileid = 0) { $allowcid = ''; - if (x($profileid)) { - - $r = q("SELECT photo, profile_guid, id, is_default, uid FROM profile WHERE profile.id = %d OR profile.profile_guid = '%s' LIMIT 1", intval($profileid), dbesc($profileid)); - - } else { - + if($profileid) { + $r = q("SELECT photo, profile_guid, id, is_default, uid + FROM profile WHERE uid = %d and ( profile.id = %d OR profile.profile_guid = '%s') LIMIT 1", + intval($profileid), + dbesc($profileid) + ); + } + else { logger('Resetting permissions on default-profile-photo for user'.local_channel()); - $r = q("SELECT photo, profile_guid, id, is_default, uid FROM profile WHERE profile.uid = %d AND is_default = 1 LIMIT 1", intval(local_channel()) ); //If no profile is given, we update the default profile + + $r = q("SELECT photo, profile_guid, id, is_default, uid FROM profile + WHERE profile.uid = %d AND is_default = 1 LIMIT 1", + intval($uid) + ); //If no profile is given, we update the default profile } + if(! $r) + return; $profile = $r[0]; - if(x($profile['id']) && x($profile['photo'])) { - preg_match("@\w*(?=-\d*$)@i", $profile['photo'], $resource_id); - $resource_id = $resource_id[0]; + + if($profile['id'] && $profile['photo']) { + preg_match("@\w*(?=-\d*$)@i", $profile['photo'], $resource_id); + $resource_id = $resource_id[0]; - if (intval($profile['is_default']) != 1) { - $r0 = q("SELECT channel_hash FROM channel WHERE channel_id = %d LIMIT 1", intval(local_channel()) ); - $r1 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%d' ", intval($profile['id'])); //Should not be needed in future. Catches old int-profile-ids. - $r2 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%s'", dbesc($profile['profile_guid'])); + if (! intval($profile['is_default'])) { + $r0 = q("SELECT channel_hash FROM channel WHERE channel_id = %d LIMIT 1", + intval($uid) + ); + //Should not be needed in future. Catches old int-profile-ids. + $r1 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%d' ", + intval($profile['id']) + ); + $r2 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%s'", + dbesc($profile['profile_guid']) + ); $allowcid = "<" . $r0[0]['channel_hash'] . ">"; foreach ($r1 as $entry) { $allowcid .= "<" . $entry['abook_xchan'] . ">"; } foreach ($r2 as $entry) { - $allowcid .= "<" . $entry['abook_xchan'] . ">"; - } + $allowcid .= "<" . $entry['abook_xchan'] . ">"; + } - q("UPDATE `photo` SET allow_cid = '%s' WHERE resource_id = '%s' AND uid = %d",dbesc($allowcid),dbesc($resource_id),intval($profile['uid'])); + q("UPDATE photo SET allow_cid = '%s' WHERE resource_id = '%s' AND uid = %d", + dbesc($allowcid), + dbesc($resource_id), + intval($uid) + ); - } else { - q("UPDATE `photo` SET allow_cid = '' WHERE profile = 1 AND uid = %d",intval($profile['uid'])); //Reset permissions on default profile picture to public + } + else { + //Reset permissions on default profile picture to public + q("UPDATE photo SET allow_cid = '' WHERE photo_usage = %d AND uid = %d", + intval(PHOTO_PROFILE), + intval($uid) + ); } } diff --git a/include/text.php b/include/text.php index 12b6b1137..89c3a0539 100644 --- a/include/text.php +++ b/include/text.php @@ -376,30 +376,6 @@ function unxmlify($s) { return $ret; } -/** - * Convenience wrapper, reverse the operation "bin2hex" - * This is a built-in function in php >= 5.4 - * - * @FIXME We already have php >= 5.4 requirements, so can we remove this? - */ -if(! function_exists('hex2bin')) { -function hex2bin($s) { - if(! (is_string($s) && strlen($s))) - return ''; - - if(strlen($s) & 1) { - logger('hex2bin: illegal hex string: ' . $s); - return $s; - } - - if(! ctype_xdigit($s)) { - return($s); - } - - return(pack("H*",$s)); -}} - - // Automatic pagination. // To use, get the count of total items. // Then call App::set_pager_total($number_items); @@ -1283,7 +1259,7 @@ function normalise_link($url) { * is https and the other isn't, or if one is www.something and the other * isn't - and also ignore case differences. * - * @see normalis_link() + * @see normalise_link() * * @param string $a * @param string $b @@ -1635,7 +1611,7 @@ function prepare_text($text, $content_type = 'text/bbcode', $cache = false) { function create_export_photo_body(&$item) { if(($item['verb'] === ACTIVITY_POST) && ($item['obj_type'] === ACTIVITY_OBJ_PHOTO)) { - $j = json_decode($item['object'],true); + $j = json_decode($item['obj'],true); if($j) { $item['body'] .= "\n\n" . (($j['body']) ? $j['body'] : $j['bbcode']); $item['sig'] = ''; diff --git a/include/zot.php b/include/zot.php index 2530e55bb..6dd789181 100644 --- a/include/zot.php +++ b/include/zot.php @@ -552,7 +552,7 @@ function zot_refresh($them, $channel = null, $force = false) { unset($new_connection[0]['abook_account']); unset($new_connection[0]['abook_channel']); - $abconfig = load_abconfig($channel['channel_hash'],$new_connection['abook_xchan']); + $abconfig = load_abconfig($channel['channel_id'],$new_connection['abook_xchan']); if($abconfig) $new_connection['abconfig'] = $abconfig; @@ -3335,8 +3335,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if($abconfig) { // @fixme does not handle sync of del_abconfig foreach($abconfig as $abc) { - if($abc['chan'] === $channel['channel_hash']) - set_abconfig($abc['chan'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']); + set_abconfig($channel['channel_id'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']); } } } |