+ $profiledata = display_fetchauthor($a, $r[0]);
+
+ if (strstr(normalise_link($profiledata["url"]), normalise_link(App::get_baseurl()))) {
+ $nickname = str_replace(normalise_link(App::get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
+
+ if (($nickname != $a->user["nickname"])) {
+ $r = qu("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
+ INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
+ WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` AND `contact`.`self` LIMIT 1",
+ dbesc($nickname)
+ );
+ if (dbm::is_result($r)) {
+ $profiledata = $r[0];
+ }
+ $profiledata["network"] = NETWORK_DFRN;
+ } else {
+ $profiledata = array();
+ }
+ }
+ } else {
+ $a->error = 404;
+ notice(t('Item not found.') . EOL);
+ return;
+ }
+ }
+
+ profile_load($a, $nick, 0, $profiledata);
+
+}
+
+function display_fetchauthor($a, $item) {
+
+ require_once("include/Contact.php");
+
+ $profiledata = array();
+ $profiledata["uid"] = -1;
+ $profiledata["nickname"] = $item["author-name"];
+ $profiledata["name"] = $item["author-name"];
+ $profiledata["picdate"] = "";
+ $profiledata["photo"] = $item["author-avatar"];
+ $profiledata["url"] = $item["author-link"];
+ $profiledata["network"] = $item["network"];
+
+ // Check for a repeated message
+ $skip = false;
+ $body = trim($item["body"]);
+
+ // Skip if it isn't a pure repeated messages
+ // Does it start with a share?
+ if (!$skip AND strpos($body, "[share") > 0) {
+ $skip = true;
+ }
+ // Does it end with a share?
+ if (!$skip AND (strlen($body) > (strrpos($body, "[/share]") + 8))) {
+ $skip = true;
+ }
+ if (!$skip) {
+ $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
+ // Skip if there is no shared message in there
+ if ($body == $attributes) {
+ $skip = true;
+ }
+ }
+
+ if (!$skip) {
+ $author = "";
+ preg_match("/author='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "") {
+ $profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
+ }
+ preg_match('/author="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "") {
+ $profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
+ }
+ $profile = "";
+ preg_match("/profile='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "") {
+ $profiledata["url"] = $matches[1];
+ }
+ preg_match('/profile="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "") {
+ $profiledata["url"] = $matches[1];
+ }
+ $avatar = "";
+ preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "") {
+ $profiledata["photo"] = $matches[1];
+ }
+ preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "") {
+ $profiledata["photo"] = $matches[1];
+ }
+ $profiledata["nickname"] = $profiledata["name"];
+ $profiledata["network"] = GetProfileUsername($profiledata["url"], "", false, true);
+
+ $profiledata["address"] = "";
+ $profiledata["about"] = "";
+ }
+
+ $profiledata = get_contact_details_by_url($profiledata["url"], local_user(), $profiledata);
+
+ $profiledata["photo"] = App::remove_baseurl($profiledata["photo"]);
+
+ if (local_user()) {
+ if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
+ $profiledata["remoteconnect"] = App::get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
+ }
+ } elseif ($profiledata["network"] == NETWORK_DFRN) {
+ $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
+ $profiledata["remoteconnect"] = $connect;
+ }
+
+ return($profiledata);
+}
+
+function display_content(App $a, $update = 0) {
+
+ if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ notice(t('Public access denied.') . EOL);