X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fapi.php;h=1ec65762028f64a95e616a06d8d32176d6d1d64f;hb=a905522eb58612dfc9e4479998de2bd6477b3868;hp=123a4b9cfe8b425e5e450b746684e4364f10df8a;hpb=724f9c80e79783957d75d011a0393f6d6bb1949e;p=friendica.git diff --git a/include/api.php b/include/api.php index 123a4b9cfe..1ec6576202 100644 --- a/include/api.php +++ b/include/api.php @@ -208,7 +208,7 @@ dbesc(trim($user)), dbesc($encrypted) ); - if(count($r)) + if (dbm::is_result($r)) $record = $r[0]; } @@ -409,12 +409,12 @@ $arr['$user'] = $user_info; $arr['$rss'] = array( 'alternate' => $user_info['url'], - 'self' => App::get_baseurl(). "/". $a->query_string, - 'base' => App::get_baseurl(), + 'self' => $a->get_baseurl(). "/". $a->query_string, + 'base' => $a->get_baseurl(), 'updated' => api_date(null), 'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME), 'language' => $user_info['language'], - 'logo' => App::get_baseurl()."/images/friendica-32.png", + 'logo' => $a->get_baseurl()."/images/friendica-32.png", ); return $arr; @@ -623,7 +623,7 @@ // count friends $r = q("SELECT count(*) as `count` FROM `contact` WHERE `uid` = %d AND `rel` IN ( %d, %d ) - AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0", + AND `self`=0 AND NOT `blocked` AND `hidden`=0", intval($uinfo[0]['uid']), intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND) @@ -632,7 +632,7 @@ $r = q("SELECT count(*) as `count` FROM `contact` WHERE `uid` = %d AND `rel` IN ( %d, %d ) - AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0", + AND `self`=0 AND NOT `blocked` AND `hidden`=0", intval($uinfo[0]['uid']), intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND) @@ -693,7 +693,7 @@ 'follow_request_sent' => false, 'statusnet_blocking' => false, 'notifications' => false, - //'statusnet_profile_url' => App::get_baseurl()."/contacts/".$uinfo[0]['cid'], + //'statusnet_profile_url' => $a->get_baseurl()."/contacts/".$uinfo[0]['cid'], 'statusnet_profile_url' => $uinfo[0]['url'], 'uid' => intval($uinfo[0]['uid']), 'cid' => intval($uinfo[0]['cid']), @@ -1078,8 +1078,8 @@ if ($r) { $phototypes = Photo::supportedTypes(); $ext = $phototypes[$r[0]['type']]; - $_REQUEST['body'] .= "\n\n".'[url='.App::get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']'; - $_REQUEST['body'] .= '[img]'.App::get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]"; + $_REQUEST['body'] .= "\n\n".'[url='.$a->get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']'; + $_REQUEST['body'] .= '[img]'.$a->get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]"; } } @@ -1326,10 +1326,10 @@ if (isset($_GET["q"])) { $r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"])); - if (!count($r)) + if (!dbm::is_result($r)) $r = q("SELECT `id` FROM `contact` WHERE `uid` = 0 AND `nick` = '%s'", dbesc($_GET["q"])); - if (count($r)) { + if (dbm::is_result($r)) { $k = 0; foreach ($r AS $user) { $user_info = api_get_user($a, $user["id"], "json"); @@ -1399,7 +1399,7 @@ `contact`.`id` AS `cid` FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`uid` = %d AND `verb` = '%s' AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` $sql_extra @@ -1476,7 +1476,7 @@ `user`.`nickname`, `user`.`hidewall` FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) STRAIGHT_JOIN `user` ON `user`.`uid` = `item`.`uid` AND NOT `user`.`hidewall` WHERE `verb` = '%s' AND `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated` @@ -1543,7 +1543,7 @@ `contact`.`id` AS `cid` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` AND `item`.`uid` = %d AND `item`.`verb` = '%s' $sql_extra", @@ -1619,7 +1619,7 @@ `contact`.`id` AS `cid` FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`parent` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` AND `item`.`uid` = %d AND `item`.`verb` = '%s' @@ -1673,7 +1673,7 @@ `contact`.`id` AS `cid` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` AND NOT `item`.`private` AND `item`.`allow_cid` = '' AND `item`.`allow`.`gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' @@ -1777,7 +1777,7 @@ $start = $page*$count; // Ugly code - should be changed - $myurl = App::get_baseurl() . '/profile/'. $a->user['nickname']; + $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); @@ -1792,7 +1792,7 @@ `contact`.`id` AS `cid` FROM `item` FORCE INDEX (`uid_id`) STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`uid` = %d AND `verb` = '%s' AND NOT (`item`.`author-link` IN ('https://%s', 'http://%s')) AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` @@ -1866,7 +1866,7 @@ `contact`.`id` AS `cid` FROM `item` FORCE INDEX (`uid_contactid_id`) STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`uid` = %d AND `verb` = '%s' AND `item`.`contact-id` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` @@ -2002,7 +2002,7 @@ AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 AND `item`.`starred` = 1 AND `contact`.`id` = `item`.`contact-id` - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND (NOT `contact`.`blocked` OR `contact`.`pending`) $sql_extra AND `item`.`id`>%d ORDER BY `item`.`id` DESC LIMIT %d ,%d ", @@ -2302,7 +2302,7 @@ $text = preg_replace_callback( "|data:image/([^;]+)[^=]+=*|m", function($match) use ($item) { - return App::get_baseurl()."/display/".$item['guid']; + return $a->get_baseurl()."/display/".$item['guid']; }, $text); return $text; @@ -2436,18 +2436,18 @@ 'religion' => $profile['religion'], 'public_keywords' => $profile['pub_keywords'], 'private_keywords' => $profile['prv_keywords'], - 'likes' => bbcode(api_clean_plain_items($profile['likes']), false, false, 2, true), - 'dislikes' => bbcode(api_clean_plain_items($profile['dislikes']), false, false, 2, true), - 'about' => bbcode(api_clean_plain_items($profile['about']), false, false, 2, true), - 'music' => bbcode(api_clean_plain_items($profile['music']), false, false, 2, true), - 'book' => bbcode(api_clean_plain_items($profile['book']), false, false, 2, true), - 'tv' => bbcode(api_clean_plain_items($profile['tv']), false, false, 2, true), - 'film' => bbcode(api_clean_plain_items($profile['film']), false, false, 2, true), - 'interest' => bbcode(api_clean_plain_items($profile['interest']), false, false, 2, true), - 'romance' => bbcode(api_clean_plain_items($profile['romance']), false, false, 2, true), - 'work' => bbcode(api_clean_plain_items($profile['work']), false, false, 2, true), - 'education' => bbcode(api_clean_plain_items($profile['education']), false, false, 2, true), - 'social_networks' => bbcode(api_clean_plain_items($profile['contact']), false, false, 2, true), + 'likes' => bbcode(api_clean_plain_items($profile['likes']), false, false, 2, false), + 'dislikes' => bbcode(api_clean_plain_items($profile['dislikes']), false, false, 2, false), + 'about' => bbcode(api_clean_plain_items($profile['about']), false, false, 2, false), + 'music' => bbcode(api_clean_plain_items($profile['music']), false, false, 2, false), + 'book' => bbcode(api_clean_plain_items($profile['book']), false, false, 2, false), + 'tv' => bbcode(api_clean_plain_items($profile['tv']), false, false, 2, false), + 'film' => bbcode(api_clean_plain_items($profile['film']), false, false, 2, false), + 'interest' => bbcode(api_clean_plain_items($profile['interest']), false, false, 2, false), + 'romance' => bbcode(api_clean_plain_items($profile['romance']), false, false, 2, false), + 'work' => bbcode(api_clean_plain_items($profile['work']), false, false, 2, false), + 'education' => bbcode(api_clean_plain_items($profile['education']), false, false, 2, false), + 'social_networks' => bbcode(api_clean_plain_items($profile['contact']), false, false, 2, false), 'homepage' => $profile['homepage'], 'users' => null); return $profile; @@ -2648,7 +2648,7 @@ if ($user_info['self'] == 0) $sql_extra = " AND false "; - $r = q("SELECT `nurl` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 $sql_extra", + $r = q("SELECT `nurl` FROM `contact` WHERE `uid` = %d AND NOT `self` AND (NOT `blocked` OR `pending`) $sql_extra", intval(api_user()) ); @@ -2690,7 +2690,7 @@ $name = $a->config['sitename']; $server = $a->get_hostname(); - $logo = App::get_baseurl() . '/images/friendica-64.png'; + $logo = $a->get_baseurl() . '/images/friendica-64.png'; $email = $a->config['admin_email']; $closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false'); $private = (($a->config['system']['block_public']) ? 'true' : 'false'); @@ -2698,7 +2698,7 @@ if($a->config['api_import_size']) $texlimit = string($a->config['api_import_size']); $ssl = (($a->config['system']['have_ssl']) ? 'true' : 'false'); - $sslserver = (($ssl === 'true') ? str_replace('http:','https:',App::get_baseurl()) : ''); + $sslserver = (($ssl === 'true') ? str_replace('http:','https:',$a->get_baseurl()) : ''); $config = array( 'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '', @@ -2755,7 +2755,7 @@ intval(api_user()) ); - if(!dbm::is_result($r)) + if (!dbm::is_result($r)) return; $ids = array(); @@ -3075,7 +3075,7 @@ $photo['album'] = $rr['album']; $photo['filename'] = $rr['filename']; $photo['type'] = $rr['type']; - $thumb = App::get_baseurl()."/photo/".$rr['resource-id']."-".$rr['scale'].".".$typetoext[$rr['type']]; + $thumb = $a->get_baseurl()."/photo/".$rr['resource-id']."-".$rr['scale'].".".$typetoext[$rr['type']]; if ($type == "xml") $data['photo'][] = array("@attributes" => $photo, "1" => $thumb); @@ -3124,11 +3124,11 @@ for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++) $data['photo']['links'][$k.":link"]["@attributes"] = array("type" => $data['photo']['type'], "scale" => $k, - "href" => App::get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]); + "href" => $a->get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]); } else { $data['photo']['link'] = array(); for ($k=intval($data['photo']['minscale']); $k<=intval($data['photo']['maxscale']); $k++) { - $data['photo']['link'][$k] = App::get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]; + $data['photo']['link'][$k] = $a->get_baseurl()."/photo/".$data['photo']['resource-id']."-".$k.".".$typetoext[$data['photo']['type']]; } } unset($data['photo']['resource-id']); @@ -3174,7 +3174,7 @@ intval(api_user()) ); - if ((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN)) + if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN)) throw new BadRequestException("Unknown contact"); $cid = $r[0]['id']; @@ -3526,7 +3526,7 @@ intval($uid), intval($gid)); // error message if specified gid is not in database - if (count($r) == 0) + if (!dbm::is_result($r)) throw new BadRequestException("gid not available"); } else @@ -3581,7 +3581,7 @@ intval($uid), intval($gid)); // error message if specified gid is not in database - if (count($r) == 0) + if (!dbm::is_result($r)) throw new BadRequestException('gid not available'); // get data of the specified group id and group name @@ -3919,7 +3919,9 @@ $profile_url = $user_info["url"]; // message if nothing was found - if (count($r) == 0) + if (!dbm::is_result($r)) + $success = array('success' => false, 'search_results' => 'problem with query'); + else if (count($r) == 0) $success = array('success' => false, 'search_results' => 'nothing found'); else { $ret = Array(); @@ -3941,7 +3943,6 @@ } api_register_func('api/friendica/direct_messages_search', 'api_friendica_direct_messages_search', true); - /** * @brief return data of all the profiles a user has to the client * @@ -3966,7 +3967,7 @@ intval(api_user()), intval($profileid)); // error message if specified gid is not in database - if (count($r) == 0) + if (!dbm::is_result($r)) throw new BadRequestException("profile_id not available"); } else