3 function noscrape_init(&$a) {
11 if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
12 $which = $a->user['nickname'];
13 $profile = $a->argv[1];
16 profile_load($a,$which,$profile);
18 if(!$a->profile['net-publish'])
21 $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
22 $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
23 $keywords = explode(',', $keywords);
26 'fn' => $a->profile['name'],
27 'key' => $a->profile['pubkey'],
28 'homepage' => $a->get_baseurl()."/profile/{$which}",
29 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
30 'photo' => $a->profile['photo'],
34 if(is_array($a->profile) AND !$a->profile['hide-friends']) {
35 $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
36 intval($a->profile['uid']));
38 $json_info["updated"] = date("c", strtotime($r[0]['updated']));
40 $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
41 AND `network` IN ('%s', '%s', '%s', '')",
42 intval($a->profile['uid']),
44 dbesc(NETWORK_DIASPORA),
45 dbesc(NETWORK_OSTATUS)
48 $json_info["contacts"] = intval($r[0]['total']);
51 //These are optional fields.
52 $profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');
53 foreach($profile_fields as $field)
54 if(!empty($a->profile[$field])) $json_info["$field"] = $a->profile[$field];
56 $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
57 foreach($dfrn_pages as $dfrn)
58 $json_info["dfrn-{$dfrn}"] = $a->get_baseurl()."/dfrn_{$dfrn}/{$which}";
60 //Output all the JSON!
61 header('Content-type: application/json; charset=utf-8');
62 echo json_encode($json_info);