') !== false && $item['coord']) {
$x = generate_map(trim($item['coord']));
- if($x) {
+ if ($x) {
$s = preg_replace('/\
/','$0' . $x,$s);
}
}
@@ -1717,7 +1717,7 @@ function bb_translate_video($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);
@@ -2000,8 +2000,9 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
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'])),
@@ -2020,11 +2021,11 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
//$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;
}
diff --git a/include/threads.php b/include/threads.php
index 48391174e..c214cf264 100644
--- a/include/threads.php
+++ b/include/threads.php
@@ -267,12 +267,10 @@ function update_threads() {
}
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')))",
diff --git a/include/uimport.php b/include/uimport.php
index 51672d92b..0d9ffc35f 100644
--- a/include/uimport.php
+++ b/include/uimport.php
@@ -133,7 +133,7 @@ function import_account(&$a, $file) {
}
$oldbaseurl = $account['baseurl'];
- $newbaseurl = $a->get_baseurl();
+ $newbaseurl = App::get_baseurl();
$olduid = $account['user']['uid'];
unset($account['user']['uid']);
@@ -290,5 +290,5 @@ function import_account(&$a, $file) {
proc_run(PRIORITY_HIGH, 'include/notifier.php', 'relocate', $newuid);
info(t("Done. You can now login with your username and password"));
- goaway($a->get_baseurl() . "/login");
+ goaway(App::get_baseurl() . "/login");
}
diff --git a/include/user.php b/include/user.php
index ec15d5b13..983c4a416 100644
--- a/include/user.php
+++ b/include/user.php
@@ -216,7 +216,7 @@ function create_user($arr) {
dbesc($default_service_class)
);
- if($r) {
+ if ($r) {
$r = q("SELECT * FROM `user`
WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
dbesc($username),
diff --git a/index.php b/index.php
index 08f24af60..f05151757 100644
--- a/index.php
+++ b/index.php
@@ -60,15 +60,15 @@ if(!$install) {
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();
}
@@ -150,24 +150,28 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) {
*
*/
-// 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
@@ -177,11 +181,11 @@ if(! x($_SESSION,'sysmsg_info'))
// 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);
@@ -191,8 +195,7 @@ nav_set_selected('nothing');
//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);
@@ -238,9 +241,9 @@ if(strlen($a->module)) {
$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 {
@@ -254,7 +257,7 @@ if(strlen($a->module)) {
* 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;
}
@@ -272,16 +275,16 @@ if(strlen($a->module)) {
*
*/
- 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);
@@ -304,11 +307,13 @@ if (file_exists($theme_info_file)){
/* 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
diff --git a/mod/admin.php b/mod/admin.php
index cf0d8d9ac..72412f69b 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -32,13 +32,12 @@ function admin_post(&$a){
// 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);
@@ -134,8 +133,9 @@ function admin_content(&$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")) {
@@ -376,7 +376,7 @@ function admin_page_federation(&$a) {
'$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(),
));
}
@@ -489,7 +489,7 @@ function admin_page_summary(&$a) {
'$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'),
@@ -527,7 +527,7 @@ function admin_page_site_post(&$a) {
* 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));
@@ -961,7 +961,7 @@ function admin_page_site(&$a) {
'$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'], ""),
@@ -1043,7 +1043,7 @@ function admin_page_site(&$a) {
'$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("
Embedly is used to fetch additional data for web pages. This is an optional parameter.")),
@@ -1122,26 +1122,26 @@ function admin_page_dbsync(&$a) {
$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
));
}
@@ -1156,11 +1156,11 @@ function admin_page_dbsync(&$a) {
* @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');
@@ -1205,7 +1205,7 @@ function admin_page_users_post(&$a){
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",
@@ -1430,7 +1430,7 @@ function admin_page_users(&$a){
'$form_security_token' => get_form_security_token("admin_users"),
// values //
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$pending' => $pending,
'deleted' => $deleted,
@@ -1522,7 +1522,7 @@ function admin_page_plugins(&$a){
'$page' => t('Plugins'),
'$toggle' => t('Toggle'),
'$settings' => t('Settings'),
- '$baseurl' => $a->get_baseurl(true),
+ '$baseurl' => App::get_baseurl(true),
'$plugin' => $plugin,
'$status' => $status,
@@ -1546,32 +1546,35 @@ function admin_page_plugins(&$a){
* 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);
+ }
}
}
}
@@ -1582,7 +1585,7 @@ function admin_page_plugins(&$a){
'$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),
@@ -1780,7 +1783,7 @@ function admin_page_themes(&$a){
'$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,
@@ -1798,18 +1801,18 @@ function admin_page_themes(&$a){
// 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');
}
/*
@@ -1817,7 +1820,7 @@ function admin_page_themes(&$a){
*/
$xthemes = array();
- if($themes) {
+ if ($themes) {
foreach($themes as $th) {
$xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
}
@@ -1826,17 +1829,17 @@ function admin_page_themes(&$a){
$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'),'
/view/themes
'),
- '$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'),'
/view/themes
'),
+ '$experimental' => t('[Experimental]'),
+ '$unsupported' => t('[Unsupported]'),
'$form_security_token' => get_form_security_token("admin_themes"),
));
}
@@ -1904,7 +1907,7 @@ function admin_page_logs(&$a){
'$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...
diff --git a/mod/allfriends.php b/mod/allfriends.php
index 240aa524b..d7f4073b7 100644
--- a/mod/allfriends.php
+++ b/mod/allfriends.php
@@ -8,16 +8,18 @@ require_once('mod/contacts.php');
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];
@@ -26,8 +28,9 @@ function allfriends_content(&$a) {
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"]));
@@ -39,14 +42,14 @@ function allfriends_content(&$a) {
$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);
@@ -60,7 +63,7 @@ function allfriends_content(&$a) {
$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)
diff --git a/mod/api.php b/mod/api.php
index 406ef26c1..caa1cba2a 100644
--- a/mod/api.php
+++ b/mod/api.php
@@ -22,7 +22,7 @@ function oauth_get_client($request){
function api_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -84,7 +84,7 @@ function api_content(&$a) {
}
- 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());
diff --git a/mod/attach.php b/mod/attach.php
index 274acfc2b..94cb75a38 100644
--- a/mod/attach.php
+++ b/mod/attach.php
@@ -16,7 +16,7 @@ function attach_init(&$a) {
$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;
}
@@ -29,7 +29,7 @@ function attach_init(&$a) {
dbesc($item_id)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Permission denied.') . EOL);
return;
}
diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php
index be8645c1f..86a73a788 100644
--- a/mod/bookmarklet.php
+++ b/mod/bookmarklet.php
@@ -8,14 +8,14 @@ function bookmarklet_init(&$a) {
}
function bookmarklet_content(&$a) {
- if(!local_user()) {
+ if (!local_user()) {
$o = '
'.t('Login').' ';
$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"]);
diff --git a/mod/cal.php b/mod/cal.php
index ba4339328..d49e8f764 100644
--- a/mod/cal.php
+++ b/mod/cal.php
@@ -80,7 +80,7 @@ function cal_content(&$a) {
$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,
@@ -89,7 +89,7 @@ function cal_content(&$a) {
$etpl = get_markup_template('event_end.tpl');
$a->page['end'] .= replace_macros($etpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$editselect' => $editselect
));
@@ -229,10 +229,11 @@ function cal_content(&$a) {
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;
+ }
}
}
@@ -270,12 +271,12 @@ function cal_content(&$a) {
}
$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,
diff --git a/mod/common.php b/mod/common.php
index 9f9379be5..9657ac36d 100644
--- a/mod/common.php
+++ b/mod/common.php
@@ -19,23 +19,27 @@ function common_content(&$a) {
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']),
@@ -43,8 +47,9 @@ function common_content(&$a) {
'url' => 'contacts/' . $cid
));
- if(! x($a->page,'aside'))
+ if (! x($a->page,'aside')) {
$a->page['aside'] = '';
+ }
$a->page['aside'] .= $vcard_widget;
}
@@ -69,75 +74,77 @@ function common_content(&$a) {
}
}
-
-
- 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),
));
diff --git a/mod/community.php b/mod/community.php
index 40d4016f3..d7fd2bb93 100644
--- a/mod/community.php
+++ b/mod/community.php
@@ -1,7 +1,7 @@
pager['start'], $a->pager['itemspage']);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
info( t('No results.') . EOL);
return $o;
}
diff --git a/mod/contactgroup.php b/mod/contactgroup.php
index 4456db2f5..856b01dd5 100644
--- a/mod/contactgroup.php
+++ b/mod/contactgroup.php
@@ -5,7 +5,7 @@ require_once('include/group.php');
function contactgroup_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
killme();
}
@@ -24,7 +24,7 @@ function contactgroup_content(&$a) {
intval($a->argv[1]),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
killme();
}
diff --git a/mod/contacts.php b/mod/contacts.php
index 735ccec72..b1553393e 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -8,8 +8,9 @@ require_once('mod/proxy.php');
require_once('include/Photo.php');
function contacts_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$contact_id = 0;
@@ -19,7 +20,7 @@ function contacts_init(&$a) {
intval(local_user()),
intval($contact_id)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$contact_id = 0;
}
}
@@ -78,13 +79,13 @@ function contacts_init(&$a) {
$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
));
@@ -128,18 +129,21 @@ function contacts_batch_actions(&$a){
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);
@@ -147,15 +151,16 @@ function contacts_post(&$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
@@ -164,12 +169,12 @@ function contacts_post(&$a) {
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;
}
@@ -346,7 +351,7 @@ function contacts_content(&$a) {
nav_set_selected('contacts');
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -384,7 +389,7 @@ function contacts_content(&$a) {
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);
}
@@ -395,7 +400,7 @@ function contacts_content(&$a) {
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);
}
@@ -407,7 +412,7 @@ function contacts_content(&$a) {
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);
}
@@ -446,22 +451,26 @@ function contacts_content(&$a) {
));
}
// 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);
}
}
@@ -480,11 +489,11 @@ function contacts_content(&$a) {
$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,
));
@@ -564,7 +573,7 @@ function contacts_content(&$a) {
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);
diff --git a/mod/content.php b/mod/content.php
index 1e2307f55..2377032a7 100644
--- a/mod/content.php
+++ b/mod/content.php
@@ -23,7 +23,7 @@ function content_content(&$a, $update = 0) {
// Currently security is based on the logged in user
- if(! local_user()) {
+ if (! local_user()) {
return;
}
@@ -113,11 +113,11 @@ function content_content(&$a, $update = 0) {
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
}
@@ -509,8 +509,8 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
'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'),
);
@@ -742,10 +742,11 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
}
}
- 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;
@@ -764,7 +765,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
$isstarred = "unstarred";
if ($profile_owner == local_user()) {
- if($toplevelpost) {
+ if ($toplevelpost) {
$isstarred = (($item['starred']) ? "starred" : "unstarred");
$star = array(
@@ -782,6 +783,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
intval($item['uid']),
intval($item['id'])
);
+
if (dbm::is_result($r)) {
$ignore = array(
'do' => t("ignore thread"),
@@ -793,7 +795,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
);
}
$tagger = '';
- if(feature_enabled($profile_owner,'commtag')) {
+ if (feature_enabled($profile_owner,'commtag')) {
$tagger = array(
'add' => t("add tag"),
'class' => "",
@@ -818,19 +820,22 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
$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']) : '');
diff --git a/mod/crepair.php b/mod/crepair.php
index b4275f6ba..59b92df0a 100644
--- a/mod/crepair.php
+++ b/mod/crepair.php
@@ -3,8 +3,9 @@ require_once("include/contact_selectors.php");
require_once("mod/contacts.php");
function crepair_init(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$contact_id = 0;
@@ -14,7 +15,7 @@ function crepair_init(&$a) {
intval(local_user()),
intval($contact_id)
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
$contact_id = 0;
}
}
@@ -29,10 +30,10 @@ function crepair_init(&$a) {
}
}
-
function crepair_post(&$a) {
- if(! local_user())
+ if (! local_user()) {
return;
+ }
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
@@ -43,8 +44,9 @@ function crepair_post(&$a) {
);
}
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
return;
+ }
$contact = $r[0];
@@ -96,7 +98,7 @@ function crepair_post(&$a) {
function crepair_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -110,7 +112,7 @@ function crepair_content(&$a) {
);
}
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL);
return;
}
diff --git a/mod/delegate.php b/mod/delegate.php
index 71628aed0..1a3f13c76 100644
--- a/mod/delegate.php
+++ b/mod/delegate.php
@@ -8,17 +8,18 @@ function delegate_init(&$a) {
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];
@@ -29,7 +30,7 @@ function delegate_content(&$a) {
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 ) ",
@@ -38,21 +39,22 @@ function delegate_content(&$a) {
);
}
}
- 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');
}
@@ -92,12 +94,12 @@ function delegate_content(&$a) {
$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;
}
@@ -105,7 +107,7 @@ function delegate_content(&$a) {
$nicknames = array();
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
}
}
@@ -128,7 +130,7 @@ function delegate_content(&$a) {
$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,
diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php
index e30617663..684cd341e 100644
--- a/mod/dfrn_confirm.php
+++ b/mod/dfrn_confirm.php
@@ -121,7 +121,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
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 );
@@ -194,7 +194,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$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']);
@@ -503,10 +503,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
// 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
}
@@ -522,7 +523,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
*
*/
- if(x($_POST,'source_url')) {
+ if (x($_POST,'source_url')) {
// We are processing an external confirmation to an introduction created by our user.
@@ -543,7 +544,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
// 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);
}
@@ -553,7 +554,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$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
@@ -640,7 +641,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
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);
}
@@ -661,10 +662,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$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");
@@ -673,11 +675,13 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
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,
@@ -699,7 +703,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
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);
}
@@ -726,7 +730,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
'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'],
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php
index dfa2af18c..ca1221158 100644
--- a/mod/dfrn_notify.php
+++ b/mod/dfrn_notify.php
@@ -42,7 +42,7 @@ function dfrn_notify_post(&$a) {
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);
}
@@ -88,7 +88,7 @@ function dfrn_notify_post(&$a) {
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
@@ -284,8 +284,9 @@ function dfrn_notify_content(&$a) {
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);
diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php
index 91cd33f49..0c55af2a8 100644
--- a/mod/dfrn_poll.php
+++ b/mod/dfrn_poll.php
@@ -112,7 +112,7 @@ function dfrn_poll_init(&$a) {
}
}
$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());
@@ -126,7 +126,7 @@ function dfrn_poll_init(&$a) {
$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
}
@@ -223,7 +223,7 @@ function dfrn_poll_post(&$a) {
$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
}
@@ -284,8 +284,9 @@ function dfrn_poll_post(&$a) {
dbesc($challenge)
);
- if(! dbm::is_result($r))
+ if (! dbm::is_result($r)) {
killme();
+ }
$type = $r[0]['type'];
$last_update = $r[0]['last_update'];
@@ -319,8 +320,9 @@ function dfrn_poll_post(&$a) {
$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'];
@@ -499,14 +501,14 @@ function dfrn_poll_content(&$a) {
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';
diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
index 236970a2e..68ef4971b 100644
--- a/mod/dfrn_request.php
+++ b/mod/dfrn_request.php
@@ -120,17 +120,19 @@ function dfrn_request_post(&$a) {
$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 );
@@ -176,7 +178,7 @@ function dfrn_request_post(&$a) {
);
}
- if($r) {
+ if ($r) {
info( t("Introduction complete.") . EOL);
}
@@ -193,19 +195,22 @@ function dfrn_request_post(&$a) {
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)
@@ -296,7 +301,7 @@ function dfrn_request_post(&$a) {
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'])
@@ -321,7 +326,7 @@ function dfrn_request_post(&$a) {
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'])
@@ -371,7 +376,7 @@ function dfrn_request_post(&$a) {
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;
}
@@ -499,15 +504,15 @@ function dfrn_request_post(&$a) {
);
}
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
}
@@ -516,17 +521,19 @@ function dfrn_request_post(&$a) {
$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 );
@@ -565,7 +572,7 @@ function dfrn_request_post(&$a) {
);
// 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),
@@ -579,14 +586,14 @@ function dfrn_request_post(&$a) {
}
}
- 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),
@@ -600,12 +607,13 @@ function dfrn_request_post(&$a) {
// 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"
@@ -633,8 +641,9 @@ function dfrn_request_post(&$a) {
$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);
@@ -651,16 +660,17 @@ function dfrn_request_post(&$a) {
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;
@@ -742,7 +752,7 @@ function dfrn_request_content(&$a) {
'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'],
@@ -804,15 +814,18 @@ function dfrn_request_content(&$a) {
$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 );
@@ -825,10 +838,12 @@ function dfrn_request_content(&$a) {
*
*/
- 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:");
@@ -842,8 +857,9 @@ function dfrn_request_content(&$a) {
$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
diff --git a/mod/directory.php b/mod/directory.php
index ddea650de..50a0a93b9 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -92,12 +92,14 @@ function directory_content(&$a) {
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= '';
diff --git a/mod/dirfind.php b/mod/dirfind.php
index 215731978..0ac82f281 100644
--- a/mod/dirfind.php
+++ b/mod/dirfind.php
@@ -7,13 +7,14 @@ require_once('mod/contacts.php');
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();
@@ -31,7 +32,7 @@ function dirfind_content(&$a, $prefix = "") {
$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
@@ -41,7 +42,7 @@ function dirfind_content(&$a, $prefix = "") {
}
}
- if(strpos($search,'!') === 0) {
+ if (strpos($search,'!') === 0) {
$search = substr($search,1);
$community = true;
$header = sprintf( t('Forum Search - %s'), $search);
@@ -49,7 +50,7 @@ function dirfind_content(&$a, $prefix = "") {
$o = '';
- if($search) {
+ if ($search) {
if ($discover_user) {
$j = new stdClass();
@@ -85,18 +86,21 @@ function dirfind_content(&$a, $prefix = "") {
$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`
@@ -133,8 +137,9 @@ function dirfind_content(&$a, $prefix = "") {
$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);
@@ -167,16 +172,16 @@ function dirfind_content(&$a, $prefix = "") {
$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 = "";
@@ -194,10 +199,11 @@ function dirfind_content(&$a, $prefix = "") {
$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)),
@@ -235,8 +241,7 @@ function dirfind_content(&$a, $prefix = "") {
'$paginate' => paginate($a),
));
- }
- else {
+ } else {
info( t('No matches') . EOL);
}
diff --git a/mod/display.php b/mod/display.php
index 293156cf1..6ebe16ae8 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -81,8 +81,8 @@ function display_init(&$a) {
$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`
@@ -184,7 +184,7 @@ function display_fetchauthor($a, $item) {
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"]);
diff --git a/mod/editpost.php b/mod/editpost.php
index 217d793f5..54b50bc36 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -6,14 +6,14 @@ function editpost_content(&$a) {
$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;
}
@@ -23,7 +23,7 @@ function editpost_content(&$a) {
intval(local_user())
);
- if(! count($itm)) {
+ if (! count($itm)) {
notice( t('Item not found') . EOL);
return;
}
@@ -42,7 +42,7 @@ function editpost_content(&$a) {
$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
everybody '),
'$geotag' => $geotag,
@@ -51,7 +51,7 @@ function editpost_content(&$a) {
$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
everybody '),
'$geotag' => $geotag,
@@ -126,7 +126,7 @@ function editpost_content(&$a) {
'$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',
diff --git a/mod/events.php b/mod/events.php
index 7cb171f9e..36d8f0cf7 100644
--- a/mod/events.php
+++ b/mod/events.php
@@ -9,18 +9,19 @@ require_once('include/event.php');
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;
@@ -33,8 +34,9 @@ function events_post(&$a) {
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);
@@ -49,33 +51,35 @@ function events_post(&$a) {
// 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.
@@ -89,11 +93,11 @@ function events_post(&$a) {
$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();
}
@@ -186,43 +190,46 @@ function events_post(&$a) {
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,
@@ -231,7 +238,7 @@ function events_content(&$a) {
$etpl = get_markup_template('event_end.tpl');
$a->page['end'] .= replace_macros($etpl,array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$editselect' => $editselect
));
@@ -248,15 +255,15 @@ function events_content(&$a) {
$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]);
@@ -264,23 +271,27 @@ function events_content(&$a) {
}
// 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;
@@ -334,10 +345,11 @@ function events_content(&$a) {
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;
+ }
}
}
@@ -375,13 +387,13 @@ function events_content(&$a) {
}
$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,
@@ -475,7 +487,7 @@ function events_content(&$a) {
$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,
diff --git a/mod/fbrowser.php b/mod/fbrowser.php
index 11ac2d825..9c1d43cd8 100644
--- a/mod/fbrowser.php
+++ b/mod/fbrowser.php
@@ -10,6 +10,7 @@ require_once('include/Photo.php');
/**
* @param App $a
*/
+/// @TODO & is missing or App ?
function fbrowser_content($a){
if (!local_user())
@@ -83,9 +84,9 @@ function fbrowser_content($a){
$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);
@@ -93,19 +94,19 @@ function fbrowser_content($a){
$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())
);
@@ -115,26 +116,25 @@ function fbrowser_content($a){
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'],
));
diff --git a/mod/filer.php b/mod/filer.php
index 4e79f337d..eac326059 100644
--- a/mod/filer.php
+++ b/mod/filer.php
@@ -7,7 +7,7 @@ require_once('include/items.php');
function filer_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
killme();
}
diff --git a/mod/filerm.php b/mod/filerm.php
index c266082c8..d3d74a4c2 100644
--- a/mod/filerm.php
+++ b/mod/filerm.php
@@ -2,7 +2,7 @@
function filerm_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
killme();
}
@@ -10,18 +10,21 @@ function filerm_content(&$a) {
$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();
}
diff --git a/mod/follow.php b/mod/follow.php
index 1f56caea5..2e970ad0c 100644
--- a/mod/follow.php
+++ b/mod/follow.php
@@ -7,7 +7,7 @@ require_once('include/contact_selectors.php');
function follow_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
goaway($_SESSION['return_url']);
// NOTREACHED
@@ -56,14 +56,15 @@ function follow_content(&$a) {
// 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');
}
@@ -84,20 +85,22 @@ function follow_content(&$a) {
$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");
@@ -151,14 +154,15 @@ function follow_content(&$a) {
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']));
@@ -170,17 +174,20 @@ function follow_post(&$a) {
$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
diff --git a/mod/friendica.php b/mod/friendica.php
index fb25f40e4..5d8e43e6c 100644
--- a/mod/friendica.php
+++ b/mod/friendica.php
@@ -15,7 +15,7 @@ function friendica_init(&$a) {
$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;
@@ -49,7 +49,7 @@ function friendica_init(&$a) {
'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);
diff --git a/mod/fsuggest.php b/mod/fsuggest.php
index 1d56f4573..66871653d 100644
--- a/mod/fsuggest.php
+++ b/mod/fsuggest.php
@@ -3,12 +3,13 @@
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]);
@@ -16,7 +17,7 @@ function fsuggest_post(&$a) {
intval($contact_id),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL);
return;
}
@@ -74,7 +75,7 @@ function fsuggest_content(&$a) {
require_once('include/acl_selectors.php');
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -88,7 +89,7 @@ function fsuggest_content(&$a) {
intval($contact_id),
intval(local_user())
);
- if(! dbm::is_result($r)) {
+ if (! dbm::is_result($r)) {
notice( t('Contact not found.') . EOL);
return;
}
diff --git a/mod/group.php b/mod/group.php
index db92ed7de..75ccc8f6d 100644
--- a/mod/group.php
+++ b/mod/group.php
@@ -15,7 +15,7 @@ function group_init(&$a) {
function group_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -25,39 +25,44 @@ function group_post(&$a) {
$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();
@@ -68,7 +73,7 @@ function group_post(&$a) {
function group_content(&$a) {
$change = false;
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied') . EOL);
return;
}
@@ -99,26 +104,32 @@ function group_content(&$a) {
}
- 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",
@@ -129,16 +140,16 @@ function group_content(&$a) {
$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']);
diff --git a/mod/hcard.php b/mod/hcard.php
index 6d2d9e2eb..512949f1a 100644
--- a/mod/hcard.php
+++ b/mod/hcard.php
@@ -4,8 +4,9 @@ function hcard_init(&$a) {
$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;
@@ -13,39 +14,42 @@ function hcard_init(&$a) {
}
$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'] .= '
';
}
- if(x($a->profile,'openidserver'))
+ if (x($a->profile,'openidserver')) {
$a->page['htmlhead'] .= '
' . "\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'] .= '
' . "\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'] .= '
' . "\r\n" ;
+ }
}
$a->page['htmlhead'] .= '
' . "\r\n" ;
- $a->page['htmlhead'] .= '
' . "\r\n" ;
+ $a->page['htmlhead'] .= '
' . "\r\n" ;
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
- $a->page['htmlhead'] .= '
' . "\r\n";
- header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
-
+ $a->page['htmlhead'] .= '
' . "\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'] .= "
get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
+ foreach ($dfrn_pages as $dfrn) {
+ $a->page['htmlhead'] .= "
\r\n";
+ }
}
diff --git a/mod/help.php b/mod/help.php
index 722256927..0512e0f2e 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -77,7 +77,7 @@ function help_content(&$a) {
if ($level>$lastlevel) $toc.="
";
$idnum[$level]++;
$id = implode("_", array_slice($idnum,1,$level));
- $href = $a->get_baseurl()."/help/{$filename}#{$id}";
+ $href = App::get_baseurl()."/help/{$filename}#{$id}";
$toc .= "".strip_tags($line)." ";
$line = " ".$line;
$lastlevel = $level;
diff --git a/mod/home.php b/mod/home.php
index cdf4b3715..eb5d1e90b 100644
--- a/mod/home.php
+++ b/mod/home.php
@@ -6,33 +6,38 @@ function home_init(&$a) {
$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'] .= ' ';}
+ /// @TODO No absolute path used, maybe risky (security)
+ if (file_exists('home.html')) {
+ if (file_exists('home.css')) {
+ $a->page['htmlhead'] .= ' ';
+ }
- $o .= file_get_contents('home.html');}
-
- else $o .= ''.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").' ';
+ $o .= file_get_contents('home.html');
+ } else {
+ $o .= ''.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").' ';
+ }
$o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1);
@@ -41,5 +46,4 @@ function home_content(&$a) {
return $o;
-
}}
diff --git a/mod/ignored.php b/mod/ignored.php
index ba55c55e3..5e8411e37 100644
--- a/mod/ignored.php
+++ b/mod/ignored.php
@@ -5,22 +5,27 @@ function ignored_init(&$a) {
$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),
@@ -30,12 +35,12 @@ function ignored_init(&$a) {
// 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
diff --git a/mod/install.php b/mod/install.php
index b5af1373a..b13da8c28 100755
--- a/mod/install.php
+++ b/mod/install.php
@@ -11,17 +11,16 @@ function install_init(&$a){
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']);
+ }
}
@@ -52,7 +51,7 @@ function install_post(&$a) {
$r = q("CREATE DATABASE '%s'",
dbesc($dbdata)
);
- if($r) {
+ if ($r) {
unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
} else {
@@ -63,7 +62,7 @@ function install_post(&$a) {
return;
}
}*/
- if(get_db_errno()) {
+ if (get_db_errno()) {
$a->data['db_conn_failed']=true;
}
@@ -107,17 +106,18 @@ function install_post(&$a) {
$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;
@@ -125,10 +125,11 @@ function install_post(&$a) {
}
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) {
@@ -140,23 +141,23 @@ 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 = '';
$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 ."
" ;
$txt .= " ".$a->data['db_failed'] . " ". EOL ;
@@ -176,7 +177,7 @@ function install_content(&$a) {
}
}
- if(x($a->data,'txt') && strlen($a->data['txt'])) {
+ if (x($a->data,'txt') && strlen($a->data['txt'])) {
$db_return_text .= manual_config($a);
}
@@ -205,16 +206,19 @@ function install_content(&$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);
@@ -231,7 +235,7 @@ function install_content(&$a) {
'$next' => t('Next'),
'$reload' => t('Check again'),
'$phpath' => $phpath,
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
));
return $o;
}; break;
@@ -265,7 +269,7 @@ function install_content(&$a) {
'$lbl_10' => t('Please select a default timezone for your website'),
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => App::get_baseurl(),
'$phpath' => $phpath,
@@ -305,7 +309,7 @@ function install_content(&$a) {
'$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(),
@@ -343,7 +347,7 @@ function check_php(&$phpath, &$checks) {
$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
'Setup the poller' ") . EOL ;
$help .= EOL . EOL ;
@@ -370,7 +374,7 @@ function check_php(&$phpath, &$checks) {
}
- if($passed2) {
+ if ($passed2) {
$str = autoname(8);
$cmd = "$phpath testargs.php $str";
$result = trim(shell_exec($cmd));
@@ -392,15 +396,17 @@ function check_keys(&$checks) {
$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".');
}
@@ -420,7 +426,7 @@ function check_funcs(&$checks) {
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 {
@@ -428,31 +434,31 @@ function check_funcs(&$checks) {
}
}
- 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.');
}
@@ -487,7 +493,7 @@ function check_funcs(&$checks) {
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;
@@ -504,7 +510,7 @@ function check_htconfig(&$checks) {
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;
@@ -518,14 +524,14 @@ function check_smarty3(&$checks) {
}
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;
@@ -534,6 +540,7 @@ function check_htaccess(&$checks) {
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?
}
}
@@ -550,8 +557,7 @@ function check_imagik(&$checks) {
}
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, "");
@@ -559,8 +565,6 @@ function check_imagik(&$checks) {
}
}
-
-
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.');
@@ -599,8 +603,7 @@ function load_database($db) {
}
function what_next() {
- $a = get_app();
- $baseurl = $a->get_baseurl();
+ $baseurl = App::get_baseurl();
return
t('
What next ')
."
".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.')
diff --git a/mod/invite.php b/mod/invite.php
index ccf876c7c..441d39e6e 100644
--- a/mod/invite.php
+++ b/mod/invite.php
@@ -11,7 +11,7 @@ require_once('include/email.php');
function invite_post(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -19,14 +19,15 @@ function invite_post(&$a) {
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());
@@ -34,23 +35,24 @@ function invite_post(&$a) {
$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);
@@ -59,16 +61,17 @@ function invite_post(&$a) {
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,
@@ -76,7 +79,7 @@ function invite_post(&$a) {
. '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);
@@ -84,8 +87,7 @@ function invite_post(&$a) {
notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL);
return;
}
- }
- else {
+ } else {
notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL);
}
@@ -97,7 +99,7 @@ function invite_post(&$a) {
function invite_content(&$a) {
- if(! local_user()) {
+ if (! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
@@ -105,39 +107,39 @@ function invite_content(&$a) {
$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;
diff --git a/mod/item.php b/mod/item.php
index 1b071e4b4..b902f1e35 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -59,13 +59,14 @@ function item_post(&$a) {
// 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'];
+ }
}
/**
@@ -82,18 +83,20 @@ function item_post(&$a) {
$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),
@@ -105,17 +108,18 @@ function item_post(&$a) {
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];
@@ -125,7 +129,7 @@ function item_post(&$a) {
//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)
@@ -448,13 +452,15 @@ function item_post(&$a) {
$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` = ''
@@ -464,8 +470,9 @@ function item_post(&$a) {
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' ",
@@ -638,9 +645,10 @@ function item_post(&$a) {
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);
}
@@ -648,14 +656,17 @@ function item_post(&$a) {
$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 );
@@ -669,8 +680,9 @@ function item_post(&$a) {
$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;
@@ -732,7 +744,7 @@ function item_post(&$a) {
// $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;
@@ -765,8 +777,9 @@ function item_post(&$a) {
}
$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();
@@ -938,7 +951,7 @@ function item_post(&$a) {
'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'],
@@ -970,7 +983,7 @@ function item_post(&$a) {
'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'],
@@ -991,14 +1004,14 @@ function item_post(&$a) {
continue;
$disclaimer = '
' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
. '
';
- $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 = '
';
+ $link = '
';
$html = prepare_body($datarray);
$message = '' . $link . $html . $disclaimer . '';
include_once('include/html2plain.php');
@@ -1038,7 +1051,7 @@ function item_post(&$a) {
logger('post_complete');
- item_post_return($a->get_baseurl(), $api_source, $return_path);
+ item_post_return(App::get_baseurl(), $api_source, $return_path);
// NOTREACHED
}
@@ -1048,13 +1061,14 @@ function item_post_return($baseurl, $api_source, $return_path) {
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);
@@ -1066,15 +1080,16 @@ function item_post_return($baseurl, $api_source, $return_path) {
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: [
- , 0 (no perm) |
]
echo json_encode(array(intval($a->argv[2]), intval($o)));
killme();
@@ -1087,6 +1102,7 @@ function item_content(&$a) {
* 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
@@ -1104,13 +1120,14 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
$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;
}
diff --git a/mod/like.php b/mod/like.php
index 8d383b9ab..cbab9185e 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -24,7 +24,7 @@ function like_content(&$a) {
// 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
}
diff --git a/mod/localtime.php b/mod/localtime.php
index d1453bc52..ce6bf84a1 100644
--- a/mod/localtime.php
+++ b/mod/localtime.php
@@ -36,7 +36,7 @@ function localtime_content(&$a) {
$o .= '' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '
';
- $o .= '