From f6d198ce5dcd9fe416975ff760439dfacbb83812 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 29 Aug 2012 23:03:03 -0700 Subject: trim a bit of fat --- mod/amcd.php | 49 ---- mod/api.php | 2 +- mod/babel.php | 75 ----- mod/content.php | 858 ------------------------------------------------------ mod/friendika.php | 11 - mod/localtime.php | 49 ---- mod/network.php | 12 +- mod/notes.php | 143 --------- mod/openid.php | 96 ------ mod/ping.php | 2 +- mod/profile.php | 86 +----- mod/pubsub.php | 153 ---------- mod/rsd_xml.php | 4 +- mod/salmon.php | 229 --------------- mod/session.php | 5 - 15 files changed, 23 insertions(+), 1751 deletions(-) delete mode 100644 mod/amcd.php delete mode 100644 mod/babel.php delete mode 100644 mod/content.php delete mode 100644 mod/friendika.php delete mode 100644 mod/localtime.php delete mode 100644 mod/notes.php delete mode 100644 mod/openid.php delete mode 100644 mod/pubsub.php delete mode 100644 mod/salmon.php delete mode 100644 mod/session.php (limited to 'mod') diff --git a/mod/amcd.php b/mod/amcd.php deleted file mode 100644 index a2a1327e6..000000000 --- a/mod/amcd.php +++ /dev/null @@ -1,49 +0,0 @@ -get_parameters()); + return login(false,'api-login',$request->get_parameters()); } //FKOAuth1::loginUser(4); diff --git a/mod/babel.php b/mod/babel.php deleted file mode 100644 index ca2c068f8..000000000 --- a/mod/babel.php +++ /dev/null @@ -1,75 +0,0 @@ -', $s); -} - -function babel_content(&$a) { - - $o .= '

Babel Diagnostic

'; - - $o .= '
'; - $o .= t('Source (bbcode) text:') . EOL . '' . EOL; - $o .= '
'; - - $o .= '

'; - - $o .= '
'; - $o .= t('Source (Diaspora) text to convert to BBcode:') . EOL . '' . EOL; - $o .= '
'; - - $o .= '

'; - - if(x($_REQUEST,'text')) { - - $text = trim($_REQUEST['text']); - $o .= t("Source input: ") . EOL. EOL; - $o .= visible_lf($text) . EOL. EOL; - - $html = bbcode($text); - $o .= t("bb2html: ") . EOL. EOL; - $o .= $html. EOL. EOL; - - $bbcode = html2bbcode($html); - $o .= t("bb2html2bb: ") . EOL. EOL; - $o .= visible_lf($bbcode) . EOL. EOL; - - $diaspora = bb2diaspora($text); - $o .= t("bb2md: ") . EOL. EOL; - $o .= visible_lf($diaspora) . EOL. EOL; - - $html = Markdown($diaspora); - $o .= t("bb2md2html: ") . EOL. EOL; - $o .= $html. EOL. EOL; - - $bbcode = diaspora2bb($diaspora); - $o .= t("bb2dia2bb: ") . EOL. EOL; - $o .= visible_lf($bbcode) . EOL. EOL; - - $bbcode = html2bbcode($html); - $o .= t("bb2md2html2bb: ") . EOL. EOL; - $o .= visible_lf($bbcode) . EOL. EOL; - - - - } - - if(x($_REQUEST,'d2bbtext')) { - - $d2bbtext = trim($_REQUEST['d2bbtext']); - $o .= t("Source input (Diaspora format): ") . EOL. EOL; - $o .= visible_lf($d2bbtext) . EOL. EOL; - - - $bb = diaspora2bb($d2bbtext); - $o .= t("diaspora2bb: ") . EOL. EOL; - $o .= visible_lf($bb) . EOL. EOL; - } - - return $o; -} diff --git a/mod/content.php b/mod/content.php deleted file mode 100644 index dc82b2b2f..000000000 --- a/mod/content.php +++ /dev/null @@ -1,858 +0,0 @@ - $a->query_string); - - call_hooks('content_content_init', $arr); - - - $datequery = $datequery2 = ''; - - $group = 0; - - $nouveau = false; - - if($a->argc > 1) { - for($x = 1; $x < $a->argc; $x ++) { - if(is_a_date_arg($a->argv[$x])) { - if($datequery) - $datequery2 = escape_tags($a->argv[$x]); - else { - $datequery = escape_tags($a->argv[$x]); - $_GET['order'] = 'post'; - } - } - elseif($a->argv[$x] === 'new') { - $nouveau = true; - } - elseif(intval($a->argv[$x])) { - $group = intval($a->argv[$x]); - $def_acl = array('allow_gid' => '<' . $group . '>'); - } - } - } - - - $o = ''; - - - - $contact_id = $a->cid; - - require_once('include/acl_selectors.php'); - - $cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0); - $star = ((x($_GET,'star')) ? intval($_GET['star']) : 0); - $order = ((x($_GET,'order')) ? notags($_GET['order']) : 'comment'); - $liked = ((x($_GET,'liked')) ? intval($_GET['liked']) : 0); - $conv = ((x($_GET,'conv')) ? intval($_GET['conv']) : 0); - $spam = ((x($_GET,'spam')) ? intval($_GET['spam']) : 0); - $nets = ((x($_GET,'nets')) ? $_GET['nets'] : ''); - $cmin = ((x($_GET,'cmin')) ? intval($_GET['cmin']) : 0); - $cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99); - $file = ((x($_GET,'file')) ? $_GET['file'] : ''); - - - - if(x($_GET,'search') || x($_GET,'file')) - $nouveau = true; - if($cid) - $def_acl = array('allow_cid' => '<' . intval($cid) . '>'); - - if($nets) { - $r = q("select id from contact where uid = %d and network = '%s' and self = 0", - intval(local_user()), - dbesc($nets) - ); - - $str = ''; - if(count($r)) - foreach($r as $rr) - $str .= '<' . $rr['id'] . '>'; - if(strlen($str)) - $def_acl = array('allow_cid' => $str); - } - - - $sql_options = (($star) ? " and starred = 1 " : ''); - - $sql_nets = (($nets) ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : ''); - - $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) "; - - if($group) { - $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($group), - intval($_SESSION['uid']) - ); - if(! count($r)) { - if($update) - killme(); - notice( t('No such group') . EOL ); - goaway($a->get_baseurl(true) . '/network'); - // NOTREACHED - } - - $contacts = expand_groups(array($group)); - if((is_array($contacts)) && count($contacts)) { - $contact_str = implode(',',$contacts); - } - else { - $contact_str = ' 0 '; - info( t('Group is empty')); - } - - $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) "; - $o = '

' . t('Group: ') . $r[0]['name'] . '

' . $o; - } - elseif($cid) { - - $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d - AND `blocked` = 0 AND `pending` = 0 LIMIT 1", - intval($cid) - ); - if(count($r)) { - $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) "; - - } - else { - killme(); - } - } - - - $sql_extra3 = ''; - - if($datequery) { - $sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery)))); - } - if($datequery2) { - $sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); - } - - $sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` "); - $sql_extra3 = (($nouveau) ? '' : $sql_extra3); - - if(x($_GET,'search')) { - $search = escape_tags($_GET['search']); - if (get_config('system','use_fulltext_engine')) { - if(strpos($search,'#') === 0) - $sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ", - dbesc(protect_sprintf($search)) - ); - else - $sql_extra .= sprintf(" AND (MATCH(`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ", - dbesc(protect_sprintf($search)), - dbesc(protect_sprintf($search)) - ); - } else { - $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ", - dbesc(protect_sprintf('%' . $search . '%')), - dbesc(protect_sprintf('%]' . $search . '[%')) - ); - } - } - if(strlen($file)) { - $sql_extra .= file_tag_file_query('item',unxmlify($file)); - } - - if($conv) { - $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname']; - $myurl = substr($myurl,strpos($myurl,'://')+3); - $myurl = str_replace('www.','',$myurl); - $diasp_url = str_replace('/profile/','/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 . ']%')) - ); - - } - - $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); - - - - - if($nouveau) { - // "New Item View" - show all items unthreaded in reverse created date order - - $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item`, `contact` - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 - AND `item`.`deleted` = 0 and `item`.`moderated` = 0 - $simple_update - AND `contact`.`id` = `item`.`contact-id` - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - $sql_extra $sql_nets - ORDER BY `item`.`received` DESC $pager_sql ", - intval($_SESSION['uid']) - ); - - } - else { - - // Normal conversation view - - - if($order === 'post') - $ordering = "`created`"; - else - $ordering = "`commented`"; - - $start = dba_timer(); - - $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` = `item`.`id` - $sql_extra3 $sql_extra $sql_nets - ORDER BY `item`.$ordering DESC $pager_sql ", - intval(local_user()) - ); - - $first = dba_timer(); - - - // Then fetch all the children of the parents that are on this page - - $parents_arr = array(); - $parents_str = ''; - - if(count($r)) { - foreach($r as $rr) - if(! in_array($rr['item_id'],$parents_arr)) - $parents_arr[] = $rr['item_id']; - $parents_str = implode(', ', $parents_arr); - - $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item`, `contact` - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `item`.`moderated` = 0 AND `contact`.`id` = `item`.`contact-id` - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` IN ( %s ) - $sql_extra ", - intval(local_user()), - dbesc($parents_str) - ); - - $second = dba_timer(); - - $items = fetch_post_tags($items); - $items = conv_sort($items,$ordering); - - } else { - $items = array(); - } - } - - - logger('parent dba_timer: ' . sprintf('%01.4f',$first - $start)); - logger('child dba_timer: ' . sprintf('%01.4f',$second - $first)); - - // Set this so that the conversation function can find out contact info for our wall-wall items - $a->page_contact = $a->contact; - - $mode = (($nouveau) ? 'network-new' : 'network'); - - $o = render_content($a,$items,$mode,false); - - - header('Content-type: application/json'); - echo json_encode($o); - killme(); -} - - - -function render_content(&$a, $items, $mode, $update, $preview = false) { - - - require_once('bbcode.php'); - - $ssl_state = ((local_user()) ? true : false); - - $profile_owner = 0; - $page_writeable = false; - - $previewing = (($preview) ? ' preview ' : ''); - - if($mode === 'network') { - $profile_owner = local_user(); - $page_writeable = true; - } - - if($mode === 'profile') { - $profile_owner = $a->profile['profile_uid']; - $page_writeable = can_write_wall($a,$profile_owner); - } - - if($mode === 'notes') { - $profile_owner = local_user(); - $page_writeable = true; - } - - if($mode === 'display') { - $profile_owner = $a->profile['uid']; - $page_writeable = can_write_wall($a,$profile_owner); - } - - if($mode === 'community') { - $profile_owner = 0; - $page_writeable = false; - } - - if($update) - $return_url = $_SESSION['return_url']; - else - $return_url = $_SESSION['return_url'] = $a->query_string; - - load_contact_links(local_user()); - - $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview); - call_hooks('conversation_start',$cb); - - $items = $cb['items']; - - $cmnt_tpl = get_markup_template('comment_item.tpl'); - $tpl = 'wall_item.tpl'; - $wallwall = 'wallwall_item.tpl'; - $hide_comments_tpl = get_markup_template('hide_comments.tpl'); - - $alike = array(); - $dlike = array(); - - - // array with html for each thread (parent+comments) - $threads = array(); - $threadsid = -1; - - if($items && count($items)) { - - if($mode === 'network-new' || $mode === 'search' || $mode === 'community') { - - // "New Item View" on network page or search page results - // - just loop through the items and format them minimally for display - - //$tpl = get_markup_template('search_item.tpl'); - $tpl = 'search_item.tpl'; - - foreach($items as $item) { - $threadsid++; - - $comment = ''; - $owner_url = ''; - $owner_photo = ''; - $owner_name = ''; - $sparkle = ''; - - if($mode === 'search' || $mode === 'community') { - if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) - && ($item['id'] != $item['parent'])) - continue; - $nickname = $item['nickname']; - } - else - $nickname = $a->user['nickname']; - - // prevent private email from leaking. - if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) - continue; - - $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']); - if($item['author-link'] && (! $item['author-name'])) - $profile_name = $item['author-link']; - - - - $sp = false; - $profile_link = best_link_url($item,$sp); - if($profile_link === 'mailbox') - $profile_link = ''; - if($sp) - $sparkle = ' sparkle'; - else - $profile_link = zrl($profile_link); - - $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); - if(($normalised != 'mailbox') && (x($a->contacts[$normalised]))) - $profile_avatar = $a->contacts[$normalised]['thumb']; - else - $profile_avatar = ((strlen($item['author-avatar'])) ? $a->get_cached_avatar_image($item['author-avatar']) : $item['thumb']); - - $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); - call_hooks('render_location',$locate); - - $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate)); - - localize_item($item); - if($mode === 'network-new') - $dropping = true; - else - $dropping = false; - - - $drop = array( - 'dropping' => $dropping, - 'select' => t('Select'), - 'delete' => t('Delete'), - ); - - $star = false; - $isstarred = "unstarred"; - - $lock = false; - $likebuttons = false; - $shareable = false; - - $body = prepare_body($item,true); - - //$tmp_item = replace_macros($tpl,array( - $tmp_item = array( - 'template' => $tpl, - 'id' => (($preview) ? 'P0' : $item['item_id']), - 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), - 'profile_url' => $profile_link, - 'item_photo_menu' => item_photo_menu($item), - 'name' => template_escape($profile_name), - 'sparkle' => $sparkle, - 'lock' => $lock, - 'thumb' => $profile_avatar, - 'title' => template_escape($item['title']), - 'body' => template_escape($body), - 'text' => strip_tags(template_escape($body)), - 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), - 'location' => template_escape($location), - 'indent' => '', - 'owner_name' => template_escape($owner_name), - 'owner_url' => $owner_url, - 'owner_photo' => $owner_photo, - 'plink' => get_plink($item), - 'edpost' => false, - 'isstarred' => $isstarred, - 'star' => $star, - 'drop' => $drop, - 'vote' => $likebuttons, - 'like' => '', - 'dislike' => '', - 'comment' => '', - 'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), - 'previewing' => $previewing, - 'wait' => t('Please wait'), - ); - - $arr = array('item' => $item, 'output' => $tmp_item); - call_hooks('display_item', $arr); - - $threads[$threadsid]['id'] = $item['item_id']; - $threads[$threadsid]['items'] = array($arr['output']); - - } - - } - else - { - // Normal View - - - // Figure out how many comments each parent has - // (Comments all have gravity of 6) - // Store the result in the $comments array - - $comments = array(); - foreach($items as $item) { - if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) { - if(! x($comments,$item['parent'])) - $comments[$item['parent']] = 1; - else - $comments[$item['parent']] += 1; - } elseif(! x($comments,$item['parent'])) - $comments[$item['parent']] = 0; // avoid notices later on - } - - // map all the like/dislike activities for each parent item - // Store these in the $alike and $dlike arrays - - foreach($items as $item) { - like_puller($a,$item,$alike,'like'); - like_puller($a,$item,$dlike,'dislike'); - } - - $comments_collapsed = false; - $comments_seen = 0; - $comment_lastcollapsed = false; - $comment_firstcollapsed = false; - $blowhard = 0; - $blowhard_count = 0; - - - foreach($items as $item) { - - $comment = ''; - $template = $tpl; - $commentww = ''; - $sparkle = ''; - $owner_url = $owner_photo = $owner_name = ''; - - // We've already parsed out like/dislike for special treatment. We can ignore them now - - if(((activity_match($item['verb'],ACTIVITY_LIKE)) - || (activity_match($item['verb'],ACTIVITY_DISLIKE))) - && ($item['id'] != $item['parent'])) - continue; - - $toplevelpost = (($item['id'] == $item['parent']) ? true : false); - - - // Take care of author collapsing and comment collapsing - // (author collapsing is currently disabled) - // If a single author has more than 3 consecutive top-level posts, squash the remaining ones. - // If there are more than two comments, squash all but the last 2. - - if($toplevelpost) { - - $item_writeable = (($item['writable'] || $item['self']) ? true : false); - - $comments_seen = 0; - $comments_collapsed = false; - $comment_lastcollapsed = false; - $comment_firstcollapsed = false; - - $threadsid++; - $threads[$threadsid]['id'] = $item['item_id']; - $threads[$threadsid]['private'] = $item['private']; - $threads[$threadsid]['items'] = array(); - - } - else { - - // prevent private email reply to public conversation from leaking. - if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) - continue; - - $comments_seen ++; - $comment_lastcollapsed = false; - $comment_firstcollapsed = false; - } - - $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false); - $show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false); - - - if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { - - if (!$comments_collapsed){ - $threads[$threadsid]['num_comments'] = sprintf( tt('%d comment','%d comments',$comments[$item['parent']]),$comments[$item['parent']] ); - $threads[$threadsid]['hide_text'] = t('show more'); - $comments_collapsed = true; - $comment_firstcollapsed = true; - } - } - if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) { - - $comment_lastcollapsed = true; - } - - $redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid'] ; - - $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) - || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) - ? t('Private Message') - : false); - - - // Top-level wall post not written by the wall owner (wall-to-wall) - // First figure out who owns it. - - $osparkle = ''; - - if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) { - - if($item['wall']) { - - // On the network page, I am the owner. On the display page it will be the profile owner. - // This will have been stored in $a->page_contact by our calling page. - // Put this person as the wall owner of the wall-to-wall notice. - - $owner_url = zrl($a->page_contact['url']); - $owner_photo = $a->page_contact['thumb']; - $owner_name = $a->page_contact['name']; - $template = $wallwall; - $commentww = 'ww'; - } - - if((! $item['wall']) && $item['owner-link']) { - - $owner_linkmatch = (($item['owner-link']) && link_compare($item['owner-link'],$item['author-link'])); - $alias_linkmatch = (($item['alias']) && link_compare($item['alias'],$item['author-link'])); - $owner_namematch = (($item['owner-name']) && $item['owner-name'] == $item['author-name']); - if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) { - - // The author url doesn't match the owner (typically the contact) - // and also doesn't match the contact alias. - // The name match is a hack to catch several weird cases where URLs are - // all over the park. It can be tricked, but this prevents you from - // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn - // well that it's the same Bob Smith. - - // But it could be somebody else with the same name. It just isn't highly likely. - - - $owner_url = $item['owner-link']; - $owner_photo = $item['owner-avatar']; - $owner_name = $item['owner-name']; - $template = $wallwall; - $commentww = 'ww'; - // If it is our contact, use a friendly redirect link - if((link_compare($item['owner-link'],$item['url'])) - && ($item['network'] === NETWORK_DFRN)) { - $owner_url = $redirect_url; - $osparkle = ' sparkle'; - } - else - $owner_url = zrl($owner_url); - } - } - } - - $likebuttons = ''; - $shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false); - - if($page_writeable) { -/* if($toplevelpost) { */ - $likebuttons = array( - 'like' => array( t("I like this \x28toggle\x29"), t("like")), - 'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")), - ); - if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share')); -/* } */ - - $qc = $qcomment = null; - - if(in_array('qcomment',$a->plugins)) { - $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); - $qcomment = (($qc) ? explode("\n",$qc) : null); - } - - if($show_comment_box) { - $comment = replace_macros($cmnt_tpl,array( - '$return_path' => '', - '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''), - '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'), - '$id' => $item['item_id'], - '$parent' => $item['parent'], - '$qcomment' => $qcomment, - '$profile_uid' => $profile_owner, - '$mylink' => $a->contact['url'], - '$mytitle' => t('This is you'), - '$myphoto' => $a->contact['thumb'], - '$comment' => t('Comment'), - '$submit' => t('Submit'), - '$edbold' => t('Bold'), - '$editalic' => t('Italic'), - '$eduline' => t('Underline'), - '$edquote' => t('Quote'), - '$edcode' => t('Code'), - '$edimg' => t('Image'), - '$edurl' => t('Link'), - '$edvideo' => t('Video'), - '$preview' => t('Preview'), - '$sourceapp' => t($a->sourcename), - '$ww' => (($mode === 'network') ? $commentww : '') - )); - } - } - - if(local_user() && link_compare($a->contact['url'],$item['author-link'])) - $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); - else - $edpost = false; - - $drop = ''; - $dropping = false; - - if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user())) - $dropping = true; - - $drop = array( - 'dropping' => $dropping, - 'select' => t('Select'), - 'delete' => t('Delete'), - ); - - $star = false; - $filer = false; - - $isstarred = "unstarred"; - if ($profile_owner == local_user()) { - if($toplevelpost) { - $isstarred = (($item['starred']) ? "starred" : "unstarred"); - - $star = array( - 'do' => t("add star"), - 'undo' => t("remove star"), - 'toggle' => t("toggle star status"), - 'classdo' => (($item['starred']) ? "hidden" : ""), - 'classundo' => (($item['starred']) ? "" : "hidden"), - 'starred' => t('starred'), - 'tagger' => t("add tag"), - 'classtagger' => "", - ); - } - $filer = t("save to folder"); - } - - - $photo = $item['photo']; - $thumb = $item['thumb']; - - // Post was remotely authored. - - $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true); - - $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); - - if($item['author-link'] && (! $item['author-name'])) - $profile_name = $item['author-link']; - - $sp = false; - $profile_link = best_link_url($item,$sp); - if($profile_link === 'mailbox') - $profile_link = ''; - if($sp) - $sparkle = ' sparkle'; - else - $profile_link = zrl($profile_link); - - $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); - if(($normalised != 'mailbox') && (x($a->contacts,$normalised))) - $profile_avatar = $a->contacts[$normalised]['thumb']; - else - $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($thumb)); - - $like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : ''); - $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : ''); - - $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); - call_hooks('render_location',$locate); - - $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate)); - - $indent = (($toplevelpost) ? '' : ' comment'); - - if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) - $indent .= ' shiny'; - - // - localize_item($item); - - - $tags=array(); - foreach(explode(',',$item['tag']) as $tag){ - $tag = trim($tag); - if ($tag!="") $tags[] = bbcode($tag); - } - - // Build the HTML - - $body = prepare_body($item,true); - //$tmp_item = replace_macros($template, - $tmp_item = array( - // collapse comments in template. I don't like this much... - 'comment_firstcollapsed' => $comment_firstcollapsed, - 'comment_lastcollapsed' => $comment_lastcollapsed, - // template to use to render item (wall, walltowall, search) - 'template' => $template, - - 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), - 'tags' => $tags, - 'body' => template_escape($body), - 'text' => strip_tags(template_escape($body)), - 'id' => $item['item_id'], - 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), - 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), - 'to' => t('to'), - 'wall' => t('Wall-to-Wall'), - 'vwall' => t('via Wall-To-Wall:'), - 'profile_url' => $profile_link, - 'item_photo_menu' => item_photo_menu($item), - 'name' => template_escape($profile_name), - 'thumb' => $profile_avatar, - 'osparkle' => $osparkle, - 'sparkle' => $sparkle, - 'title' => template_escape($item['title']), - 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), - 'lock' => $lock, - 'location' => template_escape($location), - 'indent' => $indent, - 'owner_url' => $owner_url, - 'owner_photo' => $owner_photo, - 'owner_name' => template_escape($owner_name), - 'plink' => get_plink($item), - 'edpost' => $edpost, - 'isstarred' => $isstarred, - 'star' => $star, - 'filer' => $filer, - 'drop' => $drop, - 'vote' => $likebuttons, - 'like' => $like, - 'dislike' => $dislike, - 'comment' => $comment, - 'previewing' => $previewing, - 'wait' => t('Please wait'), - - ); - - - $arr = array('item' => $item, 'output' => $tmp_item); - call_hooks('display_item', $arr); - - $threads[$threadsid]['items'][] = $arr['output']; - } - } - } - - - return $threads; - -} diff --git a/mod/friendika.php b/mod/friendika.php deleted file mode 100644 index 1f3df565d..000000000 --- a/mod/friendika.php +++ /dev/null @@ -1,11 +0,0 @@ -data['mod-localtime'] = datetime_convert('UTC',$_POST['timezone'],$t,$bd_format); - -} - -function localtime_content(&$a) { - $t = $_REQUEST['time']; - if(! $t) - $t = 'now'; - - $o .= '

' . t('Time Conversion') . '

'; - - $o .= '

' . t('Friendika provides this service for sharing events with other networks and friends in unknown timezones.') . '

'; - - - - $o .= '

' . sprintf( t('UTC time: %s'), $t) . '

'; - - if($_REQUEST['timezone']) - $o .= '

' . sprintf( t('Current timezone: %s'), $_REQUEST['timezone']) . '

'; - - if(x($a->data,'mod-localtime')) - $o .= '

' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '

'; - - - $o .= '
'; - - $o .= '

' . t('Please select your timezone:') . '

'; - - $o .= select_timezone(($_REQUEST['timezone']) ? $_REQUEST['timezone'] : 'America/Los_Angeles'); - - $o .= '
'; - - return $o; - -} \ No newline at end of file diff --git a/mod/network.php b/mod/network.php index a85e11f90..b37be2fa8 100644 --- a/mod/network.php +++ b/mod/network.php @@ -661,14 +661,9 @@ function network_content(&$a, $update = 0, $load = false) { // Then fetch all the children of the parents that are on this page - $parents_arr = array(); - $parents_str = ''; - if(count($r)) { - foreach($r as $rr) - if(! in_array($rr['item_id'],$parents_arr)) - $parents_arr[] = $rr['item_id']; - $parents_str = implode(', ', $parents_arr); + + $parents_str = ids_to_querystr($r,'item_id'); $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`, @@ -719,9 +714,8 @@ function network_content(&$a, $update = 0, $load = false) { $second = dba_timer(); - if(! $update) { + if(! $update) $o .= alt_pager($a,count($items)); - } // logger('parent dba_timer: ' . sprintf('%01.4f',$first - $start)); // logger('child dba_timer: ' . sprintf('%01.4f',$second - $first)); diff --git a/mod/notes.php b/mod/notes.php deleted file mode 100644 index afaa60f70..000000000 --- a/mod/notes.php +++ /dev/null @@ -1,143 +0,0 @@ -user['nickname']; - -// profile_load($a,$which,$profile); - -} - - -function notes_content(&$a,$update = false) { - - if(! local_user()) { - notice( t('Permission denied.') . EOL); - return; - } - - require_once("include/bbcode.php"); - require_once('include/security.php'); - require_once('include/conversation.php'); - require_once('include/acl_selectors.php'); - $groups = array(); - - - $o = ''; - - $remote_contact = false; - - $contact_id = $_SESSION['cid']; - $contact = $a->contact; - - $is_owner = true; - - $o =""; - $o .= profile_tabs($a,True); - - if(! $update) { - $o .= '

' . t('Personal Notes') . '

'; - - $commpage = false; - $commvisitor = false; - - $celeb = false; - - - - $x = array( - 'is_owner' => $is_owner, - 'allow_location' => (($a->user['allow_location']) ? true : false), - 'default_location' => $a->user['default-location'], - 'nickname' => $a->user['nickname'], - 'lockstate' => 'lock', - 'acl' => '', - 'bang' => '', - 'visitor' => 'block', - 'profile_uid' => local_user(), - 'button' => t('Save') - - ); - - $o .= status_editor($a,$x,$a->contact['id']); - - $o .= '
' . "\r\n"; - $o .= "\r\n"; - - } - - // Construct permissions - - // default permissions - anonymous user - - $sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' "; - - $r = q("SELECT COUNT(*) AS `total` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 - AND `item`.`deleted` = 0 AND `item`.`type` = 'note' - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1 - AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0 - $sql_extra ", - intval(local_user()) - - ); - - if(count($r)) { - $a->set_pager_total($r[0]['total']); - $a->set_pager_itemspage(40); - } - - $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - and `item`.`moderated` = 0 AND `item`.`type` = 'note' - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1 - AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0 - $sql_extra - ORDER BY `item`.`created` DESC LIMIT %d ,%d ", - intval(local_user()), - intval($a->pager['start']), - intval($a->pager['itemspage']) - - ); - - $parents_arr = array(); - $parents_str = ''; - - if(count($r)) { - foreach($r as $rr) - $parents_arr[] = $rr['item_id']; - $parents_str = implode(', ', $parents_arr); - - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`, - `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, - `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` IN ( %s ) - $sql_extra - ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ", - intval(local_user()), - dbesc($parents_str) - ); - - if(count($r)) { - $items = conv_sort($r,"`commented`"); - - $o .= conversation($a,$items,'notes',$update); - } - } - - - $o .= paginate($a); - return $o; -} diff --git a/mod/openid.php b/mod/openid.php deleted file mode 100644 index e2cea7d85..000000000 --- a/mod/openid.php +++ /dev/null @@ -1,96 +0,0 @@ -validate()) { - - $authid = normalise_openid($_REQUEST['openid_identity']); - - if(! strlen($authid)) { - logger( t('OpenID protocol error. No ID returned.') . EOL); - goaway(z_root()); - } - - $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey` - FROM `user` WHERE `openid` = '%s' AND `blocked` = 0 - AND `account_expired` = 0 AND `verified` = 1 LIMIT 1", - dbesc($authid) - ); - - if($r && count($r)) { - - // successful OpenID login - - unset($_SESSION['openid']); - - require_once('include/security.php'); - authenticate_success($r[0],true,true); - - // just in case there was no return url set - // and we fell through - - goaway(z_root()); - } - - // Successful OpenID login - but we can't match it to an existing account. - // New registration? - - if($a->config['register_policy'] == REGISTER_CLOSED) { - notice( t('Account not found and OpenID registration is not permitted on this site.') . EOL); - goaway(z_root()); - } - - unset($_SESSION['register']); - $args = ''; - $attr = $openid->getAttributes(); - if(is_array($attr) && count($attr)) { - foreach($attr as $k => $v) { - if($k === 'namePerson/friendly') - $nick = notags(trim($v)); - if($k === 'namePerson/first') - $first = notags(trim($v)); - if($k === 'namePerson') - $args .= '&username=' . notags(trim($v)); - if($k === 'contact/email') - $args .= '&email=' . notags(trim($v)); - if($k === 'media/image/aspect11') - $photosq = bin2hex(trim($v)); - if($k === 'media/image/default') - $photo = bin2hex(trim($v)); - } - } - if($nick) - $args .= '&nickname=' . $nick; - elseif($first) - $args .= '&nickname=' . $first; - - if($photosq) - $args .= '&photo=' . $photosq; - elseif($photo) - $args .= '&photo=' . $photo; - - $args .= '&openid_url=' . notags(trim($authid)); - - goaway($a->get_baseurl() . '/register' . $args); - - // NOTREACHED - } - } - notice( t('Login failed.') . EOL); - goaway(z_root()); - // NOTREACHED -} diff --git a/mod/ping.php b/mod/ping.php index cf4b65c90..da612a255 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -47,7 +47,7 @@ function ping_init(&$a) { killme(); } - if($argc() > 1 && $argv(1) === 'notify') { + if(argc() > 1 && argv(1) === 'notify') { $t = q("select count(*) as total from notify where uid = %d and seen = 0", intval(local_user()) ); diff --git a/mod/profile.php b/mod/profile.php index af8f684b3..a562b37cc 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -20,42 +20,14 @@ function profile_init(&$a) { $profile = 0; - if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) { - $which = $a->user['nickname']; - $profile = $a->argv[1]; + if((local_user()) && (argc() > 2) && (argv(2) === 'view')) { + $which = $a->identity['entity_address']; + $profile = argv(1); } profile_load($a,$which,$profile); - $userblock = (($a->profile['hidewall'] && (! local_user()) && (! remote_user())) ? true : false); - - if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) { - $a->page['htmlhead'] .= ''; - } - if(x($a->profile,'openidserver')) - $a->page['htmlhead'] .= '' . "\r\n"; - if(x($a->profile,'openid')) { - $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']); - $a->page['htmlhead'] .= '' . "\r\n"; - } - // site block - if((! $blocked) && (! $userblock)) { - $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : ''); - $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords); - if(strlen($keywords)) - $a->page['htmlhead'] .= '' . "\r\n" ; - } - - $a->page['htmlhead'] .= '' . "\r\n" ; - $a->page['htmlhead'] .= '' . "\r\n" ; - $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); - $a->page['htmlhead'] .= '' . "\r\n"; - header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); - - $dfrn_pages = array('request', 'confirm', 'notify', 'poll'); - foreach($dfrn_pages as $dfrn) - $a->page['htmlhead'] .= "get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n"; - $a->page['htmlhead'] .= "get_baseurl()."/poco/{$which}\" />\r\n"; + $a->page['htmlhead'] .= '' . "\r\n" ; } @@ -64,16 +36,16 @@ function profile_content(&$a, $update = 0) { $category = $datequery = $datequery2 = ''; - if($a->argc > 2) { - for($x = 2; $x < $a->argc; $x ++) { - if(is_a_date_arg($a->argv[$x])) { + if(argc() > 2) { + for($x = 2; $x < argc(); $x ++) { + if(is_a_date_arg(argv($x))) { if($datequery) - $datequery2 = escape_tags($a->argv[$x]); + $datequery2 = escape_tags(argv($x)); else - $datequery = escape_tags($a->argv[$x]); + $datequery = escape_tags(argv($x)); } else - $category = $a->argv[$x]; + $category = argv($x); } } @@ -81,7 +53,7 @@ function profile_content(&$a, $update = 0) { $category = ((x($_GET,'category')) ? $_GET['category'] : ''); } - if(get_config('system','block_public') && (! local_user()) && (! remote_user())) { + if(get_config('system','block_public') && (! get_account_id()) && (! remote_user())) { return login(); } @@ -157,9 +129,6 @@ function profile_content(&$a, $update = 0) { $o .= common_friends_visitor_widget($a->profile['profile_uid']); - if(x($_SESSION,'new_member') && $_SESSION['new_member'] && $is_owner) - $o .= '' . t('Tips for New Members') . '' . EOL; - $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false); $commvisitor = (($commpage && $remote_contact == true) ? true : false); @@ -223,20 +192,7 @@ function profile_content(&$a, $update = 0) { $sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); } - if(! get_pconfig($a->profile['profile_uid'],'system','alt_pager')) { - $r = q("SELECT COUNT(*) AS `total` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1 - $sql_extra $sql_extra2 ", - intval($a->profile['profile_uid']) - ); - - if(count($r)) { - $a->set_pager_total($r[0]['total']); - } - } + $a->set_pager_itemspage(40); $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); @@ -254,13 +210,9 @@ function profile_content(&$a, $update = 0) { } - $parents_arr = array(); - $parents_str = ''; - if(count($r)) { - foreach($r as $rr) - $parents_arr[] = $rr['item_id']; - $parents_str = implode(', ', $parents_arr); + + $parents_str = ids_to_querystr($r,'item_id'); $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`, @@ -305,14 +257,8 @@ function profile_content(&$a, $update = 0) { $o .= conversation($a,$items,'profile',$update); - if(! $update) { - if(! get_pconfig($a->profile['profile_uid'],'system','alt_pager')) { - $o .= paginate($a); - } - else { - $o .= alt_pager($a,count($items)); - } - } + if(! $update) + $o .= alt_pager($a,count($items)); return $o; } diff --git a/mod/pubsub.php b/mod/pubsub.php deleted file mode 100644 index 33d26d553..000000000 --- a/mod/pubsub.php +++ /dev/null @@ -1,153 +0,0 @@ -argc > 1) ? notags(trim($a->argv[1])) : ''); - $contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 ); - - if($_SERVER['REQUEST_METHOD'] === 'GET') { - - $hub_mode = ((x($_GET,'hub_mode')) ? notags(trim($_GET['hub_mode'])) : ''); - $hub_topic = ((x($_GET,'hub_topic')) ? notags(trim($_GET['hub_topic'])) : ''); - $hub_challenge = ((x($_GET,'hub_challenge')) ? notags(trim($_GET['hub_challenge'])) : ''); - $hub_lease = ((x($_GET,'hub_lease_seconds')) ? notags(trim($_GET['hub_lease_seconds'])) : ''); - $hub_verify = ((x($_GET,'hub_verify_token')) ? notags(trim($_GET['hub_verify_token'])) : ''); - - logger('pubsub: Subscription from ' . $_SERVER['REMOTE_ADDR']); - logger('pubsub: data: ' . print_r($_GET,true), LOGGER_DATA); - - $subscribe = (($hub_mode === 'subscribe') ? 1 : 0); - - $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 LIMIT 1", - dbesc($nick) - ); - if(! count($r)) { - logger('pubsub: local account not found: ' . $nick); - hub_return(false, ''); - } - - - $owner = $r[0]; - - $sql_extra = ((strlen($hub_verify)) ? sprintf(" AND `hub-verify` = '%s' ", dbesc($hub_verify)) : ''); - - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d - AND `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1", - intval($contact_id), - intval($owner['uid']) - ); - if(! count($r)) { - logger('pubsub: contact not found.'); - hub_return(false, ''); - } - - if(! link_compare($hub_topic,$r[0]['poll'])) { - logger('pubsub: hub topic ' . $hub_topic . ' != ' . $r[0]['poll']); - // should abort but let's humour them. - } - - $contact = $r[0]; - - // We must initiate an unsubscribe request with a verify_token. - // Don't allow outsiders to unsubscribe us. - - if($hub_mode === 'unsubscribe') { - if(! strlen($hub_verify)) { - logger('pubsub: bogus unsubscribe'); - hub_return(false, ''); - } - logger('pubsub: unsubscribe success'); - } - - $r = q("UPDATE `contact` SET `subhub` = %d WHERE `id` = %d LIMIT 1", - intval($subscribe), - intval($contact['id']) - ); - - hub_return(true, $hub_challenge); - } -} - -require_once('include/security.php'); - -function pubsub_post(&$a) { - - $xml = file_get_contents('php://input'); - - logger('pubsub: feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $a->cmd ); - logger('pubsub: user-agent: ' . $_SERVER['HTTP_USER_AGENT'] ); - logger('pubsub: data: ' . $xml, LOGGER_DATA); - -// if(! stristr($xml,'argc > 1) ? notags(trim($a->argv[1])) : ''); - $contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 ); - - $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 LIMIT 1", - dbesc($nick) - ); - if(! count($r)) - hub_post_return(); - - $importer = $r[0]; - - $r = q("SELECT * FROM `contact` WHERE `subhub` = 1 AND `id` = %d AND `uid` = %d - AND ( `rel` = %d OR `rel` = %d ) AND `blocked` = 0 AND `readonly` = 0 LIMIT 1", - intval($contact_id), - intval($importer['uid']), - intval(CONTACT_IS_SHARING), - intval(CONTACT_IS_FRIEND) - ); - - if(! count($r)) { - logger('pubsub: no contact record - ignored'); - hub_post_return(); - } - - $contact = $r[0]; - - $feedhub = ''; - - require_once('include/items.php'); - - consume_feed($xml,$importer,$contact,$feedhub,1,1); - - // do it a second time so that any children find their parents. - - consume_feed($xml,$importer,$contact,$feedhub,1,2); - - hub_post_return(); - -} - - - diff --git a/mod/rsd_xml.php b/mod/rsd_xml.php index 5bf4663fd..f4984f0f0 100644 --- a/mod/rsd_xml.php +++ b/mod/rsd_xml.php @@ -7,8 +7,8 @@ function rsd_xml_content(&$a) { echo ' - Friendika - http://friendika.com/ + Friendica + http://friendica.com/ diff --git a/mod/salmon.php b/mod/salmon.php deleted file mode 100644 index 1e16f9d14..000000000 --- a/mod/salmon.php +++ /dev/null @@ -1,229 +0,0 @@ -= 400) - $err = 'Error'; - if($val >= 200 && $val < 300) - $err = 'OK'; - - logger('mod-salmon returns ' . $val); - header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err); - killme(); - -} - -function salmon_post(&$a) { - - $xml = file_get_contents('php://input'); - - logger('mod-salmon: new salmon ' . $xml, LOGGER_DATA); - - $nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : ''); - $mentions = (($a->argc > 2 && $a->argv[2] === 'mention') ? true : false); - - $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 LIMIT 1", - dbesc($nick) - ); - if(! count($r)) - http_status_exit(500); - - $importer = $r[0]; - - // parse the xml - - $dom = simplexml_load_string($xml,'SimpleXMLElement',0,NAMESPACE_SALMON_ME); - - // figure out where in the DOM tree our data is hiding - - if($dom->provenance->data) - $base = $dom->provenance; - elseif($dom->env->data) - $base = $dom->env; - elseif($dom->data) - $base = $dom; - - if(! $base) { - logger('mod-salmon: unable to locate salmon data in xml '); - http_status_exit(400); - } - - // Stash the signature away for now. We have to find their key or it won't be good for anything. - - - $signature = base64url_decode($base->sig); - - // unpack the data - - // strip whitespace so our data element will return to one big base64 blob - $data = str_replace(array(" ","\t","\r","\n"),array("","","",""),$base->data); - - // stash away some other stuff for later - - $type = $base->data[0]->attributes()->type[0]; - $keyhash = $base->sig[0]->attributes()->keyhash[0]; - $encoding = $base->encoding; - $alg = $base->alg; - - // Salmon magic signatures have evolved and there is no way of knowing ahead of time which - // flavour we have. We'll try and verify it regardless. - - $stnet_signed_data = $data; - - $signed_data = $data . '.' . base64url_encode($type) . '.' . base64url_encode($encoding) . '.' . base64url_encode($alg); - - $compliant_format = str_replace('=','',$signed_data); - - - // decode the data - $data = base64url_decode($data); - - // Remove the xml declaration - $data = preg_replace('/\<\?xml[^\?].*\?\>/','',$data); - - // Create a fake feed wrapper so simplepie doesn't choke - - $tpl = get_markup_template('fake_feed.tpl'); - - $base = substr($data,strpos($data,''; - - logger('mod-salmon: Processed feed: ' . $feedxml); - - // Now parse it like a normal atom feed to scrape out the author URI - - $feed = new SimplePie(); - $feed->set_raw_data($feedxml); - $feed->enable_order_by_date(false); - $feed->init(); - - logger('mod-salmon: Feed parsed.'); - - if($feed->get_item_quantity()) { - foreach($feed->get_items() as $item) { - $author = $item->get_author(); - $author_link = unxmlify($author->get_link()); - break; - } - } - - if(! $author_link) { - logger('mod-salmon: Could not retrieve author URI.'); - http_status_exit(400); - } - - // Once we have the author URI, go to the web and try to find their public key - - logger('mod-salmon: Fetching key for ' . $author_link ); - - - $key = get_salmon_key($author_link,$keyhash); - - if(! $key) { - logger('mod-salmon: Could not retrieve author key.'); - http_status_exit(400); - } - - $key_info = explode('.',$key); - - $m = base64url_decode($key_info[1]); - $e = base64url_decode($key_info[2]); - - logger('mod-salmon: key details: ' . print_r($key_info,true), LOGGER_DEBUG); - - $pubkey = metopem($m,$e); - - // We should have everything we need now. Let's see if it verifies. - - $verify = rsa_verify($compliant_format,$signature,$pubkey); - - if(! $verify) { - logger('mod-salmon: message did not verify using protocol. Trying padding hack.'); - $verify = rsa_verify($signed_data,$signature,$pubkey); - } - - if(! $verify) { - logger('mod-salmon: message did not verify using padding. Trying old statusnet hack.'); - $verify = rsa_verify($stnet_signed_data,$signature,$pubkey); - } - - if(! $verify) { - logger('mod-salmon: Message did not verify. Discarding.'); - http_status_exit(400); - } - - logger('mod-salmon: Message verified.'); - - - /* - * - * If we reached this point, the message is good. Now let's figure out if the author is allowed to send us stuff. - * - */ - - $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s' ) - AND `uid` = %d LIMIT 1", - dbesc(NETWORK_OSTATUS), - dbesc($author_link), - dbesc($author_link), - intval($importer['uid']) - ); - if(! count($r)) { - logger('mod-salmon: Author unknown to us.'); - if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) { - require_once('include/follow.php'); - $result = new_contact($importer['uid'],$author_link); - if($result['success']) { - $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s' ) - AND `uid` = %d LIMIT 1", - dbesc(NETWORK_OSTATUS), - dbesc($author_link), - dbesc($author_link), - intval($importer['uid']) - ); - } - } - } - - // is this a follower? Or have we ignored the person? - // If so we can not accept this post. - - if((count($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) { - logger('mod-salmon: Ignoring this author.'); - http_status_exit(202); - // NOTREACHED - } - - require_once('include/items.php'); - - // Placeholder for hub discovery. We shouldn't find any hubs - // since we supplied the fake feed header - and it doesn't have any. - - $hub = ''; - - /** - * - * anti-spam measure: consume_feed will accept a follow activity from - * this person (and nothing else) if there is no existing contact record. - * - */ - - $contact_rec = ((count($r)) ? $r[0] : null); - - consume_feed($feedxml,$importer,$contact_rec,$hub); - - http_status_exit(200); -} - - - - diff --git a/mod/session.php b/mod/session.php deleted file mode 100644 index 22c855edb..000000000 --- a/mod/session.php +++ /dev/null @@ -1,5 +0,0 @@ -