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);
25 $r = q("SELECT `photo` FROM `contact` WHERE `self` AND `uid` = %d",
26 intval($a->profile['uid']));
29 'fn' => $a->profile['name'],
30 'addr' => $a->profile['addr'],
31 'nick' => $a->user['nickname'],
32 'key' => $a->profile['pubkey'],
33 'homepage' => $a->get_baseurl()."/profile/{$which}",
34 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
35 'photo' => $r[0]["photo"],
39 if(is_array($a->profile) AND !$a->profile['hide-friends']) {
40 $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
41 intval($a->profile['uid']));
43 $json_info["updated"] = date("c", strtotime($r[0]['updated']));
45 $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
46 AND `network` IN ('%s', '%s', '%s', '')",
47 intval($a->profile['uid']),
49 dbesc(NETWORK_DIASPORA),
50 dbesc(NETWORK_OSTATUS)
53 $json_info["contacts"] = intval($r[0]['total']);
56 //These are optional fields.
57 $profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');
58 foreach($profile_fields as $field)
59 if(!empty($a->profile[$field])) $json_info["$field"] = $a->profile[$field];
61 $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
62 foreach($dfrn_pages as $dfrn)
63 $json_info["dfrn-{$dfrn}"] = $a->get_baseurl()."/dfrn_{$dfrn}/{$which}";
65 //Output all the JSON!
66 header('Content-type: application/json; charset=utf-8');
67 echo json_encode($json_info);