";
- }
- return $return;
-}
-/* general function to check if one strings starts with a given search */
-function starts_with($string,$search){
- if (substr(strtolower($string),0,strlen($search)) == strtolower($search)){
- return true;
- }
- return false;
-}
-/* general function to check if one strings contains with a given search */
-function contains($string,$search){
- if (is_numeric(strpos(strtolower($string),strtolower($search)))){
- return true;
- }
- return false;
-}
-/* this function fetches the context (the previous posts and replies) of a specified post
- $post = ID of the post.
-*/
-function context($post) {
- global $srv;
- global $token;
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, "https://$srv/api/v1/statuses/$post/context");
- if (!is_null($token)) {
- curl_setopt($curl, CURLOPT_HTTPHEADER, array(
- 'Authorization: Bearer ' . $token
- ));
- }
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- $result = curl_exec($curl);
- curl_close($curl);
- return $result;
-}
+// FUNCTIONS THAT HAVE TO DO WITH INSTANCE COMMUNICATION AND RETRIEVAL
-/* this function just reduces an image to a 1x1 pixel image to get the overall color.
- */
-function averageColor($url) {
- @$image = imagecreatefromstring(file_get_contents($url));
-
- if (!$image) {
- $mainColor = "CCCCCC";
- }
- else {
- $thumb = imagecreatetruecolor(1, 1);
- imagecopyresampled($thumb, $image, 0, 0, 0, 0, 1, 1, imagesx($image) , imagesy($image));
- $mainColor = strtoupper(dechex(imagecolorat($thumb, 0, 0)));
- }
-
- return $mainColor;
-}
-
-/* this function fetches all the data from a profile (bio, username, relationships, etc) */
-function user_info($user) {
- global $user_settings;
- $info = api_get("accounts/" . $user);
- $rel = api_get("accounts/relationships?id=" . $user);
- return array(
- $info,
- $rel
- );
-}
-
-/* a function to make an authenticated general GET api call to the logged-in instance */
+/* a function to make an authenticated general GET api call to the logged-in instance.
+ - $url is a string of an api call like "account/:id/statuses"
+
+ - returns the array conversion of the json response
+ */
function api_get($url) {
global $srv;
global $token;
@@ -190,7 +55,11 @@ function api_getv2($url) {
return json_decode($result, true);
}
-/* a function to make an authenticated general POST api call to the logged-in instance */
+/* a function to make an authenticated general POST api call to the logged-in instance.
+ - $url is a string of an api call like "account/:id/statuses"
+
+ - returns the array conversion of the json response
+ */
function api_post($url, $array) {
global $srv;
global $token;
@@ -212,7 +81,11 @@ function api_post($url, $array) {
return json_decode($result, true);
}
-/* a function to make general DELETE api calls to the logged-in instance*/
+/* a function to make an authenticated general DELETE api call to the logged-in instance.
+ - $url is a string of an api call like "statuses/delete/:id"
+
+ - returns the array conversion of the json response
+ */
function api_delete($url, $array) {
global $srv;
global $token;
@@ -235,7 +108,11 @@ function api_delete($url, $array) {
return json_decode($result, true);
}
-/* a function to make general PATCH api calls to the logged-in instance*/
+/* a function to make an authenticated general PATCH api call to the logged-in instance.
+ - $url is a string of an api call like "account/:id/statuses"
+
+ - returns the array conversion of the json response
+ */
function api_patch($url, $array) {
global $srv;
global $token;
@@ -259,7 +136,10 @@ function api_patch($url, $array) {
}
/* Function to upload files to the profile of the authenticated user
- $type can be 'avatar' or 'header'*/
+ - $type can be 'avatar' or 'header'
+
+ - returns the json of the api call
+ */
function upload_profile($file,$type){
global $srv;
global $token;
@@ -284,6 +164,511 @@ function upload_profile($file,$type){
return $result;
}
+/* this function fetches all the data from a profile (bio, username, relationships, etc)
+ - $user is the id of the queried user
+
+ - returns the array conversion of the json response
+*/
+function user_info($user) {
+ global $user_settings;
+ $info = api_get("accounts/" . $user);
+ $rel = api_get("accounts/relationships?id=" . $user);
+ return array(
+ $info,
+ $rel
+ );
+}
+
+/* this function fetches the context (the previous posts and replies) of a specified post
+ - $post = ID of the post queried.
+
+ - returns an array conversion of the json response
+*/
+function context($post) {
+ global $srv;
+ global $token;
+
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, "https://$srv/api/v1/statuses/$post/context");
+ if (!is_null($token)) {
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array(
+ 'Authorization: Bearer ' . $token
+ ));
+ }
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ $result = curl_exec($curl);
+ curl_close($curl);
+ return $result;
+}
+
+
+/* a function to fav or unfav a specified post
+ - $post = ID of the post queried.
+ - $mode can be true if is a fav or false if it's an unfav
+
+ - returns the number of favs of the post after the specified action or "error"
+ if there was an error performing the action
+*/
+function favourite($post, $mode) {
+ $result = api_post(($mode == true ? "statuses/$post/favourite" : "statuses/$post/unfavourite"),array());
+
+ if (isset($result['favourites_count'])) {
+ return $result['favourites_count'];
+ }
+ else {
+ return "error";
+ }
+}
+
+
+/* a function to reblog or unreblog a specified post
+ - $post = ID of the post queried.
+ - $mode can be true if is a reblog or false if it's an unreblog
+
+ - returns the number of reblogs of the post after the specified action or "error"
+ if there was an error performing the action
+*/
+function reblog($post, $mode) {
+ $result = api_post(($mode == true ? "statuses/$post/reblog" : "statuses/$post/unreblog"),array());
+ if (isset($result['reblog']['reblogs_count'])) {
+ return $result['reblog']['reblogs_count'];
+ }
+ elseif (isset($result['reblogs_count'])) {
+ return $result['reblogs_count'];
+ }
+ else {
+ return "error";
+ }
+}
+
+
+
+/* function to delete a post
+ - $id is the id of the post to delete
+
+ - returns 1 if the post was deleted succesfully or 0 if there was an error
+*/
+function delpost($id) {
+ global $srv;
+ global $token;
+
+ if (!is_null($token)) {
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_HEADER, false);
+ curl_setopt($curl, CURLOPT_POST, 1);
+ curl_setopt($curl, CURLOPT_URL, "https://$srv/api/v1/statuses/$id");
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array(
+ 'Authorization: Bearer ' . $token
+ ));
+
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ $result = curl_exec($curl);
+ curl_close($curl);
+ $result = json_decode($result, true);
+ if (empty($result)) {
+ return "1";
+ }
+ else {
+ return "0";
+ }
+ }
+}
+
+/* function to issue a vote to a poll
+ - $id is the id of the poll to vote on
+
+ - $choices is a comma separated string of the choices that will be voted.
+*/
+function vote($poll, $choices) {
+ global $srv;
+ global $token;
+ if (!is_null($token)) {
+ $cSession = curl_init();
+ curl_setopt($cSession, CURLOPT_URL, "https://$srv/api/v1/polls/$poll/votes");
+ curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($cSession, CURLOPT_POST, 1);
+ curl_setopt($cSession, CURLOPT_HTTPHEADER, array(
+ 'Authorization: Bearer ' . $token
+ ));
+ $query = "";
+ $choicelist = explode(",",$choices);
+ foreach($choicelist as $choice){
+ $query .= "choices[]=$choice&";
+ }
+
+ curl_setopt($cSession, CURLOPT_POSTFIELDS, $query);
+ $result = curl_exec($cSession);
+ curl_close($cSession);
+ return $result;
+ }
+ else {
+ return false;
+ }
+}
+
+
+/* function to send a new post to the logged in instance
+ - $text = the body of the message
+ - $media = array of uploaded media id's
+ - $reply = the id of a post being replied to, can be null.
+ - $markdown = specify if the post uses markdown (unused at this moment)
+ - $scope = the scope of the post (public, private, unlisted or direct)
+ - $sensitive = bool to specify if the post media is sensitive
+ - $spoiler = string of the title of the post
+
+ - returns the json of the api response
+ */
+function sendpost($text, $media, $reply = null, $markdown = false, $scope = "public", $sensitive = false, $spoiler = false) {
+ global $srv;
+ global $token;
+ if (!is_null($token)) {
+
+ $cSession = curl_init();
+ curl_setopt($cSession, CURLOPT_URL, "https://$srv/api/v1/statuses");
+ curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($cSession, CURLOPT_POST, 1);
+ curl_setopt($cSession, CURLOPT_HTTPHEADER, array(
+ 'Authorization: Bearer ' . $token
+ ));
+ $query = "";
+ $query .= "status=" . urlencode(html_entity_decode($text, ENT_QUOTES)) . "&visibility=" . $scope;;
+ if (!is_null($reply) && $reply != "null") {
+ $query .= "&in_reply_to_id=" . $reply;
+ }
+ if ($markdown == true) {
+ $query .= "&content_type=text/markdown";
+ }
+ if ($sensitive == 'true') {
+ $query .= "&sensitive=true";
+ }
+ if ($spoiler == true) {
+ $query .= "&spoiler_text=" . $spoiler;
+ }
+
+ if (!is_null($media)) {
+ foreach ($media as $mid) {
+ $query .= "&media_ids[]=" . $mid;
+ }
+ }
+
+ curl_setopt($cSession, CURLOPT_POSTFIELDS, $query);
+ $result = curl_exec($cSession);
+ curl_close($cSession);
+ return $result;
+ }
+ else {
+ return false;
+ }
+}
+
+/* uploads a file to the logged in instance.
+ - $file = path of the file to upload on local storage
+
+ - returns an array where:
+ 0: the ID of the uploaded file
+ 1: the url of the file (if the file isn't an image, returns a placeholder)
+ */
+function uploadpic($file) {
+ global $srv;
+ global $token;
+ if (!is_null($token)) {
+ $mime = get_mime($file);
+ $info = pathinfo($file);
+ $name = $info['basename'];
+ $output = new CURLFile($file, $mime, $name);
+ $cSession = curl_init();
+ curl_setopt($cSession, CURLOPT_URL, "https://$srv/api/v1/media");
+ curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($cSession, CURLOPT_POST, 1);
+ curl_setopt($cSession, CURLOPT_HTTPHEADER, array(
+ 'Authorization: Bearer ' . $token
+ ));
+ curl_setopt($cSession, CURLOPT_POSTFIELDS, array(
+ 'file' => $output
+ ));
+ $result = curl_exec($cSession);
+ curl_close($cSession);
+ $array = json_decode($result, true);
+
+ $ext = explode(".", $array['url']);
+ $ext = end($ext);
+ $ext = explode("?", $ext) [0];
+
+ if (in_array($ext, array(
+ 'jpg',
+ 'jpeg',
+ 'gif',
+ 'png',
+ 'svg'
+ ))) {
+ $file = $array['url'];
+ }
+ else {
+ $file = "img/doc.png";
+ }
+ return json_encode(array(
+ $array['id'],
+ $file
+ ));
+ }
+ else {
+ return false;
+ }
+}
+
+/* this is used to register DashFE as an application on an instance
+ mostly used when logging in
+ - $instance = the url of the instance where to log in
+
+ - returns the array conversion of the json response
+ */
+function register_app($instance) {
+ global $setting;
+
+ $cSession = curl_init();
+ curl_setopt($cSession, CURLOPT_URL, "https://$instance/api/v1/apps");
+ curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($cSession, CURLOPT_HEADER, false);
+ curl_setopt($cSession, CURLOPT_POST, 1);
+ curl_setopt($cSession, CURLOPT_POSTFIELDS, http_build_query(array(
+ 'client_name' => $setting['appname'],
+ 'redirect_uris' => $setting['url'],
+ 'scopes' => 'read write follow'
+ )));
+ $result = curl_exec($cSession);
+ curl_close($cSession);
+
+ return json_decode($result, true);
+}
+
+/* this function will get all the notes (reblogs and favs) that has an specified post
+ - $thread = the id of the post queried
+
+ - returns an array with all the notes
+ each note is another array where:
+ 0 = type of note ("reb" reblog or "fab" favorite)
+ 1 = array of the details of the user, converted from the json of the api response.
+ */
+function getnotes($thread) {
+ global $user_settings;
+ global $token;
+ global $srv;
+ global $setting;
+ global $logedin;
+ @$reb = array(
+ json_decode(file_get_contents("https://$srv/api/v1/statuses/" . $thread . "/reblogged_by") , true)
+ );
+ @$fab = array(
+ json_decode(file_get_contents("https://$srv/api/v1/statuses/" . $thread . "/favourited_by") , true)
+ );
+ $limit = (count($reb[0]) > count($fab[0]) ? count($reb[0]) - 1 : count($fab[0]) - 1);
+
+ $notes = array();
+ $index = 0;
+
+ for ($i = 0;$i <= $limit;$i++) {
+ if (isset($reb[0][$i])) {
+ $notes[$index][0] = "reb";
+ $notes[$index][1] = $reb[0][$i];
+ $index++;
+ }
+ if (isset($fab[0][$i])) {
+ $notes[$index][0] = "fav";
+ $notes[$index][1] = $fab[0][$i];
+ $index++;
+ }
+ }
+
+ return $notes;
+}
+
+/* this function will fetch replies of a post
+ - $thread = the id of the post from where to fetch replies
+ - $since = id of a post. If specified, the function will fetch the replies
+ only since the specified id.
+
+ - returns an array with all the replies
+ each element is another array where:
+ 'mode' = type of the reply (ancestor or descendant)
+ 'content' = array of the contents of the reply, converted from the json of the api response.
+ */
+function getreplies($thread, $since = false) {
+ global $user_settings;
+ global $token;
+ global $srv;
+ global $setting;
+ global $logedin;
+ $context = json_decode(context($thread) , true);
+ $array = array();
+ if (!empty($context['ancestors'])) {
+ if ($since == false) {
+ foreach ($context['ancestors'] as $elem) {
+ $elem['type'] = 'ancestor';
+ $array[] = $elem;
+ }
+ }
+ }
+ $flag = 0;
+ if (!empty($context['descendants'])) {
+ foreach ($context['descendants'] as $elem) {
+ if (($since != false && $flag == 1) || $since == false) {
+ $elem['type'] = 'descendant';
+ $array[] = $elem;
+ }
+ if ($since != false && $elem['id'] == $since) {
+ $flag = 1;
+ }
+ }
+ }
+
+ $replies = array();
+
+ foreach ($array as $item) {
+ $reply['mode'] = "";
+ if ($item['type'] == 'ancestor') {
+ $reply['mode'] = "ancestor";
+ }
+
+ $replies[] = array(
+ 'mode' => $reply['mode'],
+ 'content' => $item
+ );
+ }
+
+ return $replies;
+}
+
+
+/* this function takes some options from the init.php file and the user_settings cookie
+ and fetches all the posts of the appropiate timeline
+ - $query = an array with a set of elements generated by the file "include/init.php"
+
+ - returns an array of the posts list fetched converted from the json response of the api.
+ */
+function timeline($query) {
+ global $token;
+ global $srv;
+
+ $notes = "";
+
+ $hq = array();
+ $hq['limit'] = 30;
+ $hq['only_media'] = ($query['text'] == "off" ? 'true' : 'false');
+ if ($query['next']){
+ $hq['max_id'] = $query['next'];
+ $next = $query['next'];
+ } elseif ($query['since']) {
+ $hq['since_id'] = $query['since'];
+ }
+
+ switch ($query['mode']) {
+ case "home":
+ $array = api_get("timelines/home?".http_build_query($hq));
+ break;
+
+ case "federated":
+ $array = api_get("timelines/public?".http_build_query($hq));
+ break;
+
+ case "tag":
+ $array = api_get("timelines/tag/" . $query['tag'] . "?".http_build_query($hq));
+ break;
+
+ case "local":
+ $array = api_get("timelines/public?local=true&".http_build_query($hq));
+ break;
+
+ case "user":
+ $array = api_get("accounts/" . $query['user'] . "/statuses?".http_build_query($hq));
+ break;
+
+ case "thread":
+ $array = array(
+ api_get("statuses/" . $query['thread'])
+ );
+ break;
+
+ case "favourites":
+ $array = api_get("favourites?".http_build_query($hq));
+ break;
+
+ case "direct":
+ $array = api_get("timelines/direct?".http_build_query($hq));
+ break;
+
+ case "list":
+ $array = api_get("timelines/list/" . $query['list'] . "?".http_build_query($hq));
+ break;
+
+ case "bookmarks":
+ $array = api_get("bookmarks?".http_build_query($hq));
+ break;
+
+ case "search":
+ $array = api_getv2("search?limit=40&q=".$query['search']."{$next}")['statuses'];
+ break;
+
+ case "account":
+ $info = api_get("accounts/verify_credentials");
+ $array = api_get("accounts/" . $info['id'] . "/statuses?".http_build_query($hq));
+ break;
+
+ default:
+ $array = api_get("timelines/public?".http_build_query($hq));
+ break;
+ }
+
+ if (!is_array($array)) {
+ return false;
+ }
+
+ $next = end($array) ['id'];
+ $thread = array();
+ /*
+ foreach ($array as $elem) {
+ if ($query['replies'] == "on" || $query['mode'] == "thread") {
+ $thread[] = $elem;
+ }
+ else {
+ if ($elem['in_reply_to_id'] == null) {
+ $thread[] = $elem;
+ }
+ }
+
+ }*/
+
+ foreach ($array as $elem) {
+ if ($query['replies'] == "on" || $query['mode'] == "thread") {
+ $thread[] = $elem;
+ }
+ else {
+ if ($elem['in_reply_to_id'] == null || $elem['in_reply_to_account_id'] == $query['uid']) {
+ $thread[] = $elem;
+ } else {
+ $rel = api_get("accounts/relationships?id=" . $elem['in_reply_to_account_id']);
+ if ($rel[0]['following']){
+ $thread[] = $elem;
+ }
+ }
+ }
+
+ }
+
+ return $thread;
+}
+
+
+
+
+
+
+
+
+
+
+// FUNCTIONS THAT HAVE TO DO WITH RENDERING STUFF FOR THE PAGE
+
/* this function is used to generate the html code of a poll */
function renderPoll($elem) {
global $logedin;
@@ -410,204 +795,53 @@ function render_reply($item) {
return $result;
}
-/* a function to fav or unfav a specified post */
-function favourite($post, $mode) {
- $result = api_post(($mode == true ? "statuses/$post/favourite" : "statuses/$post/unfavourite"),array());
-
- if (isset($result['favourites_count'])) {
- return $result['favourites_count'];
- }
- else {
- return "error";
+/* this is the same as above but is used on other places, like user bios and places where the
+shortcodes and the emoji url is defined in the same place */
+function emojify($string, $emojis, $size = 40) {
+ foreach ($emojis as $emoji) {
+ $string = str_replace(":" . $emoji['shortcode'] . ":", "", $string);
}
+ return $string;
}
-/* a function to reblog or unreblog a specified post */
-function reblog($post, $mode) {
- $result = api_post(($mode == true ? "statuses/$post/reblog" : "statuses/$post/unreblog"),array());
- if (isset($result['reblog']['reblogs_count'])) {
- return $result['reblog']['reblogs_count'];
- }
- elseif (isset($result['reblogs_count'])) {
- return $result['reblogs_count'];
- }
- else {
- return "error";
- }
-}
-
-/* function to delete a post */
-function delpost($id) {
- global $srv;
- global $token;
-
- if (!is_null($token)) {
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_HEADER, false);
- curl_setopt($curl, CURLOPT_POST, 1);
- curl_setopt($curl, CURLOPT_URL, "https://$srv/api/v1/statuses/$id");
- curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
- curl_setopt($curl, CURLOPT_HTTPHEADER, array(
- 'Authorization: Bearer ' . $token
- ));
-
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- $result = curl_exec($curl);
- curl_close($curl);
- $result = json_decode($result, true);
- if (empty($result)) {
- return "1";
- }
- else {
- return "0";
+/* This function displays the emoji list of an instance based on a search
+ string given on $val */
+function emoji_list($val){
+ $emojilist = api_get("/custom_emojis");
+ $c = 0;
+ $return = "";
+ foreach ($emojilist as $emoji){
+ if (starts_with($emoji['shortcode'],$val) && $c < 50){
+ $return .= "";
+ $c++;
}
}
-}
-
-function vote($poll, $choices) {
- global $srv;
- global $token;
- if (!is_null($token)) {
- $cSession = curl_init();
- curl_setopt($cSession, CURLOPT_URL, "https://$srv/api/v1/polls/$poll/votes");
- curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($cSession, CURLOPT_POST, 1);
- curl_setopt($cSession, CURLOPT_HTTPHEADER, array(
- 'Authorization: Bearer ' . $token
- ));
- $query = "";
- $choicelist = explode(",",$choices);
- foreach($choicelist as $choice){
- $query .= "choices[]=$choice&";
- }
-
- curl_setopt($cSession, CURLOPT_POSTFIELDS, $query);
- $result = curl_exec($cSession);
- curl_close($cSession);
- return $result;
- }
- else {
- return false;
- }
-}
-
-
-/* function to send a new post to the logged in instance
- it takes the media ids as an array */
-function sendpost($text, $media, $reply, $markdown = false, $scope, $sensitive, $spoiler = false) {
- global $srv;
- global $token;
- if (!is_null($token)) {
-
- $cSession = curl_init();
- curl_setopt($cSession, CURLOPT_URL, "https://$srv/api/v1/statuses");
- curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($cSession, CURLOPT_POST, 1);
- curl_setopt($cSession, CURLOPT_HTTPHEADER, array(
- 'Authorization: Bearer ' . $token
- ));
- $query = "";
- $query .= "status=" . urlencode(html_entity_decode($text, ENT_QUOTES)) . "&visibility=" . $scope;;
- if (!is_null($reply) && $reply != "null") {
- $query .= "&in_reply_to_id=" . $reply;
- }
- if ($markdown == true) {
- $query .= "&content_type=text/markdown";
- }
- if ($sensitive == 'true') {
- $query .= "&sensitive=true";
- }
- if ($spoiler == true) {
- $query .= "&spoiler_text=" . $spoiler;
- }
-
- if (!is_null($media)) {
- foreach ($media as $mid) {
- $query .= "&media_ids[]=" . $mid;
+ if ($c < 50){
+ foreach ($emojilist as $emoji){
+ if ((contains($emoji['shortcode'],$val) && !starts_with($emoji['shortcode'],$val)) && $c < 50){
+ $return .= "";
+ $c++;
}
}
-
- curl_setopt($cSession, CURLOPT_POSTFIELDS, $query);
- $result = curl_exec($cSession);
- curl_close($cSession);
- return $result;
- }
- else {
- return false;
}
+
+ return $return;
}
-/* uploads a file to the logged in instance.
- the function takes the file from the local storage */
-function uploadpic($file) {
- global $srv;
- global $token;
- if (!is_null($token)) {
- $mime = get_mime($file);
- $info = pathinfo($file);
- $name = $info['basename'];
- $output = new CURLFile($file, $mime, $name);
- $cSession = curl_init();
- curl_setopt($cSession, CURLOPT_URL, "https://$srv/api/v1/media");
- curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($cSession, CURLOPT_POST, 1);
- curl_setopt($cSession, CURLOPT_HTTPHEADER, array(
- 'Authorization: Bearer ' . $token
- ));
- curl_setopt($cSession, CURLOPT_POSTFIELDS, array(
- 'file' => $output
- ));
- $result = curl_exec($cSession);
- curl_close($cSession);
- $array = json_decode($result, true);
-
- $ext = explode(".", $array['url']);
- $ext = end($ext);
- $ext = explode("?", $ext) [0];
-
- if (in_array($ext, array(
- 'jpg',
- 'jpeg',
- 'gif',
- 'png',
- 'svg'
- ))) {
- $file = $array['url'];
- }
- else {
- $file = "img/doc.png";
- }
- return json_encode(array(
- $array['id'],
- $file
- ));
+function contact_search($val){
+ global $user_settings;
+ $return = "";
+ $list = api_get("/accounts/search?q=".$val);
+ foreach ($list as $contact){
+ $return .= "
";
}
- else {
+ elseif (in_array($ext,array('jpg','jpeg','png','gif','apng','svg')) || $file['type'] == "image") {
/* we'll either hide the attachment or assign a css class depending on the user's settings */
/* if the post is marked as sensitive and nsfw hiding isn't turned off, we'll blur the image */
@@ -285,6 +285,9 @@ if ((!isset($thread[0]['id']) && !empty($thread)) || !is_array($thread)) {
$post['media'] .= "