' . $profile['name'] . '
';
$pdesc = '' . $profile['pdesc'] . '
';
$tabs = '';
$photo = '' . t('Location:') . ' ';
$location .= ((x($profile,'address') == 1) ? '
' . $profile['address'] . '
' : '');
$location .= (((x($profile,'locality') == 1) || (x($profile,'region') == 1) || (x($profile,'postal-code') == 1))
? '
' . $profile['locality'] . ''
. ((x($profile['locality']) == 1) ? t(', ') : '')
. '' . $profile['region'] . ''
. ' ' . $profile['postal-code'] . '' : '');
$location .= ((x($profile,'country-name') == 1) ? '
' . $profile['country-name'] . '' : '');
$location .= '
' . $profile['pubkey'] . '
' : '');
$marital = ((x($profile,'marital') == 1) ? '' . t('Birthday Reminders') . ' ' . '(' . $total . ')' . '
';
$o .= '' . t('Birthdays this week:') . '
';
$o .= '
' . t("\x28Adjusted for local time\x29") . '
';
$o .= '
';
foreach($r as $rr) {
if(! strlen($rr['name']))
continue;
$now = strtotime('now');
$today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
$o .= '
' . $rr['name'] . ' '
. day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '')
. '
' ;
}
$o .= '
';
}
}
return $o;
}}
if(! function_exists('normalise_link')) {
function normalise_link($url) {
$ret = str_replace(array('https:','//www.'), array('http:','//'), $url);
return(rtrim($ret,'/'));
}}
/**
*
* Compare two URLs to see if they are the same, but ignore
* slight but hopefully insignificant differences such as if one
* is https and the other isn't, or if one is www.something and
* the other isn't - and also ignore case differences.
*
* Return true if the URLs match, otherwise false.
*
*/
if(! function_exists('link_compare')) {
function link_compare($a,$b) {
if(strcasecmp(normalise_link($a),normalise_link($b)) === 0)
return true;
return false;
}}
if(! function_exists('prepare_body')) {
function prepare_body($item,$attach = false) {
$s = prepare_text($item['body']);
if(! $attach)
return $s;
$arr = explode(',',$item['attach']);
$s .= '';
if(count($arr)) {
foreach($arr as $r) {
$matches = false;
$icon = '';
$cnt = preg_match('|\[attach\]href=\"(.+?)\" size=\"(.+?)\" type=\"(.+?)\" title=\"(.+?)\"\[\/attach\]|',$r,$matches);
if($cnt) {
$icontype = strtolower(substr($matches[3],0,strpos($matches[3],'/')));
switch($icontype) {
case 'video':
case 'audio':
case 'image':
case 'text':
$icon = '
';
break;
default:
$icon = '
';
break;
}
$title = ((strlen(trim($matches[4]))) ? escape_tags(trim($matches[4])) : escape_tags($matches[1]));
$title .= ' ' . $matches[2] . ' ' . t('bytes');
$s .= '
' . $icon . '';
}
}
}
$s .= '
';
return $s;
}}
if(! function_exists('prepare_text')) {
function prepare_text($text) {
require_once('include/bbcode.php');
$s = smilies(bbcode($text));
return $s;
}}
/**
*
* Wrap calls to proc_close(proc_open()) and call hook
* so plugins can take part in process :)
*
* args:
* $cmd program to run
* next args are passed as $cmd command line
*
* e.g.: proc_run("ls","-la","/tmp");
*
* $cmd and string args are surrounded with ""
*/
if(! function_exists('proc_run')) {
function proc_run($cmd){
$a = get_app();
$args = func_get_args();
call_hooks("proc_run", $args);
if(count($args) && $args[0] === 'php')
$args[0] = ((x($a->config,'php_path')) && (strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
foreach ($args as $arg){
$arg = escapeshellarg($arg);
}
$cmdline = implode($args," ");
proc_close(proc_open($cmdline." &",array(),$foo));
}}
if(! function_exists('current_theme')) {
function current_theme(){
$app_base_themes = array('duepuntozero', 'loozah');
$a = get_app();
$system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
$theme_name = ((is_array($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme);
if($theme_name && file_exists('view/theme/' . $theme_name . '/style.css'))
return($theme_name);
foreach($app_base_themes as $t) {
if(file_exists('view/theme/' . $t . '/style.css'))
return($t);
}
$fallback = glob('view/theme/*/style.css');
if(count($fallback))
return (str_replace('view/theme/','', str_replace("/style.css","",$fallback[0])));
}}
/*
* Return full URL to theme which is currently in effect.
* Provide a sane default if nothing is chosen or the specified theme does not exist.
*/
if(! function_exists('current_theme_url')) {
function current_theme_url() {
global $a;
$t = current_theme();
return($a->get_baseurl() . '/view/theme/' . $t . '/style.css');
}}
if(! function_exists('feed_birthday')) {
function feed_birthday($uid,$tz) {
/**
*
* Determine the next birthday, but only if the birthday is published
* in the default profile. We _could_ also look for a private profile that the
* recipient can see, but somebody could get mad at us if they start getting
* public birthday greetings when they haven't made this info public.
*
* Assuming we are able to publish this info, we are then going to convert
* the start time from the owner's timezone to UTC.
*
* This will potentially solve the problem found with some social networks
* where birthdays are converted to the viewer's timezone and salutations from
* elsewhere in the world show up on the wrong day. We will convert it to the
* viewer's timezone also, but first we are going to convert it from the birthday
* person's timezone to GMT - so the viewer may find the birthday starting at
* 6:00PM the day before, but that will correspond to midnight to the birthday person.
*
*/
$birthday = '';
$p = q("SELECT `dob` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
intval($uid)
);
if($p && count($p)) {
$tmp_dob = substr($p[0]['dob'],5);
if(intval($tmp_dob)) {
$y = datetime_convert($tz,$tz,'now','Y');
$bd = $y . '-' . $tmp_dob . ' 00:00';
$t_dob = strtotime($bd);
$now = strtotime(datetime_convert($tz,$tz,'now'));
if($t_dob < $now)
$bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
$birthday = datetime_convert($tz,'UTC',$bd,ATOM_TIME);
}
}
return $birthday;
}}
/**
* return atom link elements for all of our hubs
*/
if(! function_exists('feed_hublinks')) {
function feed_hublinks() {
$hub = get_config('system','huburl');
$hubxml = '';
if(strlen($hub)) {
$hubs = explode(',', $hub);
if(count($hubs)) {
foreach($hubs as $h) {
$h = trim($h);
if(! strlen($h))
continue;
$hubxml .= '