diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Contact.php | 21 | ||||
-rw-r--r-- | include/api.php | 177 | ||||
-rw-r--r-- | include/bbcode.php | 15 | ||||
-rw-r--r-- | include/comanche.php | 5 | ||||
-rw-r--r-- | include/contact_selectors.php | 2 | ||||
-rw-r--r-- | include/conversation.php | 15 | ||||
-rwxr-xr-x | include/diaspora.php | 37 | ||||
-rw-r--r-- | include/dir_fns.php | 61 | ||||
-rw-r--r-- | include/event.php | 150 | ||||
-rw-r--r-- | include/follow.php | 3 | ||||
-rw-r--r-- | include/identity.php | 85 | ||||
-rwxr-xr-x | include/items.php | 55 | ||||
-rw-r--r-- | include/network.php | 4 | ||||
-rw-r--r-- | include/photo/photo_driver.php | 8 | ||||
-rw-r--r-- | include/security.php | 10 | ||||
-rw-r--r-- | include/taxonomy.php | 4 | ||||
-rw-r--r-- | include/text.php | 6 | ||||
-rw-r--r-- | include/widgets.php | 4 | ||||
-rw-r--r-- | include/zot.php | 41 |
19 files changed, 513 insertions, 190 deletions
diff --git a/include/Contact.php b/include/Contact.php index 9490fd2da..a27a8eca9 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -149,9 +149,6 @@ function abook_toggle_flag($abook,$flag) { ); } - $a = get_app(); - if($a->data['abook']) - $a->data['abook']['abook_flags'] = $a->data['abook']['abook_flags'] ^ $flag; return $r; } @@ -311,6 +308,24 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { intval(PAGE_REMOVED), intval($channel_id) ); + // if this was the default channel, set another one as default + if($a->account['account_default_channel'] == $channel_id) { + $r = q("select channel_id from channel where channel_account_id = %d and not ( channel_pageflags & %d)>0 limit 1", + intval($a->account['account_id']), + intval(PAGE_REMOVED)); + if ($r) { + $rr = q("update account set account_default_channel = %d where account_id = %d", + intval($r[0]['channel_id']), + intval($a->account['account_id'])); + logger("Default channel deleted, changing default to channel_id " . $r[0]['channel_id']); + } + else { + $rr = q("update account set account_default_channel = 0 where account_id = %d", + intval($r[0]['channel_id']), + intval($a->account['account_id'])); + } + } + $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_hash = '%s' and hubloc_url = '%s' ", intval(HUBLOC_FLAGS_DELETED), diff --git a/include/api.php b/include/api.php index 6eede68f4..027779558 100644 --- a/include/api.php +++ b/include/api.php @@ -631,6 +631,47 @@ require_once('include/items.php'); } api_register_func('api/red/photos','api_photos', true); + function api_photo_detail(&$a,$type) { + if (api_user()===false) return false; + if(! $_REQUEST['photo_id']) return false; + $scale = ((array_key_exists('scale',$_REQUEST)) ? intval($_REQUEST['scale']) : 0); + $r = q("select * from photo where uid = %d and resource_id = '%s' and scale = %d limit 1", + intval(local_channel()), + dbesc($_REQUEST['photo_id']), + intval($scale) + ); + if($r) { + $data = dbunescbin($r[0]['data']); + if(array_key_exists('os_storage',$r[0]) && intval($r[0]['os_storage'])) + $data = file_get_contents($data); + $r[0]['data'] = base64_encode($data); + $ret = array('photo' => $r[0]); + $i = q("select id from item where uid = %d and resource_type = 'photo' and resource_id = '%s' limit 1", + intval(local_channel()), + dbesc($_REQUEST['photo_id']) + ); + if($i) { + $ii = q("select * from item where parent = %d order by id", + intval($i[0]['id']) + ); + if($ii) { + xchan_query($ii,true,0); + $ii = fetch_post_tags($ii,true); + if($ii) { + $ret['item'] = array(); + foreach($ii as $iii) + $ret['item'][] = encode_item($iii,true); + } + } + } + + json_return_and_die($ret); + } + killme(); + } + + api_register_func('api/red/photo', 'api_photo_detail', true); + function api_group_members(&$a,$type) { if(api_user() === false) @@ -686,7 +727,7 @@ require_once('include/items.php'); api_register_func('api/red/xchan','api_red_xchan',true); - function api_statuses_mediap(&$a, $type) { + function api_statuses_mediap(&$a, $type) { if (api_user() === false) { logger('api_statuses_update: no user'); return false; @@ -696,7 +737,7 @@ require_once('include/items.php'); $_REQUEST['type'] = 'wall'; $_REQUEST['profile_uid'] = api_user(); $_REQUEST['api_source'] = true; - + $txt = requestdata('status'); require_once('library/HTMLPurifier.auto.php'); @@ -711,13 +752,13 @@ require_once('include/items.php'); } $txt = html2bbcode($txt); - $a->argv[1] = $user_info['screen_name']; + $a->argv[1] = $user_info['screen_name']; $_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo $_FILES['userfile'] = $_FILES['media']; require_once('mod/wall_attach.php'); $posted = wall_attach_post($a); - + //now that we have the img url in bbcode we can add it to the status and insert the wall item. $_REQUEST['body']=$txt."\n\n".$posted; require_once('mod/item.php'); @@ -1164,14 +1205,14 @@ require_once('include/items.php'); $sql_extra = 'AND `item`.`id` <= '.intval($max_id); require_once('include/security.php'); - $r = q("select * from item where item_restrict = 0 + $r = q("select * from item where item_restrict = 0 and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' - and item_private = 0 + and item_private = 0 and uid = " . $sys['channel_id'] . " $sql_extra AND id > %d group by mid - order by received desc LIMIT %d OFFSET %d ", + order by received desc LIMIT %d OFFSET %d ", intval($since_id), intval($count), intval($start) @@ -1382,17 +1423,17 @@ require_once('include/items.php'); $diasp_url = str_replace('/channel/','/u/',$myurl); if (get_config('system','use_fulltext_engine')) - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", - dbesc(protect_sprintf($myurl)), - dbesc(protect_sprintf($myurl)), - dbesc(protect_sprintf($diasp_url)) - ); - else - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", - dbesc(protect_sprintf('%' . $myurl)), - dbesc(protect_sprintf('%' . $myurl . ']%')), - dbesc(protect_sprintf('%' . $diasp_url . ']%')) - ); + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($diasp_url)) + ); + else + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", + dbesc(protect_sprintf('%' . $myurl)), + dbesc(protect_sprintf('%' . $myurl . ']%')), + dbesc(protect_sprintf('%' . $diasp_url . ']%')) + ); if ($max_id > 0) $sql_extra .= ' AND `item`.`id` <= '.intval($max_id); @@ -1486,10 +1527,10 @@ require_once('include/items.php'); // ); $arr = array( - 'uid' => api_user(), - 'since_id' => $since_id, - 'start' => $start, - 'records' => $count); + 'uid' => api_user(), + 'since_id' => $since_id, + 'start' => $start, + 'records' => $count); if ($user_info['self']==1) $arr['wall'] = 1; @@ -1498,7 +1539,7 @@ require_once('include/items.php'); $r = items_fetch($arr,get_app()->get_channel(),get_observer_hash()); - + $ret = api_format_items($r,$user_info); @@ -1516,80 +1557,80 @@ require_once('include/items.php'); - /** - * Star/unstar an item - * param: id : id of the item - * - * api v1 : https://web.archive.org/web/20131019055350/https://dev.twitter.com/docs/api/1/post/favorites/create/%3Aid - */ - function api_favorites_create_destroy(&$a, $type){ + /** + * Star/unstar an item + * param: id : id of the item + * + * api v1 : https://web.archive.org/web/20131019055350/https://dev.twitter.com/docs/api/1/post/favorites/create/%3Aid + */ + function api_favorites_create_destroy(&$a, $type){ logger('favorites_create_destroy'); - if (api_user()===false) + if (api_user()===false) return false; - $action = str_replace(".".$type,"",argv(2)); - if (argc() > 3) { - $itemid = intval(argv(3)); - } else { - $itemid = intval($_REQUEST['id']); - } + $action = str_replace(".".$type,"",argv(2)); + if (argc() > 3) { + $itemid = intval(argv(3)); + } else { + $itemid = intval($_REQUEST['id']); + } - $item = q("SELECT * FROM item WHERE id = %d AND uid = %d", - intval($itemid), + $item = q("SELECT * FROM item WHERE id = %d AND uid = %d", + intval($itemid), intval(api_user()) ); - if (! $item) + if (! $item) return false; - switch($action){ - case "create": + switch($action){ + case "create": - $flags = $item[0]['item_flags'] | ITEM_STARRED; + $flags = $item[0]['item_flags'] | ITEM_STARRED; - break; - case "destroy": + break; + case "destroy": - $flags = $item[0]['item_flags'] | (~ ITEM_STARRED); - break; - default: - return false; - } + $flags = $item[0]['item_flags'] | (~ ITEM_STARRED); + break; + default: + return false; + } - $r = q("UPDATE item SET item_flags = %d where id = %d and uid = %d", - intval($flags), + $r = q("UPDATE item SET item_flags = %d where id = %d and uid = %d", + intval($flags), intval($itemid), intval(api_user()) ); if(! $r) return false; - $item = q("SELECT * FROM item WHERE id = %d AND uid = %d", - intval($itemid), + $item = q("SELECT * FROM item WHERE id = %d AND uid = %d", + intval($itemid), intval(api_user()) ); xchan_query($item,true); - $user_info = api_get_user($a); - $rets = api_format_items($item,$user_info); - $ret = $rets[0]; + $user_info = api_get_user($a); + $rets = api_format_items($item,$user_info); + $ret = $rets[0]; - $data = array('$status' => $ret); - switch($type){ - case "atom": - case "rss": - $data = api_rss_extra($a, $data, $user_info); - } + $data = array('$status' => $ret); + switch($type){ + case "atom": + case "rss": + $data = api_rss_extra($a, $data, $user_info); + } - return api_apply_template("status", $type, $data); - } + return api_apply_template("status", $type, $data); + } - api_register_func('api/favorites/create', 'api_favorites_create_destroy', true); - api_register_func('api/favorites/destroy', 'api_favorites_create_destroy', true); + api_register_func('api/favorites/create', 'api_favorites_create_destroy', true); + api_register_func('api/favorites/destroy', 'api_favorites_create_destroy', true); @@ -1600,7 +1641,7 @@ require_once('include/items.php'); $user_info = api_get_user($a); // params - $count = (x($_REQUEST,'count')?$_REQUEST['count']:20); + $count = (x($_REQUEST,'count')?$_REQUEST['count']:20); $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0); if($page < 0) $page = 0; diff --git a/include/bbcode.php b/include/bbcode.php index e248c3771..6fc481fff 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -174,10 +174,14 @@ function bb_parse_app($match) { function bb_parse_element($match) { $j = json_decode(base64url_decode($match[1]),true); - if ($j) { + if ($j && local_channel()) { $text = sprintf( t('Install %s element: '), translate_design_element($j['type'])) . $j['pagetitle']; $o = EOL . '<a href="#" onclick="importElement(\'' . $match[1] . '\'); return false;" >' . $text . '</a>' . EOL; } + else { + $text = sprintf( t('This post contains an installable %s element, however you lack permissions to install it on this site.' ), translate_design_element($j['type'])) . $j['pagetitle']; + $o = EOL . $text . EOL; + } return $o; } @@ -922,14 +926,21 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) { // start which is always required). Allow desc with a missing summary for compatibility. if ((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) { + $sub = format_event_html($ev); + $sub = str_replace('$',"\0",$sub); + + $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",$sub,$Text); + $Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text); $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",'',$Text); - $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",$sub,$Text); $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism",'',$Text); $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism",'',$Text); $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text); + + $Text = str_replace("\0",'$',$Text); + } // Unhide all [noparse] contained bbtags unspacefying them diff --git a/include/comanche.php b/include/comanche.php index cb46985eb..49b910bdb 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -284,6 +284,11 @@ function comanche_widget($name, $text) { if(file_exists('widget/' . trim($name) . '.php')) require_once('widget/' . trim($name) . '.php'); + else { + $theme_widget = 'widget_' . trim($name) . '.php'; + if(theme_include($theme_widget)) + require_once(theme_include($theme_widget)); + } $func = 'widget_' . trim($name); if (function_exists($func)) diff --git a/include/contact_selectors.php b/include/contact_selectors.php index 726efce9d..8671f1bd1 100644 --- a/include/contact_selectors.php +++ b/include/contact_selectors.php @@ -5,7 +5,7 @@ function contact_profile_assign($current) { $o = ''; - $o .= "<select id=\"contact-profile-selector\" name=\"profile_assign\" />\r\n"; + $o .= "<select id=\"contact-profile-selector\" name=\"profile_assign\" class=\"form-control\"/>\r\n"; $r = q("SELECT profile_guid, profile_name FROM `profile` WHERE `uid` = %d", intval($_SESSION['uid'])); diff --git a/include/conversation.php b/include/conversation.php index fb012667e..8bbb87e2c 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -404,7 +404,9 @@ function count_descendants($item) { * @brief Check if the activity of the item is visible. * * likes (etc.) can apply to other things besides posts. Check if they are post - * children, in which case we handle them specially. + * 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. * * @param array $item * @return boolean @@ -412,12 +414,21 @@ function count_descendants($item) { function visible_activity($item) { $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE); + $post_types = array(ACTIVITY_OBJ_NOTE,ACTIVITY_OBJ_COMMENT,basename(ACTIVITY_OBJ_NOTE),basename(ACTIVITY_OBJ_COMMENT)); + foreach ($hidden_activities as $act) { if ((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) { return false; } } + // 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. + + if(($item['verb'] === ACTIVITY_UPDATE) && (in_array($item['obj_type'],$post_types))) + return false; + return true; } @@ -597,7 +608,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ if($arr_blocked) { $blocked = false; foreach($arr_blocked as $b) { - if(($b) && ($item['author_xchan'] == $b)) { + if(($b) && (($item['author_xchan'] == $b) || ($item['owner_xchan'] == $b))) { $blocked = true; break; } diff --git a/include/diaspora.php b/include/diaspora.php index cf8d89023..61556fd9d 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1009,6 +1009,10 @@ function diaspora_post($importer,$xml,$msg) { return 202; } + if(! post_is_importable($datarray,$contact)) { + logger('diaspora_post: filtering this author.'); + return 202; + } $result = item_store($datarray); return; @@ -2738,21 +2742,26 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { // versions of Diaspora (i.e. Diaspora-pistos) support // likes on comments + + // That version is now dead so detect a "sublike" and + // just send it as an activity. + + $sublike = false; + + if($item['verb'] === ACTIVITY_LIKE && $item['thr_parent']) { - $p = q("select * from item where mid = '%s' limit 1", - dbesc($item['thr_parent']) - ); - } - else { - // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always - // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent. - // The only item with `parent` and `id` as the parent id is the parent item. - $p = q("select * from item where parent = %d and id = %d limit 1", - intval($item['parent']), - intval($item['parent']) - ); + $sublike = true; } + + // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always + // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent. + // The only item with `parent` and `id` as the parent id is the parent item. + $p = q("select * from item where parent = %d and id = %d limit 1", + intval($item['parent']), + intval($item['parent']) + ); + if($p) $parent = $p[0]; else { @@ -2767,12 +2776,12 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { if( $item['item_restrict'] & ITEM_DELETED) { $relay_retract = true; - $target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment'); + $target_type = ( ($item['verb'] === ACTIVITY_LIKE && (! $sublike)) ? 'Like' : 'Comment'); $sql_sign_id = 'retract_iid'; $tpl = get_markup_template('diaspora_relayable_retraction.tpl'); } - elseif($item['verb'] === ACTIVITY_LIKE) { + elseif(($item['verb'] === ACTIVITY_LIKE) && (! $sublike)) { $like = true; $target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment'); diff --git a/include/dir_fns.php b/include/dir_fns.php index 77c78558c..83073154a 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -72,33 +72,20 @@ function check_upstream_directory() { set_config('system', 'directory_server', ''); } -function get_globaldir_setting($observer) { - - if($observer) - $globaldir = get_xconfig($observer,'directory','globaldir'); - else - $globaldir = ((array_key_exists('globaldir',$_SESSION)) ? intval($_SESSION['globaldir']) : false); - - if($globaldir === false) - $globaldir = get_config('directory','globaldir'); - - return $globaldir; -} - -function get_safemode_setting($observer) { +function get_directory_setting($observer, $setting) { if ($observer) - $safe_mode = get_xconfig($observer,'directory','safe_mode'); + $ret = get_xconfig($observer, 'directory', $setting); else - $safe_mode = ((array_key_exists('safemode',$_SESSION)) ? intval($_SESSION['safemode']) : false); + $ret = ((array_key_exists($setting,$_SESSION)) ? intval($_SESSION[$setting]) : false); - if($safe_mode === false) - $safe_mode = get_config('directory','safe_mode'); + if($ret === false) + $ret = get_config('directory', $setting); - if($safe_mode === false) - $safe_mode = 1; + if($setting == 'safemode' && $ret === false) + $ret = 1; - return $safe_mode; + return $ret; } /** @@ -110,49 +97,37 @@ function dir_sort_links() { $observer = get_observer_hash(); - $safe_mode = get_safemode_setting($observer); - $globaldir = get_globaldir_setting($observer); + $safe_mode = get_directory_setting($observer, 'safemode'); + $globaldir = get_directory_setting($observer, 'globaldir'); + $pubforums = get_directory_setting($observer, 'pubforums'); // Build urls without order and pubforums so it's easy to tack on the changed value // Probably there's an easier way to do this - $directory_sort_order = get_config('system','directory_sort_order'); if(! $directory_sort_order) $directory_sort_order = 'date'; - $current_order = (($_REQUEST['order']) ? $_REQUEST['order'] : $directory_sort_order); - $url = 'directory?f='; + $suggest = (($_REQUEST['suggest']) ? '&suggest=' . $_REQUEST['suggest'] : ''); - $tmp = array_merge($_GET,$_POST); - unset($tmp['order']); - unset($tmp['q']); - unset($tmp['f']); - $sorturl = $url . http_build_query($tmp); + $url = 'directory?f='; $tmp = array_merge($_GET,$_POST); + unset($tmp['suggest']); unset($tmp['pubforums']); unset($tmp['global']); unset($tmp['safe']); unset($tmp['q']); unset($tmp['f']); - $forumsurl = $url . http_build_query($tmp); + $forumsurl = $url . http_build_query($tmp) . $suggest; $o = replace_macros(get_markup_template('dir_sort_links.tpl'), array( '$header' => t('Directory Options'), - '$normal' => t('Alphabetic'), - '$reverse' => t('Reverse Alphabetic'), - '$date' => t('Newest to Oldest'), - '$reversedate' => t('Oldest to Newest'), - '$sort' => t('Sort'), - '$selected_sort' => $current_order, - '$sorturl' => $sorturl, '$forumsurl' => $forumsurl, - '$safemode' => array('safemode', t('Safe Mode'),$safe_mode,'','',' onchange=\'window.location.href="' . $forumsurl . '&safe="+(this.checked ? 1 : 0)\''), - - '$pubforums' => array('pubforums', t('Public Forums Only'),(x($_REQUEST,'pubforums') ? $_REQUEST['pubforums'] : ''),'','',' onchange=\'window.location.href="' . $forumsurl . '&pubforums="+(this.checked ? 1 : 0)\''), - '$globaldir' => array('globaldir', t('This Website Only'), 1-intval($globaldir),'','',' onchange=\'window.location.href="' . $forumsurl . '&global="+(this.checked ? 0 : 1)\''), + '$safemode' => array('safemode', t('Safe Mode'),$safe_mode,'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&safe="+(this.checked ? 1 : 0)\''), + '$pubforums' => array('pubforums', t('Public Forums Only'),$pubforums,'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&pubforums="+(this.checked ? 1 : 0)\''), + '$globaldir' => array('globaldir', t('This Website Only'), 1-intval($globaldir),'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&global="+(this.checked ? 0 : 1)\''), )); return $o; diff --git a/include/event.php b/include/event.php index 0b1e56ae2..134c23aa2 100644 --- a/include/event.php +++ b/include/event.php @@ -1,4 +1,6 @@ <?php +use Sabre\VObject; + /** * @file include/event.php */ @@ -16,6 +18,7 @@ function format_event_html($ev) { if(! ((is_array($ev)) && count($ev))) return ''; + $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8:01 AM $o = '<div class="vevent">' . "\r\n"; @@ -90,6 +93,7 @@ function format_event_ical($ev) { $o .= "\nLOCATION:" . format_ical_text($ev['location']); if($ev['description']) $o .= "\nDESCRIPTION:" . format_ical_text($ev['description']); + $o .= "\nUID:" . $ev['event_hash'] ; $o .= "\nEND:VEVENT\n"; return $o; @@ -100,7 +104,7 @@ function format_ical_text($s) { require_once('include/bbcode.php'); require_once('include/html2plain.php'); - return(wordwrap(html2plain(bbcode($s)),72,"\n ",true)); + return(wordwrap(str_replace(',','\\,',html2plain(bbcode($s))),72,"\n ",true)); } @@ -162,7 +166,18 @@ function bbtoevent($s) { $match = ''; if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match)) $ev['adjust'] = $match[1]; - $ev['nofinish'] = (((x($ev, 'start') && $ev['start']) && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0); + if(array_key_exists('start',$ev)) { + if(array_key_exists('finish',$ev)) { + if($ev['finish'] === $ev['start']) + $ev['nofinish'] = 1; + elseif($ev['finish']) + $ev['nofinish'] = 0; + else + $ev['nofinish'] = 1; + } + else + $ev['nofinish'] = 1; + } return $ev; } @@ -208,6 +223,7 @@ function event_store_event($arr) { $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : ''); + // Existing event being modified if($arr['id'] || $arr['event_hash']) { @@ -275,7 +291,11 @@ function event_store_event($arr) { // New event. Store it. - $hash = random_string(); + + if(array_key_exists('external_id',$arr)) + $hash = $arr['external_id']; + else + $hash = random_string() . '@' . get_app()->get_hostname(); $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type, adjust,nofinish,allow_cid,allow_gid,deny_cid,deny_gid) @@ -364,6 +384,130 @@ function event_addtocal($item_id, $uid) { } +function parse_ical_file($f,$uid) { +require_once('vendor/autoload.php'); + + $s = @file_get_contents($f); + + // Change the current timezone to something besides UTC. + // Doesn't matter what it is, as long as it isn't UTC. + // Save the current timezone so we can reset it when we're done processing. + + $saved_timezone = date_default_timezone_get(); + date_default_timezone_set('Australia/Sydney'); + + $ical = VObject\Reader::read($s); + + if($ical) { + foreach($ical->VEVENT as $event) { + event_import_ical($event,$uid); + + } + } + + date_default_timezone_set($saved_timezone); + + if($ical) + return true; + return false; +} + + + +function event_import_ical($ical, $uid) { + + $c = q("select * from channel where channel_id = %d limit 1", + intval($uid) + ); + + if(! $c) + return false; + + $channel = $c[0]; + $ev = array(); + + + if(! isset($ical->DTSTART)) { + logger('no event start'); + return false; + } + + $dtstart = $ical->DTSTART->getDateTime(); + +// logger('dtstart: ' . var_export($dtstart,true)); + + if(($dtstart->timezone_type == 2) || (($dtstart->timezone_type == 3) && ($dtstart->timezone === 'UTC'))) { + $ev['adjust'] = 1; + } + else { + $ev['adjust'] = 0; + } + + $ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $dtstart->format(\DateTime::W3C)); + + + if(isset($ical->DTEND)) { + $dtend = $ical->DTEND->getDateTime(); + $ev['finish'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $dtend->format(\DateTime::W3C)); + } + else + $ev['nofinish'] = 1; + + + if($ev['start'] === $ev['finish']) + $ev['nofinish'] = 1; + + if(isset($ical->CREATED)) { + $created = $ical->CREATED->getDateTime(); + $ev['created'] = datetime_convert('UTC','UTC',$created->format(\DateTime::W3C)); + } + + if(isset($ical->{'LAST-MODIFIED'})) { + $edited = $ical->{'LAST-MODIFIED'}->getDateTime(); + $ev['edited'] = datetime_convert('UTC','UTC',$edited->format(\DateTime::W3C)); + } + + if(isset($ical->LOCATION)) + $ev['location'] = (string) $ical->LOCATION; + if(isset($ical->DESCRIPTION)) + $ev['description'] = (string) $ical->DESCRIPTION; + if(isset($ical->SUMMARY)) + $ev['summary'] = (string) $ical->SUMMARY; + + if(isset($ical->UID)) { + $evuid = (string) $ical->UID; + $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", + dbesc($evuid), + intval($uid) + ); + if($r) + $ev['event_hash'] = $evuid; + else + $ev['external_id'] = $evuid; + } + + if($ev['summary'] && $ev['start']) { + $ev['event_xchan'] = $channel['channel_hash']; + $ev['uid'] = $channel['channel_id']; + $ev['account'] = $channel['channel_account_id']; + $ev['private'] = 1; + $ev['allow_cid'] = '<' . $channel['channel_hash'] . '>'; + + logger('storing event: ' . print_r($ev,true), LOGGER_ALL); + $event = event_store_event($ev); + if($event) { + $item_id = event_store_item($ev,$event); + return true; + } + } + + return false; + +} + + function event_store_item($arr, $event) { require_once('include/datetime.php'); diff --git a/include/follow.php b/include/follow.php index 1e5df4cd5..54e16703d 100644 --- a/include/follow.php +++ b/include/follow.php @@ -265,8 +265,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) ); if($r) { $result['abook'] = $r[0]; - if($is_red) - proc_run('php', 'include/notifier.php', 'permission_update', $result['abook']['abook_id']); + proc_run('php', 'include/notifier.php', 'permission_update', $result['abook']['abook_id']); } $arr = array('channel_id' => $uid, 'abook' => $result['abook']); diff --git a/include/identity.php b/include/identity.php index 29d9ef022..1a2a9c177 100644 --- a/include/identity.php +++ b/include/identity.php @@ -555,17 +555,38 @@ function identity_basic_export($channel_id, $items = false) { if($r) $ret['term'] = $r; - $r = q("select * from obj where obj_channel = %d", + + // make the obj output match the hubzilla file format + + $datestamp = datetime_convert(); + + $r = q("select obj.*, term.term as obj_term, term.url as obj_url, term.imgurl as obj_imgurl, '%s' as obj_created, '%s' as obj_edited, '%s' as obj_baseurl from obj left join term on obj_obj = term.term_hash where obj_channel = %d", + dbesc($datestamp), + dbesc($datestamp), + dbesc(z_root()), intval($channel_id) ); if($r) $ret['obj'] = $r; + + $r = q("select * from app where app_channel = %d", + intval($channel_id) + ); + if($r) + $ret['app'] = $r; + + $r = q("select * from chatroom where cr_uid = %d", + intval($channel_id) + ); + if($r) + $ret['chatroom'] = $r; + if(! $items) return $ret; - $r = q("select likes.*, item.mid from likes left join item on likes.iid = item.id where likes.channel_id = %d", + $r = q("select * from likes where channel_id = %d", intval($channel_id) ); @@ -583,7 +604,9 @@ function identity_basic_export($channel_id, $items = false) { /** @warning this may run into memory limits on smaller systems */ - $r = q("select * from item where (item_flags & %d)>0 and not (item_restrict & %d)>0 and uid = %d", + /** Don't export linked resource items. we'll have to pull those out separately. */ + + $r = q("select * from item where (item_flags & %d) > 0 and not (item_restrict & %d) > 0 and uid = %d and resource_type = '' order by created", intval(ITEM_WALL), intval(ITEM_DELETED), intval($channel_id) @@ -600,6 +623,58 @@ function identity_basic_export($channel_id, $items = false) { } + +function identity_export_year($channel_id,$year,$month = 0) { + + if(! $year) + return array(); + + if($month && $month <= 12) { + $target_month = sprintf('%02d',$month); + $target_month_plus = sprintf('%02d',$month+1); + } + else + $target_month = '01'; + + $ret = array(); + $mindate = datetime_convert('UTC','UTC',$year . '-' . $target_month . '-01 00:00:00'); + if($month && $month < 12) + $maxdate = datetime_convert('UTC','UTC',$year . '-' . $target_month_plus . '-01 00:00:00'); + else + $maxdate = datetime_convert('UTC','UTC',$year+1 . '-01-01 00:00:00'); + + $r = q("select * from item where (item_flags & %d) > 0 and (item_restrict & %d) = 0 and uid = %d and created >= '%s' and created < '%s' and resource_type = '' order by created ", + intval(ITEM_WALL), + intval(ITEM_DELETED), + intval($channel_id), + dbesc($mindate), + dbesc($maxdate) + ); + + if($r) { + $ret['item'] = array(); + xchan_query($r); + $r = fetch_post_tags($r,true); + foreach($r as $rr) + $ret['item'][] = encode_item($rr,true); + } + + + $r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d + and item.created >= '%s' and item.created < '%s' order by created ", + intval($channel_id), + dbesc($mindate), + dbesc($maxdate) + ); + + if($r) + $ret['item_id'] = $r; + + + return $ret; +} + + /** * @brief Loads a profile into the App structure. * @@ -1364,10 +1439,10 @@ function get_theme_uid() { * with the specified size. * * @param int $size -* one of (175, 80, 48) +* one of (300, 80, 48) * @returns string */ -function get_default_profile_photo($size = 175) { +function get_default_profile_photo($size = 300) { $scheme = get_config('system','default_profile_photo'); if(! $scheme) $scheme = 'rainbow_man'; diff --git a/include/items.php b/include/items.php index 1009530a4..01b4a3460 100755 --- a/include/items.php +++ b/include/items.php @@ -161,7 +161,7 @@ function filter_insecure($channel_id, $arr) { $ret = array(); - if((! intval(get_config($channel_id, 'system', 'filter_insecure_collections'))) || (! $arr)) + if((! intval(get_pconfig($channel_id, 'system', 'filter_insecure_collections'))) || (! $arr)) return $arr; $str = ''; @@ -866,6 +866,9 @@ function get_item_elements($x) { $arr['sig'] = (($x['signature']) ? htmlspecialchars($x['signature'], ENT_COMPAT,'UTF-8',false) : ''); + if(array_key_exists('diaspora_signature',$x) && is_array($x['diaspora_signature'])) + $x['diaspora_signature'] = json_encode($x['diaspora_signature']); + $arr['diaspora_meta'] = (($x['diaspora_signature']) ? json_encode(crypto_encapsulate($x['diaspora_signature'],$key)) : ''); $arr['object'] = activity_sanitise($x['object']); $arr['target'] = activity_sanitise($x['target']); @@ -1198,12 +1201,15 @@ function encode_item($item,$mirror = false) { case 2: $x['item_restrict'] |= ITEM_PDL; break; - case 2: + case 3: $x['item_restrict'] |= ITEM_WEBPAGE; break; - case 2: + case 4: $x['item_restrict'] |= ITEM_BUG; break; + case 5: + $x['item_restrict'] |= ITEM_DOC; + break; default: break; } @@ -2654,11 +2660,12 @@ function item_store_update($arr,$allow_exec = false) { return $ret; } + $r = q("delete from term where oid = %d and otype = %d", + intval($orig_post_id), + intval(TERM_OBJ_POST) + ); + if(is_array($terms)) { - $r = q("delete from term where oid = %d and otype = %d", - intval($orig_post_id), - intval(TERM_OBJ_POST) - ); foreach($terms as $t) { q("insert into term (uid,oid,otype,type,term,url) values(%d,%d,%d,%d,'%s','%s') ", @@ -2670,7 +2677,6 @@ function item_store_update($arr,$allow_exec = false) { dbesc($t['url']) ); } - $arr['term'] = $terms; } @@ -3332,6 +3338,9 @@ function check_item_source($uid, $item) { if($r[0]['src_channel_xchan'] === $item['owner_xchan']) return false; + + // since we now have connection filters with more features, the source filter is redundant and can probably go away + if(! $r[0]['src_patt']) return true; @@ -3346,10 +3355,10 @@ function check_item_source($uid, $item) { foreach($words as $word) { if(substr($word,0,1) === '#' && $tags) { foreach($tags as $t) - if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*'))) + if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) return true; } - elseif((strpos($word,'/') === 0) && preg_match($word,$body)) + elseif((strpos($word,'/') === 0) && preg_match($word,$text)) return true; elseif(stristr($text,$word) !== false) return true; @@ -3370,14 +3379,21 @@ function post_is_importable($item,$abook) { if(! $item) return false; - if((! $abook['abook_incl']) && (! $abook['abook_excl'])) + if(! ($abook['abook_incl'] || $abook['abook_excl'])) return true; - require_once('include/html2plain.php'); + + unobscure($item); + $text = prepare_text($item['body'],$item['mimetype']); $text = html2plain($text); + $lang = null; + + if((strpos($abook['abook_incl'],'lang=') !== false) || (strpos($abook['abook_excl'],'lang=') !== false)) { + $lang = detect_language($text); + } $tags = ((count($item['term'])) ? $item['term'] : false); // exclude always has priority @@ -3389,10 +3405,12 @@ function post_is_importable($item,$abook) { $word = trim($word); if(substr($word,0,1) === '#' && $tags) { foreach($tags as $t) - if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*'))) + if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) return false; } - elseif((strpos($word,'/') === 0) && preg_match($word,$body)) + elseif((strpos($word,'/') === 0) && preg_match($word,$text)) + return false; + elseif((strpos($word,'lang=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,5))) == 0)) return false; elseif(stristr($text,$word) !== false) return false; @@ -3406,10 +3424,12 @@ function post_is_importable($item,$abook) { $word = trim($word); if(substr($word,0,1) === '#' && $tags) { foreach($tags as $t) - if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*'))) + if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) return true; } - elseif((strpos($word,'/') === 0) && preg_match($word,$body)) + elseif((strpos($word,'/') === 0) && preg_match($word,$text)) + return true; + elseif((strpos($word,'lang=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,5))) == 0)) return true; elseif(stristr($text,$word) !== false) return true; @@ -3751,6 +3771,9 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $author['owner_avatar'] = $contact['thumb']; } + if(! post_is_importable($datarray,$contact)) + continue; + logger('consume_feed: author ' . print_r($author,true),LOGGER_DEBUG); logger('consume_feed: ' . print_r($datarray,true),LOGGER_DATA); diff --git a/include/network.php b/include/network.php index 3abb1b40e..d9546a074 100644 --- a/include/network.php +++ b/include/network.php @@ -531,7 +531,7 @@ function avatar_img($email) { $avatar = array(); $a = get_app(); - $avatar['size'] = 175; + $avatar['size'] = 300; $avatar['email'] = $email; $avatar['url'] = ''; $avatar['success'] = false; @@ -1658,4 +1658,4 @@ function format_and_send_email($sender,$xchan,$item) { -}
\ No newline at end of file +} diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 6f508bf72..5d61556ab 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -606,16 +606,16 @@ function import_profile_photo($photo,$xchan,$thing = false) { if(($width / $height) > 1.2) { // crop out the sides $margin = $width - $height; - $img->cropImage(175,($margin / 2),0,$height,$height); + $img->cropImage(300,($margin / 2),0,$height,$height); } elseif(($height / $width) > 1.2) { // crop out the bottom $margin = $height - $width; - $img->cropImage(175,0,0,$width,$width); + $img->cropImage(300,0,0,$width,$width); } else { - $img->scaleImageSquare(175); + $img->scaleImageSquare(300); } } @@ -682,7 +682,7 @@ function import_channel_photo($photo,$type,$aid,$uid) { $img = photo_factory($photo, $type); if($img->is_valid()) { - $img->scaleImageSquare(175); + $img->scaleImageSquare(300); $p = array('aid' => $aid, 'uid' => $uid, 'resource_id' => $hash, 'filename' => $filename, 'album' => t('Profile Photos'), 'photo_flags' => PHOTO_PROFILE, 'scale' => 4); diff --git a/include/security.php b/include/security.php index 91683cc98..0c3dc29d6 100644 --- a/include/security.php +++ b/include/security.php @@ -260,7 +260,7 @@ function item_permissions_sql($owner_id, $remote_observer = null) { $regexop = db_getfunc('REGEXP'); $sql = sprintf( " AND ( NOT (deny_cid like '%s' OR deny_gid $regexop '%s') - AND ( allow_cid like '%s' OR allow_gid $regexop '%s' OR ( allow_cid = '' AND allow_gid = '') ) + AND ( allow_cid like '%s' OR allow_gid $regexop '%s' OR ( allow_cid = '' AND allow_gid = '' AND item_private = 0 ) ) ) ", dbesc(protect_sprintf( '%<' . $observer . '>%')), @@ -295,7 +295,7 @@ function public_permissions_sql($observer_hash) { $regexop = db_getfunc('REGEXP'); $sql = sprintf( " OR (( NOT (deny_cid like '%s' OR deny_gid $regexop '%s') - AND ( allow_cid like '%s' OR allow_gid $regexop '%s' OR ( allow_cid = '' AND allow_gid = '') ) + AND ( allow_cid like '%s' OR allow_gid $regexop '%s' OR ( allow_cid = '' AND allow_gid = '' AND item_private = 0 ) ) )) ", dbesc(protect_sprintf( '%<' . $observer_hash . '>%')), @@ -422,6 +422,9 @@ function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0 ) { $str .= intval($rr); } } + else + $str = "''"; + logger('stream_perms_api_uids: ' . $str, LOGGER_DEBUG); return $str; @@ -452,6 +455,9 @@ function stream_perms_xchans($perms = NULL ) { $str .= "'" . dbesc($rr) . "'"; } } + else + $str = "''"; + logger('stream_perms_xchans: ' . $str, LOGGER_DEBUG); return $str; diff --git a/include/taxonomy.php b/include/taxonomy.php index fa540ac56..a5da190d4 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -276,7 +276,7 @@ function dir_tagblock($link,$r) { $o = ''; $observer = get_observer_hash(); - if(! get_globaldir_setting($observer)) + if(! get_directory_setting($observer, 'globaldir')) return $o; @@ -407,4 +407,4 @@ function get_things($profile_hash,$uid) { //logger('things: ' . print_r($sorted_things,true)); return $sorted_things; -}
\ No newline at end of file +} diff --git a/include/text.php b/include/text.php index 7101d76da..f4122845e 100644 --- a/include/text.php +++ b/include/text.php @@ -72,10 +72,6 @@ function notags($string) { // return(str_replace(array("<",">","\xBA","\xBC","\xBE"), array('[',']','','',''), $string)); } -// use this on "body" or "content" input where angle chars shouldn't be removed, -// and allow them to be safely displayed. - - /** * use this on "body" or "content" input where angle chars shouldn't be removed, @@ -807,7 +803,7 @@ function contact_block() { $shown = get_pconfig($a->profile['uid'],'system','display_friend_count'); if($shown === false) - $shown = 24; + $shown = 25; if($shown == 0) return; diff --git a/include/widgets.php b/include/widgets.php index 4a9032a21..032b1c67e 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -132,7 +132,7 @@ function widget_suggestions($arr) { 'profile' => $rr['xchan_url'], 'name' => $rr['xchan_name'], 'photo' => $rr['xchan_photo_m'], - 'ignlnk' => z_root() . '/suggest?ignore=' . $rr['xchan_hash'], + 'ignlnk' => z_root() . '/directory?ignore=' . $rr['xchan_hash'], 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'ignore' => t('Ignore/Hide') @@ -381,6 +381,7 @@ function widget_categories($arr) { $srchurl = str_replace(array('?f=','&f='),array('',''),$srchurl); return categories_widget($srchurl, $cat); + } function widget_tagcloud_wall($arr) { @@ -409,6 +410,7 @@ function widget_catcloud_wall($arr) { $limit = ((array_key_exists('limit',$arr)) ? intval($arr['limit']) : 50); return catblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], ITEM_WALL); + } diff --git a/include/zot.php b/include/zot.php index 34e7f3e42..0376dc7f5 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1110,13 +1110,18 @@ function zot_import($arr, $sender_url) { logger('specific recipients'); $recip_arr = array(); foreach($i['notify']['recipients'] as $recip) { - $recip_arr[] = make_xchan_hash($recip['guid'],$recip['guid_sig']); + if(is_array($recip)) { + $recip_arr[] = make_xchan_hash($recip['guid'],$recip['guid_sig']); + } + } + $r = false; + if($recip_arr) { + stringify_array_elms($recip_arr); + $recips = implode(',',$recip_arr); + $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " ) and not ( channel_pageflags & %d ) > 0 ", + intval(PAGE_REMOVED) + ); } - stringify_array_elms($recip_arr); - $recips = implode(',',$recip_arr); - $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " ) and not ( channel_pageflags & %d ) > 0 ", - intval(PAGE_REMOVED) - ); if(! $r) { logger('recips: no recipients on this site'); continue; @@ -1272,7 +1277,8 @@ function public_recips($msg) { $include_sys = false; if($msg['message']['type'] === 'activity') { - $include_sys = true; + if(! get_config('system','disable_discover_tab')) + $include_sys = true; $col = 'channel_w_stream'; $field = PERMS_W_STREAM; if(array_key_exists('flags',$msg['message']) && in_array('thread_parent', $msg['message']['flags'])) { @@ -1554,8 +1560,9 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $tag_delivery = tgroup_check($channel['channel_id'],$arr); - $perm = (($arr['mid'] == $arr['parent_mid']) ? 'send_stream' : 'post_comments'); - + $perm = 'send_stream'; + if(($arr['mid'] !== $arr['parent_mid']) && ($relay)) + $perm = 'post_comments'; // This is our own post, possibly coming from a channel clone @@ -1654,9 +1661,9 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ } } - $ab = q("select abook.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and (abook_flags & %d) = 0", + $ab = q("select * from abook where abook_channel = %d and abook_xchan = '%s'", intval($channel['channel_id']), - intval(ABOOK_FLAG_SELF) + dbesc($arr['owner_xchan']) ); $abook = (($ab) ? $ab[0] : null); @@ -2887,7 +2894,12 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { } if(array_key_exists('channel',$arr) && is_array($arr['channel']) && count($arr['channel'])) { - $disallowed = array('channel_id','channel_account_id','channel_primary','channel_prvkey', 'channel_address', 'channel_notifyflags'); + if(array_key_exists('channel_removed',$arr['channel'])) + $arr['channel_pageflags'] |= PAGE_REMOVED; + if(array_key_exists('channel_system',$arr['channel'])) + $arr['channel_pageflags'] |= PAGE_SYSTEM; + + $disallowed = array('channel_id','channel_account_id','channel_primary','channel_prvkey', 'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_system'); $clean = array(); foreach($arr['channel'] as $k => $v) { @@ -2918,7 +2930,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $total_feeds ++; } - $disallowed = array('abook_id','abook_account','abook_channel'); + $disallowed = array('abook_id','abook_account','abook_channel','abook_blocked','abook_ignored','abook_hidden','abook_archived','abook_pending','abook_unconnected','abook_self','abook_feed'); foreach($arr['abook'] as $abook) { @@ -3017,7 +3029,6 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { foreach($clean as $k => $v) { if($k == 'abook_dob') $v = dbescdate($v); - $r = dbq("UPDATE abook set " . dbesc($k) . " = '" . dbesc($v) . "' where abook_xchan = '" . dbesc($clean['abook_xchan']) . "' and abook_channel = " . intval($channel['channel_id'])); } @@ -3200,7 +3211,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { } if(count($clean)) { foreach($clean as $k => $v) { - $r = dbq("UPDATE profile set " . dbesc($k) . " = '" . dbesc($v) + $r = dbq("UPDATE profile set `" . dbesc($k) . "` = '" . dbesc($v) . "' where profile_guid = '" . dbesc($profile['profile_guid']) . "' and uid = " . intval($channel['channel_id'])); } } |