define('API_METHOD_DELETE', 'POST,DELETE');
$API = [];
-$called_api = null;
+$called_api = [];
/**
* It is not sufficient to use local_user() to check whether someone is allowed to use the API,
*
* @return string The XML data
*/
-function api_create_xml($data, $root_element)
+function api_create_xml(array $data, $root_element)
{
$childname = key($data);
$data2 = array_pop($data);
$i = 1;
foreach ($data2 as $item) {
- $data4[$i++.":".$childname] = $item;
+ $data4[$i++ . ":" . $childname] = $item;
}
$data2 = $data4;
}
// this should output the last post (the one we just posted).
- $called_api = null;
+ $called_api = [];
return api_status_show($type);
}
*
* @param string $body
*
- * @return array|false
+ * @return array
*/
function api_get_attachments(&$body)
{
$ret = preg_match_all("/\[img\]([$URLSearchString]*)\[\/img\]/ism", $text, $images);
if (!$ret) {
- return false;
+ return [];
}
$attachments = [];
throw new InternalServerErrorException("unknown error - this error on uploading or updating a photo should never happen");
}
-
/**
* @brief delete a single photo from the database through api
*
} else {
throw new InternalServerErrorException('Unsupported filetype');
}
+
// change specified profile or all profiles to the new resource-id
if ($is_default_profile) {
$condition = ["`profile` AND `resource-id` != ? AND `uid` = ?", $data['photo']['id'], api_user()];
Contact::updateSelfFromUserID(api_user(), true);
// Update global directory in background
- //$user = api_get_user(get_app());
$url = System::baseUrl() . '/profile/' . get_app()->user['nickname'];
if ($url && strlen(Config::get('system', 'directory'))) {
Worker::add(PRIORITY_LOW, "Directory", $url);
/**
*
- * @param string $Text
+ * @param string $text
*
* @return string
*/
-function api_clean_plain_items($Text)
+function api_clean_plain_items($text)
{
$include_entities = strtolower(x($_REQUEST, 'include_entities') ? $_REQUEST['include_entities'] : "false");
- $Text = BBCode::cleanPictureLinks($Text);
+ $text = BBCode::cleanPictureLinks($text);
$URLSearchString = "^\[\]";
- $Text = preg_replace("/([!#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
+ $text = preg_replace("/([!#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $text);
if ($include_entities == "true") {
- $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url=$1]$1[/url]', $Text);
+ $text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url=$1]$1[/url]', $text);
}
// Simplify "attachment" element
- $Text = api_clean_attachments($Text);
+ $text = api_clean_attachments($text);
- return($Text);
+ return $text;
}
/**