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 'key' => $a->profile['pubkey'],
40 'homepage' => System::baseUrl()."/profile/{$which}",
41 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
42 'photo' => $r[0]["photo"],
46 if (is_array($a->profile) && !$a->profile['hide-friends']) {
47 $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
48 intval($a->profile['uid']));
49 if (dbm::is_result($r)) {
50 $json_info["updated"] = date("c", strtotime($r[0]['updated']));
53 $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
54 AND `network` IN ('%s', '%s', '%s', '')",
55 intval($a->profile['uid']),
57 dbesc(NETWORK_DIASPORA),
58 dbesc(NETWORK_OSTATUS)
60 if (dbm::is_result($r)) {
61 $json_info["contacts"] = intval($r[0]['total']);
65 //These are optional fields.
66 $profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');
67 foreach ($profile_fields as $field) {
68 if (!empty($a->profile[$field])) {
69 $json_info["$field"] = $a->profile[$field];
73 $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
74 foreach ($dfrn_pages as $dfrn) {
75 $json_info["dfrn-{$dfrn}"] = System::baseUrl()."/dfrn_{$dfrn}/{$which}";
78 //Output all the JSON!
79 header('Content-type: application/json; charset=utf-8');
80 echo json_encode($json_info);