function suggest_content(&$a) { require_once "mod/proxy.php"; $o = ''; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= follow_widget(); $r = suggestion_query(local_user()); if (!count($r)) { $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.'); return $o; } require_once 'include/contact_selectors.php'; foreach ($r as $rr) { $connlnk = $a->get_baseurl() . '/follow/?url=' . ($rr['connect'] ? $rr['connect'] : $rr['url']); $ignlnk = $a->get_baseurl() . '/suggest?ignore=' . $rr['id']; $photo_menu = array(array(t("View Profile"), zrl($rr["url"]))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); $photo_menu[] = array(t('Ignore/Hide'), $ignlnk); $contact_details = get_contact_details_by_url($rr["url"], local_user()); $entry = array('url' => zrl($rr['url']), 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'img_hover' => $rr['url'], 'name' => $rr['name'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'ignlnk' => $ignlnk, 'ignid' => $rr['id'], 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'photo_menu' => $photo_menu, 'ignore' => t('Ignore/Hide'), 'network' => network_to_name($rr['network'], $rr['url']), 'id' => ++$id); $entries[] = $entry; } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('$title' => t('Friend Suggestions'), '$contacts' => $entries)); return $o; }
function dirfind_content(&$a) { $search = notags(trim($_REQUEST['search'])); if (strpos($search, '@') === 0) { $search = substr($search, 1); } $o = ''; $o .= '<h2>' . t('People Search') . ' - ' . $search . '</h2>'; if ($search) { $p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : ''; if (strlen(get_config('system', 'directory_submit_url'))) { $x = fetch_url('http://dir.friendica.com/lsearch?f=' . $p . '&search=' . urlencode($search)); } //TODO fallback local search if global dir not available. // else // $x = post_url($a->get_baseurl() . '/lsearch', $params); $j = json_decode($x); if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $tpl = get_markup_template('match.tpl'); foreach ($j->results as $jj) { $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => $jj->photo, '$tags' => $jj->tags)); } } else { info(t('No matches') . EOL); } } $o .= '<div class="clear"></div>'; $o .= paginate($a); return $o; }
function suggest_content(&$a) { $o = ''; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $a->page['aside'] .= follow_widget(); $a->page['aside'] .= findpeople_widget(); $o .= '<h2>' . t('Friend Suggestions') . '</h2>'; $r = suggestion_query(local_user()); if (!count($r)) { $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.'); return $o; } $tpl = get_markup_template('suggest_friends.tpl'); foreach ($r as $rr) { $connlnk = $a->get_baseurl() . '/follow/?url=' . ($rr['connect'] ? $rr['connect'] : $rr['url']); $o .= replace_macros($tpl, array('$url' => zrl($rr['url']), '$name' => $rr['name'], '$photo' => $rr['photo'], '$ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['id'], '$ignid' => $rr['id'], '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$ignore' => t('Ignore/Hide'))); } $o .= cleardiv(); // $o .= paginate($a); return $o; }
/** * @brief Controller for /match. * * It takes keywords from your profile and queries the directory server for * matching keywords from other profiles. * * @param App &$a * @return void|string */ function match_content(&$a) { $o = ''; if (!local_user()) { return; } $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= follow_widget(); $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user())); if (!count($r)) { return; } if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) { notice(t('No keywords to match. Please add keywords to your default profile.') . EOL); return; } $params = array(); $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); if ($tags) { $params['s'] = $tags; if ($a->pager['page'] != 1) { $params['p'] = $a->pager['page']; } if (strlen(get_config('system', 'directory'))) { $x = post_url(get_server() . '/msearch', $params); } else { $x = post_url($a->get_baseurl() . '/msearch', $params); } $j = json_decode($x); if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $id = 0; foreach ($j->results as $jj) { $match_nurl = normalise_link($jj->url); $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl)); if (!count($match)) { $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo); $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; $photo_menu = array(array(t("View Profile"), zrl($jj->url))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); $contact_details = get_contact_details_by_url($jj->url, local_user()); $entry = array('url' => zrl($jj->url), 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $jj->url, 'name' => $jj->name, 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'inttxt' => ' ' . t('is interested in:'), 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'img_hover' => $jj->tags, 'photo_menu' => $photo_menu, 'id' => ++$id); $entries[] = $entry; } } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('$title' => t('Profile Match'), '$contacts' => $entries, '$paginate' => paginate($a))); } else { info(t('No matches') . EOL); } } return $o; }
function randprof_init(&$a) { require_once 'include/Contact.php'; $x = random_profile(); if ($x) { goaway(zrl($x)); } goaway($a->get_baseurl() . '/profile'); }
function match_content(&$a) { $o = ''; if (!local_user()) { return; } $a->page['aside'] .= follow_widget(); $a->page['aside'] .= findpeople_widget(); $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Profile Match'))); $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user())); if (!count($r)) { return; } if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) { notice(t('No keywords to match. Please add keywords to your default profile.') . EOL); return; } $params = array(); $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); if ($tags) { $params['s'] = $tags; if ($a->pager['page'] != 1) { $params['p'] = $a->pager['page']; } if (strlen(get_config('system', 'directory'))) { $x = post_url(get_server() . '/msearch', $params); } else { $x = post_url($a->get_baseurl() . '/msearch', $params); } $j = json_decode($x); if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $tpl = get_markup_template('match.tpl'); foreach ($j->results as $jj) { $match_nurl = normalise_link($jj->url); $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl)); if (!count($match)) { $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo); $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => proxy_url($jj->photo), '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags)); } } } else { info(t('No matches') . EOL); } } $o .= cleardiv(); $o .= paginate($a); return $o; }
function allfriends_content(&$a) { $o = ''; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($a->argc > 1) { $cid = intval($a->argv[1]); } if (!$cid) { return; } $uid = $a->user[uid]; $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user())); if (!count($c)) { return; } $a->page['aside'] = ""; profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"])); $total = count_all_friends(local_user(), $cid); if (count($total)) { $a->set_pager_total($total); } $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']); if (!count($r)) { $o .= t('No friends to display.'); return $o; } $id = 0; foreach ($r as $rr) { //get further details of the contact $contact_details = get_contact_details_by_url($rr['url'], $uid); $photo_menu = ''; // $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu // If the contact is not common to the user, Connect/Follow' will be added to the photo menu if ($rr[cid]) { $rr[id] = $rr[cid]; $photo_menu = contact_photo_menu($rr); } else { $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url']; $photo_menu = array(array(t("View Profile"), zrl($rr['url']))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); } $entry = array('url' => $rr['url'], 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'name' => htmlentities($rr['name']), 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'img_hover' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($contact_details['network'], $contact_details['url']), 'photo_menu' => $photo_menu, 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'id' => ++$id); $entries[] = $entry; } $tab_str = contacts_tab($a, $cid, 3); $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a))); return $o; }
function match_content(&$a) { $o = ''; if (!local_user()) { return; } $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $o .= '<h2>' . t('Profile Match') . '</h2>'; $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user())); if (!count($r)) { return; } if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) { notice(t('No keywords to match. Please add keywords to your default profile.') . EOL); return; } $params = array(); $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); if ($tags) { $params['s'] = $tags; if ($a->pager['page'] != 1) { $params['p'] = $a->pager['page']; } if (strlen(get_config('system', 'directory_submit_url'))) { $x = post_url('http://dir.friendica.com/msearch', $params); } else { $x = post_url($a->get_baseurl() . '/msearch', $params); } $j = json_decode($x); if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $tpl = get_markup_template('match.tpl'); foreach ($j->results as $jj) { $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => $jj->photo, '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags)); } } else { info(t('No matches') . EOL); } } $o .= cleardiv(); $o .= paginate($a); return $o; }
function viewcontacts_content(&$a) { require_once "mod/proxy.php"; if (get_config('system', 'block_public') && !local_user() && !remote_user()) { notice(t('Public access denied.') . EOL); return; } if (!count($a->profile) || $a->profile['hide-friends']) { notice(t('Permission denied.') . EOL); return; } $o = ""; // tabs $o .= profile_tabs($a, $is_owner, $a->data['user']['nickname']); $r = q("SELECT COUNT(*) AS `total` FROM `contact`\n\t\tWHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0\n\t\t\tAND `network` IN ('%s', '%s', '%s')", intval($a->profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); if (count($r)) { $a->set_pager_total($r[0]['total']); } $r = q("SELECT * FROM `contact`\n\t\tWHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0\n\t\t\tAND `network` IN ('%s', '%s', '%s')\n\t\tORDER BY `name` ASC LIMIT %d, %d", intval($a->profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS), intval($a->pager['start']), intval($a->pager['itemspage'])); if (!count($r)) { info(t('No contacts.') . EOL); return $o; } $contacts = array(); foreach ($r as $rr) { if ($rr['self']) { continue; } $url = $rr['url']; // route DFRN profiles through the redirect $is_owner = local_user() && $a->profile['profile_uid'] == local_user() ? true : false; if ($is_owner && $rr['network'] === NETWORK_DFRN && $rr['rel']) { $url = 'redir/' . $rr['id']; } else { $url = zrl($url); } $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid']); $contacts[] = array('id' => $rr['id'], 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'photo_menu' => contact_photo_menu($rr), 'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB), 'name' => htmlentities(substr($rr['name'], 0, 20)), 'username' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'url' => $url, 'sparkle' => '', 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'network' => network_to_name($rr['network'], $rr['url'])); } $tpl = get_markup_template("viewcontact_template.tpl"); $o .= replace_macros($tpl, array('$title' => t('Contacts'), '$contacts' => $contacts, '$paginate' => paginate($a))); return $o; }
function viewcontacts_content(&$a) { require_once "mod/proxy.php"; if (get_config('system', 'block_public') && !local_user() && !remote_user()) { notice(t('Public access denied.') . EOL); return; } if (!count($a->profile) || $a->profile['hide-friends']) { notice(t('Permission denied.') . EOL); return; } $r = q("SELECT COUNT(*) as `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ", intval($a->profile['uid'])); if (count($r)) { $a->set_pager_total($r[0]['total']); } $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ORDER BY `name` ASC LIMIT %d , %d ", intval($a->profile['uid']), intval($a->pager['start']), intval($a->pager['itemspage'])); if (!count($r)) { info(t('No contacts.') . EOL); return $o; } $contacts = array(); foreach ($r as $rr) { if ($rr['self']) { continue; } $url = $rr['url']; // route DFRN profiles through the redirect $is_owner = local_user() && $a->profile['profile_uid'] == local_user() ? true : false; if ($is_owner && $rr['network'] === NETWORK_DFRN && $rr['rel']) { $url = 'redir/' . $rr['id']; } else { $url = zrl($url); } $contacts[] = array('id' => $rr['id'], 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'thumb' => proxy_url($rr['thumb']), 'name' => substr($rr['name'], 0, 20), 'username' => $rr['name'], 'url' => $url, 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => network_to_name($rr['network'], $rr['url'])); } $tpl = get_markup_template("viewcontact_template.tpl"); $o .= replace_macros($tpl, array('$title' => t('View Contacts'), '$contacts' => $contacts, '$paginate' => paginate($a))); return $o; }
function notifications_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } nav_set_selected('notifications'); $json = $a->argc > 1 && $a->argv[$a->argc - 1] === 'json' ? true : false; $o = ''; $tabs = array(array('label' => t('System'), 'url' => $a->get_baseurl(true) . '/notifications/system', 'sel' => $a->argv[1] == 'system' ? 'active' : ''), array('label' => t('Network'), 'url' => $a->get_baseurl(true) . '/notifications/network', 'sel' => $a->argv[1] == 'network' ? 'active' : ''), array('label' => t('Personal'), 'url' => $a->get_baseurl(true) . '/notifications/personal', 'sel' => $a->argv[1] == 'personal' ? 'active' : ''), array('label' => t('Home'), 'url' => $a->get_baseurl(true) . '/notifications/home', 'sel' => $a->argv[1] == 'home' ? 'active' : ''), array('label' => t('Introductions'), 'url' => $a->get_baseurl(true) . '/notifications/intros', 'sel' => $a->argv[1] == 'intros' ? 'active' : '')); $o = ""; if ($a->argc > 1 && $a->argv[1] == 'intros' || $a->argc == 1) { nav_set_selected('introductions'); if ($a->argc > 2 && $a->argv[2] == 'all') { $sql_extra = ''; } else { $sql_extra = " AND `ignore` = 0 "; } $notif_tpl = get_markup_template('notifications.tpl'); $notif_content .= '<a href="' . (strlen($sql_extra) ? 'notifications/intros/all' : 'notifications/intros') . '" id="notifications-show-hide-link" >' . (strlen($sql_extra) ? t('Show Ignored Requests') : t('Hide Ignored Requests')) . '</a></div>' . "\r\n"; $r = q("SELECT COUNT(*)\tAS `total` FROM `intro`\n\t\t\tWHERE `intro`.`uid` = %d {$sql_extra} AND `intro`.`blocked` = 0 ", intval($_SESSION['uid'])); if ($r && count($r)) { $a->set_pager_total($r[0]['total']); $a->set_pager_itemspage(20); } $r = q("SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*, `fcontact`.`name` AS `fname`,`fcontact`.`url` AS `furl`,`fcontact`.`photo` AS `fphoto`,`fcontact`.`request` AS `frequest`\n\t\t\tFROM `intro` LEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`\n\t\t\tWHERE `intro`.`uid` = %d {$sql_extra} AND `intro`.`blocked` = 0 ", intval($_SESSION['uid'])); if ($r !== false && count($r)) { $sugg = get_markup_template('suggestions.tpl'); $tpl = get_markup_template("intros.tpl"); foreach ($r as $rr) { if ($rr['fid']) { $return_addr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname() . ($a->path ? '/' . $a->path : '')); $notif_content .= replace_macros($sugg, array('$str_notifytype' => t('Notification type: '), '$notify_type' => t('Friend Suggestion'), '$intro_id' => $rr['intro_id'], '$madeby' => sprintf(t('suggested by %s'), $rr['name']), '$contact_id' => $rr['contact-id'], '$photo' => x($rr, 'fphoto') ? $rr['fphoto'] : "images/person-175.jpg", '$fullname' => $rr['fname'], '$url' => zrl($rr['furl']), '$hidden' => array('hidden', t('Hide this contact from others'), $rr['hidden'] == 1, ''), '$activity' => array('activity', t('Post a new friend activity'), intval(get_pconfig(local_user(), 'system', 'post_newfriend')) ? '1' : 0, t('if applicable')), '$knowyou' => $knowyou, '$approve' => t('Approve'), '$note' => $rr['note'], '$request' => $rr['frequest'] . '?addr=' . $return_addr, '$ignore' => t('Ignore'), '$discard' => t('Discard'))); continue; } $friend_selected = $rr['network'] !== NETWORK_OSTATUS ? ' checked="checked" ' : ' disabled '; $fan_selected = $rr['network'] === NETWORK_OSTATUS ? ' checked="checked" disabled ' : ''; $dfrn_tpl = get_markup_template('netfriend.tpl'); $knowyou = ''; $dfrn_text = ''; if ($rr['network'] === NETWORK_DFRN || $rr['network'] === NETWORK_DIASPORA) { if ($rr['network'] === NETWORK_DFRN) { $knowyou = t('Claims to be known to you: ') . ($rr['knowyou'] ? t('yes') : t('no')); $helptext = t('Shall your connection be bidirectional or not? "Friend" implies that you allow to read and you subscribe to their posts. "Fan/Admirer" means that you allow to read but you do not want to read theirs. Approve as: '); } else { $knowyou = ''; $helptext = t('Shall your connection be bidirectional or not? "Friend" implies that you allow to read and you subscribe to their posts. "Sharer" means that you allow to read but you do not want to read theirs. Approve as: '); } $dfrn_text = replace_macros($dfrn_tpl, array('$intro_id' => $rr['intro_id'], '$friend_selected' => $friend_selected, '$fan_selected' => $fan_selected, '$approve_as' => $helptext, '$as_friend' => t('Friend'), '$as_fan' => $rr['network'] == NETWORK_DIASPORA ? t('Sharer') : t('Fan/Admirer'))); } $notif_content .= replace_macros($tpl, array('$str_notifytype' => t('Notification type: '), '$notify_type' => $rr['network'] !== NETWORK_OSTATUS ? t('Friend/Connect Request') : t('New Follower'), '$dfrn_text' => $dfrn_text, '$dfrn_id' => $rr['issued-id'], '$uid' => $_SESSION['uid'], '$intro_id' => $rr['intro_id'], '$contact_id' => $rr['contact-id'], '$photo' => x($rr, 'photo') ? $rr['photo'] : "images/person-175.jpg", '$fullname' => $rr['name'], '$hidden' => array('hidden', t('Hide this contact from others'), $rr['hidden'] == 1, ''), '$activity' => array('activity', t('Post a new friend activity'), intval(get_pconfig(local_user(), 'system', 'post_newfriend')) ? '1' : 0, t('if applicable')), '$url' => zrl($rr['url']), '$knowyou' => $knowyou, '$approve' => t('Approve'), '$note' => $rr['note'], '$ignore' => t('Ignore'), '$discard' => t('Discard'))); } } else { info(t('No introductions.') . EOL); } $o .= replace_macros($notif_tpl, array('$notif_header' => t('Notifications'), '$tabs' => $tabs, '$notif_content' => $notif_content)); $o .= paginate($a); return $o; } else { if ($a->argc > 1 && $a->argv[1] == 'network') { $notif_tpl = get_markup_template('notifications.tpl'); $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,\n\t\t\t\t`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,\n\t\t\t\t`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`\n\t\t\t\tFROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`\n\t\t\t\tWHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND `pitem`.`parent` != 0 AND\n\t\t\t\t `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC", intval(local_user())); $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); $tpl_item_posts = get_markup_template('notifications_posts_item.tpl'); $notif_content = ''; if ($r) { foreach ($r as $it) { switch ($it['verb']) { case ACTIVITY_LIKE: $notif_content .= replace_macros($tpl_item_likes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s liked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_DISLIKE: $notif_content .= replace_macros($tpl_item_dislikes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s disliked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_FRIEND: $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $obj = parse_xml_string($xmlhead . $it['object']); $it['fname'] = $obj->title; $notif_content .= replace_macros($tpl_item_friends, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s is now friends with %s"), $it['author-name'], $it['fname']), '$item_when' => relative_date($it['created']))); break; default: $item_text = $it['id'] == $it['parent'] ? sprintf(t("%s created a new post"), $it['author-name']) : sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname']); $tpl = $it['id'] == $it['parent'] ? $tpl_item_posts : $tpl_item_comments; $notif_content .= replace_macros($tpl, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => $item_text, '$item_when' => relative_date($it['created']))); } } } else { $notif_content = t('No more network notifications.'); } $o .= replace_macros($notif_tpl, array('$notif_header' => t('Network Notifications'), '$tabs' => $tabs, '$notif_content' => $notif_content)); } else { if ($a->argc > 1 && $a->argv[1] == 'system') { $notif_tpl = get_markup_template('notifications.tpl'); $not_tpl = get_markup_template('notify.tpl'); require_once 'include/bbcode.php'; $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc", intval(local_user())); if (count($r) > 0) { foreach ($r as $it) { $notif_content .= replace_macros($not_tpl, array('$item_link' => $a->get_baseurl(true) . '/notify/view/' . $it['id'], '$item_image' => $it['photo'], '$item_text' => strip_tags(bbcode($it['msg'])), '$item_when' => relative_date($it['date']))); } } else { $notif_content .= t('No more system notifications.'); } $o .= replace_macros($notif_tpl, array('$notif_header' => t('System Notifications'), '$tabs' => $tabs, '$notif_content' => $notif_content)); } else { if ($a->argc > 1 && $a->argv[1] == 'personal') { $notif_tpl = get_markup_template('notifications.tpl'); $myurl = $a->get_baseurl(true) . '/profile/' . $a->user['nickname']; $myurl = substr($myurl, strpos($myurl, '://') + 3); $myurl = str_replace(array('www.', '.'), array('', '\\.'), $myurl); $diasp_url = str_replace('/profile/', '/u/', $myurl); $sql_extra .= sprintf(" AND ( `item`.`author-link` regexp '%s' or `item`.`tag` regexp '%s' or `item`.`tag` regexp '%s' ) ", dbesc($myurl . '$'), dbesc($myurl . '\\]'), dbesc($diasp_url . '\\]')); $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,\n\t\t\t\t`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,\n\t\t\t\t`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`\n\t\t\t\tFROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`\n\t\t\t\tWHERE `item`.`unseen` = 1 AND `item`.`visible` = 1\n\t\t\t\t{$sql_extra}\n\t\t\t\tAND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC", intval(local_user())); $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); $tpl_item_posts = get_markup_template('notifications_posts_item.tpl'); $notif_content = ''; if (count($r) > 0) { foreach ($r as $it) { switch ($it['verb']) { case ACTIVITY_LIKE: $notif_content .= replace_macros($tpl_item_likes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s liked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_DISLIKE: $notif_content .= replace_macros($tpl_item_dislikes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s disliked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_FRIEND: $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $obj = parse_xml_string($xmlhead . $it['object']); $it['fname'] = $obj->title; $notif_content .= replace_macros($tpl_item_friends, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s is now friends with %s"), $it['author-name'], $it['fname']), '$item_when' => relative_date($it['created']))); break; default: $item_text = $it['id'] == $it['parent'] ? sprintf(t("%s created a new post"), $it['author-name']) : sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname']); $tpl = $it['id'] == $it['parent'] ? $tpl_item_posts : $tpl_item_comments; $notif_content .= replace_macros($tpl, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => $item_text, '$item_when' => relative_date($it['created']))); } } } else { $notif_content = t('No more personal notifications.'); } $o .= replace_macros($notif_tpl, array('$notif_header' => t('Personal Notifications'), '$tabs' => $tabs, '$notif_content' => $notif_content)); } else { if ($a->argc > 1 && $a->argv[1] == 'home') { $notif_tpl = get_markup_template('notifications.tpl'); $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,\n\t\t\t\t`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,\n\t\t\t\t`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`\n\t\t\t\tFROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`\n\t\t\t\tWHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND\n\t\t\t\t `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1 ORDER BY `item`.`created` DESC", intval(local_user())); $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); $notif_content = ''; if (count($r) > 0) { foreach ($r as $it) { switch ($it['verb']) { case ACTIVITY_LIKE: $notif_content .= replace_macros($tpl_item_likes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s liked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_DISLIKE: $notif_content .= replace_macros($tpl_item_dislikes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s disliked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_FRIEND: $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $obj = parse_xml_string($xmlhead . $it['object']); $it['fname'] = $obj->title; $notif_content .= replace_macros($tpl_item_friends, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s is now friends with %s"), $it['author-name'], $it['fname']), '$item_when' => relative_date($it['created']))); break; default: $notif_content .= replace_macros($tpl_item_comments, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); } } } else { $notif_content = t('No more home notifications.'); } $o .= replace_macros($notif_tpl, array('$notif_header' => t('Home Notifications'), '$tabs' => $tabs, '$notif_content' => $notif_content)); } } } } } $o .= paginate($a); return $o; }
/** * * @param array $contact * @param boolean $redirect * @param string $class * @param boolean $textmode * @return string #FIXME: remove html */ function micropro($contact, $redirect = false, $class = '', $textmode = false) { if ($class) { $class = ' ' . $class; } $url = $contact['url']; $sparkle = ''; $redir = false; if ($redirect) { $a = get_app(); $redirect_url = $a->get_baseurl() . '/redir/' . $contact['id']; if (local_user() && $contact['uid'] == local_user() && $contact['network'] === 'dfrn') { $redir = true; $url = $redirect_url; $sparkle = ' sparkle'; } else { $url = zrl($url); } } $click = x($contact, 'click') ? ' onclick="' . $contact['click'] . '" ' : ''; if ($click) { $url = ''; } if ($textmode) { return '<div class="contact-block-textdiv' . $class . '"><a class="contact-block-link' . $class . $sparkle . ($click ? ' fakelink' : '') . '" ' . ($redir ? ' target="redir" ' : '') . ($url ? ' href="' . $url . '"' : '') . $click . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name'] . '" >' . $contact['name'] . '</a></div>' . "\r\n"; } else { return '<div class="contact-block-div' . $class . '"><a class="contact-block-link' . $class . $sparkle . ($click ? ' fakelink' : '') . '" ' . ($redir ? ' target="redir" ' : '') . ($url ? ' href="' . $url . '"' : '') . $click . ' ><img class="contact-block-img' . $class . $sparkle . '" src="' . $contact['micro'] . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name'] . '" /></a></div>' . "\r\n"; } }
/** * Check if we are a wall to wall item and set the relevant properties */ protected function check_wall_to_wall() { $a = $this->get_app(); $conv = $this->get_conversation(); $this->wall_to_wall = false; if ($this->is_toplevel()) { if ($conv->get_mode() !== 'profile') { if ($this->get_data_value('wall') and !$this->get_data_value('self')) { // On the network page, I am the owner. On the display page it will be the profile owner. // This will have been stored in $a->page_contact by our calling page. // Put this person as the wall owner of the wall-to-wall notice. $this->owner_url = zrl($a->page_contact['url']); $this->owner_photo = $a->page_contact['thumb']; $this->owner_name = $a->page_contact['name']; $this->wall_to_wall = true; } else { if ($this->get_data_value('owner-link')) { $owner_linkmatch = $this->get_data_value('owner-link') && link_compare($this->get_data_value('owner-link'), $this->get_data_value('author-link')); $alias_linkmatch = $this->get_data_value('alias') && link_compare($this->get_data_value('alias'), $this->get_data_value('author-link')); $owner_namematch = $this->get_data_value('owner-name') && $this->get_data_value('owner-name') == $this->get_data_value('author-name'); if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) { // The author url doesn't match the owner (typically the contact) // and also doesn't match the contact alias. // The name match is a hack to catch several weird cases where URLs are // all over the park. It can be tricked, but this prevents you from // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn // well that it's the same Bob Smith. // But it could be somebody else with the same name. It just isn't highly likely. $this->owner_photo = $this->get_data_value('owner-avatar'); $this->owner_name = $this->get_data_value('owner-name'); $this->wall_to_wall = true; // If it is our contact, use a friendly redirect link if (link_compare($this->get_data_value('owner-link'), $this->get_data_value('url')) && $this->get_data_value('network') === NETWORK_DFRN) { $this->owner_url = $this->get_redirect_url(); } else { $this->owner_url = zrl($this->get_data_value('owner-link')); } } } } } } if (!$this->wall_to_wall) { $this->set_template('wall'); $this->owner_url = ''; $this->owner_photo = ''; $this->owner_name = ''; } }
function follow_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED } $uid = local_user(); $url = notags(trim($_REQUEST['url'])); $submit = t('Submit Request'); // There is a current issue. It seems as if you can't start following a Friendica that is following you // With Diaspora this works - but Friendica is special, it seems ... $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND\n\t\t(`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND\n\t\t`network` != '%s' LIMIT 1", intval(local_user()), dbesc(CONTACT_IS_FOLLOWER), dbesc(NETWORK_DFRN), dbesc(normalise_link($url)), dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET)); if ($r) { notice(t('You already added this contact.') . EOL); $submit = ""; //goaway($_SESSION['return_url']); // NOTREACHED } $ret = probe_url($url); if ($ret["network"] == NETWORK_DIASPORA and !get_config('system', 'diaspora_enabled')) { notice(t("Diaspora support isn't enabled. Contact can't be added.") . EOL); $submit = ""; //goaway($_SESSION['return_url']); // NOTREACHED } if ($ret["network"] == NETWORK_OSTATUS and get_config('system', 'ostatus_disabled')) { notice(t("OStatus support is disabled. Contact can't be added.") . EOL); $submit = ""; //goaway($_SESSION['return_url']); // NOTREACHED } if ($ret["network"] == NETWORK_PHANTOM) { notice(t("The network type couldn't be detected. Contact can't be added.") . EOL); $submit = ""; //goaway($_SESSION['return_url']); // NOTREACHED } if ($ret["network"] == NETWORK_MAIL) { $ret["url"] = $ret["addr"]; } if ($ret['network'] === NETWORK_DFRN) { $request = $ret["request"]; $tpl = get_markup_template('dfrn_request.tpl'); } else { $request = $a->get_baseurl() . "/follow"; $tpl = get_markup_template('auto_request.tpl'); } $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid)); if (!$r) { notice(t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED } $myaddr = $r[0]["url"]; // Makes the connection request for friendica contacts easier $_SESSION["fastlane"] = $ret["url"]; $r = q("SELECT `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($ret["url"])); if (!$r) { $r = array(array("location" => "", "about" => "", "keywords" => "")); } if ($ret['network'] === NETWORK_DIASPORA) { $r[0]["location"] = ""; $r[0]["about"] = ""; } $header = $ret["name"]; if ($ret["addr"] != "") { $header .= " <" . $ret["addr"] . ">"; } $header .= " (" . network_to_name($ret['network'], $ret['url']) . ")"; $o = replace_macros($tpl, array('$header' => htmlentities($header), '$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL), '$desc' => "", '$pls_answer' => t('Please answer the following:'), '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'), $ret["name"]), false, '', array(t('No'), t('Yes'))), '$add_note' => t('Add a personal note:'), '$page_desc' => "", '$friendica' => "", '$statusnet' => "", '$diaspora' => "", '$diasnote' => "", '$your_address' => t('Your Identity Address:'), '$invite_desc' => "", '$emailnet' => "", '$submit' => $submit, '$cancel' => t('Cancel'), '$nickname' => "", '$name' => $ret["name"], '$url' => $ret["url"], '$zrl' => zrl($ret["url"]), '$url_label' => t("Profile URL"), '$myaddr' => $myaddr, '$request' => $request, '$location' => bbcode($r[0]["location"]), '$location_label' => t("Location:"), '$about' => bbcode($r[0]["about"], false, false), '$about_label' => t("About:"), '$keywords' => $r[0]["keywords"], '$keywords_label' => t("Tags:"))); return $o; }
function diabook_community_info() { $a = get_app(); $close_pages = get_diabook_config("close_pages", 1); $close_profiles = get_diabook_config("close_profiles", 0); $close_helpers = get_diabook_config("close_helpers", 0); $close_services = get_diabook_config("close_services", 0); $close_friends = get_diabook_config("close_friends", 0); $close_lastusers = get_diabook_config("close_lastusers", 0); $close_lastphotos = get_diabook_config("close_lastphotos", 0); $close_lastlikes = get_diabook_config("close_lastlikes", 0); $close_mapquery = get_diabook_config("close_mapquery", 1); // comunity_profiles if ($close_profiles != "1") { $aside['$comunity_profiles_title'] = t('Community Profiles'); $aside['$comunity_profiles_items'] = array(); $r = q("select gcontact.* from gcontact left join glink on glink.gcid = gcontact.id\n\t\t\t where glink.cid = 0 and glink.uid = 0 order by rand() limit 9"); $tpl = get_markup_template('ch_directory_item.tpl'); if (count($r)) { $photo = 'photo'; foreach ($r as $rr) { $profile_link = $a->get_baseurl() . '/profile/' . (strlen($rr['nickname']) ? $rr['nickname'] : $rr['profile_uid']); $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => zrl($rr['url']), '$photo' => $rr[$photo], '$alt_text' => $rr['name'])); $aside['$comunity_profiles_items'][] = $entry; } } } // last 12 users if ($close_lastusers != "1") { $aside['$lastusers_title'] = t('Last users'); $aside['$lastusers_items'] = array(); $sql_extra = ""; $publish = get_config('system', 'publish_all') ? '' : " AND `publish` = 1 "; $order = " ORDER BY `register_date` DESC "; $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`\n\t\t\tFROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`\n\t\t\tWHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$sql_extra} {$order} LIMIT %d , %d ", 0, 9); $tpl = get_markup_template('ch_directory_item.tpl'); if (count($r)) { $photo = 'thumb'; foreach ($r as $rr) { $profile_link = $a->get_baseurl() . '/profile/' . (strlen($rr['nickname']) ? $rr['nickname'] : $rr['profile_uid']); $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => $profile_link, '$photo' => $a->get_cached_avatar_image($rr[$photo]), '$alt_text' => $rr['name'])); $aside['$lastusers_items'][] = $entry; } } } // last 10 liked items if ($close_lastlikes != "1") { $aside['$like_title'] = t('Last likes'); $aside['$like_items'] = array(); $r = q("SELECT `T1`.`created`, `T1`.`liker`, `T1`.`liker-link`, `item`.* FROM\n\t\t\t(SELECT `parent-uri`, `created`, `author-name` AS `liker`,`author-link` AS `liker-link`\n\t\t\t\tFROM `item` WHERE `verb`='http://activitystrea.ms/schema/1.0/like' GROUP BY `parent-uri` ORDER BY `created` DESC) AS T1\n\t\t\tINNER JOIN `item` ON `item`.`uri`=`T1`.`parent-uri`\n\t\t\tWHERE `T1`.`liker-link` LIKE '%s%%' OR `item`.`author-link` LIKE '%s%%'\n\t\t\tGROUP BY `uri`\n\t\t\tORDER BY `T1`.`created` DESC\n\t\t\tLIMIT 0,5", $a->get_baseurl(), $a->get_baseurl()); foreach ($r as $rr) { $author = '<a href="' . $rr['liker-link'] . '">' . $rr['liker'] . '</a>'; $objauthor = '<a href="' . $rr['author-link'] . '">' . $rr['author-name'] . '</a>'; //var_dump($rr['verb'],$rr['object-type']); killme(); switch ($rr['verb']) { case 'http://activitystrea.ms/schema/1.0/post': switch ($rr['object-type']) { case 'http://activitystrea.ms/schema/1.0/event': $post_type = t('event'); break; default: $post_type = t('status'); } break; default: if ($rr['resource-id']) { $post_type = t('photo'); $m = array(); preg_match("/\\[url=([^]]*)\\]/", $rr['body'], $m); $rr['plink'] = $m[1]; } else { $post_type = t('status'); } } $plink = '<a href="' . $rr['plink'] . '">' . $post_type . '</a>'; $aside['$like_items'][] = sprintf(t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink); } } // last 12 photos if ($close_lastphotos != "1") { $aside['$photos_title'] = t('Last photos'); $aside['$photos_items'] = array(); $r = q("SELECT `photo`.`id`, `photo`.`resource-id`, `photo`.`scale`, `photo`.`desc`, `user`.`nickname`, `user`.`username` FROM\n\t\t\t\t(SELECT `resource-id`, MAX(`scale`) as maxscale FROM `photo`\n\t\t\t\t\tWHERE `profile`=0 AND `contact-id`=0 AND `album` NOT IN ('Contact Photos', '%s', 'Profile Photos', '%s')\n\t\t\t\t\t\tAND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`='' GROUP BY `resource-id`) AS `t1`\n\t\t\t\tINNER JOIN `photo` ON `photo`.`resource-id`=`t1`.`resource-id` AND `photo`.`scale` = `t1`.`maxscale`,\n\t\t\t\t`user`\n\t\t\t\tWHERE `user`.`uid` = `photo`.`uid`\n\t\t\t\tAND `user`.`blockwall`=0\n\t\t\t\tAND `user`.`hidewall`=0\n\t\t\t\tORDER BY `photo`.`edited` DESC\n\t\t\t\tLIMIT 0, 9", dbesc(t('Contact Photos')), dbesc(t('Profile Photos'))); if (count($r)) { $tpl = get_markup_template('ch_directory_item.tpl'); foreach ($r as $rr) { $photo_page = $a->get_baseurl() . '/photos/' . $rr['nickname'] . '/image/' . $rr['resource-id']; $photo_url = $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg'; $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => $photo_page, '$photo' => $photo_url, '$alt_text' => $rr['username'] . " : " . $rr['desc'])); $aside['$photos_items'][] = $entry; } } } //right_aside FIND FRIENDS if ($close_friends != "1") { if (local_user()) { $nv = array(); $nv['title'] = array("", t('Find Friends'), "", ""); $nv['directory'] = array('directory', t('Local Directory'), "", ""); $nv['global_directory'] = array('http://dir.friendica.com/', t('Global Directory'), "", ""); $nv['match'] = array('match', t('Similar Interests'), "", ""); $nv['suggest'] = array('suggest', t('Friend Suggestions'), "", ""); $nv['invite'] = array('invite', t('Invite Friends'), "", ""); $nv['search'] = '<form name="simple_bar" method="get" action="http://dir.friendica.com/directory"> <span class="sbox_l"></span> <span class="sbox"> <input type="text" name="search" size="13" maxlength="50"> </span> <span class="sbox_r" id="srch_clear"></span>'; $aside['$nv'] = $nv; } } //Community_Pages at right_aside if ($close_pages != "1") { if (local_user()) { $page = ' <h3 style="margin-top:0px;">' . t("Community Pages") . '<a id="closeicon" href="#boxsettings" onClick="open_boxsettings(); return false;" style="text-decoration:none;" class="icon close_box" title="' . t("Settings") . '"></a></h3> <div id=""><ul style="margin-left: 7px;margin-top: 0px;padding-left: 0px;padding-top: 0px;">'; $pagelist = array(); $contacts = q("SELECT `id`, `url`, `name`, `micro`FROM `contact`\n\t\t\tWHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d\n\t\t\tORDER BY `name` ASC", intval($a->user['uid'])); $pageD = array(); // Look if the profile is a community page foreach ($contacts as $contact) { $pageD[] = array("url" => $contact["url"], "name" => $contact["name"], "id" => $contact["id"], "micro" => $contact['micro']); } $contacts = $pageD; foreach ($contacts as $contact) { $page .= '<li style="list-style-type: none;" class="tool"><img height="20" width="20" style="float: left; margin-right: 3px;" src="' . $contact['micro'] . '" alt="' . $contact['url'] . '" /> <a href="' . $a->get_baseurl() . '/redir/' . $contact["id"] . '" style="margin-top: 2px; word-wrap: break-word; width: 132px;" title="' . $contact['url'] . '" class="label" target="external-link">' . $contact["name"] . "</a></li>"; } $page .= '</ul></div>'; //if (sizeof($contacts) > 0) $aside['$page'] = $page; } } //END Community Page //mapquery if ($close_mapquery != "1") { $mapquery = array(); $mapquery['title'] = array("", "<a id='mapcontrol-link' href='#mapcontrol' style='text-decoration:none;' onclick='open_mapcontrol(); return false;'>" . t('Earth Layers') . "</a>", "", ""); $aside['$mapquery'] = $mapquery; $ELZoom = get_pconfig(local_user(), 'diabook', 'ELZoom'); $ELPosX = get_pconfig(local_user(), 'diabook', 'ELPosX'); $ELPosY = get_pconfig(local_user(), 'diabook', 'ELPosY'); $aside['$ELZoom'] = array('diabook_ELZoom', t('Set zoomfactor for Earth Layers'), $ELZoom, '', $ELZoom); $aside['$ELPosX'] = array('diabook_ELPosX', t('Set longitude (X) for Earth Layers'), $ELPosX, '', $ELPosX); $aside['$ELPosY'] = array('diabook_ELPosY', t('Set latitude (Y) for Earth Layers'), $ELPosY, '', $ELPosY); if (isset($_POST['diabook-settings-map-sub']) && $_POST['diabook-settings-map-sub'] != '') { set_pconfig(local_user(), 'diabook', 'ELZoom', $_POST['diabook_ELZoom']); set_pconfig(local_user(), 'diabook', 'ELPosX', $_POST['diabook_ELPosX']); set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']); header("Location: network"); } } //end mapquery //helpers if ($close_helpers != "1") { $helpers = array(); $helpers['title'] = array("", t('Help or @NewHere ?'), "", ""); $aside['$helpers'] = $helpers; } //end helpers //connectable services if ($close_services != "1") { $con_services = array(); $con_services['title'] = array("", t('Connect Services'), "", ""); $aside['$con_services'] = $con_services; } //end connectable services if ($ccCookie != "9") { $close_pages = get_diabook_config("close_pages", 1); $close_profiles = get_diabook_config("close_profiles", 0); $close_helpers = get_diabook_config("close_helpers", 0); $close_services = get_diabook_config("close_services", 0); $close_friends = get_diabook_config("close_friends", 0); $close_lastusers = get_diabook_config("close_lastusers", 0); $close_lastphotos = get_diabook_config("close_lastphotos", 0); $close_lastlikes = get_diabook_config("close_lastlikes", 0); $close_mapquery = get_diabook_config("close_mapquery", 1); $close_or_not = array('1' => t("don't show"), '0' => t("show")); $boxsettings['title'] = array("", t('Show/hide boxes at right-hand column:'), "", ""); $aside['$boxsettings'] = $boxsettings; $aside['$close_pages'] = array('diabook_close_pages', t('Community Pages'), $close_pages, '', $close_or_not); $aside['$close_mapquery'] = array('diabook_close_mapquery', t('Earth Layers'), $close_mapquery, '', $close_or_not); $aside['$close_profiles'] = array('diabook_close_profiles', t('Community Profiles'), $close_profiles, '', $close_or_not); $aside['$close_helpers'] = array('diabook_close_helpers', t('Help or @NewHere ?'), $close_helpers, '', $close_or_not); $aside['$close_services'] = array('diabook_close_services', t('Connect Services'), $close_services, '', $close_or_not); $aside['$close_friends'] = array('diabook_close_friends', t('Find Friends'), $close_friends, '', $close_or_not); $aside['$close_lastusers'] = array('diabook_close_lastusers', t('Last users'), $close_lastusers, '', $close_or_not); $aside['$close_lastphotos'] = array('diabook_close_lastphotos', t('Last photos'), $close_lastphotos, '', $close_or_not); $aside['$close_lastlikes'] = array('diabook_close_lastlikes', t('Last likes'), $close_lastlikes, '', $close_or_not); $aside['$sub'] = t('Submit'); $baseurl = $a->get_baseurl($ssl_state); $aside['$baseurl'] = $baseurl; if (isset($_POST['diabook-settings-box-sub']) && $_POST['diabook-settings-box-sub'] != '') { set_pconfig(local_user(), 'diabook', 'close_pages', $_POST['diabook_close_pages']); set_pconfig(local_user(), 'diabook', 'close_mapquery', $_POST['diabook_close_mapquery']); set_pconfig(local_user(), 'diabook', 'close_profiles', $_POST['diabook_close_profiles']); set_pconfig(local_user(), 'diabook', 'close_helpers', $_POST['diabook_close_helpers']); set_pconfig(local_user(), 'diabook', 'close_services', $_POST['diabook_close_services']); set_pconfig(local_user(), 'diabook', 'close_friends', $_POST['diabook_close_friends']); set_pconfig(local_user(), 'diabook', 'close_lastusers', $_POST['diabook_close_lastusers']); set_pconfig(local_user(), 'diabook', 'close_lastphotos', $_POST['diabook_close_lastphotos']); set_pconfig(local_user(), 'diabook', 'close_lastlikes', $_POST['diabook_close_lastlikes']); } } $close = t('Settings'); $aside['$close'] = $close; //get_baseurl $url = $a->get_baseurl($ssl_state); $aside['$url'] = $url; //print right_aside $tpl = get_markup_template('communityhome.tpl'); $a->page['right_aside'] = replace_macros($tpl, $aside); }
function dirfind_content(&$a, $prefix = "") { $community = false; $discover_user = false; $local = get_config('system', 'poco_local_search'); $search = $prefix . notags(trim($_REQUEST['search'])); if (strpos($search, '@') === 0) { $search = substr($search, 1); if (valid_email($search) and validate_email($search) or substr(normalise_link($search), 0, 7) == "http://") { $user_data = probe_url($search); $discover_user = in_array($user_data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)); } } if (strpos($search, '!') === 0) { $search = substr($search, 1); $community = true; } $o = ''; if ($search) { if ($discover_user) { $j = new stdClass(); $j->total = 1; $j->items_page = 1; $j->page = $a->pager['page']; $objresult = new stdClass(); $objresult->cid = 0; $objresult->name = $user_data["name"]; $objresult->addr = $user_data["addr"]; $objresult->url = $user_data["url"]; $objresult->photo = $user_data["photo"]; $objresult->tags = ""; $objresult->network = $user_data["network"]; $contact = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", dbesc(normalise_link($user_data["url"])), intval(local_user())); if ($contact) { $objresult->cid = $contact[0]["id"]; } $j->results[] = $objresult; poco_check($user_data["url"], $user_data["name"], $user_data["network"], $user_data["photo"], "", "", "", "", "", datetime_convert(), 0); } elseif ($local) { if ($community) { $extra_sql = " AND `community`"; } else { $extra_sql = ""; } $perpage = 80; $startrec = $a->pager['page'] * $perpage - $perpage; if (get_config('system', 'diaspora_enabled')) { $diaspora = NETWORK_DIASPORA; } else { $diaspora = NETWORK_DFRN; } if (!get_config('system', 'ostatus_disabled')) { $ostatus = NETWORK_OSTATUS; } else { $ostatus = NETWORK_DFRN; } $count = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t(`url` REGEXP '%s' OR `name` REGEXP '%s' OR `location` REGEXP '%s' OR\n\t\t\t\t\t\t`about` REGEXP '%s' OR `keywords` REGEXP '%s')" . $extra_sql, dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search))); $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`\n\t\t\t\t\tFROM `gcontact`\n\t\t\t\t\tLEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`\n\t\t\t\t\t\tAND `contact`.`uid` = %d AND NOT `contact`.`blocked`\n\t\t\t\t\t\tAND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')\n\t\t\t\t\tWHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND\n\t\t\t\t\t(`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`location` REGEXP '%s' OR\n\t\t\t\t\t\t`gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s') {$extra_sql}\n\t\t\t\t\t\tGROUP BY `gcontact`.`nurl`\n\t\t\t\t\t\tORDER BY `gcontact`.`updated` DESC LIMIT %d, %d", intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND), dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), intval($startrec), intval($perpage)); $j = new stdClass(); $j->total = $count[0]["total"]; $j->items_page = $perpage; $j->page = $a->pager['page']; foreach ($results as $result) { if (poco_alternate_ostatus_url($result["url"])) { continue; } if ($result["name"] == "") { $urlparts = parse_url($result["url"]); $result["name"] = end(explode("/", $urlparts["path"])); } $objresult = new stdClass(); $objresult->cid = $result["cid"]; $objresult->name = $result["name"]; $objresult->addr = $result["addr"]; $objresult->url = $result["url"]; $objresult->photo = $result["photo"]; $objresult->tags = $result["keywords"]; $objresult->network = $result["network"]; $j->results[] = $objresult; } // Add found profiles from the global directory to the local directory proc_run('php', 'include/discover_poco.php', "dirsearch", urlencode($search)); } else { $p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : ''; if (strlen(get_config('system', 'directory'))) { $x = fetch_url(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search)); } $j = json_decode($x); } if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $id = 0; foreach ($j->results as $jj) { $alt_text = ""; $contact_details = get_contact_details_by_url($jj->url, local_user()); $itemurl = $contact_details["addr"] != "" ? $contact_details["addr"] : $jj->url; // If We already know this contact then don't show the "connect" button if ($jj->cid > 0) { $connlnk = ""; $conntxt = ""; $contact = q("SELECT * FROM `contact` WHERE `id` = %d", intval($jj->cid)); if ($contact) { $photo_menu = contact_photo_menu($contact[0]); $details = _contact_detail_for_template($contact[0]); $alt_text = $details['alt_text']; } else { $photo_menu = array(); } } else { $connlnk = $a->get_baseurl() . '/follow/?url=' . ($jj->connect ? $jj->connect : $jj->url); $conntxt = t('Connect'); $photo_menu = array(array(t("View Profile"), zrl($jj->url))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); } $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo); $entry = array('alt_text' => $alt_text, 'url' => zrl($jj->url), 'itemurl' => $itemurl, 'name' => htmlentities($jj->name), 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'img_hover' => $jj->tags, 'conntxt' => $conntxt, 'connlnk' => $connlnk, 'photo_menu' => $photo_menu, 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($jj->network, $jj->url), 'id' => ++$id); $entries[] = $entry; } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('title' => sprintf(t('People Search - %s'), $search), '$contacts' => $entries, '$paginate' => paginate($a))); } else { info(t('No matches') . EOL); } } return $o; }
function dfrn_request_post(&$a) { if ($a->argc != 2 || !count($a->profile)) { return; } if (x($_POST, 'cancel')) { goaway(z_root()); } /** * * Scenario 2: We've introduced ourself to another cell, then have been returned to our own cell * to confirm the request, and then we've clicked submit (perhaps after logging in). * That brings us here: * */ if (x($_POST, 'localconfirm') && $_POST['localconfirm'] == 1) { /** * Ensure this is a valid request */ if (local_user() && $a->user['nickname'] == $a->argv[1] && x($_POST, 'dfrn_url')) { $dfrn_url = notags(trim($_POST['dfrn_url'])); $aes_allow = x($_POST, 'aes_allow') && $_POST['aes_allow'] == 1 ? 1 : 0; $confirm_key = x($_POST, 'confirm_key') ? $_POST['confirm_key'] : ""; $hidden = x($_POST, 'hidden-contact') ? intval($_POST['hidden-contact']) : 0; $contact_record = null; if (x($dfrn_url)) { /** * Lookup the contact based on their URL (which is the only unique thing we have at the moment) */ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND (`url` = '%s' OR `nurl` = '%s') AND `self` = 0 LIMIT 1", intval(local_user()), dbesc($dfrn_url), dbesc(normalise_link($dfrn_url))); if (count($r)) { if (strlen($r[0]['dfrn-id'])) { /** * We don't need to be here. It has already happened. */ notice(t("This introduction has already been accepted.") . EOL); return; } else { $contact_record = $r[0]; } } if (is_array($contact_record)) { $r = q("UPDATE `contact` SET `ret-aes` = %d, hidden = %d WHERE `id` = %d LIMIT 1", intval($aes_allow), intval($hidden), intval($contact_record['id'])); } else { /** * Scrape the other site's profile page to pick up the dfrn links, key, fn, and photo */ require_once 'include/Scrape.php'; $parms = scrape_dfrn($dfrn_url); if (!count($parms)) { notice(t('Profile location is not valid or does not contain profile information.') . EOL); return; } else { if (!x($parms, 'fn')) { notice(t('Warning: profile location has no identifiable owner name.') . EOL); } if (!x($parms, 'photo')) { notice(t('Warning: profile location has no profile photo.') . EOL); } $invalid = validate_dfrn($parms); if ($invalid) { notice(sprintf(tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid), $invalid) . EOL); return; } } $dfrn_request = $parms['dfrn-request']; /********* Escape the entire array ********/ dbesc_array($parms); /******************************************/ /** * Create a contact record on our site for the other person */ $r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `name`, `nick`, `photo`, `site-pubkey`,\n\t\t\t\t\t\t`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`) \n\t\t\t\t\t\tVALUES ( %d, '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)", intval(local_user()), datetime_convert(), dbesc($dfrn_url), dbesc(normalise_link($dfrn_url)), $parms['fn'], $parms['nick'], $parms['photo'], $parms['key'], $parms['dfrn-request'], $parms['dfrn-confirm'], $parms['dfrn-notify'], $parms['dfrn-poll'], $parms['dfrn-poco'], dbesc(NETWORK_DFRN), intval($aes_allow), intval($hidden)); } if ($r) { info(t("Introduction complete.") . EOL); } $r = q("select id from contact where uid = %d and url = '%s' and `site-pubkey` = '%s' limit 1", intval(local_user()), dbesc($dfrn_url), $parms['key']); if (count($r)) { $g = q("select def_gid from user where uid = %d limit 1", intval(local_user())); if ($g && intval($g[0]['def_gid'])) { require_once 'include/group.php'; group_add_member(local_user(), '', $r[0]['id'], $g[0]['def_gid']); } } /** * Allow the blocked remote notification to complete */ if (is_array($contact_record)) { $dfrn_request = $contact_record['request']; } if (strlen($dfrn_request) && strlen($confirm_key)) { $s = fetch_url($dfrn_request . '?confirm_key=' . $confirm_key); } // (ignore reply, nothing we can do it failed) goaway(zrl($dfrn_url)); return; // NOTREACHED } } // invalid/bogus request notice(t('Unrecoverable protocol error.') . EOL); goaway(z_root()); return; // NOTREACHED } /** * Otherwise: * * Scenario 1: * We are the requestee. A person from a remote cell has made an introduction * on our profile web page and clicked submit. We will use their DFRN-URL to * figure out how to contact their cell. * * Scrape the originating DFRN-URL for everything we need. Create a contact record * and an introduction to show our user next time he/she logs in. * Finally redirect back to the requestor so that their site can record the request. * If our user (the requestee) later confirms this request, a record of it will need * to exist on the requestor's cell in order for the confirmation process to complete.. * * It's possible that neither the requestor or the requestee are logged in at the moment, * and the requestor does not yet have any credentials to the requestee profile. * * Who is the requestee? We've already loaded their profile which means their nickname should be * in $a->argv[1] and we should have their complete info in $a->profile. * */ if (!(is_array($a->profile) && count($a->profile))) { notice(t('Profile unavailable.') . EOL); return; } $nickname = $a->profile['nickname']; $notify_flags = $a->profile['notify-flags']; $uid = $a->profile['uid']; $maxreq = intval($a->profile['maxreq']); $contact_record = null; $failed = false; $parms = null; if (x($_POST, 'dfrn_url')) { /** * Block friend request spam */ if ($maxreq) { $r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d", dbesc(datetime_convert('UTC', 'UTC', 'now - 24 hours')), intval($uid)); if (count($r) > $maxreq) { notice(sprintf(t('%s has received too many connection requests today.'), $a->profile['name']) . EOL); notice(t('Spam protection measures have been invoked.') . EOL); notice(t('Friends are advised to please try again in 24 hours.') . EOL); return; } } /** * * Cleanup old introductions that remain blocked. * Also remove the contact record, but only if there is no existing relationship * Do not remove email contacts as these may be awaiting email verification */ $r = q("SELECT `intro`.*, `intro`.`id` AS `iid`, `contact`.`id` AS `cid`, `contact`.`rel` \n\t\t\tFROM `intro` LEFT JOIN `contact` on `intro`.`contact-id` = `contact`.`id`\n\t\t\tWHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0 \n\t\t\tAND `contact`.`network` != '%s'\n\t\t\tAND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ", dbesc(NETWORK_MAIL2)); if (count($r)) { foreach ($r as $rr) { if (!$rr['rel']) { q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1", intval($rr['cid'])); } q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", intval($rr['iid'])); } } /** * * Cleanup any old email intros - which will have a greater lifetime */ $r = q("SELECT `intro`.*, `intro`.`id` AS `iid`, `contact`.`id` AS `cid`, `contact`.`rel` \n\t\t\tFROM `intro` LEFT JOIN `contact` on `intro`.`contact-id` = `contact`.`id`\n\t\t\tWHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0 \n\t\t\tAND `contact`.`network` = '%s'\n\t\t\tAND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ", dbesc(NETWORK_MAIL2)); if (count($r)) { foreach ($r as $rr) { if (!$rr['rel']) { q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1", intval($rr['cid'])); } q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", intval($rr['iid'])); } } $email_follow = x($_POST, 'email_follow') ? intval($_POST['email_follow']) : 0; $real_name = x($_POST, 'realname') ? notags(trim($_POST['realname'])) : ''; $url = trim($_POST['dfrn_url']); if (!strlen($url)) { notice(t("Invalid locator") . EOL); return; } $hcard = ''; if ($email_follow) { if (!validate_email($url)) { notice(t('Invalid email address.') . EOL); return; } $addr = $url; $name = $realname ? $realname : $addr; $nick = substr($addr, 0, strpos($addr, '@')); $url = 'http://' . substr($addr, strpos($addr, '@') + 1); $nurl = normalise_url($host); $poll = 'email ' . random_string(); $notify = 'smtp ' . random_string(); $blocked = 1; $pending = 1; $network = NETWORK_MAIL2; $rel = CONTACT_IS_FOLLOWER; $mail_disabled = function_exists('imap_open') && !get_config('system', 'imap_disabled') ? 0 : 1; if (get_config('system', 'dfrn_only')) { $mail_disabled = 1; } if (!$mail_disabled) { $failed = false; $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval($uid)); if (!count($r)) { notice(t('This account has not been configured for email. Request failed.') . EOL); return; } } $r = q("insert into contact ( uid, created, addr, name, nick, url, nurl, poll, notify, blocked, pending, network, rel )\n\t\t\t\tvalues( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d ) ", intval($uid), dbesc(datetime_convert()), dbesc($addr), dbesc($name), dbesc($nick), dbesc($url), dbesc($nurl), dbesc($poll), dbesc($notify), intval($blocked), intval($pending), dbesc($network), intval($rel)); $r = q("select id from contact where poll = '%s' and uid = %d limit 1", dbesc($poll), intval($uid)); if (count($r)) { $contact_id = $r[0]['id']; $g = q("select def_gid from user where uid = %d limit 1", intval($uid)); if ($g && intval($g[0]['def_gid'])) { require_once 'include/group.php'; group_add_member($uid, '', $contact_id, $g[0]['def_gid']); } $photo = avatar_img($addr); $r = q("UPDATE `contact` SET \n\t\t\t\t\t`photo` = '%s', \n\t\t\t\t\t`thumb` = '%s',\n\t\t\t\t\t`micro` = '%s', \n\t\t\t\t\t`name-date` = '%s', \n\t\t\t\t\t`uri-date` = '%s', \n\t\t\t\t\t`avatar-date` = '%s', \n\t\t\t\t\t`hidden` = 0,\n\t\t\t\t\tWHERE `id` = %d LIMIT 1\n\t\t\t\t", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact_id)); } // contact is created. Now create an introduction $hash = random_string(); $r = q("insert into intro ( uid, `contact-id`, knowyou, note, hash, datetime, blocked )\n\t\t\t\tvalues( %d , %d, %d, '%s', '%s', '%s', %d ) ", intval($uid), intval($contact_id), x($_POST, 'knowyou') && $_POST['knowyou'] == 1 ? 1 : 0, dbesc(notags(trim($_POST['dfrn-request-message']))), dbesc($hash), dbesc(datetime_convert()), 1); // Next send an email verify form to the requestor. } else { // Canonicalise email-style profile locator $url = webfinger_dfrn($url, $hcard); if (substr($url, 0, 5) === 'stat:') { $network = NETWORK_OSTATUS; $url = substr($url, 5); } else { $network = NETWORK_DFRN; } } logger('dfrn_request: url: ' . $url); if (!strlen($url)) { notice(t("Unable to resolve your name at the provided location.") . EOL); return; } if ($network === NETWORK_DFRN) { $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1", intval($uid), dbesc($url)); if (count($ret)) { if (strlen($ret[0]['issued-id'])) { notice(t('You have already introduced yourself here.') . EOL); return; } elseif ($ret[0]['rel'] == CONTACT_IS_FRIEND) { notice(sprintf(t('Apparently you are already friends with %s.'), $a->profile['name']) . EOL); return; } else { $contact_record = $ret[0]; $parms = array('dfrn-request' => $ret[0]['request']); } } $issued_id = random_string(); if (is_array($contact_record)) { // There is a contact record but no issued-id, so this // is a reciprocal introduction from a known contact $r = q("UPDATE `contact` SET `issued-id` = '%s' WHERE `id` = %d LIMIT 1", dbesc($issued_id), intval($contact_record['id'])); } else { if (!validate_url($url)) { notice(t('Invalid profile URL.') . EOL); goaway($a->get_baseurl() . '/' . $a->cmd); return; // NOTREACHED } if (!allowed_url($url)) { notice(t('Disallowed profile URL.') . EOL); goaway($a->get_baseurl() . '/' . $a->cmd); return; // NOTREACHED } require_once 'include/Scrape.php'; $parms = scrape_dfrn($hcard ? $hcard : $url); if (!count($parms)) { notice(t('Profile location is not valid or does not contain profile information.') . EOL); goaway($a->get_baseurl() . '/' . $a->cmd); } else { if (!x($parms, 'fn')) { notice(t('Warning: profile location has no identifiable owner name.') . EOL); } if (!x($parms, 'photo')) { notice(t('Warning: profile location has no profile photo.') . EOL); } $invalid = validate_dfrn($parms); if ($invalid) { notice(sprintf(tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", $invalid), $invalid) . EOL); return; } } $parms['url'] = $url; $parms['issued-id'] = $issued_id; dbesc_array($parms); $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`,`name`, `nick`, `issued-id`, `photo`, `site-pubkey`,\n\t\t\t\t\t`request`, `confirm`, `notify`, `poll`, `poco`, `network` )\n\t\t\t\t\tVALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($uid), dbesc(datetime_convert()), $parms['url'], dbesc(normalise_link($parms['url'])), $parms['fn'], $parms['nick'], $parms['issued-id'], $parms['photo'], $parms['key'], $parms['dfrn-request'], $parms['dfrn-confirm'], $parms['dfrn-notify'], $parms['dfrn-poll'], $parms['dfrn-poco'], dbesc(NETWORK_DFRN)); // find the contact record we just created if ($r) { $r = q("SELECT `id` FROM `contact` \n\t\t\t\t\t\tWHERE `uid` = %d AND `url` = '%s' AND `issued-id` = '%s' LIMIT 1", intval($uid), $parms['url'], $parms['issued-id']); if (count($r)) { $contact_record = $r[0]; } } } if ($r === false) { notice(t('Failed to update contact record.') . EOL); return; } $hash = random_string() . (string) time(); // Generate a confirm_key if (is_array($contact_record)) { $ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`)\n\t\t\t\t\tVALUES ( %d, %d, 1, %d, '%s', '%s', '%s' )", intval($uid), intval($contact_record['id']), x($_POST, 'knowyou') && $_POST['knowyou'] == 1 ? 1 : 0, dbesc(notags(trim($_POST['dfrn-request-message']))), dbesc($hash), dbesc(datetime_convert())); } // This notice will only be seen by the requestor if the requestor and requestee are on the same server. if (!$failed) { info(t('Your introduction has been sent.') . EOL); } // "Homecoming" - send the requestor back to their site to record the introduction. $dfrn_url = bin2hex($a->get_baseurl() . '/profile/' . $nickname); $aes_allow = function_exists('openssl_encrypt') ? 1 : 0; goaway($parms['dfrn-request'] . "?dfrn_url={$dfrn_url}" . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&confirm_key=' . $hash . ($aes_allow ? "&aes_allow=1" : "")); // NOTREACHED // END $network === NETWORK_DFRN } elseif ($network === NETWORK_OSTATUS) { /** * * OStatus network * Check contact existence * Try and scrape together enough information to create a contact record, * with us as CONTACT_IS_FOLLOWER * Substitute our user's feed URL into $url template * Send the subscriber home to subscribe * */ $url = str_replace('{uri}', $a->get_baseurl() . '/profile/' . $nickname, $url); goaway($url); // NOTREACHED // END $network === NETWORK_OSTATUS } } return; }
function directory_content(&$a) { if (get_config('system', 'block_public') && !local_user() && !remote_user()) { notice(t('Public access denied.') . EOL); return; } $o = ''; nav_set_selected('directory'); if (x($a->data, 'search')) { $search = notags(trim($a->data['search'])); } else { $search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : ''; } $tpl = get_markup_template('directory_header.tpl'); $globaldir = ''; $gdirpath = dirname(get_config('system', 'directory_submit_url')); if (strlen($gdirpath)) { $globaldir = '<ul><li><div id="global-directory-link"><a href="' . zrl($gdirpath, true) . '">' . t('Global Directory') . '</a></div></li></ul>'; } $admin = ''; $o .= replace_macros($tpl, array('$search' => $search, '$globaldir' => $globaldir, '$desc' => t('Find on this site'), '$admin' => $admin, '$finding' => strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : "", '$sitedir' => t('Site Directory'), '$submit' => t('Find'))); if ($search) { $search = dbesc($search); } $sql_extra = strlen($search) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('{$search}' IN BOOLEAN MODE) " : ""; $publish = get_config('system', 'publish_all') ? '' : " AND `publish` = 1 "; $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$sql_extra} "); if (count($r)) { $a->set_pager_total($r[0]['total']); } $order = " ORDER BY `name` ASC "; $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$sql_extra} {$order} LIMIT %d , %d ", intval($a->pager['start']), intval($a->pager['itemspage'])); if (count($r)) { $tpl = get_markup_template('directory_item.tpl'); if (in_array('small', $a->argv)) { $photo = 'thumb'; } else { $photo = 'photo'; } foreach ($r as $rr) { $profile_link = $a->get_baseurl() . '/profile/' . (strlen($rr['nickname']) ? $rr['nickname'] : $rr['profile_uid']); $pdesc = $rr['pdesc'] ? $rr['pdesc'] . '<br />' : ''; $details = ''; if (strlen($rr['locality'])) { $details .= $rr['locality']; } if (strlen($rr['region'])) { if (strlen($rr['locality'])) { $details .= ', '; } $details .= $rr['region']; } if (strlen($rr['country-name'])) { if (strlen($details)) { $details .= ', '; } $details .= $rr['country-name']; } if (strlen($rr['dob'])) { if (($years = age($rr['dob'], $rr['timezone'], '')) != 0) { $details .= '<br />' . t('Age: ') . $years; } } if (strlen($rr['gender'])) { $details .= '<br />' . t('Gender: ') . $rr['gender']; } $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile-link' => $profile_link, '$photo' => $rr[$photo], '$alt-text' => $rr['name'], '$name' => $rr['name'], '$details' => $pdesc . $details)); $arr = array('contact' => $rr, 'entry' => $entry); call_hooks('directory_item', $arr); $o .= $entry; } $o .= "<div class=\"directory-end\" ></div>\r\n"; $o .= paginate($a); } else { info(t("No entries (some entries may be hidden).") . EOL); } return $o; }
function render_content(&$a, $items, $mode, $update, $preview = false) { require_once 'include/bbcode.php'; require_once 'mod/proxy.php'; $ssl_state = local_user() ? true : false; $profile_owner = 0; $page_writeable = false; $previewing = $preview ? ' preview ' : ''; if ($mode === 'network') { $profile_owner = local_user(); $page_writeable = true; } if ($mode === 'profile') { $profile_owner = $a->profile['profile_uid']; $page_writeable = can_write_wall($a, $profile_owner); } if ($mode === 'notes') { $profile_owner = local_user(); $page_writeable = true; } if ($mode === 'display') { $profile_owner = $a->profile['uid']; $page_writeable = can_write_wall($a, $profile_owner); } if ($mode === 'community') { $profile_owner = 0; $page_writeable = false; } if ($update) { $return_url = $_SESSION['return_url']; } else { $return_url = $_SESSION['return_url'] = $a->query_string; } load_contact_links(local_user()); $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview); call_hooks('conversation_start', $cb); $items = $cb['items']; $cmnt_tpl = get_markup_template('comment_item.tpl'); $tpl = 'wall_item.tpl'; $wallwall = 'wallwall_item.tpl'; $hide_comments_tpl = get_markup_template('hide_comments.tpl'); $alike = array(); $dlike = array(); // array with html for each thread (parent+comments) $threads = array(); $threadsid = -1; if ($items && count($items)) { if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') { // "New Item View" on network page or search page results // - just loop through the items and format them minimally for display //$tpl = get_markup_template('search_item.tpl'); $tpl = 'search_item.tpl'; foreach ($items as $item) { $threadsid++; $comment = ''; $owner_url = ''; $owner_photo = ''; $owner_name = ''; $sparkle = ''; if ($mode === 'search' || $mode === 'community') { if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) { continue; } $nickname = $item['nickname']; } else { $nickname = $a->user['nickname']; } // prevent private email from leaking. if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { continue; } $profile_name = strlen($item['author-name']) ? $item['author-name'] : $item['name']; if ($item['author-link'] && !$item['author-name']) { $profile_name = $item['author-link']; } $sp = false; $profile_link = best_link_url($item, $sp); if ($profile_link === 'mailbox') { $profile_link = ''; } if ($sp) { $sparkle = ' sparkle'; } else { $profile_link = zrl($profile_link); } $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']); if ($normalised != 'mailbox' && x($a->contacts[$normalised])) { $profile_avatar = $a->contacts[$normalised]['thumb']; } else { $profile_avatar = strlen($item['author-avatar']) ? $a->get_cached_avatar_image($item['author-avatar']) : $item['thumb']; } $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location', $locate); $location = strlen($locate['html']) ? $locate['html'] : render_location_dummy($locate); localize_item($item); if ($mode === 'network-new') { $dropping = true; } else { $dropping = false; } $drop = array('dropping' => $dropping, 'select' => t('Select'), 'delete' => t('Delete')); $star = false; $isstarred = "unstarred"; $lock = false; $likebuttons = false; $shareable = false; $body = prepare_body($item, true); if ($a->theme['template_engine'] === 'internal') { $name_e = template_escape($profile_name); $title_e = template_escape($item['title']); $body_e = template_escape($body); $text_e = strip_tags(template_escape($body)); $location_e = template_escape($location); $owner_name_e = template_escape($owner_name); } else { $name_e = $profile_name; $title_e = $item['title']; $body_e = $body; $text_e = strip_tags($body); $location_e = $location; $owner_name_e = $owner_name; } //$tmp_item = replace_macros($tpl,array( $tmp_item = array('template' => $tpl, 'id' => $preview ? 'P0' : $item['item_id'], 'linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['author-link']) ? $item['author-link'] : $item['url']), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $name_e, 'sparkle' => $sparkle, 'lock' => $lock, 'thumb' => proxy_url($profile_avatar), 'title' => $title_e, 'body' => $body_e, 'text' => $text_e, 'ago' => $item['app'] ? sprintf(t('%s from %s'), relative_date($item['created']), $item['app']) : relative_date($item['created']), 'location' => $location_e, 'indent' => '', 'owner_name' => $owner_name_e, 'owner_url' => $owner_url, 'owner_photo' => proxy_url($owner_photo), 'plink' => get_plink($item), 'edpost' => false, 'isstarred' => $isstarred, 'star' => $star, 'drop' => $drop, 'vote' => $likebuttons, 'like' => '', 'dislike' => '', 'comment' => '', 'conv' => $preview ? '' : array('href' => $a->get_baseurl($ssl_state) . '/display/' . $item['guid'], 'title' => t('View in context')), 'previewing' => $previewing, 'wait' => t('Please wait')); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); $threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['items'] = array($arr['output']); } } else { // Normal View // Figure out how many comments each parent has // (Comments all have gravity of 6) // Store the result in the $comments array $comments = array(); foreach ($items as $item) { if (intval($item['gravity']) == 6 && $item['id'] != $item['parent']) { if (!x($comments, $item['parent'])) { $comments[$item['parent']] = 1; } else { $comments[$item['parent']] += 1; } } elseif (!x($comments, $item['parent'])) { $comments[$item['parent']] = 0; } // avoid notices later on } // map all the like/dislike activities for each parent item // Store these in the $alike and $dlike arrays foreach ($items as $item) { like_puller($a, $item, $alike, 'like'); like_puller($a, $item, $dlike, 'dislike'); } $comments_collapsed = false; $comments_seen = 0; $comment_lastcollapsed = false; $comment_firstcollapsed = false; $blowhard = 0; $blowhard_count = 0; foreach ($items as $item) { $comment = ''; $template = $tpl; $commentww = ''; $sparkle = ''; $owner_url = $owner_photo = $owner_name = ''; // We've already parsed out like/dislike for special treatment. We can ignore them now if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) { continue; } $toplevelpost = $item['id'] == $item['parent'] ? true : false; // Take care of author collapsing and comment collapsing // (author collapsing is currently disabled) // If a single author has more than 3 consecutive top-level posts, squash the remaining ones. // If there are more than two comments, squash all but the last 2. if ($toplevelpost) { $item_writeable = $item['writable'] || $item['self'] ? true : false; $comments_seen = 0; $comments_collapsed = false; $comment_lastcollapsed = false; $comment_firstcollapsed = false; $threadsid++; $threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['private'] = $item['private']; $threads[$threadsid]['items'] = array(); } else { // prevent private email reply to public conversation from leaking. if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { continue; } $comments_seen++; $comment_lastcollapsed = false; $comment_firstcollapsed = false; } $override_comment_box = $page_writeable && $item_writeable ? true : false; $show_comment_box = $page_writeable && $item_writeable && $comments_seen == $comments[$item['parent']] ? true : false; if ($comments[$item['parent']] > 2 && $comments_seen <= $comments[$item['parent']] - 2 && $item['gravity'] == 6) { if (!$comments_collapsed) { $threads[$threadsid]['num_comments'] = sprintf(tt('%d comment', '%d comments', $comments[$item['parent']]), $comments[$item['parent']]); $threads[$threadsid]['hidden_comments_num'] = $comments[$item['parent']]; $threads[$threadsid]['hidden_comments_text'] = tt('comment', 'comments', $comments[$item['parent']]); $threads[$threadsid]['hide_text'] = t('show more'); $comments_collapsed = true; $comment_firstcollapsed = true; } } if ($comments[$item['parent']] > 2 && $comments_seen == $comments[$item['parent']] - 1) { $comment_lastcollapsed = true; } $redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid']; $lock = $item['private'] == 1 || $item['uid'] == local_user() && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) ? t('Private Message') : false; // Top-level wall post not written by the wall owner (wall-to-wall) // First figure out who owns it. $osparkle = ''; if ($toplevelpost && !$item['self'] && $mode !== 'profile') { if ($item['wall']) { // On the network page, I am the owner. On the display page it will be the profile owner. // This will have been stored in $a->page_contact by our calling page. // Put this person as the wall owner of the wall-to-wall notice. $owner_url = zrl($a->page_contact['url']); $owner_photo = $a->page_contact['thumb']; $owner_name = $a->page_contact['name']; $template = $wallwall; $commentww = 'ww'; } if (!$item['wall'] && $item['owner-link']) { $owner_linkmatch = $item['owner-link'] && link_compare($item['owner-link'], $item['author-link']); $alias_linkmatch = $item['alias'] && link_compare($item['alias'], $item['author-link']); $owner_namematch = $item['owner-name'] && $item['owner-name'] == $item['author-name']; if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) { // The author url doesn't match the owner (typically the contact) // and also doesn't match the contact alias. // The name match is a hack to catch several weird cases where URLs are // all over the park. It can be tricked, but this prevents you from // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn // well that it's the same Bob Smith. // But it could be somebody else with the same name. It just isn't highly likely. $owner_url = $item['owner-link']; $owner_photo = $item['owner-avatar']; $owner_name = $item['owner-name']; $template = $wallwall; $commentww = 'ww'; // If it is our contact, use a friendly redirect link if (link_compare($item['owner-link'], $item['url']) && $item['network'] === NETWORK_DFRN) { $owner_url = $redirect_url; $osparkle = ' sparkle'; } else { $owner_url = zrl($owner_url); } } } } $likebuttons = ''; $shareable = $profile_owner == local_user() && $item['private'] != 1 ? true : false; if ($page_writeable) { /* if($toplevelpost) { */ $likebuttons = array('like' => array(t("I like this (toggle)"), t("like")), 'dislike' => array(t("I don't like this (toggle)"), t("dislike"))); if ($shareable) { $likebuttons['share'] = array(t('Share this'), t('share')); } /* } */ $qc = $qcomment = null; if (in_array('qcomment', $a->plugins)) { $qc = local_user() ? get_pconfig(local_user(), 'qcomment', 'words') : null; $qcomment = $qc ? explode("\n", $qc) : null; } if ($show_comment_box || $show_comment_box == false && $override_comment_box == false && $item['last-child']) { $comment = replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $mode === 'display' ? $_SESSION['return_url'] : '', '$type' => $mode === 'profile' ? 'wall-comment' : 'net-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], '$qcomment' => $qcomment, '$profile_uid' => $profile_owner, '$mylink' => $a->contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $a->contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$edbold' => t('Bold'), '$editalic' => t('Italic'), '$eduline' => t('Underline'), '$edquote' => t('Quote'), '$edcode' => t('Code'), '$edimg' => t('Image'), '$edurl' => t('Link'), '$edvideo' => t('Video'), '$preview' => t('Preview'), '$sourceapp' => t($a->sourcename), '$ww' => $mode === 'network' ? $commentww : '', '$rand_num' => random_digits(12))); } } if (local_user() && link_compare($a->contact['url'], $item['author-link'])) { $edpost = array($a->get_baseurl($ssl_state) . "/editpost/" . $item['id'], t("Edit")); } else { $edpost = false; } $drop = ''; $dropping = false; if (intval($item['contact-id']) && $item['contact-id'] == remote_user() || $item['uid'] == local_user()) { $dropping = true; } $drop = array('dropping' => $dropping, 'select' => t('Select'), 'delete' => t('Delete')); $star = false; $filer = false; $isstarred = "unstarred"; if ($profile_owner == local_user()) { if ($toplevelpost) { $isstarred = $item['starred'] ? "starred" : "unstarred"; $star = array('do' => t("add star"), 'undo' => t("remove star"), 'toggle' => t("toggle star status"), 'classdo' => $item['starred'] ? "hidden" : "", 'classundo' => $item['starred'] ? "" : "hidden", 'starred' => t('starred'), 'tagger' => t("add tag"), 'classtagger' => ""); } $filer = t("save to folder"); } $photo = $item['photo']; $thumb = $item['thumb']; // Post was remotely authored. $diff_author = link_compare($item['url'], $item['author-link']) ? false : true; $profile_name = strlen($item['author-name']) && $diff_author ? $item['author-name'] : $item['name']; if ($item['author-link'] && !$item['author-name']) { $profile_name = $item['author-link']; } $sp = false; $profile_link = best_link_url($item, $sp); if ($profile_link === 'mailbox') { $profile_link = ''; } if ($sp) { $sparkle = ' sparkle'; } else { $profile_link = zrl($profile_link); } $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']); if ($normalised != 'mailbox' && x($a->contacts, $normalised)) { $profile_avatar = $a->contacts[$normalised]['thumb']; } else { $profile_avatar = strlen($item['author-avatar']) && $diff_author ? $item['author-avatar'] : $a->get_cached_avatar_image($thumb); } $like = x($alike, $item['uri']) ? format_like($alike[$item['uri']], $alike[$item['uri'] . '-l'], 'like', $item['uri']) : ''; $dislike = x($dlike, $item['uri']) ? format_like($dlike[$item['uri']], $dlike[$item['uri'] . '-l'], 'dislike', $item['uri']) : ''; $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location', $locate); $location = strlen($locate['html']) ? $locate['html'] : render_location_dummy($locate); $indent = $toplevelpost ? '' : ' comment'; $shiny = ""; if (strcmp(datetime_convert('UTC', 'UTC', $item['created']), datetime_convert('UTC', 'UTC', 'now - 12 hours')) > 0) { $shiny = 'shiny'; } // localize_item($item); $tags = array(); foreach (explode(',', $item['tag']) as $tag) { $tag = trim($tag); if ($tag != "") { $tags[] = bbcode($tag); } } // Build the HTML $body = prepare_body($item, true); //$tmp_item = replace_macros($template, if ($a->theme['template_engine'] === 'internal') { $body_e = template_escape($body); $text_e = strip_tags(template_escape($body)); $name_e = template_escape($profile_name); $title_e = template_escape($item['title']); $location_e = template_escape($location); $owner_name_e = template_escape($owner_name); } else { $body_e = $body; $text_e = strip_tags($body); $name_e = $profile_name; $title_e = $item['title']; $location_e = $location; $owner_name_e = $owner_name; } $tmp_item = array('comment_firstcollapsed' => $comment_firstcollapsed, 'comment_lastcollapsed' => $comment_lastcollapsed, 'template' => $template, 'type' => implode("", array_slice(explode("/", $item['verb']), -1)), 'tags' => $tags, 'body' => $body_e, 'text' => $text_e, 'id' => $item['item_id'], 'linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['author-link']) ? $item['author-link'] : $item['url']), 'olinktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['owner-link']) ? $item['owner-link'] : $item['url']), 'to' => t('to'), 'wall' => t('Wall-to-Wall'), 'vwall' => t('via Wall-To-Wall:'), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $name_e, 'thumb' => proxy_url($profile_avatar), 'osparkle' => $osparkle, 'sparkle' => $sparkle, 'title' => $title_e, 'ago' => $item['app'] ? sprintf(t('%s from %s'), relative_date($item['created']), $item['app']) : relative_date($item['created']), 'lock' => $lock, 'location' => $location_e, 'indent' => $indent, 'shiny' => $shiny, 'owner_url' => $owner_url, 'owner_photo' => proxy_url($owner_photo), 'owner_name' => $owner_name_e, 'plink' => get_plink($item), 'edpost' => $edpost, 'isstarred' => $isstarred, 'star' => $star, 'filer' => $filer, 'drop' => $drop, 'vote' => $likebuttons, 'like' => $like, 'dislike' => $dislike, 'comment' => $comment, 'previewing' => $previewing, 'wait' => t('Please wait')); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); $threads[$threadsid]['items'][] = $arr['output']; } } } return $threads; }
function directory_content(&$a) { global $db; require_once "mod/proxy.php"; if (get_config('system', 'block_public') && !local_user() && !remote_user() || get_config('system', 'block_local_dir') && !local_user() && !remote_user()) { notice(t('Public access denied.') . EOL); return; } $o = ''; nav_set_selected('directory'); if (x($a->data, 'search')) { $search = notags(trim($a->data['search'])); } else { $search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : ''; } $gdirpath = ''; $dirurl = get_config('system', 'directory'); if (strlen($dirurl)) { $gdirpath = zrl($dirurl, true); } if ($search) { $search = dbesc($search); $sql_extra = " AND ((`profile`.`name` LIKE '%{$search}%') OR\n\t\t\t\t(`user`.`nickname` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`pdesc` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`locality` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`region` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`country-name` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`gender` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`marital` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`sexual` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`about` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`romance` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`work` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`education` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`pub_keywords` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`prv_keywords` LIKE '%{$search}%'))"; } $publish = get_config('system', 'publish_all') ? '' : " AND `publish` = 1 "; $r = $db->q("SELECT COUNT(*) AS `total` FROM `profile`\n\t\t\tLEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`\n\t\t\tWHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$sql_extra} "); if (count($r)) { $a->set_pager_total($r[0]['total']); } $order = " ORDER BY `name` ASC "; $limit = intval($a->pager['start']) . "," . intval($a->pager['itemspage']); $r = $db->q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,\n\t\t\t`contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`\n\t\t\tLEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`\n\t\t\tLEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`\n\t\t\tWHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 AND `contact`.`self` {$sql_extra} {$order} LIMIT " . $limit); if (count($r)) { if (in_array('small', $a->argv)) { $photo = 'thumb'; } else { $photo = 'photo'; } foreach ($r as $rr) { $community = ''; $itemurl = ''; $itemurl = $rr['addr'] != "" ? $rr['addr'] : $rr['profile_url']; $profile_link = z_root() . '/profile/' . (strlen($rr['nickname']) ? $rr['nickname'] : $rr['profile_uid']); $pdesc = $rr['pdesc'] ? $rr['pdesc'] . '<br />' : ''; $details = ''; if (strlen($rr['locality'])) { $details .= $rr['locality']; } if (strlen($rr['region'])) { if (strlen($rr['locality'])) { $details .= ', '; } $details .= $rr['region']; } if (strlen($rr['country-name'])) { if (strlen($details)) { $details .= ', '; } $details .= $rr['country-name']; } // if(strlen($rr['dob'])) { // if(($years = age($rr['dob'],$rr['timezone'],'')) != 0) // $details .= '<br />' . t('Age: ') . $years ; // } // if(strlen($rr['gender'])) // $details .= '<br />' . t('Gender: ') . $rr['gender']; // show if account is a community account // ToDo the other should be also respected, but first we need a good translatiion // and systemwide consistency for displaying the page type if (intval($rr['page-flags']) == PAGE_COMMUNITY or intval($rr['page-flags']) == PAGE_PRVGROUP) { $community = true; } $profile = $rr; if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal-code') == 1 || x($profile, 'country-name') == 1) { $location = t('Location:'); } $gender = x($profile, 'gender') == 1 ? t('Gender:') : False; $marital = x($profile, 'marital') == 1 ? t('Status:') : False; $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False; $about = x($profile, 'about') == 1 ? t('About:') : False; if ($a->theme['template_engine'] === 'internal') { $location_e = template_escape($location); } else { $location_e = $location; } $photo_menu = array(array(t("View Profile"), zrl($profile_link))); $entry = array('id' => $rr['id'], 'url' => $profile_link, 'itemurl' => $itemurl, 'thumb' => proxy_url($a->get_cached_avatar_image($rr[$photo]), false, PROXY_SIZE_THUMB), 'img_hover' => $rr['name'], 'name' => $rr['name'], 'details' => $details, 'account_type' => $community ? t('Forum') : '', 'profile' => $profile, 'location' => $location_e, 'tags' => $rr['pub_keywords'], 'gender' => $gender, 'pdesc' => $pdesc, 'marital' => $marital, 'homepage' => $homepage, 'about' => $about, 'photo_menu' => $photo_menu); $arr = array('contact' => $rr, 'entry' => $entry); call_hooks('directory_item', $arr); unset($profile); unset($location); if (!$arr['entry']) { continue; } $entries[] = $arr['entry']; } $tpl = get_markup_template('directory_header.tpl'); $o .= replace_macros($tpl, array('$search' => $search, '$globaldir' => t('Global Directory'), '$gdirpath' => $gdirpath, '$desc' => t('Find on this site'), '$contacts' => $entries, '$finding' => t('Finding:'), '$findterm' => strlen($search) ? $search : "", '$title' => t('Site Directory'), '$submit' => t('Find'), '$paginate' => paginate($a))); } else { info(t("No entries (some entries may be hidden).") . EOL); } return $o; }
function directory_content(&$a) { require_once "mod/proxy.php"; if (get_config('system', 'block_public') && !local_user() && !remote_user()) { notice(t('Public access denied.') . EOL); return; } $o = ''; nav_set_selected('directory'); if (x($a->data, 'search')) { $search = notags(trim($a->data['search'])); } else { $search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : ''; } $tpl = get_markup_template('directory_header.tpl'); $globaldir = ''; $gdirpath = dirname(get_config('system', 'directory_submit_url')); if (strlen($gdirpath)) { $globaldir = '<ul><li><div id="global-directory-link"><a href="' . zrl($gdirpath, true) . '">' . t('Global Directory') . '</a></div></li></ul>'; } $admin = ''; $o .= replace_macros($tpl, array('$search' => $search, '$globaldir' => $globaldir, '$desc' => t('Find on this site'), '$admin' => $admin, '$finding' => strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : "", '$sitedir' => t('Site Directory'), '$submit' => t('Find'))); if ($search) { $search = dbesc($search); } $sql_extra = strlen($search) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('{$search}' IN BOOLEAN MODE) " : ""; $publish = get_config('system', 'publish_all') ? '' : " AND `publish` = 1 "; $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$sql_extra} "); if (count($r)) { $a->set_pager_total($r[0]['total']); } $order = " ORDER BY `name` ASC "; $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$sql_extra} {$order} LIMIT %d , %d ", intval($a->pager['start']), intval($a->pager['itemspage'])); if (count($r)) { if (in_array('small', $a->argv)) { $photo = 'thumb'; } else { $photo = 'photo'; } foreach ($r as $rr) { $profile_link = $a->get_baseurl() . '/profile/' . (strlen($rr['nickname']) ? $rr['nickname'] : $rr['profile_uid']); $pdesc = $rr['pdesc'] ? $rr['pdesc'] . '<br />' : ''; $details = ''; if (strlen($rr['locality'])) { $details .= $rr['locality']; } if (strlen($rr['region'])) { if (strlen($rr['locality'])) { $details .= ', '; } $details .= $rr['region']; } if (strlen($rr['country-name'])) { if (strlen($details)) { $details .= ', '; } $details .= $rr['country-name']; } if (strlen($rr['dob'])) { if (($years = age($rr['dob'], $rr['timezone'], '')) != 0) { $details .= '<br />' . t('Age: ') . $years; } } if (strlen($rr['gender'])) { $details .= '<br />' . t('Gender: ') . $rr['gender']; } if ($rr['page-flags'] == PAGE_NORMAL) { $page_type = "Personal Profile"; } if ($rr['page-flags'] == PAGE_SOAPBOX) { $page_type = "Fan Page"; } if ($rr['page-flags'] == PAGE_COMMUNITY) { $page_type = "Community Forum"; } if ($rr['page-flags'] == PAGE_FREELOVE) { $page_type = "Open Forum"; } if ($rr['page-flags'] == PAGE_PRVGROUP) { $page_type = "Private Group"; } $profile = $rr; if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal-code') == 1 || x($profile, 'country-name') == 1) { $location = t('Location:'); } $gender = x($profile, 'gender') == 1 ? t('Gender:') : False; $marital = x($profile, 'marital') == 1 ? t('Status:') : False; $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False; $about = x($profile, 'about') == 1 ? t('About:') : False; $tpl = get_markup_template('directory_item.tpl'); if ($a->theme['template_engine'] === 'internal') { $location_e = template_escape($location); } else { $location_e = $location; } $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => $profile_link, '$photo' => proxy_url($a->get_cached_avatar_image($rr[$photo])), '$alt_text' => $rr['name'], '$name' => $rr['name'], '$details' => $pdesc . $details, '$page_type' => $page_type, '$profile' => $profile, '$location' => $location_e, '$gender' => $gender, '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$about' => $about)); $arr = array('contact' => $rr, 'entry' => $entry); call_hooks('directory_item', $arr); unset($profile); unset($location); $o .= $entry; } $o .= "<div class=\"directory-end\" ></div>\r\n"; $o .= paginate($a); } else { info(t("No entries (some entries may be hidden).") . EOL); } return $o; }
function builtin_activity_puller($item, &$conv_responses) { foreach ($conv_responses as $mode => $v) { $url = ''; $sparkle = ''; switch ($mode) { case 'like': $verb = ACTIVITY_LIKE; break; case 'dislike': $verb = ACTIVITY_DISLIKE; break; case 'attendyes': $verb = ACTIVITY_ATTEND; break; case 'attendno': $verb = ACTIVITY_ATTENDNO; break; case 'attendmaybe': $verb = ACTIVITY_ATTENDMAYBE; break; default: return; break; } if (activity_match($item['verb'], $verb) && $item['id'] != $item['parent']) { $url = $item['author-link']; if (local_user() && local_user() == $item['uid'] && $item['network'] === NETWORK_DFRN && !$item['self'] && link_compare($item['author-link'], $item['url'])) { $url = z_root(true) . '/redir/' . $item['contact-id']; $sparkle = ' class="sparkle" '; } else { $url = zrl($url); } $url = '<a href="' . $url . '"' . $sparkle . '>' . htmlentities($item['author-name']) . '</a>'; if (!$item['thr-parent']) { $item['thr-parent'] = $item['parent-uri']; } if (!(isset($conv_responses[$mode][$item['thr-parent'] . '-l']) && is_array($conv_responses[$mode][$item['thr-parent'] . '-l']))) { $conv_responses[$mode][$item['thr-parent'] . '-l'] = array(); } // only list each unique author once if (in_array($url, $conv_responses[$mode][$item['thr-parent'] . '-l'])) { continue; } if (!isset($conv_responses[$mode][$item['thr-parent']])) { $conv_responses[$mode][$item['thr-parent']] = 1; } else { $conv_responses[$mode][$item['thr-parent']]++; } $conv_responses[$mode][$item['thr-parent'] . '-l'][] = $url; // there can only be one activity verb per item so if we found anything, we can stop looking return; } } }
function directory_content(&$a) { $forums = false; if ($a->argc == 2 && $a->argv[1] === 'forum') { $forums = true; } $alpha = false; if ($_GET['alpha'] == 1) { $alpha = true; } $search = x($_GET, 'search') ? notags(trim($_GET['search'])) : ''; if ($_GET['submit'] === t('Clear')) { goaway($a->get_baseurl()); } if ($search) { $alpha = true; } $tpl .= file_get_contents('view/directory_header.tpl'); $o .= replace_macros($tpl, array('$search' => $search, '$header' => t('Global Directory'), '$submit' => t('Find'), '$clear' => t('Clear'), '$forum' => $a->get_baseurl() . ($forums ? '' : '/directory/forum'), '$toggle' => $forums ? t('Show People') : t('Show Community Forums'), '$alpha' => $alpha ? t('Updated order') : t('Alphabetic order'), '$alink' => $alpha ? str_replace('&alpha=1', '', $a->query_string) : $a->query_string . "&alpha=1", '$args' => $forums ? '/forum' : '', '$finding' => strlen($search) ? '<h4>' . t('Search for: ') . "'" . $search . "'" . '</h4>' : "")); if ($search) { $search = dbesc($search . '*'); } $sql_extra = strlen($search) ? " AND MATCH (`name`, `pdesc`, `homepage`, `locality`, `region`, `country-name`, `gender`, `marital`, `tags` ) \n\t\tAGAINST ('{$search}' IN BOOLEAN MODE) " : ""; if ($forums) { $sql_extra .= " and comm = 1 "; } $sql_extra = str_replace('%', '%%', $sql_extra); $r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `censored` = 0 {$sql_extra} "); if (count($r)) { $a->set_pager_total($r[0]['total']); } if ($alpha) { $order = " order by name asc "; } else { $order = " order by updated desc, id desc "; } $r = q("SELECT * FROM `profile` WHERE `censored` = 0 {$sql_extra} {$order} LIMIT %d , %d ", intval($a->pager['start']), intval($a->pager['itemspage'])); if (count($r)) { $tpl = file_get_contents('view/directory_item.tpl'); foreach ($r as $rr) { $pdesc = $rr['pdesc'] ? $rr['pdesc'] . '<br />' : ''; $details = ''; if (strlen($rr['locality'])) { $details .= $rr['locality']; } if (strlen($rr['region'])) { if (strlen($rr['locality'])) { $details .= ', '; } $details .= $rr['region']; } if (strlen($rr['country-name'])) { if (strlen($details)) { $details .= ', '; } $details .= $rr['country-name']; } if (strlen($rr['gender'])) { $details .= '<br />' . t('Gender: ') . $rr['gender']; } $o .= replace_macros($tpl, array('$id' => $rr['id'], '$mod' => '<div class="moderate"><a href="flag/' . $rr['id'] . '" title="' . t('Flag this entry') . '" ><img src="images/shield_2_16.png" alt="' . t('Flag this entry') . '" title="' . t('Flag this entry') . '"></a></div>', '$star' => $rr['tags'] ? '<div class="star" title="' . strip_tags($rr['tags']) . '"></div>' : '', '$profile-link' => zrl($rr['homepage']), '$photo' => $a->get_baseurl() . '/photo/' . $rr['id'], '$alt-text' => $rr['name'] . ' ' . '(' . $rr['homepage'] . ')', '$name' => $rr['name'], '$pclass' => $rr['comm'] ? ' group' : '', '$pgroup' => $rr['comm'] ? '<div class="directory-group">' . t('[Public Group]') . '</div>' : '', '$details' => $pdesc . $details, '$marital' => strlen($rr['marital']) ? '<div class="marital"><span class="marital-label"><span class="heart">♥</span> ' . t('Status:') . ' </span><span class="marital-text">' . $rr['marital'] . '</span></div>' : '')); } $o .= "<div class=\"directory-end\" ></div>\r\n"; $o .= paginate($a); } else { notice(t('No matching entries.') . EOL); } return $o; }
function vier_community_info() { $a = get_app(); $show_pages = get_vier_config("show_pages", 1); $show_profiles = get_vier_config("show_profiles", 1); $show_helpers = get_vier_config("show_helpers", 1); $show_services = get_vier_config("show_services", 1); $show_friends = get_vier_config("show_friends", 1); $show_lastusers = get_vier_config("show_lastusers", 1); //get_baseurl $url = $a->get_baseurl($ssl_state); $aside['$url'] = $url; // comunity_profiles if ($show_profiles) { $r = suggestion_query(local_user(), 0, 9); $tpl = get_markup_template('ch_directory_item.tpl'); if (count($r)) { $aside['$comunity_profiles_title'] = t('Community Profiles'); $aside['$comunity_profiles_items'] = array(); foreach ($r as $rr) { $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => $a->get_baseurl() . '/follow/?url=' . urlencode($rr['url']), '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO), '$alt_text' => $rr['name'])); $aside['$comunity_profiles_items'][] = $entry; } } } // last 9 users if ($show_lastusers) { $publish = get_config('system', 'publish_all') ? '' : " AND `publish` = 1 "; $order = " ORDER BY `register_date` DESC "; $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`\n\t\t\t\tFROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`\n\t\t\t\tWHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$order} LIMIT %d , %d ", 0, 9); $tpl = get_markup_template('ch_directory_item.tpl'); if (count($r)) { $aside['$lastusers_title'] = t('Last users'); $aside['$lastusers_items'] = array(); foreach ($r as $rr) { $profile_link = $a->get_baseurl() . '/profile/' . (strlen($rr['nickname']) ? $rr['nickname'] : $rr['profile_uid']); $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => $profile_link, '$photo' => $a->get_cached_avatar_image($rr['thumb']), '$alt_text' => $rr['name'])); $aside['$lastusers_items'][] = $entry; } } } //right_aside FIND FRIENDS if ($show_friends and local_user()) { $nv = array(); $nv['title'] = array("", t('Find Friends'), "", ""); $nv['directory'] = array('directory', t('Local Directory'), "", ""); $nv['global_directory'] = array(get_server(), t('Global Directory'), "", ""); $nv['match'] = array('match', t('Similar Interests'), "", ""); $nv['suggest'] = array('suggest', t('Friend Suggestions'), "", ""); $nv['invite'] = array('invite', t('Invite Friends'), "", ""); $nv['search'] = '<form name="simple_bar" method="get" action="' . $a->get_baseurl() . '/dirfind"> <span class="sbox_l"></span> <span class="sbox"> <input type="text" name="search" size="13" maxlength="50"> </span> <span class="sbox_r" id="srch_clear"></span>'; $aside['$nv'] = $nv; } //Community_Pages at right_aside if ($show_pages and local_user()) { require_once 'include/forums.php'; if (x($_GET['cid']) && intval($_GET['cid']) != 0) { $cid = $_GET['cid']; } //sort by last updated item $lastitem = true; $contacts = get_forumlist($a->user['uid'], true, $lastitem, true); $total = count($contacts); $visible_forums = 10; if (count($contacts)) { $id = 0; foreach ($contacts as $contact) { $selected = $cid == $contact['id'] ? ' forum-selected' : ''; $entry = array('url' => z_root() . '/network?f=&cid=' . $contact['id'], 'external_url' => z_root() . '/redir/' . $contact['id'], 'name' => $contact['name'], 'cid' => $contact['id'], 'selected' => $selected, 'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO), 'id' => ++$id); $entries[] = $entry; } $tpl = get_markup_template('widget_forumlist_right.tpl'); $page .= replace_macros($tpl, array('$title' => t('Forums'), '$forums' => $entries, '$link_desc' => t('External link to forum'), '$total' => $total, '$visible_forums' => $visible_forums, '$showmore' => t('show more'))); $aside['$page'] = $page; } } //END Community Page //helpers if ($show_helpers) { $r = array(); $helperlist = get_config("vier", "helperlist"); $helpers = explode(",", $helperlist); if ($helpers) { $query = ""; foreach ($helpers as $index => $helper) { if ($query != "") { $query .= ","; } $query .= "'" . dbesc(normalise_link(trim($helper))) . "'"; } $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query); } foreach ($r as $index => $helper) { $r[$index]["url"] = zrl($helper["url"]); } $r[] = array("url" => "help/Quick-Start-guide", "name" => t("Quick Start")); $tpl = get_markup_template('ch_helpers.tpl'); if ($r) { $helpers = array(); $helpers['title'] = array("", t('Help'), "", ""); $aside['$helpers_items'] = array(); foreach ($r as $rr) { $entry = replace_macros($tpl, array('$url' => $rr['url'], '$title' => $rr['name'])); $aside['$helpers_items'][] = $entry; } $aside['$helpers'] = $helpers; } } //end helpers //connectable services if ($show_services) { $r = array(); if (plugin_enabled("appnet")) { $r[] = array("photo" => "images/appnet.png", "name" => "App.net"); } if (plugin_enabled("buffer")) { $r[] = array("photo" => "images/buffer.png", "name" => "Buffer"); } if (plugin_enabled("blogger")) { $r[] = array("photo" => "images/blogger.png", "name" => "Blogger"); } if (plugin_enabled("dwpost")) { $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth"); } if (plugin_enabled("fbpost")) { $r[] = array("photo" => "images/facebook.png", "name" => "Facebook"); } if (plugin_enabled("ifttt")) { $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"); } if (plugin_enabled("statusnet")) { $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social"); } if (plugin_enabled("gpluspost")) { $r[] = array("photo" => "images/googleplus.png", "name" => "Google+"); } //if (plugin_enabled("ijpost")) // $r[] = array("photo" => "images/", "name" => ""); if (plugin_enabled("libertree")) { $r[] = array("photo" => "images/libertree.png", "name" => "Libertree"); } //if (plugin_enabled("ljpost")) // $r[] = array("photo" => "images/", "name" => ""); if (plugin_enabled("pumpio")) { $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io"); } if (plugin_enabled("tumblr")) { $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr"); } if (plugin_enabled("twitter")) { $r[] = array("photo" => "images/twitter.png", "name" => "Twitter"); } if (plugin_enabled("wppost")) { $r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress"); } if (function_exists("imap_open") and !get_config("system", "imap_disabled") and !get_config("system", "dfrn_only")) { $r[] = array("photo" => "images/mail.png", "name" => "E-Mail"); } $tpl = get_markup_template('ch_connectors.tpl'); if (count($r)) { $con_services = array(); $con_services['title'] = array("", t('Connect Services'), "", ""); $aside['$con_services'] = $con_services; foreach ($r as $rr) { $entry = replace_macros($tpl, array('$url' => $url, '$photo' => $rr['photo'], '$alt_text' => $rr['name'])); $aside['$connector_items'][] = $entry; } } } //end connectable services //print right_aside $tpl = get_markup_template('communityhome.tpl'); $a->page['right_aside'] = replace_macros($tpl, $aside); }
function dirfind_content(&$a, $prefix = "") { $community = false; $local = get_config('system', 'poco_local_search'); $search = $prefix . notags(trim($_REQUEST['search'])); if (strpos($search, '@') === 0) { $search = substr($search, 1); } if (strpos($search, '!') === 0) { $search = substr($search, 1); $community = true; } $o = ''; $o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => sprintf(t('People Search - %s'), $search))); if ($search) { if ($local) { if ($community) { $extra_sql = " AND `community`"; } else { $extra_sql = ""; } $perpage = 80; $startrec = $a->pager['page'] * $perpage - $perpage; $count = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t(`url` REGEXP '%s' OR `name` REGEXP '%s' OR `location` REGEXP '%s' OR\n\t\t\t\t\t\t`about` REGEXP '%s' OR `keywords` REGEXP '%s')" . $extra_sql, dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search))); $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`keywords`\n\t\t\t\t\tFROM `gcontact`\n\t\t\t\t\tLEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`\n\t\t\t\t\t\tAND `contact`.`uid` = %d AND NOT `contact`.`blocked`\n\t\t\t\t\t\tAND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')\n\t\t\t\t\tWHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND\n\t\t\t\t\t(`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`location` REGEXP '%s' OR\n\t\t\t\t\t\t`gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s') {$extra_sql}\n\t\t\t\t\t\tGROUP BY `gcontact`.`nurl`\n\t\t\t\t\t\tORDER BY `gcontact`.`updated` DESC LIMIT %d, %d", intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND), dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), intval($startrec), intval($perpage)); $j = new stdClass(); $j->total = $count[0]["total"]; $j->items_page = $perpage; $j->page = $a->pager['page']; foreach ($results as $result) { if (poco_alternate_ostatus_url($result["url"])) { continue; } if ($result["name"] == "") { $urlparts = parse_url($result["url"]); $result["name"] = end(explode("/", $urlparts["path"])); } $objresult = new stdClass(); $objresult->cid = $result["cid"]; $objresult->name = $result["name"]; $objresult->url = $result["url"]; $objresult->photo = $result["photo"]; $objresult->tags = $result["keywords"]; $j->results[] = $objresult; } // Add found profiles from the global directory to the local directory proc_run('php', 'include/discover_poco.php', "dirsearch", urlencode($search)); } else { $p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : ''; if (strlen(get_config('system', 'directory'))) { $x = fetch_url(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search)); } $j = json_decode($x); } if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $tpl = get_markup_template('match.tpl'); foreach ($j->results as $jj) { // If We already know this contact then don't show the "connect" button if ($jj->cid > 0) { $connlnk = ""; $conntxt = ""; } else { $connlnk = $a->get_baseurl() . '/follow/?url=' . ($jj->connect ? $jj->connect : $jj->url); $conntxt = t('Connect'); } $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo); $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => proxy_url($jj->photo), '$tags' => $jj->tags, '$conntxt' => $conntxt, '$connlnk' => $connlnk)); } } else { info(t('No matches') . EOL); } } $o .= '<div class="clear"></div>'; $o .= paginate($a); return $o; }
function like_puller($a, $item, &$arr, $mode) { $url = ''; $sparkle = ''; $verb = $mode === 'like' ? ACTIVITY_LIKE : ACTIVITY_DISLIKE; if (activity_match($item['verb'], $verb) && $item['id'] != $item['parent']) { $url = $item['author-link']; if (local_user() && local_user() == $item['uid'] && $item['network'] === 'dfrn' && !$item['self'] && link_compare($item['author-link'], $item['url'])) { $url = $a->get_baseurl(true) . '/redir/' . $item['contact-id']; $sparkle = ' class="sparkle" '; } else { $url = zrl($url); } if (!$item['thr-parent']) { $item['thr-parent'] = $item['parent-uri']; } if (!(isset($arr[$item['thr-parent'] . '-l']) && is_array($arr[$item['thr-parent'] . '-l']))) { $arr[$item['thr-parent'] . '-l'] = array(); } if (!isset($arr[$item['thr-parent']])) { $arr[$item['thr-parent']] = 1; } else { $arr[$item['thr-parent']]++; } $arr[$item['thr-parent'] . '-l'][] = '<a href="' . $url . '"' . $sparkle . '>' . $item['author-name'] . '</a>'; } return; }
function contact_photo_menu($contact, $uid = 0) { $a = get_app(); $contact_url = ""; $pm_url = ""; $status_link = ""; $photos_link = ""; $posts_link = ""; $contact_drop_link = ""; $poke_link = ""; if ($uid == 0) { $uid = local_user(); } if ($contact["uid"] != $uid) { if ($uid == 0) { $profile_link = zrl($contact['url']); $menu = array('profile' => array(t("View Profile"), $profile_link, true)); return $menu; } $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `network` = '%s' AND `uid` = %d", dbesc($contact["nurl"]), dbesc($contact["network"]), intval($uid)); if ($r) { return contact_photo_menu($r[0], $uid); } else { $profile_link = zrl($contact['url']); $connlnk = 'follow/?url=' . $contact['url']; $menu = array('profile' => array(t("View Profile"), $profile_link, true), 'follow' => array(t("Connect/Follow"), $connlnk, true)); return $menu; } } $sparkle = false; if ($contact['network'] === NETWORK_DFRN) { $sparkle = true; $profile_link = $a->get_baseurl() . '/redir/' . $contact['id']; } else { $profile_link = $contact['url']; } if ($profile_link === 'mailbox') { $profile_link = ''; } if ($sparkle) { $status_link = $profile_link . "?url=status"; $photos_link = $profile_link . "?url=photos"; $profile_link = $profile_link . "?url=profile"; } if (in_array($contact["network"], array(NETWORK_DFRN, NETWORK_DIASPORA))) { $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id']; } if ($contact["network"] == NETWORK_DFRN) { $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id']; } $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id']; $posts_link = $a->get_baseurl() . "/contacts/" . $contact['id'] . '/posts'; $contact_drop_link = $a->get_baseurl() . "/contacts/" . $contact['id'] . '/drop?confirm=1'; /** * menu array: * "name" => [ "Label", "link", (bool)Should the link opened in a new tab? ] */ $menu = array('status' => array(t("View Status"), $status_link, true), 'profile' => array(t("View Profile"), $profile_link, true), 'photos' => array(t("View Photos"), $photos_link, true), 'network' => array(t("Network Posts"), $posts_link, false), 'edit' => array(t("Edit Contact"), $contact_url, false), 'drop' => array(t("Drop Contact"), $contact_drop_link, false), 'pm' => array(t("Send PM"), $pm_url, false), 'poke' => array(t("Poke"), $poke_link, false)); $args = array('contact' => $contact, 'menu' => &$menu); call_hooks('contact_photo_menu', $args); $menucondensed = array(); foreach ($menu as $menuname => $menuitem) { if ($menuitem[1] != "") { $menucondensed[$menuname] = $menuitem; } } return $menucondensed; }