1
1
Fork 0

Merge branch 'develop' into 1703-worker-splitting

This commit is contained in:
Michael Vogel 2017-03-21 16:38:59 +01:00 committed by GitHub
commit 5a6da8b447
181 changed files with 4303 additions and 3483 deletions

309
boot.php
View file

@ -711,7 +711,6 @@ 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) === '~') {
@ -745,8 +744,7 @@ 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';
@ -760,8 +758,9 @@ 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;
/*
@ -793,14 +792,17 @@ 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);
}
@ -876,7 +878,7 @@ class App {
}
if (file_exists(".htpreconfig.php")) {
@include(".htpreconfig.php");
include(".htpreconfig.php");
}
if (get_config('config', 'hostname') != '') {
@ -890,8 +892,9 @@ class App {
}
function get_hostname() {
if (get_config('config','hostname') != "")
if (get_config('config','hostname') != "") {
$this->hostname = get_config('config','hostname');
}
return $this->hostname;
}
@ -926,16 +929,17 @@ 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'];
@ -945,25 +949,29 @@ 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);
@ -985,8 +993,9 @@ 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!!!!
@ -1159,8 +1168,9 @@ 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);
@ -1242,8 +1252,9 @@ class App {
array_shift($trace);
$callstack = array();
foreach ($trace AS $func)
foreach ($trace AS $func) {
$callstack[] = $func["function"];
}
return implode(", ", $callstack);
}
@ -1265,32 +1276,34 @@ class App {
* @return bool Is it a known backend?
*/
function is_backend() {
$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";
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",
);
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
@ -1302,14 +1315,16 @@ 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"] != "") {
@ -1333,14 +1348,16 @@ 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) {
@ -1375,16 +1392,17 @@ 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__)));
}
}
/**
@ -1463,13 +1481,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;
@ -1499,8 +1517,9 @@ function clean_urls() {
function z_path() {
$base = App::get_baseurl();
if(! clean_urls())
if (! clean_urls()) {
$base .= '/?q=';
}
return $base;
}
@ -1525,8 +1544,9 @@ function z_root() {
* @return string
*/
function absurl($path) {
if(strpos($path,'/') === 0)
if (strpos($path,'/') === 0) {
return z_path() . $path;
}
return $path;
}
@ -1546,8 +1566,9 @@ 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');
}
}
@ -1566,10 +1587,12 @@ 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;
}
@ -1580,8 +1603,9 @@ 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);
@ -1600,8 +1624,9 @@ 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());
@ -1609,10 +1634,13 @@ 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 (!$r) {
break;
}
}
if ($stored < NEW_UPDATE_ROUTINE_VERSION) {
$stored = NEW_UPDATE_ROUTINE_VERSION;
}
if ($stored < NEW_UPDATE_ROUTINE_VERSION) $stored = NEW_UPDATE_ROUTINE_VERSION;
// run new update routine
// it update the structure in one call
@ -1630,7 +1658,9 @@ 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;
}
}
}
}
@ -1651,8 +1681,9 @@ 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
@ -1697,16 +1728,18 @@ 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;
@ -1716,8 +1749,7 @@ 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'];
}
}
@ -1787,8 +1819,7 @@ 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)
));
@ -1836,8 +1867,9 @@ function login($register = false, $hiddens=false) {
*/
function killme() {
if (!get_app()->is_backend())
if (!get_app()->is_backend()) {
session_write_close();
}
exit;
}
@ -1846,8 +1878,9 @@ 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();
@ -1895,8 +1928,9 @@ 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;
}
@ -1909,10 +1943,13 @@ 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.
@ -1924,13 +1961,17 @@ 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;
}
}
/**
@ -1991,8 +2032,9 @@ 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");
@ -2015,12 +2057,13 @@ function proc_run($cmd){
$found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'",
dbesc($parameters));
if (!$found)
if (!dbm::is_result($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) {
@ -2033,12 +2076,14 @@ 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");
@ -2059,17 +2104,19 @@ 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();
@ -2094,33 +2141,39 @@ 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?
}
@ -2137,8 +2190,9 @@ 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');
}
@ -2167,8 +2221,9 @@ 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)
@ -2181,8 +2236,9 @@ 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);
}
}
@ -2247,9 +2303,10 @@ 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) {
@ -2271,7 +2328,9 @@ 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"];
@ -2292,8 +2351,9 @@ function random_digits($digits) {
function get_server() {
$server = get_config("system", "directory");
if ($server == "")
if ($server == "") {
$server = "http://dir.friendi.ca";
}
return($server);
}
@ -2301,8 +2361,9 @@ 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);
@ -2324,25 +2385,30 @@ 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);
}
}
@ -2351,8 +2417,9 @@ 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)) {
@ -2467,37 +2534,42 @@ 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;
}
if (!$valid)
return false;
return true;
// Simply return flag
return ($valid);
}
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]);
}
@ -2518,8 +2590,9 @@ 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,11 +122,13 @@ 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($contact) {
function mark_for_death(array $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,10 +33,11 @@ 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,12 +154,16 @@ 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,15 +1133,17 @@ 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();
@ -1157,10 +1159,11 @@ 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)
@ -1169,11 +1172,13 @@ 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,11 +170,13 @@ 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,8 +121,9 @@ 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,17 +219,20 @@ 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 );
@ -243,9 +246,10 @@ 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,6 +173,7 @@ 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]));
@ -215,9 +216,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()))
);
@ -227,22 +228,26 @@ 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,10 +309,11 @@ 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";
@ -484,9 +485,10 @@ 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]);
}
}
}
@ -1359,18 +1361,23 @@ 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']) {
@ -1418,9 +1425,11 @@ 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;
}
@ -1443,8 +1452,7 @@ 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']);
@ -1453,9 +1461,10 @@ 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

@ -8,19 +8,21 @@ 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,10 +486,12 @@ 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);
@ -498,29 +500,33 @@ 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 {
@ -534,9 +540,11 @@ 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,17 +3632,20 @@ class Diaspora {
}
$r = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($contact['uid']));
if(!$r)
if (!dbm::is_result($r)) {
return false;
}
$contact["uprvkey"] = $r[0]['prvkey'];
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($post_id));
if (!$r)
if (!dbm::is_result($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

@ -207,7 +207,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 ($exists) {
if (dbm::is_result($exists)) {
logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND
@ -260,11 +260,13 @@ 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,10 +411,12 @@ 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,12 +11,13 @@ 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,8 +289,9 @@ 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,9 +347,10 @@ 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,16 +878,20 @@ 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;
}
@ -908,9 +912,10 @@ 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,8 +57,9 @@ 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,14 +497,15 @@ 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,7 +316,9 @@ 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 (! count($contacts)) {
if (! dbm::is_result($contacts)) {
return;
}
@ -437,17 +437,19 @@ 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,12 +524,14 @@ 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;
}
@ -556,13 +558,15 @@ 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);
@ -573,10 +577,11 @@ 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;
if(file_exists($p))
} elseif (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,8 +372,9 @@ 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,9 +28,11 @@ function handle_pubsubhubbub($id) {
global $a;
$r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
if (!$r)
if (!dbm::is_result($r)) {
return;
else
}
$rr = $r[0];
logger("Generate feed of user ".$rr['nickname']." to ".$rr['callback_url']." - last updated ".$rr['last_update'], LOGGER_DEBUG);
@ -65,8 +67,10 @@ 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,12 +49,14 @@ 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 ",
@ -64,8 +66,7 @@ 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,8 +16,7 @@ function get_salmon_key($uri,$keyhash) {
$ret[] = $a['@attributes']['href'];
}
}
}
else {
} else {
return '';
}
@ -69,8 +68,9 @@ function slapper($owner,$url,$slap) {
// does contact have a salmon endpoint?
if(! strlen($url))
if (! strlen($url)) {
return;
}
if (! $owner['sprvkey']) {
@ -169,10 +169,12 @@ 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,21 +55,25 @@ 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
} 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'];
@ -358,9 +362,10 @@ 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,20 +1664,22 @@ 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,10 +105,11 @@ 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,8 +53,9 @@ 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);
@ -73,14 +74,16 @@ 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);
} elseif (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]);
@ -109,14 +112,16 @@ 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();
}
@ -136,8 +141,9 @@ 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,10 +421,11 @@ 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,29 +174,34 @@ 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)."'";
}
@ -208,8 +213,9 @@ 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 (!$items)
if (!dbm::is_result($items)) {
return;
}
$result = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s' WHERE `id` = %d",
dbesc($item["title"]),
@ -224,10 +230,12 @@ 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(count($messages))
foreach ($messages as $message)
if (dbm::is_result($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,35 +21,41 @@ function update_gcontact_run(&$argv, &$argc){
$r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
if (!$r)
if (!dbm::is_result($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);
@include(".htconfig.php");
// Only load config if found, don't surpress errors
if (!$install) {
include(".htconfig.php");
}
/**
*
@ -233,12 +233,14 @@ 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');
@ -246,13 +248,13 @@ 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 {
} else {
include_once("addon/{$a->module}/{$a->module}.php");
if(function_exists($a->module . '_module'))
if (function_exists($a->module . '_module')) {
$a->module_loaded = true;
}
}
}
/**
* If not, next look for a 'standard' program module in the 'mod' directory
@ -392,13 +394,15 @@ $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.
@ -448,8 +452,7 @@ 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(
@ -462,10 +465,11 @@ 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));
@ -499,8 +503,9 @@ 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,8 +859,9 @@ function admin_page_site(App $a) {
$allowed_theme_list = Config::get('system', 'allowed_themes');
foreach ($files as $file) {
if (intval(file_exists($file.'/unsupported')))
if (file_exists($file.'/unsupported'))
continue;
}
$f = basename($file);
@ -1274,7 +1275,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 (count($user) == 0) {
if (!dbm::is_result($user)) {
notice('User not found'.EOL);
goaway('admin/users');
return ''; // NOTREACHED
@ -1706,9 +1707,9 @@ function admin_page_themes(App $a) {
continue;
}
$is_experimental = intval(file_exists($file.'/experimental'));
$is_supported = 1-(intval(file_exists($file.'/unsupported')));
$is_allowed = intval(in_array($f,$allowed_themes));
$is_experimental = file_exists($file.'/experimental');
$is_supported = (!file_exists($file.'/unsupported'));
$is_allowed = 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);
@ -1761,7 +1762,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,8 +37,9 @@ 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,21 +5,19 @@ 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,6 +69,7 @@ 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
@ -94,6 +95,7 @@ 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';
@ -235,9 +237,10 @@ 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,17 +63,18 @@ 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,8 +79,9 @@ 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,9 +14,10 @@ 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]))) {
@ -32,15 +33,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,13 +99,22 @@ 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'];
@ -130,14 +139,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');
}
@ -165,7 +174,8 @@ function contacts_post(App $a) {
intval(local_user())
);
if (! count($orig_record)) {
if (! dbm::is_result($orig_record)) {
/// @TODO EOL really needed?
notice( t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
@ -194,8 +204,10 @@ 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']));
@ -212,17 +224,21 @@ function contacts_post(App $a) {
intval($contact_id),
intval(local_user())
);
if($r)
/// @TODO Decide to use dbm::is_result() here, what does $r include?
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($r && dbm::is_result($r))
if (dbm::is_result($r)) {
$a->data['contact'] = $r[0];
}
return;
@ -231,40 +247,47 @@ 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 (!$r)
if (!dbm::is_result($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 (!$r)
if (!dbm::is_result($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");
@ -273,30 +296,36 @@ 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),
@ -364,8 +393,9 @@ 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];
@ -374,7 +404,7 @@ function contacts_content(App $a) {
intval(local_user())
);
if(! count($orig_record)) {
if (! dbm::is_result($orig_record)) {
notice( t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
@ -394,6 +424,7 @@ 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);
@ -405,6 +436,7 @@ 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);
@ -417,6 +449,7 @@ 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);
@ -459,8 +492,7 @@ function contacts_content(App $a) {
if ($_REQUEST['canceled']) {
if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']);
}
else {
} else {
goaway('contacts');
}
}
@ -469,8 +501,7 @@ 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
@ -538,7 +569,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') : '');
@ -564,20 +595,22 @@ 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"),
@ -664,25 +697,21 @@ 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
} else {
$sql_extra = " AND `blocked` = 0 ";
}
$search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
$nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : '');
@ -754,8 +783,6 @@ 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;
@ -764,12 +791,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']));
@ -857,23 +884,25 @@ 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,
@ -891,12 +920,13 @@ 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 ($r) {
if (dbm::is_result($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);
@ -928,8 +958,7 @@ 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,17 +41,15 @@ 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 . '>');
}
@ -842,8 +840,9 @@ 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';
@ -863,8 +862,9 @@ 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,7 +873,9 @@ 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
@ -888,8 +890,7 @@ 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,8 +20,9 @@ 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];
@ -35,6 +36,9 @@ 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) {
@ -85,11 +89,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,34 +64,40 @@ 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)
@ -116,12 +122,15 @@ 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,8 +349,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
dbesc(NETWORK_DFRN),
intval($contact_id)
);
}
else {
} else {
// $network !== NETWORK_DFRN
@ -586,17 +585,18 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
dbesc($decrypted_source_url),
intval($local_uid)
);
if(! count($ret)) {
if(strstr($decrypted_source_url,'http:'))
if (!dbm::is_result($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(! count($ret)) {
if (!dbm::is_result($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(count($self)) {
if (dbm::is_result($self)) {
$arr = array();
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid);
@ -792,8 +792,9 @@ 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,7 +143,9 @@ 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);
@ -301,13 +303,12 @@ 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
} else {
$status = 1;
}
$challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id);
@ -316,7 +317,9 @@ 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);
@ -326,8 +329,7 @@ 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,8 +185,9 @@ function directory_content(App $a) {
unset($profile);
unset($location);
if(! $arr['entry'])
if (! $arr['entry']) {
continue;
}
$entries[] = $arr['entry'];

View file

@ -166,8 +166,9 @@ 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 (count($c)) {
if (dbm::is_result($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,7 +407,9 @@ 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,8 +68,7 @@ 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,7 +95,9 @@ 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,8 +80,9 @@ function fsuggest_content(App $a) {
return;
}
if($a->argc != 2)
if ($a->argc != 2) {
return;
}
$contact_id = intval($a->argv[1]);

View file

@ -80,10 +80,12 @@ 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');
@ -99,8 +101,6 @@ 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,9 +135,10 @@ 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]))) {
@ -154,15 +155,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);
}
@ -193,8 +194,9 @@ function group_content(App $a) {
}
if(! isset($group))
if (! isset($group)) {
return;
}
$groupeditor = array(
'label_members' => t('Members'),
@ -210,10 +212,10 @@ 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
} 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",
intval(local_user())

View file

@ -31,8 +31,9 @@ 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);
@ -71,10 +72,16 @@ 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;
for ($k=$level;$k<$lastlevel; $k++) {
$toc.="</ul>";
}
for ($k=$level+1;$k<count($idnum);$k++) {
$idnum[$k]=0;
}
}
if ($level>$lastlevel) {
$toc.="<ul>";
}
if ($level>$lastlevel) $toc.="<ul>";
$idnum[$level]++;
$id = implode("_", array_slice($idnum,1,$level));
$href = App::get_baseurl()."/help/{$filename}#{$id}";

View file

@ -37,8 +37,11 @@ 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 Executable file → Normal file
View file

View file

@ -575,8 +575,9 @@ 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
@ -588,8 +589,9 @@ 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']) {
@ -722,8 +724,9 @@ 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);
@ -1032,8 +1035,9 @@ 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);
@ -1111,19 +1115,24 @@ 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 (!$r)
if (!dbm::is_result($r)) {
$r = q("SELECT `alias`, `name` FROM `gcontact` WHERE `nurl` = '%s' AND `alias` != ''",
normalise_link($matches[1]));
if ($r)
}
if (dbm::is_result($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;
}
}
@ -1155,7 +1164,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
);
// Then check in the contact table for the url
if (!$r)
if (!dbm::is_result($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` != ''))
@ -1164,6 +1173,7 @@ 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)
@ -1175,15 +1185,16 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
);
// Then check in the global contacts for the url
if (!$r)
if (!dbm::is_result($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 (!$r) {
if (!dbm::is_result($r)) {
$probed = probe_url($name);
if ($result['network'] != NETWORK_PHANTOM) {
update_gcontact($probed);
@ -1204,55 +1215,61 @@ 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(!$r AND ($network != ""))
if (!dbm::is_result($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 (!$r AND ($network != ""))
if (!dbm::is_result($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(!$r)
if (!dbm::is_result($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(!$r)
if (!dbm::is_result($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 ($r) {
if(strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"])))
if (dbm::is_result($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 != "")) {
@ -1264,8 +1281,9 @@ 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;
}
@ -1275,8 +1293,9 @@ 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 Executable file → Normal file
View file

@ -13,13 +13,16 @@ 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'] : '');
@ -37,8 +40,11 @@ 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,20 +6,23 @@ 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>';
@ -29,11 +32,13 @@ 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,17 +53,21 @@ 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'];
}
}
}
@ -71,17 +75,21 @@ 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,13 +1,16 @@
<?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,7 +79,6 @@ 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,15 +22,16 @@ 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;
@ -48,8 +49,7 @@ 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,18 +70,22 @@ 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
} else {
goaway($_SESSION['return_url']);
}
}
@ -109,14 +109,15 @@ function item_extract_images($body) {
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
$cnt++;
}
else
} 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);
@ -251,9 +252,10 @@ function message_content(App $a) {
// );
//}
if($r)
if ($r) {
info( t('Conversation removed.') . EOL );
}
}
//goaway(App::get_baseurl(true) . '/message' );
goaway($_SESSION['return_url']);
}
@ -430,8 +432,9 @@ 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 = '';
@ -445,8 +448,9 @@ 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']);
@ -461,10 +465,11 @@ 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'],
@ -491,8 +496,7 @@ 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,9 +123,11 @@ 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,17 +329,15 @@ 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,8 +47,9 @@ 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,10 +2,11 @@
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,8 +104,9 @@ 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,9 +309,10 @@ 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,8 +84,7 @@ function photo_init(App $a) {
$data = file_get_contents($default);
$mimetype = 'image/jpeg';
}
}
else {
} else {
/**
* Other photos

View file

@ -1345,10 +1345,11 @@ 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 ",
@ -1356,15 +1357,17 @@ function photos_content(App $a) {
intval($owner_uid)
);
if (count($prvnxt)) {
if (dbm::is_result($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;
}
}
@ -1374,8 +1377,9 @@ 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,14 +207,17 @@ 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'];
}
@ -292,6 +295,7 @@ function poco_init(App $a) {
} else {
$entry['updated'] = $rr['updated'];
}
$entry['updated'] = date("c", strtotime($entry['updated']));
}
if ($fields_ret['photos']) {
@ -345,6 +349,7 @@ function poco_init(App $a) {
if ($fields_ret['contactType']) {
$entry['contactType'] = intval($rr['contact-type']);
}
$ret['entry'][] = $entry;
}
} else {
@ -353,6 +358,7 @@ function poco_init(App $a) {
} else {
http_status_exit(500);
}
logger("End of poco", LOGGER_DEBUG);
if ($format === 'xml') {
@ -367,4 +373,5 @@ function poco_init(App $a) {
} else {
http_status_exit(500);
}
}

View file

@ -185,9 +185,11 @@ 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,8 +16,7 @@ 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",
@ -34,15 +33,17 @@ 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,8 +10,7 @@ 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,8 +28,7 @@ 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);
}
@ -289,8 +288,9 @@ 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,8 +34,9 @@ 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
@ -247,11 +248,13 @@ 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) {
@ -260,16 +263,14 @@ 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())
@ -473,8 +474,9 @@ function profiles_post(App $a) {
intval(local_user())
);
if($r)
if ($r) {
info( t('Profile updated.') . EOL);
}
if ($namechanged && $is_default) {

View file

@ -142,8 +142,9 @@ 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,12 +10,14 @@ 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();
@ -25,10 +27,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') " : "");
@ -40,10 +42,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,8 +72,9 @@ 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 Executable file → Normal file
View file

View file

@ -384,7 +384,10 @@ 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( $oldpass != $r[0]['password'] ) {
if (!dbm::is_result($r)) {
/// @todo Don't quit silently here
killme();
} elseif ( $oldpass != $r[0]['password'] ) {
notice( t('Wrong password.') . EOL);
$err = true;
}
@ -395,12 +398,13 @@ 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'])) : '');
@ -442,32 +446,41 @@ 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;
@ -477,11 +490,13 @@ 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;
@ -493,8 +508,9 @@ 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')) {
@ -511,8 +527,7 @@ function settings_post(App $a) {
return;
}
if($timezone != $a->user['timezone']) {
if(strlen($timezone))
if ($timezone != $a->user['timezone'] && strlen($timezone)) {
date_default_timezone_set($timezone);
}
@ -534,10 +549,10 @@ 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
} else {
$openidserver = '';
}
}
set_pconfig(local_user(),'expire','items', $expire_items);
set_pconfig(local_user(),'expire','notes', $expire_notes);
@ -558,8 +573,7 @@ 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);
}
}
@ -599,8 +613,9 @@ 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']);
@ -669,8 +684,6 @@ 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,8 +14,7 @@ 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,8 +25,9 @@ function videos_init(App $a) {
dbesc($nick)
);
if(! count($user))
if (!dbm::is_result($user)) {
return;
}
$a->data['user'] = $user[0];
$a->profile_uid = $user[0]['uid'];

View file

@ -9,9 +9,10 @@ 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,10 +90,11 @@ 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,23 +228,25 @@ 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 (!$r){
if (!dbm::is_result($r)) {
if ($r_json) {
echo json_encode(array('error'=>''));
killme();

View file

@ -98,11 +98,14 @@ 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($r[0]['total'] > $user['cntunkmail']) {
if (!dbm::is_result($r)) {
///@TODO Output message to use of failed query
return;
} elseif ($r[0]['total'] > $user['cntunkmail']) {
notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
return;
}

View file

@ -12,8 +12,9 @@ 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,6 +1,7 @@
<?php
if(class_exists('BaseObject'))
if (class_exists('BaseObject')) {
return;
}
require_once('boot.php');
@ -18,8 +19,9 @@ 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,6 +1,7 @@
<?php
if(class_exists('Conversation'))
if (class_exists('Conversation')) {
return;
}
require_once('boot.php');
require_once('object/BaseObject.php');
@ -133,8 +134,9 @@ 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);
@ -157,9 +159,10 @@ 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,6 +1,7 @@
<?php
if(class_exists('Item'))
if (class_exists('Item')) {
return;
}
require_once('object/BaseObject.php');
require_once('include/text.php');

View file

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

View file

@ -37,7 +37,7 @@ define('UPDATE_VERSION' , 1216);
*/
/// @TODO These old updates need to have UPDATE_SUCCESS returned on success?
function update_1000() {
q("ALTER TABLE `item` DROP `like`, DROP `dislike` ");
@ -157,17 +157,18 @@ function update_1014() {
$r = q("SELECT * FROM `contact` WHERE 1");
if (dbm::is_result($r)) {
foreach ($r as $rr) {
if(stristr($rr['thumb'],'avatar'))
if (stristr($rr['thumb'],'avatar')) {
q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
dbesc(str_replace('avatar','micro',$rr['thumb'])),
intval($rr['id']));
else
} else {
q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
dbesc(str_replace('5.jpg','6.jpg',$rr['thumb'])),
intval($rr['id']));
}
}
}
}
function update_1015() {
q("ALTER TABLE `item` CHANGE `body` `body` mediumtext NOT NULL");
@ -308,7 +309,7 @@ function update_1030() {
function update_1031() {
// Repair any bad links that slipped into the item table
$r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
if($r && dbm::is_result($r)) {
if (dbm::is_result($r)) {
foreach ($r as $rr) {
if (strstr($rr['object'],'type=&quot;http')) {
q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
@ -368,9 +369,7 @@ function update_1036() {
}
function update_1037() {
q("ALTER TABLE `contact` CHANGE `lrdd` `alias` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ");
}
function update_1038() {
@ -531,9 +530,12 @@ function update_1065() {
}
function update_1066() {
$r = q("ALTER TABLE `item` ADD `received` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `edited` ");
if($r)
$r = q("ALTER TABLE `item` ADD `received` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` ");
/// @TODO Decide to use dbm::is_result() here, what does $r include?
if ($r) {
q("ALTER TABLE `item` ADD INDEX ( `received` ) ");
}
$r = q("UPDATE `item` SET `received` = `edited` WHERE 1");
}
@ -595,11 +597,12 @@ function update_1074() {
q("ALTER TABLE `user` ADD `hidewall` TINYINT( 1) NOT NULL DEFAULT '0' AFTER `blockwall` ");
$r = q("SELECT `uid` FROM `profile` WHERE `is-default` = 1 AND `hidewall` = 1");
if (dbm::is_result($r)) {
foreach($r as $rr)
foreach ($r as $rr) {
q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d",
intval($rr['uid'])
);
}
}
q("ALTER TABLE `profile` DROP `hidewall`");
}
@ -614,8 +617,9 @@ function update_1075() {
$x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
dbesc($guid)
);
if(! count($x))
if (!dbm::is_result($x)) {
$found = false;
}
} while ($found == true );
q("UPDATE `user` SET `guid` = '%s' WHERE `uid` = %d",
@ -684,14 +688,19 @@ function update_1082() {
q("ALTER TABLE `photo` ADD `guid` CHAR( 64 ) NOT NULL AFTER `contact-id`,
ADD INDEX ( `guid` ) ");
// make certain the following code is only executed once
$r = q("select `id` from `photo` where `guid` != '' limit 1");
if (dbm::is_result($r))
$r = q("SELECT `id` FROM `photo` WHERE `guid` != '' LIMIT 1");
if (dbm::is_result($r)) {
return;
}
$r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
if (dbm::is_result($r)) {
foreach ($r as $rr) {
$guid = get_guid();
q("update `photo` set `guid` = '%s' where `resource-id` = '%s'",
q("UPDATE `photo` SET `guid` = '%s' WHERE `resource-id` = '%s'",
dbesc($guid),
dbesc($rr['resource-id'])
);
@ -736,7 +745,8 @@ function update_1087() {
$x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
intval($rr['id'])
);
if(count($x))
if (dbm::is_result($x)) {
q("UPDATE `item` SET `commented` = '%s' WHERE `id` = %d",
dbesc($x[0]['cdate']),
intval($rr['id'])
@ -744,6 +754,7 @@ function update_1087() {
}
}
}
}
function update_1088() {
q("ALTER TABLE `user` ADD `account_expired` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `expire` ,
@ -849,14 +860,14 @@ function update_1099() {
function update_1100() {
q("ALTER TABLE `contact` ADD `nurl` CHAR( 255 ) NOT NULL AFTER `url` ");
q("alter table contact add index (`nurl`) ");
q("ALTER TABLE `contact` ADD INDEX (`nurl`) ");
require_once('include/text.php');
$r = q("select id, url from contact where url != '' and nurl = '' ");
$r = q("SELECT `id`, `url` FROM `contact` WHERE `url` != '' AND `nurl` = '' ");
if (dbm::is_result($r)) {
foreach ($r as $rr) {
q("update contact set nurl = '%s' where id = %d",
q("UPDATE `contact` SET `nurl` = '%s' WHERE `id` = %d",
dbesc(normalise_link($rr['url'])),
intval($rr['id'])
);
@ -886,6 +897,7 @@ function update_1102() {
function update_1103() {
/// @TODO Commented out:
// q("ALTER TABLE `item` ADD INDEX ( `wall` ) ");
q("ALTER TABLE `item` ADD FULLTEXT ( `tag` ) ");
q("ALTER TABLE `contact` ADD INDEX ( `pending` ) ");
@ -1031,10 +1043,12 @@ function update_1120() {
$r = q("describe item");
if (dbm::is_result($r)) {
foreach($r as $rr)
if($rr['Field'] == 'spam')
foreach ($r as $rr) {
if ($rr['Field'] == 'spam') {
return;
}
}
}
q("ALTER TABLE `item` ADD `spam` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `visible` , ADD INDEX (`spam`) ");
}
@ -1076,7 +1090,7 @@ set_config('system','allowed_themes','dispy,quattro,testbubble,vier,darkbubble,d
}
function update_1124() {
q("alter table item add index (`author-name`) ");
q("ALTER TABLE `item` ADD INDEX (`author-name`) ");
}
function update_1125() {
@ -1088,7 +1102,7 @@ function update_1125() {
`receiver-uid` INT NOT NULL,
INDEX ( `master-parent-item` ),
INDEX ( `receiver-uid` )
) ENGINE = MyISAM DEFAULT CHARSET=utf8");
) DEFAULT CHARSET=utf8");
}
function update_1126() {
@ -1107,12 +1121,12 @@ function update_1127() {
INDEX ( `spam` ),
INDEX ( `ham` ),
INDEX ( `term` )
) ENGINE = MyISAM DEFAULT CHARSET=utf8");
) DEFAULT CHARSET=utf8");
}
function update_1128() {
q("alter table spam add `date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `term` ");
q("ALTER TABLE `spam` ADD `date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `term` ");
}
function update_1129() {
@ -1133,7 +1147,7 @@ function update_1132() {
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` CHAR( 255 ) NOT NULL,
INDEX ( `username` )
) ENGINE = MYISAM ");
) ");
}
@ -1167,14 +1181,14 @@ function update_1136() {
// order in reverse so that we save the newest entry
$r = q("select * from config where 1 order by id desc");
$r = q("SELECT * FROM `config` WHERE 1 ORDER BY `id` DESC");
if (dbm::is_result($r)) {
foreach ($r as $rr) {
$found = false;
foreach ($arr as $x) {
if ($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
$found = true;
q("delete from config where id = %d",
q("DELETE FROM `config` WHERE `id` = %d",
intval($rr['id'])
);
}
@ -1186,14 +1200,14 @@ function update_1136() {
}
$arr = array();
$r = q("select * from pconfig where 1 order by id desc");
$r = q("SELECT * FROM `pconfig` WHERE 1 ORDER BY `id` DESC");
if (dbm::is_result($r)) {
foreach ($r as $rr) {
$found = false;
foreach ($arr as $x) {
if ($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
$found = true;
q("delete from pconfig where id = %d",
q("DELETE FROM `pconfig` WHERE `id` = %d",
intval($rr['id'])
);
}
@ -1210,116 +1224,155 @@ function update_1136() {
function update_1137() {
q("alter table item_id DROP `face` , DROP `dspr` , DROP `twit` , DROP `stat` ");
q("ALTER TABLE `item_id` ADD `sid` CHAR( 255 ) NOT NULL AFTER `uid` , ADD `service` CHAR( 255 ) NOT NULL AFTER `sid` , add index (`sid`), add index ( `service`) ");
q("ALTER TABLE `item_id` DROP `face` , DROP `dspr` , DROP `twit` , DROP `stat` ");
q("ALTER TABLE `item_id` ADD `sid` CHAR( 255 ) NOT NULL AFTER `uid` , ADD `service` CHAR( 255 ) NOT NULL AFTER `sid` , ADD INDEX (`sid`), ADD INDEX ( `service`) ");
}
function update_1138() {
q("alter table contact add archive tinyint(1) not null default '0' after hidden, add index (archive)");
q("ALTER TABLE `contact` ADD `archive` TINYINT(1) NOT NULL DEFAULT '0' AFTER `hidden`, ADD INDEX (`archive`)");
}
function update_1139() {
$r = q("alter table user add account_removed tinyint(1) not null default '0' after expire, add index(account_removed) ");
if(! $r)
return UPDATE_FAILED ;
$r = q("ALTER TABLE `user` ADD `account_removed` TINYINT(1) NOT NULL DEFAULT '0' AFTER `expire`, ADD INDEX(`account_removed`)");
if ($r) {
return UPDATE_SUCCESS ;
}
return UPDATE_FAILED ;
}
function update_1140() {
$r = q("alter table addon add hidden tinyint(1) not null default '0' after installed, add index(hidden) ");
if(! $r)
return UPDATE_FAILED ;
$r = q("ALTER TABLE `addon` ADD `hidden` TINYINT(1) NOT NULL DEFAULT '0' AFTER `installed`, ADD INDEX(`hidden`) ");
if ($r) {
return UPDATE_SUCCESS ;
}
function update_1141() {
$r = q("alter table glink add zcid int(11) not null after gcid, add index(zcid) ");
if(! $r)
return UPDATE_FAILED ;
}
function update_1141() {
$r = q("ALTER TABLE `glink` ADD `zcid` INT(11) NOT NULL AFTER `gcid`, ADD INDEX(`zcid`) ");
if ($r) {
return UPDATE_SUCCESS ;
}
return UPDATE_FAILED ;
}
function update_1142() {
$r = q("alter table user add service_class char(32) not null after expire_notification_sent, add index(service_class) ");
if(! $r)
return UPDATE_FAILED ;
$r = q("ALTER TABLE `user` ADD `service_class` CHAR(32) NOT NULL AFTER `expire_notification_sent`, ADD INDEX(`service_class`) ");
if ($r) {
return UPDATE_SUCCESS ;
}
return UPDATE_FAILED ;
}
function update_1143() {
$r = q("alter table user add def_gid int(11) not null default '0' after service_class");
if(! $r)
return UPDATE_FAILED ;
$r = q("ALTER TABLE `user` ADD `def_gid` INT(11) NOT NULL DEFAULT '0' AFTER `service_class`");
if ($r) {
return UPDATE_SUCCESS ;
}
return UPDATE_FAILED ;
}
function update_1144() {
$r = q("alter table contact add prv tinyint(1) not null default '0' after forum");
if(! $r)
return UPDATE_FAILED ;
$r = q("ALTER TABLE `contact` ADD `prv` TINYINT(1) NOT NULL DEFAULT '0' AFTER `forum`");
if ($r) {
return UPDATE_SUCCESS ;
}
return UPDATE_FAILED ;
}
function update_1145() {
$r = q("alter table profile add howlong datetime not null default '0001-01-01 00:00:00' after `with`");
if(! $r)
return UPDATE_FAILED ;
$r = q("ALTER TABLE `profile` ADD `howlong` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `with`");
if ($r) {
return UPDATE_SUCCESS ;
}
function update_1146() {
$r = q("alter table profile add hometown char(255) not null after `country-name`, add index ( `hometown` ) ");
if(! $r)
return UPDATE_FAILED ;
}
function update_1146() {
$r = q("ALTER TABLE `profile` ADD `hometown` CHAR(255) NOT NULL AFTER `country-name`, ADD INDEX ( `hometown` ) ");
if ($r) {
return UPDATE_SUCCESS ;
}
return UPDATE_FAILED ;
}
function update_1147() {
$r1 = q("ALTER TABLE `sign` ALTER `iid` SET DEFAULT '0'");
$r2 = q("ALTER TABLE `sign` ADD `retract_iid` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `iid`");
$r3 = q("ALTER TABLE `sign` ADD INDEX ( `retract_iid` )");
if((! $r1) || (! $r2) || (! $r3))
return UPDATE_FAILED ;
if ($r1 && $r2 && $r3) {
return UPDATE_SUCCESS ;
}
function update_1148() {
$r = q("ALTER TABLE photo ADD type CHAR(128) NOT NULL DEFAULT 'image/jpeg' AFTER filename");
if (!$r)
return UPDATE_FAILED ;
}
function update_1148() {
$r = q("ALTER TABLE `photo` ADD `type` CHAR(128) NOT NULL DEFAULT 'image/jpeg' AFTER `filename`");
if ($r) {
return UPDATE_SUCCESS ;
}
return UPDATE_FAILED ;
}
function update_1149() {
$r1 = q("ALTER TABLE profile ADD likes text NOT NULL after prv_keywords");
$r2 = q("ALTER TABLE profile ADD dislikes text NOT NULL after likes");
if (! ($r1 && $r2))
return UPDATE_FAILED;
$r1 = q("ALTER TABLE `profile` ADD `likes` TEXT NOT NULL AFTER `prv_keywords`");
$r2 = q("ALTER TABLE `profile` ADD `dislikes` TEXT NOT NULL AFTER `likes`");
if ($r1 && $r2) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1150() {
$r = q("ALTER TABLE event ADD summary text NOT NULL after finish, add index ( uid ), add index ( cid ), add index ( uri ), add index ( `start` ), add index ( finish ), add index ( `type` ), add index ( adjust ) ");
if(! $r)
return UPDATE_FAILED;
$r = q("ALTER TABLE `event` ADD `summary` TEXT NOT NULL AFTER `finish`, ADD INDEX ( `uid` ), ADD INDEX ( `cid` ), ADD INDEX ( `uri` ), ADD INDEX ( `start` ), ADD INDEX ( `finish` ), ADD INDEX ( `type` ), ADD INDEX ( `adjust` ) ");
if ($r) {
return UPDATE_SUCCESS ;
}
return UPDATE_FAILED ;
}
function update_1151() {
$r = q("CREATE TABLE IF NOT EXISTS locks (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
name CHAR( 128 ) NOT NULL ,
locked TINYINT( 1 ) NOT NULL DEFAULT '0'
) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
if (!$r)
return UPDATE_FAILED;
$r = q("CREATE TABLE IF NOT EXISTS `locks` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` CHAR( 128 ) NOT NULL ,
`locked` TINYINT( 1 ) NOT NULL DEFAULT '0'
) DEFAULT CHARSET=utf8 ");
if ($r) {
return UPDATE_SUCCESS ;
}
return UPDATE_FAILED ;
}
function update_1152() {
$r = q("CREATE TABLE IF NOT EXISTS `term` (
`tid` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
@ -1332,33 +1385,43 @@ function update_1152() {
KEY `otype` ( `otype` ),
KEY `type` ( `type` ),
KEY `term` ( `term` )
) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
if (!$r)
return UPDATE_FAILED;
) DEFAULT CHARSET=utf8 ");
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1153() {
$r = q("ALTER TABLE `hook` ADD `priority` INT(11) UNSIGNED NOT NULL DEFAULT '0'");
if(!$r) return UPDATE_FAILED;
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1154() {
$r = q("ALTER TABLE `event` ADD `ignore` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `adjust` , ADD INDEX ( `ignore` )");
if(!$r) return UPDATE_FAILED;
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1155() {
$r1 = q("ALTER TABLE `item_id` DROP PRIMARY KEY");
$r2 = q("ALTER TABLE `item_id` ADD `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
$r3 = q("ALTER TABLE `item_id` ADD INDEX ( `iid` ) ");
if($r1 && $r2 && $r3)
if ($r1 && $r2 && $r3) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
@ -1367,10 +1430,13 @@ function update_1156() {
$r = q("ALTER TABLE `photo` ADD `datasize` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `width` ,
ADD INDEX ( `datasize` ) ");
if(!$r) return UPDATE_FAILED;
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1157() {
$r = q("CREATE TABLE IF NOT EXISTS `dsprphotoq` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
@ -1381,10 +1447,13 @@ function update_1157() {
) ENGINE=MyISAM DEFAULT CHARSET=utf8"
);
if($r)
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1158() {
set_config('system', 'maintenance', 1);
@ -1395,8 +1464,9 @@ function update_1158() {
$r = q("CREATE INDEX event_id ON item(`event-id`)");
set_config('system', 'maintenance', 0);
if($r)
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
@ -1407,12 +1477,13 @@ function update_1159() {
ADD INDEX (`uid`),
ADD INDEX (`aid`)");
if(!$r)
return UPDATE_FAILED;
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1160() {
set_config('system', 'maintenance', 1);
@ -1423,21 +1494,23 @@ function update_1160() {
$r = q("ALTER TABLE `item` ADD `mention` TINYINT(1) NOT NULL DEFAULT '0', ADD INDEX (`mention`)");
set_config('system', 'maintenance', 0);
if(!$r)
return UPDATE_FAILED;
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1161() {
$r = q("ALTER TABLE `pconfig` ADD INDEX (`cat`)");
if(!$r)
return UPDATE_FAILED;
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1162() {
require_once('include/tags.php');
update_items();
@ -1451,11 +1524,13 @@ function update_1163() {
$r = q("ALTER TABLE `item` ADD `network` char(32) NOT NULL");
set_config('system', 'maintenance', 0);
if(!$r)
return UPDATE_FAILED;
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1164() {
set_config('system', 'maintenance', 1);
@ -1519,13 +1594,15 @@ function update_1165() {
`push` INT NOT NULL,
`last_update` DATETIME NOT NULL,
`secret` CHAR( 255 ) NOT NULL
) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
if (!$r)
return UPDATE_FAILED;
) DEFAULT CHARSET=utf8 ");
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1166() {
$r = q("CREATE TABLE IF NOT EXISTS `unique_contacts` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@ -1534,29 +1611,35 @@ function update_1166() {
`name` CHAR(255) NOT NULL,
`avatar` CHAR(255) NOT NULL,
INDEX (`url`)
) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
if (!$r)
return UPDATE_FAILED;
) DEFAULT CHARSET=utf8 ");
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1167() {
$r = q("ALTER TABLE `contact` ADD `notify_new_posts` TINYINT(1) NOT NULL DEFAULT '0'");
if (!$r)
return UPDATE_FAILED;
if ($r) {
return UPDATE_SUCCESS;
}
return UPDATE_FAILED;
}
function update_1168() {
$r = q("ALTER TABLE `contact` ADD `fetch_further_information` TINYINT(1) NOT NULL DEFAULT '0'");
if (!$r)
return UPDATE_FAILED;
if ($r) {
return UPDATE_SUCCESS ;
}
return UPDATE_FAILED ;
}
function update_1169() {
$r = q("CREATE TABLE IF NOT EXISTS `thread` (
`iid` int(10) unsigned NOT NULL DEFAULT '0',
@ -1592,8 +1675,10 @@ function update_1169() {
KEY `uid_created` (`uid`,`created`),
KEY `uid_commented` (`uid`,`commented`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
if (!$r)
if (!$r) {
return UPDATE_FAILED;
}
proc_run(PRIORITY_LOW, "include/threadupdate.php");
@ -1699,19 +1784,22 @@ function update_1190() {
$key = $rr['k'];
$value = $rr['v'];
if ($key === 'randomise')
if ($key === 'randomise') {
del_pconfig($uid,$family,$key);
}
if ($key === 'show_on_profile') {
if ($value)
if ($value) {
set_pconfig($uid,feature,forumlist_profile,$value);
}
del_pconfig($uid,$family,$key);
}
if ($key === 'show_on_network') {
if ($value)
if ($value) {
set_pconfig($uid,feature,forumlist_widget,$value);
}
del_pconfig($uid,$family,$key);
}

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