X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fapi.php;h=bd579bf19adc3a1dacc0d5f3d9159a5caf0aab18;hb=5d0e7d24babf345431df73472fc0d1c7c80996f9;hp=67e191725897aca3b4ff89aad97038f7c4af82f8;hpb=4a473611163a12b48d3bbad71dc54765be8789f9;p=friendica.git
diff --git a/include/api.php b/include/api.php
index 67e1917258..bd579bf19a 100644
--- a/include/api.php
+++ b/include/api.php
@@ -7,6 +7,7 @@
*/
use Friendica\App;
+use Friendica\Core\System;
use Friendica\Core\Config;
require_once 'include/HTTPExceptions.php';
@@ -96,7 +97,7 @@ $called_api = null;
*
* Register a function to be the endpont for defined API path.
*
- * @param string $path API URL path, relative to App::get_baseurl()
+ * @param string $path API URL path, relative to System::baseUrl()
* @param string $func Function name to call on path request
* @param bool $auth API need logged user
* @param string $method HTTP method reqiured to call this endpoint.
@@ -436,12 +437,12 @@ $called_api = null;
$arr['$user'] = $user_info;
$arr['$rss'] = array(
'alternate' => $user_info['url'],
- 'self' => App::get_baseurl() . "/" . $a->query_string,
- 'base' => App::get_baseurl(),
+ 'self' => System::baseUrl() . "/" . $a->query_string,
+ 'base' => System::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' => System::baseUrl() . "/images/friendica-32.png",
);
return $arr;
@@ -456,10 +457,13 @@ $called_api = null;
* Contact url or False if contact id is unknown
*/
function api_unique_id_to_url($id) {
- $r = q("SELECT `url` FROM `contact` WHERE `uid` = 0 AND `id` = %d LIMIT 1",
- intval($id));
+ $r = dba::select('contact', array('url'), array('uid' => 0, 'id' => $id), array('limit' => 1));
- return (dbm::is_result($r) && $r[0]["url"]);
+ if (dbm::is_result($r)) {
+ return $r["url"];
+ } else {
+ return false;
+ }
}
/**
@@ -480,7 +484,7 @@ $called_api = null;
logger("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG);
// Searching for contact URL
- if (!is_null($contact_id) AND (intval($contact_id) == 0)) {
+ if (!is_null($contact_id) && (intval($contact_id) == 0)) {
$user = dbesc(normalise_link($contact_id));
$url = $user;
$extra_query = "AND `contact`.`nurl` = '%s' ";
@@ -490,7 +494,7 @@ $called_api = null;
}
// Searching for contact id with uid = 0
- if (!is_null($contact_id) AND (intval($contact_id) != 0)) {
+ if (!is_null($contact_id) && (intval($contact_id) != 0)) {
$user = dbesc(api_unique_id_to_url($contact_id));
if ($user == "") {
@@ -535,7 +539,7 @@ $called_api = null;
}
}
- if (is_null($user) AND ($a->argc > (count($called_api) - 1)) AND (count($called_api) > 0)) {
+ if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api);
list($user, $null) = explode(".", $a->argv[$argid]);
if (is_numeric($user)) {
@@ -597,7 +601,7 @@ $called_api = null;
$network_name = network_to_name($r[0]['network'], $r[0]['url']);
// If no nick where given, extract it from the address
- if (($r[0]['nick'] == "") OR ($r[0]['name'] == $r[0]['nick'])) {
+ if (($r[0]['nick'] == "") || ($r[0]['name'] == $r[0]['nick'])) {
$r[0]['nick'] = api_get_nick($r[0]["url"]);
}
@@ -713,7 +717,7 @@ $called_api = null;
$starred = 0;
// Add a nick if it isn't present there
- if (($uinfo[0]['nick'] == "") OR ($uinfo[0]['name'] == $uinfo[0]['nick'])) {
+ if (($uinfo[0]['nick'] == "") || ($uinfo[0]['name'] == $uinfo[0]['nick'])) {
$uinfo[0]['nick'] = api_get_nick($uinfo[0]["url"]);
}
@@ -746,12 +750,12 @@ $called_api = null;
'contributors_enabled' => false,
'is_translator' => false,
'is_translation_enabled' => false,
- 'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) OR ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)),
+ 'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) || ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)),
'follow_request_sent' => false,
'statusnet_blocking' => false,
'notifications' => false,
/// @TODO old way?
- //'statusnet_profile_url' => App::get_baseurl()."/contacts/".$uinfo[0]['cid'],
+ //'statusnet_profile_url' => System::baseUrl()."/contacts/".$uinfo[0]['cid'],
'statusnet_profile_url' => $uinfo[0]['url'],
'uid' => intval($uinfo[0]['uid']),
'cid' => intval($uinfo[0]['cid']),
@@ -774,10 +778,10 @@ $called_api = null;
$status_user = api_get_user($a, $item["author-link"]);
- $status_user["protected"] = (($item["allow_cid"] != "") OR
- ($item["allow_gid"] != "") OR
- ($item["deny_cid"] != "") OR
- ($item["deny_gid"] != "") OR
+ $status_user["protected"] = (($item["allow_cid"] != "") ||
+ ($item["allow_gid"] != "") ||
+ ($item["deny_cid"] != "") ||
+ ($item["deny_gid"] != "") ||
$item["private"]);
if ($item['thr-parent'] == $item['uri']) {
@@ -1161,8 +1165,8 @@ $called_api = null;
if (dbm::is_result($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=' . System::baseUrl() . '/photos/' . $r[0]['nickname'] . '/image/' . $r[0]['resource-id'] . ']';
+ $_REQUEST['body'] .= '[img]' . System::baseUrl() . '/photo/' . $r[0]['resource-id'] . '-' . $r[0]['scale'] . '.' . $ext . '[/img][/url]';
}
}
@@ -1302,9 +1306,9 @@ $called_api = null;
$status_info["entities"] = $converted["entities"];
}
- if (($lastwall['item_network'] != "") AND ($status["source"] == 'web')) {
+ if (($lastwall['item_network'] != "") && ($status["source"] == 'web')) {
$status_info["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
- } elseif (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
+ } elseif (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $status_info["source"])) {
$status_info["source"] = trim($status_info["source"].' ('.network_to_name($lastwall['item_network'], $user_info['url']).')');
}
@@ -1390,11 +1394,11 @@ $called_api = null;
$user_info["status"]["entities"] = $converted["entities"];
}
- if (($lastwall['item_network'] != "") AND ($user_info["status"]["source"] == 'web')) {
+ if (($lastwall['item_network'] != "") && ($user_info["status"]["source"] == 'web')) {
$user_info["status"]["source"] = network_to_name($lastwall['item_network'], $user_info['url']);
}
- if (($lastwall['item_network'] != "") AND (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
+ if (($lastwall['item_network'] != "") && (network_to_name($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) {
$user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . network_to_name($lastwall['item_network'], $user_info['url']) . ')');
}
@@ -1814,7 +1818,7 @@ $called_api = null;
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
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 NOT `item`.`private` AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
$sql_extra
AND `item`.`id`=%d",
@@ -1926,7 +1930,7 @@ $called_api = null;
$start = $page * $count;
// Ugly code - should be changed
- $myurl = App::get_baseurl() . '/profile/'. $a->user['nickname'];
+ $myurl = System::baseUrl() . '/profile/'. $a->user['nickname'];
$myurl = substr($myurl,strpos($myurl, '://') + 3);
//$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
$myurl = str_replace('www.', '', $myurl);
@@ -2175,7 +2179,7 @@ $called_api = null;
`contact`.`id` AS `cid`
FROM `item`, `contact`
WHERE `item`.`uid` = %d
- AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
+ AND `item`.`visible` = 1 AND `item`.`moderated` = 0 AND `item`.`deleted` = 0
AND `item`.`starred` = 1
AND `contact`.`id` = `item`.`contact-id`
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
@@ -2229,7 +2233,7 @@ $called_api = null;
//don't send title to regular StatusNET requests to avoid confusing these apps
if (x($_GET, 'getText')) {
- $ret['title'] = $item['title'] ;
+ $ret['title'] = $item['title'];
if ($_GET['getText'] == 'html') {
$ret['text'] = bbcode($item['body'], false, false);
} elseif ($_GET['getText'] == 'plain') {
@@ -2260,30 +2264,49 @@ $called_api = null;
$statustitle = trim($item['title']);
- if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false)) {
+ if (($statustitle != '') && (strpos($statusbody, $statustitle) !== false)) {
$statustext = trim($statusbody);
} else {
$statustext = trim($statustitle."\n\n".$statusbody);
}
- if (($item["network"] == NETWORK_FEED) and (strlen($statustext)> 1000)) {
+ if (($item["network"] == NETWORK_FEED) && (strlen($statustext)> 1000)) {
$statustext = substr($statustext, 0, 1000)."... \n".$item["plink"];
}
$statushtml = trim(bbcode($body, false, false));
+ // Workaround for clients with limited HTML parser functionality
$search = array("
", "
", "", "
", "\n", - "\n
", "