本文整理汇总了PHP中proxy_url函数的典型用法代码示例。如果您正苦于以下问题:PHP proxy_url函数的具体用法?PHP proxy_url怎么用?PHP proxy_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了proxy_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: suggest_content
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;
}
示例2: suggest_content
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'] .= 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' => proxy_url($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;
}
示例3: match_content
/**
* @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;
}
示例4: match_content
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;
}
示例5: allfriends_content
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;
}
示例6: viewcontacts_content
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;
}
示例7: viewcontacts_content
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;
}
示例8: widget_forumlist
/**
* @brief Forumlist widget
*
* Sidebar widget to show subcribed friendica forums. If activated
* in the settings, it appears at the notwork page sidebar
*
* @param int $uid
* @param int $cid
* The contact id which is used to mark a forum as "selected"
* @return string
*/
function widget_forumlist($uid, $cid = 0)
{
if (!intval(feature_enabled(local_user(), 'forumlist_widget'))) {
return;
}
$o = '';
//sort by last updated item
$lastitem = true;
$contacts = get_forumlist($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.tpl');
$o .= 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')));
}
return $o;
}
示例9: get_template_data
//.........这里部分代码省略.........
if (strcmp(datetime_convert('UTC', 'UTC', $item['created']), datetime_convert('UTC', 'UTC', 'now - 12 hours')) > 0) {
$shiny = 'shiny';
}
localize_item($item);
if ($item["postopts"] and !get_config("system", "suppress_language")) {
//$langdata = explode(";", $item["postopts"]);
//$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)";
$langstr = "";
if (substr($item["postopts"], 0, 5) == "lang=") {
$postopts = substr($item["postopts"], 5);
$languages = explode(":", $postopts);
if (sizeof($languages) == 1) {
$languages = array();
$languages[] = $postopts;
}
foreach ($languages as $language) {
$langdata = explode(";", $language);
if ($langstr != "") {
$langstr .= ", ";
}
//$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
$langstr .= round($langdata[1] * 100, 1) . "% " . $langdata[0];
}
}
}
$body = prepare_body($item, true);
list($categories, $folders) = get_cats_and_terms($item);
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($this->get_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 = $this->get_owner_name();
}
// Disable features that aren't available in several networks
if ($item["item_network"] != "dfrn" and isset($buttons["dislike"])) {
unset($buttons["dislike"]);
$tagger = '';
}
if ($item["item_network"] == "feed" and isset($buttons["like"])) {
unset($buttons["like"]);
}
if ($item["item_network"] == "mail" and isset($buttons["like"])) {
unset($buttons["like"]);
}
if ($item["item_network"] == "dspr" and $indent == 'comment' and isset($buttons["like"])) {
unset($buttons["like"]);
}
// Facebook can like comments - but it isn't programmed in the connector yet.
if ($item["item_network"] == "face" and $indent == 'comment' and isset($buttons["like"])) {
unset($buttons["like"]);
}
$tmp_item = array('template' => $this->get_template(), 'type' => implode("", array_slice(explode("/", $item['verb']), -1)), 'tags' => $item['tags'], 'hashtags' => $item['hashtags'], 'mentions' => $item['mentions'], 'txt_cats' => t('Categories:'), 'txt_folders' => t('Filed under:'), 'has_cats' => count($categories) ? 'true' : '', 'has_folders' => count($folders) ? 'true' : '', 'categories' => $categories, 'folders' => $folders, 'body' => $body_e, 'text' => $text_e, 'id' => $this->get_id(), 'guid' => $item['guid'], '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'), $this->get_owner_name(), strlen($item['owner-link']) ? $item['owner-link'] : $item['url']), 'to' => t('to'), 'via' => t('via'), '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, 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'ago' => $item['app'] ? sprintf(t('%s from %s'), relative_date($item['created']), $item['app']) : relative_date($item['created']), 'app' => $item['app'], 'created' => relative_date($item['created']), 'lock' => $lock, 'location' => $location_e, 'indent' => $indent, 'shiny' => $shiny, 'owner_url' => $this->get_owner_url(), 'owner_photo' => proxy_url($this->get_owner_photo()), 'owner_name' => $owner_name_e, 'plink' => get_plink($item), 'edpost' => feature_enabled($conv->get_profile_owner(), 'edit_posts') ? $edpost : '', 'isstarred' => $isstarred, 'star' => feature_enabled($conv->get_profile_owner(), 'star_posts') ? $star : '', 'ignore' => feature_enabled($conv->get_profile_owner(), 'ignore_posts') ? $ignore : '', 'tagger' => $tagger, 'filer' => feature_enabled($conv->get_profile_owner(), 'filing') ? $filer : '', 'drop' => $drop, 'vote' => $buttons, 'like' => $like, 'dislike' => $dislike, 'switchcomment' => t('Comment'), 'comment' => $this->get_comment_box($indent), 'previewing' => $conv->is_preview() ? ' preview ' : '', 'wait' => t('Please wait'), 'thread_level' => $thread_level, 'postopts' => $langstr, 'edited' => $edited, 'network' => $item["item_network"], 'network_name' => network_to_name($item['item_network']));
$arr = array('item' => $item, 'output' => $tmp_item);
call_hooks('display_item', $arr);
$result = $arr['output'];
$result['children'] = array();
$children = $this->get_children();
$nb_children = count($children);
if ($nb_children > 0) {
foreach ($children as $child) {
$result['children'][] = $child->get_template_data($alike, $dlike, $thread_level + 1);
}
// Collapse
if ($nb_children > 2 || $thread_level > 1) {
$result['children'][0]['comment_firstcollapsed'] = true;
$result['children'][0]['num_comments'] = sprintf(tt('%d comment', '%d comments', $total_children), $total_children);
$result['children'][0]['hidden_comments_num'] = $total_children;
$result['children'][0]['hidden_comments_text'] = tt('comment', 'comments', $total_children);
$result['children'][0]['hide_text'] = t('show more');
if ($thread_level > 1) {
$result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
} else {
$result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
}
}
}
if ($this->is_toplevel()) {
$result['total_comments_num'] = "{$total_children}";
$result['total_comments_text'] = tt('comment', 'comments', $total_children);
}
$result['private'] = $item['private'];
$result['toplevel'] = $this->is_toplevel() ? 'toplevel_item' : '';
if ($this->is_threaded()) {
$result['flatten'] = false;
$result['threaded'] = true;
} else {
$result['flatten'] = true;
$result['threaded'] = false;
}
return $result;
}
示例10: display_fetchauthor
function display_fetchauthor($a, $item)
{
require_once "mod/proxy.php";
require_once "include/bbcode.php";
$profiledata = array();
$profiledata["uid"] = -1;
$profiledata["nickname"] = $item["author-name"];
$profiledata["name"] = $item["author-name"];
$profiledata["picdate"] = "";
$profiledata["photo"] = proxy_url($item["author-avatar"]);
$profiledata["url"] = $item["author-link"];
$profiledata["network"] = $item["network"];
// Fetching further contact data from the contact table
$r = q("SELECT `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d", normalise_link($profiledata["url"]), $item["uid"]);
if (count($r)) {
$profiledata["photo"] = proxy_url($r[0]["photo"]);
$profiledata["address"] = proxy_parse_html(bbcode($r[0]["location"]));
$profiledata["about"] = proxy_parse_html(bbcode($r[0]["about"]));
if ($r[0]["nick"] != "") {
$profiledata["nickname"] = $r[0]["nick"];
}
}
// Fetching profile data from unique contacts
$r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"]));
if (count($r)) {
if ($profiledata["photo"] == "") {
$profiledata["photo"] = proxy_url($r[0]["avatar"]);
}
if ($profiledata["address"] == "") {
$profiledata["address"] = proxy_parse_html(bbcode($r[0]["location"]));
}
if ($profiledata["about"] == "") {
$profiledata["about"] = proxy_parse_html(bbcode($r[0]["about"]));
}
if ($profiledata["nickname"] == "" and $r[0]["nick"] != "") {
$profiledata["nickname"] = $r[0]["nick"];
}
}
// Check for a repeated message
$skip = false;
$body = trim($item["body"]);
// Skip if it isn't a pure repeated messages
// Does it start with a share?
if (!$skip and strpos($body, "[share") > 0) {
$skip = true;
}
// Does it end with a share?
if (!$skip and strlen($body) > strrpos($body, "[/share]") + 8) {
$skip = true;
}
if (!$skip) {
$attributes = preg_replace("/\\[share(.*?)\\]\\s?(.*?)\\s?\\[\\/share\\]\\s?/ism", "\$1", $body);
// Skip if there is no shared message in there
if ($body == $attributes) {
$skip = true;
}
}
if (!$skip) {
$author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") {
$profiledata["name"] = html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8');
}
preg_match('/author="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") {
$profiledata["name"] = html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8');
}
$profile = "";
preg_match("/profile='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") {
$profiledata["url"] = $matches[1];
}
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") {
$profiledata["url"] = $matches[1];
}
$avatar = "";
preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") {
$profiledata["photo"] = $matches[1];
}
preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") {
$profiledata["photo"] = $matches[1];
}
$profiledata["nickname"] = $profiledata["name"];
$profiledata["network"] = GetProfileUsername($profiledata["url"], "", false, true);
$profiledata["address"] = "";
$profiledata["about"] = "";
// Fetching profile data from unique contacts
if ($profiledata["url"] != "") {
$r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"]));
if (count($r)) {
$profiledata["photo"] = proxy_url($r[0]["avatar"]);
$profiledata["address"] = proxy_parse_html(bbcode($r[0]["location"]));
$profiledata["about"] = proxy_parse_html(bbcode($r[0]["about"]));
if ($r[0]["nick"] != "") {
$profiledata["nickname"] = $r[0]["nick"];
}
}
//.........这里部分代码省略.........
示例11: dirfind_content
//.........这里部分代码省略.........
$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;
}
示例12: acl_lookup
function acl_lookup(&$a, $out_type = 'json')
{
if (!local_user()) {
return "";
}
$start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
$count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
$search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
$type = x($_REQUEST, 'type') ? $_REQUEST['type'] : "";
$conv_id = x($_REQUEST, 'conversation') ? $_REQUEST['conversation'] : null;
// For use with jquery.autocomplete for private mail completion
if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
if (!$type) {
$type = 'm';
}
$search = $_REQUEST['query'];
}
if ($search != "") {
$sql_extra = "AND `name` LIKE '%%" . dbesc($search) . "%%'";
$sql_extra2 = "AND (`attag` LIKE '%%" . dbesc($search) . "%%' OR `name` LIKE '%%" . dbesc($search) . "%%' OR `nick` LIKE '%%" . dbesc($search) . "%%')";
} else {
$sql_extra = $sql_extra2 = "";
}
// count groups and contacts
if ($type == '' || $type == 'g') {
$r = q("SELECT COUNT(*) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d {$sql_extra}", intval(local_user()));
$group_count = (int) $r[0]['g'];
} else {
$group_count = 0;
}
if ($type == '' || $type == 'c') {
$r = q("SELECT COUNT(*) AS c FROM `contact`\n\t\t\t\tWHERE `uid` = %d AND `self` = 0\n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 AND `archive` = 0\n\t\t\t\tAND `notify` != '' {$sql_extra2}", intval(local_user()));
$contact_count = (int) $r[0]['c'];
} elseif ($type == 'm') {
// autocomplete for Private Messages
$r = q("SELECT COUNT(*) AS c FROM `contact`\n\t\t\t\tWHERE `uid` = %d AND `self` = 0\n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 AND `archive` = 0\n\t\t\t\tAND `network` IN ('%s','%s','%s') {$sql_extra2}", intval(local_user()), dbesc(NETWORK_DFRN), dbesc(NETWORK_ZOT), dbesc(NETWORK_DIASPORA));
$contact_count = (int) $r[0]['c'];
} elseif ($type == 'a') {
// autocomplete for Contacts
$r = q("SELECT COUNT(*) AS c FROM `contact`\n\t\t\t\tWHERE `uid` = %d AND `self` = 0\n\t\t\t\tAND `pending` = 0 {$sql_extra2}", intval(local_user()));
$contact_count = (int) $r[0]['c'];
} else {
$contact_count = 0;
}
$tot = $group_count + $contact_count;
$groups = array();
$contacts = array();
if ($type == '' || $type == 'g') {
$r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') as uids\n\t\t\t\tFROM `group`,`group_member`\n\t\t\t\tWHERE `group`.`deleted` = 0 AND `group`.`uid` = %d\n\t\t\t\t\tAND `group_member`.`gid`=`group`.`id`\n\t\t\t\t\t{$sql_extra}\n\t\t\t\tGROUP BY `group`.`id`\n\t\t\t\tORDER BY `group`.`name`\n\t\t\t\tLIMIT %d,%d", intval(local_user()), intval($start), intval($count));
foreach ($r as $g) {
// logger('acl: group: ' . $g['name'] . ' members: ' . $g['uids']);
$groups[] = array("type" => "g", "photo" => "images/twopeople.png", "name" => $g['name'], "id" => intval($g['id']), "uids" => array_map("intval", explode(",", $g['uids'])), "link" => '', "forum" => '0');
}
}
if ($type == '' || $type == 'c') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, forum FROM `contact`\n\t\t\tWHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''\n\t\t\t{$sql_extra2}\n\t\t\tORDER BY `name` ASC ", intval(local_user()));
} elseif ($type == 'm') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact`\n\t\t\tWHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0\n\t\t\tAND `network` IN ('%s','%s','%s')\n\t\t\t{$sql_extra2}\n\t\t\tORDER BY `name` ASC ", intval(local_user()), dbesc(NETWORK_DFRN), dbesc(NETWORK_ZOT), dbesc(NETWORK_DIASPORA));
} elseif ($type == 'a') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact`\n\t\t\tWHERE `uid` = %d AND `pending` = 0\n\t\t\t{$sql_extra2}\n\t\t\tORDER BY `name` ASC ", intval(local_user()));
} else {
$r = array();
}
if ($type == 'm' || $type == 'a') {
$x = array();
$x['query'] = $search;
$x['photos'] = array();
$x['links'] = array();
$x['suggestions'] = array();
$x['data'] = array();
if (count($r)) {
foreach ($r as $g) {
$x['photos'][] = proxy_url($g['micro']);
$x['links'][] = $g['url'];
$x['suggestions'][] = $g['name'];
$x['data'][] = intval($g['id']);
}
}
echo json_encode($x);
killme();
}
if (count($r)) {
foreach ($r as $g) {
$contacts[] = array("type" => "c", "photo" => proxy_url($g['micro']), "name" => $g['name'], "id" => intval($g['id']), "network" => $g['network'], "link" => $g['url'], "nick" => $g['attag'] ? $g['attag'] : $g['nick'], "forum" => $g['forum']);
}
}
$items = array_merge($groups, $contacts);
if ($conv_id) {
/* if $conv_id is set, get unknow contacts in thread */
/* but first get know contacts url to filter them out */
function _contact_link($i)
{
return dbesc($i['link']);
}
$known_contacts = array_map(_contact_link, $contacts);
$unknow_contacts = array();
$r = q("select\n\t\t\t\t\t`author-avatar`,`author-name`,`author-link`\n\t\t\t\tfrom item where parent=%d\n\t\t\t\tand (\n\t\t\t\t\t`author-name` LIKE '%%%s%%' OR\n\t\t\t\t\t`author-link` LIKE '%%%s%%'\n\t\t\t\t) and\n\t\t\t\t`author-link` NOT IN ('%s')\n\t\t\t\tGROUP BY `author-link`\n\t\t\t\tORDER BY `author-name` ASC\n\t\t\t\t", intval($conv_id), dbesc($search), dbesc($search), implode("','", $known_contacts));
if (is_array($r) && count($r)) {
foreach ($r as $row) {
// nickname..
//.........这里部分代码省略.........
示例13: xmlize
function xmlize($href, $name, $url, $photo, $date, $seen, $message)
{
require_once "mod/proxy.php";
$photo = proxy_url($photo);
$data = array('href' => &$href, 'name' => &$name, 'url' => &$url, 'photo' => &$photo, 'date' => &$date, 'seen' => &$seen, 'messsage' => &$message);
call_hooks('ping_xmlize', $data);
$notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s" seen="%s" >%s</note>';
return sprintf($notsxml, xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($seen), xmlify($message));
}
示例14: directory_content
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);
//.........这里部分代码省略.........
示例15: curweather_network_mod_init
function curweather_network_mod_init(&$fk_app, &$b)
{
if (!intval(get_pconfig(local_user(), 'curweather', 'curweather_enable'))) {
return;
}
$fk_app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $fk_app->get_baseurl() . '/addon/curweather/curweather.css' . '" media="all" />' . "\r\n";
// $rpt value is needed for location
// $lang will be taken from the browser session to honour user settings
// TODO $lang does not work if the default settings are used
// and not all response strings are translated
// $units can be set in the settings by the user
// $appid is configured by the admin in the admin panel
// those parameters will be used to get: cloud status, temperature, preassure
// and relative humidity for display, also the relevent area of the map is
// linked from lat/log of the reply of OWMp
$rpt = get_pconfig(local_user(), 'curweather', 'curweather_loc');
// set the language to the browsers language and use metric units
$lang = $_SESSION['language'];
$units = get_pconfig(local_user(), 'curweather', 'curweather_units');
$appid = get_config('curweather', 'appid');
$cachetime = intval(get_config('curweather', 'cachetime'));
if ($units === "") {
$units = 'metric';
}
$ok = true;
$res = getWeather($rpt, $units, $lang, $appid, $cachetime);
if ($res === false) {
$ok = false;
}
if ($ok) {
$t = get_markup_template("widget.tpl", "addon/curweather/");
$curweather = replace_macros($t, array('$title' => t("Current Weather"), '$icon' => proxy_url('http://openweathermap.org/img/w/' . $res['icon'] . '.png'), '$city' => $res['city'], '$lon' => $res['lon'], '$lat' => $res['lat'], '$description' => $res['descripion'], '$temp' => $res['temperature'], '$relhumidity' => array('caption' => t('Relative Humidity'), 'val' => $res['humidity']), '$pressure' => array('caption' => t('Pressure'), 'val' => $res['pressure']), '$wind' => array('caption' => t('Wind'), 'val' => $res['wind']), '$lastupdate' => t('Last Updated') . ': ' . $res['update'] . 'UTC', '$databy' => t('Data by'), '$showonmap' => t('Show on map')));
} else {
$t = get_markup_template('widget-error.tpl', 'addon/curweather/');
$curweather = replace_macros($t, array('$problem' => t('There was a problem accessing the weather data. But have a look'), '$rpt' => $rpt, '$atOWM' => t('at OpenWeatherMap')));
}
$fk_app->page['aside'] = $curweather . $fk_app->page['aside'];
}