#set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
- if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
+ if ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,9) === "pagename=") {
$this->query_string = substr($_SERVER['QUERY_STRING'],9);
// removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/")
$this->query_string = substr($this->query_string, 1);
- } elseif((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
+ } elseif ((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
$this->query_string = substr($_SERVER['QUERY_STRING'],2);
// removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/")
$this->query_string = substr($this->query_string, 1);
}
- if (x($_GET,'pagename'))
+ if (x($_GET,'pagename')) {
$this->cmd = trim($_GET['pagename'],'/\\');
- elseif (x($_GET,'q'))
+ } elseif (x($_GET,'q')) {
$this->cmd = trim($_GET['q'],'/\\');
+ }
// fix query_string
// unix style "homedir"
- if(substr($this->cmd,0,1) === '~')
+ if (substr($this->cmd,0,1) === '~') {
$this->cmd = 'profile/' . substr($this->cmd,1);
+ }
// Diaspora style profile url
- if(substr($this->cmd,0,2) === 'u/')
+ if (substr($this->cmd,0,2) === 'u/') {
$this->cmd = 'profile/' . substr($this->cmd,2);
+ }
/*
} else {
$r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'",
$common_filename);
- if(! dbm::is_result($r)){
+ if (! dbm::is_result($r)) {
$this->cached_profile_image[$avatar_image] = $avatar_image;
} else {
$this->cached_profile_picdate[$common_filename] = "?rev=".urlencode($r[0]['picdate']);
// We will only change the url to an ip address if there is no existing setting
if(! x($url))
- $url = set_config('system','url',$a->get_baseurl());
- if((! link_compare($url,$a->get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname)))
- $url = set_config('system','url',$a->get_baseurl());
+ $url = set_config('system','url',App::get_baseurl());
+ if((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname)))
+ $url = set_config('system','url',App::get_baseurl());
return;
}
function theme_post(&$a){
// non local users shall not pass
- if(! local_user())
+ if (! local_user()) {
return;
+ }
// if the one specific submit button was pressed then proceed
if (isset($_POST['duepuntozero-settings-submit'])){
// and save the selection key into the personal config of the user
function user_remove($uid) {
if(! $uid)
return;
- $a = get_app();
logger('Removing user: ' . $uid);
$r = q("select * from user where uid = %d limit 1", intval($uid));
if($uid == local_user()) {
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
- goaway($a->get_baseurl());
+ goaway(App::get_baseurl());
}
}
function terminate_friendship($user,$self,$contact) {
-
+ /// @TODO Get rid of this, include/datetime.php should care about by itself
$a = get_app();
require_once('include/datetime.php');
- if($contact['network'] === NETWORK_OSTATUS) {
+ if ($contact['network'] === NETWORK_OSTATUS) {
require_once('include/ostatus.php');
$item['follow'] = $contact["url"];
$slap = ostatus::salmon($item, $user);
- if((x($contact,'notify')) && (strlen($contact['notify']))) {
+ if ((x($contact,'notify')) && (strlen($contact['notify']))) {
require_once('include/salmon.php');
slapper($user,$contact['notify'],$slap);
}
- }
- elseif($contact['network'] === NETWORK_DIASPORA) {
+ } elseif ($contact['network'] === NETWORK_DIASPORA) {
require_once('include/diaspora.php');
Diaspora::send_unshare($user,$contact);
- }
- elseif($contact['network'] === NETWORK_DFRN) {
+ } elseif ($contact['network'] === NETWORK_DFRN) {
require_once('include/dfrn.php');
dfrn::deliver($user,$contact,'placeholder', 1);
}
$sparkle = false;
if ($contact['network'] === NETWORK_DFRN) {
$sparkle = true;
- $profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
+ $profile_link = App::get_baseurl() . '/redir/' . $contact['id'];
} else {
$profile_link = $contact['url'];
}
}
if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) {
- $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
+ $pm_url = App::get_baseurl() . '/message/new/' . $contact['id'];
}
if ($contact['network'] == NETWORK_DFRN) {
- $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id'];
+ $poke_link = App::get_baseurl() . '/poke/?f=&c=' . $contact['id'];
}
- $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
+ $contact_url = App::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';
+ $posts_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
+ $contact_drop_link = App::get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
/**
* menu array:
function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
- $a = get_app();
-
$r = q("SELECT `resource-id` FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `scale` = 4 AND `album` = 'Contact Photos' LIMIT 1",
intval($uid),
intval($cid)
$photo_failure = true;
}
- $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
- $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
- $micro = $a->get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
+ $photo = App::get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
+ $thumb = App::get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
+ $micro = App::get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
} else {
$photo_failure = true;
}
}
if ($photo_failure) {
- $photo = $a->get_baseurl() . '/images/person-175.jpg';
- $thumb = $a->get_baseurl() . '/images/person-80.jpg';
- $micro = $a->get_baseurl() . '/images/person-48.jpg';
+ $photo = App::get_baseurl() . '/images/person-175.jpg';
+ $thumb = App::get_baseurl() . '/images/person-80.jpg';
+ $micro = App::get_baseurl() . '/images/person-48.jpg';
}
return(array($photo,$thumb,$micro));
return(array());
}
- $image = array("page" => $a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
- "full" => $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
+ $image = array("page" => App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
+ "full" => App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
if ($width > 800 || $height > 800) {
- $image["large"] = $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
+ $image["large"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
}
if ($width > 640 || $height > 640) {
$ph->scaleImage(640);
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
if ($r) {
- $image["medium"] = $a->get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
+ $image["medium"] = App::get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
}
}
$ph->scaleImage(320);
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
if ($r) {
- $image["small"] = $a->get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
+ $image["small"] = App::get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
}
}
$r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
if ($r) {
- $image["thumb"] = $a->get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
+ $image["thumb"] = App::get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
}
}
call_hooks($a->module . '_pre_' . $selname, $arr);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" ";
else
$exclude = false;
$size = 4;
- if(is_array($options)) {
- if(x($options,'size'))
+ if (is_array($options)) {
+ if (x($options,'size'))
$size = $options['size'];
- if(x($options,'mutual_friends'))
+ if (x($options,'mutual_friends')) {
$mutual = true;
- if(x($options,'single'))
+ }
+ if (x($options,'single')) {
$single = true;
- if(x($options,'multiple'))
+ }
+ if (x($options,'multiple')) {
$single = false;
- if(x($options,'exclude'))
+ }
+ if (x($options,'exclude')) {
$exclude = $options['exclude'];
+ }
- if(x($options,'networks')) {
+ if (x($options,'networks')) {
switch($options['networks']) {
case 'DFRN_ONLY':
$networks = array(NETWORK_DFRN);
call_hooks($a->module . '_pre_' . $selname, $arr);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
- if((is_array($preselected)) && in_array($rr['id'], $preselected))
+ foreach ($r as $rr) {
+ if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
$selected = " selected=\"selected\" ";
- else
+ } else {
$selected = '';
+ }
$trimmed = mb_substr($rr['name'],0,20);
$receiverlist = array();
if (dbm::is_result($r)) {
- foreach($r as $rr) {
- if((is_array($preselected)) && in_array($rr['id'], $preselected))
+ foreach ($r as $rr) {
+ if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
$selected = " selected=\"selected\" ";
- else
+ }
+ else {
$selected = '';
+ }
- if($privmail)
+ if ($privmail) {
$trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
- else
+ } else {
$trimmed = mb_substr($rr['name'],0,20);
+ }
$receiverlist[] = $trimmed;
function prune_deadguys($arr) {
- if(! $arr)
+ if (! $arr) {
return $arr;
+ }
+
$str = dbesc(implode(',',$arr));
+
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
- if($r) {
+
+ if ($r) {
$ret = array();
- foreach($r as $rr)
+ foreach ($r as $rr) {
$ret[] = intval($rr['id']);
+ }
return $ret;
}
+
return array();
}
function acl_lookup(&$a, $out_type = 'json') {
- if(!local_user())
- return "";
+ if (!local_user()) {
+ return '';
+ }
$start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0);
$count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100);
dbesc(NETWORK_ZOT),
dbesc(NETWORK_DIASPORA)
);
- }
- elseif($type == 'a') {
+ } elseif ($type == 'a') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
WHERE `uid` = %d AND `pending` = 0
$sql_extra2
ORDER BY `name` ASC ",
intval(local_user())
);
- }
- elseif($type == 'x') {
+ } elseif ($type == 'x') {
// autocomplete for global contact search (e.g. navbar search)
$r = navbar_complete($a);
$contacts = array();
- if($r) {
- foreach($r as $g) {
+ if ($r) {
+ foreach ($r as $g) {
$contacts[] = array(
- "photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
- "name" => $g['name'],
- "nick" => (x($g['addr']) ? $g['addr'] : $g['url']),
- "network" => $g['network'],
- "link" => $g['url'],
- "forum" => (x($g['community']) ? 1 : 0),
+ 'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
+ 'name' => $g['name'],
+ 'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
+ 'network' => $g['network'],
+ 'link' => $g['url'],
+ 'forum' => (x($g['community']) ? 1 : 0),
);
}
}
$o = array(
'start' => $start,
- 'count' => $count,
- 'items' => $contacts,
+ 'count' => $count,
+ 'items' => $contacts,
);
echo json_encode($o);
killme();
if (dbm::is_result($r)) {
- foreach($r as $g){
+ foreach ($r as $g){
$contacts[] = array(
- "type" => "c",
- "photo" => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
- "name" => htmlentities($g['name']),
- "id" => intval($g['id']),
- "network" => $g['network'],
- "link" => $g['url'],
- "nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
- "forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
+ 'type' => 'c',
+ 'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
+ 'name' => htmlentities($g['name']),
+ 'id' => intval($g['id']),
+ 'network' => $g['network'],
+ 'link' => $g['url'],
+ 'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
+ 'forum' => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
);
}
}
implode("','", $known_contacts)
);
if (dbm::is_result($r)){
- foreach($r as $row) {
+ foreach ($r as $row) {
// nickname..
$up = parse_url($row['author-link']);
$nick = explode("/",$up['path']);
$nick .= "@".$up['host'];
// /nickname
$unknow_contacts[] = array(
- "type" => "c",
- "photo" => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
- "name" => htmlentities($row['author-name']),
- "id" => '',
- "network" => "unknown",
- "link" => $row['author-link'],
- "nick" => htmlentities($nick),
- "forum" => false
+ 'type' => 'c',
+ 'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
+ 'name' => htmlentities($row['author-name']),
+ 'id' => '',
+ 'network' => 'unknown',
+ 'link' => $row['author-link'],
+ 'nick' => htmlentities($nick),
+ 'forum' => false
);
}
}
}
$results = array(
- "tot" => $tot,
- "start" => $start,
- "count" => $count,
- "groups" => $groups,
- "contacts" => $contacts,
- "items" => $items,
- "type" => $type,
- "search" => $search,
+ 'tot' => $tot,
+ 'start' => $start,
+ 'count' => $count,
+ 'groups' => $groups,
+ 'contacts' => $contacts,
+ 'items' => $items,
+ 'type' => $type,
+ 'search' => $search,
);
call_hooks('acl_lookup_end', $results);
if($out_type === 'html') {
$o = array(
- 'tot' => $results["tot"],
- 'start' => $results["start"],
- 'count' => $results["count"],
- 'groups' => $results["groups"],
- 'contacts' => $results["contacts"],
+ 'tot' => $results['tot'],
+ 'start' => $results['start'],
+ 'count' => $results['count'],
+ 'groups' => $results['groups'],
+ 'contacts' => $results['contacts'],
);
return $o;
}
$o = array(
- 'tot' => $results["tot"],
- 'start' => $results["start"],
- 'count' => $results["count"],
- 'items' => $results["items"],
+ 'tot' => $results['tot'],
+ 'start' => $results['start'],
+ 'count' => $results['count'],
+ 'items' => $results['items'],
);
echo json_encode($o);
// logger('navbar_complete');
- if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
$mode = $_REQUEST['smode'];
// don't search if search term has less than 2 characters
- if(! $search || mb_strlen($search) < 2)
+ if (! $search || mb_strlen($search) < 2) {
return array();
+ }
- if(substr($search,0,1) === '@')
+ if (substr($search,0,1) === '@') {
$search = substr($search,1);
+ }
- if($localsearch) {
+ if ($localsearch) {
$x = DirSearch::global_search_by_name($search, $mode);
return $x;
}
- if(! $localsearch) {
+ if (! $localsearch) {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
$x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
- if($x['success']) {
+ if ($x['success']) {
$t = 0;
$j = json_decode($x['body'],true);
- if($j && $j['results']) {
+ if ($j && $j['results']) {
return $j['results'];
}
}
}
+
+ /// @TODO Not needed here?
return;
}
'image/gif' => 'gif'
);
$data = array('photo'=>array());
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
$photo = array();
$photo['id'] = $rr['resource-id'];
$photo['album'] = $rr['album'];
$openid = new LightOpenID;
$openid->identity = $openid_url;
$_SESSION['openid'] = $openid_url;
- $a = get_app();
- $openid->returnUrl = $a->get_baseurl(true).'/openid';
+ $openid->returnUrl = App::get_baseurl(true).'/openid';
goaway($openid->authUrl());
} catch (Exception $e) {
notice(t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.').'<br /><br >'.t('The error message was:').' '.$e->getMessage());
function format_event_diaspora($ev) {
- $a = get_app();
-
if(! ((is_array($ev)) && count($ev)))
return '';
$ev['start'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['start'] , $bd_format)))
- . '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
+ . '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
if(! $ev['nofinish'])
$o .= t('Finishes:') . ' ' . '['
$ev['finish'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format )))
- . '](' . $a->get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
+ . '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
if(strlen($ev['location']))
$o .= t('Location:') . bb2diaspora($ev['location'])
$newbody = $body;
$cnt = 0;
- foreach($images as $image) {
+ foreach ($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that
// it loops over the array starting from the first element and going sequentially
// to the last element
}
function bb_DiasporaLinks($match) {
- $a = get_app();
-
- return "[url=".$a->get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]";
+ return "[url=".App::get_baseurl()."/display/".$match[1]."]".$match[2]."[/url]";
}
function bb_RemovePictureLinks($match) {
// we may need to restrict this further if it picks up too many strays
// link acct:user@host to a webfinger profile redirector
- $Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', '<a href="' . $a->get_baseurl() . '/acctlink?addr=$1@$2" target="extlink">acct:$1@$2</a>',$Text);
+ $Text = preg_replace('/acct:([^@]+)@((?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63})/', '<a href="' . App::get_baseurl() . '/acctlink?addr=$1@$2" target="extlink">acct:$1@$2</a>',$Text);
// Perform MAIL Search
$Text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '<a href="mailto:$1">$1</a>', $Text);
return(bb_ShareAttributes($match, $simplehtml));
},$Text);
- $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
- $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
- //$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
+ $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
+ $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
+ //$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .App::get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
// Try to Oembed
intval($_SESSION['uid']));
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
}
$a = get_app();
- if(!local_user())
+ if (!local_user()) {
return '';
+ }
- if(!feature_enabled(local_user(),'networks'))
+ if (!feature_enabled(local_user(),'networks')) {
return '';
+ }
$extra_sql = unavailable_networks();
$nets = array();
if (dbm::is_result($r)) {
require_once('include/contact_selectors.php');
- foreach($r as $rr) {
- if($rr['network'])
- $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
+ foreach ($r as $rr) {
+ /// @TODO If 'network' is not there, this triggers an E_NOTICE
+ if ($rr['network']) {
+ $nets[] = array('ref' => $rr['network'], 'name' => network_to_name($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
+ }
}
}
}
function fileas_widget($baseurl,$selected = '') {
- $a = get_app();
- if(! local_user())
+ if (! local_user()) {
return '';
+ }
- if(! feature_enabled(local_user(),'filing'))
+ if (! feature_enabled(local_user(),'filing')) {
return '';
+ }
$saved = get_pconfig(local_user(),'system','filetags');
- if(! strlen($saved))
+ if (! strlen($saved)) {
return;
+ }
$matches = false;
$terms = array();
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
- '$base' => $a->get_baseurl(),
+ '$base' => App::get_baseurl(),
'$uid' => $profile_uid,
'$cid' => (($cid) ? $cid : '0'),
'$linkmore' => (($t > 5) ? 'true' : ''),
$newbody .= $origbody;
$cnt = 0;
- foreach($images as $image) {
+ foreach ($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that
// it loops over the array starting from the first element and going sequentially
// to the last element
// add sparkle links to appropriate permalinks
$x = stristr($item['plink'],'/display/');
- if($x) {
+ if ($x) {
$sparkle = false;
$y = best_link_url($item,$sparkle,true);
- if(strstr($y,'/redir/'))
+
+ if (strstr($y,'/redir/')) {
$item['plink'] = $y . '?f=&url=' . $item['plink'];
+ }
}
}
$o = replace_macros($page_template, array(
- '$baseurl' => $a->get_baseurl($ssl_state),
+ '$baseurl' => App::get_baseurl($ssl_state),
'$return_path' => $a->query_string,
'$live_update' => $live_update_div,
'$remove' => t('remove'),
$tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array(
'$newpost' => 'true',
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$geotag' => $geotag,
'$nickname' => $x['nickname'],
$tpl = get_markup_template('jot-end.tpl');
$a->page['end'] .= replace_macros($tpl, array(
'$newpost' => 'true',
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$geotag' => $geotag,
'$nickname' => $x['nickname'],
'$ptyp' => (($notes_cid) ? 'note' : 'wall'),
'$content' => $x['content'],
'$post_id' => $x['post_id'],
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$defloc' => $x['default_location'],
'$visitor' => $x['visitor'],
'$pvisit' => (($notes_cid) ? 'none' : $x['visitor']),
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
logger('update_contact_birthday: ' . $rr['bd']);
}
// every admin could had different language
-
foreach ($adminlist as $admin) {
$lang = (($admin['language'])?$admin['language']:'en');
push_lang($lang);
$email_tpl = get_intltext_template("update_fail_eml.tpl");
$email_msg = replace_macros($email_tpl, array(
'$sitename' => $a->config['sitename'],
- '$siteurl' => $a->get_baseurl(),
+ '$siteurl' => App::get_baseurl(),
'$update' => DB_UPDATE_VERSION,
'$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
));
- $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
+ $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
require_once('include/email.php');
$subject = email_header_encode($subject,'UTF-8');
mail($a->config['admin_email'], $subject, $email_msg,
if (dbm::is_result($indexes))
foreach ($indexes AS $index) {
- if ($index["Index_type"] == "FULLTEXT")
+ if ($index["Index_type"] == "FULLTEXT") {
continue;
+ }
if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
$indexdata[$index["Key_name"]] = array('UNIQUE');
// To avoid the need to add this to every index definition we just ignore it here.
// Exception are primary indexes
// Since there are some combindex primary indexes we use the limit of 180 here.
- if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY")))
+ if (($index["Sub_part"] != "") AND (($index["Sub_part"] < 180) OR ($index["Key_name"] == "PRIMARY"))) {
$column .= "(".$index["Sub_part"].")";
+ }
$indexdata[$index["Key_name"]][] = $column;
}
if (dbm::is_result($structures)) {
- foreach($structures AS $field) {
+ foreach ($structures AS $field) {
$fielddata[$field["Field"]]["type"] = $field["Type"];
- if ($field["Null"] == "NO")
+ if ($field["Null"] == "NO") {
$fielddata[$field["Field"]]["not null"] = true;
+ }
- if (isset($field["Default"]))
+ if (isset($field["Default"])) {
$fielddata[$field["Field"]]["default"] = $field["Default"];
+ }
- if ($field["Extra"] != "")
+ if ($field["Extra"] != "") {
$fielddata[$field["Field"]]["extra"] = $field["Extra"];
+ }
- if ($field["Key"] == "PRI")
+ if ($field["Key"] == "PRI") {
$fielddata[$field["Field"]]["primary"] = true;
+ }
}
}
return(array("fields"=>$fielddata, "indexes"=>$indexdata));
function update_structure($verbose, $action, $tables=null, $definition=null) {
global $a, $db;
- if ($action)
+ if ($action) {
set_config('system', 'maintenance', 1);
+ }
- if (isset($a->config["system"]["db_charset"]))
+ if (isset($a->config["system"]["db_charset"])) {
$charset = $a->config["system"]["db_charset"];
- else
+ } else {
$charset = "utf8";
+ }
$errors = false;
// Get the current structure
$database = array();
- if (is_null($tables))
- $tables = q("show tables");
+ if (is_null($tables)) {
+ $tables = q("SHOW TABLES");
+ }
foreach ($tables AS $table) {
$table = current($table);
}
// Get the definition
- if (is_null($definition))
+ if (is_null($definition)) {
$definition = db_definition($charset);
+ }
// Ensure index conversion to unique removes duplicates
$sql_config = "SET session old_alter_table=1;";
- if ($verbose)
+ if ($verbose) {
echo $sql_config."\n";
- if ($action)
- @$db->q($sql_config);
+ }
+ if ($action) {
+ $db->q($sql_config);
+ }
// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
!(strpos($db->server_info(), 'MariaDB') !== false)) {
$ignore = '';
- }else {
+ } else {
$ignore = ' IGNORE';
}
}
$is_new_table = True;
} else {
- // Drop the index if it isn't present in the definition
- // or the definition differ from current status
- // and index name doesn't start with "local_"
- foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) {
+ /*
+ * Drop the index if it isn't present in the definition
+ * or the definition differ from current status
+ * and index name doesn't start with "local_"
+ */
+ foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
$current_index_definition = implode(",",$fieldnames);
if (isset($structure["indexes"][$indexname])) {
$new_index_definition = implode(",",$structure["indexes"][$indexname]);
}
if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
$sql2=db_drop_index($indexname);
- if ($sql3 == "")
+ if ($sql3 == "") {
$sql3 = "ALTER".$ignore." TABLE `".$name."` ".$sql2;
- else
+ } else {
$sql3 .= ", ".$sql2;
+ }
}
}
// Compare the field structure field by field
foreach ($structure["fields"] AS $fieldname => $parameters) {
if (!isset($database[$name]["fields"][$fieldname])) {
$sql2=db_add_table_field($fieldname, $parameters);
- if ($sql3 == "")
+ if ($sql3 == "") {
$sql3 = "ALTER TABLE `".$name."` ".$sql2;
- else
+ } else {
$sql3 .= ", ".$sql2;
+ }
} else {
// Compare the field definition
$current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
$new_field_definition = implode(",",$parameters);
if ($current_field_definition != $new_field_definition) {
$sql2=db_modify_table_field($fieldname, $parameters);
- if ($sql3 == "")
+ if ($sql3 == "") {
$sql3 = "ALTER TABLE `".$name."` ".$sql2;
- else
+ } else {
$sql3 .= ", ".$sql2;
+ }
}
}
}
}
- // Create the index if the index don't exists in database
- // or the definition differ from the current status.
- // Don't create keys if table is new
+ /*
+ * Create the index if the index don't exists in database
+ * or the definition differ from the current status.
+ * Don't create keys if table is new
+ */
if (!$is_new_table) {
foreach ($structure["indexes"] AS $indexname => $fieldnames) {
if (isset($database[$name]["indexes"][$indexname])) {
if ($names != "")
$names .= ",";
- if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
+ if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
$names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
- else
+ } else {
$names .= "`".dbesc($fieldname)."`";
+ }
}
if ($indexname == "PRIMARY") {
}
function db_index_suffix($charset, $reduce = 0) {
- if ($charset != "utf8mb4")
+ if ($charset != "utf8mb4") {
return "";
+ }
// On utf8mb4 indexes can only have a length of 191
$indexlength = 191 - $reduce;
echo "dumpsql dump database schema\n";
return;
-
-
-
}
if (array_search(__file__,get_included_files())===0){
// perform local delivery if we are on the same site
- if (link_compare($basepath,$a->get_baseurl())) {
+ if (link_compare($basepath,App::get_baseurl())) {
$nickname = basename($contact['url']);
if ($contact['issued-id'])
dbesc($owner_nick)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
killme();
+ }
$owner = $r[0];
$owner_id = $owner['uid'];
intval($owner_id)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
killme();
+ }
$contact = $r[0];
require_once('include/security.php');
dbesc(NETWORK_DIASPORA),
dbesc($msg["author"])
);
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
logger("delivering to: ".$rr["username"]);
self::dispatch($rr,$msg);
}
dbesc($guid)
);
- if($r) {
+ if ($r) {
logger("message ".$guid." already exists for user ".$uid);
return $r[0]["id"];
}
$author = unxmlify($data->author);
$recipient = unxmlify($data->recipient);
- if (!$author || !$recipient)
+ if (!$author || !$recipient) {
return false;
+ }
// the current protocol version doesn't know these fields
// That means that we will assume their existance
- if (isset($data->following))
+ if (isset($data->following)) {
$following = (unxmlify($data->following) == "true");
- else
+ } else {
$following = true;
+ }
- if (isset($data->sharing))
+ if (isset($data->sharing)) {
$sharing = (unxmlify($data->sharing) == "true");
- else
+ } else {
$sharing = true;
+ }
$contact = self::contact_by_handle($importer["uid"],$author);
// Normally we needn't to do so, but the first message could have been vanished.
if (in_array($contact["rel"], array(CONTACT_IS_FRIEND, CONTACT_IS_FOLLOWER))) {
$u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer["uid"]));
- if($u) {
+ if ($u) {
logger("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], LOGGER_DEBUG);
$ret = self::send_share($u[0], $contact);
}
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
$contact = self::allowed_contact_by_handle($importer, $author, false);
- if (!$contact)
+ if (!$contact) {
return false;
+ }
$message_id = self::message_exists($importer["uid"], $guid);
- if ($message_id)
+ if ($message_id) {
return $message_id;
+ }
$original_item = self::original_item($root_guid, $root_author, $author);
- if (!$original_item)
+ if (!$original_item) {
return false;
+ }
$orig_url = App::get_baseurl()."/display/".$original_item["guid"];
self::fetch_guid($datarray);
$message_id = item_store($datarray);
- if ($message_id)
+ if ($message_id) {
logger("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
+ }
return $message_id;
}
logger("transmit: ".$logid."-".$guid." returns: ".$return_code);
- if(!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
+ if (!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
logger("queue message");
$r = q("SELECT `id` FROM `queue` WHERE `cid` = %d AND `network` = '%s' AND `content` = '%s' AND `batch` = %d LIMIT 1",
dbesc($slap),
intval($public_batch)
);
- if($r) {
+ if ($r) {
logger("add_to_queue ignored - identical item already in queue");
} else {
// queue message for redelivery
$html = '';
foreach($struc->parts as $ptop => $p) {
$x = email_get_part($mbox,$uid,$p,$ptop + 1, 'plain');
- if($x) $text .= $x;
+ if ($x) {
+ $text .= $x;
+ }
$x = email_get_part($mbox,$uid,$p,$ptop + 1, 'html');
- if($x) $html .= $x;
+ if ($x) {
+ $html .= $x;
+ }
}
- if (trim($html) != '')
+ if (trim($html) != '') {
$ret['body'] = html2bbcode($html);
- else
+ } else {
$ret['body'] = $text;
+ }
}
$ret['body'] = removegpg($ret['body']);
$ret['body'] = $msg['body'];
$ret['body'] = convertquote($ret['body'], $reply);
- if (trim($html) != '')
+ if (trim($html) != '') {
$ret['body'] = removelinebreak($ret['body']);
+ }
$ret['body'] = unifyattributionline($ret['body']);
$x = "";
foreach ($p->parts as $partno0=>$p2) {
$x .= email_get_part($mbox,$uid,$p2,$partno . '.' . ($partno0+1), $subtype); // 1.2, 1.2.1, etc.
- //if($x)
+ //if ($x) {
// return $x;
+ //}
}
return $x;
}
$banner = t('Friendica Notification');
$product = FRIENDICA_PLATFORM;
- $siteurl = $a->get_baseurl(true);
+ $siteurl = App::get_baseurl(true);
$thanks = t('Thank You,');
$sitename = $a->config['sitename'];
if (!x($a->config['admin_name']))
$additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
$additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
$additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
- $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
+ $additional_mail_header .= "List-Archive: <".App::get_baseurl()."/notifications/system>\n";
if (array_key_exists('item', $params)) {
$title = $params['item']['title'];
}
- $itemlink = $a->get_baseurl().'/notify/view/'.$notify_id;
+ $itemlink = App::get_baseurl().'/notify/view/'.$notify_id;
$msg = replace_macros($epreamble, array('$itemlink' => $itemlink));
$msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg)));
$r = q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d",
* @param str $defaulttype (Optional) Forces a notification with this type.
*/
function check_item_notification($itemid, $uid, $defaulttype = "") {
- $a = get_app();
-
$notification_data = array("uid" => $uid, "profiles" => array());
call_hooks('check_item_notification', $notification_data);
$profiles[] = $owner[0]["url"];
// Notifications from Diaspora are often with an URL in the Diaspora format
- $profiles[] = $a->get_baseurl()."/u/".$user[0]["nickname"];
+ $profiles[] = App::get_baseurl()."/u/".$user[0]["nickname"];
$profiles2 = array();
intval($arr['uid'])
);
//if (dbm::is_result($r))
- // $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
+ // $plink = App::get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
if($item_id) {
$r = q("SELECT `uid`,`username`,`expire` FROM `user` WHERE `expire` != 0");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
logger('Expire: ' . $rr['username'] . ' interval: ' . $rr['expire'], LOGGER_DEBUG);
item_expire($rr['uid'],$rr['expire']);
}
$url = str_replace('/#!/','/',$url);
- if(! allowed_url($url)) {
+ if (! allowed_url($url)) {
$result['message'] = t('Disallowed profile URL.');
return $result;
}
- if(! $url) {
+ if (! $url) {
$result['message'] = t('Connect URL missing.');
return $result;
}
call_hooks('follow', $arr);
- if(x($arr['contact'],'name'))
+ if (x($arr['contact'],'name')) {
$ret = $arr['contact'];
- else
+ }
+ else {
$ret = probe_url($url);
+ }
- if($ret['network'] === NETWORK_DFRN) {
- if($interactive) {
- if(strlen($a->path))
- $myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']);
- else
+ if ($ret['network'] === NETWORK_DFRN) {
+ if ($interactive) {
+ if (strlen($a->path)) {
+ $myaddr = bin2hex(App::get_baseurl() . '/profile/' . $a->user['nickname']);
+ }
+ else {
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
+ }
goaway($ret['request'] . "&addr=$myaddr");
intval($uid)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$result['message'] .= t('Unable to retrieve contact information.') . EOL;
return $result;
}
$r = q("SELECT def_gid, allow_gid, deny_gid FROM user WHERE uid = %d LIMIT 1",
intval($uid)
);
- if($r) {
+ if ($r) {
$user_info = $r[0];
$change = false;
return true; // You might question this, but
// we indicate success because the group member was in fact created
// -- It was just created at another time
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
$r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`)
VALUES( %d, %d, %d ) ",
intval($uid),
intval($gid),
intval($member)
- );
+ );
+ }
return $r;
}
);
$grps[] = array('name' => '', 'id' => '0', 'selected' => '');
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$grps[] = array('name' => $rr['name'], 'id' => $rr['id'], 'selected' => (($gid == $rr['id']) ? 'true' : ''));
}
$o = '';
- if(! local_user())
+ if (! local_user())
return '';
$groups = array();
}
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$selected = (($group_id == $rr['id']) ? ' group-selected' : '');
if ($editmode == "full") {
// Is the local user already connected to that user?
if ($connect AND local_user()) {
- if (isset($profile["url"]))
+ if (isset($profile["url"])) {
$profile_url = normalise_link($profile["url"]);
- else
- $profile_url = normalise_link($a->get_baseurl()."/profile/".$profile["nickname"]);
+ }
+ else {
+ $profile_url = normalise_link(App::get_baseurl()."/profile/".$profile["nickname"]);
+ }
$r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
local_user(), $profile_url);
+
if (dbm::is_result($r))
$connect = false;
}
// show edit profile to yourself
if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
- $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
+ $profile['edit'] = array(App::get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
$r = q("SELECT * FROM `profile` WHERE `uid` = %d",
local_user());
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$profile['menu']['entries'][] = array(
'photo' => $rr['thumb'],
'id' => $rr['id'],
}
}
if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) {
- $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
+ $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
$profile['menu'] = array(
'chg_photo' => t('Change profile photo'),
'cr_new' => null,
if ($profile['guid'] != "")
$diaspora = array(
'guid' => $profile['guid'],
- 'podloc' => $a->get_baseurl(),
+ 'podloc' => App::get_baseurl(),
'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
'nickname' => $profile['nickname'],
'fullname' => $profile['name'],
'firstname' => $firstname,
'lastname' => $lastname,
- 'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
- 'photo100' => $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
- 'photo50' => $a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg',
+ 'photo300' => App::get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
+ 'photo100' => App::get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
+ 'photo50' => App::get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg',
);
else
$diaspora = false;
$cids = array();
$istoday = false;
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if(strlen($rr['name']))
$total ++;
if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
$url = $rr['url'];
if($rr['network'] === NETWORK_DFRN) {
$sparkle = " sparkle";
- $url = $a->get_baseurl() . '/redir/' . $rr['cid'];
+ $url = App::get_baseurl() . '/redir/' . $rr['cid'];
}
$rr['link'] = $url;
}
$tpl = get_markup_template("birthdays_reminder.tpl");
return replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$classtoday' => $classtoday,
'$count' => $total,
'$event_reminders' => t('Birthday Reminders'),
if (dbm::is_result($r)) {
$now = strtotime('now');
$istoday = false;
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if(strlen($rr['name']))
$total ++;
$tpl = get_markup_template("events_reminder.tpl");
return replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$classtoday' => $classtoday,
'$count' => count($r) - $skip,
'$event_reminders' => t('Event Reminders'),
$profile['forumlist'] = array( t('Forums:'), ForumManager::profile_advanced($uid));
}
- if ($a->profile['uid'] == local_user())
- $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
+ if ($a->profile['uid'] == local_user()) {
+ $profile['edit'] = array(App::get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
+ }
return replace_macros($tpl, array(
'$title' => t('Profile'),
if(x($_GET,'tab'))
$tab = notags(trim($_GET['tab']));
- $url = $a->get_baseurl() . '/profile/' . $nickname;
+ $url = App::get_baseurl() . '/profile/' . $nickname;
$tabs = array(
array(
),
array(
'label' => t('Photos'),
- 'url' => $a->get_baseurl() . '/photos/' . $nickname,
+ 'url' => App::get_baseurl() . '/photos/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''),
'title' => t('Photo Albums'),
'id' => 'photo-tab',
),
array(
'label' => t('Videos'),
- 'url' => $a->get_baseurl() . '/videos/' . $nickname,
+ 'url' => App::get_baseurl() . '/videos/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='videos')?'active':''),
'title' => t('Videos'),
'id' => 'video-tab',
if ($is_owner && $a->theme_events_in_profile) {
$tabs[] = array(
'label' => t('Events'),
- 'url' => $a->get_baseurl() . '/events',
+ 'url' => App::get_baseurl() . '/events',
'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''),
'title' => t('Events and Calendar'),
'id' => 'events-tab',
} elseif (! $is_owner) {
$tabs[] = array(
'label' => t('Events'),
- 'url' => $a->get_baseurl() . '/cal/' . $nickname,
+ 'url' => App::get_baseurl() . '/cal/' . $nickname,
'sel' =>((!isset($tab)&&$a->argv[0]=='cal')?'active':''),
'title' => t('Events and Calendar'),
'id' => 'events-tab',
if ($is_owner){
$tabs[] = array(
'label' => t('Personal Notes'),
- 'url' => $a->get_baseurl() . '/notes',
+ 'url' => App::get_baseurl() . '/notes',
'sel' =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''),
'title' => t('Only You Can See This'),
'id' => 'notes-tab',
if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) {
$tabs[] = array(
'label' => t('Contacts'),
- 'url' => $a->get_baseurl() . '/viewcontacts/' . $nickname,
+ 'url' => App::get_baseurl() . '/viewcontacts/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''),
'title' => t('Contacts'),
'id' => 'viewcontacts-tab',
$hashtags = "";
if (isset($data["keywords"]) AND count($data["keywords"])) {
- $a = get_app();
$hashtags = "\n";
foreach ($data["keywords"] AS $keyword) {
/// @todo make a positive list of allowed characters
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"),
array("","", "", "", "", "", "", "", "", "", "", ""), $keyword);
- $hashtags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] ";
+ $hashtags .= "#[url=".App::get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] ";
}
}
$tags = "";
if (isset($data["keywords"]) AND count($data["keywords"])) {
- $a = get_app();
foreach ($data["keywords"] AS $keyword) {
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"),
array("","", "", "", "", ""), $keyword);
if ($tags != "")
$tags .= ",";
- $tags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]";
+ $tags .= "#[url=".App::get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url]";
}
}
logger("Both author-link and owner-link are empty. Called by: ".App::callstack(), LOGGER_DEBUG);
if ($arr['plink'] == "") {
- $a = get_app();
- $arr['plink'] = $a->get_baseurl().'/display/'.urlencode($arr['guid']);
+ $arr['plink'] = App::get_baseurl().'/display/'.urlencode($arr['guid']);
}
if ($arr['network'] == "") {
$u = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($arr['uid']));
if (count($u)) {
$a = get_app();
- $self = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+ $self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
if ((normalise_link($arr['author-link']) == $self) OR (normalise_link($arr['owner-link']) == $self)) {
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id));
// All hashtags should point to the home server
//$item["body"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
- // "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]);
+ // "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["body"]);
//$item["tag"] = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
- // "#[url=".$a->get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]);
+ // "#[url=".App::get_baseurl()."/search?tag=$2]$2[/url]", $item["tag"]);
// mask hashtags inside of url, bookmarks and attachments to avoid urls in urls
$item["body"] = preg_replace_callback("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
$basetag = str_replace('_',' ',substr($tag,1));
- $newtag = '#[url='.$a->get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]';
+ $newtag = '#[url='.App::get_baseurl().'/search?tag='.rawurlencode($basetag).']'.$basetag.'[/url]';
$item["body"] = str_replace($tag, $newtag, $item["body"]);
$item = $i[0];
- $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+ $link = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
// Diaspora uses their own hardwired link URL in @-tags
// instead of the one we supply with webfinger
- $dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']);
+ $dlink = normalise_link(App::get_baseurl() . '/u/' . $u[0]['nickname']);
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if ($cnt) {
$c = q("select name, url, thumb from contact where self = 1 and uid = %d limit 1",
intval($u[0]['uid'])
);
- if (! count($c))
+ if (! count($c)) {
return;
+ }
// also reset all the privacy bits to the forum default permissions
$forum_mode = (($prvgroup) ? 2 : 1);
- q("update item set wall = 1, origin = 1, forum_mode = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
- `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d",
+ q("UPDATE `item` SET `wall` = 1, `origin` = 1, `forum_mode` = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
+ `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `id` = %d",
intval($forum_mode),
dbesc($c[0]['name']),
dbesc($c[0]['url']),
$prvgroup = (($u[0]['page-flags'] == PAGE_PRVGROUP) ? true : false);
- $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+ $link = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
// Diaspora uses their own hardwired link URL in @-tags
// instead of the one we supply with webfinger
- $dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']);
+ $dlink = normalise_link(App::get_baseurl() . '/u/' . $u[0]['nickname']);
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if ($cnt) {
- foreach($matches as $mtch) {
+ foreach ($matches as $mtch) {
if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
$mention = true;
logger('tgroup_check: mention found: ' . $mtch[2]);
}
}
- if (! $mention)
- return false;
-
- if ((! $community_page) && (! $prvgroup))
+ if (! $mention) {
return false;
+ }
- return true;
+ /// @TODO Combines both return statements into one
+ return (($community_page) || ($prvgroup));
}
/*
assumes the update has been seen before and should be ignored.
*/
function edited_timestamp_is_newer($existing, $update) {
- if (!x($existing,'edited') || !$existing['edited']) {
- return true;
- }
- if (!x($update,'edited') || !$update['edited']) {
- return false;
- }
- $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']);
- $update_edited = datetime_convert('UTC', 'UTC', $update['edited']);
- return (strcmp($existing_edited, $update_edited) < 0);
+ if (!x($existing,'edited') || !$existing['edited']) {
+ return true;
+ }
+ if (!x($update,'edited') || !$update['edited']) {
+ return false;
+ }
+
+ $existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']);
+ $update_edited = datetime_convert('UTC', 'UTC', $update['edited']);
+ return (strcmp($existing_edited, $update_edited) < 0);
}
/**
'to_name' => $r[0]['username'],
'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'],
- 'link' => $a->get_baseurl() . '/notifications/intro',
+ 'link' => App::get_baseurl() . '/notifications/intro',
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : t('[Name Withheld]')),
'source_link' => $contact_record['url'],
'source_photo' => $contact_record['photo'],
$a = get_app();
logger('fix_private_photos: check for photos', LOGGER_DEBUG);
- $site = substr($a->get_baseurl(),strpos($a->get_baseurl(),'://'));
+ $site = substr(App::get_baseurl(),strpos(App::get_baseurl(),'://'));
$orig_body = $s;
$new_body = '';
if (! $interactive)
return 0;
notice( t('Item not found.') . EOL);
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
}
$item = $r[0];
}
// Now check how the user responded to the confirmation query
if ($_REQUEST['canceled']) {
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
}
logger('delete item: ' . $item['id'], LOGGER_DEBUG);
if (! $interactive)
return $owner;
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
//NOTREACHED
} else {
if (! $interactive)
return 0;
notice( t('Permission denied.') . EOL);
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
//NOTREACHED
}
break;
}
-
logger('like: verb ' . $verb . ' item ' . $item_id);
-
$r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
dbesc($item_id),
dbesc($item_id)
$owner_uid = $item['uid'];
- if(! can_write_wall($a,$owner_uid)) {
+ if (! can_write_wall($a,$owner_uid)) {
return false;
}
intval($item['contact-id']),
intval($item['uid'])
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
return false;
- if(! $r[0]['self'])
+ }
+ if (! $r[0]['self']) {
$remote_owner = $r[0];
+ }
}
// this represents the post owner on this system.
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
intval($owner_uid)
);
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$owner = $r[0];
+ }
- if(! $owner) {
+ if (! $owner) {
logger('like: no owner');
return false;
}
- if(! $remote_owner)
+ if (! $remote_owner) {
$remote_owner = $owner;
-
+ }
// This represents the person posting
- if((local_user()) && (local_user() == $owner_uid)) {
+ if ((local_user()) && (local_user() == $owner_uid)) {
$contact = $owner;
- }
- else {
+ } else {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($_SESSION['visitor_id']),
intval($owner_uid)
if (dbm::is_result($r))
$contact = $r[0];
}
- if(! $contact) {
+ if (! $contact) {
return false;
}
// event participation are essentially radio toggles. If you make a subsequent choice,
// we need to eradicate your first choice.
- if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
+ if ($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
}
$uri = item_new_uri($a->get_hostname(),$owner_uid);
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
- if($item['object-type'] === ACTIVITY_OBJ_EVENT)
+ if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$post_type = t('event');
+ }
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
- $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
+ $link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
$body = $item['body'];
$obj = <<< EOT
<content>$body</content>
</object>
EOT;
- if($verb === 'like')
+ if ($verb === 'like') {
$bodyverb = t('%1$s likes %2$s\'s %3$s');
- if($verb === 'dislike')
+ }
+ if ($verb === 'dislike') {
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
- if($verb === 'attendyes')
+ }
+ if ($verb === 'attendyes') {
$bodyverb = t('%1$s is attending %2$s\'s %3$s');
- if($verb === 'attendno')
+ }
+ if ($verb === 'attendno') {
$bodyverb = t('%1$s is not attending %2$s\'s %3$s');
- if($verb === 'attendmaybe')
+ }
+ if ($verb === 'attendmaybe') {
$bodyverb = t('%1$s may attend %2$s\'s %3$s');
+ }
- if(! isset($bodyverb))
- return false;
+ if (! isset($bodyverb)) {
+ return false;
+ }
+ $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
+ $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
+ $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
+
+ /// @TODO Or rewrite this to multi-line initialization of the array?
$arr = array();
$arr['guid'] = get_guid(32);
$arr['author-name'] = $contact['name'];
$arr['author-link'] = $contact['url'];
$arr['author-avatar'] = $contact['thumb'];
-
- $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
- $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
- $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
-
$arr['verb'] = $activity;
$arr['object-type'] = $objtype;
$arr['object'] = $obj;
$post_id = item_store($arr);
- if(! $item['visible']) {
+ if (! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']),
intval($owner_uid)
);
$got_lock = true;
}
- elseif(! dbm::is_result($r)) { // the Boolean value for count($r) should be equivalent to the Boolean value of $r
+ elseif (! dbm::is_result($r)) {
+ /// @TODO the Boolean value for count($r) should be equivalent to the Boolean value of $r
q("INSERT INTO `locks` (`name`, `created`, `locked`) VALUES ('%s', '%s', 1)",
dbesc($fn_name),
dbesc(datetime_convert())
}
$guid = get_guid(32);
- $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $guid;
+ $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
$convid = 0;
$reply = false;
$recip_host = substr($recip_host,0,strpos($recip_host,'/'));
$recip_handle = (($contact[0]['addr']) ? $contact[0]['addr'] : $contact[0]['nick'] . '@' . $recip_host);
- $sender_handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $sender_handle = $a->user['nickname'] . '@' . substr(App::get_baseurl(), strpos(App::get_baseurl(),'://') + 3);
$conv_guid = get_guid(32);
$convuri = $recip_handle.':'.$conv_guid;
$match = null;
- if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
+ if (preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
$images = $match[1];
- if(count($images)) {
- foreach($images as $image) {
- if(! stristr($image,$a->get_baseurl() . '/photo/'))
+ if (count($images)) {
+ foreach ($images as $image) {
+ if (! stristr($image,App::get_baseurl() . '/photo/')) {
continue;
+ }
$image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
$r = q("UPDATE `photo` SET `allow_cid` = '%s'
}
}
- if($post_id) {
+ if ($post_id) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "mail", $post_id);
return intval($post_id);
} else {
}
-
-
-
-
function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
- $a = get_app();
-
-
- if(! $recipient) return -1;
+ if (! $recipient) {
+ return -1;
+ }
- if(! strlen($subject))
+ if (! strlen($subject)) {
$subject = t('[no subject]');
+ }
$guid = get_guid(32);
- $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $guid;
+ $uri = 'urn:X-dfrn:' . App::get_baseurl() . ':' . local_user() . ':' . $guid;
$convid = 0;
$reply = false;
$me = probe_url($replyto);
- if(! $me['name'])
+ if (! $me['name']) {
return -2;
+ }
$conv_guid = get_guid(32);
- $recip_handle = $recipient['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $recip_handle = $recipient['nickname'] . '@' . substr(App::get_baseurl(), strpos(App::get_baseurl(),'://') + 3);
$sender_nick = basename($replyto);
$sender_host = substr($replyto,strpos($replyto,'://')+3);
$handles = $recip_handle . ';' . $sender_handle;
- $r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
+ $r = q("INSERT INTO `conv` (`uid`,`guid`,`creator`,`created`,`updated`,`subject`,`recips`) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
intval($recipient['uid']),
dbesc($conv_guid),
dbesc($sender_handle),
dbesc($handles)
);
- $r = q("select * from conv where guid = '%s' and uid = %d limit 1",
+ $r = q("SELECT * FROM `conv` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($conv_guid),
intval($recipient['uid'])
);
- if (dbm::is_result($r))
- $convid = $r[0]['id'];
- if(! $convid) {
+
+ if (! dbm::is_result($r)) {
logger('send message: conversation not found.');
return -4;
}
+ $convid = $r[0]['id'];
+
$r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`)
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )",
$tpl = get_markup_template('nav.tpl');
$a->page['nav'] .= replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$sitelocation' => $nav_info['sitelocation'],
'$nav' => $nav_info['nav'],
'$banner' => $nav_info['banner'],
$myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
- $sitelocation = $myident . substr($a->get_baseurl($ssl_state), strpos($a->get_baseurl($ssl_state), '//') + 2 );
+ $sitelocation = $myident . substr(App::get_baseurl($ssl_state), strpos(App::get_baseurl($ssl_state), '//') + 2 );
// nav links: array of array('href', 'text', 'extra css classes', 'title')
$nav = array();
function avatar_img($email) {
- $a = get_app();
-
$avatar['size'] = 175;
$avatar['email'] = $email;
$avatar['url'] = '';
call_hooks('avatar_lookup', $avatar);
- if(! $avatar['success'])
- $avatar['url'] = $a->get_baseurl() . '/images/person-175.jpg';
+ if (! $avatar['success']) {
+ $avatar['url'] = App::get_baseurl() . '/images/person-175.jpg';
+ }
logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG);
return $avatar['url'];
foreach($matches as $mtch) {
logger('scale_external_image: ' . $mtch[1]);
- $hostname = str_replace('www.','',substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3));
+ $hostname = str_replace('www.','',substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3));
if(stristr($mtch[1],$hostname))
continue;
intval($uid)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
return;
+ }
$owner = $r[0];
if($slap && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) {
if(!get_config('system','dfrn_only')) {
foreach($url_recipients as $url) {
- if($url) {
+ if ($url) {
logger('notifier: urldelivery: ' . $url);
$deliver_status = slapper($owner,$url,$slap);
/// @TODO Redeliver/queue these items on failure, though there is no contact record
// throw everything into the queue in case we get killed
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if((! $mail) && (! $fsuggest) && (! $followup)) {
q("INSERT INTO `deliverq` (`cmd`,`item`,`contact`) VALUES ('%s', %d, %d)
ON DUPLICATE KEY UPDATE `cmd` = '%s', `item` = %d, `contact` = %d",
}
}
- foreach($r as $rr) {
+ foreach ($r as $rr) {
// except for Diaspora batch jobs
// Don't deliver to folks who have already been delivered to
} else {
- $params = 'hub.mode=publish&hub.url=' . urlencode( $a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
+ $params = 'hub.mode=publish&hub.url=' . urlencode( App::get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
post_url($h,$params);
logger('publish for item '.$item_id.' ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code());
}
$_SESSION['mobile-theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme');
$_SESSION['authenticated'] = 1;
$_SESSION['page_flags'] = $record['page-flags'];
- $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $record['nickname'];
+ $_SESSION['my_url'] = App::get_baseurl() . '/profile/' . $record['nickname'];
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
$_SESSION["allow_api"] = true;
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($importer_uid)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
return;
+ }
$importer = $r[0];
$a = get_app();
$a->hooks = array();
$r = q("SELECT * FROM `hook` WHERE 1 ORDER BY `priority` DESC, `file`");
+
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if(! array_key_exists($rr['hook'],$a->hooks))
$a->hooks[$rr['hook']] = array();
$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
* @return string
*/
function get_theme_screenshot($theme) {
- $a = get_app();
$exts = array('.png','.jpg');
foreach($exts as $ext) {
- if(file_exists('view/theme/' . $theme . '/screenshot' . $ext))
- return($a->get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
+ if(file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
+ return(App::get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
+ }
}
- return($a->get_baseurl() . '/images/blank.png');
+ return(App::get_baseurl() . '/images/blank.png');
}
// install and uninstall theme
return;
}
- $url = get_app()->get_baseurl()."/worker";
+ $url = App::get_baseurl()."/worker";
fetch_url($url, false, $redirects, 1);
}
$headers = array("Content-type: application/atom+xml",
sprintf("Link: <%s>;rel=hub,<%s>;rel=self",
- $a->get_baseurl().'/pubsubhubbub',
+ App::get_baseurl().'/pubsubhubbub',
$rr['topic']),
"X-Hub-Signature: sha1=".$hmac_sig);
load_config('system');
// Don't check this stuff if the function is called by the poller
- if (App::callstack() != "poller_run")
- if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540))
+ if (App::callstack() != "poller_run") {
+ if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540)) {
return;
+ }
+ }
$a->set_baseurl(get_config('system','url'));
load_hooks();
- if($argc > 1)
+ if ($argc > 1) {
$pubsubpublish_id = intval($argv[1]);
+ }
else {
// We'll push to each subscriber that has push > 0,
// i.e. there has been an update (set in notifier.php).
$interval = Config::get("system", "delivery_interval", 2);
// If we are using the worker we don't need a delivery interval
- if (get_config("system", "worker"))
+ if (get_config("system", "worker")) {
$interval = false;
+ }
- foreach($r as $rr) {
+ foreach ($r as $rr) {
logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);
$interval = false;
$r = q("select * from deliverq where 1");
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
logger('queue: deliverq');
proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+ if($interval) {
+ time_sleep_until(microtime(true) + (float) $interval);
+ }
}
}
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
}
//
// We also have to make sure that I'm a legitimate contact--I'm not blocked or pending.
- $baseurl = $a->get_baseurl();
+ $baseurl = App::get_baseurl();
$domain_st = strpos($baseurl, "://");
if($domain_st === false)
return;
dbesc($nurl)
);
- if((! dbm::is_result($r)) || $r[0]['id'] == remote_user())
+ if ((! dbm::is_result($r)) || $r[0]['id'] == remote_user()) {
return;
-
+ }
$r = q("SELECT * FROM contact WHERE nick = '%s'
AND network = '%s' AND uid = %d AND url LIKE '%%%s%%' LIMIT 1",
dbesc($baseurl)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
return;
+ }
$cid = $r[0]['id'];
// We have found at least one key URL
// If it's inline, parse it - otherwise get the key
- if(count($ret)) {
- for($x = 0; $x < count($ret); $x ++) {
- if(substr($ret[$x],0,5) === 'data:') {
- if(strstr($ret[$x],','))
+ if (count($ret) > 0) {
+ for ($x = 0; $x < count($ret); $x ++) {
+ if (substr($ret[$x],0,5) === 'data:') {
+ if (strstr($ret[$x],',')) {
$ret[$x] = substr($ret[$x],strpos($ret[$x],',')+1);
- else
+ } else {
$ret[$x] = substr($ret[$x],5);
- } elseif (normalise_link($ret[$x]) == 'http://')
+ }
+ } elseif (normalise_link($ret[$x]) == 'http://') {
$ret[$x] = fetch_url($ret[$x]);
+ }
}
}
logger('Key located: ' . print_r($ret,true));
- if(count($ret) == 1) {
+ if (count($ret) == 1) {
// We only found one one key so we don't care if the hash matches.
// If it's the wrong key we'll find out soon enough because
return $ret[0];
}
else {
- foreach($ret as $a) {
+ foreach ($ret as $a) {
$hash = base64url_encode(hash('sha256',$a));
- if($hash == $keyhash)
+ if ($hash == $keyhash) {
return $a;
+ }
}
}
$_SESSION['mobile-theme'] = get_pconfig($user_record['uid'], 'system', 'mobile_theme');
$_SESSION['authenticated'] = 1;
$_SESSION['page_flags'] = $user_record['page-flags'];
- $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname'];
- $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
+ $_SESSION['my_url'] = App::get_baseurl() . '/profile/' . $user_record['nickname'];
+ $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3);
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
$a->user = $user_record;
}
- if($login_initial) {
+ if ($login_initial) {
call_hooks('logged_in', $a->user);
- if(($a->module !== 'home') && isset($_SESSION['return_url']))
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ if (($a->module !== 'home') && isset($_SESSION['return_url'])) {
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
+ }
}
}
static $verified = 0;
- if((! (local_user())) && (! (remote_user())))
+ if ((! (local_user())) && (! (remote_user()))) {
return false;
+ }
$uid = local_user();
- if(($uid) && ($uid == $owner)) {
+ if (($uid) && ($uid == $owner)) {
return true;
}
- if(remote_user()) {
+ if (remote_user()) {
// use remembered decision and avoid a DB lookup for each and every display item
// DO NOT use this function if there are going to be multiple owners
// We have a contact-id for an authenticated remote user, this block determines if the contact
// belongs to this page owner, and has the necessary permissions to post content
- if($verified === 2)
+ if ($verified === 2) {
return true;
- elseif($verified === 1)
+ } elseif ($verified === 1) {
return false;
- else {
+ } else {
$cid = 0;
- if(is_array($_SESSION['remote'])) {
- foreach($_SESSION['remote'] as $visitor) {
- if($visitor['uid'] == $owner) {
+ if (is_array($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $visitor) {
+ if ($visitor['uid'] == $owner) {
$cid = $visitor['cid'];
break;
}
}
}
- if(! $cid)
+ if (! $cid) {
return false;
-
+ }
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid`
WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
notice( check_form_security_std_err_msg() );
- goaway($a->get_baseurl() . $err_redirect );
+ goaway(App::get_baseurl() . $err_redirect );
}
}
function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') {
$name = $entry->displayName;
- if(isset($entry->urls)) {
- foreach($entry->urls as $url) {
- if($url->type == 'profile') {
+ if (isset($entry->urls)) {
+ foreach ($entry->urls as $url) {
+ if ($url->type == 'profile') {
$profile_url = $url->value;
continue;
}
- if($url->type == 'webfinger') {
+ if ($url->type == 'webfinger') {
$connect_url = str_replace('acct:' , '', $url->value);
continue;
}
}
}
- if(isset($entry->photos)) {
- foreach($entry->photos as $photo) {
- if($photo->type == 'profile') {
+ if (isset($entry->photos)) {
+ foreach ($entry->photos as $photo) {
+ if ($photo->type == 'profile') {
$profile_photo = $photo->value;
continue;
}
}
}
- if(isset($entry->updated))
+ if (isset($entry->updated)) {
$updated = date("Y-m-d H:i:s", strtotime($entry->updated));
+ }
- if(isset($entry->network))
+ if (isset($entry->network)) {
$network = $entry->network;
+ }
- if(isset($entry->currentLocation))
+ if (isset($entry->currentLocation)) {
$location = $entry->currentLocation;
+ }
- if(isset($entry->aboutMe))
+ if (isset($entry->aboutMe)) {
$about = html2bbcode($entry->aboutMe);
+ }
- if(isset($entry->gender))
+ if (isset($entry->gender)) {
$gender = $entry->gender;
+ }
- if(isset($entry->generation) AND ($entry->generation > 0))
+ if (isset($entry->generation) AND ($entry->generation > 0)) {
$generation = ++$entry->generation;
+ }
- if(isset($entry->tags))
- foreach($entry->tags as $tag)
+ if (isset($entry->tags)) {
+ foreach($entry->tags as $tag) {
$keywords = implode(", ", $tag);
+ }
+ }
- if(isset($entry->contactType) AND ($entry->contactType >= 0))
+ if (isset($entry->contactType) AND ($entry->contactType >= 0))
$contact_type = $entry->contactType;
// If you query a Friendica server for its profiles, the network has to be Friendica
function poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation, $cid = 0, $uid = 0, $zcid = 0) {
- $a = get_app();
-
// Generation:
// 0: No definition
// 1: Profiles on this server
$orig_updated = $updated;
// The global contacts should contain the original picture, not the cached one
- if (($generation != 1) AND stristr(normalise_link($profile_photo), normalise_link($a->get_baseurl()."/photo/")))
+ if (($generation != 1) AND stristr(normalise_link($profile_photo), normalise_link(App::get_baseurl()."/photo/"))) {
$profile_photo = "";
+ }
$r = q("SELECT `network` FROM `contact` WHERE `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1",
dbesc(normalise_link($profile_url)), dbesc(NETWORK_STATUSNET)
intval($gcid),
intval($zcid)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
q("INSERT INTO `glink` (`cid`,`uid`,`gcid`,`zcid`, `updated`) VALUES (%d,%d,%d,%d, '%s') ",
intval($cid),
intval($uid),
$done = array();
/// TODO Check if it is really neccessary to poll the own server
- poco_load(0,0,0,$a->get_baseurl() . '/poco');
+ poco_load(0,0,0,App::get_baseurl() . '/poco');
- $done[] = $a->get_baseurl() . '/poco';
+ $done[] = App::get_baseurl() . '/poco';
- if(strlen(get_config('system','directory'))) {
+ if (strlen(get_config('system','directory'))) {
$x = fetch_url(get_server()."/pubsites");
- if($x) {
+ if ($x) {
$j = json_decode($x);
- if($j->entries) {
- foreach($j->entries as $entry) {
+ if ($j->entries) {
+ foreach ($j->entries as $entry) {
poco_check_server($entry->url);
$url = $entry->url . '/poco';
- if(! in_array($url,$done))
+ if (! in_array($url,$done)) {
poco_load(0,0,0,$entry->url . '/poco');
+ }
}
}
}
);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
if(! in_array($base,$done))
poco_load(0,0,0,$base);
function poco_discover_federation() {
$last = get_config('poco','last_federation_discovery');
- if($last) {
+ if ($last) {
$next = $last + (24 * 60 * 60);
if($next > time())
return;
$username = "";
if (isset($entry->urls)) {
foreach($entry->urls as $url)
- if($url->type == 'profile') {
+ if ($url->type == 'profile') {
$profile_url = $url->value;
$urlparts = parse_url($profile_url);
$username = end(explode("/", $urlparts["path"]));
$name = $entry->displayName;
- if(isset($entry->urls)) {
+ if (isset($entry->urls)) {
foreach($entry->urls as $url) {
- if($url->type == 'profile') {
+ if ($url->type == 'profile') {
$profile_url = $url->value;
continue;
}
- if($url->type == 'webfinger') {
+ if ($url->type == 'webfinger') {
$connect_url = str_replace('acct:' , '', $url->value);
continue;
}
}
}
- if(isset($entry->photos)) {
- foreach($entry->photos as $photo) {
- if($photo->type == 'profile') {
+ if (isset($entry->photos)) {
+ foreach ($entry->photos as $photo) {
+ if ($photo->type == 'profile') {
$profile_photo = $photo->value;
continue;
}
}
}
- if(isset($entry->updated))
+ if (isset($entry->updated)) {
$updated = date("Y-m-d H:i:s", strtotime($entry->updated));
+ }
- if(isset($entry->network))
+ if(isset($entry->network)) {
$network = $entry->network;
+ }
- if(isset($entry->currentLocation))
+ if(isset($entry->currentLocation)) {
$location = $entry->currentLocation;
+ }
- if(isset($entry->aboutMe))
+ if(isset($entry->aboutMe)) {
$about = html2bbcode($entry->aboutMe);
+ }
- if(isset($entry->gender))
+ if(isset($entry->gender)) {
$gender = $entry->gender;
+ }
- if(isset($entry->generation) AND ($entry->generation > 0))
+ if(isset($entry->generation) AND ($entry->generation > 0)) {
$generation = ++$entry->generation;
+ }
- if(isset($entry->contactType) AND ($entry->contactType >= 0))
+ if(isset($entry->contactType) AND ($entry->contactType >= 0)) {
$contact_type = $entry->contactType;
+ }
- if(isset($entry->tags))
- foreach($entry->tags as $tag)
+ if(isset($entry->tags)) {
+ foreach ($entry->tags as $tag) {
$keywords = implode(", ", $tag);
+ }
+ }
if ($generation > 0) {
$success = true;
logger("Fetching users from GNU Social server ".$server, LOGGER_DEBUG);
- $a = get_app();
-
$url = $server."/main/statistics";
$result = z_fetch_url($url);
"nick" => $user->nickname,
"about" => $user->bio,
"network" => NETWORK_OSTATUS,
- "photo" => $a->get_baseurl()."/images/person-175.jpg");
+ "photo" => App::get_baseurl()."/images/person-175.jpg");
get_gcontact_id($contact);
}
}
<?php
function create_tags_from_item($itemid) {
- $a = get_app();
-
- $profile_base = $a->get_baseurl();
+ $profile_base = App::get_baseurl();
$profile_data = parse_url($profile_base);
$profile_base_friendica = $profile_data['host'].$profile_data['path']."/profile/";
$profile_base_diaspora = $profile_data['host'].$profile_data['path']."/u/";
- $searchpath = $a->get_baseurl()."/search?tag=";
+ $searchpath = App::get_baseurl()."/search?tag=";
$messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `created`, `received`, `title`, `body`, `tag`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
$a = get_app();
// pass $baseurl to all templates
- $r['$baseurl'] = $a->get_baseurl();
+ $r['$baseurl'] = App::get_baseurl();
$t = $a->template_engine();
if (dbm::is_result($r)) {
$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
$micropro = Array();
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$micropro[] = micropro($rr,true,'mpfriend');
}
}
// map
if(strpos($s,'<div class="map">') !== false && $item['coord']) {
$x = generate_map(trim($item['coord']));
- if($x) {
+ if ($x) {
$s = preg_replace('/\<div class\=\"map\"\>/','$0' . $x,$s);
}
}
$matches = null;
$r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER);
- if($r) {
+ if ($r) {
foreach($matches as $mtch) {
if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be')))
$s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s);
intval($item),
intval($uid)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
return false;
+ }
q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc(str_replace($pattern,'',$r[0]['file'])),
//$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')),
//);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$saved = get_pconfig($uid,'system','filetags');
set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved));
-
}
+
return true;
}
}
function update_threads_mention() {
- $a = get_app();
-
$users = q("SELECT `uid`, `nickname` FROM `user` ORDER BY `uid`");
foreach ($users AS $user) {
- $self = normalise_link($a->get_baseurl() . '/profile/' . $user['nickname']);
+ $self = normalise_link(App::get_baseurl() . '/profile/' . $user['nickname']);
$selfhttps = str_replace("http://", "https://", $self);
$parents = q("SELECT DISTINCT(`parent`) FROM `item` WHERE `uid` = %d AND
((`owner-link` IN ('%s', '%s')) OR (`author-link` IN ('%s', '%s')))",
}\r
\r
$oldbaseurl = $account['baseurl'];\r
- $newbaseurl = $a->get_baseurl();\r
+ $newbaseurl = App::get_baseurl();\r
$olduid = $account['user']['uid'];\r
\r
unset($account['user']['uid']);\r
proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $newuid);\r
\r
info(t("Done. You can now login with your username and password"));\r
- goaway($a->get_baseurl() . "/login");\r
+ goaway(App::get_baseurl() . "/login");\r
}\r
dbesc($default_service_class)
);
- if($r) {
+ if ($r) {
$r = q("SELECT * FROM `user`
WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
dbesc($username),
if ($a->max_processes_reached() OR $a->maxload_reached()) {
header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable');
header('Retry-After: 120');
- header('Refresh: 120; url='.$a->get_baseurl()."/".$a->query_string);
+ header('Refresh: 120; url='.App::get_baseurl()."/".$a->query_string);
die("System is currently unavailable. Please try again later");
}
if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND
(intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND
- (substr($a->get_baseurl(), 0, 8) == "https://")) {
+ (substr(App::get_baseurl(), 0, 8) == "https://")) {
header("HTTP/1.1 302 Moved Temporarily");
- header("Location: ".$a->get_baseurl()."/".$a->query_string);
+ header("Location: ".App::get_baseurl()."/".$a->query_string);
exit();
}
*
*/
-// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
+// header('Link: <' . App::get_baseurl() . '/amcd>; rel="acct-mgmt";');
-if(x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
+if (x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) {
require("include/auth.php");
+}
-if(! x($_SESSION,'authenticated'))
+if (! x($_SESSION,'authenticated')) {
header('X-Account-Management-Status: none');
+}
/* set up page['htmlhead'] and page['end'] for the modules to use */
$a->page['htmlhead'] = '';
$a->page['end'] = '';
-if(! x($_SESSION,'sysmsg'))
+if (! x($_SESSION,'sysmsg')) {
$_SESSION['sysmsg'] = array();
+}
-if(! x($_SESSION,'sysmsg_info'))
+if (! x($_SESSION,'sysmsg_info')) {
$_SESSION['sysmsg_info'] = array();
+}
/*
* check_config() is responsible for running update scripts. These automatically
// in install mode, any url loads install module
// but we need "view" module for stylesheet
-if($install && $a->module!="view")
+if ($install && $a->module!="view") {
$a->module = 'install';
-elseif($maintenance && $a->module!="view")
+} elseif ($maintenance && $a->module!="view") {
$a->module = 'maintenance';
-else {
+} else {
check_url($a);
check_db();
check_plugins($a);
//Don't populate apps_menu if apps are private
$privateapps = get_config('config','private_addons');
-if((local_user()) || (! $privateapps === "1"))
-{
+if ((local_user()) || (! $privateapps === "1")) {
$arr = array('app_menu' => $a->apps);
call_hooks('app_menu', $arr);
$privateapps = get_config('config','private_addons');
- if(is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
+ if (is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
//Check if module is an app and if public access to apps is allowed or not
- if((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
+ if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
info( t("You must be logged in to use addons. "));
}
else {
* If not, next look for a 'standard' program module in the 'mod' directory
*/
- if((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
+ if ((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
include_once("mod/{$a->module}.php");
$a->module_loaded = true;
}
*
*/
- if(! $a->module_loaded) {
+ if (! $a->module_loaded) {
// Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
- if((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) {
+ if ((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) {
killme();
}
- if((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
+ if ((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
- goaway($a->get_baseurl() . $_SERVER['REQUEST_URI']);
+ goaway(App::get_baseurl() . $_SERVER['REQUEST_URI']);
}
logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
/* initialise content region */
-if(! x($a->page,'content'))
+if (! x($a->page,'content')) {
$a->page['content'] = '';
+}
-if(!$install && !$maintenance)
+if (!$install && !$maintenance) {
call_hooks('page_content_top',$a->page['content']);
+}
/**
* Call module functions
// do not allow a page manager to access the admin panel at all.
- if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
+ if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
return;
-
-
+ }
// urls
- if($a->argc > 1) {
+ if ($a->argc > 1) {
switch ($a->argv[1]){
case 'site':
admin_page_site_post($a);
return login(false);
}
- if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
+ if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
return "";
+ }
// APC deactivated, since there are problems with PHP 5.5
//if (function_exists("apc_delete")) {
'$counts' => $counts,
'$version' => FRIENDICA_VERSION,
'$legendtext' => sprintf(t('Currently this node is aware of %d nodes from the following platforms:'), $total),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
));
}
'$accounts' => $accounts,
'$pending' => array(t('Pending registrations'), $pending),
'$version' => array(t('Version'), FRIENDICA_VERSION),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$platform' => FRIENDICA_PLATFORM,
'$codename' => FRIENDICA_CODENAME,
'$build' => get_config('system','build'),
* send relocate for every local user
* */
- $old_url = $a->get_baseurl(true);
+ $old_url = App::get_baseurl(true);
// Generate host names for relocation the addresses in the format user@address.tld
$new_host = str_replace("http://", "@", normalise_link($new_url));
'$performance' => t('Performance'),
'$worker_title' => t('Worker'),
'$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
// name, label, value, help string, extra data...
'$sitename' => array('sitename', t("Site name"), $a->config['sitename'],''),
'$hostname' => array('hostname', t("Host name"), $a->config['hostname'], ""),
'$old_pager' => array('old_pager', t("Enable old style pager"), get_config('system','old_pager'), t("The old style pager has page numbers but slows down massively the page speed.")),
'$only_tag_search' => array('only_tag_search', t("Only search in tags"), get_config('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")),
- '$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
+ '$relocate_url' => array('relocate_url', t("New base url"), App::get_baseurl(), t("Change base url for this server. Sends relocate message to all DFRN contacts of all users.")),
'$rino' => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")),
'$embedly' => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("<a href='http://embed.ly'>Embedly</a> is used to fetch additional data for web pages. This is an optional parameter.")),
$failed = array();
$r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' ");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$upd = intval(substr($rr['k'],7));
if($upd < 1139 || $rr['v'] === 'success')
continue;
$failed[] = $upd;
}
}
- if(! count($failed)) {
+ if (! count($failed)) {
$o = replace_macros(get_markup_template('structure_check.tpl'),array(
- '$base' => $a->get_baseurl(true),
+ '$base' => App::get_baseurl(true),
'$banner' => t('No failed updates.'),
- '$check' => t('Check database structure'),
+ '$check' => t('Check database structure'),
));
} else {
$o = replace_macros(get_markup_template('failed_updates.tpl'),array(
- '$base' => $a->get_baseurl(true),
+ '$base' => App::get_baseurl(true),
'$banner' => t('Failed Updates'),
- '$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
- '$mark' => t('Mark success (if update was manually applied)'),
- '$apply' => t('Attempt to execute this update step automatically'),
+ '$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
+ '$mark' => t('Mark success (if update was manually applied)'),
+ '$apply' => t('Attempt to execute this update step automatically'),
'$failed' => $failed
));
}
* @param App $a
*/
function admin_page_users_post(&$a){
- $pending = (x($_POST, 'pending') ? $_POST['pending'] : array());
- $users = (x($_POST, 'user') ? $_POST['user'] : array());
- $nu_name = (x($_POST, 'new_user_name') ? $_POST['new_user_name'] : '');
- $nu_nickname = (x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
- $nu_email = (x($_POST, 'new_user_email') ? $_POST['new_user_email'] : '');
+ $pending = (x($_POST, 'pending') ? $_POST['pending'] : array());
+ $users = (x($_POST, 'user') ? $_POST['user'] : array());
+ $nu_name = (x($_POST, 'new_user_name') ? $_POST['new_user_name'] : '');
+ $nu_nickname = (x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
+ $nu_email = (x($_POST, 'new_user_email') ? $_POST['new_user_email'] : '');
$nu_language = get_config('system', 'language');
check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
Thank you and welcome to %4$s.'));
$preamble = sprintf($preamble, $nu['username'], $a->config['sitename']);
- $body = sprintf($body, $a->get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']);
+ $body = sprintf($body, App::get_baseurl(), $nu['email'], $result['password'], $a->config['sitename']);
notification(array(
'type' => "SYSTEM_EMAIL",
'$form_security_token' => get_form_security_token("admin_users"),
// values //
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$pending' => $pending,
'deleted' => $deleted,
'$page' => t('Plugins'),
'$toggle' => t('Toggle'),
'$settings' => t('Settings'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$plugin' => $plugin,
'$status' => $status,
* List plugins
*/
- if(x($_GET,"a") && $_GET['a']=="r") {
- check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/plugins', 'admin_themes', 't');
+ if (x($_GET,"a") && $_GET['a']=="r") {
+ check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/plugins', 'admin_themes', 't');
reload_plugins();
info("Plugins reloaded");
- goaway($a->get_baseurl().'/admin/plugins');
+ goaway(App::get_baseurl().'/admin/plugins');
}
$plugins = array();
$files = glob("addon/*/");
- if($files) {
- foreach($files as $file) {
- if(is_dir($file)) {
+ if ($files) {
+ foreach ($files as $file) {
+ if (is_dir($file)) {
list($tmp, $id)=array_map("trim", explode("/",$file));
$info = get_plugin_info($id);
$show_plugin = true;
// If the addon is unsupported, then only show it, when it is enabled
- if((strtolower($info["status"]) == "unsupported") AND !in_array($id, $a->plugins))
+ if ((strtolower($info["status"]) == "unsupported") AND !in_array($id, $a->plugins)) {
$show_plugin = false;
+ }
// Override the above szenario, when the admin really wants to see outdated stuff
- if(get_config("system", "show_unsupported_addons"))
+ if (get_config("system", "show_unsupported_addons")) {
$show_plugin = true;
+ }
- if($show_plugin)
+ if ($show_plugin) {
$plugins[] = array($id, (in_array($id, $a->plugins)?"on":"off") , $info);
+ }
}
}
}
'$page' => t('Plugins'),
'$submit' => t('Save Settings'),
'$reload' => t('Reload active plugins'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$function' => 'plugins',
'$plugins' => $plugins,
'$pcount' => count($plugins),
'$page' => t('Themes'),
'$toggle' => t('Toggle'),
'$settings' => t('Settings'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$plugin' => $theme,
'$status' => $status,
'$action' => $action,
// reload active themes
- if(x($_GET,"a") && $_GET['a']=="r") {
- check_form_security_token_redirectOnErr($a->get_baseurl().'/admin/themes', 'admin_themes', 't');
- if($themes) {
- foreach($themes as $th) {
- if($th['allowed']) {
+ if (x($_GET,"a") && $_GET['a']=="r") {
+ check_form_security_token_redirectOnErr(App::get_baseurl().'/admin/themes', 'admin_themes', 't');
+ if ($themes) {
+ foreach ($themes as $th) {
+ if ($th['allowed']) {
uninstall_theme($th['name']);
install_theme($th['name']);
}
}
}
info("Themes reloaded");
- goaway($a->get_baseurl().'/admin/themes');
+ goaway(App::get_baseurl().'/admin/themes');
}
/*
*/
$xthemes = array();
- if($themes) {
+ if ($themes) {
foreach($themes as $th) {
$xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
}
$t = get_markup_template("admin_plugins.tpl");
return replace_macros($t, array(
- '$title' => t('Administration'),
- '$page' => t('Themes'),
- '$submit' => t('Save Settings'),
- '$reload' => t('Reload active themes'),
- '$baseurl' => $a->get_baseurl(true),
- '$function' => 'themes',
- '$plugins' => $xthemes,
- '$pcount' => count($themes),
- '$noplugshint' => sprintf(t('No themes found on the system. They should be paced in %1$s'),'<code>/view/themes</code>'),
- '$experimental' => t('[Experimental]'),
- '$unsupported' => t('[Unsupported]'),
+ '$title' => t('Administration'),
+ '$page' => t('Themes'),
+ '$submit' => t('Save Settings'),
+ '$reload' => t('Reload active themes'),
+ '$baseurl' => App::get_baseurl(true),
+ '$function' => 'themes',
+ '$plugins' => $xthemes,
+ '$pcount' => count($themes),
+ '$noplugshint' => sprintf(t('No themes found on the system. They should be paced in %1$s'),'<code>/view/themes</code>'),
+ '$experimental' => t('[Experimental]'),
+ '$unsupported' => t('[Unsupported]'),
'$form_security_token' => get_form_security_token("admin_themes"),
));
}
'$page' => t('Logs'),
'$submit' => t('Save Settings'),
'$clear' => t('Clear'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$logname' => get_config('system','logfile'),
// name, label, value, help string, extra data...
function allfriends_content(&$a) {
$o = '';
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
- if($a->argc > 1)
+ if ($a->argc > 1) {
$cid = intval($a->argv[1]);
+ }
- if(! $cid)
+ if (! $cid) {
return;
+ }
$uid = $a->user[uid];
intval(local_user())
);
- if(! count($c))
+ if (! count($c)) {
return;
+ }
$a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
$r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$o .= t('No friends to display.');
return $o;
}
$id = 0;
- foreach($r as $rr) {
+ foreach ($r as $rr) {
//get further details of the contact
$contact_details = get_contact_details_by_url($rr['url'], $uid, $rr);
$photo_menu = contact_photo_menu ($rr);
}
else {
- $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url'];
+ $connlnk = App::get_baseurl() . '/follow/?url=' . $rr['url'];
$photo_menu = array(
'profile' => array(t("View Profile"), zrl($rr['url'])),
'follow' => array(t("Connect/Follow"), $connlnk)
function api_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
}
- if(! local_user()) {
+ if (! local_user()) {
/// @TODO We need login form to redirect to this page
notice( t('Please login to continue.') . EOL );
return login(false,$request->get_parameters());
$r = q("SELECT * FROM `attach` WHERE `id` = %d LIMIT 1",
intval($item_id)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Item was not found.'). EOL);
return;
}
dbesc($item_id)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Permission denied.') . EOL);
return;
}
}
function bookmarklet_content(&$a) {
- if(!local_user()) {
+ if (!local_user()) {
$o = '<h2>'.t('Login').'</h2>';
$o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true);
return $o;
}
$referer = normalise_link($_SERVER["HTTP_REFERER"]);
- $page = normalise_link($a->get_baseurl()."/bookmarklet");
+ $page = normalise_link(App::get_baseurl()."/bookmarklet");
if (!strstr($referer, $page)) {
$content = add_page_info($_REQUEST["url"]);
$htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$module_url' => '/cal/' . $a->data['user']['nickname'],
'$modparams' => 2,
'$i18n' => $i18n,
$etpl = get_markup_template('event_end.tpl');
$a->page['end'] .= replace_macros($etpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$editselect' => $editselect
));
if (dbm::is_result($r)) {
$r = sort_by_date($r);
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
- if(! x($links,$j))
- $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+ if (! x($links,$j)) {
+ $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+ }
}
}
}
$o = replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$tabs' => $tabs,
'$title' => t('Events'),
'$view' => t('View'),
- '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
- '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
+ '$previus' => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
+ '$next' => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
'$calendar' => cal($y,$m,$links, ' eventcal'),
'$events' => $events,
return;
}
- if($cmd !== 'loc' && $cmd != 'rem')
+ if ($cmd !== 'loc' && $cmd != 'rem') {
return;
+ }
- if(! $uid)
+ if (! $uid) {
return;
+ }
- if($cmd === 'loc' && $cid) {
+ if ($cmd === 'loc' && $cid) {
$c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($cid),
intval($uid)
);
+ /// @TODO Handle $c with dbm::is_result()
$a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
} else {
$c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
intval($uid)
);
+ /// @TODO Handle $c with dbm::is_result()
$vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
'$name' => htmlentities($c[0]['name']),
'url' => 'contacts/' . $cid
));
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside')) {
$a->page['aside'] = '';
+ }
$a->page['aside'] .= $vcard_widget;
}
}
}
-
-
- if($cid == 0 && $zcid == 0)
+ if ($cid == 0 && $zcid == 0) {
return;
+ }
-
- if($cid)
+ if ($cid) {
$t = count_common_friends($uid, $cid);
- else
+ } else {
$t = count_common_friends_zcid($uid, $zcid);
+ }
- if(count($t))
+ if (count($t)) {
$a->set_pager_total($t);
- else {
+ } else {
notice( t('No contacts in common.') . EOL);
return $o;
}
- if($cid)
+ if ($cid) {
$r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
- else
+ } else {
$r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
+ }
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
return $o;
}
$id = 0;
- foreach($r as $rr) {
+ foreach ($r as $rr) {
//get further details of the contact
$contact_details = get_contact_details_by_url($rr['url'], $uid);
- // $rr[id] is needed to use contact_photo_menu()
- $rr[id] = $rr[cid];
+ // $rr['id'] is needed to use contact_photo_menu()
+ /// @TODO Adding '/" here avoids E_NOTICE on missing constants
+ $rr['id'] = $rr['cid'];
$photo_menu = '';
$photo_menu = contact_photo_menu($rr);
$entry = array(
- 'url' => $rr['url'],
- 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
- 'name' => $contact_details['name'],
- 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
- 'img_hover' => htmlentities($contact_details['name']),
- 'details' => $contact_details['location'],
- 'tags' => $contact_details['keywords'],
- 'about' => $contact_details['about'],
- 'account_type' => account_type($contact_details),
- 'network' => network_to_name($contact_details['network'], $contact_details['url']),
- 'photo_menu' => $photo_menu,
- 'id' => ++$id,
+ 'url' => $rr['url'],
+ 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
+ 'name' => $contact_details['name'],
+ 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
+ 'img_hover' => htmlentities($contact_details['name']),
+ 'details' => $contact_details['location'],
+ 'tags' => $contact_details['keywords'],
+ 'about' => $contact_details['about'],
+ 'account_type' => account_type($contact_details),
+ 'network' => network_to_name($contact_details['network'], $contact_details['url']),
+ 'photo_menu' => $photo_menu,
+ 'id' => ++$id,
);
$entries[] = $entry;
}
- if($cmd === 'loc' && $cid && $uid == local_user()) {
+ if ($cmd === 'loc' && $cid && $uid == local_user()) {
$tab_str = contacts_tab($a, $cid, 4);
- } else
+ } else {
$title = t('Common Friends');
+ }
$tpl = get_markup_template('viewcontact_template.tpl');
$o .= replace_macros($tpl,array(
- '$title' => $title,
- '$tab_str' => $tab_str,
+ '$title' => $title,
+ '$tab_str' => $tab_str,
'$contacts' => $entries,
'$paginate' => paginate($a),
));
<?php
function community_init(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
unset($_SESSION['theme']);
unset($_SESSION['mobile-theme']);
}
$r = community_getitems($a->pager['start'], $a->pager['itemspage']);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
info( t('No results.') . EOL);
return $o;
}
function contactgroup_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
killme();
}
intval($a->argv[1]),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
killme();
}
require_once('include/Photo.php');
function contacts_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$contact_id = 0;
intval(local_user()),
intval($contact_id)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$contact_id = 0;
}
}
$base = z_root();
$tpl = get_markup_template("contacts-head.tpl");
$a->page['htmlhead'] .= replace_macros($tpl,array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$base' => $base
));
$tpl = get_markup_template("contacts-end.tpl");
$a->page['end'] .= replace_macros($tpl,array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$base' => $base
));
info ( sprintf( tt("%d contact edited.", "%d contacts edited.", $count_actions), $count_actions) );
}
- if(x($_SESSION,'return_url'))
+ if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']);
- else
+ }
+ else {
goaway('contacts');
+ }
}
function contacts_post(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
if ($a->argv[1]==="batch") {
contacts_batch_actions($a);
}
$contact_id = intval($a->argv[1]);
- if(! $contact_id)
+ if (! $contact_id) {
return;
+ }
$orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
intval(local_user())
);
- if(! count($orig_record)) {
+ if (! count($orig_record)) {
notice( t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
call_hooks('contact_edit_post', $_POST);
$profile_id = intval($_POST['profile-assign']);
- if($profile_id) {
+ if ($profile_id) {
$r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($profile_id),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Could not locate selected profile.') . EOL);
return;
}
nav_set_selected('contacts');
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
if($cmd === 'block') {
$r = _contact_block($contact_id, $orig_record[0]);
- if($r) {
+ if ($r) {
$blocked = (($orig_record[0]['blocked']) ? 0 : 1);
info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL);
}
if($cmd === 'ignore') {
$r = _contact_ignore($contact_id, $orig_record[0]);
- if($r) {
+ if ($r) {
$readonly = (($orig_record[0]['readonly']) ? 0 : 1);
info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL);
}
if($cmd === 'archive') {
$r = _contact_archive($contact_id, $orig_record[0]);
- if($r) {
+ if ($r) {
$archived = (($orig_record[0]['archive']) ? 0 : 1);
info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL);
}
));
}
// Now check how the user responded to the confirmation query
- if($_REQUEST['canceled']) {
- if(x($_SESSION,'return_url'))
+ if ($_REQUEST['canceled']) {
+ if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']);
- else
+ }
+ else {
goaway('contacts');
+ }
}
_contact_drop($contact_id, $orig_record[0]);
info( t('Contact has been removed.') . EOL );
- if(x($_SESSION,'return_url'))
+ if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']);
- else
+ }
+ else {
goaway('contacts');
+ }
return; // NOTREACHED
}
- if($cmd === 'posts') {
+ if ($cmd === 'posts') {
return contact_posts($a, $contact_id);
}
}
$editselect = 'exact';
$a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => $editselect,
));
$a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => $editselect,
));
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND
($contact['rel'] == CONTACT_IS_FOLLOWER))
- $follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
+ $follow = App::get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
// Load contactact related actions like hide, suggest, delete and others
$contact_actions = contact_actions($contact);
// Currently security is based on the logged in user
- if(! local_user()) {
+ if (! local_user()) {
return;
}
intval($group),
intval($_SESSION['uid'])
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
if($update)
killme();
notice( t('No such group') . EOL );
- goaway($a->get_baseurl(true) . '/network');
+ goaway(App::get_baseurl(true) . '/network');
// NOTREACHED
}
'like' => '',
'dislike' => '',
'comment' => '',
- //'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
- 'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state).'/display/'.$item['guid'], 'title'=> t('View in context'))),
+ //'conv' => (($preview) ? '' : array('href'=> App::get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
+ 'conv' => (($preview) ? '' : array('href'=> App::get_baseurl($ssl_state).'/display/'.$item['guid'], 'title'=> t('View in context'))),
'previewing' => $previewing,
'wait' => t('Please wait'),
);
}
}
- if(local_user() && link_compare($a->contact['url'],$item['author-link']))
- $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
- else
+ if (local_user() && link_compare($a->contact['url'],$item['author-link'])) {
+ $edpost = array(App::get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
+ } else {
$edpost = false;
+ }
$drop = '';
$dropping = false;
$isstarred = "unstarred";
if ($profile_owner == local_user()) {
- if($toplevelpost) {
+ if ($toplevelpost) {
$isstarred = (($item['starred']) ? "starred" : "unstarred");
$star = array(
intval($item['uid']),
intval($item['id'])
);
+
if (dbm::is_result($r)) {
$ignore = array(
'do' => t("ignore thread"),
);
}
$tagger = '';
- if(feature_enabled($profile_owner,'commtag')) {
+ if (feature_enabled($profile_owner,'commtag')) {
$tagger = array(
'add' => t("add tag"),
'class' => "",
$sp = false;
$profile_link = best_link_url($item,$sp);
- if($profile_link === 'mailbox')
+ if ($profile_link === 'mailbox') {
$profile_link = '';
- if($sp)
+ }
+ if ($sp) {
$sparkle = ' sparkle';
- else
+ } else {
$profile_link = zrl($profile_link);
+ }
// Don't rely on the author-avatar. It is better to use the data from the contact table
$author_contact = get_contact_details_by_url($item['author-link'], $profile_owner);
- if ($author_contact["thumb"])
+ if ($author_contact["thumb"]) {
$profile_avatar = $author_contact["thumb"];
- else
+ } else {
$profile_avatar = $item['author-avatar'];
+ }
$like = ((x($conv_responses['like'],$item['uri'])) ? format_like($conv_responses['like'][$item['uri']],$conv_responses['like'][$item['uri'] . '-l'],'like',$item['uri']) : '');
$dislike = ((x($conv_responses['dislike'],$item['uri'])) ? format_like($conv_responses['dislike'][$item['uri']],$conv_responses['dislike'][$item['uri'] . '-l'],'dislike',$item['uri']) : '');
require_once("mod/contacts.php");
function crepair_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$contact_id = 0;
intval(local_user()),
intval($contact_id)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$contact_id = 0;
}
}
}
}
-
function crepair_post(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
);
}
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
return;
+ }
$contact = $r[0];
function crepair_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
);
}
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL);
return;
}
function delegate_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
- if($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
+ if ($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
// delegated admins can view but not change delegation permissions
- if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
- goaway($a->get_baseurl() . '/delegate');
+ if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
+ goaway(App::get_baseurl() . '/delegate');
+ }
$id = $a->argv[2];
if (dbm::is_result($r)) {
$r = q("select id from contact where uid = %d and nurl = '%s' limit 1",
intval(local_user()),
- dbesc(normalise_link($a->get_baseurl() . '/profile/' . $r[0]['nickname']))
+ dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname']))
);
if (dbm::is_result($r)) {
q("insert into manage ( uid, mid ) values ( %d , %d ) ",
);
}
}
- goaway($a->get_baseurl() . '/delegate');
+ goaway(App::get_baseurl() . '/delegate');
}
- if($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
+ if ($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
// delegated admins can view but not change delegation permissions
- if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
- goaway($a->get_baseurl() . '/delegate');
+ if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
+ goaway(App::get_baseurl() . '/delegate');
+ }
q("delete from manage where uid = %d and mid = %d limit 1",
intval($a->argv[2]),
intval(local_user())
);
- goaway($a->get_baseurl() . '/delegate');
+ goaway(App::get_baseurl() . '/delegate');
}
$r = q("select nurl from contact where substring_index(contact.nurl,'/',3) = '%s'
and contact.uid = %d and contact.self = 0 and network = '%s' ",
- dbesc(normalise_link($a->get_baseurl())),
+ dbesc(normalise_link(App::get_baseurl())),
intval(local_user()),
dbesc(NETWORK_DFRN)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('No potential page delegates located.') . EOL);
return;
}
$nicknames = array();
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
}
}
$o = replace_macros(get_markup_template('delegate.tpl'),array(
'$header' => t('Delegate Page Management'),
- '$base' => $a->get_baseurl(),
+ '$base' => App::get_baseurl(),
'$desc' => t('Delegates are able to manage all aspects of this account/page except for basic account settings. Please do not delegate your personal account to anybody that you do not trust completely.'),
'$head_managers' => t('Existing Page Managers'),
'$managers' => $full_managers,
intval($uid)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
logger('Contact not found in DB.');
notice( t('Contact not found.') . EOL );
notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL );
$params['public_key'] = $public_key;
- $my_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
+ $my_url = App::get_baseurl() . '/profile/' . $user[0]['nickname'];
openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
$params['source_url'] = bin2hex($params['source_url']);
// Let's send our user to the contact editor in case they want to
// do anything special with this new friend.
- if($handsfree === null)
- goaway($a->get_baseurl() . '/contacts/' . intval($contact_id));
- else
+ if ($handsfree === null) {
+ goaway(App::get_baseurl() . '/contacts/' . intval($contact_id));
+ } else {
return;
+ }
//NOTREACHED
}
*
*/
- if(x($_POST,'source_url')) {
+ if (x($_POST,'source_url')) {
// We are processing an external confirmation to an introduction created by our user.
// If $aes_key is set, both of these items require unpacking from the hex transport encoding.
- if(x($aes_key)) {
+ if (x($aes_key)) {
$aes_key = hex2bin($aes_key);
$public_key = hex2bin($public_key);
}
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
dbesc($node));
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$message = sprintf(t('No user record found for \'%s\' '), $node);
xml_status(3,$message); // failure
// NOTREACHED
dbesc($dfrn_pubkey),
intval($dfrn_record)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$message = t('Unable to set your contact credentials on our system.');
xml_status(3,$message);
}
$r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1",
intval($dfrn_record));
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$photo = $r[0]['photo'];
- else
- $photo = $a->get_baseurl() . '/images/person-175.jpg';
+ } else {
+ $photo = App::get_baseurl() . '/images/person-175.jpg';
+ }
require_once("include/Photo.php");
logger('dfrn_confirm: request - photos imported');
$new_relation = CONTACT_IS_SHARING;
- if(($relation == CONTACT_IS_FOLLOWER) || ($duplex))
+ if (($relation == CONTACT_IS_FOLLOWER) || ($duplex)) {
$new_relation = CONTACT_IS_FRIEND;
+ }
- if(($relation == CONTACT_IS_FOLLOWER) && ($duplex))
+ if (($relation == CONTACT_IS_FOLLOWER) && ($duplex)) {
$duplex = 0;
+ }
$r = q("UPDATE `contact` SET
`rel` = %d,
dbesc(NETWORK_DFRN),
intval($dfrn_record)
);
- if($r === false) { // indicates schema is messed up or total db failure
+ if ($r === false) { // indicates schema is messed up or total db failure
$message = t('Unable to update your contact profile details on our system');
xml_status(3,$message);
}
'to_name' => $r[0]['username'],
'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'],
- 'link' => $a->get_baseurl() . '/contacts/' . $dfrn_record,
+ 'link' => App::get_baseurl() . '/contacts/' . $dfrn_record,
'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
'source_link' => $r[0]['url'],
'source_photo' => $r[0]['photo'],
dbesc($dfrn_id),
dbesc($challenge)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
logger('dfrn_notify: could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge);
xml_status(3);
}
dbesc($a->argv[1])
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
logger('dfrn_notify: contact not found for dfrn_id ' . $dfrn_id);
xml_status(3);
//NOTREACHED
dbesc($a->argv[1])
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
$status = 1;
+ }
logger("Remote rino version: ".$rino_remote." for ".$r[0]["url"], LOGGER_DEBUG);
}
}
$profile = $r[0]['nickname'];
- goaway((strlen($destination_url)) ? $destination_url : $a->get_baseurl() . '/profile/' . $profile);
+ goaway((strlen($destination_url)) ? $destination_url : App::get_baseurl() . '/profile/' . $profile);
}
goaway(z_root());
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
xml_status(3, 'No ticket');
// NOTREACHED
}
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
xml_status(3, 'No ticket');
// NOTREACHED
}
dbesc($challenge)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
killme();
+ }
$type = $r[0]['type'];
$last_update = $r[0]['last_update'];
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1");
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
killme();
+ }
$contact = $r[0];
$owner_uid = $r[0]['uid'];
switch($destination_url) {
case 'profile':
- $dest = $a->get_baseurl() . '/profile/' . $profile . '?f=&tab=profile';
+ $dest = App::get_baseurl() . '/profile/' . $profile . '?f=&tab=profile';
break;
case 'photos':
- $dest = $a->get_baseurl() . '/photos/' . $profile;
+ $dest = App::get_baseurl() . '/photos/' . $profile;
break;
case 'status':
case '':
- $dest = $a->get_baseurl() . '/profile/' . $profile;
+ $dest = App::get_baseurl() . '/profile/' . $profile;
break;
default:
$dest = $destination_url . '?f=&redir=1';
$parms = Probe::profile($dfrn_url);
- if(! count($parms)) {
+ if (! count($parms)) {
notice( t('Profile location is not valid or does not contain profile information.') . EOL );
return;
}
else {
- if(! x($parms,'fn'))
+ if (! x($parms,'fn')) {
notice( t('Warning: profile location has no identifiable owner name.') . EOL );
- if(! x($parms,'photo'))
+ }
+ if (! x($parms,'photo')) {
notice( t('Warning: profile location has no profile photo.') . EOL );
+ }
$invalid = Probe::valid_dfrn($parms);
- if($invalid) {
+ 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 );
);
}
- if($r) {
+ if ($r) {
info( t("Introduction complete.") . EOL);
}
if (isset($photo))
update_contact_avatar($photo, local_user(), $r[0]["id"], true);
- $forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id'];
- } else
- $forwardurl = $a->get_baseurl()."/contacts";
+ $forwardurl = App::get_baseurl()."/contacts/".$r[0]['id'];
+ } else {
+ $forwardurl = App::get_baseurl()."/contacts";
+ }
/*
* Allow the blocked remote notification to complete
*/
- if(is_array($contact_record))
+ if (is_array($contact_record)) {
$dfrn_request = $contact_record['request'];
+ }
- if(strlen($dfrn_request) && strlen($confirm_key))
+ if (strlen($dfrn_request) && strlen($confirm_key)) {
$s = fetch_url($dfrn_request . '?confirm_key=' . $confirm_key);
+ }
// (ignore reply, nothing we can do it failed)
dbesc(NETWORK_MAIL2)
);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d",
intval($rr['cid'])
dbesc(NETWORK_MAIL2)
);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d",
intval($rr['cid'])
intval($uid)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('This account has not been configured for email. Request failed.') . EOL);
return;
}
);
}
else {
- if(! validate_url($url)) {
+ if (! validate_url($url)) {
notice( t('Invalid profile URL.') . EOL);
- goaway($a->get_baseurl() . '/' . $a->cmd);
+ goaway(App::get_baseurl() . '/' . $a->cmd);
return; // NOTREACHED
}
- if(! allowed_url($url)) {
+ if (! allowed_url($url)) {
notice( t('Disallowed profile URL.') . EOL);
- goaway($a->get_baseurl() . '/' . $a->cmd);
+ goaway(App::get_baseurl() . '/' . $a->cmd);
return; // NOTREACHED
}
$parms = Probe::profile(($hcard) ? $hcard : $url);
- if(! count($parms)) {
+ if (! count($parms)) {
notice( t('Profile location is not valid or does not contain profile information.') . EOL );
- goaway($a->get_baseurl() . '/' . $a->cmd);
+ goaway(App::get_baseurl() . '/' . $a->cmd);
}
else {
- if(! x($parms,'fn'))
+ if (! x($parms,'fn')) {
notice( t('Warning: profile location has no identifiable owner name.') . EOL );
- if(! x($parms,'photo'))
+ }
+ if (! x($parms,'photo')) {
notice( t('Warning: profile location has no profile photo.') . EOL );
+ }
$invalid = Probe::valid_dfrn($parms);
- if($invalid) {
+ 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 );
);
// find the contact record we just created
- if($r) {
+ if ($r) {
$r = q("SELECT `id` FROM `contact`
WHERE `uid` = %d AND `url` = '%s' AND `issued-id` = '%s' LIMIT 1",
intval($uid),
}
}
- if($r === false) {
+ 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)) {
+ if (is_array($contact_record)) {
$ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime`)
VALUES ( %d, %d, 1, %d, '%s', '%s', '%s' )",
intval($uid),
// This notice will only be seen by the requestor if the requestor and requestee are on the same server.
- if(! $failed)
+ 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);
+ $dfrn_url = bin2hex(App::get_baseurl() . '/profile/' . $nickname);
$aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
$uri .= '/'.$a->get_path();
$uri = urlencode($uri);
- } else
- $uri = $a->get_baseurl().'/profile/'.$nickname;
+ } else {
+ $uri = App::get_baseurl().'/profile/'.$nickname;
+ }
$url = str_replace('{uri}', $uri, $url);
goaway($url);
function dfrn_request_content(&$a) {
- if(($a->argc != 2) || (! count($a->profile)))
+ if (($a->argc != 2) || (! count($a->profile))) {
return "";
+ }
// "Homecoming". Make sure we're logged in to this site as the correct user. Then offer a confirm button
// to send us to the post section to record the introduction.
- if(x($_GET,'dfrn_url')) {
+ if (x($_GET,'dfrn_url')) {
- if(! local_user()) {
+ if (! local_user()) {
info( t("Please login to confirm introduction.") . EOL );
/* setup the return URL to come back to this page if they use openid */
$_SESSION['return_url'] = $a->query_string;
'to_name' => $r[0]['username'],
'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'],
- 'link' => $a->get_baseurl() . '/notifications/intros',
+ 'link' => App::get_baseurl() . '/notifications/intros',
'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
'source_link' => $r[0]['url'],
'source_photo' => $r[0]['photo'],
$myaddr = hex2bin($_GET['addr']);
elseif (x($_GET,'address') AND ($_GET['address'] != ""))
$myaddr = $_GET['address'];
- elseif(local_user()) {
- if(strlen($a->path)) {
- $myaddr = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
+ elseif (local_user()) {
+ if (strlen($a->path)) {
+ $myaddr = App::get_baseurl() . '/profile/' . $a->user['nickname'];
}
else {
$myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
}
- } else // last, try a zrl
+ }
+ else {
+ // last, try a zrl
$myaddr = get_my_url();
+ }
$target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
*
*/
- if($a->profile['page-flags'] == PAGE_NORMAL)
+ if ($a->profile['page-flags'] == PAGE_NORMAL) {
$tpl = get_markup_template('dfrn_request.tpl');
- else
+ }
+ else {
$tpl = get_markup_template('auto_request.tpl');
+ }
$page_desc = t("Please enter your 'Identity Address' from one of the following supported communications networks:");
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($a->profile['uid'])
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
$mail_disabled = 1;
+ }
}
// "coming soon" is disabled for now
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
if (dbm::is_result($r)) {
- if(in_array('small', $a->argv))
+ if (in_array('small', $a->argv)) {
$photo = 'thumb';
- else
+ }
+ else {
$photo = 'photo';
+ }
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$itemurl= '';
function dirfind_init(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL );
return;
}
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside')) {
$a->page['aside'] = '';
+ }
$a->page['aside'] .= findpeople_widget();
$search = $prefix.notags(trim($_REQUEST['search']));
- if(strpos($search,'@') === 0) {
+ if (strpos($search,'@') === 0) {
$search = substr($search,1);
$header = sprintf( t('People Search - %s'), $search);
if ((valid_email($search) AND validate_email($search)) OR
}
}
- if(strpos($search,'!') === 0) {
+ if (strpos($search,'!') === 0) {
$search = substr($search,1);
$community = true;
$header = sprintf( t('Forum Search - %s'), $search);
$o = '';
- if($search) {
+ if ($search) {
if ($discover_user) {
$j = new stdClass();
$perpage = 80;
$startrec = (($a->pager['page']) * $perpage) - $perpage;
- if (get_config('system','diaspora_enabled'))
+ if (get_config('system','diaspora_enabled')) {
$diaspora = NETWORK_DIASPORA;
- else
+ } else {
$diaspora = NETWORK_DFRN;
+ }
- if (!get_config('system','ostatus_disabled'))
+ if (!get_config('system','ostatus_disabled')) {
$ostatus = NETWORK_OSTATUS;
- else
+ } else {
$ostatus = NETWORK_DFRN;
+ }
$search2 = "%".$search."%";
+ /// @TODO These 2 SELECTs are not checked on validity with dbm::is_result()
$count = q("SELECT count(*) AS `total` FROM `gcontact`
LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
AND `contact`.`network` = `gcontact`.`network`
$j->items_page = $perpage;
$j->page = $a->pager['page'];
foreach ($results AS $result) {
- if (poco_alternate_ostatus_url($result["url"]))
- continue;
+ if (poco_alternate_ostatus_url($result["url"])) {
+ continue;
+ }
$result = get_contact_details_by_url($result["url"], local_user(), $result);
$j = json_decode($x);
}
- if($j->total) {
+ if ($j->total) {
$a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page);
}
- if(count($j->results)) {
+ if (count($j->results)) {
$id = 0;
- foreach($j->results as $jj) {
+ foreach ($j->results as $jj) {
$alt_text = "";
$photo_menu = contact_photo_menu($contact[0]);
$details = _contact_detail_for_template($contact[0]);
$alt_text = $details['alt_text'];
- } else
+ } else {
$photo_menu = array();
+ }
} else {
- $connlnk = $a->get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
+ $connlnk = App::get_baseurl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
$conntxt = t('Connect');
$photo_menu = array(
'profile' => array(t("View Profile"), zrl($jj->url)),
'$paginate' => paginate($a),
));
- }
- else {
+ } else {
info( t('No matches') . EOL);
}
$profiledata = display_fetchauthor($a, $r[0]);
- if (strstr(normalise_link($profiledata["url"]), normalise_link($a->get_baseurl()))) {
- $nickname = str_replace(normalise_link($a->get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
+ if (strstr(normalise_link($profiledata["url"]), normalise_link(App::get_baseurl()))) {
+ $nickname = str_replace(normalise_link(App::get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
if (($nickname != $a->user["nickname"])) {
$r = qu("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
if (local_user()) {
if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
- $profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
+ $profiledata["remoteconnect"] = App::get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
}
} elseif ($profiledata["network"] == NETWORK_DFRN) {
$connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
$o = '';
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- if(! $post_id) {
+ if (! $post_id) {
notice( t('Item not found') . EOL);
return;
}
intval(local_user())
);
- if(! count($itm)) {
+ if (! count($itm)) {
notice( t('Item not found') . EOL);
return;
}
$tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$ispublic' => ' ', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag,
$tpl = get_markup_template('jot-end.tpl');
$a->page['end'] .= replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$ispublic' => ' ', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag,
'$ptyp' => $itm[0]['type'],
'$content' => undo_post_tagging($itm[0]['body']),
'$post_id' => $post_id,
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$defloc' => $a->user['default-location'],
'$visitor' => 'none',
'$pvisit' => 'none',
require_once('include/items.php');
function events_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
- if($a->argc == 1) {
+ if ($a->argc == 1) {
// if it's a json request abort here becaus we don't
// need the widget data
- if($a->argv[1] === 'json')
+ if ($a->argv[1] === 'json')
return;
$cal_widget = widget_events();
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside'))
$a->page['aside'] = '';
$a->page['aside'] .= $cal_widget;
logger('post: ' . print_r($_REQUEST,true));
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0);
$cid = ((x($_POST,'cid')) ? intval($_POST['cid']) : 0);
// The default setting for the `private` field in event_store() is false, so mirror that
$private_event = false;
- if($start_text) {
+ if ($start_text) {
$start = $start_text;
}
else {
$start = sprintf('%d-%d-%d %d:%d:0',$startyear,$startmonth,$startday,$starthour,$startminute);
}
- if($nofinish) {
+ if ($nofinish) {
$finish = '0000-00-00 00:00:00';
}
- if($finish_text) {
+ if ($finish_text) {
$finish = $finish_text;
}
else {
$finish = sprintf('%d-%d-%d %d:%d:0',$finishyear,$finishmonth,$finishday,$finishhour,$finishminute);
}
- if($adjust) {
+ if ($adjust) {
$start = datetime_convert(date_default_timezone_get(),'UTC',$start);
- if(! $nofinish)
+ if (! $nofinish) {
$finish = datetime_convert(date_default_timezone_get(),'UTC',$finish);
+ }
}
else {
$start = datetime_convert('UTC','UTC',$start);
- if(! $nofinish)
+ if (! $nofinish) {
$finish = datetime_convert('UTC','UTC',$finish);
+ }
}
// Don't allow the event to finish before it begins.
$type = 'event';
$action = ($event_id == '') ? 'new' : "event/" . $event_id;
- $onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
+ $onerror_url = App::get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
- if(strcmp($finish,$start) < 0 && !$nofinish) {
+ if (strcmp($finish,$start) < 0 && !$nofinish) {
notice( t('Event can not end before it has started.') . EOL);
- if(intval($_REQUEST['preview'])) {
+ if (intval($_REQUEST['preview'])) {
echo( t('Event can not end before it has started.'));
killme();
}
function events_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
- if($a->argc == 1)
- $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
+ if ($a->argc == 1) {
+ $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
+ }
- if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
+ if (($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
$r = q("update event set ignore = 1 where id = %d and uid = %d",
intval($a->argv[2]),
intval(local_user())
);
}
- if(($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
+ if (($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
$r = q("update event set ignore = 0 where id = %d and uid = %d",
intval($a->argv[2]),
intval(local_user())
);
}
- if ($a->theme_events_in_profile)
+ if ($a->theme_events_in_profile) {
nav_set_selected('home');
- else
+ } else {
nav_set_selected('events');
+ }
$editselect = 'none';
- if( feature_enabled(local_user(), 'richtext') )
+ if ( feature_enabled(local_user(), 'richtext') ) {
$editselect = 'textareas';
+ }
// get the translation strings for the callendar
$i18n = get_event_strings();
$htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$module_url' => '/events',
'$modparams' => 1,
'$i18n' => $i18n,
$etpl = get_markup_template('event_end.tpl');
$a->page['end'] .= replace_macros($etpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$editselect' => $editselect
));
$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
if($a->argc > 1) {
- if($a->argc > 2 && $a->argv[1] == 'event') {
+ if ($a->argc > 2 && $a->argv[1] == 'event') {
$mode = 'edit';
$event_id = intval($a->argv[2]);
}
- if($a->argv[1] === 'new') {
+ if ($a->argv[1] === 'new') {
$mode = 'new';
$event_id = 0;
}
- if($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
+ if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
$mode = 'view';
$y = intval($a->argv[1]);
$m = intval($a->argv[2]);
}
// The view mode part is similiar to /mod/cal.php
- if($mode == 'view') {
+ if ($mode == 'view') {
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
- if(! $y)
+ if (! $y) {
$y = intval($thisyear);
- if(! $m)
+ }
+ if (! $m) {
$m = intval($thismonth);
+ }
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
- if($y < 1901)
+ if ($y < 1901) {
$y = 1900;
- if($y > 2099)
+ }
+ if ($y > 2099) {
$y = 2100;
+ }
$nextyear = $y;
$nextmonth = $m + 1;
if (dbm::is_result($r)) {
$r = sort_by_date($r);
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
- if(! x($links,$j))
- $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+ if (! x($links,$j)) {
+ $links[$j] = App::get_baseurl() . '/' . $a->cmd . '#link-' . $j;
+ }
}
}
}
$o = replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$tabs' => $tabs,
'$title' => t('Events'),
'$view' => t('View'),
- '$new_event' => array($a->get_baseurl().'/events/new',t('Create New Event'),'',''),
- '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
- '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
+ '$new_event' => array(App::get_baseurl().'/events/new',t('Create New Event'),'',''),
+ '$previus' => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
+ '$next' => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
'$calendar' => cal($y,$m,$links, ' eventcal'),
'$events' => $events,
$tpl = get_markup_template('event_form.tpl');
$o .= replace_macros($tpl,array(
- '$post' => $a->get_baseurl() . '/events',
+ '$post' => App::get_baseurl() . '/events',
'$eid' => $eid,
'$cid' => $cid,
'$uri' => $uri,
/**
* @param App $a
*/
+/// @TODO & is missing or App ?
function fbrowser_content($a){
if (!local_user())
$scale = $rr['loq'];
return array(
- $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
+ App::get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
$filename_e,
- $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
+ App::get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
);
}
$files = array_map("_map_files1", $r);
$tpl = get_markup_template($template_file);
$o = replace_macros($tpl, array(
- '$type' => 'image',
- '$baseurl' => $a->get_baseurl(),
- '$path' => $path,
- '$folders' => $albums,
- '$files' =>$files,
- '$cancel' => t('Cancel'),
+ '$type' => 'image',
+ '$baseurl' => App::get_baseurl(),
+ '$path' => $path,
+ '$folders' => $albums,
+ '$files' => $files,
+ '$cancel' => t('Cancel'),
'$nickname' => $a->user['nickname'],
));
break;
case "file":
- if ($a->argc==2){
+ if ($a->argc==2) {
$files = q("SELECT `id`, `filename`, `filetype` FROM `attach` WHERE `uid` = %d ",
intval(local_user())
);
list($m1,$m2) = explode("/",$rr['filetype']);
$filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
- if($a->theme['template_engine'] === 'internal') {
+ if ($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']);
- }
- else {
+ } else {
$filename_e = $rr['filename'];
}
- return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
+ return array( App::get_baseurl() . '/attach/' . $rr['id'], $filename_e, App::get_baseurl() . '/images/icons/16/' . $filetype . '.png');
}
$files = array_map("_map_files2", $files);
$tpl = get_markup_template($template_file);
$o = replace_macros($tpl, array(
- '$type' => 'file',
- '$baseurl' => $a->get_baseurl(),
- '$path' => array( array( "", t("Files")) ),
- '$folders' => false,
- '$files' =>$files,
- '$cancel' => t('Cancel'),
+ '$type' => 'file',
+ '$baseurl' => App::get_baseurl(),
+ '$path' => array( array( "", t("Files")) ),
+ '$folders' => false,
+ '$files' =>$files,
+ '$cancel' => t('Cancel'),
'$nickname' => $a->user['nickname'],
));
function filer_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
killme();
}
function filerm_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
killme();
}
$cat = unxmlify(trim($_GET['cat']));
$category = (($cat) ? true : false);
- if($category)
+ if ($category) {
$term = $cat;
+ }
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
logger('filerm: tag ' . $term . ' item ' . $item_id);
- if($item_id && strlen($term))
+ if ($item_id && strlen($term)) {
file_tag_unsave_file(local_user(),$item_id,$term, $category);
+ }
- if(x($_SESSION,'return_url'))
- goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
+ if (x($_SESSION,'return_url')) {
+ goaway(App::get_baseurl() . '/' . $_SESSION['return_url']);
+ }
killme();
}
function follow_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
goaway($_SESSION['return_url']);
// NOTREACHED
// NOTREACHED
}
- if ($ret["network"] == NETWORK_MAIL)
+ if ($ret["network"] == NETWORK_MAIL) {
$ret["url"] = $ret["addr"];
+ }
- if($ret['network'] === NETWORK_DFRN) {
+ if ($ret['network'] === NETWORK_DFRN) {
$request = $ret["request"];
$tpl = get_markup_template('dfrn_request.tpl');
} else {
- $request = $a->get_baseurl()."/follow";
+ $request = App::get_baseurl()."/follow";
$tpl = get_markup_template('auto_request.tpl');
}
$r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
normalise_link($ret["url"]));
- if (!$r)
+ if (!$r) {
$r = array(array("location" => "", "about" => "", "keywords" => ""));
- else
+ } else {
$gcontact_id = $r[0]["id"];
+ }
- if($ret['network'] === NETWORK_DIASPORA) {
+ if ($ret['network'] === NETWORK_DIASPORA) {
$r[0]["location"] = "";
$r[0]["about"] = "";
}
$header = $ret["name"];
- if ($ret["addr"] != "")
+ if ($ret["addr"] != "") {
$header .= " <".$ret["addr"].">";
+ }
//$header .= " (".network_to_name($ret['network'], $ret['url']).")";
$header = t("Connect/Follow");
function follow_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
goaway($_SESSION['return_url']);
// NOTREACHED
}
- if ($_REQUEST['cancel'])
+ if ($_REQUEST['cancel']) {
goaway($_SESSION['return_url']);
+ }
$uid = local_user();
$url = notags(trim($_REQUEST['url']));
$result = new_contact($uid,$url,true);
- if($result['success'] == false) {
- if($result['message'])
+ if ($result['success'] == false) {
+ if ($result['message']) {
notice($result['message']);
+ }
goaway($return_url);
- } elseif ($result['cid'])
- goaway($a->get_baseurl().'/contacts/'.$result['cid']);
+ } elseif ($result['cid']) {
+ goaway(App::get_baseurl().'/contacts/'.$result['cid']);
+ }
info( t('Contact added').EOL);
- if(strstr($return_url,'contacts'))
- goaway($a->get_baseurl().'/contacts/'.$contact_id);
+ if (strstr($return_url,'contacts')) {
+ goaway(App::get_baseurl().'/contacts/'.$contact_id);
+ }
goaway($return_url);
// NOTREACHED
$r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($adminlist[0]));
$admin = array(
'name' => $r[0]['username'],
- 'profile'=> $a->get_baseurl().'/profile/'.$r[0]['nickname'],
+ 'profile'=> App::get_baseurl().'/profile/'.$r[0]['nickname'],
);
} else {
$admin = false;
'site_name' => $a->config['sitename'],
'platform' => FRIENDICA_PLATFORM,
'info' => ((x($a->config,'info')) ? $a->config['info'] : ''),
- 'no_scrape_url' => $a->get_baseurl().'/noscrape'
+ 'no_scrape_url' => App::get_baseurl().'/noscrape'
);
echo json_encode($data);
function fsuggest_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
return;
}
- if($a->argc != 2)
+ if ($a->argc != 2) {
return;
+ }
$contact_id = intval($a->argv[1]);
intval($contact_id),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL);
return;
}
require_once('include/acl_selectors.php');
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
intval($contact_id),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL);
return;
}
function group_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
$name = notags(trim($_POST['groupname']));
$r = group_add(local_user(),$name);
- if($r) {
+ if ($r) {
info( t('Group created.') . EOL );
$r = group_byname(local_user(),$name);
- if($r)
- goaway($a->get_baseurl() . '/group/' . $r);
+ if ($r) {
+ goaway(App::get_baseurl() . '/group/' . $r);
+ }
}
- else
+ else {
notice( t('Could not create group.') . EOL );
- goaway($a->get_baseurl() . '/group');
+ }
+ goaway(App::get_baseurl() . '/group');
return; // NOTREACHED
}
- if(($a->argc == 2) && (intval($a->argv[1]))) {
+
+ if (($a->argc == 2) && (intval($a->argv[1]))) {
check_form_security_token_redirectOnErr('/group', 'group_edit');
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Group not found.') . EOL );
- goaway($a->get_baseurl() . '/contacts');
+ goaway(App::get_baseurl() . '/contacts');
return; // NOTREACHED
}
$group = $r[0];
$groupname = notags(trim($_POST['groupname']));
- if((strlen($groupname)) && ($groupname != $group['name'])) {
+ if ((strlen($groupname)) && ($groupname != $group['name'])) {
$r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc($groupname),
intval(local_user()),
intval($group['id'])
);
- if($r)
+
+ if ($r) {
info( t('Group name changed.') . EOL );
+ }
}
$a->page['aside'] = group_side();
function group_content(&$a) {
$change = false;
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied') . EOL);
return;
}
}
- if(($a->argc == 3) && ($a->argv[1] === 'drop')) {
+ if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
check_form_security_token_redirectOnErr('/group', 'group_drop', 't');
- if(intval($a->argv[2])) {
+ if (intval($a->argv[2])) {
$r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]),
intval(local_user())
);
- if (dbm::is_result($r))
+
+ $result = null;
+
+ if (dbm::is_result($r)) {
$result = group_rmv(local_user(),$r[0]['name']);
- if($result)
+ }
+
+ if ($result) {
info( t('Group removed.') . EOL);
- else
+ } else {
notice( t('Unable to remove group.') . EOL);
+ }
}
- goaway($a->get_baseurl() . '/group');
+ goaway(App::get_baseurl() . '/group');
// NOTREACHED
}
- if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
+ if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
check_form_security_token_ForbiddenOnErr('group_member_change', 't');
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
$change = intval($a->argv[2]);
}
- if(($a->argc > 1) && (intval($a->argv[1]))) {
+ if (($a->argc > 1) && (intval($a->argv[1]))) {
require_once('include/acl_selectors.php');
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
intval($a->argv[1]),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Group not found.') . EOL );
- goaway($a->get_baseurl() . '/contacts');
+ goaway(App::get_baseurl() . '/contacts');
}
$group = $r[0];
$members = group_get_members($group['id']);
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
- if($a->argc > 1)
+ if ($a->argc > 1) {
$which = $a->argv[1];
+ }
else {
notice( t('No profile') . EOL );
$a->error = 404;
}
$profile = 0;
- if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
- $which = $a->user['nickname'];
- $profile = $a->argv[1];
+ if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
+ $which = $a->user['nickname'];
+ $profile = $a->argv[1];
}
profile_load($a,$which,$profile);
- if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
+ if ((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
}
- if(x($a->profile,'openidserver'))
+ if (x($a->profile,'openidserver')) {
$a->page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\r\n";
- if(x($a->profile,'openid')) {
+ }
+ if (x($a->profile,'openid')) {
$delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
$a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
}
- if(! $blocked) {
+ if (! $blocked) {
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
- if(strlen($keywords))
+ if (strlen($keywords)) {
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
+ }
}
$a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
+ $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . App::get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
- $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
- header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
-
+ $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . App::get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
+ header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
+
$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
- foreach($dfrn_pages as $dfrn)
- $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
+ foreach ($dfrn_pages as $dfrn) {
+ $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".App::get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
+ }
}
if ($level>$lastlevel) $toc.="<ul>";
$idnum[$level]++;
$id = implode("_", array_slice($idnum,1,$level));
- $href = $a->get_baseurl()."/help/{$filename}#{$id}";
+ $href = App::get_baseurl()."/help/{$filename}#{$id}";
$toc .= "<li><a href='{$href}'>".strip_tags($line)."</a></li>";
$line = "<a name='{$id}'></a>".$line;
$lastlevel = $level;
$ret = array();
call_hooks('home_init',$ret);
- if(local_user() && ($a->user['nickname']))
- goaway($a->get_baseurl()."/network");
- //goaway($a->get_baseurl()."/profile/".$a->user['nickname']);
+ if (local_user() && ($a->user['nickname'])) {
+ goaway(App::get_baseurl()."/network");
+ }
- if(strlen(get_config('system','singleuser')))
- goaway($a->get_baseurl()."/profile/" . get_config('system','singleuser'));
+ if (strlen(get_config('system','singleuser'))) {
+ goaway(App::get_baseurl()."/profile/" . get_config('system','singleuser'));
+ }
}}
-
if(! function_exists('home_content')) {
function home_content(&$a) {
$o = '';
- if(x($_SESSION,'theme'))
+ if (x($_SESSION,'theme')) {
unset($_SESSION['theme']);
- if(x($_SESSION,'mobile-theme'))
+ }
+ if (x($_SESSION,'mobile-theme')) {
unset($_SESSION['mobile-theme']);
+ }
- if(file_exists('home.html')){
- if(file_exists('home.css')){
- $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.$a->get_baseurl().'/home.css'.'" media="all" />';}
-
- $o .= file_get_contents('home.html');}
+ /// @TODO No absolute path used, maybe risky (security)
+ if (file_exists('home.html')) {
+ if (file_exists('home.css')) {
+ $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'.App::get_baseurl().'/home.css'.'" media="all" />';
+ }
- else $o .= '<h1>'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'</h1>';
+ $o .= file_get_contents('home.html');
+ } else {
+ $o .= '<h1>'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'</h1>';
+ }
$o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
return $o;
-
}}
$ignored = 0;
- if(! local_user())
+ if (! local_user()) {
killme();
- if($a->argc > 1)
+ }
+ if ($a->argc > 1) {
$message_id = intval($a->argv[1]);
- if(! $message_id)
+ }
+ if (! $message_id) {
killme();
+ }
$r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1",
intval(local_user()),
intval($message_id)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
killme();
+ }
- if(! intval($r[0]['ignored']))
+ if (! intval($r[0]['ignored'])) {
$ignored = 1;
+ }
$r = q("UPDATE `thread` SET `ignored` = %d WHERE `uid` = %d and `iid` = %d",
intval($ignored),
// See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
- if($return_path) {
+ if ($return_path) {
$rand = '_=' . time();
if(strpos($return_path, '?')) $rand = "&$rand";
else $rand = "?$rand";
- goaway($a->get_baseurl() . "/" . $return_path . $rand);
+ goaway(App::get_baseurl() . "/" . $return_path . $rand);
}
// the json doesn't really matter, it will either be 0 or 1
echo "ok";
killme();
}
-
+
// We overwrite current theme css, because during install we could not have a working mod_rewrite
// so we could not have a css at all. Here we set a static css file for the install procedure pages
$a->config['system']['theme'] = "../install";
- $a->theme['stylesheet'] = $a->get_baseurl()."/view/install/style.css";
-
-
-
+ $a->theme['stylesheet'] = App::get_baseurl()."/view/install/style.css";
+
global $install_wizard_pass;
- if (x($_POST,'pass'))
+ if (x($_POST,'pass')) {
$install_wizard_pass = intval($_POST['pass']);
+ }
}
$r = q("CREATE DATABASE '%s'",
dbesc($dbdata)
);
- if($r) {
+ if ($r) {
unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
} else {
return;
}
}*/
- if(get_db_errno()) {
+ if (get_db_errno()) {
$a->data['db_conn_failed']=true;
}
$result = file_put_contents('.htconfig.php', $txt);
- if(! $result) {
+ if (! $result) {
$a->data['txt'] = $txt;
}
$errors = load_database($db);
- if($errors)
+ if ($errors) {
$a->data['db_failed'] = $errors;
- else
+ } else {
$a->data['db_installed'] = true;
+ }
return;
break;
}
function get_db_errno() {
- if(class_exists('mysqli'))
+ if (class_exists('mysqli')) {
return mysqli_connect_errno();
- else
+ } else {
return mysql_errno();
+ }
}
function install_content(&$a) {
- if(x($a->data,'db_conn_failed')) {
+ if (x($a->data,'db_conn_failed')) {
$install_wizard_pass = 2;
$wizard_status = t('Could not connect to database.');
}
- if(x($a->data,'db_create_failed')) {
+ if (x($a->data,'db_create_failed')) {
$install_wizard_pass = 2;
$wizard_status = t('Could not create table.');
}
$db_return_text="";
- if(x($a->data,'db_installed')) {
+ if (x($a->data,'db_installed')) {
$txt = '<p style="font-size: 130%;">';
$txt .= t('Your Friendica site database has been installed.') . EOL;
$db_return_text .= $txt;
}
- if(x($a->data,'db_failed')) {
+ if (x($a->data,'db_failed')) {
$txt = t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL;
$txt .= t('Please see the file "INSTALL.txt".') . EOL ."<hr>" ;
$txt .= "<pre>".$a->data['db_failed'] . "</pre>". EOL ;
}
}
- if(x($a->data,'txt') && strlen($a->data['txt'])) {
+ if (x($a->data,'txt') && strlen($a->data['txt'])) {
$db_return_text .= manual_config($a);
}
check_keys($checks);
- if(x($_POST,'phpath'))
+ if (x($_POST,'phpath')) {
$phpath = notags(trim($_POST['phpath']));
+ }
check_php($phpath, $checks);
- check_htaccess($checks);
+ check_htaccess($checks);
+ /// @TODO Maybe move this out?
function check_passed($v, $c){
- if ($c['required'])
+ if ($c['required']) {
$v = $v && $c['status'];
+ }
return $v;
}
$checkspassed = array_reduce($checks, "check_passed", true);
'$next' => t('Next'),
'$reload' => t('Check again'),
'$phpath' => $phpath,
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
));
return $o;
}; break;
'$lbl_10' => t('Please select a default timezone for your website'),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$phpath' => $phpath,
'$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''),
'$language' => array('language', t('System Language:'), 'en', t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
$passed = strlen($phpath);
}
$help = "";
- if(!$passed) {
+ if (!$passed) {
$help .= t('Could not find a command line version of PHP in the web server PATH.'). EOL;
$help .= t("If you don't have a command line version of PHP installed on server, you will not be able to run background polling via cron. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-poller'>'Setup the poller'</a>") . EOL ;
$help .= EOL . EOL ;
}
- if($passed2) {
+ if ($passed2) {
$str = autoname(8);
$cmd = "$phpath testargs.php $str";
$result = trim(shell_exec($cmd));
$res = false;
- if(function_exists('openssl_pkey_new'))
- $res=openssl_pkey_new(array(
- 'digest_alg' => 'sha1',
- 'private_key_bits' => 4096,
- 'encrypt_key' => false ));
+ if (function_exists('openssl_pkey_new')) {
+ $res = openssl_pkey_new(array(
+ 'digest_alg' => 'sha1',
+ 'private_key_bits' => 4096,
+ 'encrypt_key' => false
+ ));
+ }
// Get private key
- if(! $res) {
+ if (! $res) {
$help .= t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys'). EOL;
$help .= t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".');
}
check_add($ck_funcs, t('XML PHP module'), true, true, "");
check_add($ck_funcs, t('iconv module'), true, true, "");
- if(function_exists('apache_get_modules')){
+ if (function_exists('apache_get_modules')){
if (! in_array('mod_rewrite',apache_get_modules())) {
check_add($ck_funcs, t('Apache mod_rewrite module'), false, true, t('Error: Apache webserver mod-rewrite module is required but not installed.'));
} else {
}
}
- if(! function_exists('curl_init')){
+ if (! function_exists('curl_init')){
$ck_funcs[0]['status']= false;
$ck_funcs[0]['help']= t('Error: libCURL PHP module required but not installed.');
}
- if(! function_exists('imagecreatefromjpeg')){
+ if (! function_exists('imagecreatefromjpeg')){
$ck_funcs[1]['status']= false;
$ck_funcs[1]['help']= t('Error: GD graphics PHP module with JPEG support required but not installed.');
}
- if(! function_exists('openssl_public_encrypt')) {
+ if (! function_exists('openssl_public_encrypt')) {
$ck_funcs[2]['status']= false;
$ck_funcs[2]['help']= t('Error: openssl PHP module required but not installed.');
}
- if(! function_exists('mysqli_connect')){
+ if (! function_exists('mysqli_connect')){
$ck_funcs[3]['status']= false;
$ck_funcs[3]['help']= t('Error: mysqli PHP module required but not installed.');
}
- if(! function_exists('mb_strlen')){
+ if (! function_exists('mb_strlen')){
$ck_funcs[4]['status']= false;
$ck_funcs[4]['help']= t('Error: mb_string PHP module required but not installed.');
}
- if(! function_exists('mcrypt_create_iv')){
+ if (! function_exists('mcrypt_create_iv')){
$ck_funcs[5]['status']= false;
$ck_funcs[5]['help']= t('Error: mcrypt PHP module required but not installed.');
}
- if(! function_exists('iconv_strlen')){
+ if (! function_exists('iconv_strlen')){
$ck_funcs[7]['status']= false;
$ck_funcs[7]['help']= t('Error: iconv PHP module required but not installed.');
}
function check_htconfig(&$checks) {
$status = true;
$help = "";
- if( (file_exists('.htconfig.php') && !is_writable('.htconfig.php')) ||
+ if ((file_exists('.htconfig.php') && !is_writable('.htconfig.php')) ||
(!file_exists('.htconfig.php') && !is_writable('.')) ) {
$status=false;
function check_smarty3(&$checks) {
$status = true;
$help = "";
- if( !is_writable('view/smarty3') ) {
+ if (!is_writable('view/smarty3') ) {
$status=false;
$help = t('Friendica uses the Smarty3 template engine to render its web views. Smarty3 compiles templates to PHP to speed up rendering.') .EOL;
}
function check_htaccess(&$checks) {
- $a = get_app();
$status = true;
$help = "";
- if (function_exists('curl_init')){
- $test = fetch_url($a->get_baseurl()."/install/testrewrite");
+ if (function_exists('curl_init')) {
+ $test = fetch_url(App::get_baseurl()."/install/testrewrite");
- if ($test!="ok")
- $test = fetch_url(normalise_link($a->get_baseurl()."/install/testrewrite"));
+ if ($test!="ok") {
+ $test = fetch_url(normalise_link(App::get_baseurl()."/install/testrewrite"));
+ }
if ($test!="ok") {
$status = false;
check_add($checks, t('Url rewrite is working'), $status, true, $help);
} else {
// cannot check modrewrite if libcurl is not installed
+ /// @TODO Maybe issue warning here?
}
}
}
if ($imagick == false) {
check_add($checks, t('ImageMagick PHP extension is not installed'), $imagick, false, "");
- }
- else {
+ } else {
check_add($checks, t('ImageMagick PHP extension is installed'), $imagick, false, "");
if ($imagick) {
check_add($checks, t('ImageMagick supports GIF'), $gif, false, "");
}
}
-
-
function manual_config(&$a) {
$data = htmlentities($a->data['txt'],ENT_COMPAT,'UTF-8');
$o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.');
}
function what_next() {
- $a = get_app();
- $baseurl = $a->get_baseurl();
+ $baseurl = App::get_baseurl();
return
t('<h1>What next</h1>')
."<p>".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.')
function invite_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
check_form_security_token_redirectOnErr('/', 'send_invite');
$max_invites = intval(get_config('system','max_invites'));
- if(! $max_invites)
+ if (! $max_invites) {
$max_invites = 50;
+ }
$current_invites = intval(get_pconfig(local_user(),'system','sent_invites'));
- if($current_invites > $max_invites) {
+ if ($current_invites > $max_invites) {
notice( t('Total invitation limit exceeded.') . EOL);
return;
- };
+ }
$recips = ((x($_POST,'recipients')) ? explode("\n",$_POST['recipients']) : array());
$total = 0;
- if(get_config('system','invitation_only')) {
+ if (get_config('system','invitation_only')) {
$invonly = true;
$x = get_pconfig(local_user(),'system','invites_remaining');
- if((! $x) && (! is_site_admin()))
+ if ((! $x) && (! is_site_admin())) {
return;
+ }
}
- foreach($recips as $recip) {
+ foreach ($recips as $recip) {
$recip = trim($recip);
- if(! valid_email($recip)) {
+ if (! valid_email($recip)) {
notice( sprintf( t('%s : Not a valid email address.'), $recip) . EOL);
continue;
}
-
- if($invonly && ($x || is_site_admin())) {
+
+ if ($invonly && ($x || is_site_admin())) {
$code = autoname(8) . srand(1000,9999);
$nmessage = str_replace('$invite_code',$code,$message);
dbesc(datetime_convert())
);
- if(! is_site_admin()) {
+ if (! is_site_admin()) {
$x --;
- if($x >= 0)
+ if ($x >= 0) {
set_pconfig(local_user(),'system','invites_remaining',$x);
- else
+ } else {
return;
+ }
}
- }
- else
+ } else {
$nmessage = $message;
+ }
$res = mail($recip, email_header_encode( t('Please join us on Friendica'),'UTF-8'),
$nmessage,
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit' );
- if($res) {
+ if ($res) {
$total ++;
$current_invites ++;
set_pconfig(local_user(),'system','sent_invites',$current_invites);
notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL);
return;
}
- }
- else {
+ } else {
notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL);
}
function invite_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
$tpl = get_markup_template('invite.tpl');
$invonly = false;
- if(get_config('system','invitation_only')) {
+ if (get_config('system','invitation_only')) {
$invonly = true;
$x = get_pconfig(local_user(),'system','invites_remaining');
- if((! $x) && (! is_site_admin())) {
+ if ((! $x) && (! is_site_admin())) {
notice( t('You have no more invitations available') . EOL);
return '';
}
}
$dirloc = get_config('system','directory');
- if(strlen($dirloc)) {
- if($a->config['register_policy'] == REGISTER_CLOSED)
+ if (strlen($dirloc)) {
+ if ($a->config['register_policy'] == REGISTER_CLOSED) {
$linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo');
- elseif($a->config['register_policy'] != REGISTER_CLOSED)
- $linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), $a->get_baseurl())
+ } elseif($a->config['register_policy'] != REGISTER_CLOSED) {
+ $linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), App::get_baseurl())
. "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo');
- }
- else {
+ }
+ } else {
$o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
return $o;
}
$o = replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("send_invite"),
- '$invite' => t('Send invitations'),
- '$addr_text' => t('Enter email addresses, one per line:'),
- '$msg_text' => t('Your message:'),
- '$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
+ '$invite' => t('Send invitations'),
+ '$addr_text' => t('Enter email addresses, one per line:'),
+ '$msg_text' => t('Your message:'),
+ '$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
. $linktxt
. "\r\n" . "\r\n" . (($invonly) ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') .t('Once you have registered, please connect with me via my profile page at:')
- . "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname']
+ . "\r\n" . "\r\n" . App::get_baseurl() . '/profile/' . $a->user['nickname']
. "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n" ,
- '$submit' => t('Submit')
+ '$submit' => t('Submit')
));
return $o;
// Check for doubly-submitted posts, and reject duplicates
// Note that we have to ignore previews, otherwise nothing will post
// after it's been previewed
- if(!$preview && x($_REQUEST['post_id_random'])) {
- if(x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
+ if (!$preview && x($_REQUEST['post_id_random'])) {
+ if (x($_SESSION['post-random']) && $_SESSION['post-random'] == $_REQUEST['post_id_random']) {
logger("item post: duplicate post", LOGGER_DEBUG);
- item_post_return($a->get_baseurl(), $api_source, $return_path);
+ item_post_return(App::get_baseurl(), $api_source, $return_path);
}
- else
+ else {
$_SESSION['post-random'] = $_REQUEST['post_id_random'];
+ }
}
/**
$r = false;
$objecttype = null;
- if($parent || $parent_uri) {
+ if ($parent || $parent_uri) {
$objecttype = ACTIVITY_OBJ_COMMENT;
- if(! x($_REQUEST,'type'))
+ if (! x($_REQUEST,'type')) {
$_REQUEST['type'] = 'net-comment';
+ }
- if($parent) {
+ if ($parent) {
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
intval($parent)
);
- } elseif($parent_uri && local_user()) {
+ }
+ elseif ($parent_uri && local_user()) {
// This is coming from an API source, and we are logged in
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($parent_uri),
if (dbm::is_result($r)) {
$parid = $r[0]['parent'];
$parent_uri = $r[0]['uri'];
- if($r[0]['id'] != $r[0]['parent']) {
+ if ($r[0]['id'] != $r[0]['parent']) {
$r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1",
intval($parid)
);
}
}
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Unable to locate original post.') . EOL);
- if(x($_REQUEST,'return'))
+ if (x($_REQUEST,'return')) {
goaway($return_path);
+ }
killme();
}
$parent_item = $r[0];
//if(($parid) && ($parid != $parent))
$thr_parent = $parent_uri;
- if($parent_item['contact-id'] && $uid) {
+ if ($parent_item['contact-id'] && $uid) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($parent_item['contact-id']),
intval($uid)
$objecttype = ACTIVITY_OBJ_IMAGE;
- foreach($images as $image) {
- if(! stristr($image,$a->get_baseurl() . '/photo/'))
+ foreach ($images as $image) {
+ if (! stristr($image,App::get_baseurl() . '/photo/')) {
continue;
+ }
$image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
- if(! strlen($image_uri))
+ if (! strlen($image_uri)) {
continue;
+ }
$srch = '<' . intval($contact_id) . '>';
$r = q("SELECT `id` FROM `photo` WHERE `allow_cid` = '%s' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''
intval($profile_uid)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
continue;
+ }
$r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
WHERE `resource-id` = '%s' AND `uid` = %d AND `album` = '%s' ",
intval($mtch)
);
if (dbm::is_result($r)) {
- if(strlen($attachments))
+ if (strlen($attachments)) {
$attachments .= ',';
- $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
+ }
+ $attachments .= '[attach]href="' . App::get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
}
$body = str_replace($match[1],'',$body);
}
$wall = 0;
- if($post_type === 'wall' || $post_type === 'wall-comment')
+ if ($post_type === 'wall' || $post_type === 'wall-comment') {
$wall = 1;
+ }
- if(! strlen($verb))
+ if (! strlen($verb)) {
$verb = ACTIVITY_POST ;
+ }
- if ($network == "")
+ if ($network == "") {
$network = NETWORK_DFRN;
+ }
$gravity = (($parent) ? 6 : 0 );
$uri = (($message_id) ? $message_id : item_new_uri($a->get_hostname(),$profile_uid, $guid));
// Fallback so that we alway have a thr-parent
- if(!$thr_parent)
+ if (!$thr_parent) {
$thr_parent = $uri;
+ }
$datarray = array();
$datarray['uid'] = $profile_uid;
// $datarray['prvnets'] = $user['prvnets'];
$datarray['parent-uri'] = ($parent == 0) ? $uri : $parent_item['uri'];
- $datarray['plink'] = $a->get_baseurl().'/display/'.urlencode($datarray['guid']);
+ $datarray['plink'] = App::get_baseurl().'/display/'.urlencode($datarray['guid']);
$datarray['last-child'] = 1;
$datarray['visible'] = 1;
}
$json = array('cancel' => 1);
- if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
- $json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
+ if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) {
+ $json['reload'] = App::get_baseurl() . '/' . $_REQUEST['jsreload'];
+ }
echo json_encode($json);
killme();
'to_email' => $user['email'],
'uid' => $user['uid'],
'item' => $datarray,
- 'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']),
+ 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
'to_email' => $user['email'],
'uid' => $user['uid'],
'item' => $datarray,
- 'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']),
+ 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
continue;
$disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
. '<br />';
- $disclaimer .= sprintf( t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
+ $disclaimer .= sprintf( t('You may visit them online at %s'), App::get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
$disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
if (!$datarray['title']=='') {
$subject = email_header_encode($datarray['title'],'UTF-8');
} else {
$subject = email_header_encode('[Friendica]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']),'UTF-8');
}
- $link = '<a href="' . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
+ $link = '<a href="' . App::get_baseurl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
$html = prepare_body($datarray);
$message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';
include_once('include/html2plain.php');
logger('post_complete');
- item_post_return($a->get_baseurl(), $api_source, $return_path);
+ item_post_return(App::get_baseurl(), $api_source, $return_path);
// NOTREACHED
}
if($api_source)
return;
- if($return_path) {
+ if ($return_path) {
goaway($return_path);
}
$json = array('success' => 1);
- if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
+ if (x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload'])) {
$json['reload'] = $baseurl . '/' . $_REQUEST['jsreload'];
+ }
logger('post_json: ' . print_r($json,true), LOGGER_DEBUG);
function item_content(&$a) {
- if((! local_user()) && (! remote_user()))
+ if ((! local_user()) && (! remote_user())) {
return;
+ }
require_once('include/security.php');
$o = '';
- if(($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
+ if (($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
$o = drop_item($a->argv[2], !is_ajax());
- if (is_ajax()){
+ if (is_ajax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>]
echo json_encode(array(intval($a->argv[2]), intval($o)));
killme();
* This function removes the tag $tag from the text $body and replaces it with
* the appropiate link.
*
+ * @param App $a Application instance @TODO is unused in this function's scope (excluding included files)
* @param unknown_type $body the text to replace the tag in
* @param string $inform a comma-seperated string containing everybody to inform
* @param string $str_tags string to add the tag to
$r = null;
//is it a person tag?
- if(strpos($tag,'@') === 0) {
+ if (strpos($tag,'@') === 0) {
//is it already replaced?
- if(strpos($tag,'[url=')) {
+ if (strpos($tag,'[url=')) {
//append tag to str_tags
- if(!stristr($str_tags,$tag)) {
- if(strlen($str_tags))
+ if (!stristr($str_tags,$tag)) {
+ if (strlen($str_tags)) {
$str_tags .= ',';
+ }
$str_tags .= $tag;
}
// See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
- like_content_return($a->get_baseurl(), $return_path);
+ like_content_return(App::get_baseurl(), $return_path);
killme(); // NOTREACHED
// return; // NOTREACHED
}
$o .= '<p>' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '</p>';
- $o .= '<form action ="' . $a->get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >';
+ $o .= '<form action ="' . App::get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >';
$o .= '<p>' . t('Please select your timezone:') . '</p>';
dbesc($type),
intval($item_id)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
killme();
+ }
$item = $r[0];
call_hooks('lockview_content', $item);
dbesc($loginame)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('No valid account found.') . EOL);
goaway(z_root());
}
$sitename = $a->config['sitename'];
- $siteurl = $a->get_baseurl();
- $resetlink = $a->get_baseurl() . '/lostpass?verify=' . $new_password;
+ $resetlink = App::get_baseurl() . '/lostpass?verify=' . $new_password;
$preamble = deindent(t('
Dear %1$s,
Login Name: %3$s'));
$preamble = sprintf($preamble, $username, $sitename);
- $body = sprintf($body, $resetlink, $siteurl, $email);
+ $body = sprintf($body, $resetlink, App::get_baseurl(), $email);
notification(array(
'type' => "SYSTEM_EMAIL",
$r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1",
dbesc($hash)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$o = t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.");
return $o;
}
dbesc($new_password_encoded),
intval($uid)
);
- if($r) {
+ if ($r) {
$tpl = get_markup_template('pwdreset.tpl');
$o .= replace_macros($tpl,array(
'$lbl1' => t('Password Reset'),
'$lbl2' => t('Your password has been reset as requested.'),
'$lbl3' => t('Your new password is'),
'$lbl4' => t('Save or copy your new password - and then'),
- '$lbl5' => '<a href="' . $a->get_baseurl() . '">' . t('click here to login') . '</a>.',
+ '$lbl5' => '<a href="' . App::get_baseurl() . '">' . t('click here to login') . '</a>.',
'$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'),
'$newpass' => $new_password,
- '$baseurl' => $a->get_baseurl()
+ '$baseurl' => App::get_baseurl()
));
info("Your password has been reset." . EOL);
$sitename = $a->config['sitename'];
- $siteurl = $a->get_baseurl();
// $username, $email, $new_password
$preamble = deindent(t('
Dear %1$s,
'));
$preamble = sprintf($preamble, $username);
- $body = sprintf($body, $siteurl, $email, $new_password);
+ $body = sprintf($body, App::get_baseurl(), $email, $new_password);
notification(array(
'type' => "SYSTEM_EMAIL",
function manage_post(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$uid = local_user();
$orig_record = $a->user;
);
}
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
return;
+ }
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
$ret = array();
call_hooks('home_init',$ret);
- goaway( $a->get_baseurl() . "/profile/" . $a->user['nickname'] );
+ goaway( App::get_baseurl() . "/profile/" . $a->user['nickname'] );
// NOTREACHED
}
function manage_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
function match_content(&$a) {
$o = '';
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$a->page['aside'] .= findpeople_widget();
$a->page['aside'] .= follow_widget();
- $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
+ $_SESSION['return_url'] = App::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(! dbm::is_result($r))
+ if (! dbm::is_result($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;
if(strlen(get_config('system','directory')))
$x = post_url(get_server().'/msearch', $params);
else
- $x = post_url($a->get_baseurl() . '/msearch', $params);
+ $x = post_url(App::get_baseurl() . '/msearch', $params);
$j = json_decode($x);
if (!count($match)) {
$jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
- $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
+ $connlnk = App::get_baseurl() . '/follow/?url=' . $jj->url;
$photo_menu = array(
'profile' => array(t("View Profile"), zrl($jj->url)),
'follow' => array(t("Connect/Follow"), $connlnk)
'$tabs'=>$tabs,
'$new'=>$new,
));
- $base = $a->get_baseurl();
+ $base = App::get_baseurl();
$head_tpl = get_markup_template('message-head.tpl');
$a->page['htmlhead'] .= replace_macros($head_tpl,array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$base' => $base
));
$end_tpl = get_markup_template('message-end.tpl');
$a->page['end'] .= replace_macros($end_tpl,array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$base' => $base
));
function message_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
$newbody = $newbody . $origbody;
$cnt = 0;
- foreach($images as $image) {
+ foreach ($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that
// it loops over the array starting from the first element and going sequentially
// to the last element
$o = '';
nav_set_selected('messages');
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
- $myprofile = $a->get_baseurl().'/profile/' . $a->user['nickname'];
+ $myprofile = App::get_baseurl().'/profile/' . $a->user['nickname'];
$tpl = get_markup_template('mail_head.tpl');
$header = replace_macros($tpl, array(
intval($a->argv[2]),
intval(local_user())
);
- if($r) {
+ if ($r) {
info( t('Message deleted.') . EOL );
}
- //goaway($a->get_baseurl(true) . '/message' );
+ //goaway(App::get_baseurl(true) . '/message' );
goaway($_SESSION['return_url']);
}
else {
if($r)
info( t('Conversation removed.') . EOL );
}
- //goaway($a->get_baseurl(true) . '/message' );
+ //goaway(App::get_baseurl(true) . '/message' );
goaway($_SESSION['return_url']);
}
$tpl = get_markup_template('msg-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$nickname' => $a->user['nickname'],
'$linkurl' => t('Please enter a link URL:')
$tpl = get_markup_template('msg-end.tpl');
$a->page['end'] .= replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$nickname' => $a->user['nickname'],
'$linkurl' => t('Please enter a link URL:')
$r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
info( t('No messages.') . EOL);
return $o;
}
$tpl = get_markup_template('msg-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$nickname' => $a->user['nickname'],
'$linkurl' => t('Please enter a link URL:')
$tpl = get_markup_template('msg-end.tpl');
$a->page['end'] .= replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$nickname' => $a->user['nickname'],
'$linkurl' => t('Please enter a link URL:')
$tpl = get_markup_template($t);
$rslt = '';
- $myprofile = $a->get_baseurl().'/profile/' . $a->user['nickname'];
+ $myprofile = App::get_baseurl().'/profile/' . $a->user['nickname'];
foreach($msg as $rr) {
dbesc($nick)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
killme();
+ }
$lines = explode("\n",$r[0]['spubkey']);
unset($lines[0]);
function mood_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$uid = local_user();
$verb = notags(trim($_GET['verb']));
$item_id = item_store($arr);
if($item_id) {
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
- dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
+ dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
intval($uid),
intval($item_id)
);
function mood_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
foreach($r as $rr)
$results[] = array(
'name' => $rr['name'],
- 'url' => $a->get_baseurl() . '/profile/' . $rr['nickname'],
- 'photo' => $a->get_baseurl() . '/photo/avatar/' . $rr['uid'] . '.jpg',
+ 'url' => App::get_baseurl() . '/profile/' . $rr['nickname'],
+ 'photo' => App::get_baseurl() . '/photo/avatar/' . $rr['uid'] . '.jpg',
'tags' => str_replace(array(',',' '),array(' ',' '),$rr['pub_keywords'])
);
}
$tpl = get_markup_template('navigation.tpl');
return replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$sitelocation' => $nav_info['sitelocation'],
'$nav' => $nav_info['nav'],
'$banner' => $nav_info['banner'],
<?php
function network_init(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
$redir_url = ($net_queries ? $net_baseurl."?".$net_queries : $net_baseurl);
- goaway($a->get_baseurl() . $redir_url);
+ goaway(App::get_baseurl() . $redir_url);
}
}
intval(local_user()),
dbesc($search)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
q("INSERT INTO `search` ( `uid`,`term` ) VALUES ( %d, '%s') ",
intval(local_user()),
dbesc($search)
$saved = array();
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$saved[] = array(
- 'id' => $rr['id'],
- 'term' => $rr['term'],
- 'encodedterm' => urlencode($rr['term']),
- 'delete' => t('Remove term'),
- 'selected' => ($search==$rr['term']),
+ 'id' => $rr['id'],
+ 'term' => $rr['term'],
+ 'encodedterm' => urlencode($rr['term']),
+ 'delete' => t('Remove term'),
+ 'selected' => ($search==$rr['term']),
);
}
}
$tpl = get_markup_template("saved_searches_aside.tpl");
$o = replace_macros($tpl, array(
- '$title' => t('Saved Searches'),
- '$add' => t('add'),
- '$searchbox' => search($search,'netsearch-box',$srchurl,true),
- '$saved' => $saved,
+ '$title' => t('Saved Searches'),
+ '$add' => t('add'),
+ '$searchbox' => search($search,'netsearch-box',$srchurl,true),
+ '$saved' => $saved,
));
return $o;
require_once('include/conversation.php');
- if(! local_user()) {
+ if (! local_user()) {
$_SESSION['return_url'] = $a->query_string;
return login(false);
}
intval($group),
intval($_SESSION['uid'])
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
if($update)
killme();
notice( t('No such group') . EOL );
killme();
}
$nodeinfo = array("links" => array(array("rel" => "http://nodeinfo.diaspora.software/ns/schema/1.0",
- "href" => $a->get_baseurl()."/nodeinfo/1.0")));
+ "href" => App::get_baseurl()."/nodeinfo/1.0")));
header('Content-type: application/json; charset=utf-8');
echo json_encode($nodeinfo, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
function nogroup_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
require_once('include/group.php');
require_once('include/contact_widgets.php');
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside')) {
$a->page['aside'] = '';
+ }
$a->page['aside'] .= group_side('contacts','group','extended',0,$contact_id);
}
function nogroup_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return '';
}
}
$r = contacts_not_grouped(local_user(),$a->pager['start'],$a->pager['itemspage']);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$contact_details = get_contact_details_by_url($rr['url'], local_user(), $rr);
intval($a->profile['uid']));
$json_info = array(
- 'fn' => $a->profile['name'],
- 'addr' => $a->profile['addr'],
- 'nick' => $which,
- 'key' => $a->profile['pubkey'],
- 'homepage' => $a->get_baseurl()."/profile/{$which}",
- 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
- 'photo' => $r[0]["photo"],
- 'tags' => $keywords
+ 'fn' => $a->profile['name'],
+ 'addr' => $a->profile['addr'],
+ 'nick' => $which,
+ 'key' => $a->profile['pubkey'],
+ 'homepage' => App::get_baseurl()."/profile/{$which}",
+ 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
+ 'photo' => $r[0]["photo"],
+ 'tags' => $keywords
);
- if(is_array($a->profile) AND !$a->profile['hide-friends']) {
+ if (is_array($a->profile) AND !$a->profile['hide-friends']) {
$r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
intval($a->profile['uid']));
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$json_info["updated"] = date("c", strtotime($r[0]['updated']));
+ }
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0
AND `network` IN ('%s', '%s', '%s', '')",
dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_OSTATUS)
);
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$json_info["contacts"] = intval($r[0]['total']);
+ }
}
//These are optional fields.
$profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about');
- foreach($profile_fields as $field)
- if(!empty($a->profile[$field])) $json_info["$field"] = $a->profile[$field];
+ foreach ($profile_fields as $field) {
+ if (!empty($a->profile[$field])) {
+ $json_info["$field"] = $a->profile[$field];
+ }
+ }
$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
- foreach($dfrn_pages as $dfrn)
- $json_info["dfrn-{$dfrn}"] = $a->get_baseurl()."/dfrn_{$dfrn}/{$which}";
+ foreach ($dfrn_pages as $dfrn) {
+ $json_info["dfrn-{$dfrn}"] = App::get_baseurl()."/dfrn_{$dfrn}/{$which}";
+ }
//Output all the JSON!
header('Content-type: application/json; charset=utf-8');
function notes_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$profile = 0;
function notes_content(&$a,$update = false) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
);
if (dbm::is_result($r)){
$nick = $r[0]['nickname'];
- $url = $a->get_baseurl()."/display/$nick/$id";
+ $url = App::get_baseurl()."/display/$nick/$id";
goaway($url);
} else {
$a->error = 404;
function notifications_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
goaway(z_root());
}
function notifications_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
function notify_init(&$a) {
- if(! local_user()) return;
+ if (! local_user()) {
+ return;
+ }
+
$nm = new NotificationsManager();
-
- if($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
+
+ if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
$note = $nm->getByID($a->argv[2]);
if ($note) {
$nm->setSeen($note);
$urldata = parse_url($note['link']);
$guid = basename($urldata["path"]);
$itemdata = get_item_id($guid, local_user());
- if ($itemdata["id"] != 0)
- $note['link'] = $a->get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
+ if ($itemdata["id"] != 0) {
+ $note['link'] = App::get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
+ }
}
goaway($note['link']);
}
- goaway($a->get_baseurl(true));
+ goaway(App::get_baseurl(true));
}
- if($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
+ if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
$r = $nm->setAllSeen();
$j = json_encode(array('result' => ($r) ? 'success' : 'fail'));
echo $j;
}
function notify_content(&$a) {
- if(! local_user()) return login();
+ if (! local_user()) {
+ return login();
+ }
$nm = new NotificationsManager();
if (dbm::is_result($r) > 0) {
foreach ($r as $it) {
$notif_content .= replace_macros($not_tpl,array(
- '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
+ '$item_link' => App::get_baseurl(true).'/notify/view/'. $it['id'],
'$item_image' => $it['photo'],
'$item_text' => strip_tags(bbcode($it['msg'])),
'$item_when' => relative_date($it['date'])
if(($a->argc > 1) && ($a->argv[1] === 'xrd')) {
$tpl = get_markup_template('oexchange_xrd.tpl');
- $o = replace_macros($tpl, array('$base' => $a->get_baseurl()));
+ $o = replace_macros($tpl, array('$base' => App::get_baseurl()));
echo $o;
killme();
}
function oexchange_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
$o = login(false);
return $o;
}
- if(($a->argc > 1) && $a->argv[1] === 'done') {
+ if (($a->argc > 1) && $a->argv[1] === 'done') {
info( t('Post successful.') . EOL);
return;
}
$tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags']))
? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
- $s = fetch_url($a->get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
+ $s = fetch_url(App::get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
if(! strlen($s))
return;
// Successful OpenID login - but we can't match it to an existing account.
// New registration?
- if($a->config['register_policy'] == REGISTER_CLOSED) {
+ if ($a->config['register_policy'] == REGISTER_CLOSED) {
notice( t('Account not found and OpenID registration is not permitted on this site.') . EOL);
goaway(z_root());
}
unset($_SESSION['register']);
$args = '';
$attr = $openid->getAttributes();
- if(is_array($attr) && count($attr)) {
- foreach($attr as $k => $v) {
- if($k === 'namePerson/friendly')
+ if (is_array($attr) && count($attr)) {
+ foreach ($attr as $k => $v) {
+ if ($k === 'namePerson/friendly') {
$nick = notags(trim($v));
- if($k === 'namePerson/first')
+ }
+ if($k === 'namePerson/first') {
$first = notags(trim($v));
- if($k === 'namePerson')
+ }
+ if($k === 'namePerson') {
$args .= '&username=' . notags(trim($v));
- if($k === 'contact/email')
+ }
+ if ($k === 'contact/email') {
$args .= '&email=' . notags(trim($v));
- if($k === 'media/image/aspect11')
+ }
+ if ($k === 'media/image/aspect11') {
$photosq = bin2hex(trim($v));
- if($k === 'media/image/default')
+ }
+ if ($k === 'media/image/default') {
$photo = bin2hex(trim($v));
+ }
}
}
- if($nick)
+ if ($nick) {
$args .= '&nickname=' . $nick;
- elseif($first)
+ }
+ elseif ($first) {
$args .= '&nickname=' . $first;
+ }
- if($photosq)
+ if ($photosq) {
$args .= '&photo=' . $photosq;
- elseif($photo)
+ }
+ elseif ($photo) {
$args .= '&photo=' . $photo;
+ }
$args .= '&openid_url=' . notags(trim($authid));
- goaway($a->get_baseurl() . '/register' . $args);
+ goaway(App::get_baseurl() . '/register' . $args);
// NOTREACHED
}
header("Content-type: application/opensearchdescription+xml");
$o = replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$nodename' => $a->get_hostname(),
));
function ostatus_subscribe_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
goaway($_SESSION['return_url']);
// NOTREACHED
if (get_pconfig($uid, "ostatus", "legacy_friends") == "") {
- if ($_REQUEST["url"] == "")
+ if ($_REQUEST["url"] == "") {
return $o.t("No contact provided.");
+ }
$contact = probe_url($_REQUEST["url"]);
- if (!$contact)
+ if (!$contact) {
return $o.t("Couldn't fetch information for contact.");
+ }
$api = $contact["baseurl"]."/api/";
// Fetching friends
$data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]);
- if (!$data["success"])
+ if (!$data["success"]) {
return $o.t("Couldn't fetch friends for contact.");
+ }
set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]);
}
$total = sizeof($friends);
if ($counter >= $total) {
- $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/settings/connectors">';
+ $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/settings/connectors">';
del_pconfig($uid, "ostatus", "legacy_friends");
del_pconfig($uid, "ostatus", "legacy_contact");
$o .= t("Done");
$data = probe_url($url);
if ($data["network"] == NETWORK_OSTATUS) {
$result = new_contact($uid,$url,true);
- if ($result["success"])
+ if ($result["success"]) {
$o .= " - ".t("success");
- else
+ } else {
$o .= " - ".t("failed");
- } else
+ }
+ } else {
$o .= " - ".t("ignored");
+ }
$o .= "</p>";
$o .= "<p>".t("Keep this window open until done.")."</p>";
- $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/ostatus_subscribe?counter='.$counter.'">';
+ $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/ostatus_subscribe?counter='.$counter.'">';
return $o;
}
);
}
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$res[] = "'" . dbesc($rr['rid']) . "'" ;
}
} else {
intval($page_owner_uid)
);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(datetime_convert()),
dbesc($rr['parent-uri']),
create_tags_from_itemuri($i[0]['uri'], $page_owner_uid);
delete_thread_uri($i[0]['uri'], $page_owner_uid);
- $url = $a->get_baseurl();
+ $url = App::get_baseurl();
$drop_id = intval($i[0]['id']);
if ($i[0]['visible'])
$arr['visible'] = $visibility;
$arr['origin'] = 1;
- $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
- . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
+ $arr['body'] = '[url=' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
+ . '[img]' . App::get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
. '[/url]';
$item_id = item_store($arr);
}
} elseif (strpos($tag,'#') === 0) {
$tagname = substr($tag, 1);
- $str_tags .= '#[url='.$a->get_baseurl()."/search?tag=".$tagname.']'.$tagname.'[/url]';
+ $str_tags .= '#[url='.App::get_baseurl()."/search?tag=".$tagname.']'.$tagname.'[/url]';
}
}
}
$arr['tag'] = $tagged[4];
$arr['inform'] = $tagged[2];
$arr['origin'] = 1;
- $arr['body'] = sprintf( t('%1$s was tagged in %2$s by %3$s'), '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
- $arr['body'] .= "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
+ $arr['body'] = sprintf( t('%1$s was tagged in %2$s by %3$s'), '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
+ $arr['body'] .= "\n\n" . '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . App::get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
$arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
$arr['object'] .= '</link></object>' . "\n";
$arr['target'] = '<target><type>' . ACTIVITY_OBJ_IMAGE . '</type><title>' . $p[0]['desc'] . '</title><id>'
- . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>';
- $arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
+ . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>';
+ $arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . App::get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
$item_id = item_store($arr);
if ($item_id) {
$arr['visible'] = $visible;
$arr['origin'] = 1;
- $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
- . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
+ $arr['body'] = '[url=' . App::get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
+ . '[img]' . App::get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
. '[/url]';
$item_id = item_store($arr);
$intro_count = count($intros1) + count($intros2);
$intros = $intros1 + $intros2;
- $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
+ $myurl = App::get_baseurl() . '/profile/' . $a->user['nickname'] ;
$mails = qu("SELECT `id`, `from-name`, `from-url`, `from-photo`, `created` FROM `mail`
WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
intval(local_user()),
if (dbm::is_result($intros)) {
foreach ($intros as $intro) {
$notif = array(
- 'href' => $a->get_baseurl() . '/notifications/intros/' . $intro['id'],
+ 'href' => App::get_baseurl() . '/notifications/intros/' . $intro['id'],
'name' => $intro['name'],
'url' => $intro['url'],
'photo' => $intro['photo'],
if (dbm::is_result($mails)) {
foreach ($mails as $mail) {
$notif = array(
- 'href' => $a->get_baseurl() . '/message/' . $mail['id'],
+ 'href' => App::get_baseurl() . '/message/' . $mail['id'],
'name' => $mail['from-name'],
'url' => $mail['from-url'],
'photo' => $mail['from-photo'],
if (dbm::is_result($regs)) {
foreach ($regs as $reg) {
$notif = array(
- 'href' => $a->get_baseurl() . '/admin/users/',
+ 'href' => App::get_baseurl() . '/admin/users/',
'name' => $reg['name'],
'url' => $reg['url'],
'photo' => $reg['micro'],
);
}
- $notification["href"] = $a->get_baseurl() . "/notify/view/" . $notification["id"];
+ $notification["href"] = App::get_baseurl() . "/notify/view/" . $notification["id"];
if ($notification["visible"] AND !$notification["spam"] AND
!$notification["deleted"] AND !is_array($result[$notification["parent"]])) {
if(is_array($r)) {
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if (!isset($rr['generation'])) {
if ($global)
$rr['generation'] = 3;
function poke_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$uid = local_user();
$verb = notags(trim($_GET['verb']));
- if(! $verb)
+ if (! $verb) {
return;
+ }
$verbs = get_poke_verbs();
- if(! array_key_exists($verb,$verbs))
+ if (! array_key_exists($verb,$verbs)) {
return;
+ }
$activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]);
$contact_id = intval($_GET['cid']);
- if(! $contact_id)
+ if (! $contact_id) {
return;
+ }
$parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
intval($uid)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
logger('poke: no contact ' . $contact_id);
return;
}
$arr['origin'] = 1;
$arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]';
- $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . $a->get_baseurl() . '/contact/' . $target['id'] . '</id>';
+ $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . App::get_baseurl() . '/contact/' . $target['id'] . '</id>';
$arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $target['url'] . '" />' . "\n");
$arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
$item_id = item_store($arr);
if($item_id) {
//q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
- // dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
+ // dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
// intval($uid),
// intval($item_id)
//);
function poke_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
}
- $base = $a->get_baseurl();
+ $base = App::get_baseurl();
$head_tpl = get_markup_template('poke_head.tpl');
$a->page['htmlhead'] .= replace_macros($head_tpl,array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$base' => $base
));
AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($nickname)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
http_status_exit(500);
+ }
$importer = $r[0];
}
else {
$r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1");
if (dbm::is_result($r)) {
- goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']);
+ goaway(App::get_baseurl() . '/profile/' . $r[0]['nickname']);
}
else {
logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
}
$a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
+ $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . App::get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
- $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
- header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
+ $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . App::get_baseurl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
+ header('Link: <' . App::get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
- foreach($dfrn_pages as $dfrn)
- $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".$a->get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
- $a->page['htmlhead'] .= "<link rel=\"dfrn-poco\" href=\"".$a->get_baseurl()."/poco/{$which}\" />\r\n";
+ foreach ($dfrn_pages as $dfrn) {
+ $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".App::get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
+ }
+ $a->page['htmlhead'] .= "<link rel=\"dfrn-poco\" href=\"".App::get_baseurl()."/poco/{$which}\" />\r\n";
}
$commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false);
$commvisitor = (($commpage && $remote_contact == true) ? true : false);
- $a->page['aside'] .= posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true);
- $a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : ''));
+ $a->page['aside'] .= posted_date_widget(App::get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true);
+ $a->page['aside'] .= categories_widget(App::get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : ''));
if(can_write_wall($a,$a->profile['profile_uid'])) {
function profile_photo_init(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
return;
}
function profile_photo_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice ( t('Permission denied.') . EOL );
return;
}
);
$r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `self` AND `uid` = %d",
- dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
- dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
- dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()),
+ dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
+ dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
+ dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()),
intval(local_user())
);
} else {
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
- dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
- dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
+ dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
+ dbesc(App::get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
intval($_REQUEST['profile']),
intval(local_user())
);
info( t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
// Update global directory in background
- $url = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
- if($url && strlen(get_config('system','directory')))
+ $url = App::get_baseurl() . '/profile/' . $a->user['nickname'];
+ if ($url && strlen(get_config('system','directory'))) {
proc_run(PRIORITY_LOW, "include/directory.php", $url);
+ }
require_once('include/profile_update.php');
profile_change();
notice( t('Unable to process image') . EOL);
}
- goaway($a->get_baseurl() . '/profiles');
+ goaway(App::get_baseurl() . '/profiles');
return; // NOTREACHED
}
if(! function_exists('profile_photo_content')) {
function profile_photo_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL );
return;
}
return;
}
$havescale = false;
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if($rr['scale'] == 5)
$havescale = true;
}
// Update global directory in background
$url = $_SESSION['my_url'];
- if($url && strlen(get_config('system','directory')))
+ if ($url && strlen(get_config('system','directory'))) {
proc_run(PRIORITY_LOW, "include/directory.php", $url);
+ }
- goaway($a->get_baseurl() . '/profiles');
+ goaway(App::get_baseurl() . '/profiles');
return; // NOTREACHED
}
$ph = new Photo($r[0]['data'], $r[0]['type']);
'$submit' => t('Upload'),
'$profiles' => $profiles,
'$form_security_token' => get_form_security_token("profile_photo"),
- '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . $a->get_baseurl() . '">' . t('skip this step') . '</a>' : '<a href="'. $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '">' . t('select a photo from your photo albums') . '</a>')
+ '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . App::get_baseurl() . '">' . t('skip this step') . '</a>' : '<a href="'. App::get_baseurl() . '/photos/' . $a->user['nickname'] . '">' . t('select a photo from your photo albums') . '</a>')
));
return $o;
'$filename' => $filename,
'$profile' => intval($_REQUEST['profile']),
'$resource' => $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'],
- '$image_url' => $a->get_baseurl() . '/photo/' . $filename,
+ '$image_url' => App::get_baseurl() . '/photo/' . $filename,
'$title' => t('Crop Image'),
'$desc' => t('Please adjust the image cropping for optimum viewing.'),
'$form_security_token' => get_form_security_token("profile_photo"),
nav_set_selected('profiles');
- if(! local_user()) {
+ if (! local_user()) {
return;
}
intval($a->argv[2]),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Profile not found.') . EOL);
goaway('profiles');
return; // NOTREACHED
intval($a->argv[1]),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Profile not found.') . EOL);
killme();
return;
function profiles_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
// Update global directory in background
$url = $_SESSION['my_url'];
- if($url && strlen(get_config('system','directory')))
+ if ($url && strlen(get_config('system','directory'))) {
proc_run(PRIORITY_LOW, "include/directory.php", $url);
+ }
require_once('include/profile_update.php');
profile_change();
$arr['deny_gid'] = $a->user['deny_gid'];
$i = item_store($arr);
- if($i)
+ if ($i) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
+ }
}
function profiles_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
intval($a->argv[1]),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Profile not found.') . EOL);
return;
}
$editselect = 'textareas';
$a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => $editselect,
));
$a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), array(
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$editselect' => $editselect,
));
'$lbl_ex2' => t('Example: fishing photography software'),
'$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$profile_id' => $r[0]['id'],
'$profile_name' => array('profile_name', t('Profile Name:'), $r[0]['profile-name'], t('Required'), '*'),
'$is_default' => $is_default,
if (dbm::is_result($r)) {
$tpl = get_markup_template('profile_entry.tpl');
- foreach($r as $rr) {
+
+ $profiles = '';
+ foreach ($r as $rr) {
$profiles .= replace_macros($tpl, array(
- '$photo' => $a->remove_baseurl($rr['thumb']),
- '$id' => $rr['id'],
- '$alt' => t('Profile Image'),
+ '$photo' => $a->remove_baseurl($rr['thumb']),
+ '$id' => $rr['id'],
+ '$alt' => t('Profile Image'),
'$profile_name' => $rr['profile-name'],
- '$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>'
+ '$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>'
: '<a href="'.'profperm/'.$rr['id'].'" />' . t('Edit visibility') . '</a>')
));
}
$tpl_header = get_markup_template('profile_listing_header.tpl');
$o .= replace_macros($tpl_header,array(
- '$header' => t('Edit/Manage Profiles'),
- '$chg_photo' => t('Change profile photo'),
- '$cr_new' => t('Create New Profile'),
+ '$header' => t('Edit/Manage Profiles'),
+ '$chg_photo' => t('Change profile photo'),
+ '$cr_new' => t('Create New Profile'),
'$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
- '$profiles' => $profiles
+ '$profiles' => $profiles
));
}
return $o;
function profperm_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$which = $a->user['nickname'];
$profile = $a->argv[1];
function profperm_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied') . EOL);
return;
}
intval($a->argv[1]),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Invalid profile identifier.') . EOL );
return;
}
}
$valid = true;
+ $r = array();
if (!$direct_cache AND ($cachefile == '')) {
$r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
$mime = 'image/jpeg';
}
}
- } else {
- $r = array();
}
if (!dbm::is_result($r)) {
// Only continue if it isn't a local image and the isn't deactivated
if (proxy_is_local_image($url)) {
- $url = str_replace(normalise_link($a->get_baseurl()) . '/', $a->get_baseurl() . '/', $url);
+ $url = str_replace(normalise_link(App::get_baseurl()) . '/', App::get_baseurl() . '/', $url);
return $url;
}
$longpath .= '.' . $extension;
}
- $proxypath = $a->get_baseurl() . '/proxy/' . $longpath;
+ $proxypath = App::get_baseurl() . '/proxy/' . $longpath;
if ($size != '') {
$size = ':' . $size;
if ((strlen($proxypath) > 250) AND $writemode) {
return $shortpath;
} elseif (strlen($proxypath) > 250) {
- return $a->get_baseurl() . '/proxy/' . $shortpath . '?url=' . urlencode($url);
+ return App::get_baseurl() . '/proxy/' . $shortpath . '?url=' . urlencode($url);
} elseif ($writemode) {
return $longpath;
} else {
}
// links normalised - bug #431
- $baseurl = normalise_link(get_app()->get_baseurl());
+ $baseurl = normalise_link(App::get_baseurl());
$url = normalise_link($url);
return (substr($url, 0, strlen($baseurl)) == $baseurl);
}
}
function proxy_parse_html($html) {
- $a = get_app();
- $html = str_replace(normalise_link($a->get_baseurl()) . '/', $a->get_baseurl() . '/', $html);
+ $html = str_replace(normalise_link(App::get_baseurl()) . '/', App::get_baseurl() . '/', $html);
return preg_replace_callback('/(<img [^>]*src *= *["\'])([^"\']+)(["\'][^>]*>)/siU', 'proxy_img_cb', $html);
}
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($nick)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
logger('pubsub: local account not found: ' . $nick);
hub_return(false, '');
}
intval($contact_id),
intval($owner['uid'])
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
logger('pubsub: contact '.$contact_id.' not found.');
hub_return(false, '');
}
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($nick)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
hub_post_return();
+ }
$importer = $r[0];
dbesc(NETWORK_FEED)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
logger('pubsub: no contact record for "'.$nick.' ('.$contact_id.')" - ignored. '.$xml);
hub_post_return();
}
function qsearch_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
killme();
+ }
$limit = (get_config('system','qsearch_limit') ? intval(get_config('system','qsearch_limit')) : 100);
function randprof_init(&$a) {
require_once('include/Contact.php');
+
$x = random_profile();
- if($x)
+
+ if ($x) {
goaway(zrl($x));
- goaway($a->get_baseurl() . '/profile');
+ }
+
+ goaway(App::get_baseurl() . '/profile');
}
$r = q("SELECT * FROM `user` WHERE `guid` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($guid)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
http_status_exit(500);
+ }
$importer = $r[0];
}
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet );
}
- if(local_user())
- $handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
- if(remote_user())
+ if (local_user()) {
+ $handle = $a->user['nickname'] . '@' . substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3);
+ }
+ if (remote_user()) {
$handle = $_SESSION['handle'];
+ }
- if($url) {
+ if ($url) {
$url = str_replace('{zid}','&zid=' . $handle,$url);
goaway($url);
}
$user = $result['user'];
if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
- $url = $a->get_baseurl() . '/profile/' . $user['nickname'];
+ $url = App::get_baseurl() . '/profile/' . $user['nickname'];
proc_run(PRIORITY_LOW, "include/directory.php", $url);
}
$res = send_register_open_eml(
$user['email'],
$a->config['sitename'],
- $a->get_baseurl(),
+ App::get_baseurl(),
$user['username'],
$result['password']);
'source_name' => $user['username'],
'source_mail' => $user['email'],
'source_nick' => $user['nickname'],
- 'source_link' => $a->get_baseurl()."/admin/users/",
- 'link' => $a->get_baseurl()."/admin/users/",
- 'source_photo' => $a->get_baseurl() . "/photo/avatar/".$user['uid'].".jpg",
+ 'source_link' => App::get_baseurl()."/admin/users/",
+ 'link' => App::get_baseurl()."/admin/users/",
+ 'source_photo' => App::get_baseurl() . "/photo/avatar/".$user['uid'].".jpg",
'to_email' => $admin['email'],
'uid' => $admin['uid'],
'language' => ($admin['language']?$admin['language']:'en'),
intval($user[0]['uid'])
);
if (dbm::is_result($r) && $r[0]['net-publish']) {
- $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
- if($url && strlen(get_config('system','directory')))
+ $url = App::get_baseurl() . '/profile/' . $user[0]['nickname'];
+ if ($url && strlen(get_config('system','directory'))) {
proc_run(PRIORITY_LOW, "include/directory.php", $url);
+ }
}
push_lang($register[0]['language']);
send_register_open_eml(
$user[0]['email'],
$a->config['sitename'],
- $a->get_baseurl(),
+ App::get_baseurl(),
$user[0]['username'],
$register[0]['password']);
$_SESSION['return_url'] = $a->cmd;
- if(! local_user()) {
+ if (! local_user()) {
info( t('Please login.') . EOL);
$o .= '<br /><br />' . login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
return $o;
}
- if((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) {
+ if ((!is_site_admin()) || (x($_SESSION,'submanage') && intval($_SESSION['submanage']))) {
notice( t('Permission denied.') . EOL);
return '';
}
- if($a->argc != 3)
+ if ($a->argc != 3) {
killme();
+ }
$cmd = $a->argv[1];
$hash = $a->argv[2];
- if($cmd === 'deny') {
+ if ($cmd === 'deny') {
user_deny($hash);
- goaway($a->get_baseurl()."/admin/users/");
+ goaway(App::get_baseurl()."/admin/users/");
killme();
}
- if($cmd === 'allow') {
+ if ($cmd === 'allow') {
user_allow($hash);
- goaway($a->get_baseurl()."/admin/users/");
+ goaway(App::get_baseurl()."/admin/users/");
killme();
}
}
function removeme_post(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
- if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
+ if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
return;
+ }
- if((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password']))))
+ if ((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password'])))) {
return;
+ }
- if((! x($_POST,'verify')) || (! strlen(trim($_POST['verify']))))
+ if ((! x($_POST,'verify')) || (! strlen(trim($_POST['verify'])))) {
return;
+ }
- if($_POST['verify'] !== $_SESSION['remove_account_verify'])
+ if ($_POST['verify'] !== $_SESSION['remove_account_verify']) {
return;
+ }
$encrypted = hash('whirlpool',trim($_POST['qxz_password']));
- if((strlen($a->user['password'])) && ($encrypted === $a->user['password'])) {
+ if ((strlen($a->user['password'])) && ($encrypted === $a->user['password'])) {
require_once('include/Contact.php');
user_remove($a->user['uid']);
// NOTREACHED
function removeme_content(&$a) {
- if(! local_user())
+ if (! local_user()) {
goaway(z_root());
+ }
$hash = random_string();
- require_once("mod/settings.php");
- settings_init($a);
+ require_once("mod/settings.php");
+ settings_init($a);
$_SESSION['remove_account_verify'] = $hash;
$tpl = get_markup_template('removeme.tpl');
$o .= replace_macros($tpl, array(
- '$basedir' => $a->get_baseurl(),
+ '$basedir' => App::get_baseurl(),
'$hash' => $hash,
'$title' => t('Remove My Account'),
'$desc' => t('This will completely remove your account. Once this has been done it is not recoverable.'),
function repair_ostatus_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
goaway($_SESSION['return_url']);
// NOTREACHED
$result = new_contact($uid,$r[0]["url"],true);
- $a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL='.$a->get_baseurl().'/repair_ostatus?counter='.$counter.'">';
+ $a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL='.App::get_baseurl().'/repair_ostatus?counter='.$counter.'">';
return $o;
}
<engineName>Friendica</engineName>
<engineLink>http://friendica.com/</engineLink>
<apis>
- <api name="Twitter" preferred="true" apiLink="'.$a->get_baseurl().'/api/" blogID="">
+ <api name="Twitter" preferred="true" apiLink="'.App::get_baseurl().'/api/" blogID="">
<settings>
<docs>http://status.net/wiki/TwitterCompatibleAPI</docs>
<setting name="OAuth">false</setting>
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
dbesc($nick)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
http_status_exit(500);
+ }
$importer = $r[0];
dbesc(normalise_link($author_link)),
intval($importer['uid'])
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
logger('mod-salmon: Author unknown to us.');
if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) {
$result = new_contact($importer['uid'],$author_link);
if (dbm::is_result($r)) {
$saved = array();
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$saved[] = array(
'id' => $rr['id'],
'term' => $rr['term'],
intval(local_user()),
dbesc($search)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
q("INSERT INTO `search` (`uid`,`term`) VALUES ( %d, '%s')",
intval(local_user()),
dbesc($search)
intval($a->pager['start']), intval($a->pager['itemspage']));
}
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
info( t('No results.') . EOL);
return $o;
}
function settings_init(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL );
return;
}
function settings_post(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
- if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
+ if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
return;
+ }
- if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
+ if (count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
$old_page_flags = $a->user['page-flags'];
- if(($a->argc > 1) && ($a->argv[1] === 'oauth') && x($_POST,'remove')){
+ if (($a->argc > 1) && ($a->argv[1] === 'oauth') && x($_POST,'remove')) {
check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
$key = $_POST['remove'];
q("DELETE FROM tokens WHERE id='%s' AND uid=%d",
dbesc($key),
local_user());
- goaway($a->get_baseurl(true)."/settings/oauth/");
+ goaway(App::get_baseurl(true)."/settings/oauth/");
return;
}
- if(($a->argc > 2) && ($a->argv[1] === 'oauth') && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && x($_POST,'submit')) {
+ if (($a->argc > 2) && ($a->argv[1] === 'oauth') && ($a->argv[2] === 'edit'||($a->argv[2] === 'add')) && x($_POST,'submit')) {
check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
local_user());
}
}
- goaway($a->get_baseurl(true)."/settings/oauth/");
+ goaway(App::get_baseurl(true)."/settings/oauth/");
return;
}
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
q("INSERT INTO `mailacct` (`uid`) VALUES (%d)",
intval(local_user())
);
);
}
- if(($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
+ if (($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
// Update global directory in background
$url = $_SESSION['my_url'];
- if($url && strlen(get_config('system','directory')))
+ if ($url && strlen(get_config('system','directory'))) {
proc_run(PRIORITY_LOW, "include/directory.php", $url);
+ }
}
require_once('include/profile_update.php');
update_gcontact_for_user(local_user());
//$_SESSION['theme'] = $theme;
- if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {
+ if ($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {
- // FIXME - set to un-verified, blocked and redirect to logout
- // Why? Are we verifying people or email addresses?
+ /// @TODO set to un-verified, blocked and redirect to logout
+ /// @TODO Why? Are we verifying people or email addresses?
}
$o = '';
nav_set_selected('settings');
- if(! local_user()) {
+ if (! local_user()) {
#notice( t('Permission denied.') . EOL );
return;
}
- if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
+ if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
notice( t('Permission denied.') . EOL );
return;
}
- if(($a->argc > 1) && ($a->argv[1] === 'oauth')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'oauth')) {
- if(($a->argc > 2) && ($a->argv[2] === 'add')) {
+ if (($a->argc > 2) && ($a->argv[2] === 'add')) {
$tpl = get_markup_template("settings_oauth_edit.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_oauth"),
return $o;
}
- if(($a->argc > 3) && ($a->argv[2] === 'edit')) {
+ if (($a->argc > 3) && ($a->argv[2] === 'edit')) {
$r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d",
dbesc($a->argv[3]),
local_user());
$r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
dbesc($a->argv[3]),
local_user());
- goaway($a->get_baseurl(true)."/settings/oauth/");
+ goaway(App::get_baseurl(true)."/settings/oauth/");
return;
}
-
+ /// @TODO validate result with dbm::is_result()
$r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my
FROM clients
LEFT JOIN tokens ON clients.client_id=tokens.client_id
$tpl = get_markup_template("settings_oauth.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_oauth"),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$title' => t('Connected Apps'),
'$add' => t('Add application'),
'$edit' => t('Edit'),
}
- if(($a->argc > 1) && ($a->argv[1] === 'addon')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'addon')) {
$settings_addons = "";
$r = q("SELECT * FROM `hook` WHERE `hook` = 'plugin_settings' ");
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
$settings_addons = t('No Plugin settings configured');
+ }
call_hooks('plugin_settings', $settings_addons);
return $o;
}
- if(($a->argc > 1) && ($a->argv[1] === 'features')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'features')) {
$arr = array();
$features = get_features();
- foreach($features as $fname => $fdata) {
+ foreach ($features as $fname => $fdata) {
$arr[$fname] = array();
$arr[$fname][0] = $fdata[0];
- foreach(array_slice($fdata,1) as $f) {
+ foreach (array_slice($fdata,1) as $f) {
$arr[$fname][1][] = array('feature_' .$f[0],$f[1],((intval(feature_enabled(local_user(),$f[0]))) ? "1" : ''),$f[2],array(t('Off'),t('On')));
}
}
$tpl = get_markup_template("settings_features.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_features"),
- '$title' => t('Additional Features'),
- '$features' => $arr,
- '$submit' => t('Save Settings'),
+ '$title' => t('Additional Features'),
+ '$features' => $arr,
+ '$submit' => t('Save Settings'),
));
return $o;
}
- if(($a->argc > 1) && ($a->argv[1] === 'connectors')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'connectors')) {
$settings_connectors = '<span id="settings_general_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_general_expanded\'); openClose(\'settings_general_inflated\');">';
$settings_connectors .= '<h3 class="connector">'. t('General Social Media Settings').'</h3>';
$settings_connectors .= mini_group_select(local_user(), $default_group, t("Default group for OStatus contacts"));
- if ($legacy_contact != "")
- $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/ostatus_subscribe?url='.urlencode($legacy_contact).'">';
+ /// @TODO Found to much different usage to test empty/non-empty strings (e.g. empty(), trim() == '' ) which is wanted?
+ if ($legacy_contact != "") {
+ $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/ostatus_subscribe?url='.urlencode($legacy_contact).'">';
+ }
$settings_connectors .= '<div id="legacy-contact-wrapper" class="field input">';
$settings_connectors .= '<label id="legacy-contact-label" for="snautofollow-checkbox">'. t('Your legacy GNU Social account'). '</label>';
$settings_connectors .= '<span class="field_help">'.t('If you enter your old GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.').'</span>';
$settings_connectors .= '</div>';
- $settings_connectors .= '<p><a href="'.$a->get_baseurl().'/repair_ostatus">'.t("Repair OStatus subscriptions").'</a></p>';
+ $settings_connectors .= '<p><a href="'.App::get_baseurl().'/repair_ostatus">'.t("Repair OStatus subscriptions").'</a></p>';
$settings_connectors .= '<div class="settings-submit-wrapper" ><input type="submit" name="general-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
local_user()
);
- }
- else {
+ } else {
$r = null;
}
$tpl = get_markup_template("settings_connectors.tpl");
- if(! service_class_allows(local_user(),'email_connect')) {
+ if (! service_class_allows(local_user(),'email_connect')) {
$mail_disabled_message = upgrade_bool_message();
- }
- else {
+ } else {
$mail_disabled_message = (($mail_disabled) ? t('Email access is disabled on this site.') : '');
}
/*
* DISPLAY SETTINGS
*/
- if(($a->argc > 1) && ($a->argv[1] === 'display')) {
+ if (($a->argc > 1) && ($a->argv[1] === 'display')) {
$default_theme = get_config('system','theme');
- if(! $default_theme)
+ if (! $default_theme) {
$default_theme = 'default';
+ }
$default_mobile_theme = get_config('system','mobile-theme');
- if(! $mobile_default_theme)
+ if (! $mobile_default_theme) {
$mobile_default_theme = 'none';
+ }
$allowed_themes_str = get_config('system','allowed_themes');
$allowed_themes_raw = explode(',',$allowed_themes_str);
$allowed_themes = array();
- if(count($allowed_themes_raw))
- foreach($allowed_themes_raw as $x)
- if(strlen(trim($x)) && is_dir("view/theme/$x"))
+ if (count($allowed_themes_raw)) {
+ foreach ($allowed_themes_raw as $x) {
+ if (strlen(trim($x)) && is_dir("view/theme/$x")) {
$allowed_themes[] = trim($x);
+ }
+ }
+ }
$themes = array();
$mobile_themes = array("---" => t('No special theme for mobile devices'));
$files = glob('view/theme/*'); /* */
- if($allowed_themes) {
- foreach($allowed_themes as $th) {
+ if ($allowed_themes) {
+ foreach ($allowed_themes as $th) {
$f = $th;
$is_experimental = file_exists('view/theme/' . $th . '/experimental');
$unsupported = file_exists('view/theme/' . $th . '/unsupported');
$is_mobile = file_exists('view/theme/' . $th . '/mobile');
if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){
$theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
- if($is_mobile) {
+ if ($is_mobile) {
$mobile_themes[$f]=$theme_name;
- }
- else {
+ } else {
$themes[$f]=$theme_name;
}
}
$nowarn_insecure = intval(get_pconfig(local_user(), 'system', 'nowarn_insecure'));
$browser_update = intval(get_pconfig(local_user(), 'system','update_interval'));
- if (intval($browser_update) != -1)
+ if (intval($browser_update) != -1) {
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
+ }
$itemspage_network = intval(get_pconfig(local_user(), 'system','itemspage_network'));
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : 40); // default if not set: 40 items
'$ptitle' => t('Display Settings'),
'$form_security_token' => get_form_security_token("settings_display"),
'$submit' => t('Save Settings'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$uid' => local_user(),
'$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes, true),
$p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
intval(local_user())
);
- if(count($p))
+ if (count($p)) {
$profile = $p[0];
+ }
$username = $a->user['username'];
$email = $a->user['email'];
// nowarn_insecure
- if(! strlen($a->user['timezone']))
+ if (! strlen($a->user['timezone'])) {
$timezone = date_default_timezone_get();
+ }
// Set the account type to "Community" when the page is a community page but the account type doesn't fit
// This is only happening on the first visit after the update
$noid = get_config('system','no_openid');
- if($noid) {
+ if ($noid) {
$openid_field = false;
- }
- else {
+ } else {
$openid_field = array('openid_url', t('OpenID:'),$openid, t("\x28Optional\x29 Allow this OpenID to login to this account."), "", "", "url");
}
-
$opt_tpl = get_markup_template("field_yesno.tpl");
if(get_config('system','publish_all')) {
$profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
- }
- else {
+ } else {
$profile_in_dir = replace_macros($opt_tpl,array(
'$field' => array('profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], '', array(t('No'),t('Yes'))),
));
}
- if(strlen(get_config('system','directory'))) {
+ if (strlen(get_config('system','directory'))) {
$profile_in_net_dir = replace_macros($opt_tpl,array(
'$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))),
));
- }
- else
+ } else {
$profile_in_net_dir = '';
-
+ }
$hide_friends = replace_macros($opt_tpl,array(
'$field' => array('hide-friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', array(t('No'),t('Yes'))),
));
-
$blocktags = replace_macros($opt_tpl,array(
'$field' => array('blocktags', t('Allow friends to tag your posts?'), (intval($a->user['blocktags']) ? '0' : '1'), '', array(t('No'),t('Yes'))),
));
-
$suggestme = replace_macros($opt_tpl,array(
'$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', array(t('No'),t('Yes'))),
));
-
$unkmail = replace_macros($opt_tpl,array(
'$field' => array('unkmail', t('Permit unknown people to send you private mail?'), $unkmail, '', array(t('No'),t('Yes'))),
$invisible = (((! $profile['publish']) && (! $profile['net-publish']))
? true : false);
- if($invisible)
+ if ($invisible) {
info( t('Profile is <strong>not published</strong>.') . EOL );
-
+ }
//$subdir = ((strlen($a->get_path())) ? '<br />' . t('or') . ' ' . 'profile/' . $nickname : '');
$tpl_addr = get_markup_template("settings_nick_set.tpl");
$prof_addr = replace_macros($tpl_addr,array(
- '$desc' => sprintf(t("Your Identity Address is <strong>'%s'</strong> or '%s'."), $nickname.'@'.$a->get_hostname().$a->get_path(), $a->get_baseurl().'/profile/'.$nickname),
+ '$desc' => sprintf(t("Your Identity Address is <strong>'%s'</strong> or '%s'."), $nickname.'@'.$a->get_hostname().$a->get_path(), App::get_baseurl().'/profile/'.$nickname),
'$basepath' => $a->get_hostname()
));
require_once('include/group.php');
$group_select = mini_group_select(local_user(),$a->user['def_gid']);
-
// Private/public post links for the non-JS ACL form
$private_post = 1;
- if($_REQUEST['public'])
+ if ($_REQUEST['public']) {
$private_post = 0;
+ }
$query_str = $a->query_string;
- if(strpos($query_str, 'public=1') !== false)
+ if (strpos($query_str, 'public=1') !== false) {
$query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
+ }
// I think $a->query_string may never have ? in it, but I could be wrong
// It looks like it's from the index.php?q=[etc] rewrite that the web
// server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
- if(strpos($query_str, '?') === false)
+ if (strpos($query_str, '?') === false) {
$public_post_link = '?public=1';
- else
+ } else {
$public_post_link = '&public=1';
+ }
/* Installed langs */
$lang_choices = get_available_languages();
+ /// @TODO Fix indending (or so)
$o .= replace_macros($stpl, array(
'$ptitle' => t('Account Settings'),
'$submit' => t('Save Settings'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$uid' => local_user(),
'$form_security_token' => get_form_security_token("settings"),
'$nickname_block' => $prof_addr,
$starred = 0;
- if(! local_user())
+ if (! local_user()) {
killme();
- if($a->argc > 1)
+ }
+ if ($a->argc > 1) {
$message_id = intval($a->argv[1]);
- if(! $message_id)
+ }
+ if (! $message_id) {
killme();
+ }
- $r = q("SELECT starred FROM item WHERE uid = %d AND id = %d LIMIT 1",
+ $r = q("SELECT `starred` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval(local_user()),
intval($message_id)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
killme();
+ }
- if(! intval($r[0]['starred']))
+ if (! intval($r[0]['starred'])) {
$starred = 1;
+ }
- $r = q("UPDATE item SET starred = %d WHERE uid = %d and id = %d",
+ $r = q("UPDATE `item` SET `starred` = %d WHERE `uid` = %d AND `id` = %d",
intval($starred),
intval(local_user()),
intval($message_id)
// See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
- if($return_path) {
+ if ($return_path) {
$rand = '_=' . time();
- if(strpos($return_path, '?')) $rand = "&$rand";
- else $rand = "?$rand";
+ if (strpos($return_path, '?')) {
+ $rand = "&$rand";
+ } else {
+ $rand = "?$rand";
+ }
- goaway($a->get_baseurl() . "/" . $return_path . $rand);
+ goaway(App::get_baseurl() . "/" . $return_path . $rand);
}
// the json doesn't really matter, it will either be 0 or 1
intval($item['contact-id']),
intval($item['uid'])
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
return;
- if(! $r[0]['self'])
+ }
+ if (! $r[0]['self']) {
$remote_owner = $r[0];
+ }
}
// this represents the post owner on this system.
if (dbm::is_result($r))
$owner = $r[0];
- if(! $owner) {
+ if (! $owner) {
logger('like: no owner');
return;
}
- if(! $remote_owner)
+ if (! $remote_owner)
$remote_owner = $owner;
// This represents the person posting
- if((local_user()) && (local_user() == $owner_uid)) {
+ if ((local_user()) && (local_user() == $owner_uid)) {
$contact = $owner;
}
else {
if (dbm::is_result($r))
$contact = $r[0];
}
- if(! $contact) {
+ if (! $contact) {
return;
}
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
- $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
+ $link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
$body = $item['body'];
$obj = <<< EOT
EOT;
$bodyverb = t('%1$s is following %2$s\'s %3$s');
- if(! isset($bodyverb))
- return;
+ if (! isset($bodyverb)) {
+ return;
+ }
$arr = array();
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
- $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
+ $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
$arr['verb'] = $activity;
$post_id = item_store($arr);
- if(! $item['visible']) {
+ if (! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']),
intval($owner_uid)
function suggest_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
- if(x($_GET,'ignore') && intval($_GET['ignore'])) {
+ if (x($_GET,'ignore') && intval($_GET['ignore'])) {
// Check if we should do HTML-based delete confirmation
- if($_REQUEST['confirm']) {
+ if ($_REQUEST['confirm']) {
// <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs
$query = explode_querystring($a->query_string);
return;
}
// Now check how the user responded to the confirmation query
- if(!$_REQUEST['canceled']) {
+ if (!$_REQUEST['canceled']) {
q("INSERT INTO `gcign` ( `uid`, `gcid` ) VALUES ( %d, %d ) ",
intval(local_user()),
intval($_GET['ignore'])
require_once("mod/proxy.php");
$o = '';
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
- $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
+ $_SESSION['return_url'] = App::get_baseurl() . '/' . $a->cmd;
$a->page['aside'] .= findpeople_widget();
$a->page['aside'] .= follow_widget();
$r = suggestion_query(local_user());
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($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) {
+ foreach ($r as $rr) {
- $connlnk = $a->get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
- $ignlnk = $a->get_baseurl() . '/suggest?ignore=' . $rr['id'];
+ $connlnk = App::get_baseurl() . '/follow/?url=' . (($rr['connect']) ? $rr['connect'] : $rr['url']);
+ $ignlnk = App::get_baseurl() . '/suggest?ignore=' . $rr['id'];
$photo_menu = array(
'profile' => array(t("View Profile"), zrl($rr["url"])),
'follow' => array(t("Connect/Follow"), $connlnk),
$targettype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
$link = xmlify('<link rel="alternate" type="text/html" href="'
- . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
+ . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
$body = xmlify($item['body']);
</target>
EOT;
- $tagid = $a->get_baseurl() . '/search?tag=' . $term;
+ $tagid = App::get_baseurl() . '/search?tag=' . $term;
$objtype = ACTIVITY_OBJ_TAGTERM;
$obj = <<< EOT
$bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s');
- if(! isset($bodyverb))
- return;
+ if (! isset($bodyverb)) {
+ return;
+ }
- $termlink = html_entity_decode('⌗') . '[url=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]';
+ $termlink = html_entity_decode('⌗') . '[url=' . App::get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]';
$arr = array();
$post_id = item_store($arr);
// q("UPDATE `item` set plink = '%s' where id = %d",
-// dbesc($a->get_baseurl() . '/display/' . $owner_nick . '/' . $post_id),
+// dbesc(App::get_baseurl() . '/display/' . $owner_nick . '/' . $post_id),
// intval($post_id)
// );
);
if((! $blocktags) && $t[0]['tcount']==0 ) {
/*q("update item set tag = '%s' where id = %d",
- dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
+ dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($item['id'])
);*/
$term_objtype,
TERM_HASHTAG,
dbesc($term),
- dbesc($a->get_baseurl() . '/search?tag=' . $term),
+ dbesc(App::get_baseurl() . '/search?tag=' . $term),
intval($owner_uid)
);
}
$term_objtype,
TERM_HASHTAG,
dbesc($term),
- dbesc($a->get_baseurl() . '/search?tag=' . $term),
+ dbesc(App::get_baseurl() . '/search?tag=' . $term),
intval($owner_uid)
);
}
/*if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
q("update item set tag = '%s' where id = %d",
- dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
+ dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($r[0]['id'])
);
}*/
function tagrm_post(&$a) {
- if(! local_user())
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
-
+ if (! local_user()) {
+ goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
+ }
- if((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel')))
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ if ((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel'))) {
+ goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
+ }
$tag = ((x($_POST,'tag')) ? hex2bin(notags(trim($_POST['tag']))) : '');
$item = ((x($_POST,'item')) ? intval($_POST['item']) : 0 );
intval(local_user())
);
- if(! dbm::is_result($r))
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ if (! dbm::is_result($r)) {
+ goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
+ }
$arr = explode(',', $r[0]['tag']);
- for($x = 0; $x < count($arr); $x ++) {
- if($arr[$x] === $tag) {
+ for ($x = 0; $x < count($arr); $x ++) {
+ if ($arr[$x] === $tag) {
unset($arr[$x]);
break;
}
);
info( t('Tag removed') . EOL );
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
// NOTREACHED
$o = '';
- if(! local_user()) {
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ if (! local_user()) {
+ goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
// NOTREACHED
}
$item = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- if(! $item) {
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ if (! $item) {
+ goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
// NOTREACHED
}
-
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($item),
intval(local_user())
);
- if(! dbm::is_result($r))
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ if (! dbm::is_result($r)) {
+ goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
+ }
$arr = explode(',', $r[0]['tag']);
- if(! count($arr))
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ if (! count($arr)) {
+ goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
+ }
$o .= '<h3>' . t('Remove Item Tag') . '</h3>';
$o .= '<input type="hidden" name="item" value="' . $item . '" />';
$o .= '<ul>';
-
- foreach($arr as $x) {
+ foreach ($arr as $x) {
$o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . bbcode($x) . '</input></li>';
}
$o .= '</form>';
return $o;
-
+
}
function toggle_mobile_init(&$a) {
- if(isset($_GET['off']))
+ if (isset($_GET['off'])) {
$_SESSION['show-mobile'] = false;
- else
+ } else {
$_SESSION['show-mobile'] = true;
+ }
- if(isset($_GET['address']))
+ if (isset($_GET['address'])) {
$address = $_GET['address'];
- else
- $address = $a->get_baseurl();
+ } else {
+ $address = App::get_baseurl();
+ }
goaway($address);
}
<?php
function uexport_init(&$a){
- if(! local_user())
+ if (! local_user()) {
killme();
+ }
require_once("mod/settings.php");
- settings_init($a);
+ settings_init($a);
}
function uexport_content(&$a){
$tpl = get_markup_template("uexport.tpl");
return replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$title' => t('Export personal data'),
'$options' => $options
));
$output = array(
'version' => FRIENDICA_VERSION,
'schema' => DB_UPDATE_VERSION,
- 'baseurl' => $a->get_baseurl(),
+ 'baseurl' => App::get_baseurl(),
'user' => $user,
'contact' => $contact,
'profile' => $profile,
if($albums_visible) {
$o .= '<div id="sidebar-photos-albums" class="widget">';
- $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
+ $o .= '<h3>' . '<a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
$o .= '<ul>';
foreach($albums as $album) {
$o .= '</ul>';
}
if(local_user() && $a->data['user']['uid'] == local_user()) {
- $o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
+ $o .= '<div id="photo-albums-upload-link"><a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
}
$o .= '</div>';
$tpl = get_markup_template("videos_head.tpl");
$a->page['htmlhead'] .= replace_macros($tpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
));
$tpl = get_markup_template("videos_end.tpl");
$a->page['end'] .= replace_macros($tpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
));
}
$owner_uid = $a->data['user']['uid'];
- if (local_user() != $owner_uid) goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+ if (local_user() != $owner_uid) {
+ goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+ }
- if(($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) {
+ if (($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) {
// Check if we should do HTML-based delete confirmation
if(!x($_REQUEST,'confirm')) {
- if(x($_REQUEST,'canceled')) goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+ if (x($_REQUEST,'canceled')) {
+ goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+ }
$drop_url = $a->query_string;
$a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array(
dbesc($video_id),
intval(local_user())
);
- #echo "<pre>"; var_dump($i); killme();
+ //echo "<pre>"; var_dump($i); killme();
if(count($i)) {
q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(datetime_convert()),
create_tags_from_itemuri($i[0]['uri'], local_user());
delete_thread_uri($i[0]['uri'], local_user());
- $url = $a->get_baseurl();
+ $url = App::get_baseurl();
$drop_id = intval($i[0]['id']);
if($i[0]['visible'])
}
}
- goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+ goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
return; // NOTREACHED
}
- goaway($a->get_baseurl() . '/videos/' . $a->data['user']['nickname']);
+ goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
}
$videos = array();
if (dbm::is_result($r)) {
- foreach($r as $rr) {
- if($a->theme['template_engine'] === 'internal') {
+ foreach ($r as $rr) {
+ if ($a->theme['template_engine'] === 'internal') {
$alt_e = template_escape($rr['filename']);
$name_e = template_escape($rr['album']);
}
$videos[] = array(
'id' => $rr['id'],
- 'link' => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'],
- 'title' => t('View Video'),
- 'src' => $a->get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0',
- 'alt' => $alt_e,
- 'mime' => $rr['filetype'],
- 'album' => array(
- 'link' => $a->get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
+ 'link' => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/video/' . $rr['resource-id'],
+ 'title' => t('View Video'),
+ 'src' => App::get_baseurl() . '/attach/' . $rr['id'] . '?attachment=0',
+ 'alt' => $alt_e,
+ 'mime' => $rr['filetype'],
+ 'album' => array(
+ 'link' => App::get_baseurl() . '/videos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
'name' => $name_e,
'alt' => t('View Album'),
),
$tpl = get_markup_template('videos_recent.tpl');
$o .= replace_macros($tpl, array(
- '$title' => t('Recent Videos'),
- '$can_post' => $can_post,
- '$upload' => array(t('Upload New Videos'), $a->get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'),
- '$videos' => $videos,
- '$delete_url' => (($can_post)?$a->get_baseurl().'/videos/'.$a->data['user']['nickname']:False)
+ '$title' => t('Recent Videos'),
+ '$can_post' => $can_post,
+ '$upload' => array(t('Upload New Videos'), App::get_baseurl().'/videos/'.$a->data['user']['nickname'].'/upload'),
+ '$videos' => $videos,
+ '$delete_url' => (($can_post)?App::get_baseurl().'/videos/'.$a->data['user']['nickname']:False)
));
dbesc($nick)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
return;
+ }
$a->data['user'] = $r[0];
$a->profile_uid = $r[0]['uid'];
$contacts = array();
- foreach($r as $rr) {
- if($rr['self'])
+ foreach ($r as $rr) {
+ /// @TODO This triggers an E_NOTICE if 'self' is not there
+ if ($rr['self']) {
continue;
+ }
$url = $rr['url'];
function viewsrc_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Access denied.') . EOL);
return;
}
$r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
dbesc($nick)
);
- if(! dbm::is_result($r)){
+ if (! dbm::is_result($r)) {
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
killme();
dbesc($hash)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$msg = t('File upload failed.');
if ($r_json) {
echo json_encode(array('error'=>$msg));
dbesc($nick)
);
- if(! dbm::is_result($r)){
+ if (! dbm::is_result($r)) {
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
killme();
$picture["width"] = $r[0]["width"];
$picture["height"] = $r[0]["height"];
$picture["type"] = $r[0]["type"];
- $picture["albumpage"] = $a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash;
- $picture["picture"] = $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
- $picture["preview"] = $a->get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt();
+ $picture["albumpage"] = App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash;
+ $picture["picture"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
+ $picture["preview"] = App::get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt();
if ($r_json) {
echo json_encode(array('picture'=>$picture));
//if we get the signal then return the image url info in BBCODE, otherwise this outputs the info and bails (for the ajax image uploader on wall post)
if ($_REQUEST['hush']!='yeah') {
if(local_user() && (! feature_enabled(local_user(),'richtext') || x($_REQUEST['nomce'])) ) {
- echo "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n";
+ echo "\n\n" . '[url=' . App::get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . App::get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n";
}
else {
- echo '<br /><br /><a href="' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '" ><img src="' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."\" alt=\"$basename\" /></a><br /><br />";
+ echo '<br /><br /><a href="' . App::get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '" ><img src="' . App::get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."\" alt=\"$basename\" /></a><br /><br />";
}
}
else {
- $m = '[url='.$a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.$a->get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]";
+ $m = '[url='.App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.App::get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]";
return($m);
}
/* mod Waitman Gobble NO WARRANTY */
dbesc($recipient)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
logger('wallmessage: no recipient');
return;
}
dbesc($recipient)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('No recipient.') . EOL);
logger('wallmessage: no recipient');
return;
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
dbesc($name)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
killme();
+ }
$salmon_key = salmon_key($r[0]['spubkey']);
$tpl = get_markup_template('xrd_diaspora.tpl');
$dspr = replace_macros($tpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$dspr_guid' => $r[0]['guid'],
'$dspr_key' => base64_encode(pemtorsa($r[0]['pubkey']))
));
$tpl = get_markup_template('xrd_person.tpl');
- $profile_url = $a->get_baseurl().'/profile/'.$r[0]['nickname'];
+ $profile_url = App::get_baseurl().'/profile/'.$r[0]['nickname'];
- if ($acct)
+ if ($acct) {
$alias = $profile_url;
+ }
else {
$alias = 'acct:'.$r[0]['nickname'].'@'.$a->get_hostname();
- if ($a->get_path())
+ if ($a->get_path()) {
$alias .= '/'.$a->get_path();
+ }
}
$o = replace_macros($tpl, array(
'$accturi' => $uri,
'$alias' => $alias,
'$profile_url' => $profile_url,
- '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['nickname'],
- '$atom' => $a->get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'],
- '$zot_post' => $a->get_baseurl() . '/post/' . $r[0]['nickname'],
- '$poco_url' => $a->get_baseurl() . '/poco/' . $r[0]['nickname'],
- '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg',
+ '$hcard_url' => App::get_baseurl() . '/hcard/' . $r[0]['nickname'],
+ '$atom' => App::get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'],
+ '$zot_post' => App::get_baseurl() . '/post/' . $r[0]['nickname'],
+ '$poco_url' => App::get_baseurl() . '/poco/' . $r[0]['nickname'],
+ '$photo' => App::get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg',
'$dspr' => $dspr,
- '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'],
- '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention',
- '$subscribe' => $a->get_baseurl() . '/follow?url={uri}',
+ '$salmon' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'],
+ '$salmen' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention',
+ '$subscribe' => App::get_baseurl() . '/follow?url={uri}',
'$modexp' => 'data:application/magic-public-key,' . $salmon_key,
- '$bigkey' => salmon_key($r[0]['pubkey'])
+ '$bigkey' => salmon_key($r[0]['pubkey']),
));
$ssl_state = ((local_user()) ? true : false);
$this->redirect_url = 'redir/' . $this->get_data_value('cid') ;
- if(get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel())
+ if (get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) {
$this->threaded = true;
+ }
// Prepare the children
- if(count($data['children'])) {
- foreach($data['children'] as $item) {
+ if (count($data['children'])) {
+ foreach ($data['children'] as $item) {
/*
* Only add will be displayed
*/
- if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
+ if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
continue;
- }
- if(! visible_activity($item)) {
+ } elseif (! visible_activity($item)) {
continue;
}
+
$item['pagedrop'] = $data['pagedrop'];
$child = new Item($item);
$this->add_child($child);
$item = $this->get_data();
$edited = false;
if (strcmp($item['created'], $item['edited'])<>0) {
- $edited = array(
- 'label' => t('This entry was edited'),
- 'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'),
- 'relative' => relative_date($item['edited'])
- );
+ $edited = array(
+ 'label' => t('This entry was edited'),
+ 'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'),
+ 'relative' => relative_date($item['edited'])
+ );
}
$commentww = '';
$sparkle = '';
$conv = $this->get_conversation();
-
$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);
$shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false);
- if(local_user() && link_compare($a->contact['url'],$item['author-link'])) {
- if ($item["event-id"] != 0)
+ if (local_user() && link_compare($a->contact['url'],$item['author-link'])) {
+ if ($item["event-id"] != 0) {
$edpost = array("events/event/".$item['event-id'], t("Edit"));
- else
+ } else {
$edpost = array("editpost/".$item['id'], t("Edit"));
- } else
+ }
+ } else {
$edpost = false;
- if(($this->get_data_value('uid') == local_user()) || $this->is_visiting())
+ }
+
+ if (($this->get_data_value('uid') == local_user()) || $this->is_visiting()) {
$dropping = true;
+ }
$drop = array(
'dropping' => $dropping,
'pagedrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $item['pagedrop'] : ''),
- 'select' => t('Select'),
- 'delete' => t('Delete'),
+ 'select' => t('Select'),
+ 'delete' => t('Delete'),
);
$filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false);
$diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
$profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
- if($item['author-link'] && (! $item['author-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')
+ if ($profile_link === 'mailbox') {
$profile_link = '';
- if($sp)
+ }
+
+ if ($sp) {
$sparkle = ' sparkle';
- else
+ } else {
$profile_link = zrl($profile_link);
+ }
if (!isset($item['author-thumb']) OR ($item['author-thumb'] == "")) {
$author_contact = get_contact_details_by_url($item['author-link'], $conv->get_profile_owner());
- if ($author_contact["thumb"])
+ if ($author_contact["thumb"]) {
$item['author-thumb'] = $author_contact["thumb"];
- else
+ } else {
$item['author-thumb'] = $item['author-avatar'];
+ }
}
if (!isset($item['owner-thumb']) OR ($item['owner-thumb'] == "")) {
$owner_contact = get_contact_details_by_url($item['owner-link'], $conv->get_profile_owner());
- if ($owner_contact["thumb"])
+ if ($owner_contact["thumb"]) {
$item['owner-thumb'] = $owner_contact["thumb"];
- else
+ } else {
$item['owner-thumb'] = $item['owner-avatar'];
+ }
}
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
// process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like');
- if(feature_enabled($conv->get_profile_owner(),'dislike'))
+ if (feature_enabled($conv->get_profile_owner(),'dislike')) {
$response_verbs[] = 'dislike';
- if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
+ }
+ if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno';
$response_verbs[] = 'attendmaybe';
- if($conv->is_writable()) {
+ if ($conv->is_writable()) {
$isevent = true;
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
}
$responses = get_responses($conv_responses,$response_verbs,$this,$item);
foreach ($response_verbs as $value=>$verbs) {
- $responses[$verbs][output] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : '');
-
+ $responses[$verbs]['output'] = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : '');
}
/*
*/
$this->check_wall_to_wall();
- if($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url()))
+ if ($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url())) {
$osparkle = ' sparkle';
+ }
- if($this->is_toplevel()) {
- if($conv->get_profile_owner() == local_user()) {
+ if ($this->is_toplevel()) {
+ if ($conv->get_profile_owner() == local_user()) {
$isstarred = (($item['starred']) ? "starred" : "unstarred");
$star = array(
- 'do' => t("add star"),
- 'undo' => t("remove star"),
- 'toggle' => t("toggle star status"),
- 'classdo' => (($item['starred']) ? "hidden" : ""),
+ 'do' => t("add star"),
+ 'undo' => t("remove star"),
+ 'toggle' => t("toggle star status"),
+ 'classdo' => (($item['starred']) ? "hidden" : ""),
'classundo' => (($item['starred']) ? "" : "hidden"),
- 'starred' => t('starred'),
+ 'starred' => t('starred'),
);
$r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1",
intval($item['uid']),
);
if (dbm::is_result($r)) {
$ignore = array(
- 'do' => t("ignore thread"),
- 'undo' => t("unignore thread"),
- 'toggle' => t("toggle ignore status"),
- 'classdo' => (($r[0]['ignored']) ? "hidden" : ""),
+ 'do' => t("ignore thread"),
+ 'undo' => t("unignore thread"),
+ 'toggle' => t("toggle ignore status"),
+ 'classdo' => (($r[0]['ignored']) ? "hidden" : ""),
'classundo' => (($r[0]['ignored']) ? "" : "hidden"),
- 'ignored' => t('ignored'),
+ 'ignored' => t('ignored'),
);
}
$tagger = '';
if(feature_enabled($conv->get_profile_owner(),'commtag')) {
$tagger = array(
- 'add' => t("add tag"),
+ 'add' => t("add tag"),
'class' => "",
);
}
$indent = 'comment';
}
- if($conv->is_writable()) {
+ if ($conv->is_writable()) {
$buttons = array(
'like' => array( t("I like this \x28toggle\x29"), t("like")),
'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''),
);
- if ($shareable) $buttons['share'] = array( t('Share this'), t('share'));
+ if ($shareable) {
+ $buttons['share'] = array( t('Share this'), t('share'));
+ }
}
$comment = $this->get_comment_box($indent);
- if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0){
+ if (strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0){
$shiny = 'shiny';
}
foreach ($languages as $language) {
$langdata = explode(";", $language);
- if ($langstr != "")
+ if ($langstr != "") {
$langstr .= ", ";
+ }
//$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)";
$langstr .= round($langdata[1]*100, 1)."% ".$langdata[0];
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);
+ 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;
+ } 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();
}
$tagger = '';
}
- if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"]))
+ if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"])) {
unset($buttons["like"]);
+ }
- if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"]))
+ if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"])) {
unset($buttons["like"]);
+ }
// Diaspora isn't able to do likes on comments - but red does
if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment') AND
- !Diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"]))
+ !Diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"])) {
unset($buttons["like"]);
+ }
// Diaspora doesn't has multithreaded comments
- if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment'))
+ if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment')) {
unset($comment);
+ }
// Facebook can like comments - but it isn't programmed in the connector yet.
- if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"]))
+ if (($item["item_network"] == NETWORK_FACEBOOK) 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' => urlencode($item['guid']),
- 'isevent' => $isevent,
- 'attend' => $attend,
- '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'), htmlentities($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,
+ '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' => urlencode($item['guid']),
+ 'isevent' => $isevent,
+ 'attend' => $attend,
+ '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'), htmlentities($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' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)),
- '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' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)),
- 'owner_name' => htmlentities($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' => $responses['like']['output'],
- 'dislike' => $responses['dislike']['output'],
- 'responses' => $responses,
- 'switchcomment' => t('Comment'),
- 'comment' => $comment,
- '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'], $profile_link),
+ 'name' => $name_e,
+ 'thumb' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)),
+ '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' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)),
+ 'owner_name' => htmlentities($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' => $responses['like']['output'],
+ 'dislike' => $responses['dislike']['output'],
+ 'responses' => $responses,
+ 'switchcomment' => t('Comment'),
+ 'comment' => $comment,
+ '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'], $profile_link),
);
$arr = array('item' => $item, 'output' => $tmp_item);
$result['children'] = array();
$children = $this->get_children();
$nb_children = count($children);
- if($nb_children > 0) {
- foreach($children as $child) {
+ if ($nb_children > 0) {
+ foreach ($children as $child) {
$result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1);
}
// Collapse
- if(($nb_children > 2) || ($thread_level > 1)) {
+ 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) {
+ if ($thread_level > 1) {
$result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
- }
- else {
+ } 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['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()) {
+ if ($this->is_threaded()) {
$result['flatten'] = false;
$result['threaded'] = true;
- }
- else {
+ } else {
$result['flatten'] = true;
$result['threaded'] = false;
}
/**
* Add a child item
*/
- public function add_child($item) {
+ public function add_child(Item $item) {
$item_id = $item->get_id();
- if(!$item_id) {
+ if (!$item_id) {
logger('[ERROR] Item::add_child : Item has no ID!!', LOGGER_DEBUG);
return false;
- }
- if($this->get_child($item->get_id())) {
+ } elseif ($this->get_child($item->get_id())) {
logger('[WARN] Item::add_child : Item already exists ('. $item->get_id() .').', LOGGER_DEBUG);
return false;
}
/*
* Only add what will be displayed
*/
- if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
+ if ($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
return false;
- }
- if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
+ } elseif (activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
return false;
}
* Get a child by its ID
*/
public function get_child($id) {
- foreach($this->get_children() as $child) {
- if($child->get_id() == $id)
+ foreach ($this->get_children() as $child) {
+ if ($child->get_id() == $id) {
return $child;
+ }
}
return null;
}
*/
public function remove_child($item) {
$id = $item->get_id();
- foreach($this->get_children() as $key => $child) {
- if($child->get_id() == $id) {
+ foreach ($this->get_children() as $key => $child) {
+ if ($child->get_id() == $id) {
$child->remove_parent();
unset($this->children[$key]);
// Reindex the array, in order to make sure there won't be any trouble on loops using count()
$this->conversation = $conv;
// Set it on our children too
- foreach($this->get_children() as $child)
+ foreach ($this->get_children() as $child) {
$child->set_conversation($conv);
+ }
}
/**
* _ false on failure
*/
public function get_data_value($name) {
- if(!isset($this->data[$name])) {
+ if (!isset($this->data[$name])) {
// logger('[ERROR] Item::get_data_value : Item has no value name "'. $name .'".', LOGGER_DEBUG);
return false;
}
* Set template
*/
private function set_template($name) {
- $a = get_app();
-
- if(!x($this->available_templates, $name)) {
+ if (!x($this->available_templates, $name)) {
logger('[ERROR] Item::set_template : Template not available ("'. $name .'").', LOGGER_DEBUG);
return false;
}
private function is_writable() {
$conv = $this->get_conversation();
- if($conv) {
+ if ($conv) {
// This will allow us to comment on wall-to-wall items owned by our friends
// and community forums even if somebody else wrote the post.
// bug #517 - this fixes for conversation owner
- if($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user())
- return true;
+ if ($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user()) {
+ return true;
+ }
// this fixes for visitors
return ($this->writable || ($this->is_visiting() && $conv->get_mode() == 'profile'));
private function count_descendants() {
$children = $this->get_children();
$total = count($children);
- if($total > 0) {
- foreach($children as $child) {
+ if ($total > 0) {
+ foreach ($children as $child) {
$total += $child->count_descendants();
}
}
*/
private function get_comment_box($indent) {
$a = $this->get_app();
- if(!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) {
+ if (!$this->is_toplevel() && !(get_config('system','thread_allow') && $a->theme_thread_allow)) {
return '';
}
$conv = $this->get_conversation();
$template = get_markup_template($this->get_comment_box_template());
$ww = '';
- if( ($conv->get_mode() === 'network') && $this->is_wall_to_wall() )
+ if ( ($conv->get_mode() === 'network') && $this->is_wall_to_wall() )
$ww = 'ww';
- if($conv->is_writable() && $this->is_writable()) {
+ if ($conv->is_writable() && $this->is_writable()) {
$qc = $qcomment = null;
/*
* Hmmm, code depending on the presence of a particular plugin?
* This should be better if done by a hook
*/
- if(in_array('qcomment',$a->plugins)) {
+ if (in_array('qcomment',$a->plugins)) {
$qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
$qcomment = (($qc) ? explode("\n",$qc) : null);
}
$comment_box = replace_macros($template,array(
'$return_path' => $a->query_string,
- '$threaded' => $this->is_threaded(),
-// '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
- '$jsreload' => '',
- '$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'),
- '$id' => $this->get_id(),
- '$parent' => $this->get_id(),
- '$qcomment' => $qcomment,
+ '$threaded' => $this->is_threaded(),
+// '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
+ '$jsreload' => '',
+ '$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'),
+ '$id' => $this->get_id(),
+ '$parent' => $this->get_id(),
+ '$qcomment' => $qcomment,
'$profile_uid' => $conv->get_profile_owner(),
- '$mylink' => $a->remove_baseurl($a->contact['url']),
- '$mytitle' => t('This is you'),
- '$myphoto' => $a->remove_baseurl($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' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''),
- '$indent' => $indent,
- '$sourceapp' => t($a->sourcename),
- '$ww' => (($conv->get_mode() === 'network') ? $ww : ''),
- '$rand_num' => random_digits(12)
+ '$mylink' => $a->remove_baseurl($a->contact['url']),
+ '$mytitle' => t('This is you'),
+ '$myphoto' => $a->remove_baseurl($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' => ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''),
+ '$indent' => $indent,
+ '$sourceapp' => t($a->sourcename),
+ '$ww' => (($conv->get_mode() === 'network') ? $ww : ''),
+ '$rand_num' => random_digits(12)
));
}
$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')) {
+ } elseif($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)) {
+ 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.
$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')))
+ 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
+ } else {
$this->owner_url = zrl($this->get_data_value('owner-link'));
+ }
}
}
}
}
- if(!$this->wall_to_wall) {
+ if (!$this->wall_to_wall) {
$this->set_template('wall');
$this->owner_url = '';
$this->owner_photo = '';
return $this->visiting;
}
-
-
-
}
+/// @TODO These are discouraged and should be removed:
?>
$r = q("SELECT * FROM `user` WHERE `spubkey` = '' ");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$sres=openssl_pkey_new(array('encrypt_key' => false ));
$sprvkey = '';
openssl_pkey_export($sres, $sprvkey);
q("ALTER TABLE `contact` ADD `nick` CHAR( 255 ) NOT NULL AFTER `name` ");
$r = q("SELECT * FROM `contact` WHERE 1");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d",
dbesc(basename($rr['url'])),
intval($rr['id'])
q("ALTER TABLE `contact` ADD `micro` TEXT NOT NULL AFTER `thumb` ");
$r = q("SELECT * FROM `photo` WHERE `scale` = 4");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$ph = new Photo($rr['data']);
if($ph->is_valid()) {
$ph->scaleImage(48);
}
$r = q("SELECT * FROM `contact` WHERE 1");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if(stristr($rr['thumb'],'avatar'))
q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
dbesc(str_replace('avatar','micro',$rr['thumb'])),
// Repair any bad links that slipped into the item table
$r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
if($r && dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if(strstr($rr['object'],'type="http')) {
q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
dbesc(str_replace('type="http','href="http',$rr['object'])),
$r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
dbesc(str_replace('include/photo','photo',$rr['photo'])),
dbesc(str_replace('include/photo','photo',$rr['thumb'])),
q("ALTER TABLE `user` ADD `guid` CHAR( 16 ) NOT NULL AFTER `uid` ");
$r = q("SELECT `uid` FROM `user` WHERE 1");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$found = true;
do {
$guid = substr(random_string(),0,16);
return;
$r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$guid = get_guid();
q("update `photo` set `guid` = '%s' where `resource-id` = '%s'",
dbesc($guid),
$r = q("SELECT `id` FROM `item` WHERE `parent` = `id` ");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
intval($rr['id'])
);
$r = q("select id, url from contact where url != '' and nurl = '' ");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
q("update contact set nurl = '%s' where id = %d",
dbesc(normalise_link($rr['url'])),
intval($rr['id'])
$r = q("select * from config where 1 order by id desc");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$found = false;
foreach($arr as $x) {
if($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
$arr = array();
$r = q("select * from pconfig where 1 order by id desc");
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$found = false;
foreach($arr as $x) {
if($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
<html itemscope itemtype="http://schema.org/Blog" lang="<?php echo $lang; ?>">\r
<head>\r
<title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
- <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>\r
+ <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
<?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
</head>\r
<body>\r
<html>\r
<head>\r
<title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
- <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>\r
+ <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
<?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
</head>\r
<body>\r
function theme_content(&$a){
- if(!local_user())
- return;
+ if (!local_user()) {
+ return;
+ }
- $colorset = get_pconfig( local_user(), 'duepuntozero', 'colorset');
- $user = true;
+ $colorset = get_pconfig( local_user(), 'duepuntozero', 'colorset');
+ $user = true;
- return clean_form($a, $colorset, $user);
+ return clean_form($a, $colorset, $user);
}
function theme_post(&$a){
- if(! local_user())
- return;
-
- if (isset($_POST['duepuntozero-settings-submit'])){
- set_pconfig(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
- }
+
+ if (! local_user()) {
+ return;
+ }
+
+ if (isset($_POST['duepuntozero-settings-submit'])){
+ set_pconfig(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
+ }
}
function theme_admin(&$a){
- $colorset = get_config( 'duepuntozero', 'colorset');
- $user = false;
+ $colorset = get_config( 'duepuntozero', 'colorset');
+ $user = false;
- return clean_form($a, $colorset, $user);
+ return clean_form($a, $colorset, $user);
}
function theme_admin_post(&$a){
- if (isset($_POST['duepuntozero-settings-submit'])){
- set_config('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
- }
+ if (isset($_POST['duepuntozero-settings-submit'])){
+ set_config('duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
+ }
}
-
+/// @TODO $a is no longer used
function clean_form(&$a, &$colorset, $user){
- $colorset = array(
- 'default'=>t('default'),
- 'greenzero'=>t('greenzero'),
- 'purplezero'=>t('purplezero'),
- 'easterbunny'=>t('easterbunny'),
- 'darkzero'=>t('darkzero'),
- 'comix'=>t('comix'),
- 'slackr'=>t('slackr'),
- );
- if ($user) {
- $color = get_pconfig(local_user(), 'duepuntozero', 'colorset');
- } else {
- $color = get_config( 'duepuntozero', 'colorset');
- }
- $t = get_markup_template("theme_settings.tpl" );
- $o .= replace_macros($t, array(
- '$submit' => t('Submit'),
- '$baseurl' => $a->get_baseurl(),
- '$title' => t("Theme settings"),
- '$colorset' => array('duepuntozero_colorset', t('Variations'), $color, '', $colorset),
- ));
- return $o;
+ $colorset = array(
+ 'default'=>t('default'),
+ 'greenzero'=>t('greenzero'),
+ 'purplezero'=>t('purplezero'),
+ 'easterbunny'=>t('easterbunny'),
+ 'darkzero'=>t('darkzero'),
+ 'comix'=>t('comix'),
+ 'slackr'=>t('slackr'),
+ );
+
+ if ($user) {
+ $color = get_pconfig(local_user(), 'duepuntozero', 'colorset');
+ } else {
+ $color = get_config( 'duepuntozero', 'colorset');
+ }
+
+ $t = get_markup_template("theme_settings.tpl" );
+ /// @TODO No need for adding string here, $o is not defined
+ $o .= replace_macros($t, array(
+ '$submit' => t('Submit'),
+ '$baseurl' => App::get_baseurl(),
+ '$title'=> t("Theme settings"),
+ '$colorset' => array('duepuntozero_colorset', t('Variations'), $color, '', $colorset),
+ ));
+
+ return $o;
}
require_once('view/theme/frio/php/Image.php');
function theme_content(&$a) {
- if(!local_user()) { return;}
+ if (!local_user()) {
+ return;
+ }
$arr = array();
$arr["schema"] = get_pconfig(local_user(),'frio', 'schema');
}
function theme_post(&$a) {
- if(!local_user()) { return;}
+ if (!local_user()) {
+ return;
+ }
+
if (isset($_POST['frio-settings-submit'])) {
set_pconfig(local_user(), 'frio', 'schema', $_POST["frio_schema"]);
set_pconfig(local_user(), 'frio', 'nav_bg', $_POST["frio_nav_bg"]);
$t = get_markup_template('theme_settings.tpl');
$o .= replace_macros($t, array(
'$submit' => t('Submit'),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$title' => t("Theme settings"),
'$schema' => array('frio_schema', t("Select scheme"), $arr["schema"], '', $scheme_choices),
'$nav_bg' => array_key_exists("nav_bg", $disable) ? "" : array('frio_nav_bg', t('Navigation bar background color'), $arr['nav_bg']),
<head>
<title><?php if(x($page,'title')) echo $page['title'] ?></title>
<meta request="<?php echo htmlspecialchars($_REQUEST['pagename']) ?> ">
- <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>
+ <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
<script>var frio="<?php echo "view/theme/frio"; ?>";</script>
- <?php $baseurl = $a->get_baseurl(); ?>
+ <?php $baseurl = App::get_baseurl(); ?>
<?php $frio = "view/theme/frio"; ?>
<?php
// Because we use minimal for modals the header and the included js stuff should be only loaded
<title><?php if(x($page,'title')) echo $page['title'] ?></title>
<meta name="viewport" content="initial-scale=1.0">
<meta request="<?php echo htmlspecialchars($_REQUEST['pagename']) ?> ">
- <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>
+ <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
<script>var frio="<?php echo "view/theme/frio"; ?>";</script>
- <?php $baseurl = $a->get_baseurl(); ?>
+ <?php $baseurl = App::get_baseurl(); ?>
<?php $frio = "view/theme/frio"; ?>
<?php if(x($page,'htmlhead')) echo $page['htmlhead']; ?>
set_template_engine($a, 'smarty3');
- $baseurl = $a->get_baseurl();
+ $baseurl = App::get_baseurl();
$style = get_pconfig(local_user(), 'frio', 'style');
* We use this to give the data to textcomplete and have a filter function at the
* contact page.
*
- * @param App $a The app data
+ * @param App $a The app data @TODO Unused
* @param array $results The array with the originals from acl_lookup()
*/
function frio_acl_lookup($a, &$results) {
// we introduce a new search type, r should do the same query like it's
// done in /mod/contacts for connections
- if($results["type"] == "r") {
+ if ($results["type"] == "r") {
$searching = false;
- if($search) {
+ if ($search) {
$search_hdr = $search;
$search_txt = dbesc(protect_sprintf(preg_quote($search)));
$searching = true;
}
$sql_extra .= (($searching) ? " AND (`attag` LIKE '%%".dbesc($search_txt)."%%' OR `name` LIKE '%%".dbesc($search_txt)."%%' OR `nick` LIKE '%%".dbesc($search_txt)."%%') " : "");
- if($nets)
+ if ($nets) {
$sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
+ }
$sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
$contacts = array();
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$contacts[] = _contact_detail_for_template($rr);
}
}
<html lang="<?php echo $lang; ?>">\r
<head>\r
<title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
- <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>\r
+ <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
<?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
</head>\r
<body <?php if($a->module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>>\r
// I could do this in style.php, but by having the CSS in a file the browser will cache it,
// making pages load faster
- if( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) {
-// $a->page['htmlhead'] = str_replace('$stylesheet', $a->get_baseurl() . '/view/theme/frost-mobile/login-style.css', $a->page['htmlhead']);
- $a->theme['stylesheet'] = $a->get_baseurl() . '/view/theme/frost-mobile/login-style.css';
+ if ( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) {
+// $a->page['htmlhead'] = str_replace('$stylesheet', App::get_baseurl() . '/view/theme/frost-mobile/login-style.css', $a->page['htmlhead']);
+ $a->theme['stylesheet'] = App::get_baseurl() . '/view/theme/frost-mobile/login-style.css';
}
- if( $a->module === 'login' )
+
+ if ( $a->module === 'login' ) {
$a->page['end'] .= '<script type="text/javascript"> $(document).ready(function() { $("#id_" + window.loginName).focus();} );</script>';
+ }
}
<html lang="<?php echo $lang; ?>">\r
<head>\r
<title><?php if(x($page,'title')) echo $page['title'] ?></title>\r
- <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>\r
+ <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>\r
<?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>\r
</head>\r
<body <?php if($a->module === 'home') echo 'onLoad="setTimeout(\'homeRedirect()\', 1500)"'?>>\r
// I could do this in style.php, but by having the CSS in a file the browser will cache it,
// making pages load faster
if( $a->module === 'home' || $a->module === 'login' || $a->module === 'register' || $a->module === 'lostpass' ) {
- //$a->page['htmlhead'] = str_replace('$stylesheet', $a->get_baseurl() . '/view/theme/frost/login-style.css', $a->page['htmlhead']);
- $a->theme['stylesheet'] = $a->get_baseurl() . '/view/theme/frost/login-style.css';
+ //$a->page['htmlhead'] = str_replace('$stylesheet', App::get_baseurl() . '/view/theme/frost/login-style.css', $a->page['htmlhead']);
+ $a->theme['stylesheet'] = App::get_baseurl() . '/view/theme/frost/login-style.css';
}
- if( $a->module === 'login' )
+
+ if ( $a->module === 'login' ) {
$a->page['end'] .= '<script type="text/javascript"> $(document).ready(function() { $("#id_" + window.loginName).focus();} );</script>';
+ }
}
function theme_content(&$a){
- if(!local_user())
- return;
-
+ if (!local_user()) {
+ return;
+ }
+
$align = get_pconfig(local_user(), 'quattro', 'align' );
$color = get_pconfig(local_user(), 'quattro', 'color' );
- $tfs = get_pconfig(local_user(),"quattro","tfs");
- $pfs = get_pconfig(local_user(),"quattro","pfs");
-
+ $tfs = get_pconfig(local_user(),"quattro","tfs");
+ $pfs = get_pconfig(local_user(),"quattro","pfs");
+
return quattro_form($a,$align, $color, $tfs, $pfs);
}
function theme_post(&$a){
- if(! local_user())
+ if (! local_user()) {
return;
-
+ }
+
if (isset($_POST['quattro-settings-submit'])){
set_pconfig(local_user(), 'quattro', 'align', $_POST['quattro_align']);
set_pconfig(local_user(), 'quattro', 'color', $_POST['quattro_color']);
}
}
-
+/// @TODO $a is no longer used here
function quattro_form(&$a, $align, $color, $tfs, $pfs){
$colors = array(
"dark"=>"Quattro",
$t = get_markup_template("theme_settings.tpl" );
$o .= replace_macros($t, array(
'$submit' => t('Submit'),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$title' => t("Theme settings"),
'$align' => array('quattro_align', t('Alignment'), $align, '', array('left'=>t('Left'), 'center'=>t('Center'))),
'$color' => array('quattro_color', t('Color scheme'), $color, '', $colors),
*/
function quattro_init(&$a) {
- $a->page['htmlhead'] .= '<script src="'.$a->get_baseurl().'/view/theme/quattro/tinycon.min.js"></script>';
- $a->page['htmlhead'] .= '<script src="'.$a->get_baseurl().'/view/theme/quattro/js/quattro.js"></script>';;
+ $a->page['htmlhead'] .= '<script src="'.App::get_baseurl().'/view/theme/quattro/tinycon.min.js"></script>';
+ $a->page['htmlhead'] .= '<script src="'.App::get_baseurl().'/view/theme/quattro/js/quattro.js"></script>';;
}
<html>
<head>
<title><?php if(x($page,'title')) echo $page['title'] ?></title>
- <script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>
+ <script>var baseurl="<?php echo App::get_baseurl() ?>";</script>
<script type="text/javascript">
function ScrollToBottom(){
window.scrollTo(0,document.body.scrollHeight);
$cssFile = null;
$ssl_state = null;
- $baseurl = $a->get_baseurl($ssl_state);
+ $baseurl = App::get_baseurl($ssl_state);
$a->page['htmlhead'] .= <<< EOT
<script>
*/
$a = get_app();
$ssl_state = null;
- $baseurl = $a->get_baseurl($ssl_state);
+ $baseurl = App::get_baseurl($ssl_state);
$bottom['$baseurl'] = $baseurl;
$tpl = get_markup_template('bottom.tpl');
function theme_content(&$a){
- if(!local_user())
+ if (!local_user()) {
return;
+ }
- if (!function_exists('get_vier_config'))
+ if (!function_exists('get_vier_config')) {
return;
+ }
$style = get_pconfig(local_user(), 'vier', 'style');
- if ($style == "")
+ if ($style == "") {
$style = get_config('vier', 'style');
+ }
- if ($style == "")
+ if ($style == "") {
$style = "plus";
+ }
$show_pages = get_vier_config('show_pages', true);
$show_profiles = get_vier_config('show_profiles', true);
}
function theme_post(&$a){
- if(! local_user())
+ if (! local_user()) {
return;
+ }
if (isset($_POST['vier-settings-submit'])){
set_pconfig(local_user(), 'vier', 'style', $_POST['vier_style']);
}
}
-
+/// @TODO $a is no longer used
function vier_form(&$a, $style, $show_pages, $show_profiles, $show_helpers, $show_services, $show_friends, $show_lastusers){
$styles = array(
"plus"=>"Plus",
$t = get_markup_template("theme_settings.tpl");
$o .= replace_macros($t, array(
'$submit' => t('Submit'),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$title' => t("Theme settings"),
'$style' => array('vier_style',t ('Set style'),$style,'',$styles),
'$show_pages' => array('vier_show_pages', t('Community Pages'), $show_pages, '', $show_or_not),
$show_lastusers = get_vier_config("show_lastusers", 1);
//get_baseurl
- $url = $a->get_baseurl($ssl_state);
+ $url = App::get_baseurl($ssl_state);
$aside['$url'] = $url;
// comunity_profiles
$aside['$comunity_profiles_title'] = t('Community Profiles');
$aside['$comunity_profiles_items'] = array();
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$entry = replace_macros($tpl,array(
'$id' => $rr['id'],
//'$profile_link' => zrl($rr['url']),
$aside['$lastusers_title'] = t('Last users');
$aside['$lastusers_items'] = array();
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
$entry = replace_macros($tpl,array(
'$id' => $rr['id'],
$aside['$helpers_items'] = array();
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$entry = replace_macros($tpl,array(
'$url' => $rr['url'],
'$title' => $rr['name'],
//connectable services
if ($show_services) {
+ /// @TODO This whole thing is hard-coded, better rewrite to Intercepting Filter Pattern (future-todo)
$r = array();
- if (plugin_enabled("appnet"))
+ if (plugin_enabled("appnet")) {
$r[] = array("photo" => "images/appnet.png", "name" => "App.net");
+ }
- if (plugin_enabled("buffer"))
+ if (plugin_enabled("buffer")) {
$r[] = array("photo" => "images/buffer.png", "name" => "Buffer");
+ }
- if (plugin_enabled("blogger"))
+ if (plugin_enabled("blogger")) {
$r[] = array("photo" => "images/blogger.png", "name" => "Blogger");
+ }
- if (plugin_enabled("dwpost"))
+ if (plugin_enabled("dwpost")) {
$r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth");
+ }
- if (plugin_enabled("fbpost"))
+ if (plugin_enabled("fbpost")) {
$r[] = array("photo" => "images/facebook.png", "name" => "Facebook");
+ }
- if (plugin_enabled("ifttt"))
+ if (plugin_enabled("ifttt")) {
$r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT");
+ }
- if (plugin_enabled("statusnet"))
+ if (plugin_enabled("statusnet")) {
$r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social");
+ }
- if (plugin_enabled("gpluspost"))
+ if (plugin_enabled("gpluspost")) {
$r[] = array("photo" => "images/googleplus.png", "name" => "Google+");
+ }
- //if (plugin_enabled("ijpost"))
+ //if (plugin_enabled("ijpost")) {
// $r[] = array("photo" => "images/", "name" => "");
+ //}
- if (plugin_enabled("libertree"))
+ if (plugin_enabled("libertree")) {
$r[] = array("photo" => "images/libertree.png", "name" => "Libertree");
+ }
- //if (plugin_enabled("ljpost"))
+ //if (plugin_enabled("ljpost")) {
// $r[] = array("photo" => "images/", "name" => "");
+ //}
- if (plugin_enabled("pumpio"))
+ if (plugin_enabled("pumpio")) {
$r[] = array("photo" => "images/pumpio.png", "name" => "pump.io");
+ }
- if (plugin_enabled("tumblr"))
+ if (plugin_enabled("tumblr")) {
$r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr");
+ }
- if (plugin_enabled("twitter"))
+ if (plugin_enabled("twitter")) {
$r[] = array("photo" => "images/twitter.png", "name" => "Twitter");
+ }
- if (plugin_enabled("wppost"))
+ 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"))
+ 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');
$con_services['title'] = Array("", t('Connect Services'), "", "");
$aside['$con_services'] = $con_services;
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$entry = replace_macros($tpl,array(
'$url' => $url,
'$photo' => $rr['photo'],