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