4 use Friendica\Core\System;
6 function noscrape_init(App $a) {
14 if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
15 $which = $a->user['nickname'];
16 $profile = $a->argv[1];
19 profile_load($a,$which,$profile);
21 if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
22 header('Content-type: application/json; charset=utf-8');
23 $json_info = array("hide" => true);
24 echo json_encode($json_info);
28 $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
29 $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
30 $keywords = explode(',', $keywords);
32 $r = q("SELECT `photo` FROM `contact` WHERE `self` AND `uid` = %d",
33 intval($a->profile['uid']));
36 'fn' => $a->profile['name'],
37 'addr' => $a->profile['addr'],
39 'guid' => $a->profile['guid'],
40 'key' => $a->profile['pubkey'],
41 'homepage' => System::baseUrl()."/profile/{$which}",
42 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
43 'photo' => $r[0]["photo"],
47 if (is_array($a->profile) && !$a->profile['hide-friends']) {
48 $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
49 intval($a->profile['uid']));
50 if (dbm::is_result($r)) {
51 $json_info["updated"] = date("c", strtotime($r[0]['updated']));
54 $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0
55 AND `network` IN ('%s', '%s', '%s', '')",
56 intval($a->profile['uid']),
58 dbesc(NETWORK_DIASPORA),
59 dbesc(NETWORK_OSTATUS)
61 if (dbm::is_result($r)) {
62 $json_info["contacts"] = intval($r[0]['total']);
66 //These are optional fields.
67 $profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');
68 foreach ($profile_fields as $field) {
69 if (!empty($a->profile[$field])) {
70 $json_info["$field"] = $a->profile[$field];
74 $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
75 foreach ($dfrn_pages as $dfrn) {
76 $json_info["dfrn-{$dfrn}"] = System::baseUrl()."/dfrn_{$dfrn}/{$which}";
79 //Output all the JSON!
80 header('Content-type: application/json; charset=utf-8');
81 echo json_encode($json_info);