5 function noscrape_init(App $a) {
13 if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
14 $which = $a->user['nickname'];
15 $profile = $a->argv[1];
18 profile_load($a,$which,$profile);
20 if (!$a->profile['net-publish'] OR $a->profile['hidewall']) {
21 header('Content-type: application/json; charset=utf-8');
22 $json_info = array("hide" => true);
23 echo json_encode($json_info);
27 $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
28 $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
29 $keywords = explode(',', $keywords);
31 $r = q("SELECT `photo` FROM `contact` WHERE `self` AND `uid` = %d",
32 intval($a->profile['uid']));
35 'fn' => $a->profile['name'],
36 'addr' => $a->profile['addr'],
38 'key' => $a->profile['pubkey'],
39 'homepage' => App::get_baseurl()."/profile/{$which}",
40 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
41 'photo' => $r[0]["photo"],
45 if (is_array($a->profile) AND !$a->profile['hide-friends']) {
46 $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
47 intval($a->profile['uid']));
48 if (dbm::is_result($r)) {
49 $json_info["updated"] = date("c", strtotime($r[0]['updated']));
52 $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
53 AND `network` IN ('%s', '%s', '%s', '')",
54 intval($a->profile['uid']),
56 dbesc(NETWORK_DIASPORA),
57 dbesc(NETWORK_OSTATUS)
59 if (dbm::is_result($r)) {
60 $json_info["contacts"] = intval($r[0]['total']);
64 //These are optional fields.
65 $profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');
66 foreach ($profile_fields as $field) {
67 if (!empty($a->profile[$field])) {
68 $json_info["$field"] = $a->profile[$field];
72 $dfrn_pages = array('request', 'confirm', 'notify', 'poll');
73 foreach ($dfrn_pages as $dfrn) {
74 $json_info["dfrn-{$dfrn}"] = App::get_baseurl()."/dfrn_{$dfrn}/{$which}";
77 //Output all the JSON!
78 header('Content-type: application/json; charset=utf-8');
79 echo json_encode($json_info);