Revert "Coding convention applied - part 1"

This commit is contained in:
Hypolite Petovan 2017-03-21 12:02:59 -04:00 committed by GitHub
parent 9c2c483996
commit 7b352f3f74
181 changed files with 3507 additions and 4338 deletions

309
boot.php
View file

@ -711,6 +711,7 @@ class App {
// fix query_string
$this->query_string = str_replace($this->cmd."&",$this->cmd."?", $this->query_string);
// unix style "homedir"
if (substr($this->cmd,0,1) === '~') {
@ -744,7 +745,8 @@ class App {
if((array_key_exists('0',$this->argv)) && strlen($this->argv[0])) {
$this->module = str_replace(".", "_", $this->argv[0]);
$this->module = str_replace("-", "_", $this->module);
} else {
}
else {
$this->argc = 1;
$this->argv = array('home');
$this->module = 'home';
@ -758,9 +760,8 @@ class App {
$this->pager['page'] = ((x($_GET,'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
$this->pager['itemspage'] = 50;
$this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
if ($this->pager['start'] < 0) {
if($this->pager['start'] < 0)
$this->pager['start'] = 0;
}
$this->pager['total'] = 0;
/*
@ -792,17 +793,14 @@ class App {
$basepath = get_config("system", "basepath");
if ($basepath == "") {
if ($basepath == "")
$basepath = dirname(__FILE__);
}
if ($basepath == "") {
if ($basepath == "")
$basepath = $_SERVER["DOCUMENT_ROOT"];
}
if ($basepath == "") {
if ($basepath == "")
$basepath = $_SERVER["PWD"];
}
return($basepath);
}
@ -878,7 +876,7 @@ class App {
}
if (file_exists(".htpreconfig.php")) {
include(".htpreconfig.php");
@include(".htpreconfig.php");
}
if (get_config('config', 'hostname') != '') {
@ -892,9 +890,8 @@ class App {
}
function get_hostname() {
if (get_config('config','hostname') != "") {
if (get_config('config','hostname') != "")
$this->hostname = get_config('config','hostname');
}
return $this->hostname;
}
@ -929,17 +926,16 @@ class App {
$interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000);
// If the update is "deactivated" set it to the highest integer number (~24 days)
if ($interval < 0) {
if ($interval < 0)
$interval = 2147483647;
}
if ($interval < 10000) {
if($interval < 10000)
$interval = 40000;
}
// compose the page title from the sitename and the
// current module called
if (!$this->module=='') {
if (!$this->module=='')
{
$this->page['title'] = $this->config['sitename'].' ('.$this->module.')';
} else {
$this->page['title'] = $this->config['sitename'];
@ -949,29 +945,25 @@ class App {
* since the code added by the modules frequently depends on it
* being first
*/
if (!isset($this->page['htmlhead'])) {
if(!isset($this->page['htmlhead']))
$this->page['htmlhead'] = '';
}
// If we're using Smarty, then doing replace_macros() will replace
// any unrecognized variables with a blank string. Since we delay
// replacing $stylesheet until later, we need to replace it now
// with another variable name
if ($this->theme['template_engine'] === 'smarty3') {
if($this->theme['template_engine'] === 'smarty3')
$stylesheet = $this->get_template_ldelim('smarty3') . '$stylesheet' . $this->get_template_rdelim('smarty3');
} else {
else
$stylesheet = '$stylesheet';
}
$shortcut_icon = get_config("system", "shortcut_icon");
if ($shortcut_icon == "") {
if ($shortcut_icon == "")
$shortcut_icon = "images/friendica-32.png";
}
$touch_icon = get_config("system", "touch_icon");
if ($touch_icon == "") {
if ($touch_icon == "")
$touch_icon = "images/friendica-128.png";
}
// get data wich is needed for infinite scroll on the network page
$invinite_scroll = infinite_scroll_data($this->module);
@ -993,9 +985,8 @@ class App {
}
function init_page_end() {
if (!isset($this->page['end'])) {
if(!isset($this->page['end']))
$this->page['end'] = '';
}
$tpl = get_markup_template('end.tpl');
$this->page['end'] = replace_macros($tpl,array(
'$baseurl' => $this->get_baseurl() // FIXME for z_path!!!!
@ -1168,9 +1159,8 @@ class App {
}
function save_timestamp($stamp, $value) {
if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler']) {
if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler'])
return;
}
$duration = (float)(microtime(true)-$stamp);
@ -1252,9 +1242,8 @@ class App {
array_shift($trace);
$callstack = array();
foreach ($trace AS $func) {
foreach ($trace AS $func)
$callstack[] = $func["function"];
}
return implode(", ", $callstack);
}
@ -1276,34 +1265,32 @@ class App {
* @return bool Is it a known backend?
*/
function is_backend() {
static $backend = array(
"_well_known",
"api",
"dfrn_notify",
"fetch",
"hcard",
"hostxrd",
"nodeinfo",
"noscrape",
"p",
"poco",
"post",
"proxy",
"pubsub",
"pubsubhubbub",
"receive",
"rsd_xml",
"salmon",
"statistics_json",
"xrd",
);
$backend = array();
$backend[] = "_well_known";
$backend[] = "api";
$backend[] = "dfrn_notify";
$backend[] = "fetch";
$backend[] = "hcard";
$backend[] = "hostxrd";
$backend[] = "nodeinfo";
$backend[] = "noscrape";
$backend[] = "p";
$backend[] = "poco";
$backend[] = "post";
$backend[] = "proxy";
$backend[] = "pubsub";
$backend[] = "pubsubhubbub";
$backend[] = "receive";
$backend[] = "rsd_xml";
$backend[] = "salmon";
$backend[] = "statistics_json";
$backend[] = "xrd";
if (in_array($this->module, $backend)) {
if (in_array($this->module, $backend))
return(true);
} else {
else
return($this->backend);
}
}
/**
* @brief Checks if the maximum number of database processes is reached
@ -1315,16 +1302,14 @@ class App {
if ($this->is_backend()) {
$process = "backend";
$max_processes = get_config('system', 'max_processes_backend');
if (intval($max_processes) == 0) {
if (intval($max_processes) == 0)
$max_processes = 5;
}
} else {
$process = "frontend";
$max_processes = get_config('system', 'max_processes_frontend');
if (intval($max_processes) == 0) {
if (intval($max_processes) == 0)
$max_processes = 20;
}
}
$processlist = dbm::processlist();
if ($processlist["list"] != "") {
@ -1348,16 +1333,14 @@ class App {
if ($this->is_backend()) {
$process = "backend";
$maxsysload = intval(get_config('system', 'maxloadavg'));
if ($maxsysload < 1) {
if ($maxsysload < 1)
$maxsysload = 50;
}
} else {
$process = "frontend";
$maxsysload = intval(get_config('system','maxloadavg_frontend'));
if ($maxsysload < 1) {
if ($maxsysload < 1)
$maxsysload = 50;
}
}
$load = current_load();
if ($load) {
@ -1392,17 +1375,16 @@ class App {
// add baseurl to args. cli scripts can't construct it
$args[] = $this->get_baseurl();
for ($x = 0; $x < count($args); $x ++) {
for($x = 0; $x < count($args); $x ++)
$args[$x] = escapeshellarg($args[$x]);
}
$cmdline = implode($args," ");
if (get_config('system','proc_windows')) {
if(get_config('system','proc_windows'))
proc_close(proc_open('cmd /c start /b ' . $cmdline,array(),$foo,dirname(__FILE__)));
} else {
else
proc_close(proc_open($cmdline." &",array(),$foo,dirname(__FILE__)));
}
}
/**
@ -1481,13 +1463,13 @@ function get_app() {
function x($s,$k = NULL) {
if($k != NULL) {
if((is_array($s)) && (array_key_exists($k,$s))) {
if ($s[$k]) {
if($s[$k])
return (int) 1;
}
return (int) 0;
}
return false;
} else {
}
else {
if(isset($s)) {
if($s) {
return (int) 1;
@ -1517,9 +1499,8 @@ function clean_urls() {
function z_path() {
$base = App::get_baseurl();
if (! clean_urls()) {
if(! clean_urls())
$base .= '/?q=';
}
return $base;
}
@ -1544,9 +1525,8 @@ function z_root() {
* @return string
*/
function absurl($path) {
if (strpos($path,'/') === 0) {
if(strpos($path,'/') === 0)
return z_path() . $path;
}
return $path;
}
@ -1566,9 +1546,8 @@ function check_db() {
set_config('system','build',DB_UPDATE_VERSION);
$build = DB_UPDATE_VERSION;
}
if ($build != DB_UPDATE_VERSION) {
if($build != DB_UPDATE_VERSION)
proc_run(PRIORITY_CRITICAL, 'include/dbupdate.php');
}
}
@ -1587,12 +1566,10 @@ function check_url(App $a) {
// and www.example.com vs example.com.
// We will only change the url to an ip address if there is no existing setting
if (! x($url)) {
if(! x($url))
$url = set_config('system','url',App::get_baseurl());
}
if ((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname))) {
if((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname)))
$url = set_config('system','url',App::get_baseurl());
}
return;
}
@ -1603,9 +1580,8 @@ function check_url(App $a) {
*/
function update_db(App $a) {
$build = get_config('system','build');
if (! x($build)) {
if(! x($build))
$build = set_config('system','build',DB_UPDATE_VERSION);
}
if($build != DB_UPDATE_VERSION) {
$stored = intval($build);
@ -1624,9 +1600,8 @@ function update_db(App $a) {
// Compare the current structure with the defined structure
$t = get_config('database','dbupdate_'.DB_UPDATE_VERSION);
if ($t !== false) {
if($t !== false)
return;
}
set_config('database','dbupdate_'.DB_UPDATE_VERSION, time());
@ -1634,13 +1609,10 @@ function update_db(App $a) {
// conflits with new routine)
for ($x = $stored; $x < NEW_UPDATE_ROUTINE_VERSION; $x++) {
$r = run_update_function($x);
if (!$r) {
break;
}
}
if ($stored < NEW_UPDATE_ROUTINE_VERSION) {
$stored = NEW_UPDATE_ROUTINE_VERSION;
if (!$r) break;
}
if ($stored < NEW_UPDATE_ROUTINE_VERSION) $stored = NEW_UPDATE_ROUTINE_VERSION;
// run new update routine
// it update the structure in one call
@ -1658,9 +1630,7 @@ function update_db(App $a) {
// run any left update_nnnn functions in update.php
for($x = $stored; $x < $current; $x ++) {
$r = run_update_function($x);
if (!$r) {
break;
}
if (!$r) break;
}
}
}
@ -1681,9 +1651,8 @@ function run_update_function($x) {
// delete the config entry to try again.
$t = get_config('database','update_' . $x);
if ($t !== false) {
if($t !== false)
return false;
}
set_config('database','update_' . $x, time());
// call the specific update
@ -1728,18 +1697,16 @@ function run_update_function($x) {
function check_plugins(App $a) {
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$installed = $r;
} else {
else
$installed = array();
}
$plugins = get_config('system','addon');
$plugins_arr = array();
if ($plugins) {
if($plugins)
$plugins_arr = explode(',',str_replace(' ', '',$plugins));
}
$a->plugins = $plugins_arr;
@ -1749,7 +1716,8 @@ function check_plugins(App $a) {
foreach($installed as $i) {
if(! in_array($i['name'],$plugins_arr)) {
uninstall_plugin($i['name']);
} else {
}
else {
$installed_arr[] = $i['name'];
}
}
@ -1819,7 +1787,8 @@ function login($register = false, $hiddens=false) {
if(local_user()) {
$tpl = get_markup_template("logout.tpl");
} else {
}
else {
$a->page['htmlhead'] .= replace_macros(get_markup_template("login_head.tpl"),array(
'$baseurl' => $a->get_baseurl(true)
));
@ -1867,9 +1836,8 @@ function login($register = false, $hiddens=false) {
*/
function killme() {
if (!get_app()->is_backend()) {
if (!get_app()->is_backend())
session_write_close();
}
exit;
}
@ -1878,9 +1846,8 @@ function killme() {
* @brief Redirect to another URL and terminate this process.
*/
function goaway($s) {
if (!strstr(normalise_link($s), "http://")) {
if (!strstr(normalise_link($s), "http://"))
$s = App::get_baseurl()."/".$s;
}
header("Location: $s");
killme();
@ -1928,9 +1895,8 @@ function public_contact() {
* @return int|bool visitor_id or false
*/
function remote_user() {
if ((x($_SESSION,'authenticated')) && (x($_SESSION,'visitor_id'))) {
if((x($_SESSION,'authenticated')) && (x($_SESSION,'visitor_id')))
return intval($_SESSION['visitor_id']);
}
return false;
}
@ -1943,13 +1909,10 @@ function remote_user() {
*/
function notice($s) {
$a = get_app();
if (! x($_SESSION,'sysmsg')) {
$_SESSION['sysmsg'] = array();
}
if ($a->interactive) {
if(! x($_SESSION,'sysmsg')) $_SESSION['sysmsg'] = array();
if($a->interactive)
$_SESSION['sysmsg'][] = $s;
}
}
/**
* @brief Show an info message to user.
@ -1961,17 +1924,13 @@ function notice($s) {
function info($s) {
$a = get_app();
if (local_user() AND get_pconfig(local_user(),'system','ignore_info')) {
if (local_user() AND get_pconfig(local_user(),'system','ignore_info'))
return;
}
if (! x($_SESSION,'sysmsg_info')) {
$_SESSION['sysmsg_info'] = array();
}
if ($a->interactive) {
if(! x($_SESSION,'sysmsg_info')) $_SESSION['sysmsg_info'] = array();
if($a->interactive)
$_SESSION['sysmsg_info'][] = $s;
}
}
/**
@ -2032,9 +1991,8 @@ function proc_run($cmd){
$arr = array('args' => $args, 'run_cmd' => true);
call_hooks("proc_run", $arr);
if (!$arr['run_cmd'] OR !count($args)) {
if (!$arr['run_cmd'] OR !count($args))
return;
}
$priority = PRIORITY_MEDIUM;
$dont_fork = get_config("system", "worker_dont_fork");
@ -2057,13 +2015,12 @@ function proc_run($cmd){
$found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'",
dbesc($parameters));
if (!dbm::is_result($found)) {
if (!$found)
q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`)
VALUES ('%s', '%s', %d)",
dbesc($parameters),
dbesc(datetime_convert()),
intval($priority));
}
// Should we quit and wait for the poller to be called as a cronjob?
if ($dont_fork) {
@ -2076,14 +2033,12 @@ function proc_run($cmd){
// Get number of allowed number of worker threads
$queues = intval(get_config("system", "worker_queues"));
if ($queues == 0) {
if ($queues == 0)
$queues = 4;
}
// If there are already enough workers running, don't fork another one
if ($workers[0]["workers"] >= $queues) {
if ($workers[0]["workers"] >= $queues)
return;
}
// Now call the poller to execute the jobs that we just added to the queue
$args = array("include/poller.php", "no_cron");
@ -2104,19 +2059,17 @@ function current_theme(){
$r = q("select theme from user where uid = %d limit 1",
intval($a->profile_uid)
);
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$page_theme = $r[0]['theme'];
}
}
// Allow folks to over-rule user themes and always use their own on their own site.
// This works only if the user is on the same server
if($page_theme && local_user() && (local_user() != $a->profile_uid)) {
if (get_pconfig(local_user(),'system','always_my_theme')) {
if(get_pconfig(local_user(),'system','always_my_theme'))
$page_theme = null;
}
}
// $mobile_detect = new Mobile_Detect();
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
@ -2141,39 +2094,33 @@ function current_theme(){
$system_theme = $standard_system_theme;
$theme_name = $standard_theme_name;
if ($page_theme) {
if($page_theme)
$theme_name = $page_theme;
}
}
}
} else {
else {
$system_theme = $standard_system_theme;
$theme_name = $standard_theme_name;
if ($page_theme) {
if($page_theme)
$theme_name = $page_theme;
}
}
if($theme_name &&
(file_exists('view/theme/' . $theme_name . '/style.css') ||
file_exists('view/theme/' . $theme_name . '/style.php'))) {
file_exists('view/theme/' . $theme_name . '/style.php')))
return($theme_name);
}
foreach($app_base_themes as $t) {
if(file_exists('view/theme/' . $t . '/style.css')||
file_exists('view/theme/' . $t . '/style.php')) {
file_exists('view/theme/' . $t . '/style.php'))
return($t);
}
}
$fallback = array_merge(glob('view/theme/*/style.css'),glob('view/theme/*/style.php'));
if (count($fallback)) {
if(count($fallback))
return (str_replace('view/theme/','', substr($fallback[0],0,-10)));
}
/// @TODO No final return statement?
}
@ -2190,9 +2137,8 @@ function current_theme_url() {
$t = current_theme();
$opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
if (file_exists('view/theme/' . $t . '/style.php')) {
if (file_exists('view/theme/' . $t . '/style.php'))
return('view/theme/'.$t.'/style.pcss'.$opts);
}
return('view/theme/'.$t.'/style.css');
}
@ -2221,9 +2167,8 @@ function feed_birthday($uid,$tz) {
$birthday = '';
if (! strlen($tz)) {
if(! strlen($tz))
$tz = 'UTC';
}
$p = q("SELECT `dob` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
intval($uid)
@ -2236,9 +2181,8 @@ function feed_birthday($uid,$tz) {
$bd = $y . '-' . $tmp_dob . ' 00:00';
$t_dob = strtotime($bd);
$now = strtotime(datetime_convert($tz,$tz,'now'));
if ($t_dob < $now) {
if($t_dob < $now)
$bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
}
$birthday = datetime_convert($tz,'UTC',$bd,ATOM_TIME);
}
}
@ -2303,10 +2247,9 @@ function explode_querystring($query) {
$args = explode('&', substr($query, $arg_st));
foreach($args as $k=>$arg) {
if ($arg === '') {
if($arg === '')
unset($args[$k]);
}
}
$args = array_values($args);
if(!$base) {
@ -2328,9 +2271,7 @@ function explode_querystring($query) {
*/
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
@ -2351,9 +2292,8 @@ function random_digits($digits) {
function get_server() {
$server = get_config("system", "directory");
if ($server == "") {
if ($server == "")
$server = "http://dir.friendi.ca";
}
return($server);
}
@ -2361,9 +2301,8 @@ function get_server() {
function get_cachefile($file, $writemode = true) {
$cache = get_itemcachepath();
if ((! $cache) || (! is_dir($cache))) {
if ((! $cache) || (! is_dir($cache)))
return("");
}
$subfolder = $cache."/".substr($file, 0, 2);
@ -2385,30 +2324,25 @@ function clear_cache($basepath = "", $path = "") {
$path = $basepath;
}
if (($path == "") OR (!is_dir($path))) {
if (($path == "") OR (!is_dir($path)))
return;
}
if (substr(realpath($path), 0, strlen($basepath)) != $basepath) {
if (substr(realpath($path), 0, strlen($basepath)) != $basepath)
return;
}
$cachetime = (int)get_config('system','itemcache_duration');
if ($cachetime == 0) {
if ($cachetime == 0)
$cachetime = 86400;
}
if (is_writable($path)){
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
$fullpath = $path."/".$file;
if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != "..")) {
if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != ".."))
clear_cache($basepath, $fullpath);
}
if ((filetype($fullpath) == "file") and (filectime($fullpath) < (time() - $cachetime))) {
if ((filetype($fullpath) == "file") and (filectime($fullpath) < (time() - $cachetime)))
unlink($fullpath);
}
}
closedir($dh);
}
}
@ -2417,9 +2351,8 @@ function clear_cache($basepath = "", $path = "") {
function get_itemcachepath() {
// Checking, if the cache is deactivated
$cachetime = (int)get_config('system','itemcache_duration');
if ($cachetime < 0) {
if ($cachetime < 0)
return "";
}
$itemcache = get_config('system','itemcache');
if (($itemcache != "") AND App::directory_usable($itemcache)) {
@ -2534,42 +2467,37 @@ function validate_include(&$file) {
$file = realpath($file);
if (strpos($file, getcwd()) !== 0) {
if (strpos($file, getcwd()) !== 0)
return false;
}
$file = str_replace(getcwd()."/", "", $file, $count);
if ($count != 1) {
if ($count != 1)
return false;
}
if ($orig_file !== $file) {
if ($orig_file !== $file)
return false;
}
$valid = false;
if (strpos($file, "include/") === 0) {
if (strpos($file, "include/") === 0)
$valid = true;
}
if (strpos($file, "addon/") === 0) {
if (strpos($file, "addon/") === 0)
$valid = true;
}
// Simply return flag
return ($valid);
if (!$valid)
return false;
return true;
}
function current_load() {
if (!function_exists('sys_getloadavg')) {
if (!function_exists('sys_getloadavg'))
return false;
}
$load_arr = sys_getloadavg();
if (!is_array($load_arr)) {
if (!is_array($load_arr))
return false;
}
return max($load_arr[0], $load_arr[1]);
}
@ -2590,9 +2518,8 @@ function argc() {
* @return string Value of the argv key
*/
function argv($x) {
if (array_key_exists($x,get_app()->argv)) {
if(array_key_exists($x,get_app()->argv))
return get_app()->argv[$x];
}
return '';
}

View file

@ -122,13 +122,11 @@ function terminate_friendship($user,$self,$contact) {
// This provides for the possibility that their database is temporarily messed
// up or some other transient event and that there's a possibility we could recover from it.
function mark_for_death(array $contact) {
function mark_for_death($contact) {
if ($contact['archive']) {
if($contact['archive'])
return;
}
/// @TODO Comparison of strings this way may lead to bugs/incompatibility, better switch to DateTime
if ($contact['term-date'] <= NULL_DATE) {
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),

View file

@ -33,11 +33,10 @@ class DirSearch {
$ostatus = NETWORK_DFRN;
// check if we search only communities or every contact
if ($mode === "community") {
if($mode === "community")
$extra_sql = " AND `community`";
} else {
else
$extra_sql = "";
}
$search .= "%";

View file

@ -154,16 +154,12 @@ class ForumManager {
foreach($contacts as $contact) {
$forumlist .= micropro($contact,false,'forumlist-profile-advanced');
$total_shown ++;
if ($total_shown == $show_total) {
if($total_shown == $show_total)
break;
}
}
if (count($contacts) > 0) {
if(count($contacts) > 0)
$o .= $forumlist;
}
return $o;
}

View file

@ -1133,17 +1133,15 @@ class Probe {
$password = '';
openssl_private_decrypt(hex2bin($r[0]['pass']), $password,$x[0]['prvkey']);
$mbox = email_connect($mailbox,$r[0]['user'], $password);
if (!$mbox) {
if(!mbox)
return false;
}
}
$msgs = email_poll($mbox, $uri);
logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG);
if (!count($msgs)) {
if (!count($msgs))
return false;
}
$data = array();
@ -1159,11 +1157,10 @@ class Probe {
$data["poll"] = 'email '.random_string();
$x = email_msg_meta($mbox, $msgs[0]);
if (stristr($x[0]->from, $uri)) {
if(stristr($x[0]->from, $uri))
$adr = imap_rfc822_parse_adrlist($x[0]->from, '');
} elseif (stristr($x[0]->to, $uri)) {
elseif(stristr($x[0]->to, $uri))
$adr = imap_rfc822_parse_adrlist($x[0]->to, '');
}
if(isset($adr)) {
foreach($adr as $feadr) {
if((strcasecmp($feadr->mailbox, $data["name"]) == 0)
@ -1172,13 +1169,11 @@ class Probe {
$personal = imap_mime_header_decode($feadr->personal);
$data["name"] = "";
foreach ($personal as $perspart) {
if ($perspart->charset != "default") {
foreach($personal as $perspart)
if ($perspart->charset != "default")
$data["name"] .= iconv($perspart->charset, 'UTF-8//IGNORE', $perspart->text);
} else {
else
$data["name"] .= $perspart->text;
}
}
$data["name"] = notags($data["name"]);
}

View file

@ -170,13 +170,11 @@ class Smilies {
* @todo: Rework because it doesn't work correctly
*/
private function preg_heart($x) {
if (strlen($x[1]) == 1) {
if(strlen($x[1]) == 1)
return $x[0];
}
$t = '';
for ($cnt = 0; $cnt < strlen($x[1]); $cnt ++) {
for($cnt = 0; $cnt < strlen($x[1]); $cnt ++)
$t .= '<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-heart.gif" alt="&lt;3" />';
}
$r = str_replace($x[0],$t,$x[0]);
return $r;
}

View file

@ -121,9 +121,8 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
$sql_extra .= sprintf(" AND `id` != %d ", intval($x['exclude']));
if(is_array($x['networks']) && count($x['networks'])) {
for ($y = 0; $y < count($x['networks']) ; $y ++) {
for($y = 0; $y < count($x['networks']) ; $y ++)
$x['networks'][$y] = "'" . dbesc($x['networks'][$y]) . "'";
}
$str_nets = implode(',',$x['networks']);
$sql_extra .= " AND `network` IN ( $str_nets ) ";
}

View file

@ -219,20 +219,17 @@ function bb_find_open_close($s, $open, $close, $occurance = 1) {
$start_pos = -1;
for($i = 1; $i <= $occurance; $i++) {
if ( $start_pos !== false) {
if( $start_pos !== false)
$start_pos = strpos($s, $open, $start_pos + 1);
}
}
if ( $start_pos === false) {
if( $start_pos === false)
return false;
}
$end_pos = strpos($s, $close, $start_pos);
if ( $end_pos === false) {
if( $end_pos === false)
return false;
}
$res = array( 'start' => $start_pos, 'end' => $end_pos );
@ -246,10 +243,9 @@ function get_bb_tag_pos($s, $name, $occurance = 1) {
$start_open = -1;
for($i = 1; $i <= $occurance; $i++) {
if ( $start_open !== false) {
if( $start_open !== false)
$start_open = strpos($s, '[' . $name, $start_open + 1); // allow [name= type tags
}
}
if( $start_open === false)
return false;

View file

@ -173,7 +173,6 @@ function categories_widget($baseurl,$selected = '') {
$matches = false;
$terms = array();
$cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$unescaped = xmlify(file_tag_decode($mtch[1]));
@ -216,9 +215,9 @@ function common_friends_visitor_widget($profile_uid) {
dbesc(normalise_link(get_my_url())),
intval($profile_uid)
);
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$cid = $r[0]['id'];
} else {
else {
$r = q("select id from gcontact where nurl = '%s' limit 1",
dbesc(normalise_link(get_my_url()))
);
@ -228,26 +227,22 @@ function common_friends_visitor_widget($profile_uid) {
}
}
if ($cid == 0 && $zcid == 0) {
if($cid == 0 && $zcid == 0)
return;
}
require_once('include/socgraph.php');
if ($cid) {
if($cid)
$t = count_common_friends($profile_uid,$cid);
} else {
else
$t = count_common_friends_zcid($profile_uid,$zcid);
}
if (! $t) {
if(! $t)
return;
}
if ($cid) {
if($cid)
$r = common_friends($profile_uid,$cid,0,5,true);
} else {
else
$r = common_friends_zcid($profile_uid,$zcid,0,5,true);
}
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),

View file

@ -309,11 +309,10 @@ function localize_item(&$item){
$matches = null;
if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
foreach($matches as $mtch) {
if (! strpos($mtch[1],'zrl=')) {
if(! strpos($mtch[1],'zrl='))
$item['body'] = str_replace($mtch[0],'@[url=' . zrl($mtch[1]). ']',$item['body']);
}
}
}
// add zrl's to public images
$photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
@ -485,10 +484,9 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$str_blocked = get_pconfig(local_user(),'system','blocked');
if($str_blocked) {
$arr_blocked = explode(',',$str_blocked);
for ($x = 0; $x < count($arr_blocked); $x ++) {
for($x = 0; $x < count($arr_blocked); $x ++)
$arr_blocked[$x] = trim($arr_blocked[$x]);
}
}
}
@ -1361,23 +1359,18 @@ function conv_sort($arr,$order) {
$arr = $newarr;
foreach ($arr as $x) {
if ($x['id'] == $x['parent']) {
foreach($arr as $x)
if($x['id'] == $x['parent'])
$parents[] = $x;
}
}
if (stristr($order,'created')) {
if(stristr($order,'created'))
usort($parents,'sort_thr_created');
} elseif (stristr($order,'commented')) {
elseif(stristr($order,'commented'))
usort($parents,'sort_thr_commented');
}
if (count($parents)) {
foreach($parents as $i=>$_x) {
if(count($parents))
foreach($parents as $i=>$_x)
$parents[$i]['children'] = get_item_children($arr, $_x);
}
}
/*foreach($arr as $x) {
if($x['id'] != $x['parent']) {
@ -1425,11 +1418,9 @@ function sort_thr_commented($a,$b) {
}
function find_thread_parent_index($arr,$x) {
foreach ($arr as $k => $v) {
if ($v['id'] == $x['parent']) {
foreach($arr as $k => $v)
if($v['id'] == $x['parent'])
return $k;
}
}
return false;
}
@ -1452,7 +1443,8 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'
. (($ob) ? $ob->get_id() : $item['id']) . '"><b>' . t('View all') . '</b></a>');
} else {
}
else {
$ret[$v]['list_part'] = '';
}
$ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']);
@ -1461,10 +1453,9 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
$count = 0;
foreach($ret as $key) {
if ($key['count'] == true) {
if ($key['count'] == true)
$count++;
}
}
$ret['count'] = $count;
return $ret;

View file

@ -292,13 +292,11 @@ function cron_clear_cache(App $a) {
if($last) {
$next = $last + (3600); // Once per hour
$clear_cache = ($next <= time());
} else {
} else
$clear_cache = true;
}
if (!$clear_cache) {
if (!$clear_cache)
return;
}
// clear old cache
Cache::clear();
@ -317,9 +315,7 @@ function cron_clear_cache(App $a) {
clear_cache($a->get_basepath(), $a->get_basepath()."/proxy");
$cachetime = get_config('system','proxy_cache_time');
if (!$cachetime) {
$cachetime = PROXY_DEFAULT_TIME;
}
if (!$cachetime) $cachetime = PROXY_DEFAULT_TIME;
q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%" AND `created` < NOW() - INTERVAL %d SECOND', $cachetime);
}
@ -332,30 +328,26 @@ function cron_clear_cache(App $a) {
// Maximum table size in megabyte
$max_tablesize = intval(get_config('system','optimize_max_tablesize')) * 1000000;
if ($max_tablesize == 0) {
if ($max_tablesize == 0)
$max_tablesize = 100 * 1000000; // Default are 100 MB
}
if ($max_tablesize > 0) {
// Minimum fragmentation level in percent
$fragmentation_level = intval(get_config('system','optimize_fragmentation')) / 100;
if ($fragmentation_level == 0) {
if ($fragmentation_level == 0)
$fragmentation_level = 0.3; // Default value is 30%
}
// Optimize some tables that need to be optimized
$r = q("SHOW TABLE STATUS");
foreach($r as $table) {
// Don't optimize tables that are too large
if ($table["Data_length"] > $max_tablesize) {
if ($table["Data_length"] > $max_tablesize)
continue;
}
// Don't optimize empty tables
if ($table["Data_length"] == 0) {
if ($table["Data_length"] == 0)
continue;
}
// Calculate fragmentation
$fragmentation = $table["Data_free"] / ($table["Data_length"] + $table["Index_length"]);
@ -363,9 +355,8 @@ function cron_clear_cache(App $a) {
logger("Table ".$table["Name"]." - Fragmentation level: ".round($fragmentation * 100, 2), LOGGER_DEBUG);
// Don't optimize tables that needn't to be optimized
if ($fragmentation < $fragmentation_level) {
if ($fragmentation < $fragmentation_level)
continue;
}
// So optimize it
logger("Optimize Table ".$table["Name"], LOGGER_DEBUG);
@ -425,11 +416,9 @@ function cron_repair_database() {
// Update the global contacts for local users
$r = q("SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired`");
if (dbm::is_result($r)) {
foreach ($r AS $user) {
if (dbm::is_result($r))
foreach ($r AS $user)
update_gcontact_for_user($user["uid"]);
}
}
/// @todo
/// - remove thread entries without item

View file

@ -8,21 +8,19 @@ function cronhooks_run(&$argv, &$argc){
require_once('include/datetime.php');
if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
foreach ($a->hooks["cron"] as $hook) {
foreach ($a->hooks["cron"] as $hook)
if ($hook[1] == $argv[1]) {
logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG);
call_single_hook($a, $name, $hook, $data);
}
}
return;
}
$last = get_config('system', 'last_cronhook');
$poll_interval = intval(get_config('system','cronhook_interval'));
if (! $poll_interval) {
if(! $poll_interval)
$poll_interval = 9;
}
if($last) {
$next = $last + ($poll_interval * 60);

View file

@ -48,12 +48,12 @@ function select_timezone($current = 'America/Los_Angeles') {
$continent = $ex[0];
$o .= '<optgroup label="' . t($continent) . '">';
}
if (count($ex) > 2) {
if(count($ex) > 2)
$city = substr($value,strpos($value,'/')+1);
} else {
else
$city = $ex[1];
}
} else {
else {
$city = $ex[0];
if($continent != t('Miscellaneous')) {
$o .= '</optgroup>';
@ -486,12 +486,10 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
$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 = $thisyear;
}
if (! $m) {
if(! $m)
$m = intval($thismonth);
}
$dn = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$f = get_first_dim($y,$m);
@ -500,33 +498,29 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
$dow = 0;
$started = false;
if (($y == $thisyear) && ($m == $thismonth)) {
if(($y == $thisyear) && ($m == $thismonth))
$tddate = intval(datetime_convert('UTC',date_default_timezone_get(),'now','j'));
}
$str_month = day_translate($mtab[$m]);
$o = '<table class="calendar' . $class . '">';
$o .= "<caption>$str_month $y</caption><tr>";
for ($a = 0; $a < 7; $a ++) {
for($a = 0; $a < 7; $a ++)
$o .= '<th>' . mb_substr(day_translate($dn[$a]),0,3,'UTF-8') . '</th>';
}
$o .= '</tr><tr>';
while($d <= $l) {
if (($dow == $f) && (! $started)) {
if(($dow == $f) && (! $started))
$started = true;
}
$today = (((isset($tddate)) && ($tddate == $d)) ? "class=\"today\" " : '');
$o .= "<td $today>";
$day = str_replace(' ','&nbsp;',sprintf('%2.2d', $d));
if($started) {
if (is_array($links) && isset($links[$d])) {
if(is_array($links) && isset($links[$d]))
$o .= "<a href=\"{$links[$d]}\">$day</a>";
} else {
else
$o .= $day;
}
$d ++;
} else {
@ -540,11 +534,9 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
$o .= '</tr><tr>';
}
}
if ($dow) {
for ($a = $dow; $a < 7; $a ++) {
if($dow)
for($a = $dow; $a < 7; $a ++)
$o .= '<td>&nbsp;</td>';
}
}
$o .= '</tr></table>'."\r\n";

File diff suppressed because it is too large Load diff

View file

@ -3632,20 +3632,17 @@ class Diaspora {
}
$r = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($contact['uid']));
if (!dbm::is_result($r)) {
if(!$r)
return false;
}
$contact["uprvkey"] = $r[0]['prvkey'];
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($post_id));
if (!dbm::is_result($r)) {
if (!$r)
return false;
}
if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE)))
return false;
}
$message = self::construct_like($r[0], $contact);
$message["author_signature"] = self::signature($contact, $message);

View file

@ -192,7 +192,7 @@ function discover_directory($search) {
foreach($j->results as $jj) {
// Check if the contact already exists
$exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
if (dbm::is_result($exists)) {
if ($exists) {
logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND
@ -245,13 +245,11 @@ function gs_search_user($search) {
if (!$result["success"]) {
return false;
}
$contacts = json_decode($result["body"]);
if ($contacts->status == 'ERROR') {
return false;
}
foreach($contacts->data AS $user) {
$contact = probe_url($user->site_address."/".$user->name);
if ($contact["network"] != NETWORK_PHANTOM) {

View file

@ -411,12 +411,10 @@ function notification($params) {
$hash = random_string();
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
dbesc($hash));
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$dups = true;
}
} while($dups == true);
/// @TODO One statement is enough
$datarray = array();
$datarray['hash'] = $hash;
$datarray['name'] = $params['source_name'];

View file

@ -11,13 +11,12 @@ function expire_run(&$argv, &$argc){
// physically remove anything that has been deleted for more than two months
$r = q("DELETE FROM `item` WHERE `deleted` = 1 AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY");
$r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
// make this optional as it could have a performance impact on large sites
if (intval(get_config('system','optimize_items'))) {
q("OPTIMIZE TABLE `item`");
}
if(intval(get_config('system','optimize_items')))
q("optimize table item");
logger('expire: start');

View file

@ -289,9 +289,8 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
$type = $attributes->textContent;
}
}
if (strlen($item["attach"])) {
if(strlen($item["attach"]))
$item["attach"] .= ',';
}
$attachments[] = array("link" => $href, "type" => $type, "length" => $length);

View file

@ -347,10 +347,9 @@ function groups_containing($uid,$c) {
$ret = array();
if (dbm::is_result($r)) {
foreach ($r as $rr) {
foreach($r as $rr)
$ret[] = $rr['gid'];
}
}
return $ret;
}

View file

@ -878,20 +878,16 @@ function zrl_init(App $a) {
}
function zrl($s,$force = false) {
if (! strlen($s)) {
if(! strlen($s))
return $s;
}
if ((! strpos($s,'/profile/')) && (! $force)) {
if((! strpos($s,'/profile/')) && (! $force))
return $s;
}
if ($force && substr($s,-1,1) !== '/') {
if($force && substr($s,-1,1) !== '/')
$s = $s . '/';
}
$achar = strpos($s,'?') ? '&' : '?';
$mine = get_my_url();
if ($mine and ! link_compare($mine,$s)) {
if($mine and ! link_compare($mine,$s))
return $s . $achar . 'zrl=' . urlencode($mine);
}
return $s;
}
@ -912,10 +908,9 @@ function zrl($s,$force = false) {
function get_theme_uid() {
$uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0);
if(local_user()) {
if ((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid)) {
if((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid))
return local_user();
}
}
return $uid;
}

View file

@ -57,9 +57,8 @@ function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) {
dbesc($fn_name)
);
if (dbm::is_result($r) && $r[0]['locked']) {
if (dbm::is_result($r) && $r[0]['locked'])
sleep($wait_sec);
}
} while(dbm::is_result($r) && $r[0]['locked'] && ((time() - $start) < $timeout));

View file

@ -497,15 +497,14 @@ function allowed_url($url) {
*/
function allowed_email($email) {
$domain = strtolower(substr($email,strpos($email,'@') + 1));
if (! $domain) {
if(! $domain)
return false;
}
$str_allowed = get_config('system','allowed_email');
if (! $str_allowed) {
if(! $str_allowed)
return true;
}
$found = false;

View file

@ -316,9 +316,7 @@ function oembed_html2bbcode($text) {
$xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed");
foreach($entries as $e) {
$href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue;
if (!is_null($href)) {
$e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
}
if(!is_null($href)) $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
}
return oe_get_inner_html( $dom->getElementsByTagName("body")->item(0) );
} else {

View file

@ -61,7 +61,7 @@ function onepoll_run(&$argv, &$argc){
intval($contact_id)
);
if (! dbm::is_result($contacts)) {
if (! count($contacts)) {
return;
}
@ -437,19 +437,17 @@ function onepoll_run(&$argv, &$argc){
if ($raw_refs) {
$refs_arr = explode(' ', $raw_refs);
if (count($refs_arr)) {
for ($x = 0; $x < count($refs_arr); $x ++) {
for($x = 0; $x < count($refs_arr); $x ++)
$refs_arr[$x] = "'" . msgid2iri(str_replace(array('<','>',' '),array('','',''),dbesc($refs_arr[$x]))) . "'";
}
}
$qstr = implode(',',$refs_arr);
$r = q("SELECT `uri` , `parent-uri` FROM `item` USE INDEX (`uid_uri`) WHERE `uri` IN ($qstr) AND `uid` = %d LIMIT 1",
intval($importer_uid)
);
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$datarray['parent-uri'] = $r[0]['parent-uri']; // Set the parent as the top-level item
// $datarray['parent-uri'] = $r[0]['uri'];
}
}
// Decoding the header
$subject = imap_mime_header_decode($meta->subject);

File diff suppressed because it is too large Load diff

View file

@ -524,14 +524,12 @@ function service_class_fetch($uid,$property) {
function upgrade_link($bbcode = false) {
$l = get_config('service_class','upgrade_link');
if (! $l) {
if(! $l)
return '';
}
if ($bbcode) {
if($bbcode)
$t = sprintf('[url=%s]' . t('Click here to upgrade.') . '[/url]', $l);
} else {
else
$t = sprintf('<a href="%s">' . t('Click here to upgrade.') . '</div>', $l);
}
return $t;
}
@ -558,15 +556,13 @@ function upgrade_bool_message($bbcode = false) {
*/
function theme_include($file, $root = '') {
// Make sure $root ends with a slash / if it's not blank
if ($root !== '' && $root[strlen($root)-1] !== '/') {
if($root !== '' && $root[strlen($root)-1] !== '/')
$root = $root . '/';
}
$theme_info = $a->theme_info;
if (is_array($theme_info) AND array_key_exists('extends',$theme_info)) {
if(is_array($theme_info) AND array_key_exists('extends',$theme_info))
$parent = $theme_info['extends'];
} else {
else
$parent = 'NOPATH';
}
$theme = current_theme();
$thname = $theme;
$ext = substr($file,strrpos($file,'.')+1);
@ -577,11 +573,10 @@ function theme_include($file, $root = '') {
);
foreach($paths as $p) {
// strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php)
if (strpos($p,'NOPATH') !== false) {
if(strpos($p,'NOPATH') !== false)
continue;
} elseif (file_exists($p)) {
if(file_exists($p))
return $p;
}
}
return '';
}

View file

@ -364,7 +364,7 @@ function poller_kill_stale_workers() {
return;
}
foreach ($r AS $pid)
foreach ($r AS $pid) {
if (!posix_kill($pid["pid"], 0)) {
q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = 0 WHERE `pid` = %d",
dbesc(NULL_DATE), intval($pid["pid"]));
@ -372,9 +372,8 @@ function poller_kill_stale_workers() {
// Kill long running processes
// Check if the priority is in a valid range
if (!in_array($pid["priority"], array(PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE))) {
if (!in_array($pid["priority"], array(PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE)))
$pid["priority"] = PRIORITY_MEDIUM;
}
// Define the maximum durations
$max_duration_defaults = array(PRIORITY_CRITICAL => 360, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 360);

View file

@ -28,11 +28,9 @@ function handle_pubsubhubbub($id) {
global $a;
$r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
if (!dbm::is_result($r)) {
if (!$r)
return;
}
else
$rr = $r[0];
logger("Generate feed of user ".$rr['nickname']." to ".$rr['callback_url']." - last updated ".$rr['last_update'], LOGGER_DEBUG);
@ -67,10 +65,8 @@ function handle_pubsubhubbub($id) {
// increment this until some upper limit where we give up
$new_push = intval($rr['push']) + 1;
if ($new_push > 30) {
// OK, let's give up
if ($new_push > 30) // OK, let's give up
$new_push = 0;
}
q("UPDATE `push_subscriber` SET `push` = %d WHERE id = %d",
$new_push,

View file

@ -49,14 +49,12 @@ function was_recently_delayed($cid) {
function add_to_queue($cid,$network,$msg,$batch = false) {
$max_queue = get_config('system','max_contact_queue');
if ($max_queue < 1) {
if($max_queue < 1)
$max_queue = 500;
}
$batch_queue = get_config('system','max_batch_queue');
if ($batch_queue < 1) {
if($batch_queue < 1)
$batch_queue = 1000;
}
$r = q("SELECT COUNT(*) AS `total` FROM `queue` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
@ -66,7 +64,8 @@ function add_to_queue($cid,$network,$msg,$batch = false) {
if($batch && ($r[0]['total'] > $batch_queue)) {
logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message');
return;
} elseif ((! $batch) && ($r[0]['total'] > $max_queue)) {
}
elseif((! $batch) && ($r[0]['total'] > $max_queue)) {
logger('add_to_queue: too many queued items for contact ' . $cid . ' - discarding message');
return;
}

View file

@ -16,7 +16,8 @@ function get_salmon_key($uri,$keyhash) {
$ret[] = $a['@attributes']['href'];
}
}
} else {
}
else {
return '';
}
@ -68,9 +69,8 @@ function slapper($owner,$url,$slap) {
// does contact have a salmon endpoint?
if (! strlen($url)) {
if(! strlen($url))
return;
}
if(! $owner['sprvkey']) {
@ -169,12 +169,10 @@ function slapper($owner,$url,$slap) {
}
}
logger('slapper for '.$url.' returned ' . $return_code);
if (! $return_code) {
if(! $return_code)
return(-1);
}
if (($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after'))) {
if(($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after')))
return(-1);
}
return ((($return_code >= 200) && ($return_code < 300)) ? 0 : 1);
}

View file

@ -55,25 +55,21 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$a->user = $user_record;
if($interactive) {
/// @TODO Comparison of strings this way may lead to bugs/incompatiblities
if ($a->user['login_date'] <= NULL_DATE) {
$_SESSION['return_url'] = 'profile_photo/new';
$a->module = 'profile_photo';
info( t("Welcome ") . $a->user['username'] . EOL);
info( t('Please upload a profile photo.') . EOL);
} else {
info( t("Welcome back ") . $a->user['username'] . EOL);
}
else
info( t("Welcome back ") . $a->user['username'] . EOL);
}
$member_since = strtotime($a->user['register_date']);
if (time() < ($member_since + ( 60 * 60 * 24 * 14))) {
if(time() < ($member_since + ( 60 * 60 * 24 * 14)))
$_SESSION['new_member'] = true;
} else {
else
$_SESSION['new_member'] = false;
}
if(strlen($a->user['timezone'])) {
date_default_timezone_set($a->user['timezone']);
$a->timezone = $a->user['timezone'];
@ -362,10 +358,9 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
$gs = '<<>>'; // should be impossible to match
if(is_array($groups) && count($groups)) {
foreach ($groups as $g) {
foreach($groups as $g)
$gs .= '|<' . intval($g) . '>';
}
}
$sql = sprintf(
/*" AND ( private = 0 OR ( private in (1,2) AND wall = 1 AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' )

View file

@ -1664,22 +1664,20 @@ function poco_discover_federation() {
}
}
/*
* Currently disabled, since the service isn't available anymore.
* It is not removed since I hope that there will be a successor.
* Discover GNU Social Servers.
if (!get_config('system','ostatus_disabled')) {
$serverdata = "http://gstools.org/api/get_open_instances/";
// Currently disabled, since the service isn't available anymore.
// It is not removed since I hope that there will be a successor.
// Discover GNU Social Servers.
//if (!get_config('system','ostatus_disabled')) {
// $serverdata = "http://gstools.org/api/get_open_instances/";
$result = z_fetch_url($serverdata);
if ($result["success"]) {
$servers = json_decode($result["body"]);
// $result = z_fetch_url($serverdata);
// if ($result["success"]) {
// $servers = json_decode($result["body"]);
foreach($servers->data AS $server)
poco_check_server($server->instance_address);
}
}
*/
// foreach($servers->data AS $server)
// poco_check_server($server->instance_address);
// }
//}
set_config('poco','last_federation_discovery', time());
}

View file

@ -105,11 +105,10 @@ function create_tags_from_itemuri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
if(count($messages)) {
foreach ($messages as $message) {
foreach ($messages as $message)
create_tags_from_item($message["id"]);
}
}
}
function update_items() {
global $db;

View file

@ -53,9 +53,8 @@ class Template implements ITemplateEngine {
private function _get_var($name, $retNoKey = false) {
$keys = array_map('trim', explode(".", $name));
if ($retNoKey && !array_key_exists($keys[0], $this->r)) {
if ($retNoKey && !array_key_exists($keys[0], $this->r))
return KEY_NOT_EXISTS;
}
$val = $this->r;
foreach ($keys as $k) {
$val = (isset($val[$k]) ? $val[$k] : null);
@ -74,16 +73,14 @@ class Template implements ITemplateEngine {
if (strpos($args[2], "==") > 0) {
list($a, $b) = array_map("trim", explode("==", $args[2]));
$a = $this->_get_var($a);
if ($b[0] == "$") {
if ($b[0] == "$")
$b = $this->_get_var($b);
}
$val = ($a == $b);
} else if (strpos($args[2], "!=") > 0) {
list($a, $b) = array_map("trim", explode("!=", $args[2]));
$a = $this->_get_var($a);
if ($b[0] == "$") {
if ($b[0] == "$")
$b = $this->_get_var($b);
}
$val = ($a != $b);
} else {
$val = $this->_get_var($args[2]);
@ -112,16 +109,14 @@ class Template implements ITemplateEngine {
//$vals = $this->r[$m[0]];
$vals = $this->_get_var($m[0]);
$ret = "";
if (!is_array($vals)) {
if (!is_array($vals))
return $ret;
}
foreach ($vals as $k => $v) {
$this->_push_stack();
$r = $this->r;
$r[$varname] = $v;
if ($keyname != '') {
if ($keyname != '')
$r[$keyname] = (($k === 0) ? '0' : $k);
}
$ret .= $this->replace($args[3], $r);
$this->_pop_stack();
}
@ -141,9 +136,8 @@ class Template implements ITemplateEngine {
$newctx = null;
}
if ($tplfile[0] == "$") {
if ($tplfile[0] == "$")
$tplfile = $this->_get_var($tplfile);
}
$this->_push_stack();
$r = $this->r;

View file

@ -421,11 +421,10 @@ function expand_acl($s) {
$t = str_replace('<','',$s);
$a = explode('>',$t);
foreach($a as $aa) {
if (intval($aa)) {
if(intval($aa))
$ret[] = intval($aa);
}
}
}
return $ret;
}}

View file

@ -174,34 +174,29 @@ function add_shadow_entry($itemid) {
function update_thread_uri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
if (dbm::is_result($messages)) {
foreach ($messages as $message) {
if (dbm::is_result($messages))
foreach ($messages as $message)
update_thread($message["id"]);
}
}
}
function update_thread($itemid, $setmention = false) {
$items = q("SELECT `uid`, `guid`, `title`, `body`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
`deleted`, `origin`, `forum_mode`, `network`, `rendered-html`, `rendered-hash` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
if (!dbm::is_result($items)) {
if (!dbm::is_result($items))
return;
}
$item = $items[0];
if ($setmention) {
if ($setmention)
$item["mention"] = 1;
}
$sql = "";
foreach ($item AS $field => $data)
if (!in_array($field, array("guid", "title", "body", "rendered-html", "rendered-hash"))) {
if ($sql != "") {
if ($sql != "")
$sql .= ", ";
}
$sql .= "`".$field."` = '".dbesc($data)."'";
}
@ -213,9 +208,8 @@ function update_thread($itemid, $setmention = false) {
// Updating a shadow item entry
$items = q("SELECT `id` FROM `item` WHERE `guid` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item["guid"]));
if (!dbm::is_result($items)) {
if (!$items)
return;
}
$result = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s' WHERE `id` = %d",
dbesc($item["title"]),
@ -230,12 +224,10 @@ function update_thread($itemid, $setmention = false) {
function delete_thread_uri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
if (dbm::is_result($messages)) {
foreach ($messages as $message) {
if(count($messages))
foreach ($messages as $message)
delete_thread($message["id"], $itemuri);
}
}
}
function delete_thread($itemid, $itemuri = "") {
$item = q("SELECT `uid` FROM `thread` WHERE `iid` = %d", intval($itemid));

View file

@ -21,41 +21,35 @@ function update_gcontact_run(&$argv, &$argc){
$r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
if (!dbm::is_result($r)) {
if (!$r)
return;
}
if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) }
if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
return;
}
$data = probe_url($r[0]["url"]);
if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
if ($r[0]["server_url"] != "") {
if ($r[0]["server_url"] != "")
poco_check_server($r[0]["server_url"], $r[0]["network"]);
}
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()), intval($contact_id));
return;
}
if (($data["name"] == "") AND ($r[0]['name'] != "")) {
if (($data["name"] == "") AND ($r[0]['name'] != ""))
$data["name"] = $r[0]['name'];
}
if (($data["nick"] == "") AND ($r[0]['nick'] != "")) {
if (($data["nick"] == "") AND ($r[0]['nick'] != ""))
$data["nick"] = $r[0]['nick'];
}
if (($data["addr"] == "") AND ($r[0]['addr'] != "")) {
if (($data["addr"] == "") AND ($r[0]['addr'] != ""))
$data["addr"] = $r[0]['addr'];
}
if (($data["photo"] == "") AND ($r[0]['photo'] != "")) {
if (($data["photo"] == "") AND ($r[0]['photo'] != ""))
$data["photo"] = $r[0]['photo'];
}
q("UPDATE `gcontact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'
WHERE `id` = %d",

View file

@ -28,17 +28,17 @@ $a->backend = false;
/**
*
* Load the configuration file which contains our DB credentials.
* Ignore errors. If the file doesn't exist or is empty, we are running in
* installation mode.
* Ignore errors. If the file doesn't exist or is empty, we are running in installation mode.
*
*/
$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true);
// Only load config if found, don't surpress errors
if (!$install) {
include(".htconfig.php");
}
@include(".htconfig.php");
/**
*
@ -233,14 +233,12 @@ if (strlen($a->module)) {
*/
// Compatibility with the Android Diaspora client
if ($a->module == "stream") {
if ($a->module == "stream")
$a->module = "network";
}
// Compatibility with the Firefox App
if (($a->module == "users") AND ($a->cmd == "users/sign_in")) {
if (($a->module == "users") AND ($a->cmd == "users/sign_in"))
$a->module = "login";
}
$privateapps = get_config('config','private_addons');
@ -248,11 +246,11 @@ if (strlen($a->module)) {
//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") {
info( t("You must be logged in to use addons. "));
} else {
include_once("addon/{$a->module}/{$a->module}.php");
if (function_exists($a->module . '_module')) {
$a->module_loaded = true;
}
else {
include_once("addon/{$a->module}/{$a->module}.php");
if(function_exists($a->module . '_module'))
$a->module_loaded = true;
}
}
@ -394,15 +392,13 @@ $a->init_page_end();
// If you're just visiting, let javascript take you home
if (x($_SESSION,'visitor_home')) {
if(x($_SESSION,'visitor_home'))
$homebase = $_SESSION['visitor_home'];
} elseif (local_user()) {
elseif(local_user())
$homebase = 'profile/' . $a->user['nickname'];
}
if (isset($homebase)) {
if(isset($homebase))
$a->page['content'] .= '<script>var homebase="' . $homebase . '" ; </script>';
}
// now that we've been through the module content, see if the page reported
// a permission problem and if so, a 403 response would seem to be in order.
@ -452,7 +448,8 @@ if ($a->module != 'install' && $a->module != 'maintenance') {
if($a->is_mobile || $a->is_tablet) {
if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
$link = 'toggle_mobile?address=' . curPageURL();
} else {
}
else {
$link = 'toggle_mobile?off=1&address=' . curPageURL();
}
$a->page['footer'] = replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
@ -465,11 +462,10 @@ if ($a->is_mobile || $a->is_tablet) {
* Build the page - now that we have all the components
*/
if (!$a->theme['stylesheet']) {
if(!$a->theme['stylesheet'])
$stylesheet = current_theme_url();
} else {
else
$stylesheet = $a->theme['stylesheet'];
}
$a->page['htmlhead'] = str_replace('{{$stylesheet}}',$stylesheet,$a->page['htmlhead']);
//$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet));
@ -503,9 +499,8 @@ if (isset($_GET["mode"]) AND ($_GET["mode"] == "raw")) {
echo substr($target->saveHTML(), 6, -8);
if (!$a->is_backend()) {
if (!$a->is_backend())
session_write_close();
}
exit;
}

View file

@ -859,9 +859,8 @@ function admin_page_site(App $a) {
$allowed_theme_list = Config::get('system', 'allowed_themes');
foreach ($files as $file) {
if (file_exists($file.'/unsupported'))
if (intval(file_exists($file.'/unsupported')))
continue;
}
$f = basename($file);
@ -1275,7 +1274,7 @@ function admin_page_users(App $a) {
if ($a->argc>2) {
$uid = $a->argv[3];
$user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid));
if (!dbm::is_result($user)) {
if (count($user) == 0) {
notice('User not found'.EOL);
goaway('admin/users');
return ''; // NOTREACHED
@ -1707,9 +1706,9 @@ function admin_page_themes(App $a) {
continue;
}
$is_experimental = file_exists($file.'/experimental');
$is_supported = (!file_exists($file.'/unsupported'));
$is_allowed = in_array($f,$allowed_themes);
$is_experimental = intval(file_exists($file.'/experimental'));
$is_supported = 1-(intval(file_exists($file.'/unsupported')));
$is_allowed = intval(in_array($f,$allowed_themes));
if ($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes")) {
$themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
@ -1762,7 +1761,7 @@ function admin_page_themes(App $a) {
$status="off"; $action= t("Enable");
}
$readme = null;
$readme = Null;
if (is_file("view/theme/$theme/README.md")) {
$readme = file_get_contents("view/theme/$theme/README.md");
$readme = Markdown($readme);

View file

@ -37,9 +37,8 @@ function allfriends_content(App $a) {
$total = count_all_friends(local_user(), $cid);
if (count($total)) {
if(count($total))
$a->set_pager_total($total);
}
$r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);

View file

@ -5,19 +5,21 @@ function apps_content(App $a) {
if ($privateaddons === "1") {
if((! (local_user()))) {
info( t("You must be logged in to use addons. "));
return;
}
return;};
}
$title = t('Applications');
if (count($a->apps) == 0) {
if(count($a->apps)==0)
notice( t('No installed applications.') . EOL);
}
$tpl = get_markup_template("apps.tpl");
return replace_macros($tpl, array(
'$title' => $title,
'$apps' => $a->apps,
));
}

View file

@ -69,7 +69,6 @@ function cal_content(App $a) {
// First day of the week (0 = Sunday)
$firstDay = get_pconfig(local_user(),'system','first_day_of_week');
/// @TODO Convert all these to with curly braces
if ($firstDay === false) $firstDay=0;
// get the translation strings for the callendar
@ -95,7 +94,6 @@ function cal_content(App $a) {
$m = 0;
$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
/// @TODO Convert to one if() statement
if($a->argc == 4) {
if($a->argv[2] == 'export') {
$mode = 'export';
@ -237,10 +235,9 @@ function cal_content(App $a) {
$events=array();
// transform the event in a usable array
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$r = sort_by_date($r);
$events = process_events($r);
}
if ($a->argv[2] === 'json'){
echo json_encode($events); killme();

View file

@ -63,18 +63,17 @@ function common_content(App $a) {
dbesc(normalise_link(get_my_url())),
intval($profile_uid)
);
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$cid = $r[0]['id'];
} else {
else {
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link(get_my_url()))
);
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$zcid = $r[0]['id'];
}
}
}
}
if ($cid == 0 && $zcid == 0) {
return;

View file

@ -79,9 +79,8 @@ function community_content(App $a, $update = 0) {
$r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage']);
} while ((sizeof($s) < $a->pager['itemspage']) AND (++$count < 50) AND (sizeof($r) > 0));
} else {
} else
$s = $r;
}
// we behave the same in message lists as the search module

View file

@ -14,10 +14,9 @@ function contactgroup_content(App $a) {
intval($a->argv[2]),
intval(local_user())
);
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$change = intval($a->argv[2]);
}
}
if(($a->argc > 1) && (intval($a->argv[1]))) {
@ -33,15 +32,15 @@ function contactgroup_content(App $a) {
$members = group_get_members($group['id']);
$preselected = array();
if(count($members)) {
foreach ($members as $member) {
foreach($members as $member)
$preselected[] = $member['id'];
}
}
if($change) {
if(in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change);
} else {
}
else {
group_add_member(local_user(),$group['name'],$change);
}
}

View file

@ -99,22 +99,13 @@ function contacts_init(App $a) {
function contacts_batch_actions(App $a) {
$contacts_id = $_POST['contact_batch'];
if (!is_array($contacts_id)) {
return;
}
if (!is_array($contacts_id)) return;
$orig_records = q("SELECT * FROM `contact` WHERE `id` IN (%s) AND `uid` = %d AND `self` = 0",
implode(",", $contacts_id),
intval(local_user())
);
if (!dbm::is_result($orig_records)) {
/// @TODO EOL really needed?
notice( t('Could not access contact record(s).') . EOL);
goaway('contacts');
return; // NOTREACHED
}
$count_actions=0;
foreach($orig_records as $orig_record) {
$contact_id = $orig_record['id'];
@ -139,14 +130,14 @@ function contacts_batch_actions(App $a) {
$count_actions++;
}
}
if ($count_actions>0) {
info ( sprintf( tt("%d contact edited.", "%d contacts edited.", $count_actions), $count_actions) );
}
if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']);
} else {
}
else {
goaway('contacts');
}
@ -174,8 +165,7 @@ function contacts_post(App $a) {
intval(local_user())
);
if (! dbm::is_result($orig_record)) {
/// @TODO EOL really needed?
if (! count($orig_record)) {
notice( t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
@ -204,10 +194,8 @@ function contacts_post(App $a) {
$ffi_keyword_blacklist = escape_tags(trim($_POST['ffi_keyword_blacklist']));
$priority = intval($_POST['poll']);
if ($priority > 5 || $priority < 0) {
if($priority > 5 || $priority < 0)
$priority = 0;
}
$info = escape_tags(trim($_POST['info']));
@ -224,21 +212,17 @@ function contacts_post(App $a) {
intval($contact_id),
intval(local_user())
);
/// @TODO Decide to use dbm::is_result() here, what does $r include?
if ($r) {
if($r)
info( t('Contact updated.') . EOL);
} else {
else
notice( t('Failed to update contact record.') . EOL);
}
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
$r = q("select * from contact where id = %d and uid = %d limit 1",
intval($contact_id),
intval(local_user())
);
if (dbm::is_result($r)) {
if($r && dbm::is_result($r))
$a->data['contact'] = $r[0];
}
return;
@ -247,47 +231,40 @@ function contacts_post(App $a) {
/*contact actions*/
function _contact_update($contact_id) {
$r = q("SELECT `uid`, `url`, `network` FROM `contact` WHERE `id` = %d", intval($contact_id));
if (!dbm::is_result($r)) {
if (!$r)
return;
}
$uid = $r[0]["uid"];
if ($uid != local_user()) {
if ($uid != local_user())
return;
}
if ($r[0]["network"] == NETWORK_OSTATUS) {
$result = new_contact($uid, $r[0]["url"], false);
if ($result['success']) {
if ($result['success'])
$r = q("UPDATE `contact` SET `subhub` = 1 WHERE `id` = %d",
intval($contact_id));
}
} else {
} else
// pull feed and consume it, which should subscribe to the hub.
proc_run(PRIORITY_HIGH, "include/onepoll.php", $contact_id, "force");
}
}
function _contact_update_profile($contact_id) {
$r = q("SELECT `uid`, `url`, `network` FROM `contact` WHERE `id` = %d", intval($contact_id));
if (!dbm::is_result($r)) {
if (!$r)
return;
}
$uid = $r[0]["uid"];
if ($uid != local_user()) {
if ($uid != local_user())
return;
}
$data = probe_url($r[0]["url"]);
// "Feed" or "Unknown" is mostly a sign of communication problems
if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) AND ($data["network"] != $r[0]["network"])) {
if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) AND ($data["network"] != $r[0]["network"]))
return;
}
$updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm",
"poco", "network", "alias");
@ -296,36 +273,30 @@ function _contact_update_profile($contact_id) {
if ($data["network"] == NETWORK_OSTATUS) {
$result = new_contact($uid, $data["url"], false);
if ($result['success']) {
if ($result['success'])
$update["subhub"] = true;
}
}
foreach ($updatefields AS $field) {
if (isset($data[$field]) AND ($data[$field] != "")) {
foreach($updatefields AS $field)
if (isset($data[$field]) AND ($data[$field] != ""))
$update[$field] = $data[$field];
}
}
$update["nurl"] = normalise_link($data["url"]);
$query = "";
if (isset($data["priority"]) AND ($data["priority"] != 0)) {
if (isset($data["priority"]) AND ($data["priority"] != 0))
$query = "`priority` = ".intval($data["priority"]);
}
foreach($update AS $key => $value) {
if ($query != "") {
if ($query != "")
$query .= ", ";
}
$query .= "`".$key."` = '".dbesc($value)."'";
}
if ($query == "") {
if ($query == "")
return;
}
$r = q("UPDATE `contact` SET $query WHERE `id` = %d AND `uid` = %d",
intval($contact_id),
@ -393,9 +364,8 @@ function contacts_content(App $a) {
if($a->argc == 3) {
$contact_id = intval($a->argv[1]);
if (! $contact_id) {
if(! $contact_id)
return;
}
$cmd = $a->argv[2];
@ -404,7 +374,7 @@ function contacts_content(App $a) {
intval(local_user())
);
if (! dbm::is_result($orig_record)) {
if(! count($orig_record)) {
notice( t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
@ -424,7 +394,6 @@ function contacts_content(App $a) {
if($cmd === 'block') {
$r = _contact_block($contact_id, $orig_record[0]);
/// @TODO is $r a database result?
if ($r) {
$blocked = (($orig_record[0]['blocked']) ? 0 : 1);
info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL);
@ -436,7 +405,6 @@ function contacts_content(App $a) {
if($cmd === 'ignore') {
$r = _contact_ignore($contact_id, $orig_record[0]);
/// @TODO is $r a database result?
if ($r) {
$readonly = (($orig_record[0]['readonly']) ? 0 : 1);
info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL);
@ -449,7 +417,6 @@ function contacts_content(App $a) {
if($cmd === 'archive') {
$r = _contact_archive($contact_id, $orig_record[0]);
/// @TODO is $r a database result?
if ($r) {
$archived = (($orig_record[0]['archive']) ? 0 : 1);
info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL);
@ -492,7 +459,8 @@ function contacts_content(App $a) {
if ($_REQUEST['canceled']) {
if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']);
} else {
}
else {
goaway('contacts');
}
}
@ -501,7 +469,8 @@ function contacts_content(App $a) {
info( t('Contact has been removed.') . EOL );
if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']);
} else {
}
else {
goaway('contacts');
}
return; // NOTREACHED
@ -569,7 +538,7 @@ function contacts_content(App $a) {
? t('Never')
: datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A'));
if ($contact['last-update'] !== NULL_DATE) {
if ($contact['last-update'] > NULL_DATE) {
$last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));
}
$lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : '');
@ -595,22 +564,20 @@ function contacts_content(App $a) {
$fetch_further_information = array('fetch_further_information', t('Fetch further information for feeds'), $contact['fetch_further_information'], t('Fetch further information for feeds'),
array('0'=>t('Disabled'), '1'=>t('Fetch information'), '2'=>t('Fetch information and keywords')));
}
if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2))) {
if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2)))
$poll_interval = contact_poll_interval($contact['priority'],(! $poll_enabled));
}
if ($contact['network'] == NETWORK_DFRN) {
if ($contact['network'] == NETWORK_DFRN)
$profile_select = contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false));
}
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND
($contact['rel'] == CONTACT_IS_FOLLOWER)) {
($contact['rel'] == CONTACT_IS_FOLLOWER))
$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);
$o .= replace_macros($tpl, array(
//'$header' => t('Contact Editor'),
'$header' => t("Contact"),
@ -697,21 +664,25 @@ function contacts_content(App $a) {
if(($a->argc == 2) && ($a->argv[1] === 'all')) {
$sql_extra = '';
$all = true;
} elseif (($a->argc == 2) && ($a->argv[1] === 'blocked')) {
}
elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
$sql_extra = " AND `blocked` = 1 ";
$blocked = true;
} elseif (($a->argc == 2) && ($a->argv[1] === 'hidden')) {
}
elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
$sql_extra = " AND `hidden` = 1 ";
$hidden = true;
} elseif (($a->argc == 2) && ($a->argv[1] === 'ignored')) {
}
elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
$sql_extra = " AND `readonly` = 1 ";
$ignored = true;
} elseif (($a->argc == 2) && ($a->argv[1] === 'archived')) {
}
elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
$sql_extra = " AND `archive` = 1 ";
$archived = true;
} else {
$sql_extra = " AND `blocked` = 0 ";
}
else
$sql_extra = " AND `blocked` = 0 ";
$search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
$nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : '');
@ -783,6 +754,8 @@ function contacts_content(App $a) {
$tab_tpl = get_markup_template('common_tabs.tpl');
$t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
$searching = false;
if($search) {
$search_hdr = $search;
@ -791,12 +764,12 @@ function contacts_content(App $a) {
}
$sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt' OR nick REGEXP '$search_txt') " : "");
if ($nets) {
if($nets)
$sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
}
$sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
intval($_SESSION['uid']));
@ -884,25 +857,23 @@ function contacts_tab($a, $contact_id, $active_tab) {
// Show this tab only if there is visible friend list
$x = count_all_friends(local_user(), $contact_id);
if ($x) {
if ($x)
$tabs[] = array('label'=>t('Contacts'),
'url' => "allfriends/".$contact_id,
'sel' => (($active_tab == 3)?'active':''),
'title' => t('View all contacts'),
'id' => 'allfriends-tab',
'accesskey' => 't');
}
// Show this tab only if there is visible common friend list
$common = count_common_friends(local_user(),$contact_id);
if ($common) {
if ($common)
$tabs[] = array('label'=>t('Common Friends'),
'url' => "common/loc/".local_user()."/".$contact_id,
'sel' => (($active_tab == 4)?'active':''),
'title' => t('View all common friends'),
'id' => 'common-loc-tab',
'accesskey' => 'd');
}
$tabs[] = array('label' => t('Advanced'),
'url' => 'crepair/' . $contact_id,
@ -920,13 +891,12 @@ function contacts_tab($a, $contact_id, $active_tab) {
function contact_posts($a, $contact_id) {
$r = q("SELECT `url` FROM `contact` WHERE `id` = %d", intval($contact_id));
if (dbm::is_result($r)) {
if ($r) {
$contact = $r[0];
$a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
} else {
} else
$profile = "";
}
$tab_str = contacts_tab($a, $contact_id, 1);
@ -958,7 +928,8 @@ function _contact_detail_for_template($rr){
if(($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
$url = "redir/{$rr['id']}";
$sparkle = ' class="sparkle" ';
} else {
}
else {
$url = $rr['url'];
$sparkle = '';
}

View file

@ -41,15 +41,17 @@ function content_content(App $a, $update = 0) {
if($a->argc > 1) {
for($x = 1; $x < $a->argc; $x ++) {
if(is_a_date_arg($a->argv[$x])) {
if ($datequery) {
if($datequery)
$datequery2 = escape_tags($a->argv[$x]);
} else {
else {
$datequery = escape_tags($a->argv[$x]);
$_GET['order'] = 'post';
}
} elseif ($a->argv[$x] === 'new') {
}
elseif($a->argv[$x] === 'new') {
$nouveau = true;
} elseif (intval($a->argv[$x])) {
}
elseif(intval($a->argv[$x])) {
$group = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $group . '>');
}
@ -840,9 +842,8 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
// process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like');
if (feature_enabled($profile_owner,'dislike')) {
if(feature_enabled($profile_owner,'dislike'))
$response_verbs[] = 'dislike';
}
if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno';
@ -862,9 +863,8 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$indent = (($toplevelpost) ? '' : ' comment');
$shiny = "";
if (strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) {
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
$shiny = 'shiny';
}
//
localize_item($item);
@ -873,9 +873,7 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$tags=array();
foreach(explode(',',$item['tag']) as $tag){
$tag = trim($tag);
if ($tag!="") {
$tags[] = bbcode($tag);
}
if ($tag!="") $tags[] = bbcode($tag);
}
// Build the HTML
@ -890,7 +888,8 @@ function render_content(App $a, $items, $mode, $update, $preview = false) {
$title_e = template_escape($item['title']);
$location_e = template_escape($location);
$owner_name_e = template_escape($owner_name);
} else {
}
else {
$body_e = $body;
$text_e = strip_tags($body);
$name_e = $profile_name;

View file

@ -20,9 +20,8 @@ function crepair_init(App $a) {
}
}
if (! x($a->page,'aside')) {
if(! x($a->page,'aside'))
$a->page['aside'] = '';
}
if($contact_id) {
$a->data['contact'] = $r[0];
@ -36,9 +35,6 @@ function crepair_post(App $a) {
return;
}
// Init $r here if $cid is not set
$r = false;
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if($cid) {
@ -89,11 +85,11 @@ function crepair_post(App $a) {
update_contact_avatar($photo,local_user(),$contact['id']);
}
if ($r) {
if($r)
info( t('Contact settings applied.') . EOL);
} else {
else
notice( t('Contact update failed.') . EOL);
}
return;
}

View file

@ -23,16 +23,16 @@ function delegate_content(App $a) {
$id = $a->argv[2];
$r = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1",
$r = q("select `nickname` from user where uid = %d limit 1",
intval($id)
);
if (dbm::is_result($r)) {
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
$r = q("select id from contact where uid = %d and nurl = '%s' limit 1",
intval(local_user()),
dbesc(normalise_link(App::get_baseurl() . '/profile/' . $r[0]['nickname']))
);
if (dbm::is_result($r)) {
q("INSERT INTO `manage` ( `uid`, `mid` ) VALUES ( %d , %d ) ",
q("insert into manage ( uid, mid ) values ( %d , %d ) ",
intval($a->argv[2]),
intval(local_user())
);
@ -64,40 +64,34 @@ function delegate_content(App $a) {
dbesc($a->user['email']),
dbesc($a->user['password'])
);
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$full_managers = $r;
}
$delegates = array();
// find everybody that currently has delegated management to this account/page
$r = q("SELECT * FROM `user` WHERE `uid` IN ( SELECT `uid` FROM `manage` WHERE `mid` = %d ) ",
$r = q("select * from user where uid in ( select uid from manage where mid = %d ) ",
intval(local_user())
);
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$delegates = $r;
}
$uids = array();
if (count($full_managers)) {
foreach ($full_managers as $rr) {
if(count($full_managers))
foreach($full_managers as $rr)
$uids[] = $rr['uid'];
}
}
if (count($delegates)) {
foreach ($delegates as $rr) {
if(count($delegates))
foreach($delegates as $rr)
$uids[] = $rr['uid'];
}
}
// find every contact who might be a candidate for delegation
$r = q("SELECT `nurl` FROM `contact` WHERE SUBSTRING_INDEX(`contact`.`nurl`,'/',3) = '%s'
AND `contact`.`uid` = %d AND `contact`.`self` = 0 AND `network` = '%s' ",
$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(App::get_baseurl())),
intval(local_user()),
dbesc(NETWORK_DFRN)
@ -122,15 +116,12 @@ function delegate_content(App $a) {
// get user records for all potential page delegates who are not already delegates or managers
$r = q("SELECT `uid`, `username`, `nickname` FROM `user` WHERE `nickname` IN ( $nicks )");
$r = q("select `uid`, `username`, `nickname` from user where nickname in ( $nicks )");
if (dbm::is_result($r)) {
foreach ($r as $rr) {
if (! in_array($rr['uid'],$uids)) {
if (dbm::is_result($r))
foreach($r as $rr)
if(! in_array($rr['uid'],$uids))
$potentials[] = $rr;
}
}
}
require_once("mod/settings.php");
settings_init($a);

View file

@ -349,7 +349,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
dbesc(NETWORK_DFRN),
intval($contact_id)
);
} else {
}
else {
// $network !== NETWORK_DFRN
@ -585,18 +586,17 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
dbesc($decrypted_source_url),
intval($local_uid)
);
if (!dbm::is_result($ret)) {
if (strstr($decrypted_source_url,'http:')) {
if(! count($ret)) {
if(strstr($decrypted_source_url,'http:'))
$newurl = str_replace('http:','https:',$decrypted_source_url);
} else {
else
$newurl = str_replace('https:','http:',$decrypted_source_url);
}
$ret = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
dbesc($newurl),
intval($local_uid)
);
if (!dbm::is_result($ret)) {
if(! count($ret)) {
// this is either a bogus confirmation (?) or we deleted the original introduction.
$message = t('Contact record was not found for you on our site.');
xml_status(3,$message);
@ -755,7 +755,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
intval($local_uid)
);
if (dbm::is_result($self)) {
if(count($self)) {
$arr = array();
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid);
@ -792,9 +792,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$arr['deny_gid'] = $user[0]['deny_gid'];
$i = item_store($arr);
if ($i) {
if($i)
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
}
}
}

View file

@ -143,9 +143,7 @@ function dfrn_notify_post(App $a) {
$rino = get_config('system','rino_encrypt');
$rino = intval($rino);
// use RINO1 if mcrypt isn't installed and RINO2 was selected
if ($rino == 2 and !function_exists('mcrypt_create_iv')) {
$rino=1;
}
if ($rino==2 and !function_exists('mcrypt_create_iv')) $rino=1;
logger("Local rino version: ". $rino, LOGGER_DEBUG);
@ -303,12 +301,13 @@ function dfrn_notify_content(App $a) {
if((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) {
openssl_private_encrypt($hash,$challenge,$prv_key);
openssl_private_encrypt($id_str,$encrypted_id,$prv_key);
} elseif (strlen($pub_key)) {
}
elseif(strlen($pub_key)) {
openssl_public_encrypt($hash,$challenge,$pub_key);
openssl_public_encrypt($id_str,$encrypted_id,$pub_key);
} else {
$status = 1;
}
else
$status = 1;
$challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id);
@ -317,9 +316,7 @@ function dfrn_notify_content(App $a) {
$rino = get_config('system','rino_encrypt');
$rino = intval($rino);
// use RINO1 if mcrypt isn't installed and RINO2 was selected
if ($rino == 2 and !function_exists('mcrypt_create_iv')) {
$rino=1;
}
if ($rino==2 and !function_exists('mcrypt_create_iv')) $rino=1;
logger("Local rino version: ". $rino, LOGGER_DEBUG);
@ -329,7 +326,8 @@ function dfrn_notify_content(App $a) {
if((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
$perm = 'rw';
} else {
}
else {
$perm = 'r';
}

View file

@ -185,9 +185,8 @@ function directory_content(App $a) {
unset($profile);
unset($location);
if (! $arr['entry']) {
if(! $arr['entry'])
continue;
}
$entries[] = $arr['entry'];

View file

@ -166,9 +166,8 @@ function dirfind_content(App $a, $prefix = "") {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
if (strlen(get_config('system','directory'))) {
if(strlen(get_config('system','directory')))
$x = fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
}
$j = json_decode($x);
}

View file

@ -112,7 +112,7 @@ function events_post(App $a) {
$c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval(local_user())
);
if (dbm::is_result($c)) {
if (count($c)) {
$self = $c[0]['id'];
} else {
$self = 0;
@ -142,7 +142,7 @@ function events_post(App $a) {
$str_group_allow = $str_contact_deny = $str_group_deny = '';
}
/// @TODO One-time array initialization, one large block
$datarray = array();
$datarray['guid'] = get_guid(32);
$datarray['start'] = $start;
@ -407,9 +407,7 @@ function events_content(App $a) {
// Passed parameters overrides anything found in the DB
if ($mode === 'edit' || $mode === 'new') {
if (!x($orig_event)) {
$orig_event = array();
}
if (!x($orig_event)) {$orig_event = array();}
// In case of an error the browser is redirected back here, with these parameters filled in with the previous values
if (x($_REQUEST, 'nofinish')) {$orig_event['nofinish'] = $_REQUEST['nofinish'];}
if (x($_REQUEST, 'adjust')) {$orig_event['adjust'] = $_REQUEST['adjust'];}

View file

@ -68,7 +68,8 @@ function fbrowser_content(App $a) {
if($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']);
} else {
}
else {
$filename_e = $rr['filename'];
}

View file

@ -95,9 +95,7 @@ function friendica_content(App $a) {
sort($sorted);
foreach($sorted as $p) {
if(strlen($p)) {
if (strlen($s)) {
$s .= ', ';
}
if(strlen($s)) $s .= ', ';
$s .= $p;
}
}

View file

@ -80,9 +80,8 @@ function fsuggest_content(App $a) {
return;
}
if ($a->argc != 2) {
if($a->argc != 2)
return;
}
$contact_id = intval($a->argv[1]);

View file

@ -80,12 +80,10 @@ function group_content(App $a) {
// Switch to text mode interface if we have more than 'n' contacts or group members
$switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit');
if ($switchtotext === false) {
if($switchtotext === false)
$switchtotext = get_config('system','groupedit_image_limit');
}
if ($switchtotext === false) {
if($switchtotext === false)
$switchtotext = 400;
}
$tpl = get_markup_template('group_edit.tpl');
@ -101,6 +99,8 @@ function group_content(App $a) {
'$gid' => 'new',
'$form_security_token' => get_form_security_token("group_edit"),
));
}
if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
@ -135,10 +135,9 @@ function group_content(App $a) {
intval($a->argv[2]),
intval(local_user())
);
if (dbm::is_result($r)) {
if (dbm::is_result($r))
$change = intval($a->argv[2]);
}
}
if (($a->argc > 1) && (intval($a->argv[1]))) {
@ -155,15 +154,15 @@ function group_content(App $a) {
$members = group_get_members($group['id']);
$preselected = array();
if(count($members)) {
foreach ($members as $member) {
foreach($members as $member)
$preselected[] = $member['id'];
}
}
if($change) {
if(in_array($change,$preselected)) {
group_rmv_member(local_user(),$group['name'],$change);
} else {
}
else {
group_add_member(local_user(),$group['name'],$change);
}
@ -194,9 +193,8 @@ function group_content(App $a) {
}
if (! isset($group)) {
if(! isset($group))
return;
}
$groupeditor = array(
'label_members' => t('Members'),
@ -212,9 +210,9 @@ function group_content(App $a) {
if($member['url']) {
$member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;';
$groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode);
} else {
group_rmv_member(local_user(),$group['name'],$member['id']);
}
else
group_rmv_member(local_user(),$group['name'],$member['id']);
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `self` ORDER BY `name` ASC",

View file

@ -31,9 +31,8 @@ function help_content(App $a) {
// looping through the argv keys bigger than 0 to build
// a path relative to /help
for($x = 1; $x < argc(); $x ++) {
if (strlen($path)) {
if(strlen($path))
$path .= '/';
}
$path .= argv($x);
}
$title = basename($path);
@ -72,16 +71,10 @@ function help_content(App $a) {
if ($level!="r") {
$level = intval($level);
if ($level<$lastlevel) {
for ($k=$level;$k<$lastlevel; $k++) {
$toc.="</ul>";
}
for ($k=$level+1;$k<count($idnum);$k++) {
$idnum[$k]=0;
}
}
if ($level>$lastlevel) {
$toc.="<ul>";
for($k=$level;$k<$lastlevel; $k++) $toc.="</ul>";
for($k=$level+1;$k<count($idnum);$k++) $idnum[$k]=0;
}
if ($level>$lastlevel) $toc.="<ul>";
$idnum[$level]++;
$id = implode("_", array_slice($idnum,1,$level));
$href = App::get_baseurl()."/help/{$filename}#{$id}";

View file

@ -37,11 +37,8 @@ function ignored_init(App $a) {
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
if ($return_path) {
$rand = '_=' . time();
if (strpos($return_path, '?')) {
$rand = "&$rand";
} else {
$rand = "?$rand";
}
if(strpos($return_path, '?')) $rand = "&$rand";
else $rand = "?$rand";
goaway(App::get_baseurl() . "/" . $return_path . $rand);
}

0
mod/install.php Normal file → Executable file
View file

View file

@ -575,9 +575,8 @@ function item_post(App $a) {
if(count($tags)) {
foreach($tags as $tag) {
if (strpos($tag,'#') === 0) {
if(strpos($tag,'#') === 0)
continue;
}
// If we already tagged 'Robert Johnson', don't try and tag 'Robert'.
// Robert Johnson should be first in the $tags array
@ -589,9 +588,8 @@ function item_post(App $a) {
break;
}
}
if ($fullnametagged) {
if($fullnametagged)
continue;
}
$success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network);
if ($success['replaced']) {
@ -724,9 +722,8 @@ function item_post(App $a) {
$datarray['last-child'] = 1;
$datarray['visible'] = 1;
if ($orig_post) {
if($orig_post)
$datarray['edit'] = true;
}
// Search for hashtags
item_body_set_hashtags($datarray);
@ -1035,9 +1032,8 @@ function item_post(App $a) {
function item_post_return($baseurl, $api_source, $return_path) {
// figure out how to return, depending on from whence we came
if ($api_source) {
if($api_source)
return;
}
if ($return_path) {
goaway($return_path);
@ -1115,24 +1111,19 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
$r = q("SELECT `alias`, `name` FROM `contact` WHERE `nurl` = '%s' AND `alias` != '' AND `uid` = 0",
normalise_link($matches[1]));
if (!dbm::is_result($r)) {
if (!$r)
$r = q("SELECT `alias`, `name` FROM `gcontact` WHERE `nurl` = '%s' AND `alias` != ''",
normalise_link($matches[1]));
}
if (dbm::is_result($r)) {
if ($r)
$data = $r[0];
} else {
else
$data = probe_url($matches[1]);
}
if ($data["alias"] != "") {
$newtag = '@[url='.$data["alias"].']'.$data["name"].'[/url]';
if(!stristr($str_tags,$newtag)) {
if (strlen($str_tags)) {
if(strlen($str_tags))
$str_tags .= ',';
}
$str_tags .= $newtag;
}
}
@ -1164,7 +1155,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
);
// Then check in the contact table for the url
if (!dbm::is_result($r)) {
if (!$r)
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `contact`
WHERE `nurl` = '%s' AND `uid` = %d AND
(`network` != '%s' OR (`notify` != '' AND `alias` != ''))
@ -1173,7 +1164,6 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
intval($profile_uid),
dbesc(NETWORK_OSTATUS)
);
}
// Then check in the global contacts for the address
if (!$r)
@ -1185,16 +1175,15 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
);
// Then check in the global contacts for the url
if (!dbm::is_result($r)) {
if (!$r)
$r = q("SELECT `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `gcontact`
WHERE `nurl` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
LIMIT 1",
dbesc(normalise_link($name)),
dbesc(NETWORK_OSTATUS)
);
}
if (!dbm::is_result($r)) {
if (!$r) {
$probed = probe_url($name);
if ($result['network'] != NETWORK_PHANTOM) {
update_gcontact($probed);
@ -1215,61 +1204,55 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
}
//select someone by attag or nick and the name passed in the current network
if (!dbm::is_result($r) AND ($network != "")) {
if(!$r AND ($network != ""))
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
dbesc($name),
dbesc($name),
dbesc($network),
intval($profile_uid)
);
}
//select someone from this user's contacts by name in the current network
if (!dbm::is_result($r) AND ($network != "")) {
if (!$r AND ($network != ""))
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
dbesc($name),
dbesc($network),
intval($profile_uid)
);
}
//select someone by attag or nick and the name passed in
if (!dbm::is_result($r)) {
if(!$r)
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
dbesc($name),
dbesc($name),
intval($profile_uid)
);
}
//select someone from this user's contacts by name
if (!dbm::is_result($r)) {
if(!$r)
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
dbesc($name),
intval($profile_uid)
);
}
}
if (dbm::is_result($r)) {
if (strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"]))) {
if ($r) {
if(strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"])))
$inform .= ',';
}
if (isset($r[0]["id"])) {
if (isset($r[0]["id"]))
$inform .= 'cid:' . $r[0]["id"];
} elseif (isset($r[0]["notify"])) {
elseif (isset($r[0]["notify"]))
$inform .= $r[0]["notify"];
}
$profile = $r[0]["url"];
$alias = $r[0]["alias"];
$newname = $r[0]["nick"];
if (($newname == "") OR (($r[0]["network"] != NETWORK_OSTATUS) AND ($r[0]["network"] != NETWORK_TWITTER)
AND ($r[0]["network"] != NETWORK_STATUSNET) AND ($r[0]["network"] != NETWORK_APPNET))) {
AND ($r[0]["network"] != NETWORK_STATUSNET) AND ($r[0]["network"] != NETWORK_APPNET)))
$newname = $r[0]["name"];
}
}
//if there is an url for this persons profile
if (isset($profile) AND ($newname != "")) {
@ -1281,9 +1264,8 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
$body = str_replace('@'.$name, $newtag, $body);
//append tag to str_tags
if(! stristr($str_tags,$newtag)) {
if (strlen($str_tags)) {
if(strlen($str_tags))
$str_tags .= ',';
}
$str_tags .= $newtag;
}
@ -1293,9 +1275,8 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
if(strlen($alias)) {
$newtag = '@[url='.$alias.']'.$newname.'[/url]';
if(! stristr($str_tags,$newtag)) {
if (strlen($str_tags)) {
if(strlen($str_tags))
$str_tags .= ',';
}
$str_tags .= $newtag;
}
}

14
mod/like.php Normal file → Executable file
View file

@ -13,16 +13,13 @@ function like_content(App $a) {
$verb = notags(trim($_GET['verb']));
if (! $verb) {
if(! $verb)
$verb = 'like';
}
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
$r = do_like($item_id, $verb);
if (!$r) {
return;
}
if (!$r) return;
// See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
@ -40,11 +37,8 @@ function like_content_return($baseurl, $return_path) {
if($return_path) {
$rand = '_=' . time();
if (strpos($return_path, '?')) {
$rand = "&$rand";
} else {
$rand = "?$rand";
}
if(strpos($return_path, '?')) $rand = "&$rand";
else $rand = "?$rand";
goaway($baseurl . "/" . $return_path . $rand);
}

View file

@ -6,23 +6,20 @@ require_once('include/datetime.php');
function localtime_post(App $a) {
$t = $_REQUEST['time'];
if (! $t) {
if(! $t)
$t = 'now';
}
$bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
if ($_POST['timezone']) {
if($_POST['timezone'])
$a->data['mod-localtime'] = datetime_convert('UTC',$_POST['timezone'],$t,$bd_format);
}
}
function localtime_content(App $a) {
$t = $_REQUEST['time'];
if (! $t) {
if(! $t)
$t = 'now';
}
$o .= '<h3>' . t('Time Conversion') . '</h3>';
@ -32,13 +29,11 @@ function localtime_content(App $a) {
$o .= '<p>' . sprintf( t('UTC time: %s'), $t) . '</p>';
if ($_REQUEST['timezone']) {
if($_REQUEST['timezone'])
$o .= '<p>' . sprintf( t('Current timezone: %s'), $_REQUEST['timezone']) . '</p>';
}
if (x($a->data,'mod-localtime')) {
if(x($a->data,'mod-localtime'))
$o .= '<p>' . sprintf( t('Converted localtime: %s'),$a->data['mod-localtime']) . '</p>';
}
$o .= '<form action ="' . App::get_baseurl() . '/localtime?f=&time=' . $t . '" method="post" >';

View file

@ -53,21 +53,17 @@ function lockview_content(App $a) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
dbesc(implode(', ', $allowed_groups))
);
if (dbm::is_result($r)) {
foreach ($r as $rr) {
if (dbm::is_result($r))
foreach($r as $rr)
$l[] = '<b>' . $rr['name'] . '</b>';
}
}
}
if(count($allowed_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
dbesc(implode(', ',$allowed_users))
);
if (dbm::is_result($r)) {
foreach ($r as $rr) {
if (dbm::is_result($r))
foreach($r as $rr)
$l[] = $rr['name'];
}
}
}
@ -75,21 +71,17 @@ function lockview_content(App $a) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
dbesc(implode(', ', $deny_groups))
);
if (dbm::is_result($r)) {
foreach ($r as $rr) {
if (dbm::is_result($r))
foreach($r as $rr)
$l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
}
}
}
if(count($deny_users)) {
$r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
dbesc(implode(', ',$deny_users))
);
if (dbm::is_result($r)) {
foreach ($r as $rr) {
if (dbm::is_result($r))
foreach($r as $rr)
$l[] = '<strike>' . $rr['name'] . '</strike>';
}
}
}

View file

@ -1,16 +1,13 @@
<?php
function login_content(App $a) {
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 (local_user()) {
if(local_user())
goaway(z_root());
}
return login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true);
}

View file

@ -79,6 +79,7 @@ function lostpass_post(App $a) {
function lostpass_content(App $a) {
if(x($_GET,'verify')) {
$verify = $_GET['verify'];
$hash = hash('whirlpool', $verify);

View file

@ -13,7 +13,7 @@ function manage_post(App $a) {
$orig_record = $a->user;
if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
$r = q("select * from user where uid = %d limit 1",
intval($_SESSION['submanage'])
);
if (dbm::is_result($r)) {
@ -22,16 +22,15 @@ function manage_post(App $a) {
}
}
$r = q("SELECT * FROM `manage` WHERE `uid` = %d",
$r = q("select * from manage where uid = %d",
intval($uid)
);
$submanage = $r;
$identity = ((x($_POST['identity'])) ? intval($_POST['identity']) : 0);
if (! $identity) {
if(! $identity)
return;
}
$limited_id = 0;
$original_id = $uid;
@ -49,7 +48,8 @@ function manage_post(App $a) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($limited_id)
);
} else {
}
else {
$r = q("SELECT * FROM `user` WHERE `uid` = %d AND `email` = '%s' AND `password` = '%s' LIMIT 1",
intval($identity),
dbesc($orig_record['email']),
@ -70,22 +70,18 @@ function manage_post(App $a) {
unset($_SESSION['mobile-theme']);
unset($_SESSION['page_flags']);
unset($_SESSION['return_url']);
if (x($_SESSION,'submanage')) {
if(x($_SESSION,'submanage'))
unset($_SESSION['submanage']);
}
if (x($_SESSION,'sysmsg')) {
if(x($_SESSION,'sysmsg'))
unset($_SESSION['sysmsg']);
}
if (x($_SESSION,'sysmsg_info')) {
if(x($_SESSION,'sysmsg_info'))
unset($_SESSION['sysmsg_info']);
}
require_once('include/security.php');
authenticate_success($r[0],true,true);
if ($limited_id) {
if($limited_id)
$_SESSION['submanage'] = $original_id;
}
$ret = array();
call_hooks('home_init',$ret);

View file

@ -78,9 +78,9 @@ function message_post(App $a) {
if($norecip) {
$a->argc = 2;
$a->argv[1] = 'new';
} else {
goaway($_SESSION['return_url']);
}
else
goaway($_SESSION['return_url']);
}
@ -109,15 +109,14 @@ function item_extract_images($body) {
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
$cnt++;
} else {
$new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
}
else
$new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
$orig_body = substr($orig_body, $img_end + strlen('[/img]'));
if ($orig_body === false) {// in case the body ends on a closing image tag
if($orig_body === false) // in case the body ends on a closing image tag
$orig_body = '';
}
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
@ -252,10 +251,9 @@ function message_content(App $a) {
// );
//}
if ($r) {
if($r)
info( t('Conversation removed.') . EOL );
}
}
//goaway(App::get_baseurl(true) . '/message' );
goaway($_SESSION['return_url']);
}
@ -432,9 +430,8 @@ function message_content(App $a) {
$unknown = false;
foreach($messages as $message) {
if ($message['unknown']) {
if($message['unknown'])
$unknown = true;
}
if($message['from-url'] == $myprofile) {
$from_url = $myprofile;
$sparkle = '';
@ -448,9 +445,8 @@ function message_content(App $a) {
$extracted = item_extract_images($message['body']);
if ($extracted['images']) {
if($extracted['images'])
$message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']);
}
if($a->theme['template_engine'] === 'internal') {
$from_name_e = template_escape($message['from-name']);
@ -465,11 +461,10 @@ function message_content(App $a) {
}
$contact = get_contact_details_by_url($message['from-url']);
if (isset($contact["thumb"])) {
if (isset($contact["thumb"]))
$from_photo = $contact["thumb"];
} else {
else
$from_photo = $message['from-photo'];
}
$mails[] = array(
'id' => $message['id'],
@ -496,7 +491,8 @@ function message_content(App $a) {
if($a->theme['template_engine'] === 'internal') {
$subjtxt_e = template_escape($message['title']);
} else {
}
else {
$subjtxt_e = $message['title'];
}

View file

@ -123,11 +123,9 @@ function mood_content(App $a) {
$verbs = get_mood_verbs();
$shortlist = array();
foreach ($verbs as $k => $v) {
if ($v !== 'NOTRANSLATION') {
foreach($verbs as $k => $v)
if($v !== 'NOTRANSLATION')
$shortlist[] = array($k,$v);
}
}
$tpl = get_markup_template('mood_content.tpl');

View file

@ -329,15 +329,17 @@ function network_content(App $a, $update = 0) {
if($a->argc > 1) {
for($x = 1; $x < $a->argc; $x ++) {
if(is_a_date_arg($a->argv[$x])) {
if ($datequery) {
if($datequery)
$datequery2 = escape_tags($a->argv[$x]);
} else {
else {
$datequery = escape_tags($a->argv[$x]);
$_GET['order'] = 'post';
}
} elseif ($a->argv[$x] === 'new') {
}
elseif($a->argv[$x] === 'new') {
$nouveau = true;
} elseif (intval($a->argv[$x])) {
}
elseif(intval($a->argv[$x])) {
$group = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $group . '>');
}

View file

@ -47,9 +47,8 @@ function newmember_content(App $a) {
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if (! $mail_disabled) {
if(! $mail_disabled)
$o .= '<li>' . '<a target="newmember" href="settings/connectors">' . t('Importing Emails') . '</a><br />' . t('Enter your email access information on your Connector Settings page if you wish to import and interact with friends or mailing lists from your email INBOX') . '</li>' . EOL;
}
$o .= '<li>' . '<a target="newmember" href="contacts">' . t('Go to Your Contacts Page') . '</a><br />' . t('Your Contacts page is your gateway to managing friendships and connecting with friends on other networks. Typically you enter their address or site URL in the <em>Add New Contact</em> dialog.') . '</li>' . EOL;

View file

@ -2,11 +2,10 @@
function noscrape_init(App $a) {
if ($a->argc > 1) {
if($a->argc > 1)
$which = $a->argv[1];
} else {
else
killme();
}
$profile = 0;
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {

View file

@ -104,9 +104,8 @@ function notes_content(App $a, $update = false) {
$parents_str = '';
if (dbm::is_result($r)) {
foreach ($r as $rr) {
foreach($r as $rr)
$parents_arr[] = $rr['item_id'];
}
$parents_str = implode(', ', $parents_arr);
$r = q("SELECT %s FROM `item` %s

View file

@ -309,10 +309,9 @@ function notifications_content(App $a) {
}
// Output if there aren't any notifications available
if ($notifs['total'] == 0) {
if($notifs['total'] == 0)
$notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']);
}
}
$o .= replace_macros($notif_tpl, array(
'$notif_header' => $notif_header,

View file

@ -84,7 +84,8 @@ function photo_init(App $a) {
$data = file_get_contents($default);
$mimetype = 'image/jpeg';
}
} else {
}
else {
/**
* Other photos

View file

@ -1345,11 +1345,10 @@ function photos_content(App $a) {
// The query leads to a really intense used index.
// By now we hide it if someone wants to.
if (!Config::get('system', 'no_count', false)) {
if ($_GET['order'] === 'posted') {
if ($_GET['order'] === 'posted')
$order = 'ASC';
} else {
else
$order = 'DESC';
}
$prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
$sql_extra ORDER BY `created` $order ",
@ -1357,17 +1356,15 @@ function photos_content(App $a) {
intval($owner_uid)
);
if (dbm::is_result($prvnxt)) {
if (count($prvnxt)) {
for($z = 0; $z < count($prvnxt); $z++) {
if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
$prv = $z - 1;
$nxt = $z + 1;
if ($prv < 0) {
if ($prv < 0)
$prv = count($prvnxt) - 1;
}
if ($nxt >= count($prvnxt)) {
if ($nxt >= count($prvnxt))
$nxt = 0;
}
break;
}
}
@ -1377,9 +1374,8 @@ function photos_content(App $a) {
}
}
if (count($ph) == 1) {
if (count($ph) == 1)
$hires = $lores = $ph[0];
}
if (count($ph) > 1) {
if ($ph[1]['scale'] == 2) {
// original is 640 or less, we can display it directly

View file

@ -157,12 +157,12 @@ function poco_init(App $a) {
if (x($_GET,'updatedSince') AND !$global) {
$ret['updatedSince'] = false;
}
$ret['startIndex'] = (int) $startIndex;
$ret['itemsPerPage'] = (int) $itemsPerPage;
$ret['totalResults'] = (int) $totalResults;
$ret['entry'] = array();
$fields_ret = array(
'id' => false,
'displayName' => false,
@ -207,17 +207,14 @@ function poco_init(App $a) {
if (($rr['about'] == "") AND isset($rr['pabout'])) {
$rr['about'] = $rr['pabout'];
}
if ($rr['location'] == "") {
if (isset($rr['plocation'])) {
$rr['location'] = $rr['plocation'];
}
if (isset($rr['pregion']) AND ($rr['pregion'] != "")) {
if ($rr['location'] != "") {
$rr['location'] .= ", ";
}
$rr['location'] .= $rr['pregion'];
}
@ -295,7 +292,6 @@ function poco_init(App $a) {
} else {
$entry['updated'] = $rr['updated'];
}
$entry['updated'] = date("c", strtotime($entry['updated']));
}
if ($fields_ret['photos']) {
@ -349,7 +345,6 @@ function poco_init(App $a) {
if ($fields_ret['contactType']) {
$entry['contactType'] = intval($rr['contact-type']);
}
$ret['entry'][] = $entry;
}
} else {
@ -358,7 +353,6 @@ function poco_init(App $a) {
} else {
http_status_exit(500);
}
logger("End of poco", LOGGER_DEBUG);
if ($format === 'xml') {
@ -373,5 +367,4 @@ function poco_init(App $a) {
} else {
http_status_exit(500);
}
}

View file

@ -185,11 +185,9 @@ function poke_content(App $a) {
$verbs = get_poke_verbs();
$shortlist = array();
foreach ($verbs as $k => $v) {
if ($v[1] !== 'NOTRANSLATION') {
foreach($verbs as $k => $v)
if($v[1] !== 'NOTRANSLATION')
$shortlist[] = array($k,$v[1]);
}
}
$tpl = get_markup_template('poke_content.tpl');

View file

@ -16,7 +16,8 @@ function post_post(App $a) {
if ($a->argc == 1) {
$bulk_delivery = true;
} else {
}
else {
$nickname = $a->argv[2];
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s'
AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
@ -33,17 +34,15 @@ function post_post(App $a) {
logger('mod-post: new zot: ' . $xml, LOGGER_DATA);
if (! $xml) {
if(! $xml)
http_status_exit(500);
}
$msg = zot_decode($importer,$xml);
logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
if (! is_array($msg)) {
if(! is_array($msg))
http_status_exit(500);
}
$ret = 0;
$ret = zot_incoming($bulk_delivery, $importer,$msg);

View file

@ -10,7 +10,8 @@ function pretheme_init(App $a) {
$desc = $info['description'];
$version = $info['version'];
$credits = $info['credits'];
} else {
}
else {
$desc = '';
$version = '';
$credits = '';

View file

@ -6,17 +6,17 @@ require_once('include/redir.php');
function profile_init(App $a) {
if (! x($a->page,'aside')) {
if(! x($a->page,'aside'))
$a->page['aside'] = '';
}
if ($a->argc > 1) {
if($a->argc > 1)
$which = htmlspecialchars($a->argv[1]);
}else {
else {
$r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1");
if (dbm::is_result($r)) {
goaway(App::get_baseurl() . '/profile/' . $r[0]['nickname']);
} else {
}
else {
logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
notice( t('Requested profile is not available.') . EOL );
$a->error = 404;
@ -28,7 +28,8 @@ function profile_init(App $a) {
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
$which = $a->user['nickname'];
$profile = htmlspecialchars($a->argv[1]);
} else {
}
else {
auto_redir($a, $which);
}
@ -288,9 +289,8 @@ function profile_content(App $a, $update = 0) {
$parents_str = '';
if (dbm::is_result($r)) {
foreach ($r as $rr) {
foreach($r as $rr)
$parents_arr[] = $rr['item_id'];
}
$parents_str = implode(', ', $parents_arr);
$items = q(item_query()." AND `item`.`uid` = %d

View file

@ -34,9 +34,8 @@ function profiles_init(App $a) {
intval($a->argv[2]),
intval(local_user())
);
if ($r) {
if($r)
info(t('Profile deleted.').EOL);
}
goaway('profiles');
return; // NOTREACHED
@ -248,13 +247,11 @@ function profiles_post(App $a) {
$withchanged = true;
$prf = '';
$lookup = $with;
if (strpos($lookup,'@') === 0) {
if(strpos($lookup,'@') === 0)
$lookup = substr($lookup,1);
}
$lookup = str_replace('_',' ', $lookup);
if(strpos($lookup,'@') || (strpos($lookup,'http://'))) {
$newname = $lookup;
/// @TODO Maybe kill those error/debugging-surpressing @ characters
$links = @Probe::lrdd($lookup);
if(count($links)) {
foreach($links as $link) {
@ -263,14 +260,16 @@ function profiles_post(App $a) {
}
}
}
} else {
}
else {
$newname = $lookup;
/* if(strstr($lookup,' ')) {
$r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
dbesc($newname),
intval(local_user())
);
} else {
}
else {
$r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
dbesc($lookup),
intval(local_user())
@ -474,9 +473,8 @@ function profiles_post(App $a) {
intval(local_user())
);
if ($r) {
if($r)
info( t('Profile updated.') . EOL);
}
if($namechanged && $is_default) {

View file

@ -142,9 +142,8 @@ function pubsub_post(App $a) {
// we have no way to match Diaspora guid's with atom post id's and could get duplicates.
// we'll assume that direct delivery is robust (and this is a bad assumption, but the duplicates are messy).
if ($r[0]['network'] === NETWORK_DIASPORA) {
if($r[0]['network'] === NETWORK_DIASPORA)
hub_post_return();
}
$feedhub = '';

View file

@ -10,14 +10,12 @@ function qsearch_init(App $a) {
$search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : '');
if (! strlen($search)) {
if(! strlen($search))
killme();
}
if ($search) {
if($search)
$search = dbesc($search);
}
$results = array();
@ -27,10 +25,10 @@ function qsearch_init(App $a) {
);
if (dbm::is_result($r)) {
foreach ($r as $rr) {
foreach($r as $rr)
$results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
}
}
$sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : "");
@ -42,10 +40,10 @@ function qsearch_init(App $a) {
if (dbm::is_result($r)) {
foreach ($r as $rr) {
foreach($r as $rr)
$results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']);
}
}
echo json_encode((object) $results);
killme();

View file

@ -72,9 +72,8 @@ function user_deny($hash) {
dbesc($hash)
);
if (! dbm::is_result($register)) {
if(! dbm::is_result($register))
return false;
}
$user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($register[0]['uid'])

0
mod/repair_ostatus.php Normal file → Executable file
View file

View file

@ -384,10 +384,7 @@ function settings_post(App $a) {
// check if the old password was supplied correctly before
// changing it to the new value
$r = q("SELECT `password` FROM `user`WHERE `uid` = %d LIMIT 1", intval(local_user()));
if (!dbm::is_result($r)) {
/// @todo Don't quit silently here
killme();
} elseif ( $oldpass != $r[0]['password'] ) {
if( $oldpass != $r[0]['password'] ) {
notice( t('Wrong password.') . EOL);
$err = true;
}
@ -398,13 +395,12 @@ function settings_post(App $a) {
dbesc($password),
intval(local_user())
);
if ($r) {
if($r)
info( t('Password changed.') . EOL);
} else {
else
notice( t('Password update failed. Please try again.') . EOL);
}
}
}
$username = ((x($_POST,'username')) ? notags(trim($_POST['username'])) : '');
@ -446,41 +442,32 @@ function settings_post(App $a) {
$notify = 0;
if (x($_POST,'notify1')) {
if(x($_POST,'notify1'))
$notify += intval($_POST['notify1']);
}
if (x($_POST,'notify2')) {
if(x($_POST,'notify2'))
$notify += intval($_POST['notify2']);
}
if (x($_POST,'notify3')) {
if(x($_POST,'notify3'))
$notify += intval($_POST['notify3']);
}
if (x($_POST,'notify4')) {
if(x($_POST,'notify4'))
$notify += intval($_POST['notify4']);
}
if (x($_POST,'notify5')) {
if(x($_POST,'notify5'))
$notify += intval($_POST['notify5']);
}
if (x($_POST,'notify6')) {
if(x($_POST,'notify6'))
$notify += intval($_POST['notify6']);
}
if (x($_POST,'notify7')) {
if(x($_POST,'notify7'))
$notify += intval($_POST['notify7']);
}
if (x($_POST,'notify8')) {
if(x($_POST,'notify8'))
$notify += intval($_POST['notify8']);
}
// Adjust the page flag if the account type doesn't fit to the page flag.
if (($account_type == ACCOUNT_TYPE_PERSON) AND !in_array($page_flags, array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
if (($account_type == ACCOUNT_TYPE_PERSON) AND !in_array($page_flags, array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE)))
$page_flags = PAGE_NORMAL;
} elseif (($account_type == ACCOUNT_TYPE_ORGANISATION) AND !in_array($page_flags, array(PAGE_SOAPBOX))) {
elseif (($account_type == ACCOUNT_TYPE_ORGANISATION) AND !in_array($page_flags, array(PAGE_SOAPBOX)))
$page_flags = PAGE_SOAPBOX;
} elseif (($account_type == ACCOUNT_TYPE_NEWS) AND !in_array($page_flags, array(PAGE_SOAPBOX))) {
elseif (($account_type == ACCOUNT_TYPE_NEWS) AND !in_array($page_flags, array(PAGE_SOAPBOX)))
$page_flags = PAGE_SOAPBOX;
} elseif (($account_type == ACCOUNT_TYPE_COMMUNITY) AND !in_array($page_flags, array(PAGE_COMMUNITY, PAGE_PRVGROUP))) {
elseif (($account_type == ACCOUNT_TYPE_COMMUNITY) AND !in_array($page_flags, array(PAGE_COMMUNITY, PAGE_PRVGROUP)))
$page_flags = PAGE_COMMUNITY;
}
$email_changed = false;
@ -490,13 +477,11 @@ function settings_post(App $a) {
if($username != $a->user['username']) {
$name_change = true;
if (strlen($username) > 40) {
if(strlen($username) > 40)
$err .= t(' Please use a shorter name.');
}
if (strlen($username) < 3) {
if(strlen($username) < 3)
$err .= t(' Name too short.');
}
}
if($email != $a->user['email']) {
$email_changed = true;
@ -508,9 +493,8 @@ function settings_post(App $a) {
$email = $a->user['email'];
}
// check the email is valid
if (! valid_email($email)) {
if(! valid_email($email))
$err .= t(' Not valid email.');
}
// ensure new email is not the admin mail
//if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0)) {
if(x($a->config,'admin_email')) {
@ -527,7 +511,8 @@ function settings_post(App $a) {
return;
}
if ($timezone != $a->user['timezone'] && strlen($timezone)) {
if($timezone != $a->user['timezone']) {
if(strlen($timezone))
date_default_timezone_set($timezone);
}
@ -549,9 +534,9 @@ function settings_post(App $a) {
$open_id_obj = new LightOpenID;
$open_id_obj->identity = $openid;
$openidserver = $open_id_obj->discover($open_id_obj->identity);
} else {
$openidserver = '';
}
else
$openidserver = '';
}
set_pconfig(local_user(),'expire','items', $expire_items);
@ -573,7 +558,8 @@ function settings_post(App $a) {
if($def_gid) {
info( t('Private forum has no privacy permissions. Using default privacy group.'). EOL);
$str_group_allow = '<' . $def_gid . '>';
} else {
}
else {
notice( t('Private forum has no privacy permissions and no default privacy group.') . EOL);
}
}
@ -613,9 +599,8 @@ function settings_post(App $a) {
dbesc($language),
intval(local_user())
);
if ($r) {
if($r)
info( t('Settings updated.') . EOL);
}
// clear session language
unset($_SESSION['language']);
@ -684,6 +669,8 @@ function settings_content(App $a) {
return;
}
if (($a->argc > 1) && ($a->argv[1] === 'oauth')) {
if (($a->argc > 2) && ($a->argv[2] === 'add')) {

View file

@ -14,7 +14,8 @@ function smilies_content(App $a) {
$results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
}
json_return_and_die($results);
} else {
}
else {
return Smilies::replace('',true);
}
}

View file

@ -25,9 +25,8 @@ function videos_init(App $a) {
dbesc($nick)
);
if (!dbm::is_result($user)) {
if(! count($user))
return;
}
$a->data['user'] = $user[0];
$a->profile_uid = $user[0]['uid'];

View file

@ -9,10 +9,9 @@ function view_init($a){
if ($a->argc == 4){
$theme = $a->argv[2];
$THEMEPATH = "view/theme/$theme";
if (file_exists("view/theme/$theme/style.php")) {
if(file_exists("view/theme/$theme/style.php"))
require_once("view/theme/$theme/style.php");
}
}
killme();
}

View file

@ -90,11 +90,10 @@ function viewcontacts_content(App $a) {
$is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
if ($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
$url = 'redir/' . $rr['id'];
} else {
else
$url = zrl($url);
}
$contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr);

View file

@ -228,25 +228,23 @@ function wall_upload_post(App $a, $desktopmode = true) {
if($width > 640 || $height > 640) {
$ph->scaleImage(640);
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 1, 0, $defperm);
if ($r) {
if($r)
$smallest = 1;
}
}
if($width > 320 || $height > 320) {
$ph->scaleImage(320);
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 2, 0, $defperm);
if ($r AND ($smallest == 0)) {
if($r AND ($smallest == 0))
$smallest = 2;
}
}
$basename = basename($filename);
if (!$desktopmode) {
$r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo` WHERE `resource-id` = '%s' ORDER BY `width` DESC LIMIT 1", $hash);
if (!dbm::is_result($r)) {
if (!$r){
if ($r_json) {
echo json_encode(array('error'=>''));
killme();

View file

@ -98,14 +98,11 @@ function wallmessage_content(App $a) {
return;
}
$r = q("SELECT COUNT(*) AS `total` FROM `mail` WHERE `uid` = %d AND `created` > UTC_TIMESTAMP() - INTERVAL 1 DAY AND `unknown` = 1",
$r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
intval($user['uid'])
);
if (!dbm::is_result($r)) {
///@TODO Output message to use of failed query
return;
} elseif ($r[0]['total'] > $user['cntunkmail']) {
if($r[0]['total'] > $user['cntunkmail']) {
notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
return;
}

View file

@ -12,9 +12,8 @@ function xrd_init(App $a) {
} else {
$acct = true;
$local = str_replace('acct:', '', $uri);
if (substr($local,0,2) == '//') {
if(substr($local,0,2) == '//')
$local = substr($local,2);
}
$name = substr($local,0,strpos($local,'@'));
}

View file

@ -1,7 +1,6 @@
<?php
if (class_exists('BaseObject')) {
if(class_exists('BaseObject'))
return;
}
require_once('boot.php');
@ -19,9 +18,8 @@ class BaseObject {
* Same as get_app from boot.php
*/
public function get_app() {
if (self::$app) {
if(self::$app)
return self::$app;
}
self::$app = get_app();

View file

@ -1,7 +1,6 @@
<?php
if (class_exists('Conversation')) {
if(class_exists('Conversation'))
return;
}
require_once('boot.php');
require_once('object/BaseObject.php');
@ -134,9 +133,8 @@ class Conversation extends BaseObject {
$i = 0;
foreach($this->threads as $item) {
if ($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid'))
continue;
}
$item_data = $item->get_template_data($conv_responses);
@ -159,10 +157,9 @@ class Conversation extends BaseObject {
*/
private function get_thread($id) {
foreach($this->threads as $item) {
if ($item->get_id() == $id) {
if($item->get_id() == $id)
return $item;
}
}
return false;
}

View file

@ -1,7 +1,6 @@
<?php
if (class_exists('Item')) {
if(class_exists('Item'))
return;
}
require_once('object/BaseObject.php');
require_once('include/text.php');

View file

@ -15,8 +15,7 @@
*/
if (($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) {
if(($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1]))
echo $_SERVER["argv"][1];
} else {
else
echo '';
}

Some files were not shown because too many files have changed in this diff Show more