From 36d89d02e13ed856de6bace89bfbed05205005db Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 26 Dec 2020 14:10:56 +0100 Subject: Implement Imagemagick resources consumption limiting --- include/photo/photo_driver.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 52f761b65..f61919eea 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -38,6 +38,10 @@ function photo_factory($data, $type = null) { $v = Imagick::getVersion(); preg_match('/ImageMagick ([0-9]+\.[0-9]+\.[0-9]+)/', $v['versionString'], $m); if(version_compare($m[1], '6.6.7') >= 0) { + $limits = get_config('system', 'imagick_limits', false); + if ($limits) + foreach ($limits as $k => $v) + IMagick::setResourceLimit($k, $v); $ph = new PhotoImagick($data, $type); } else { // earlier imagick versions have issues with scaling png's -- cgit v1.2.3 From 5cefdbf98519ef6cb5dbd397e19ff9d0d79258d3 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 29 Dec 2020 20:37:23 +0100 Subject: random_profile: return zot6 entries --- include/connections.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/connections.php b/include/connections.php index 100e595d0..bd41e112e 100644 --- a/include/connections.php +++ b/include/connections.php @@ -472,7 +472,7 @@ function random_profile() { $r = q("select xchan_url, xchan_hash from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_hidden = 0 and xchan_system = 0 and - xchan_network = 'zot' and xchan_deleted = 0 and + xchan_network = 'zot6' and xchan_deleted = 0 and hubloc_connected > %s - interval %s order by $randfunc limit 1", db_utcnow(), db_quoteinterval('30 day') -- cgit v1.2.3 From efc8ed484504e2e01a8bc9dc8c720144995be210 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 2 Jan 2021 11:20:03 +0000 Subject: make share title h3 --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 2426c189f..18f4e6f02 100755 --- a/include/items.php +++ b/include/items.php @@ -3263,7 +3263,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false "' message_id='" . $item['mid'] . "']"; if($item['title']) - $bb .= '[b]'.$item['title'].'[/b]'."\r\n"; + $bb .= '[h3][b]'.$item['title'].'[/b][/h3]'."\r\n"; $bb .= $item['body']; $bb .= "[/share]"; } -- cgit v1.2.3 From 3e3b6cc1e16a797359365cd89d96492393d5ca78 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 2 Jan 2021 21:01:42 +0000 Subject: wrong variable --- include/cdav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/cdav.php b/include/cdav.php index ef248a9fe..fcce0ec4a 100644 --- a/include/cdav.php +++ b/include/cdav.php @@ -111,7 +111,7 @@ function process_cdav_card($f, &$vcard, $edit = false) { function import_cdav_card($id, $ext, $table, $column, $objects, $profile, $backend, &$ids, $notice = false) { $i = 0; - $newid = (count($ids) ? false : true); + $newid = (count($ids) ? false : true); while ($object = $objects->getNext()) { @@ -161,7 +161,7 @@ function import_cdav_card($id, $ext, $table, $column, $objects, $profile, $backe ); } - if($notice && $exp == 'vcf') { + if($notice && $ext == 'vcf') { notice( '' . t('INVALID CARD DISMISSED!') . '' . EOL . '' . t('Name: ') . '' . (($object->FN) ? $object->FN : t('Unknown')) . EOL . -- cgit v1.2.3 From b3a5f9bef4e9d4e5b0c20687d9d251a7c5ef29a1 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 2 Jan 2021 21:10:47 +0000 Subject: wrong variable --- include/channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index d610a0b9a..2d79cd074 100644 --- a/include/channel.php +++ b/include/channel.php @@ -651,7 +651,7 @@ function change_channel_keys($channel) { foreach($h as $hv) { $hv['hubloc_guid_sig'] = $sig; $hv['hubloc_hash'] = $hash; - $hv['hubloc_url_sig'] = base64url_encode(rsa_sign(z_root(),$modifed['channel_prvkey'])); + $hv['hubloc_url_sig'] = base64url_encode(rsa_sign(z_root(),$modified['channel_prvkey'])); hubloc_store_lowlevel($hv); } } -- cgit v1.2.3 From 9759cb7075949299665952ce752ec4acb4339835 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 2 Jan 2021 21:18:49 +0000 Subject: fix typo --- include/dir_fns.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index f477b35dd..b0609ce8b 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -28,7 +28,7 @@ function find_upstream_directory($dirmode) { ); if(($r) && ($r[0]['site_flags'] & DIRECTORY_MODE_STANDALONE)) { $preferred = ''; - } + } } @@ -39,7 +39,7 @@ function find_upstream_directory($dirmode) { * from our list of directory servers. However, if we're a directory * server ourself, point at the local instance * We will then set this value so this should only ever happen once. - * Ideally there will be an admin setting to change to a different + * Ideally there will be an admin setting to change to a different * directory server if you don't like our choice or if circumstances change. */ @@ -94,7 +94,7 @@ function get_directory_setting($observer, $setting) { $ret = get_config('directory', $setting); - // 'safemode' is the default if there is no observer or no established preference. + // 'safemode' is the default if there is no observer or no established preference. if($setting == 'safemode' && $ret === false) $ret = 1; @@ -152,8 +152,8 @@ function dir_sort_links() { * * Checks the directory mode of this hub to see if it is some form of directory server. If it is, * get the directory realm of this hub. Fetch a list of all other directory servers in this realm and request - * a directory sync packet. This will contain both directory updates and new ratings. Store these all in the DB. - * In the case of updates, we will query each of them asynchronously from a poller task. Ratings are stored + * a directory sync packet. This will contain both directory updates and new ratings. Store these all in the DB. + * In the case of updates, we will query each of them asynchronously from a poller task. Ratings are stored * directly if the rater's signature matches. * * @param int $dirmode; @@ -189,7 +189,7 @@ function sync_directories($dirmode) { [ 'site_url' => DIRECTORY_FALLBACK_MASTER, 'site_flags' => DIRECTORY_MODE_PRIMARY, - 'site_update' => NULL_DATE, + 'site_update' => NULL_DATE, 'site_directory' => DIRECTORY_FALLBACK_MASTER . '/dirsearch', 'site_realm' => DIRECTORY_REALM, 'site_valid' => 1, @@ -335,11 +335,11 @@ function update_directory_entry($ud) { // modify the directory search to only return zot6 entries, and also modify this function // to *only* fetch the zot6 entries. // Otherwise we'll be showing duplicates or have a mostly empty directory for a good chunk of - // the transition period. Directory server load will likely increase "moderately" during this transition. - // The one month counter begins when the primary directory has upgraded to a release which uses this code. + // the transition period. Directory server load will likely increase "moderately" during this transition. + // The one month counter begins when the primary directory has upgraded to a release which uses this code. // Hubzilla channels running traditional zot which have not upgraded can or will be dropped from the directory or // "not found" at the end of the transition period as the directory will only serve zot6 entries at that time. - + $uri = Webfinger::zot_url($ud['ud_addr']); if($uri) { $record = Zotfinger::exec($uri); @@ -347,8 +347,8 @@ function update_directory_entry($ud) { // Check the HTTP signature $hsig = $record['signature']; - if($hsig && $hsig['signer'] === $url && $hsig['header_valid'] === true && $hsig['content_valid'] === true) { - $x = \Zotlabs\Lib\Libzot::import_xchan($record['data'], 0, $ud); + if($hsig && $hsig['signer'] === $uri && $hsig['header_valid'] === true && $hsig['content_valid'] === true) { + $x = Libzot::import_xchan($record['data'], 0, $ud); if($x['success']) { $success = true; } @@ -394,7 +394,7 @@ function local_dir_update($uid, $force) { $profile['description'] = $p[0]['pdesc']; $profile['birthday'] = $p[0]['dob']; - if ($age = age($p[0]['dob'],$p[0]['channel_timezone'],'')) + if ($age = age($p[0]['dob'],$p[0]['channel_timezone'],'')) $profile['age'] = $age; $profile['gender'] = $p[0]['gender']; -- cgit v1.2.3 From 7684861249c22293e424f1bc62790fa06596b97e Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 2 Jan 2021 21:37:06 +0000 Subject: do not check against undefined variable --- include/network.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index bcd66cf85..324a99eba 100644 --- a/include/network.php +++ b/include/network.php @@ -714,7 +714,7 @@ function sxml2array ( $xmlObject, $out = array () ) * @brief xml2array() will convert the given XML text to an array in the XML structure. * * Link: http://www.bin-co.com/php/scripts/xml2array/ - * Portions significantly re-written by mike@macgirvin.com + * Portions significantly re-written by mike@macgirvin.com * (namespaces, lowercase tags, get_attribute default changed, more...) * * Examples: $array = xml2array(file_get_contents('feed.xml')); @@ -1113,8 +1113,8 @@ function discover_by_webbie($webbie, $protocol = '') { // Check the HTTP signature $hsig = $record['signature']; - if($hsig && ($hsig['signer'] === $url || $hsig['signer'] === $link['href']) && $hsig['header_valid'] === true && $hsig['content_valid'] === true) - $hsig_valid = true; + if($hsig && $hsig['signer'] === $link['href'] && $hsig['header_valid'] === true && $hsig['content_valid'] === true) + $hsig_valid = true; if(! $hsig_valid) { logger('http signature not valid: ' . print_r($hsig,true)); @@ -1431,7 +1431,7 @@ function scrape_feed($url) { function do_delivery($deliveries, $force = false) { // $force is set if a site that wasn't responding suddenly returns to life. - // Try and shove through everything going to that site while it's responding. + // Try and shove through everything going to that site while it's responding. if(! (is_array($deliveries) && count($deliveries))) return; @@ -2069,7 +2069,7 @@ function get_request_string($url) { * Takes the output of parse_url and builds a URL from it * */ - + function unparse_url($parsed_url) { $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; @@ -2081,4 +2081,4 @@ function unparse_url($parsed_url) { $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; return "$scheme$user$pass$host$port$path$query$fragment"; -} +} -- cgit v1.2.3 From cff5859c595ae3d758072b11aa60190e210cb490 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 3 Jan 2021 14:28:02 +0000 Subject: mod cloud strings --- include/js_strings.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/js_strings.php b/include/js_strings.php index 6f559f4c4..e06e105fd 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -47,10 +47,10 @@ function js_strings() { 'days' => tt('%d days', '%d days', '%d'), 'months' => tt('%d months', '%d months', '%d'), 'years' => tt('%d years', '%d years', '%d'), - + // get plural function code 'plural_func' => tf(), - + '$t01' => ((t('timeago.prefixAgo') == 'timeago.prefixAgo') ? '' : ((t('timeago.prefixAgo') == 'NONE') ? '' : t('timeago.prefixAgo'))), '$t02' => ((t('timeago.prefixFromNow') == 'timeago.prefixFromNow') ? '' : ((t('timeago.prefixFromNow') == 'NONE') ? '' : t('timeago.prefixFromNow'))), '$t03' => ((t('timeago.suffixAgo') == 'timeago.suffixAgo') ? 'ago' : ((t('timeago.suffixAgo') == 'NONE') ? '' : t('timeago.suffixAgo'))), @@ -113,6 +113,9 @@ function js_strings() { '$month' => t('month','calendar'), '$week' => t('week','calendar'), '$day' => t('day','calendar'), - '$allday' => t('All day','calendar') + '$allday' => t('All day','calendar'), + + // mod cloud + '$download_info' => t('Please stand by while your download is being prepared.') )); } -- cgit v1.2.3 From 6999b8d9b45584c0db82f8fcc6bf3b1212daa3c6 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 3 Jan 2021 20:17:45 +0000 Subject: fix no channel_id provided for contact_remove() in reply_purge(). fix wrong notifier command --- include/connections.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/connections.php b/include/connections.php index bd41e112e..99a4cc71e 100644 --- a/include/connections.php +++ b/include/connections.php @@ -357,7 +357,7 @@ function contact_remove($channel_id, $abook_id) { call_hooks('connection_remove',$x); - $archive = get_pconfig($channel_id, 'system','archive_removed_contacts'); + $archive = get_pconfig($channel_id, 'system', 'archive_removed_contacts'); if($archive) { q("update abook set abook_archived = 1 where abook_id = %d and abook_channel = %d", intval($abook_id), -- cgit v1.2.3 From 291644f29d80670bdff8160b57c152c140bd8155 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Jan 2021 20:36:24 +0100 Subject: fix issue where categories were not saved on forum wall post --- include/items.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 18f4e6f02..a90ddd208 100755 --- a/include/items.php +++ b/include/items.php @@ -3270,6 +3270,8 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false $arr['body'] = $bb; + $arr['term'] = $item['term']; + $arr['author_xchan'] = $channel['channel_hash']; $arr['owner_xchan'] = $channel['channel_hash']; -- cgit v1.2.3 From c7010dac3c74e25eac8855d87d78d892052d3c4e Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 6 Jan 2021 19:22:29 +0000 Subject: simplify attach_folder_select_list() --- include/attach.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index b4f697f81..bcb3061f4 100644 --- a/include/attach.php +++ b/include/attach.php @@ -2987,10 +2987,7 @@ function attach_folder_select_list($channel_id) { if($r) { foreach($r as $rv) { - $x = attach_folder_rpaths($r,$rv); - if($x) { - $out[$x[0]] = $x[1]; - } + $out[$rv['hash']] = $rv['display_path']; } } -- cgit v1.2.3 From 16082456dfbb3e3108ba1a1db627f7333d10ddce Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 6 Jan 2021 19:32:36 +0000 Subject: error in logic --- include/attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index bcb3061f4..f65f41477 100644 --- a/include/attach.php +++ b/include/attach.php @@ -3017,7 +3017,7 @@ function attach_folder_rpaths($all_folders,$that_folder) { if(! $found) $error = true; } - while((! $found) && (! $error) && ($parent_hash != '')); + while((! $error) && ($parent_hash != '')); } return (($error) ? false : [ $current_hash , $path ]); -- cgit v1.2.3 From 7f51ff0a8d9a63773a176a13d5202693c35a5a67 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 8 Jan 2021 21:27:06 +0000 Subject: set resource_type = group_item and resource_id = original mid for forum items so we do not need to query the body for the original mid on edit. --- include/items.php | 28 ++++++++++++++++++++-------- include/text.php | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index a90ddd208..85465192d 100755 --- a/include/items.php +++ b/include/items.php @@ -2206,6 +2206,7 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) { return $ret; } + // override the unseen flag with the original $arr['item_unseen'] = $orig[0]['item_unseen']; @@ -2682,6 +2683,12 @@ function tag_deliver($uid, $item_id) { if ($is_group && intval($item['item_thread_top']) && intval($item['item_wall']) && $item['author_xchan'] !== $item['owner_xchan']) { + + if($item['resource_type'] === 'group_item') { + logger('resource_type group_item: already shared'); + return; + } + if (strpos($item['body'],'[/share]')) { logger('W2W post already shared'); return; @@ -3113,11 +3120,12 @@ function tgroup_check($uid, $item) { } } } -*/ + if(! $found) { logger('tgroup_check: mention was in a reshare or exceeded max_tagged_forums - ignoring'); continue; } +*/ return true; } @@ -3203,16 +3211,18 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false $arr = []; if ($edit) { + // process edit or delete action - $r = q("select * from item where source_xchan = '%s' and body like '%s' and uid = %d limit 1", - dbesc($item['owner_xchan']), - dbesc("%message_id='" . $item['mid'] . "'%"), - intval($channel['channel_id']) + $r = q("select * from item where uid = %d and resource_id = '%s' and source_xchan = '%s' and resource_type = 'group_item' limit 1", + intval($channel['channel_id']), + dbesc($item['mid']), + dbesc($item['author_xchan']) ); + if ($r) { if (intval($item['item_deleted'])) { - drop_item($r[0]['id'],false,DROPITEM_PHASE1); - Master::Summon([ 'Notifier','drop',$r[0]['id'] ]); + drop_item($r[0]['id'], false, DROPITEM_PHASE1); + Master::Summon([ 'Notifier', 'drop', $r[0]['id'] ]); return; } $arr['id'] = intval($r[0]['id']); @@ -3242,6 +3252,9 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false $arr['item_uplink'] = 0; $arr['source_xchan'] = $item['owner_xchan']; + $arr['resource_id'] = $item['mid']; + $arr['resource_type'] = 'group_item'; + $arr['item_private'] = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 1 : 0); @@ -3269,7 +3282,6 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false } $arr['body'] = $bb; - $arr['term'] = $item['term']; $arr['author_xchan'] = $channel['channel_hash']; diff --git a/include/text.php b/include/text.php index 76df9e17b..d6b196f1e 100644 --- a/include/text.php +++ b/include/text.php @@ -1801,7 +1801,7 @@ function prepare_body(&$item,$attach = false,$opts = false) { $tags = format_hashtags($item); - if($item['resource_type']) + if($item['resource_type'] == 'photo') $mentions = format_mentions($item); $categories = format_categories($item,$writeable); -- cgit v1.2.3 From 7cfb230a5e90986b62a5c1df86ce48c894c0578c Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 9 Jan 2021 13:22:43 +0000 Subject: streamline keyid --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index d02cc1e1f..853690094 100644 --- a/include/import.php +++ b/include/import.php @@ -1358,7 +1358,7 @@ function sync_files($channel, $files) { $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['Sigtoken'] = random_string(); - $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'], 'acct:' . channel_reddress($channel),true,'sha512'); + $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), true, 'sha512'); $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); -- cgit v1.2.3 From 61e782389c20a0d22749985177370149af4ae119 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 9 Jan 2021 13:24:32 +0000 Subject: more streamline keyid --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index 853690094..b512e1f11 100644 --- a/include/import.php +++ b/include/import.php @@ -1463,7 +1463,7 @@ function sync_files($channel, $files) { $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['Sigtoken'] = random_string(); - $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'],'acct:' . channel_reddress($channel),true,'sha512'); + $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), true, 'sha512'); $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); -- cgit v1.2.3 From 2522d42c71baee9caba181566948ae4c899885bd Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 9 Jan 2021 20:22:47 +0100 Subject: fix some php8 fatal errors --- include/help.php | 2 +- include/html2plain.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/help.php b/include/help.php index affe64495..ebf1ccc08 100644 --- a/include/help.php +++ b/include/help.php @@ -299,7 +299,7 @@ function load_context_help() { break; array_pop($args); - $path = implode($args,'/'); + $path = implode('/', $args); } return $context_help; diff --git a/include/html2plain.php b/include/html2plain.php index 979354079..fde70bd01 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -40,7 +40,7 @@ function breaklines($line, $level, $wraplength = 75) $newlines[] = $line; - return(implode($newlines, "\n")); + return(implode("\n", $newlines)); } function quotelevel($message, $wraplength = 75) @@ -73,7 +73,7 @@ function quotelevel($message, $wraplength = 75) if (!$startquote or ($line != '')) $newlines[] = breaklines($line, $currlevel, $wraplength); } - return(implode($newlines, "\n")); + return(implode("\n", $newlines)); } function collecturls($message) { -- cgit v1.2.3 From efb8a29b5fcacd491c5e080572581437b6000f87 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 9 Jan 2021 20:20:48 +0000 Subject: keyid adapt for backward compatibility to current release part 2 --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index b512e1f11..82d6cfe07 100644 --- a/include/import.php +++ b/include/import.php @@ -1358,7 +1358,7 @@ function sync_files($channel, $files) { $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['Sigtoken'] = random_string(); - $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), true, 'sha512'); + $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_reddress($channel), true, 'sha512'); $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); -- cgit v1.2.3 From 12ba2c30b907c5350a4a79e04391f5c0e356b547 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 11 Jan 2021 08:59:16 +0000 Subject: can not access global from statc method --- include/dir_fns.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index b0609ce8b..88a1bb74f 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -16,7 +16,6 @@ require_once('include/permissions.php'); * @return array */ function find_upstream_directory($dirmode) { - global $DIRECTORY_FALLBACK_SERVERS; $preferred = get_config('system','directory_server'); @@ -43,10 +42,12 @@ function find_upstream_directory($dirmode) { * directory server if you don't like our choice or if circumstances change. */ + $directory_fallback_servers = get_directory_fallback_servers(); + $dirmode = intval(get_config('system','directory_mode')); if ($dirmode == DIRECTORY_MODE_NORMAL) { - $toss = mt_rand(0,count($DIRECTORY_FALLBACK_SERVERS)); - $preferred = $DIRECTORY_FALLBACK_SERVERS[$toss]; + $toss = mt_rand(0,count($directory_fallback_servers)); + $preferred = $directory_fallback_servers[$toss]; set_config('system','directory_server',$preferred); } else{ set_config('system','directory_server',z_root()); -- cgit v1.2.3 From b9fd87b004fe083c3f8064de5defea4ff439bce0 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 13 Jan 2021 08:54:58 +0000 Subject: do not turn the groups own direkt messages into group items - fixes #1510 --- include/items.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 85465192d..317a84730 100755 --- a/include/items.php +++ b/include/items.php @@ -2673,6 +2673,11 @@ function tag_deliver($uid, $item_id) { } if ($is_group && intval($item['item_private']) === 2 && intval($item['item_thread_top'])) { + + // do not turn the groups own direkt messages into group items + if($item['item_wall'] && $item['author_xchan'] === $u[0]['channel_hash']) + return; + // group delivery via DM if(perm_is_allowed($uid,$item['owner_xchan'],'post_wall') || perm_is_allowed($uid,$item['owner_xchan'],'tag_deliver')) { logger('group DM delivery for ' . $u[0]['channel_address']); -- cgit v1.2.3 From b7afc905ecc5b738c7696b662692f727099cb968 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 13 Jan 2021 09:34:38 +0000 Subject: Revert "keyid adapt for backward compatibility to current release part 2" This reverts commit efb8a29b5fcacd491c5e080572581437b6000f87. --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index 82d6cfe07..b512e1f11 100644 --- a/include/import.php +++ b/include/import.php @@ -1358,7 +1358,7 @@ function sync_files($channel, $files) { $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['Sigtoken'] = random_string(); - $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_reddress($channel), true, 'sha512'); + $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), true, 'sha512'); $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); -- cgit v1.2.3 From 83f0c3d1ddcedc2324021f5f0d7a7e0b319da0d3 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 14 Jan 2021 14:28:35 +0000 Subject: some work to fix r_preview in list mode --- include/conversation.php | 110 +++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 6615b04c3..087e8c135 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -90,18 +90,18 @@ function item_redir_and_replace_images($body, $images, $cid) { function localize_item(&$item){ if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){ - + if(! $item['obj']) return; if(intval($item['item_thread_top'])) - return; + return; $obj = json_decode($item['obj'],true); if((! $obj) && ($item['obj'])) { logger('localize_item: failed to decode object: ' . print_r($item['obj'],true)); } - + if(is_array($obj['author']) && $obj['author']['link']) $author_link = get_rel_link($obj['author']['link'],'alternate'); elseif(is_array($obj['actor']) && $obj['actor']['url']) @@ -167,7 +167,7 @@ function localize_item(&$item){ if($author_link && $author_name && $item_url) { $author = '[zrl=' . chanlink_url($item['author']['xchan_url']) . ']' . $item['author']['xchan_name'] . '[/zrl]'; $objauthor = '[zrl=' . chanlink_url($author_link) . ']' . $author_name . '[/zrl]'; - + $plink = '[zrl=' . zid($item_url) . ']' . $post_type . '[/zrl]'; if(activity_match($item['verb'],ACTIVITY_LIKE)) { @@ -189,7 +189,7 @@ function localize_item(&$item){ $item['shortlocalize'] = sprintf($shortbodyverb, '[bdi]' . $author_name . '[/bdi]', $post_type); $item['body'] = $item['localize'] = sprintf($bodyverb, '[bdi]' . $author . '[/bdi]', '[bdi]' . $objauthor . '[/bdi]', $plink); - if($Bphoto != "") + if($Bphoto != "") $item['body'] .= "\n\n\n" . '[zrl=' . chanlink_url($author_link) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]'; } @@ -201,7 +201,7 @@ function localize_item(&$item){ if (activity_match($item['verb'],ACTIVITY_FRIEND)) { - if ($item['obj_type'] == "" || $item['obj_type'] !== ACTIVITY_OBJ_PERSON) + if ($item['obj_type'] == "" || $item['obj_type'] !== ACTIVITY_OBJ_PERSON) return; $Aname = $item['author']['xchan_name']; @@ -209,7 +209,7 @@ function localize_item(&$item){ $obj= json_decode($item['obj'],true); - + $Blink = $Bphoto = ''; if($obj['link']) { @@ -282,7 +282,7 @@ function localize_item(&$item){ $Alink = $item['author']['xchan_url']; $A = '[zrl=' . chanlink_url($Alink) . '][bdi]' . $Aname . '[/bdi][/zrl]'; - + $txt = t('%1$s is %2$s','mood'); $item['body'] = sprintf($txt, $A, t($verb)); @@ -295,15 +295,15 @@ function localize_item(&$item){ // (and update to json storage) if (activity_match($item['verb'],ACTIVITY_TAG)) { - $r = q("SELECT * from item,contact WHERE + $r = q("SELECT * from item,contact WHERE item.contact-id=contact.id AND item.mid='%s';", dbesc($item['parent_mid'])); if(count($r)==0) return; $obj=$r[0]; - + $author = '[zrl=' . zid($item['author-link']) . ']' . $item['author-name'] . '[/zrl]'; $objauthor = '[zrl=' . zid($obj['author-link']) . ']' . $obj['author-name'] . '[/zrl]'; - + switch($obj['verb']){ case ACTIVITY_POST: switch ($obj['obj_type']){ @@ -416,7 +416,7 @@ function count_descendants($item) { * likes (etc.) can apply to other things besides posts. Check if they are post * children, in which case we handle them specially. Activities which are unrecognised * as having special meaning and hidden will be treated as posts or comments and visible - * in the stream. + * in the stream. * * @param array $item * @return boolean @@ -438,14 +438,14 @@ function visible_activity($item) { } // We only need edit activities for other federated protocols - // which do not support edits natively. While this does federate + // which do not support edits natively. While this does federate // edits, it presents a number of issues locally - such as #757 and #758. // The SQL check for an edit activity would not perform that well so to fix these issues - // requires an additional item flag (perhaps 'item_edit_activity') that we can add to the + // requires an additional item flag (perhaps 'item_edit_activity') that we can add to the // query for searches and notifications. - // For now we'll just forget about trying to make edits work on network protocols that - // don't support them. + // For now we'll just forget about trying to make edits work on network protocols that + // don't support them. // if(is_edit_activity($item)) // return false; @@ -455,7 +455,7 @@ function visible_activity($item) { /** * @brief Check if a given activity is an edit activity - * + * * * @param array $item * @return boolean @@ -463,11 +463,11 @@ function visible_activity($item) { function is_edit_activity($item) { - $post_types = [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT, basename(ACTIVITY_OBJ_NOTE), basename(ACTIVITY_OBJ_COMMENT)]; + $post_types = [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT, basename(ACTIVITY_OBJ_NOTE), basename(ACTIVITY_OBJ_COMMENT)]; - // In order to share edits with networks which have no concept of editing, we'll create + // In order to share edits with networks which have no concept of editing, we'll create // separate activities to indicate the edit. Our network will not require them, since our - // edits are automatically applied and the activity indicated. + // edits are automatically applied and the activity indicated. if(($item['verb'] === ACTIVITY_UPDATE) && (in_array($item['obj_type'],$post_types))) return true; @@ -678,12 +678,12 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa foreach($items as $item) { - $x = [ - 'mode' => $mode, - 'item' => $item + $x = [ + 'mode' => $mode, + 'item' => $item ]; call_hooks('stream_item',$x); - + if($x['item']['blocked']) continue; @@ -699,7 +699,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $is_new = false; if($mode === 'search' || $mode === 'community') { - if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) + if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent'])) continue; } @@ -726,7 +726,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $drop = array( 'pagedropping' => $page_dropping, 'dropping' => $dropping, - 'select' => t('Select'), + 'select' => t('Select'), 'delete' => t('Delete'), ); @@ -769,7 +769,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $tmp_item = array( 'template' => $tpl, 'toplevel' => 'toplevel_item', - 'item_type' => intval($item['item_type']), + 'item_type' => intval($item['item_type']), 'mode' => $mode, 'approve' => t('Approve'), 'delete' => t('Delete'), @@ -844,7 +844,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $conv = new Zotlabs\Lib\ThreadStream($mode, $preview, $uploading, $prepared_item); - // In the display mode we don't have a profile owner. + // In the display mode we don't have a profile owner. if($mode === 'display' && $items) $conv->set_profile_owner($items[0]['uid']); @@ -861,7 +861,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $x = [ 'mode' => $mode, 'item' => $item ]; call_hooks('stream_item',$x); - + if($x['item']['blocked']) continue; @@ -970,9 +970,9 @@ function best_link_url($item) { function thread_action_menu($item,$mode = '') { $menu = []; - + if((local_channel()) && local_channel() == $item['uid']) { - $menu[] = [ + $menu[] = [ 'menu' => 'view_source', 'title' => t('View Source'), 'icon' => 'code', @@ -982,7 +982,7 @@ function thread_action_menu($item,$mode = '') { if(! in_array($mode, [ 'network-new', 'search', 'community'])) { if($item['parent'] == $item['id'] && (get_observer_hash() != $item['author_xchan'])) { - $menu[] = [ + $menu[] = [ 'menu' => 'follow_thread', 'title' => t('Follow Thread'), 'icon' => 'plus', @@ -991,7 +991,7 @@ function thread_action_menu($item,$mode = '') { ]; } - $menu[] = [ + $menu[] = [ 'menu' => 'unfollow_thread', 'title' => t('Unfollow Thread'), 'icon' => 'minus', @@ -1018,7 +1018,7 @@ function author_is_pmable($xchan, $abook) { call_hooks('author_is_pmable',$x); if($x['result'] !== 'unset') return $x['result']; - + if($xchan['xchan_network'] === 'zot' && get_observer_hash()) return true; return false; @@ -1063,7 +1063,7 @@ function thread_author_menu($item, $mode = '') { if($contact) { $poke_link = ((Apps::system_app_installed($local_channel, 'Poke')) ? z_root() . '/poke/?f=&c=' . $contact['abook_id'] : ''); - if (! intval($contact['abook_self'])) + if (! intval($contact['abook_self'])) $contact_url = z_root() . '/connedit/' . $contact['abook_id']; $posts_link = z_root() . '/network/?cid=' . $contact['abook_id']; @@ -1075,7 +1075,7 @@ function thread_author_menu($item, $mode = '') { $ratings_url = (($rating_enabled) ? z_root() . '/ratings/' . urlencode($item['author_xchan']) : ''); if($profile_link) { - $menu[] = [ + $menu[] = [ 'menu' => 'view_profile', 'title' => t('View Profile'), 'icon' => 'fw', @@ -1085,7 +1085,7 @@ function thread_author_menu($item, $mode = '') { } if($posts_link) { - $menu[] = [ + $menu[] = [ 'menu' => 'view_posts', 'title' => t('Recent Activity'), 'icon' => 'fw', @@ -1095,7 +1095,7 @@ function thread_author_menu($item, $mode = '') { } if($follow_url) { - $menu[] = [ + $menu[] = [ 'menu' => 'follow', 'title' => t('Connect'), 'icon' => 'fw', @@ -1105,7 +1105,7 @@ function thread_author_menu($item, $mode = '') { } if($contact_url) { - $menu[] = [ + $menu[] = [ 'menu' => 'connedit', 'title' => t('Edit Connection'), 'icon' => 'fw', @@ -1115,7 +1115,7 @@ function thread_author_menu($item, $mode = '') { } if($pm_url) { - $menu[] = [ + $menu[] = [ 'menu' => 'prv_message', 'title' => t('Message'), 'icon' => 'fw', @@ -1125,7 +1125,7 @@ function thread_author_menu($item, $mode = '') { } if($ratings_url) { - $menu[] = [ + $menu[] = [ 'menu' => 'ratings', 'title' => t('Ratings'), 'icon' => 'fw', @@ -1135,7 +1135,7 @@ function thread_author_menu($item, $mode = '') { } if($poke_link) { - $menu[] = [ + $menu[] = [ 'menu' => 'poke', 'title' => t('Poke'), 'icon' => 'fw', @@ -1209,8 +1209,8 @@ function builtin_activity_puller($item, &$conv_responses) { if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) { $name = (($item['author']['xchan_name']) ? $item['author']['xchan_name'] : t('Unknown')); - $url = (($item['author_xchan'] && $item['author']['xchan_photo_s']) - ? '' . '' . urlencode($name) . ' ' . $name . '' + $url = (($item['author_xchan'] && $item['author']['xchan_photo_s']) + ? '' . '' . urlencode($name) . ' ' . $name . '' : '' . $name . '' ); @@ -1222,7 +1222,7 @@ function builtin_activity_puller($item, &$conv_responses) { if($item['obj_type'] === 'Answer') continue; - if(! ((isset($conv_responses[$mode][$item['thr_parent'] . '-l'])) + if(! ((isset($conv_responses[$mode][$item['thr_parent'] . '-l'])) && (is_array($conv_responses[$mode][$item['thr_parent'] . '-l'])))) $conv_responses[$mode][$item['thr_parent'] . '-l'] = array(); @@ -1297,9 +1297,9 @@ function status_editor($a, $x, $popup = false, $module='') { } /** - * This is our general purpose content editor. + * This is our general purpose content editor. * It was once nicknamed "jot" and you may see references to "jot" littered throughout the code. - * They are referring to the content editor or components thereof. + * They are referring to the content editor or components thereof. */ function hz_status_editor($a, $x, $popup = false) { @@ -1341,7 +1341,7 @@ function hz_status_editor($a, $x, $popup = false) { $weblink = (($mimetype === 'text/bbcode') ? t('Insert web link') : false); if(x($x, 'hide_weblink')) $weblink = false; - + $embedPhotos = t('Embed (existing) photo from your photo albums'); $writefiles = (($mimetype === 'text/bbcode') ? perm_is_allowed($x['profile_uid'], get_observer_hash(), 'write_storage') : false); @@ -1366,9 +1366,9 @@ function hz_status_editor($a, $x, $popup = false) { $webpage = ((x($x,'webpage')) ? $x['webpage'] : ''); $reset = ((x($x,'reset')) ? $x['reset'] : ''); - + $feature_auto_save_draft = ((feature_enabled($x['profile_uid'], 'auto_save_draft')) ? "true" : "false"); - + $tpl = get_markup_template('jot-header.tpl'); $tplmacros = [ @@ -1394,7 +1394,7 @@ function hz_status_editor($a, $x, $popup = false) { '$reset' => $reset ]; - call_hooks('jot_header_tpl_filter',$tplmacros); + call_hooks('jot_header_tpl_filter',$tplmacros); App::$page['htmlhead'] .= replace_macros($tpl, $tplmacros); $tpl = get_markup_template('jot.tpl'); @@ -1421,7 +1421,7 @@ function hz_status_editor($a, $x, $popup = false) { $catsenabled = ((feature_enabled($x['profile_uid'], 'categories') && (! $webpage)) ? 'categories' : ''); // avoid illegal offset errors - if(! array_key_exists('permissions',$x)) + if(! array_key_exists('permissions',$x)) $x['permissions'] = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; $jotplugins = ''; @@ -1539,7 +1539,7 @@ function get_item_children($arr, $parent) { $thr_parent = $item['thr_parent']; if($thr_parent == '') $thr_parent = $item['parent_mid']; - + if($thr_parent == $parent['mid']) { $item['children'] = get_item_children($arr, $item); $children[] = $item; @@ -1698,9 +1698,9 @@ function prepare_page($item) { return replace_macros(get_markup_template($tpl), array( '$body' => $body['html'] )); - + } - + $tpl = get_pconfig($item['uid'], 'system', 'pagetemplate'); if (! $tpl) $tpl = 'page_display.tpl'; -- cgit v1.2.3 From 42812078c51acb9ffc26cc3cfc52e5048fed16b8 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Jan 2021 10:00:13 +0000 Subject: make attach_upgrade() catch entries where only display_path is missing --- include/attach.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index f65f41477..9ba6be109 100644 --- a/include/attach.php +++ b/include/attach.php @@ -3064,8 +3064,7 @@ function attach_syspaths($channel_id,$attach_hash) { function attach_upgrade() { - - $r = q("select id, uid, hash from attach where os_path = '' and display_path = '' limit 100"); + $r = q("SELECT id, uid, hash FROM attach WHERE os_path = '' OR display_path = '' LIMIT 100"); if($r) { foreach($r as $rv) { $x = attach_syspaths($rv['uid'],$rv['hash']); -- cgit v1.2.3 From 1e645cabd4bdef838793f3d9b1ee92656838844b Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Jan 2021 15:00:53 +0000 Subject: style fixes --- include/security.php | 242 +++++++++++++++++++++++++-------------------------- 1 file changed, 120 insertions(+), 122 deletions(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index c9df00f1e..40905925f 100644 --- a/include/security.php +++ b/include/security.php @@ -19,26 +19,26 @@ function authenticate_success($user_record, $channel = null, $login_initial = fa $lastlog_updated = false; - if(x($user_record, 'account_id')) { + if (x($user_record, 'account_id')) { App::$account = $user_record; $_SESSION['account_id'] = $user_record['account_id']; $_SESSION['authenticated'] = 1; - if($channel) + if ($channel) $uid_to_load = $channel['channel_id']; - if(! $uid_to_load) { - $uid_to_load = (((x($_SESSION,'uid')) && (intval($_SESSION['uid']))) + if (!$uid_to_load) { + $uid_to_load = (((x($_SESSION, 'uid')) && (intval($_SESSION['uid']))) ? intval($_SESSION['uid']) : intval(App::$account['account_default_channel']) ); } - if($uid_to_load) { + if ($uid_to_load) { change_channel($uid_to_load); } - if($login_initial || $update_lastlog) { + if ($login_initial || $update_lastlog) { q("update account set account_lastlog = '%s' where account_id = %d", dbesc(datetime_convert()), intval($_SESSION['account_id']) @@ -50,24 +50,24 @@ function authenticate_success($user_record, $channel = null, $login_initial = fa } - if(($login_initial) && (! $lastlog_updated)) { + if (($login_initial) && (!$lastlog_updated)) { call_hooks('logged_in', $user_record); // might want to log success here } - if($return || x($_SESSION, 'workflow')) { + if ($return || x($_SESSION, 'workflow')) { unset($_SESSION['workflow']); return; } - if((App::$module !== 'home') && x($_SESSION,'login_return_url') && strlen($_SESSION['login_return_url'])) { + if ((App::$module !== 'home') && x($_SESSION, 'login_return_url') && strlen($_SESSION['login_return_url'])) { $return_url = $_SESSION['login_return_url']; // don't let members get redirected to a raw ajax page update - this can happen // if DHCP changes the IP address at an unfortunate time and paranoia is turned on - if(strstr($return_url,'update_')) + if (strstr($return_url, 'update_')) $return_url = ''; unset($_SESSION['login_return_url']); @@ -76,11 +76,11 @@ function authenticate_success($user_record, $channel = null, $login_initial = fa /* This account has never created a channel. Send them to new_channel by default */ - if(App::$module === 'login') { + if (App::$module === 'login') { $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0 ", intval(App::$account['account_id']) ); - if(($r) && (! $r[0]['total'])) + if (($r) && (!$r[0]['total'])) goaway(z_root() . '/new_channel'); } @@ -88,14 +88,14 @@ function authenticate_success($user_record, $channel = null, $login_initial = fa } function atoken_login($atoken) { - if(! $atoken) + if (!$atoken) return false; $_SESSION['authenticated'] = 1; $_SESSION['visitor_id'] = $atoken['xchan_hash']; $_SESSION['atoken'] = $atoken['atoken_id']; - \App::set_observer($atoken); + App::set_observer($atoken); return true; } @@ -109,14 +109,14 @@ function atoken_login($atoken) { function atoken_xchan($atoken) { $c = channelx_by_n($atoken['atoken_uid']); - if($c) { + if ($c) { return [ 'atoken_id' => $atoken['atoken_id'], - 'xchan_hash' => substr($c['channel_hash'],0,16) . '.' . $atoken['atoken_name'], + 'xchan_hash' => substr($c['channel_hash'], 0, 16) . '.' . $atoken['atoken_name'], 'xchan_name' => $atoken['atoken_name'], - 'xchan_addr' => 'guest:' . $atoken['atoken_name'] . '@' . \App::get_hostname(), + 'xchan_addr' => 'guest:' . $atoken['atoken_name'] . '@' . App::get_hostname(), 'xchan_network' => 'unknown', - 'xchan_url' => z_root() . '/guest/' . substr($c['channel_hash'],0,16) . '.' . $atoken['atoken_name'], + 'xchan_url' => z_root() . '/guest/' . substr($c['channel_hash'], 0, 16) . '.' . $atoken['atoken_name'], 'xchan_hidden' => 1, 'xchan_photo_mimetype' => 'image/png', 'xchan_photo_l' => z_root() . '/' . get_default_profile_photo(300), @@ -133,16 +133,16 @@ function atoken_delete($atoken_id) { $r = q("select * from atoken where atoken_id = %d", intval($atoken_id) ); - if(! $r) + if (!$r) return; $c = q("select channel_id, channel_hash from channel where channel_id = %d", intval($r[0]['atoken_uid']) ); - if(! $c) + if (!$c) return; - $atoken_xchan = substr($c[0]['channel_hash'],0,16) . '.' . $r[0]['atoken_name']; + $atoken_xchan = substr($c[0]['channel_hash'], 0, 16) . '.' . $r[0]['atoken_name']; q("delete from atoken where atoken_id = %d", intval($atoken_id) @@ -168,41 +168,41 @@ function atoken_create_xchan($xchan) { $r = q("select xchan_hash from xchan where xchan_hash = '%s'", dbesc($xchan['xchan_hash']) ); - if($r) + if ($r) return; $xchan['xchan_guid'] = $xchan['xchan_hash']; $store = []; - foreach($xchan as $k => $v) { - if(strpos($k,'xchan_') === 0) { + foreach ($xchan as $k => $v) { + if (strpos($k, 'xchan_') === 0) { $store[$k] = $v; } } - - $r = xchan_store_lowlevel($store); + + xchan_store_lowlevel($store); return true; } -function atoken_abook($uid,$xchan_hash) { +function atoken_abook($uid, $xchan_hash) { - if(substr($xchan_hash,16,1) != '.') + if (substr($xchan_hash, 16, 1) != '.') return false; $r = q("select channel_hash from channel where channel_id = %d limit 1", intval($uid) ); - if(! $r) + if (!$r) return false; $x = q("select * from atoken where atoken_uid = %d and atoken_name = '%s'", intval($uid), - dbesc(substr($xchan_hash,17)) + dbesc(substr($xchan_hash, 17)) ); - if($x) { + if ($x) { $xchan = atoken_xchan($x[0]); $xchan['abook_blocked'] = 0; $xchan['abook_ignored'] = 0; @@ -215,12 +215,12 @@ function atoken_abook($uid,$xchan_hash) { function pseudo_abook($xchan) { - if(! $xchan) + if (!$xchan) return false; // set abook_pseudo to flag that we aren't really connected. - $xchan['abook_pseudo'] = 1; + $xchan['abook_pseudo'] = 1; $xchan['abook_blocked'] = 0; $xchan['abook_ignored'] = 0; $xchan['abook_pending'] = 0; @@ -240,7 +240,7 @@ function change_channel($change_channel) { $ret = false; - if($change_channel) { + if ($change_channel) { $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_account_id = %d and channel_removed = 0 limit 1", intval($change_channel), @@ -249,7 +249,7 @@ function change_channel($change_channel) { // It's not there. Is this an administrator, and is this the sys channel? if (is_developer()) { - if (! $r) { + if (!$r) { if (is_site_admin()) { $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_system = 1 and channel_removed = 0 limit 1", intval($change_channel) @@ -258,19 +258,19 @@ function change_channel($change_channel) { } } - if($r) { + if ($r) { $hash = $r[0]['channel_hash']; $_SESSION['uid'] = intval($r[0]['channel_id']); App::set_channel($r[0]); $_SESSION['theme'] = $r[0]['channel_theme']; - $_SESSION['mobile_theme'] = get_pconfig(local_channel(),'system', 'mobile_theme'); - $_SESSION['cloud_tiles'] = get_pconfig(local_channel(),'system', 'cloud_tiles'); + $_SESSION['mobile_theme'] = get_pconfig(local_channel(), 'system', 'mobile_theme'); + $_SESSION['cloud_tiles'] = get_pconfig(local_channel(), 'system', 'cloud_tiles'); date_default_timezone_set($r[0]['channel_timezone']); // Update the active timestamp at most once a day - if(substr($r[0]['channel_active'],0,10) !== substr(datetime_convert(),0,10)) { - $z = q("UPDATE channel SET channel_active = '%s' WHERE channel_id = %d", + if (substr($r[0]['channel_active'], 0, 10) !== substr(datetime_convert(), 0, 10)) { + q("UPDATE channel SET channel_active = '%s' WHERE channel_id = %d", dbesc(datetime_convert()), intval($r[0]['channel_id']) ); @@ -280,17 +280,17 @@ function change_channel($change_channel) { $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($hash) ); - if($x) { + if ($x) { $_SESSION['my_url'] = $x[0]['xchan_url']; $_SESSION['my_address'] = channel_reddress($r[0]); App::set_observer($x[0]); App::set_perms(get_all_perms(local_channel(), $hash)); } - if(! is_dir('store/' . $r[0]['channel_address'])) - @os_mkdir('store/' . $r[0]['channel_address'], STORAGE_DEFAULT_PERMISSIONS,true); + if (!is_dir('store/' . $r[0]['channel_address'])) + @os_mkdir('store/' . $r[0]['channel_address'], STORAGE_DEFAULT_PERMISSIONS, true); - $arr = [ 'channel_id' => $change_channel, 'chanx' => $ret ]; + $arr = ['channel_id' => $change_channel, 'chanx' => $ret]; call_hooks('change_channel', $arr); } @@ -333,18 +333,17 @@ function permissions_sql($owner_id, $remote_observer = null, $table = '') { if (($local_channel) && ($local_channel == $owner_id)) { return EMPTY_STR; } - /** - * Authenticated visitor. + * Authenticated visitor. */ else { - $observer = ((! is_null($remote_observer)) ? $remote_observer : get_observer_hash()); + $observer = ((!is_null($remote_observer)) ? $remote_observer : get_observer_hash()); if ($observer) { - $sec = get_security_ids($owner_id,$observer); + $sec = get_security_ids($owner_id, $observer); // always allow the channel owner, even if authenticated as a visitor @@ -354,14 +353,14 @@ function permissions_sql($owner_id, $remote_observer = null, $table = '') { return EMPTY_STR; } } - } + } if (is_array($sec['allow_cid']) && count($sec['allow_cid'])) { $ca = []; foreach ($sec['allow_cid'] as $c) { $ca[] = '<' . $c . '>'; } - $cs = implode('|',$ca); + $cs = implode('|', $ca); } else { $cs = '<<>>'; // should be impossible to match @@ -372,7 +371,7 @@ function permissions_sql($owner_id, $remote_observer = null, $table = '') { foreach ($sec['allow_gid'] as $g) { $ga[] = '<' . $g . '>'; } - $gs = implode('|',$ga); + $gs = implode('|', $ga); } else { $gs = '<<>>'; // should be impossible to match @@ -420,39 +419,38 @@ function item_permissions_sql($owner_id, $remote_observer = null) { * Profile owner - everything is visible */ - if(($local_channel) && ($local_channel == $owner_id)) { + if (($local_channel) && ($local_channel == $owner_id)) { $sql = ''; } - /** - * Authenticated visitor. + * Authenticated visitor. */ else { - $observer = (($remote_observer) ? $remote_observer : get_observer_hash()); + $observer = (($remote_observer) ? $remote_observer : get_observer_hash()); - if($observer) { + if ($observer) { - $scope = scopes_sql($owner_id,$observer); - $sec = get_security_ids($owner_id,$observer); + $scope = scopes_sql($owner_id, $observer); + $sec = get_security_ids($owner_id, $observer); // always allow the channel owner, even if authenticated as a visitor - if($sec['channel_id']) { - foreach($sec['channel_id'] as $ch) { - if($observer === $ch) { + if ($sec['channel_id']) { + foreach ($sec['channel_id'] as $ch) { + if ($observer === $ch) { return EMPTY_STR; } } - } + } if (is_array($sec['allow_cid']) && count($sec['allow_cid'])) { $ca = []; foreach ($sec['allow_cid'] as $c) { $ca[] = '<' . $c . '>'; } - $cs = implode('|',$ca); + $cs = implode('|', $ca); } else { $cs = '<<>>'; // should be impossible to match @@ -463,7 +461,7 @@ function item_permissions_sql($owner_id, $remote_observer = null) { foreach ($sec['allow_gid'] as $g) { $ga[] = '<' . $g . '>'; } - $gs = implode('|',$ga); + $gs = implode('|', $ga); } else { $gs = '<<>>'; // should be impossible to match @@ -493,21 +491,20 @@ function item_permissions_sql($owner_id, $remote_observer = null) { */ - -function scopes_sql($uid,$observer) { +function scopes_sql($uid, $observer) { $str = " and ( public_policy = 'authenticated' "; - if(! is_foreigner($observer)) + if (!is_foreigner($observer)) $str .= " or public_policy = 'network: red' "; - if(local_channel()) + if (local_channel()) $str .= " or public_policy = 'site: " . App::get_hostname() . "' "; $ab = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", dbesc($observer), intval($uid) ); - if(! $ab) + if (!$ab) return $str . " ) "; - if($ab[0]['abook_pending']) + if ($ab[0]['abook_pending']) $str .= " or public_policy = 'any connections' "; $str .= " or public_policy = 'contacts' ) "; return $str; @@ -526,14 +523,14 @@ function public_permissions_sql($observer_hash) { if ($observer_hash) { - $sec = get_security_ids($owner_id,$observer_hash); + $sec = get_security_ids($owner_id, $observer_hash); if (is_array($sec['allow_cid']) && count($sec['allow_cid'])) { $ca = []; foreach ($sec['allow_cid'] as $c) { $ca[] = '<' . $c . '>'; } - $cs = implode('|',$ca); + $cs = implode('|', $ca); } else { $cs = '<<>>'; // should be impossible to match @@ -544,7 +541,7 @@ function public_permissions_sql($observer_hash) { foreach ($sec['allow_gid'] as $g) { $ga[] = '<' . $g . '>'; } - $gs = implode('|',$ga); + $gs = implode('|', $ga); } else { $gs = '<<>>'; // should be impossible to match @@ -598,7 +595,7 @@ function check_form_security_token($typename = '', $formname = 'form_security_to $x = explode('.', $hash); if (time() > (IntVal($x[0]) + $max_livetime) || time() < (IntVal($x[0]) + $min_livetime)) - return false; + return false; $sec_hash = hash('whirlpool', App::$observer['xchan_guid'] . ((local_channel()) ? App::$channel['channel_prvkey'] : '') . session_id() . $x[0] . $typename); @@ -606,16 +603,19 @@ function check_form_security_token($typename = '', $formname = 'form_security_to } function check_form_security_std_err_msg() { + /** @noinspection PhpToStringImplementationInspection */ return t('The form security token was not correct. This probably happened because the form has been opened for too long (>3 hours) before submitting it.') . EOL; } + function check_form_security_token_redirectOnErr($err_redirect, $typename = '', $formname = 'form_security_token') { if (!check_form_security_token($typename, $formname)) { logger('check_form_security_token failed: user ' . App::$observer['xchan_name'] . ' - form element ' . $typename); logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); - notice( check_form_security_std_err_msg() ); - goaway(z_root() . $err_redirect ); + notice(check_form_security_std_err_msg()); + goaway(z_root() . $err_redirect); } } + function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') { if (!check_form_security_token($typename, $formname)) { logger('check_form_security_token failed: user ' . App::$observer['xchan_name'] . ' - form element ' . $typename); @@ -636,7 +636,7 @@ function init_groups_visitor($contact_id) { dbesc($contact_id) ); - if (! $x) { + if (!$x) { return $groups; } @@ -648,8 +648,8 @@ function init_groups_visitor($contact_id) { dbesc($x[0]['xchan_pubkey']) ); - if($xchans) { - $hashes = ids_to_querystr($xchans,'xchan_hash',true); + if ($xchans) { + $hashes = ids_to_querystr($xchans, 'xchan_hash', true); } // private profiles are treated as a virtual group @@ -672,21 +672,19 @@ function init_groups_visitor($contact_id) { } - - function get_security_ids($channel_id, $ob_hash) { - $ret = [ - 'channel_id' => [], - 'allow_cid' => [], - 'allow_gid' => [] + $ret = [ + 'channel_id' => [], + 'allow_cid' => [], + 'allow_gid' => [] ]; - if($channel_id) { + if ($channel_id) { $ch = q("select channel_hash, channel_portable_id from channel where channel_id = %d", - intval($channel_id) + intval($channel_id) ); - if($ch) { + if ($ch) { $ret['channel_id'][] = $ch[0]['channel_hash']; $ret['channel_id'][] = $ch[0]['channel_portable_id']; } @@ -709,13 +707,13 @@ function get_security_ids($channel_id, $ob_hash) { ); if ($xchans) { - $ret['allow_cid'] = ids_to_array($xchans,'xchan_hash'); - $hashes = ids_to_querystr($xchans,'xchan_hash',true); + $ret['allow_cid'] = ids_to_array($xchans, 'xchan_hash'); + $hashes = ids_to_querystr($xchans, 'xchan_hash', true); // private profiles are treated as a virtual group $r = q("SELECT abook_profile from abook where abook_xchan in ( " . protect_sprintf($hashes) . " ) and abook_profile != '' "); - if($r) { + if ($r) { foreach ($r as $rv) { $groups[] = 'vp.' . $rv['abook_profile']; } @@ -724,7 +722,7 @@ function get_security_ids($channel_id, $ob_hash) { // physical groups this identity is a member of $r = q("SELECT hash FROM pgrp left join pgrp_member on pgrp.id = pgrp_member.gid WHERE xchan in ( " . protect_sprintf($hashes) . " ) "); - if($r) { + if ($r) { foreach ($r as $rv) { $groups[] = $rv['hash']; } @@ -746,39 +744,39 @@ function get_security_ids($channel_id, $ob_hash) { // will likely be too expensive. // Returns a string list of comma separated channel_ids suitable for direct inclusion in a SQL query -function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0 ) { - $perms = is_null($perms) ? (PERMS_SITE|PERMS_NETWORK|PERMS_PUBLIC) : $perms; +function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0) { + $perms = is_null($perms) ? (PERMS_SITE | PERMS_NETWORK | PERMS_PUBLIC) : $perms; $ret = array(); $limit_sql = (($limit) ? " LIMIT " . intval($limit) . " " : ''); $random_sql = (($rand) ? " ORDER BY " . db_getfunc('RAND') . " " : ''); - if(local_channel()) + if (local_channel()) $ret[] = local_channel(); $x = q("select uid, v from pconfig where cat = 'perm_limits' and k = 'view_stream' "); - if($x) { + if ($x) { $y = []; - foreach($x as $xv) { - if(intval($xv['v']) & $perms) { + foreach ($x as $xv) { + if (intval($xv['v']) & $perms) { $y[] = $xv; } } - if($y) { - $ids = ids_to_querystr($y,'uid'); + if ($y) { + $ids = ids_to_querystr($y, 'uid'); $r = q("select channel_id from channel where channel_id in ( $ids ) and ( channel_pageflags & %d ) = 0 and channel_system = 0 and channel_removed = 0 $random_sql $limit_sql ", - intval(PAGE_ADULT|PAGE_CENSORED) + intval(PAGE_ADULT | PAGE_CENSORED) ); - if($r) { - foreach($r as $rr) - if(! in_array($rr['channel_id'], $ret)) + if ($r) { + foreach ($r as $rr) + if (!in_array($rr['channel_id'], $ret)) $ret[] = $rr['channel_id']; } } } $str = ''; - if($ret) { - foreach($ret as $rr) { - if($str) + if ($ret) { + foreach ($ret as $rr) { + if ($str) $str .= ','; $str .= intval($rr); } @@ -791,39 +789,39 @@ function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0 ) { return $str; } -function stream_perms_xchans($perms = NULL ) { - $perms = is_null($perms) ? (PERMS_SITE|PERMS_NETWORK|PERMS_PUBLIC) : $perms; +function stream_perms_xchans($perms = NULL) { + $perms = is_null($perms) ? (PERMS_SITE | PERMS_NETWORK | PERMS_PUBLIC) : $perms; $ret = array(); - if(local_channel()) + if (local_channel()) $ret[] = get_observer_hash(); $x = q("select uid, v from pconfig where cat = 'perm_limits' and k = 'view_stream' "); - if($x) { + if ($x) { $y = []; - foreach($x as $xv) { - if(intval($xv['v']) & $perms) { + foreach ($x as $xv) { + if (intval($xv['v']) & $perms) { $y[] = $xv; } } - if($y) { - $ids = ids_to_querystr($y,'uid'); + if ($y) { + $ids = ids_to_querystr($y, 'uid'); $r = q("select channel_hash from channel where channel_id in ( $ids ) and ( channel_pageflags & %d ) = 0 and channel_system = 0 and channel_removed = 0 ", - intval(PAGE_ADULT|PAGE_CENSORED) + intval(PAGE_ADULT | PAGE_CENSORED) ); - if($r) { - foreach($r as $rr) - if(! in_array($rr['channel_hash'], $ret)) + if ($r) { + foreach ($r as $rr) + if (!in_array($rr['channel_hash'], $ret)) $ret[] = $rr['channel_hash']; } } } $str = ''; - if($ret) { - foreach($ret as $rr) { - if($str) + if ($ret) { + foreach ($ret as $rr) { + if ($str) $str .= ','; $str .= "'" . dbesc($rr) . "'"; } -- cgit v1.2.3 From 3bcb3221568d80d3ae8dec47d2416b7c1b091304 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Jan 2021 15:06:07 +0000 Subject: also check for zot6 --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 317a84730..2661f76a7 100755 --- a/include/items.php +++ b/include/items.php @@ -130,7 +130,7 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { case 'sit': case 'any': case 'con': - if($rr['xchan_network'] != 'zot') + if(in_array($rr['xchan_network'], ['zot6', 'zot'])) break; case 'pub': case '': -- cgit v1.2.3 From 9f8a512eb522b0c8ec2a2042945a626e74a6531f Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Jan 2021 15:07:54 +0000 Subject: only var can be passed by reference --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 2661f76a7..d89290e2f 100755 --- a/include/items.php +++ b/include/items.php @@ -4724,7 +4724,7 @@ function webpage_to_namespace($webpage) { function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid) { - if(! $post_id) + if(! intval($post_id)) return; $page_type = webpage_to_namespace($webpage); @@ -4746,7 +4746,7 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo // as the entire mid. If it were the post_id the link would be less portable. IConfig::Set( - intval($post_id), + $post_id, 'system', $page_type, ($pagetitle) ? $pagetitle : substr($mid,0,16), -- cgit v1.2.3 From 0d544e2294149efe5f442fa1191c02f241b85b6a Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 16 Jan 2021 09:17:45 +0000 Subject: wrong logic --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index d89290e2f..610727f30 100755 --- a/include/items.php +++ b/include/items.php @@ -130,7 +130,7 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { case 'sit': case 'any': case 'con': - if(in_array($rr['xchan_network'], ['zot6', 'zot'])) + if(!in_array($rr['xchan_network'], ['zot6', 'zot'])) break; case 'pub': case '': -- cgit v1.2.3 From a925b08e80bc740ea9d23b1dfb7adbf94491ed09 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 17 Jan 2021 13:52:55 +0000 Subject: get_bookmark_link() check against zot6 --- include/bookmarks.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/bookmarks.php b/include/bookmarks.php index 21456c871..145119347 100644 --- a/include/bookmarks.php +++ b/include/bookmarks.php @@ -18,7 +18,7 @@ function bookmark_add($channel,$sender,$taxonomy,$private,$opts = null) { $channel_id = $channel['channel_id']; if($private) - $iarr['contact_allow'] = array($channel['channel_hash']); + $iarr['contact_allow'] = array($channel['channel_hash']); $iarr['mitem_link'] = $taxonomy['url']; $iarr['mitem_desc'] = $taxonomy['term']; $iarr['mitem_flags'] = (($ischat) ? MENU_ITEM_CHATROOM : 0); @@ -41,34 +41,34 @@ function bookmark_add($channel,$sender,$taxonomy,$private,$opts = null) { if(! $menu_id) { $x = menu_list($arr['menu_channel_id'],$arr['menu_name'],$arr['menu_flags']); - if($x) + if($x) $menu_id = $x[0]['menu_id']; - else + else $menu_id = menu_create($arr); } if(! $menu_id) { logger('bookmark_add: unable to create menu ' . $arr['menu_name']); - return; + return; } logger('add_bookmark: menu_id ' . $menu_id); $r = q("select * from menu_item where mitem_link = '%s' and mitem_menu_id = %d and mitem_channel_id = %d limit 1", dbesc($iarr['mitem_link']), intval($menu_id), - intval($channel_id) + intval($channel_id) ); if($r) logger('add_bookmark: duplicate menu entry', LOGGER_DEBUG); if(! $r) { $r = menu_add_item($menu_id,$channel_id,$iarr); - menu_sync_packet($channel_id,get_observer_hash(),$menu_id); + menu_sync_packet($channel_id,get_observer_hash(),$menu_id); } return $r; } function get_bookmark_link($observer) { - if((! $observer) || ($observer['xchan_network'] !== 'zot')) + if((! $observer) || !in_array($observer['xchan_network'], ['zot6', 'zot'])) return ''; $h = @parse_url($observer['xchan_url']); -- cgit v1.2.3 From 8d37a4239ae867b3a6b586558c753f8ca147e4e2 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 17 Jan 2021 13:56:23 +0000 Subject: mark_orphan_hubsxchans() check against zot6 --- include/connections.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/connections.php b/include/connections.php index 99a4cc71e..87db7faa9 100644 --- a/include/connections.php +++ b/include/connections.php @@ -211,8 +211,8 @@ function mark_orphan_hubsxchans() { if($dirmode == DIRECTORY_MODE_NORMAL) return; - $r = q("update hubloc set hubloc_error = 1 where hubloc_error = 0 - and hubloc_network = 'zot' and hubloc_connected < %s - interval %s", + $r = q("UPDATE hubloc SET hubloc_error = 1 WHERE hubloc_error = 0 + AND hubloc_network IN ('zot6', 'zot') AND hubloc_connected < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('36 day') ); -- cgit v1.2.3 From 828636847ecdecb1513f19f28b5bb629b04ecec4 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 17 Jan 2021 14:13:31 +0000 Subject: get_item_elements() check against zot6 --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 610727f30..9633ee9bd 100755 --- a/include/items.php +++ b/include/items.php @@ -790,8 +790,8 @@ function get_item_elements($x,$allow_code = false) { dbesc($arr['author_xchan']) ); if($r) { - if($r[0]['xchan_pubkey'] && $r[0]['xchan_network'] === 'zot') { - if(rsa_verify($x['body'],base64url_decode($arr['sig']),$r[0]['xchan_pubkey'])) { + if($r[0]['xchan_pubkey'] && $r[0]['xchan_network'] === 'zot6') { + if(Libzot::verify($x['body'], $arr['sig'], $r[0]['xchan_pubkey'])) { $arr['item_verified'] = 1; } else { -- cgit v1.2.3 From 37f1b774b7a71d59e41cfcc5215575a5309eac94 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 17 Jan 2021 15:19:00 +0000 Subject: missing import --- include/items.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 9633ee9bd..571359167 100755 --- a/include/items.php +++ b/include/items.php @@ -11,6 +11,7 @@ use Zotlabs\Lib\ThreadListener; use Zotlabs\Lib\IConfig; use Zotlabs\Lib\Activity; use Zotlabs\Lib\Libsync; +use Zotlabs\Lib\Libzot; use Zotlabs\Access\PermissionLimits; use Zotlabs\Access\PermissionRoles; use Zotlabs\Access\AccessList; -- cgit v1.2.3 From cd59c67c678f2ac1cc8457c05e5420d38df152cc Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 18 Jan 2021 08:43:08 +0000 Subject: fix undefined variable --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 571359167..69c056f7e 100755 --- a/include/items.php +++ b/include/items.php @@ -4478,7 +4478,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE $item_uids and item_thread_top = 1 $sql_options $item_normal ) "; if($arr['since_id']) - $sql_extra .= " and item.id > " . $since_id . " "; + $sql_extra .= " and item.id > " . intval($arr['since_id']) . " "; if($arr['cat']) $sql_extra .= protect_sprintf(term_query('item', $arr['cat'], TERM_CATEGORY)); -- cgit v1.2.3 From 917c6caa14e8b72a3e981b3940a8f56e9814647d Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 18 Jan 2021 08:46:37 +0000 Subject: force arg is not used anymore in drop_item_lolevel() --- include/items.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 69c056f7e..bfca354d1 100755 --- a/include/items.php +++ b/include/items.php @@ -3970,10 +3970,10 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { ); if($items) { foreach($items as $i) - delete_item_lowlevel($i,$stage,$force); + delete_item_lowlevel($i, $stage); } else - delete_item_lowlevel($item,$stage,$force); + delete_item_lowlevel($item, $stage); if(! $interactive) return 1; @@ -4007,7 +4007,6 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { * * @param array $item * @param int $stage - * @param boolean $force * @return boolean */ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL) { -- cgit v1.2.3 From faaa2d447292e554f0498327a81016d215184abd Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 18 Jan 2021 11:21:37 +0000 Subject: $match should be array --- include/bbcode.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index d79429719..e1a5c7e47 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -966,7 +966,7 @@ function bbtopoll($s) { $pl['poll_id'] = $match[1]; $pl['poll_question'] = $match[2]; - $match = ''; + $match = []; if(preg_match_all("/\[poll\-answer=(.*?)\](.*?)\[\/poll\-answer\]/is",$s,$match,PREG_SET_ORDER)) { $pl['answer'] = []; foreach($match as $m) { @@ -1349,7 +1349,7 @@ function bbcode($Text, $options = []) { // Check for table of content with params while(strpos($Text,'[toc') !== false) { $toc_id = 'toc-' . random_string(10); - $Text = preg_replace("/\[toc([^\]]+?)\]/ism", '
    ', $Text, 1); + $Text = preg_replace("/\[toc([^\]]+?)\]/ism", '
      ', $Text, 1); } // Check for centered text if (strpos($Text,'[/center]') !== false) { -- cgit v1.2.3