/** * * http://developer.twitter.com/doc/get/statuses/mentions * */ function api_statuses_mentions(&$a, $type) { if (api_user() === false) { return false; } unset($_REQUEST["user_id"]); unset($_GET["user_id"]); unset($_REQUEST["screen_name"]); unset($_GET["screen_name"]); $user_info = api_get_user($a); // get last newtork messages // params $count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 20; $page = x($_REQUEST, 'page') ? $_REQUEST['page'] - 1 : 0; if ($page < 0) { $page = 0; } $since_id = x($_REQUEST, 'since_id') ? $_REQUEST['since_id'] : 0; $max_id = x($_REQUEST, 'max_id') ? $_REQUEST['max_id'] : 0; //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); $start = $page * $count; // Ugly code - should be changed $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname']; $myurl = substr($myurl, strpos($myurl, '://') + 3); //$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $myurl = str_replace('www.', '', $myurl); $diasp_url = str_replace('/profile/', '/u/', $myurl); if ($max_id > 0) { $sql_extra = ' AND `item`.`id` <= ' . intval($max_id); } $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,\n\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,\n\t\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,\n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item`, `contact`\n\t\t\tWHERE `item`.`uid` = %d AND `verb` = '%s'\n\t\t\tAND NOT (`item`.`author-link` IN ('https://%s', 'http://%s'))\n\t\t\tAND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0\n\t\t\tAND `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tAND `item`.`parent` IN (SELECT `iid` from thread where uid = %d AND `mention` AND !`ignored`)\n\t\t\t{$sql_extra}\n\t\t\tAND `item`.`id`>%d\n\t\t\tORDER BY `item`.`id` DESC LIMIT %d ,%d ", intval(api_user()), dbesc(ACTIVITY_POST), dbesc(protect_sprintf($myurl)), dbesc(protect_sprintf($myurl)), intval(api_user()), intval($since_id), intval($start), intval($count)); $ret = api_format_items($r, $user_info); $data = array('$statuses' => $ret); switch ($type) { case "atom": case "rss": $data = api_rss_extra($a, $data, $user_info); break; case "as": $as = api_format_as($a, $ret, $user_info); $as["title"] = $a->config['sitename'] . " Mentions"; $as['link']['url'] = $a->get_baseurl() . "/"; return $as; break; } return api_apply_template("timeline", $type, $data); }
function api_favorites(&$a, $type) { if (api_user() === false) { return false; } $user_info = api_get_user($a); // params $count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 20; $page = x($_REQUEST, 'page') ? $_REQUEST['page'] - 1 : 0; if ($page < 0) { $page = 0; } $since_id = x($_REQUEST, 'since_id') ? $_REQUEST['since_id'] : 0; $max_id = x($_REQUEST, 'max_id') ? $_REQUEST['max_id'] : 0; $exclude_replies = x($_REQUEST, 'exclude_replies') ? 1 : 0; $start = $page * $count; //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); $sql_extra = ''; if ($max_id > 0) { $sql_extra .= ' AND `item`.`id` <= ' . intval($max_id); } if ($exclude_replies > 0) { $sql_extra .= ' AND `item`.`parent` = `item`.`id`'; } if (api_user() != $user_info['uid']) { $observer = get_app()->get_observer(); require_once 'include/permissions.php'; if (!perm_is_allowed($user_info['uid'], $observer ? $observer['xchan_hash'] : '', 'view_stream')) { return ''; } $sql_extra .= " and item_private = 0 "; } $item_normal = item_normal(); $r = q("SELECT * from item WHERE uid = %d {$item_normal}\n\t\t\tand item_starred = 1 {$sql_extra}\n\t\t\tAND id > %d\n\t\t\tORDER BY received DESC LIMIT %d ,%d ", intval($user_info['uid']), intval($since_id), intval($start), intval($count)); xchan_query($r, true); $ret = api_format_items($r, $user_info); $data = array('$statuses' => $ret); switch ($type) { case "atom": case "rss": $data = api_rss_extra($a, $data, $user_info); break; case "as": $as = api_format_as($a, $ret, $user_info); $as['title'] = $a->config['sitename'] . " Home Timeline"; $as['link']['url'] = $a->get_baseurl() . "/" . $user_info["screen_name"] . "/all"; return $as; break; } return api_apply_template("timeline", $type, $data); }
/** * * http://developer.twitter.com/doc/get/statuses/mentions * */ function api_statuses_mentions(&$a, $type) { if (api_user() === false) { return false; } $user_info = api_get_user($a); // get last newtork messages // params $count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 20; $page = x($_REQUEST, 'page') ? $_REQUEST['page'] - 1 : 0; if ($page < 0) { $page = 0; } $since_id = x($_REQUEST, 'since_id') ? $_REQUEST['since_id'] : 0; $max_id = x($_REQUEST, 'max_id') ? $_REQUEST['max_id'] : 0; //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0); $start = $page * $count; //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false); $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname']; $myurl = substr($myurl, strpos($myurl, '://') + 3); //$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $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 . ']%')) ); */ $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)", dbesc(protect_sprintf($myurl)), dbesc(protect_sprintf($myurl))); if ($max_id > 0) { $sql_extra .= ' AND `item`.`id` <= ' . intval($max_id); } $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,\n\t\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,\n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item`, `contact`\n\t\t\tWHERE `item`.`uid` = %d\n\t\t\tAND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0\n\t\t\tAND `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t{$sql_extra}\n\t\t\tAND `item`.`id`>%d\n\t\t\tORDER BY `item`.`received` DESC LIMIT %d ,%d ", intval($user_info['uid']), intval($since_id), intval($start), intval($count)); $ret = api_format_items($r, $user_info); $data = array('$statuses' => $ret); switch ($type) { case "atom": case "rss": $data = api_rss_extra($a, $data, $user_info); break; case "as": $as = api_format_as($a, $ret, $user_info); $as["title"] = $a->config['sitename'] . " Mentions"; $as['link']['url'] = $a->get_baseurl() . "/"; return $as; break; } return api_apply_template("timeline", $type, $data); }