* beyond are used.
*/
public $theme = array(
- 'sourcename' => '',
- 'videowidth' => 425,
- 'videoheight' => 350,
+ 'sourcename' => '',
+ 'videowidth' => 425,
+ 'videoheight' => 350,
'force_max_items' => 0,
- 'thread_allow' => true,
- 'stylesheet' => '',
+ 'thread_allow' => true,
+ 'stylesheet' => '',
'template_engine' => 'smarty3',
);
$this->scheme = 'http';
- if ((x($_SERVER,'HTTPS') && $_SERVER['HTTPS']) ||
+ if((x($_SERVER,'HTTPS') && $_SERVER['HTTPS']) ||
(x($_SERVER['HTTP_FORWARDED']) && preg_match("/proto=https/", $_SERVER['HTTP_FORWARDED'])) ||
(x($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
(x($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') ||
(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much?
) {
$this->scheme = 'https';
- }
+ }
- if (x($_SERVER,'SERVER_NAME')) {
+ if(x($_SERVER,'SERVER_NAME')) {
$this->hostname = $_SERVER['SERVER_NAME'];
- if (x($_SERVER,'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
+ if(x($_SERVER,'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
$this->hostname .= ':' . $_SERVER['SERVER_PORT'];
/*
* Figure out if we are running at the top of a domain
*/
$path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\');
- if (isset($path) && strlen($path) && ($path != $this->path))
+ if(isset($path) && strlen($path) && ($path != $this->path))
$this->path = $path;
}
// fix query_string
$this->query_string = str_replace($this->cmd."&",$this->cmd."?", $this->query_string);
+
// unix style "homedir"
if (substr($this->cmd,0,1) === '~') {
$this->argv = explode('/',$this->cmd);
$this->argc = count($this->argv);
- if ((array_key_exists('0',$this->argv)) && strlen($this->argv[0])) {
+ 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';
$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;
/*
$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);
}
function set_baseurl($url) {
$parsed = @parse_url($url);
- if ($parsed) {
+ if($parsed) {
$this->scheme = $parsed['scheme'];
$hostname = $parsed['host'];
}
if (file_exists(".htpreconfig.php")) {
- include(".htpreconfig.php");
+ @include(".htpreconfig.php");
}
if (get_config('config', 'hostname') != '') {
}
function get_hostname() {
- if (get_config('config','hostname') != "") {
+ if (get_config('config','hostname') != "")
$this->hostname = get_config('config','hostname');
- }
return $this->hostname;
}
$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=='') {
- $this->page['title'] = $this->config['sitename'].' ('.$this->module.')';
+ if (!$this->module=='')
+ {
+ $this->page['title'] = $this->config['sitename'].' ('.$this->module.')';
} else {
- $this->page['title'] = $this->config['sitename'];
+ $this->page['title'] = $this->config['sitename'];
}
/* put the head template at the beginning of page['htmlhead']
* 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);
}
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!!!!
// The following code is deactivated. It doesn't seem to make any sense and it slows down the system.
/*
- if ($this->cached_profile_image[$avatar_image])
+ if($this->cached_profile_image[$avatar_image])
return $this->cached_profile_image[$avatar_image];
$path_parts = explode("/",$avatar_image);
$common_filename = $path_parts[count($path_parts)-1];
- if ($this->cached_profile_picdate[$common_filename]){
+ if($this->cached_profile_picdate[$common_filename]){
$this->cached_profile_image[$avatar_image] = $avatar_image . $this->cached_profile_picdate[$common_filename];
} else {
$r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'",
function register_template_engine($class, $name = '') {
if ($name===""){
$v = get_class_vars( $class );
- if (x($v,"name")) $name = $v['name'];
+ if(x($v,"name")) $name = $v['name'];
}
if ($name===""){
echo "template engine <tt>$class</tt> cannot be registered without a name.\n";
}
if (isset($this->template_engines[$template_engine])){
- if (isset($this->template_engine_instance[$template_engine])){
+ if(isset($this->template_engine_instance[$template_engine])){
return $this->template_engine_instance[$template_engine];
} else {
$class = $this->template_engines[$template_engine];
switch($engine) {
case 'smarty3':
- if (is_writable('view/smarty3/'))
+ if(is_writable('view/smarty3/'))
$this->theme['template_engine'] = 'smarty3';
break;
default:
}
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);
array_shift($trace);
$callstack = array();
- foreach ($trace AS $func) {
+ foreach ($trace AS $func)
$callstack[] = $func["function"];
- }
return implode(", ", $callstack);
}
* @return bool Is it a known backend?
*/
function is_backend() {
- static $backend = array(
- "_well_known",
- "api",
- "dfrn_notify",
- "fetch",
- "hcard",
- "hostxrd",
- "nodeinfo",
- "noscrape",
- "p",
- "poco",
- "post",
- "proxy",
- "pubsub",
- "pubsubhubbub",
- "receive",
- "rsd_xml",
- "salmon",
- "statistics_json",
- "xrd",
- );
-
- if (in_array($this->module, $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";
+
+ if (in_array($this->module, $backend))
return(true);
- } else {
+ else
return($this->backend);
- }
}
/**
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 ($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();
// 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__)));
- }
+
}
/**
* @return bool|int
*/
function x($s,$k = NULL) {
- if ($k != NULL) {
- if ((is_array($s)) && (array_key_exists($k,$s))) {
- if ($s[$k]) {
+ if($k != NULL) {
+ if((is_array($s)) && (array_key_exists($k,$s))) {
+ if($s[$k])
return (int) 1;
- }
return (int) 0;
- }
+ }
return false;
- } else {
- if (isset($s)) {
- if ($s) {
+ }
+ else {
+ if(isset($s)) {
+ if($s) {
return (int) 1;
}
return (int) 0;
function z_path() {
$base = App::get_baseurl();
- if (! clean_urls()) {
+ if(! clean_urls())
$base .= '/?q=';
- }
return $base;
}
* @return string
*/
function absurl($path) {
- if (strpos($path,'/') === 0) {
+ if(strpos($path,'/') === 0)
return z_path() . $path;
- }
return $path;
}
function check_db() {
$build = get_config('system','build');
- if (! x($build)) {
+ if(! x($build)) {
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');
- }
}
// 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;
}
*/
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) {
+ if($build != DB_UPDATE_VERSION) {
$stored = intval($build);
$current = intval(DB_UPDATE_VERSION);
- if ($stored < $current) {
+ if($stored < $current) {
Config::load('database');
// We're reporting a different version than what is currently installed.
// updating right this very second and the correct version of the update.php
// file may not be here yet. This can happen on a very busy site.
- if (DB_UPDATE_VERSION == UPDATE_VERSION) {
+ if(DB_UPDATE_VERSION == UPDATE_VERSION) {
// 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());
// conflits with new routine)
for ($x = $stored; $x < NEW_UPDATE_ROUTINE_VERSION; $x++) {
$r = run_update_function($x);
- if (!$r) {
- break;
- }
- }
- if ($stored < NEW_UPDATE_ROUTINE_VERSION) {
- $stored = NEW_UPDATE_ROUTINE_VERSION;
+ if (!$r) break;
}
+ if ($stored < NEW_UPDATE_ROUTINE_VERSION) $stored = NEW_UPDATE_ROUTINE_VERSION;
+
// run new update routine
// it update the structure in one call
$retval = update_structure(false, true);
- if ($retval) {
+ if($retval) {
update_fail(
DB_UPDATE_VERSION,
$retval
}
// run any left update_nnnn functions in update.php
- for ($x = $stored; $x < $current; $x ++) {
+ for($x = $stored; $x < $current; $x ++) {
$r = run_update_function($x);
- if (!$r) {
- break;
- }
+ if (!$r) break;
}
}
}
}
function run_update_function($x) {
- if (function_exists('update_' . $x)) {
+ if(function_exists('update_' . $x)) {
// There could be a lot of processes running or about to run.
// We want exactly one process to run the update command.
// 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
$func = 'update_' . $x;
$retval = $func();
- if ($retval) {
+ if($retval) {
//send the administrator an e-mail
update_fail(
$x,
*
* @param App $a
*
- */
+ */
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;
$installed_arr = array();
- if (count($installed)) {
- foreach ($installed as $i) {
- if (! in_array($i['name'],$plugins_arr)) {
+ if(count($installed)) {
+ foreach($installed as $i) {
+ if(! in_array($i['name'],$plugins_arr)) {
uninstall_plugin($i['name']);
- } else {
+ }
+ else {
$installed_arr[] = $i['name'];
}
}
}
- if (count($plugins_arr)) {
- foreach ($plugins_arr as $p) {
- if (! in_array($p,$installed_arr)) {
+ if(count($plugins_arr)) {
+ foreach($plugins_arr as $p) {
+ if(! in_array($p,$installed_arr)) {
install_plugin($p);
}
}
$dest_url = $a->query_string;
- if (local_user()) {
+ 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)
));
$o .= replace_macros($tpl, array(
- '$dest_url' => $dest_url,
- '$logout' => t('Logout'),
- '$login' => t('Login'),
+ '$dest_url' => $dest_url,
+ '$logout' => t('Logout'),
+ '$login' => t('Login'),
- '$lname' => array('username', t('Nickname or Email: ') , '', ''),
- '$lpassword' => array('password', t('Password: '), '', ''),
- '$lremember' => array('remember', t('Remember me'), 0, ''),
+ '$lname' => array('username', t('Nickname or Email: ') , '', ''),
+ '$lpassword' => array('password', t('Password: '), '', ''),
+ '$lremember' => array('remember', t('Remember me'), 0, ''),
- '$openid' => !$noid,
- '$lopenid' => array('openid_url', t('Or login using OpenID: '),'',''),
+ '$openid' => !$noid,
+ '$lopenid' => array('openid_url', t('Or login using OpenID: '),'',''),
- '$hiddens' => $hiddens,
+ '$hiddens' => $hiddens,
- '$register' => $reg,
+ '$register' => $reg,
'$lostpass' => t('Forgot your password?'),
'$lostlink' => t('Password Reset'),
- '$tostitle' => t('Website Terms of Service'),
- '$toslink' => t('terms of service'),
+ '$tostitle' => t('Website Terms of Service'),
+ '$toslink' => t('terms of service'),
- '$privacytitle' => t('Website Privacy Policy'),
- '$privacylink' => t('privacy policy'),
+ '$privacytitle' => t('Website Privacy Policy'),
+ '$privacylink' => t('privacy policy'),
));
*/
function killme() {
- if (!get_app()->is_backend()) {
+ if (!get_app()->is_backend())
session_write_close();
- }
exit;
}
* @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();
* @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;
}
*/
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;
- }
}
/**
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;
- }
}
$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");
$found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'",
dbesc($parameters));
- if (!dbm::is_result($found)) {
+ if (!$found)
q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`)
VALUES ('%s', '%s', %d)",
dbesc($parameters),
dbesc(datetime_convert()),
intval($priority));
- }
// Should we quit and wait for the poller to be called as a cronjob?
if ($dont_fork) {
// 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");
// Find the theme that belongs to the user whose stuff we are looking at
- if ($a->profile_uid && ($a->profile_uid != local_user())) {
+ if($a->profile_uid && ($a->profile_uid != local_user())) {
$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($page_theme && local_user() && (local_user() != $a->profile_uid)) {
+ if(get_pconfig(local_user(),'system','always_my_theme'))
$page_theme = null;
- }
}
// $mobile_detect = new Mobile_Detect();
}
$theme_name = ((isset($_SESSION) && x($_SESSION,'mobile-theme')) ? $_SESSION['mobile-theme'] : $system_theme);
- if ($theme_name === '---') {
+ if($theme_name === '---') {
// user has selected to have the mobile theme be the same as the normal one
$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 &&
+ 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')) {
+ foreach($app_base_themes as $t) {
+ if(file_exists('view/theme/' . $t . '/style.css')||
+ 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?
}
$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');
}
$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)
if (dbm::is_result($p)) {
$tmp_dob = substr($p[0]['dob'],5);
- if (intval($tmp_dob)) {
+ if(intval($tmp_dob)) {
$y = datetime_convert($tz,$tz,'now','Y');
$bd = $y . '-' . $tmp_dob . ' 00:00';
$t_dob = strtotime($bd);
$now = strtotime(datetime_convert($tz,$tz,'now'));
- if ($t_dob < $now) {
+ if($t_dob < $now)
$bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
- }
$birthday = datetime_convert($tz,'UTC',$bd,ATOM_TIME);
}
}
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
- //if (local_user() && x($a->user,'email') && x($a->config,'admin_email') && ($a->user['email'] === $a->config['admin_email']))
- if (local_user() && x($a->user,'email') && x($a->config,'admin_email') && in_array($a->user['email'], $adminlist))
+ //if(local_user() && x($a->user,'email') && x($a->config,'admin_email') && ($a->user['email'] === $a->config['admin_email']))
+ if(local_user() && x($a->user,'email') && x($a->config,'admin_email') && in_array($a->user['email'], $adminlist))
return true;
return false;
}
*/
function build_querystring($params, $name=null) {
$ret = "";
- foreach ($params as $key=>$val) {
- if (is_array($val)) {
- if ($name==null) {
+ foreach($params as $key=>$val) {
+ if(is_array($val)) {
+ if($name==null) {
$ret .= build_querystring($val, $key);
} else {
$ret .= build_querystring($val, $name."[$key]");
}
} else {
$val = urlencode($val);
- if ($name!=null) {
+ if($name!=null) {
$ret.=$name."[$key]"."=$val&";
} else {
$ret.= "$key=$val&";
function explode_querystring($query) {
$arg_st = strpos($query, '?');
- if ($arg_st !== false) {
+ if($arg_st !== false) {
$base = substr($query, 0, $arg_st);
$arg_st += 1;
} else {
}
$args = explode('&', substr($query, $arg_st));
- foreach ($args as $k=>$arg) {
- if ($arg === '') {
+ foreach($args as $k=>$arg) {
+ if($arg === '')
unset($args[$k]);
- }
}
$args = array_values($args);
- if (!$base) {
+ if(!$base) {
$base = $args[0];
unset($args[0]);
$args = array_values($args);
*/
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"];
function random_digits($digits) {
$rn = '';
- for ($i = 0; $i < $digits; $i++) {
+ for($i = 0; $i < $digits; $i++) {
$rn .= rand(0,9);
}
return $rn;
function get_server() {
$server = get_config("system", "directory");
- if ($server == "") {
+ if ($server == "")
$server = "http://dir.friendi.ca";
- }
return($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);
$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);
}
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)) {
if ($temppath != "") {
$itemcache = $temppath."/itemcache";
- if (!file_exists($itemcache) && !is_dir($itemcache)) {
+ if(!file_exists($itemcache) && !is_dir($itemcache)) {
mkdir($itemcache);
}
$a->set_template_engine($engine);
}
-if (!function_exists('exif_imagetype')) {
+if(!function_exists('exif_imagetype')) {
function exif_imagetype($file) {
$size = getimagesize($file);
return($size[2]);
$file = realpath($file);
- if (strpos($file, getcwd()) !== 0) {
+ if (strpos($file, getcwd()) !== 0)
return false;
- }
$file = str_replace(getcwd()."/", "", $file, $count);
- if ($count != 1) {
+ if ($count != 1)
return false;
- }
- if ($orig_file !== $file) {
+ if ($orig_file !== $file)
return false;
- }
$valid = false;
- if (strpos($file, "include/") === 0) {
+ if (strpos($file, "include/") === 0)
$valid = true;
- }
- if (strpos($file, "addon/") === 0) {
+ if (strpos($file, "addon/") === 0)
$valid = true;
- }
- // Simply return flag
- return ($valid);
+ if (!$valid)
+ return false;
+
+ return true;
}
function current_load() {
- if (!function_exists('sys_getloadavg')) {
+ if (!function_exists('sys_getloadavg'))
return false;
- }
$load_arr = sys_getloadavg();
- if (!is_array($load_arr)) {
+ if (!is_array($load_arr))
return false;
- }
return max($load_arr[0], $load_arr[1]);
}
* @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 '';
}
// authorisation to do this.
function user_remove($uid) {
- if (! $uid)
+ if(! $uid)
return;
logger('Removing user: ' . $uid);
// Send an update to the directory
proc_run(PRIORITY_LOW, "include/directory.php", $r[0]['url']);
- if ($uid == local_user()) {
+ if($uid == local_user()) {
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
goaway(App::get_baseurl());
// This provides for the possibility that their database is temporarily messed
// up or some other transient event and that there's a possibility we could recover from it.
-function mark_for_death(array $contact) {
+function mark_for_death($contact) {
- if ($contact['archive']) {
+ if($contact['archive'])
return;
- }
- /// @TODO Comparison of strings this way may lead to bugs/incompatibility, better switch to DateTime
if ($contact['term-date'] <= NULL_DATE) {
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),
/// Check for contact vitality via probing
$expiry = $contact['term-date'] . ' + 32 days ';
- if (datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
+ if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
// relationship is really truly dead.
// archive them rather than delete
function contacts_not_grouped($uid,$start = 0,$count = 0) {
- if (! $count) {
+ if(! $count) {
$r = q("select count(*) as total from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) ",
intval($uid),
intval($uid)
function formatted_location($profile) {
$location = '';
- if ($profile['locality'])
+ if($profile['locality'])
$location .= $profile['locality'];
- if ($profile['region'] AND ($profile['locality'] != $profile['region'])) {
- if ($location)
+ if($profile['region'] AND ($profile['locality'] != $profile['region'])) {
+ if($location)
$location .= ', ';
$location .= $profile['region'];
}
- if ($profile['country-name']) {
- if ($location)
+ if($profile['country-name']) {
+ if($location)
$location .= ', ';
$location .= $profile['country-name'];
// "page-flags" is a field in the user table,
// "forum" and "prv" are used in the contact table. They stand for PAGE_COMMUNITY and PAGE_PRVGROUP.
// "community" is used in the gcontact table and is true if the contact is PAGE_COMMUNITY or PAGE_PRVGROUP.
- if ((isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_COMMUNITY))
+ if((isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_COMMUNITY))
|| (isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_PRVGROUP))
|| (isset($contact['forum']) && intval($contact['forum']))
|| (isset($contact['prv']) && intval($contact['prv']))
$a->config[$uid][$family][$k] = $rr['v'];
self::$in_db[$uid][$family][$k] = true;
}
- } elseif ($family != 'config') {
+ } else if ($family != 'config') {
// Negative caching
$a->config[$uid][$family] = "!<unset>!";
}
*/
public static function global_search_by_name($search, $mode = '') {
- if ($search) {
+ if($search) {
// check supported networks
if (get_config('system','diaspora_enabled'))
$diaspora = NETWORK_DIASPORA;
$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 .= "%";
if (!$contacts)
return($forumlist);
- foreach ($contacts as $contact) {
+ foreach($contacts as $contact) {
$forumlist[] = array(
'url' => $contact['url'],
'name' => $contact['name'],
*/
public static function widget($uid,$cid = 0) {
- if (! intval(feature_enabled(local_user(),'forumlist_widget')))
+ if(! intval(feature_enabled(local_user(),'forumlist_widget')))
return;
$o = '';
$id = 0;
- foreach ($contacts as $contact) {
+ foreach($contacts as $contact) {
$selected = (($cid == $contact['id']) ? ' forum-selected' : '');
public static function profile_advanced($uid) {
$profile = intval(feature_enabled($uid,'forumlist_profile'));
- if (! $profile)
+ if(! $profile)
return;
$o = '';
$total_shown = 0;
- foreach ($contacts as $contact) {
+ 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;
+ return $o;
}
/**
*/
private function _set_extra($notes) {
$rets = array();
- foreach ($notes as $n) {
+ foreach($notes as $n) {
$local_time = datetime_convert('UTC',date_default_timezone_get(),$n['date']);
$n['timestamp'] = strtotime($local_time);
$n['date_rel'] = relative_date($n['date']);
public function getAll($filter = array(), $order="-date", $limit="") {
$filter_str = array();
$filter_sql = "";
- foreach ($filter as $column => $value) {
+ foreach($filter as $column => $value) {
$filter_str[] = sprintf("`%s` = '%s'", $column, dbesc($value));
}
if (count($filter_str)>0) {
$aOrder = explode(" ", $order);
$asOrder = array();
- foreach ($aOrder as $o) {
+ foreach($aOrder as $o) {
$dir = "asc";
if ($o[0]==="-") {
$dir = "desc";
}
$order_sql = implode(", ", $asOrder);
- if ($limit!="")
+ if($limit!="")
$limit = " LIMIT ".$limit;
$r = q("SELECT * FROM `notify` WHERE `uid` = %d $filter_sql ORDER BY $order_sql $limit",
private function networkTotal($seen = 0) {
$sql_seen = "";
- if ($seen === 0)
+ if($seen === 0)
$sql_seen = " AND `item`.`unseen` = 1 ";
$r = q("SELECT COUNT(*) AS `total`
$notifs = array();
$sql_seen = "";
- if ($seen === 0)
+ if($seen === 0)
$sql_seen = " AND `item`.`unseen` = 1 ";
private function systemTotal($seen = 0) {
$sql_seen = "";
- if ($seen === 0)
+ if($seen === 0)
$sql_seen = " AND `seen` = 0 ";
$r = q("SELECT COUNT(*) AS `total` FROM `notify` WHERE `uid` = %d $sql_seen",
$notifs = array();
$sql_seen = "";
- if ($seen === 0)
+ if($seen === 0)
$sql_seen = " AND `seen` = 0 ";
$r = q("SELECT `id`, `url`, `photo`, `msg`, `date`, `seen` FROM `notify`
$sql_seen = "";
$sql_extra = $this->_personal_sql_extra();
- if ($seen === 0)
+ if($seen === 0)
$sql_seen = " AND `item`.`unseen` = 1 ";
$r = q("SELECT COUNT(*) AS `total`
$notifs = array();
$sql_seen = "";
- if ($seen === 0)
+ if($seen === 0)
$sql_seen = " AND `item`.`unseen` = 1 ";
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, `item`.`unseen`,
private function homeTotal($seen = 0) {
$sql_seen = "";
- if ($seen === 0)
+ if($seen === 0)
$sql_seen = " AND `item`.`unseen` = 1 ";
$r = q("SELECT COUNT(*) AS `total` FROM `item`
$notifs = array();
$sql_seen = "";
- if ($seen === 0)
+ if($seen === 0)
$sql_seen = " AND `item`.`unseen` = 1 ";
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, `item`.`unseen`,
private function introTotal($all = false) {
$sql_extra = "";
- if (!$all)
+ if(!$all)
$sql_extra = " AND `ignore` = 0 ";
$r = q("SELECT COUNT(*) AS `total` FROM `intro`
$notifs = array();
$sql_extra = "";
- if (!$all)
+ if(!$all)
$sql_extra = " AND `ignore` = 0 ";
/// @todo Fetch contact details by "get_contact_details_by_url" instead of queries to contact, fcontact and gcontact
private function formatIntros($intros) {
$knowyou = '';
- foreach ($intros as $it) {
+ foreach($intros as $it) {
// There are two kind of introduction. Contacts suggested by other contacts and normal connection requests.
// We have to distinguish between these two because they use different data.
// Contact suggestions
- if ($it['fid']) {
+ if($it['fid']) {
$return_addr = bin2hex($this->a->user['nickname'] . '@' . $this->a->get_hostname() . (($this->a->path) ? '/' . $this->a->path : ''));
$it['gnetwork'] = $ret["network"];
// Don't show these data until you are connected. Diaspora is doing the same.
- if ($it['gnetwork'] === NETWORK_DIASPORA) {
+ if($it['gnetwork'] === NETWORK_DIASPORA) {
$it['glocation'] = "";
$it['gabout'] = "";
$it['ggender'] = "";
*/
public static function valid_dfrn($data) {
$errors = 0;
- if (!isset($data['key']))
+ if(!isset($data['key']))
$errors ++;
- if (!isset($data['dfrn-request']))
+ if(!isset($data['dfrn-request']))
$errors ++;
- if (!isset($data['dfrn-confirm']))
+ if(!isset($data['dfrn-confirm']))
$errors ++;
- if (!isset($data['dfrn-notify']))
+ if(!isset($data['dfrn-notify']))
$errors ++;
- if (!isset($data['dfrn-poll']))
+ if(!isset($data['dfrn-poll']))
$errors ++;
return $errors;
}
$data = array();
if (is_array($webfinger["aliases"]))
- foreach ($webfinger["aliases"] AS $alias)
+ foreach($webfinger["aliases"] AS $alias)
if (strstr($alias, "@"))
$data["addr"] = str_replace('acct:', '', $alias);
$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();
$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)
+ if(isset($adr)) {
+ foreach($adr as $feadr) {
+ if((strcasecmp($feadr->mailbox, $data["name"]) == 0)
&&(strcasecmp($feadr->host, $phost) == 0)
&& (strlen($feadr->personal))) {
$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"]);
}
* @return string HML Output of the Smilie
*/
public static function replace($s, $sample = false) {
- if (intval(get_config('system','no_smilies'))
+ if(intval(get_config('system','no_smilies'))
|| (local_user() && intval(get_pconfig(local_user(),'system','no_smilies'))))
return $s;
$params = self::get_list();
$params['string'] = $s;
- if ($sample) {
+ if($sample) {
$s = '<div class="smiley-sample">';
- for ($x = 0; $x < count($params['texts']); $x ++) {
+ for($x = 0; $x < count($params['texts']); $x ++) {
$s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>';
}
}
* @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="<3" />';
- }
$r = str_replace($x[0],$t,$x[0]);
return $r;
}
if (dbm::is_result($r)) {
foreach ($r as $rr) {
- if ((is_array($preselected)) && in_array($rr['id'], $preselected))
+ if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" ";
else
$selected = '';
$networks = array(NETWORK_DFRN);
break;
case 'PRIVATE':
- if (is_array($a->user) && $a->user['prvnets'])
+ if(is_array($a->user) && $a->user['prvnets'])
$networks = array(NETWORK_DFRN,NETWORK_MAIL,NETWORK_DIASPORA);
else
$networks = array(NETWORK_DFRN,NETWORK_FACEBOOK,NETWORK_MAIL, NETWORK_DIASPORA);
break;
case 'TWO_WAY':
- if (is_array($a->user) && $a->user['prvnets'])
+ if(is_array($a->user) && $a->user['prvnets'])
$networks = array(NETWORK_DFRN,NETWORK_MAIL,NETWORK_DIASPORA);
else
$networks = array(NETWORK_DFRN,NETWORK_FACEBOOK,NETWORK_MAIL,NETWORK_DIASPORA,NETWORK_OSTATUS);
$sql_extra = '';
- if ($x['mutual']) {
+ if($x['mutual']) {
$sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
}
- if (intval($x['exclude']))
+ if(intval($x['exclude']))
$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 ++) {
+ if(is_array($x['networks']) && count($x['networks'])) {
+ 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 ) ";
}
$tabindex = (x($options, 'tabindex') ? "tabindex=\"" . $options["tabindex"] . "\"" : "");
- if ($x['single'])
+ if($x['single'])
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"" . $x['size'] . "\" $tabindex >\r\n";
else
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" $tabindex >\r\n";
$sql_extra = '';
- if ($privmail || $celeb) {
+ if($privmail || $celeb) {
$sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
}
- if ($privmail)
+ if($privmail)
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ",
NETWORK_DFRN, NETWORK_DIASPORA);
- elseif ($privatenet)
+ elseif($privatenet)
$sql_extra .= sprintf(" AND `network` IN ('%s' , '%s', '%s', '%s') ",
NETWORK_DFRN, NETWORK_MAIL, NETWORK_FACEBOOK, NETWORK_DIASPORA);
} else
$hidepreselected = "";
- if ($privmail)
+ if($privmail)
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" $tabindex $hidepreselected>\r\n";
else
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex >\r\n";
function get_acl_permissions($user = null) {
$allow_cid = $allow_gid = $deny_cid = $deny_gid = false;
- if (is_array($user)) {
+ if(is_array($user)) {
$allow_cid = ((strlen($user['allow_cid']))
? explode('><', $user['allow_cid']) : array() );
$allow_gid = ((strlen($user['allow_gid']))
$perms = get_acl_permissions($user);
$jotnets = '';
- if ($show_jotnets) {
+ if($show_jotnets) {
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
$mail_enabled = false;
$pubmail_enabled = false;
- if (! $mail_disabled) {
+ if(! $mail_disabled) {
$r = q("SELECT `pubmail` FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user())
);
if (dbm::is_result($r)) {
$mail_enabled = true;
- if (intval($r[0]['pubmail']))
+ if(intval($r[0]['pubmail']))
$pubmail_enabled = true;
}
}
if (!$user['hidewall']) {
- if ($mail_enabled) {
+ if($mail_enabled) {
$selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
$jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> ' . t("Post to Email") . '</div>';
}
$user_defaults = get_acl_permissions($user);
- if ($acl_data['groups']) {
- foreach ($acl_data['groups'] as $key=>$group) {
+ if($acl_data['groups']) {
+ foreach($acl_data['groups'] as $key=>$group) {
// Add a "selected" flag to groups that are posted to by default
- if ($user_defaults['allow_gid'] &&
+ if($user_defaults['allow_gid'] &&
in_array($group['id'], $user_defaults['allow_gid']) && !in_array($group['id'], $user_defaults['deny_gid']) )
$acl_data['groups'][$key]['selected'] = 1;
else
$acl_data['groups'][$key]['selected'] = 0;
}
}
- if ($acl_data['contacts']) {
- foreach ($acl_data['contacts'] as $key=>$contact) {
+ if($acl_data['contacts']) {
+ foreach($acl_data['contacts'] as $key=>$contact) {
// Add a "selected" flag to groups that are posted to by default
- if ($user_defaults['allow_cid'] &&
+ if($user_defaults['allow_cid'] &&
in_array($contact['id'], $user_defaults['allow_cid']) && !in_array($contact['id'], $user_defaults['deny_cid']) )
$acl_data['contacts'][$key]['selected'] = 1;
else
// For use with jquery.textcomplete for private mail completion
- if (x($_REQUEST,'query') && strlen($_REQUEST['query'])) {
- if (! $type)
+ if(x($_REQUEST,'query') && strlen($_REQUEST['query'])) {
+ if(! $type)
$type = 'm';
$search = $_REQUEST['query'];
}
intval($count)
);
- foreach ($r as $g){
+ foreach($r as $g){
// logger('acl: group: ' . $g['name'] . ' members: ' . $g['uids']);
$groups[] = array(
"type" => "g",
dbesc(NETWORK_STATUSNET)
);
}
- elseif ($type == 'm') {
+ elseif($type == 'm') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact`
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
AND `network` IN ('%s','%s','%s')
call_hooks('acl_lookup_end', $results);
- if ($out_type === 'html') {
+ if($out_type === 'html') {
$o = array(
'tot' => $results['tot'],
'start' => $results['start'],
// workaround for HTTP-auth in CGI mode
- if (x($_SERVER,'REDIRECT_REMOTE_USER')) {
+ if(x($_SERVER,'REDIRECT_REMOTE_USER')) {
$userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"],6)) ;
- if (strlen($userpass)) {
+ if(strlen($userpass)) {
list($name, $password) = explode(':', $userpass);
$_SERVER['PHP_AUTH_USER'] = $name;
$_SERVER['PHP_AUTH_PW'] = $password;
call_hooks('authenticate', $addon_auth);
- if (($addon_auth['authenticated']) && (count($addon_auth['user_record']))) {
+ if(($addon_auth['authenticated']) && (count($addon_auth['user_record']))) {
$record = $addon_auth['user_record'];
}
else {
$record = $r[0];
}
- if ((! $record) || (! count($record))) {
+ if((! $record) || (! count($record))) {
logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG);
header('WWW-Authenticate: Basic realm="Friendica"');
#header('HTTP/1.0 401 Unauthorized');
break;
case "json":
header ("Content-Type: application/json");
- foreach ($r as $rr)
+ foreach($r as $rr)
$json = json_encode($rr);
if ($_GET['callback'])
$json = $_GET['callback']."(".$json.")";
logger("api_get_user: Fetching user data for user ".$contact_id, LOGGER_DEBUG);
// Searching for contact URL
- if (!is_null($contact_id) AND (intval($contact_id) == 0)){
+ if(!is_null($contact_id) AND (intval($contact_id) == 0)){
$user = dbesc(normalise_link($contact_id));
$url = $user;
$extra_query = "AND `contact`.`nurl` = '%s' ";
}
// Searching for contact id with uid = 0
- if (!is_null($contact_id) AND (intval($contact_id) != 0)){
+ if(!is_null($contact_id) AND (intval($contact_id) != 0)){
$user = dbesc(api_unique_id_to_url($contact_id));
if ($user == "")
if (api_user()!==false) $extra_query .= "AND `contact`.`uid`=".intval(api_user());
}
- if (is_null($user) && x($_GET, 'user_id')) {
+ if(is_null($user) && x($_GET, 'user_id')) {
$user = dbesc(api_unique_id_to_url($_GET['user_id']));
if ($user == "")
$extra_query = "AND `contact`.`nurl` = '%s' ";
if (api_user()!==false) $extra_query .= "AND `contact`.`uid`=".intval(api_user());
}
- if (is_null($user) && x($_GET, 'screen_name')) {
+ if(is_null($user) && x($_GET, 'screen_name')) {
$user = dbesc($_GET['screen_name']);
$nick = $user;
$extra_query = "AND `contact`.`nick` = '%s' ";
if (is_null($user) AND ($a->argc > (count($called_api)-1)) AND (count($called_api) > 0)){
$argid = count($called_api);
list($user, $null) = explode(".",$a->argv[$argid]);
- if (is_numeric($user)){
+ if(is_numeric($user)){
$user = dbesc(api_unique_id_to_url($user));
if ($user == "")
}
}
- if ($uinfo[0]['self']) {
+ if($uinfo[0]['self']) {
if ($uinfo[0]['network'] == "")
$uinfo[0]['network'] = NETWORK_DFRN;
$starred = $r[0]['count'];
- if (! $uinfo[0]['self']) {
+ if(! $uinfo[0]['self']) {
$countfriends = 0;
$countfollowers = 0;
$starred = 0;
$txt = requestdata('status');
//$txt = urldecode(requestdata('status'));
- if ((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
+ if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
$txt = html2bb_video($txt);
$config = HTMLPurifier_Config::createDefault();
// logger('api_post: ' . print_r($_POST,true));
- if (requestdata('htmlstatus')) {
+ if(requestdata('htmlstatus')) {
$txt = requestdata('htmlstatus');
- if ((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
+ if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
$txt = html2bb_video($txt);
$config = HTMLPurifier_Config::createDefault();
if ($parent == -1)
$parent = "";
- if (ctype_digit($parent))
+ if(ctype_digit($parent))
$_REQUEST['parent'] = $parent;
else
$_REQUEST['parent_uri'] = $parent;
- if (requestdata('lat') && requestdata('long'))
+ if(requestdata('lat') && requestdata('long'))
$_REQUEST['coord'] = sprintf("%s %s",requestdata('lat'),requestdata('long'));
$_REQUEST['profile_uid'] = api_user();
- if ($parent)
+ if($parent)
$_REQUEST['type'] = 'net-comment';
else {
// Check for throttling (maximum posts per day, week and month)
$_REQUEST['type'] = 'wall';
}
- if (x($_FILES,'media')) {
+ if(x($_FILES,'media')) {
// upload the image if we have one
$_REQUEST['hush']='yeah'; //tell wall_upload function to return img info instead of echo
$media = wall_upload_post($a);
- if (strlen($media)>0)
+ if(strlen($media)>0)
$_REQUEST['body'] .= "\n\n".$media;
}
$user_info = api_get_user($a);
- if (!x($_FILES,'media')) {
+ if(!x($_FILES,'media')) {
// Output error
throw new BadRequestException("No media.");
}
$media = wall_upload_post($a, false);
- if (!$media) {
+ if(!$media) {
// Output error
throw new InternalServerErrorException();
}
$ret = Array();
- foreach ($r as $item) {
+ foreach($r as $item) {
localize_item($item);
list($status_user, $owner_user) = api_item_get_user($a,$item);
return false;
}
- if ($qtype == 'friends')
+ if($qtype == 'friends')
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
- if ($qtype == 'followers')
+ if($qtype == 'followers')
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
// friends and followers only for self
);
$ret = array();
- foreach ($r as $cid){
+ foreach($r as $cid){
$user = api_get_user($a, $cid['nurl']);
// "uid" and "self" are only needed for some internal stuff, so remove it from here
unset($user["uid"]);
$closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false');
$private = ((Config::get('system', 'block_public')) ? 'true' : 'false');
$textlimit = (string) (($a->config['max_import_size']) ? $a->config['max_import_size'] : 200000);
- if ($a->config['api_import_size'])
+ if($a->config['api_import_size'])
$texlimit = string($a->config['api_import_size']);
$ssl = ((Config::get('system', 'have_ssl')) ? 'true' : 'false');
$sslserver = (($ssl === 'true') ? str_replace('http:','https:',App::get_baseurl()) : '');
$a = get_app();
- if (! api_user()) throw new ForbiddenException();
+ if(! api_user()) throw new ForbiddenException();
$user_info = api_get_user($a);
- if ($qtype == 'friends')
+ if($qtype == 'friends')
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
- if ($qtype == 'followers')
+ if($qtype == 'followers')
$sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
if (!$user_info["self"])
return;
$ids = array();
- foreach ($r as $rr)
+ foreach($r as $rr)
if ($stringify_ids)
$ids[] = $rr['id'];
else
if ($user_id !="") {
$sql_extra .= ' AND `mail`.`contact-id` = ' . intval($user_id);
}
- elseif ($screen_name !=""){
+ elseif($screen_name !=""){
$sql_extra .= " AND `contact`.`nick` = '" . dbesc($screen_name). "'";
}
);
if ($verbose == "true") {
// stop execution and return error message if no mails available
- if ($r == null) {
+ if($r == null) {
$answer = array('result' => 'error', 'message' => 'no mails available');
return api_format_data("direct_messages_all", $type, array('$result' => $answer));
}
}
$ret = Array();
- foreach ($r as $item) {
+ foreach($r as $item) {
if ($box == "inbox" || $item['from-url'] != $profile_url){
$recipient = $user_info;
$sender = api_get_user($a,normalise_link($item['contact-url']));
function api_fr_photo_detail($type) {
if (api_user()===false) throw new ForbiddenException();
- if (!x($_REQUEST,'photo_id')) throw new BadRequestException("No photo id.");
+ if(!x($_REQUEST,'photo_id')) throw new BadRequestException("No photo id.");
$scale = (x($_REQUEST, 'scale') ? intval($_REQUEST['scale']) : false);
$scale_sql = ($scale === false ? "" : sprintf("and scale=%d",intval($scale)));
$dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
- if ($r[0]['duplex'] && $r[0]['issued-id']) {
+ if($r[0]['duplex'] && $r[0]['issued-id']) {
$orig_id = $r[0]['issued-id'];
$dfrn_id = '1:' . $orig_id;
}
- if ($r[0]['duplex'] && $r[0]['dfrn-id']) {
+ if($r[0]['duplex'] && $r[0]['dfrn-id']) {
$orig_id = $r[0]['dfrn-id'];
$dfrn_id = '0:' . $orig_id;
}
$success = array('success' => false, 'search_results' => 'nothing found');
else {
$ret = Array();
- foreach ($r as $item) {
+ foreach($r as $item) {
if ($box == "inbox" || $item['from-url'] != $profile_url){
$recipient = $user_info;
$sender = api_get_user($a,normalise_link($item['contact-url']));
);
$dot = strpos($filename,'.');
- if ($dot !== false) {
+ if($dot !== false) {
$ext = strtolower(substr($filename,$dot+1));
if (array_key_exists($ext, $mime_types)) {
return $mime_types[$ext];
// Add all tags that maybe were removed
if (preg_match_all("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",$OriginalText, $tags)) {
$tagline = "";
- foreach ($tags[2] as $tag) {
+ foreach($tags[2] as $tag) {
$tag = html_entity_decode($tag, ENT_QUOTES, 'UTF-8');
if (!strpos(html_entity_decode($Text, ENT_QUOTES, 'UTF-8'), "#".$tag))
$tagline .= "#".$tag." ";
function format_event_diaspora($ev) {
- if (! ((is_array($ev)) && count($ev)))
+ if(! ((is_array($ev)) && count($ev)))
return '';
$bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
$ev['start'] , $bd_format)))
. '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
- if (! $ev['nofinish'])
+ if(! $ev['nofinish'])
$o .= t('Finishes:') . ' ' . '['
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format ))
$ev['finish'] , $bd_format )))
. '](' . App::get_baseurl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
- if (strlen($ev['location']))
+ if(strlen($ev['location']))
$o .= t('Location:') . bb2diaspora($ev['location'])
. "\n";
// returning [i]italic[/i]
function bb_unspacefy_and_trim($st) {
- $whole_match = $st[0];
- $captured = $st[1];
- $unspacefied = preg_replace("/\[ (.*?)\ ]/", "[$1]", $captured);
- return $unspacefied;
+ $whole_match = $st[0];
+ $captured = $st[1];
+ $unspacefied = preg_replace("/\[ (.*?)\ ]/", "[$1]", $captured);
+ return $unspacefied;
}
function bb_find_open_close($s, $open, $close, $occurance = 1) {
- if ($occurance < 1)
+ if($occurance < 1)
$occurance = 1;
$start_pos = -1;
- for ($i = 1; $i <= $occurance; $i++) {
- if ( $start_pos !== false) {
+ for($i = 1; $i <= $occurance; $i++) {
+ 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 );
function get_bb_tag_pos($s, $name, $occurance = 1) {
- if ($occurance < 1)
+ if($occurance < 1)
$occurance = 1;
$start_open = -1;
- for ($i = 1; $i <= $occurance; $i++) {
- if ( $start_open !== false) {
+ for($i = 1; $i <= $occurance; $i++) {
+ if( $start_open !== false)
$start_open = strpos($s, '[' . $name, $start_open + 1); // allow [name= type tags
- }
}
- if ( $start_open === false)
+ if( $start_open === false)
return false;
$start_equal = strpos($s, '=', $start_open);
$start_close = strpos($s, ']', $start_open);
- if ( $start_close === false)
+ if( $start_close === false)
return false;
$start_close++;
$end_open = strpos($s, '[/' . $name . ']', $start_close);
- if ( $end_open === false)
+ if( $end_open === false)
return false;
$res = array( 'start' => array('open' => $start_open, 'close' => $start_close),
'end' => array('open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']')) );
- if ( $start_equal !== false)
+ if( $start_equal !== false)
$res['start']['equal'] = $start_equal + 1;
return $res;
$occurance = 1;
$pos = get_bb_tag_pos($string, $name, $occurance);
- while ($pos !== false && $occurance < 1000) {
+ while($pos !== false && $occurance < 1000) {
$start = substr($string, 0, $pos['start']['open']);
$subject = substr($string, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
$end = substr($string, $pos['end']['close']);
- if ($end === false)
+ if($end === false)
$end = '';
$subject = preg_replace($pattern, $replace, $subject);
return $string;
}
-if (! function_exists('bb_extract_images')) {
+if(! function_exists('bb_extract_images')) {
function bb_extract_images($body) {
$saved_image = array();
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
- while (($img_st_close !== false) && ($img_end !== false)) {
+ while(($img_st_close !== false) && ($img_end !== false)) {
$img_st_close++; // make it point to AFTER the closing bracket
$img_end += $img_start;
- if (! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
+ if(! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
// This is an embedded image
$saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
$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');
return array('body' => $new_body, 'images' => $saved_image);
}}
-if (! function_exists('bb_replace_images')) {
+if(! function_exists('bb_replace_images')) {
function bb_replace_images($body, $images) {
$newbody = $body;
function bb_RemovePictureLinks($match) {
$text = Cache::get($match[1]);
- if (is_null($text)){
+ if(is_null($text)){
$a = get_app();
$stamp1 = microtime(true);
function bb_CleanPictureLinksSub($match) {
$text = Cache::get($match[1]);
- if (is_null($text)){
+ if(is_null($text)){
$a = get_app();
$stamp1 = microtime(true);
}
function bb_highlight($match) {
- if (in_array(strtolower($match[1]),['php','css','mysql','sql','abap','diff','html','perl','ruby',
+ if(in_array(strtolower($match[1]),['php','css','mysql','sql','abap','diff','html','perl','ruby',
'vbscript','avrc','dtd','java','xml','cpp','python','javascript','js','sh']))
return text_highlight($match[2],strtolower($match[1]));
return $match[0];
$Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);
- if ($preserve_nl)
+ if($preserve_nl)
$Text = str_replace(array("\n","\r"), array('',''),$Text);
// Set up the parameters for a URL search string
// Summary (e.g. title) is required, earlier revisions only required description (in addition to
// start which is always required). Allow desc with a missing summary for compatibility.
- if ((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) {
+ if((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) {
$sub = format_event_html($ev, $simplehtml);
$Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text);
$regex = '#<([^>]*?)(href)="(?!' . implode('|', $allowed_link_protocols) . ')(.*?)"(.*?)>#ism';
$Text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 class="invalid-href" title="' . t('Invalid link protocol') . '">', $Text);
- if ($saved_image) {
+ if($saved_image) {
$Text = bb_replace_images($Text, $saved_image);
}
require_once("dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
- };
+ };
require_once('include/session.php');
5 => t('Reputable, has my trust')
);
- foreach ($rep as $k => $v) {
+ foreach($rep as $k => $v) {
$selected = (($k == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"$k\" $selected >$v</option>\r\n";
}
5 => t('Monthly')
);
- foreach ($rep as $k => $v) {
+ foreach($rep as $k => $v) {
$selected = (($k == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"$k\" $selected >$v</option>\r\n";
}
$a = get_app();
- if (get_config('system','invitation_only')) {
+ if(get_config('system','invitation_only')) {
$x = get_pconfig(local_user(),'system','invites_remaining');
- if ($x || is_site_admin()) {
+ if($x || is_site_admin()) {
$a->page['aside'] .= '<div class="side-link" id="side-invite-remain">'
. sprintf( tt('%d invitation available','%d invitations available',$x), $x)
. '</div>' . $inv;
}
}
- if (count($nets) < 2)
+ if(count($nets) < 2)
return '';
return replace_macros(get_markup_template('nets.tpl'),array(
$terms = array();
$cnt = preg_match_all('/\[(.*?)\]/',$saved,$matches,PREG_SET_ORDER);
if ($cnt) {
- foreach ($matches as $mtch) {
+ foreach($matches as $mtch) {
$unescaped = xmlify(file_tag_decode($mtch[1]));
$terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? '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]));
+ $cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ $unescaped = xmlify(file_tag_decode($mtch[1]));
$terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : ''));
}
}
$a = get_app();
- if (local_user() == $profile_uid)
+ if(local_user() == $profile_uid)
return;
$cid = $zcid = 0;
- if (is_array($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $visitor) {
- if ($visitor['uid'] == $profile_uid) {
+ if(is_array($_SESSION['remote'])) {
+ foreach($_SESSION['remote'] as $visitor) {
+ if($visitor['uid'] == $profile_uid) {
$cid = $visitor['cid'];
break;
}
}
}
- if (! $cid) {
- if (get_my_url()) {
+ if(! $cid) {
+ if(get_my_url()) {
$r = q("select id from contact where nurl = '%s' and uid = %d limit 1",
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 ($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),
// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
// is identical to the code in mod/message.php for 'item_extract_images' and
// 'item_redir_and_replace_images'
-if (! function_exists('item_extract_images')) {
+if(! function_exists('item_extract_images')) {
function item_extract_images($body) {
$saved_image = array();
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
- while (($img_st_close !== false) && ($img_end !== false)) {
+ while(($img_st_close !== false) && ($img_end !== false)) {
$img_st_close++; // make it point to AFTER the closing bracket
$img_end += $img_start;
- if (! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
+ if(! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
// This is an embedded image
$saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
$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');
return array('body' => $new_body, 'images' => $saved_image);
}}
-if (! function_exists('item_redir_and_replace_images')) {
+if(! function_exists('item_redir_and_replace_images')) {
function item_redir_and_replace_images($body, $images, $cid) {
$origbody = $body;
$cnt = 1;
$pos = get_bb_tag_pos($origbody, 'url', 1);
- while ($pos !== false && $cnt < 1000) {
+ while($pos !== false && $cnt < 1000) {
$search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is';
$replace = '[url=' . z_path() . '/redir/' . $cid
$newbody .= substr($origbody, 0, $pos['start']['open']);
$subject = substr($origbody, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
$origbody = substr($origbody, $pos['end']['close']);
- if ($origbody === false)
+ if($origbody === false)
$origbody = '';
$subject = preg_replace($search, $replace, $subject);
function localize_item(&$item){
$extracted = item_extract_images($item['body']);
- if ($extracted['images'])
+ if($extracted['images'])
$item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']);
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
}
break;
default:
- if ($obj['resource-id']){
+ if($obj['resource-id']){
$post_type = t('photo');
$m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
$rr['plink'] = $m[1];
$plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
- if (activity_match($item['verb'],ACTIVITY_LIKE)) {
+ if(activity_match($item['verb'],ACTIVITY_LIKE)) {
$bodyverb = t('%1$s likes %2$s\'s %3$s');
}
- elseif (activity_match($item['verb'],ACTIVITY_DISLIKE)) {
+ elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
}
- elseif (activity_match($item['verb'],ACTIVITY_ATTEND)) {
+ elseif(activity_match($item['verb'],ACTIVITY_ATTEND)) {
$bodyverb = t('%1$s attends %2$s\'s %3$s');
}
- elseif (activity_match($item['verb'],ACTIVITY_ATTENDNO)) {
+ elseif(activity_match($item['verb'],ACTIVITY_ATTENDNO)) {
$bodyverb = t('%1$s doesn\'t attend %2$s\'s %3$s');
}
- elseif (activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)) {
+ elseif(activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)) {
$bodyverb = t('%1$s attends maybe %2$s\'s %3$s');
}
$item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
}
if (stristr($item['verb'],ACTIVITY_POKE)) {
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
- if (! $verb)
+ if(! $verb)
return;
if ($item['object-type']=="" || $item['object-type']!== ACTIVITY_OBJ_PERSON) return;
}
if (stristr($item['verb'],ACTIVITY_MOOD)) {
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
- if (! $verb)
+ if(! $verb)
return;
$Aname = $item['author-name'];
}
break;
default:
- if ($obj['resource-id']){
+ if($obj['resource-id']){
$post_type = t('photo');
$m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
$rr['plink'] = $m[1];
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
$obj = parse_xml_string($xmlhead.$item['object']);
- if (strlen($obj->id)) {
+ if(strlen($obj->id)) {
$r = q("select * from item where uri = '%s' and uid = %d limit 1",
dbesc($obj->id),
intval($item['uid'])
}
}
$matches = null;
- if (preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
- foreach ($matches as $mtch) {
- if (! strpos($mtch[1],'zrl=')) {
+ if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
+ foreach($matches as $mtch) {
+ 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";
- if (preg_match($photo_pattern,$item['body'])) {
+ if(preg_match($photo_pattern,$item['body'])) {
$photo_replace = '[url=' . zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
$item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']);
}
function count_descendants($item) {
$total = count($item['children']);
- if ($total > 0) {
- foreach ($item['children'] as $child) {
- if (! visible_activity($child))
+ if($total > 0) {
+ foreach($item['children'] as $child) {
+ if(! visible_activity($child))
$total --;
$total += count_descendants($child);
}
// in which case we handle them specially
$hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
- foreach ($hidden_activities as $act) {
- if (activity_match($item['verb'],$act)) {
+ foreach($hidden_activities as $act) {
+ if(activity_match($item['verb'],$act)) {
return false;
}
}
- if (activity_match($item['verb'],ACTIVITY_FOLLOW) && $item['object-type'] === ACTIVITY_OBJ_NOTE) {
- if (! (($item['self']) && ($item['uid'] == local_user()))) {
+ if(activity_match($item['verb'],ACTIVITY_FOLLOW) && $item['object-type'] === ACTIVITY_OBJ_NOTE) {
+ if(! (($item['self']) && ($item['uid'] == local_user()))) {
return false;
}
}
*
*/
-if (!function_exists('conversation')) {
+if(!function_exists('conversation')) {
function conversation(App $a, $items, $mode, $update, $preview = false) {
require_once('include/bbcode.php');
$arr_blocked = null;
- if (local_user()) {
+ if(local_user()) {
$str_blocked = get_pconfig(local_user(),'system','blocked');
- if ($str_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]);
- }
}
}
$previewing = (($preview) ? ' preview ' : '');
- if ($mode === 'network') {
+ if($mode === 'network') {
$profile_owner = local_user();
$page_writeable = true;
- if (!$update) {
+ if(!$update) {
// The special div is needed for liveUpdate to kick in for this page.
// We only launch liveUpdate if you aren't filtering in some incompatible
// way and also you aren't writing a comment (discovered in javascript).
. "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
}
}
- else if ($mode === 'profile') {
+ else if($mode === 'profile') {
$profile_owner = $a->profile['profile_uid'];
$page_writeable = can_write_wall($a,$profile_owner);
- if (!$update) {
+ if(!$update) {
$tab = notags(trim($_GET['tab']));
$tab = ( $tab ? $tab : 'posts' );
- if ($tab === 'posts') {
+ if($tab === 'posts') {
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
// because browser prefetching might change it on us. We have to deliver it with the page.
}
}
}
- else if ($mode === 'notes') {
+ else if($mode === 'notes') {
$profile_owner = local_user();
$page_writeable = true;
- if (!$update) {
+ if(!$update) {
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
. "<script> var profile_uid = " . local_user()
. "; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
}
}
- else if ($mode === 'display') {
+ else if($mode === 'display') {
$profile_owner = $a->profile['uid'];
$page_writeable = can_write_wall($a,$profile_owner);
- if (!$update) {
+ if(!$update) {
$live_update_div = '<div id="live-display"></div>' . "\r\n"
. "<script> var profile_uid = " . $_SESSION['uid'] . ";"
. " var profile_page = 1; </script>";
}
}
- else if ($mode === 'community') {
+ else if($mode === 'community') {
$profile_owner = 0;
$page_writeable = false;
- if (!$update) {
+ if(!$update) {
$live_update_div = '<div id="live-community"></div>' . "\r\n"
. "<script> var profile_uid = -1; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
}
}
- else if ($mode === 'search') {
+ else if($mode === 'search') {
$live_update_div = '<div id="live-search"></div>' . "\r\n";
}
$page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false);
- if ($update)
+ if($update)
$return_url = $_SESSION['return_url'];
else
$return_url = $_SESSION['return_url'] = $a->query_string;
$page_template = get_markup_template("conversation.tpl");
- if ($items && count($items)) {
+ if($items && count($items)) {
- if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
+ if($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
// "New Item View" on network page or search page results
// - just loop through the items and format them minimally for display
// $tpl = get_markup_template('search_item.tpl');
$tpl = 'search_item.tpl';
- foreach ($items as $item) {
+ foreach($items as $item) {
- if ($arr_blocked) {
+ if($arr_blocked) {
$blocked = false;
- foreach ($arr_blocked as $b) {
- if ($b && link_compare($item['author-link'],$b)) {
+ foreach($arr_blocked as $b) {
+ if($b && link_compare($item['author-link'],$b)) {
$blocked = true;
break;
}
}
- if ($blocked)
+ if($blocked)
continue;
}
$owner_name = '';
$sparkle = '';
- if ($mode === 'search' || $mode === 'community') {
- if (((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
+ if($mode === 'search' || $mode === 'community') {
+ if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
&& ($item['id'] != $item['parent']))
continue;
$nickname = $item['nickname'];
$nickname = $a->user['nickname'];
// prevent private email from leaking.
- if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
+ if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
continue;
$profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
- if ($item['author-link'] && (! $item['author-name']))
+ if($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link'];
$taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`",
intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
- foreach ($taglist as $tag) {
+ foreach($taglist as $tag) {
if ($tag["url"] == "")
$tag["url"] = $searchpath.strtolower($tag["term"]);
$sp = false;
$profile_link = best_link_url($item,$sp);
- if ($profile_link === 'mailbox')
+ if($profile_link === 'mailbox')
$profile_link = '';
- if ($sp)
+ if($sp)
$sparkle = ' sparkle';
else
$profile_link = zrl($profile_link);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
localize_item($item);
- if ($mode === 'network-new')
+ if($mode === 'network-new')
$dropping = true;
else
$dropping = false;
list($categories, $folders) = get_cats_and_terms($item);
- if ($a->theme['template_engine'] === 'internal') {
+ if($a->theme['template_engine'] === 'internal') {
$profile_name_e = template_escape($profile_name);
$item['title_e'] = template_escape($item['title']);
$body_e = template_escape($body);
// But for now, this array respects the old style, just in case
$threads = array();
- foreach ($items as $item) {
+ foreach($items as $item) {
- if ($arr_blocked) {
+ if($arr_blocked) {
$blocked = false;
- foreach ($arr_blocked as $b) {
+ foreach($arr_blocked as $b) {
- if ($b && link_compare($item['author-link'],$b)) {
+ if($b && link_compare($item['author-link'],$b)) {
$blocked = true;
break;
}
}
- if ($blocked)
+ if($blocked)
continue;
}
builtin_activity_puller($item, $conv_responses);
// Only add what is visible
- if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
+ if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
continue;
}
- if (! visible_activity($item)) {
+ if(! visible_activity($item)) {
continue;
}
$item['pagedrop'] = $page_dropping;
- if ($item['id'] == $item['parent']) {
+ if($item['id'] == $item['parent']) {
$item_object = new Item($item);
$conv->add_thread($item_object);
}
$threads = $conv->get_template_data($conv_responses);
- if (!$threads) {
+ if(!$threads) {
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
$threads = array();
}
$sparkle = true;
}
}
- if (! $best_url) {
- if (strlen($item['author-link']))
+ if(! $best_url) {
+ if(strlen($item['author-link']))
$best_url = $item['author-link'];
else
$best_url = $item['url'];
{
$ssl_state = false;
- if (local_user()) {
+ if(local_user()) {
$ssl_state = true;
}
$rel = $r[0]['rel'];
}
- if ($sparkle) {
+ if($sparkle) {
$status_link = $profile_link . '?url=status';
$photos_link = $profile_link . '?url=photos';
$profile_link = $profile_link . '?url=profile';
* @param array &$conv_responses (already created with builtin activity structure)
* @return void
*/
-if (! function_exists('builtin_activity_puller')) {
+if(! function_exists('builtin_activity_puller')) {
function builtin_activity_puller($item, &$conv_responses) {
- foreach ($conv_responses as $mode => $v) {
+ foreach($conv_responses as $mode => $v) {
$url = '';
$sparkle = '';
break;
}
- if ((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
+ if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
$url = $item['author-link'];
- if ((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
+ if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
$url = 'redir/' . $item['contact-id'];
$sparkle = ' class="sparkle" ';
}
$url = '<a href="'. $url . '"'. $sparkle .'>' . htmlentities($item['author-name']) . '</a>';
- if (! $item['thr-parent'])
+ if(! $item['thr-parent'])
$item['thr-parent'] = $item['parent-uri'];
- if (! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l']))
+ if(! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l']))
&& (is_array($conv_responses[$mode][$item['thr-parent'] . '-l']))))
$conv_responses[$mode][$item['thr-parent'] . '-l'] = array();
// only list each unique author once
- if (in_array($url,$conv_responses[$mode][$item['thr-parent'] . '-l']))
+ if(in_array($url,$conv_responses[$mode][$item['thr-parent'] . '-l']))
continue;
- if (! isset($conv_responses[$mode][$item['thr-parent']]))
+ if(! isset($conv_responses[$mode][$item['thr-parent']]))
$conv_responses[$mode][$item['thr-parent']] = 1;
else
$conv_responses[$mode][$item['thr-parent']] ++;
// $id = item id
// returns formatted text
-if (! function_exists('format_like')) {
+if(! function_exists('format_like')) {
function format_like($cnt,$arr,$type,$id) {
$o = '';
$expanded = '';
- if ($cnt == 1) {
+ if($cnt == 1) {
$likers = $arr[0];
// Phrase if there is only one liker. In other cases it will be uses for the expanded
}
}
- if ($cnt > 1) {
+ if($cnt > 1) {
$total = count($arr);
- if ($total >= MAX_LIKERS)
+ if($total >= MAX_LIKERS)
$arr = array_slice($arr, 0, MAX_LIKERS - 1);
- if ($total < MAX_LIKERS) {
+ if($total < MAX_LIKERS) {
$last = t('and') . ' ' . $arr[count($arr)-1];
$arr2 = array_slice($arr, 0, -1);
$str = implode(', ', $arr2) . ' ' . $last;
}
- if ($total >= MAX_LIKERS) {
+ if($total >= MAX_LIKERS) {
$str = implode(', ', $arr);
$str .= sprintf( t(', and %d other people'), $total - MAX_LIKERS );
}
// Private/public post links for the non-JS ACL form
$private_post = 1;
- if ($_REQUEST['public'])
+ if($_REQUEST['public'])
$private_post = 0;
$query_str = $a->query_string;
- if (strpos($query_str, 'public=1') !== false)
+ if(strpos($query_str, 'public=1') !== false)
$query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
// I think $a->query_string may never have ? in it, but I could be wrong
// It looks like it's from the index.php?q=[etc] rewrite that the web
// server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
- if (strpos($query_str, '?') === false)
+ if(strpos($query_str, '?') === false)
$public_post_link = '?public=1';
else
$public_post_link = '&public=1';
function get_item_children($arr, $parent) {
$children = array();
$a = get_app();
- foreach ($arr as $item) {
- if ($item['id'] != $item['parent']) {
- if (get_config('system','thread_allow') && $a->theme_thread_allow) {
+ foreach($arr as $item) {
+ if($item['id'] != $item['parent']) {
+ if(get_config('system','thread_allow') && $a->theme_thread_allow) {
// Fallback to parent-uri if thr-parent is not set
$thr_parent = $item['thr-parent'];
- if ($thr_parent == '')
+ if($thr_parent == '')
$thr_parent = $item['parent-uri'];
- if ($thr_parent == $parent['uri']) {
+ if($thr_parent == $parent['uri']) {
$item['children'] = get_item_children($arr, $item);
$children[] = $item;
}
}
- else if ($item['parent'] == $parent['id']) {
+ else if($item['parent'] == $parent['id']) {
$children[] = $item;
}
}
function sort_item_children($items) {
$result = $items;
usort($result,'sort_thr_created_rev');
- foreach ($result as $k => $i) {
- if (count($result[$k]['children'])) {
+ foreach($result as $k => $i) {
+ if(count($result[$k]['children'])) {
$result[$k]['children'] = sort_item_children($result[$k]['children']);
}
}
}
function add_children_to_list($children, &$arr) {
- foreach ($children as $y) {
+ foreach($children as $y) {
$arr[] = $y;
- if (count($y['children']))
+ if(count($y['children']))
add_children_to_list($y['children'], $arr);
}
}
function conv_sort($arr,$order) {
- if ((!(is_array($arr) && count($arr))))
+ if((!(is_array($arr) && count($arr))))
return array();
$parents = array();
// This is a preparation for having two different items with the same uri in one thread
// This will otherwise lead to an endless loop.
- foreach ($arr as $x)
+ foreach($arr as $x)
if (!isset($newarr[$x['uri']]))
$newarr[$x['uri']] = $x;
$arr = $newarr;
- foreach ($arr as $x) {
- if ($x['id'] == $x['parent']) {
- $parents[] = $x;
- }
- }
+ 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']) {
+ /*foreach($arr as $x) {
+ if($x['id'] != $x['parent']) {
$p = find_thread_parent_index($parents,$x);
- if ($p !== false)
+ if($p !== false)
$parents[$p]['children'][] = $x;
}
}*/
- if (count($parents)) {
- foreach ($parents as $k => $v) {
- if (count($parents[$k]['children'])) {
+ if(count($parents)) {
+ foreach($parents as $k => $v) {
+ if(count($parents[$k]['children'])) {
$parents[$k]['children'] = sort_item_children($parents[$k]['children']);
/*$y = $parents[$k]['children'];
usort($y,'sort_thr_created_rev');
}
$ret = array();
- if (count($parents)) {
- foreach ($parents as $x) {
+ if(count($parents)) {
+ foreach($parents as $x) {
$ret[] = $x;
- if (count($x['children']))
+ if(count($x['children']))
add_children_to_list($x['children'], $ret);
- /*foreach ($x['children'] as $y)
+ /*foreach($x['children'] as $y)
$ret[] = $y;*/
}
}
}
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;
}
function get_responses($conv_responses,$response_verbs,$ob,$item) {
$ret = array();
- foreach ($response_verbs as $v) {
+ foreach($response_verbs as $v) {
$ret[$v] = array();
$ret[$v]['count'] = ((x($conv_responses[$v],$item['uri'])) ? $conv_responses[$v][$item['uri']] : '');
$ret[$v]['list'] = ((x($conv_responses[$v],$item['uri'])) ? $conv_responses[$v][$item['uri'] . '-l'] : '');
$ret[$v]['self'] = ((x($conv_responses[$v],$item['uri'])) ? $conv_responses[$v][$item['uri'] . '-self'] : '0');
- if (count($ret[$v]['list']) > MAX_LIKERS) {
+ if(count($ret[$v]['list']) > MAX_LIKERS) {
$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']);
}
$count = 0;
- foreach ($ret as $key) {
- if ($key['count'] == true) {
+ foreach($ret as $key) {
+ if ($key['count'] == true)
$count++;
- }
}
$ret['count'] = $count;
$last = get_config('system','last_cron');
$poll_interval = intval(get_config('system','cron_interval'));
- if (! $poll_interval)
+ if(! $poll_interval)
$poll_interval = 10;
- if ($last) {
+ if($last) {
$next = $last + ($poll_interval * 60);
- if ($next > time()) {
+ if($next > time()) {
logger('cron intervall not reached');
return;
}
$d1 = get_config('system','last_expire_day');
$d2 = intval(datetime_convert('UTC','UTC','now','d'));
- if ($d2 != intval($d1)) {
+ if($d2 != intval($d1)) {
update_contact_birthdays();
// delete user and contact records for recently removed accounts
$r = q("SELECT * FROM `user` WHERE `account_removed` AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
if ($r) {
- foreach ($r as $user) {
+ foreach($r as $user) {
q("DELETE FROM `contact` WHERE `uid` = %d", intval($user['uid']));
q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid']));
}
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
$abandon_days = intval(get_config('system','account_abandon_days'));
- if ($abandon_days < 1)
+ if($abandon_days < 1)
$abandon_days = 0;
$abandon_sql = (($abandon_days)
continue;
}
- foreach ($res as $contact) {
+ foreach($res as $contact) {
$xml = false;
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
}
- if ($contact['priority'] AND !$force) {
+ if($contact['priority'] AND !$force) {
$update = false;
switch ($contact['priority']) {
case 5:
- if (datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 month"))
+ if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 month"))
$update = true;
break;
case 4:
- if (datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 week"))
+ if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 week"))
$update = true;
break;
case 3:
- if (datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day"))
+ if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day"))
$update = true;
break;
case 2:
- if (datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 12 hour"))
+ if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 12 hour"))
$update = true;
break;
case 1:
default:
- if (datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 hour"))
+ if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 hour"))
$update = true;
break;
}
$last = get_config('system','cache_last_cleared');
- if ($last) {
+ if($last) {
$next = $last + (3600); // Once per hour
$clear_cache = ($next <= time());
- } else {
+ } else
$clear_cache = true;
- }
- if (!$clear_cache) {
+ if (!$clear_cache)
return;
- }
// clear old cache
Cache::clear();
clear_cache($a->get_basepath(), $a->get_basepath()."/proxy");
$cachetime = get_config('system','proxy_cache_time');
- if (!$cachetime) {
- $cachetime = PROXY_DEFAULT_TIME;
- }
+ if (!$cachetime) $cachetime = PROXY_DEFAULT_TIME;
q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%" AND `created` < NOW() - INTERVAL %d SECOND', $cachetime);
}
// Maximum table size in megabyte
$max_tablesize = intval(get_config('system','optimize_max_tablesize')) * 1000000;
- if ($max_tablesize == 0) {
+ if ($max_tablesize == 0)
$max_tablesize = 100 * 1000000; // Default are 100 MB
- }
if ($max_tablesize > 0) {
// Minimum fragmentation level in percent
$fragmentation_level = intval(get_config('system','optimize_fragmentation')) / 100;
- if ($fragmentation_level == 0) {
+ if ($fragmentation_level == 0)
$fragmentation_level = 0.3; // Default value is 30%
- }
// Optimize some tables that need to be optimized
$r = q("SHOW TABLE STATUS");
- foreach ($r as $table) {
+ foreach($r as $table) {
// Don't optimize tables that are too large
- if ($table["Data_length"] > $max_tablesize) {
+ if ($table["Data_length"] > $max_tablesize)
continue;
- }
// Don't optimize empty tables
- if ($table["Data_length"] == 0) {
+ if ($table["Data_length"] == 0)
continue;
- }
// Calculate fragmentation
$fragmentation = $table["Data_free"] / ($table["Data_length"] + $table["Index_length"]);
logger("Table ".$table["Name"]." - Fragmentation level: ".round($fragmentation * 100, 2), LOGGER_DEBUG);
// Don't optimize tables that needn't to be optimized
- if ($fragmentation < $fragmentation_level) {
+ if ($fragmentation < $fragmentation_level)
continue;
- }
// So optimize it
logger("Optimize Table ".$table["Name"], LOGGER_DEBUG);
// Update the global contacts for local users
$r = q("SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired`");
- if (dbm::is_result($r)) {
- foreach ($r AS $user) {
+ if (dbm::is_result($r))
+ foreach ($r AS $user)
update_gcontact_for_user($user["uid"]);
- }
- }
/// @todo
/// - remove thread entries without item
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) {
+ if($last) {
$next = $last + ($poll_interval * 60);
- if ($next > time()) {
+ if($next > time()) {
logger('cronhook intervall not reached');
return;
}
openssl_sign($data,$sig,$key,(($alg == 'sha1') ? OPENSSL_ALGO_SHA1 : $alg));
}
else {
- if (strlen($key) < 1024 || extension_loaded('gmp')) {
+ if(strlen($key) < 1024 || extension_loaded('gmp')) {
require_once('library/phpsec/Crypt/RSA.php');
$rsa = new CRYPT_RSA();
$rsa->signatureMode = CRYPT_RSA_SIGNATURE_PKCS1;
$verify = openssl_verify($data,$sig,$key,(($alg == 'sha1') ? OPENSSL_ALGO_SHA1 : $alg));
}
else {
- if (strlen($key) <= 300 || extension_loaded('gmp')) {
+ if(strlen($key) <= 300 || extension_loaded('gmp')) {
require_once('library/phpsec/Crypt/RSA.php');
$rsa = new CRYPT_RSA();
$rsa->signatureMode = CRYPT_RSA_SIGNATURE_PKCS1;
-if (! function_exists('aes_decrypt')) {
+if(! function_exists('aes_decrypt')) {
// DEPRECATED IN 3.4.1
function aes_decrypt($val,$ky)
{
$key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
- for ($a=0;$a<strlen($ky);$a++)
+ for($a=0;$a<strlen($ky);$a++)
$key[$a%16]=chr(ord($key[$a%16]) ^ ord($ky[$a]));
$mode = MCRYPT_MODE_ECB;
$enc = MCRYPT_RIJNDAEL_128;
}}
-if (! function_exists('aes_encrypt')) {
+if(! function_exists('aes_encrypt')) {
// DEPRECATED IN 3.4.1
function aes_encrypt($val,$ky)
{
$key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
- for ($a=0;$a<strlen($ky);$a++)
+ for($a=0;$a<strlen($ky);$a++)
$key[$a%16]=chr(ord($key[$a%16]) ^ ord($ky[$a]));
$mode=MCRYPT_MODE_ECB;
$enc=MCRYPT_RIJNDAEL_128;
);
$conf = get_config('system','openssl_conf_file');
- if ($conf)
+ if($conf)
$openssl_options['config'] = $conf;
$result = openssl_pkey_new($openssl_options);
- if (empty($result)) {
+ if(empty($result)) {
logger('new_keypair: failed');
return false;
}
* @return int
*/
function timezone_cmp($a, $b) {
- if (strstr($a,'/') && strstr($b,'/')) {
+ if(strstr($a,'/') && strstr($b,'/')) {
if ( t($a) == t($b)) return 0;
return ( t($a) < t($b)) ? -1 : 1;
}
- if (strstr($a,'/')) return -1;
- if (strstr($b,'/')) return 1;
+ if(strstr($a,'/')) return -1;
+ if(strstr($b,'/')) return 1;
if ( t($a) == t($b)) return 0;
return ( t($a) < t($b)) ? -1 : 1;
usort($timezone_identifiers, 'timezone_cmp');
$continent = '';
- foreach ($timezone_identifiers as $value) {
+ foreach($timezone_identifiers as $value) {
$ex = explode("/", $value);
- if (count($ex) > 1) {
- if ($ex[0] != $continent) {
- if ($continent != '')
+ if(count($ex) > 1) {
+ if($ex[0] != $continent) {
+ if($continent != '')
$o .= '</optgroup>';
$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')) {
+ if($continent != t('Miscellaneous')) {
$o .= '</optgroup>';
$continent = t('Miscellaneous');
$o .= '<optgroup label="' . t($continent) . '">';
// Defaults to UTC if nothing is set, but throws an exception if set to empty string.
// Provide some sane defaults regardless.
- if ($from === '')
+ if($from === '')
$from = 'UTC';
- if ($to === '')
+ if($to === '')
$to = 'UTC';
- if ( ($s === '') || (! is_string($s)) )
+ if( ($s === '') || (! is_string($s)) )
$s = 'now';
// Slight hackish adjustment so that 'zero' datetime actually returns what is intended
// add 32 days so that we at least get year 00, and then hack around the fact that
// months and days always start with 1.
- if (substr($s,0,10) == '0000-00-00') {
+ if(substr($s,0,10) == '0000-00-00') {
$d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
return str_replace('1','0',$d->format($fmt));
}
list($year,$month,$day) = sscanf($dob,'%4d-%2d-%2d');
$f = get_config('system','birthday_input_format');
- if (! $f)
+ if(! $f)
$f = 'ymd';
- if ($dob === '0000-00-00')
+ if($dob === '0000-00-00')
$value = '';
else
$value = (($year) ? datetime_convert('UTC','UTC',$dob,'Y-m-d') : datetime_convert('UTC','UTC',$dob,'m-d'));
$o = '';
$dateformat = '';
- if ($pickdate) $dateformat .= 'Y-m-d';
- if ($pickdate && $picktime) $dateformat .= ' ';
- if ($picktime) $dateformat .= 'H:i';
+ if($pickdate) $dateformat .= 'Y-m-d';
+ if($pickdate && $picktime) $dateformat .= ' ';
+ if($picktime) $dateformat .= 'H:i';
$minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : '';
$maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : '';
$defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : '';
$pickers = '';
- if (!$pickdate) $pickers .= ',datepicker: false';
- if (!$picktime) $pickers .= ',timepicker: false';
+ if(!$pickdate) $pickers .= ',datepicker: false';
+ if(!$picktime) $pickers .= ',timepicker: false';
$extra_js = '';
$pickers .= ",dayOfWeekStart: ".$firstDay.",lang:'".$lang."'";
- if ($minfrom != '')
+ if($minfrom != '')
$extra_js .= "\$('#id_$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
- if ($maxfrom != '')
+ if($maxfrom != '')
$extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})";
$readable_format = $dateformat;
* @return int Age in years
*/
function age($dob,$owner_tz = '',$viewer_tz = '') {
- if (! intval($dob))
+ if(! intval($dob))
return 0;
- if (! $owner_tz)
+ if(! $owner_tz)
$owner_tz = date_default_timezone_get();
- if (! $viewer_tz)
+ if(! $viewer_tz)
$viewer_tz = date_default_timezone_get();
$birthdate = datetime_convert('UTC',$owner_tz,$dob . ' 00:00:00+00:00','Y-m-d');
$curr_month = datetime_convert('UTC',$viewer_tz,'now','m');
$curr_day = datetime_convert('UTC',$viewer_tz,'now','d');
- if (($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day)))
+ if(($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day)))
$year_diff--;
return $year_diff;
31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31);
- if ($m != 2)
+ if($m != 2)
return $dim[$m];
- if (((($y % 4) == 0) && (($y % 100) != 0)) || (($y % 400) == 0))
+ if(((($y % 4) == 0) && (($y % 100) != 0)) || (($y % 400) == 0))
return 29;
return $dim[2];
$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);
$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)) {
+ while($d <= $l) {
+ if(($dow == $f) && (! $started))
$started = true;
- }
$today = (((isset($tddate)) && ($tddate == $d)) ? "class=\"today\" " : '');
$o .= "<td $today>";
$day = str_replace(' ',' ',sprintf('%2.2d', $d));
- if ($started) {
- if (is_array($links) && isset($links[$d])) {
+ if($started) {
+ if(is_array($links) && isset($links[$d]))
$o .= "<a href=\"{$links[$d]}\">$day</a>";
- } else {
+ else
$o .= $day;
- }
$d ++;
} else {
$o .= '</td>';
$dow ++;
- if (($dow == 7) && ($d <= $l)) {
+ if(($dow == 7) && ($d <= $l)) {
$dow = 0;
$o .= '</tr><tr>';
}
}
- if ($dow) {
- for ($a = $dow; $a < 7; $a ++) {
+ if($dow)
+ for($a = $dow; $a < 7; $a ++)
$o .= '<td> </td>';
- }
- }
$o .= '</tr></table>'."\r\n";
*
*/
-if (! class_exists('dba')) {
+if(! class_exists('dba')) {
class dba {
private $debug = 0;
return;
}
- if ($install) {
- if (strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
- if (! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
+ if($install) {
+ if(strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1')) {
+ if(! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
$this->error = sprintf( t('Cannot locate DNS info for database server \'%s\''), $server);
$this->connected = false;
$this->db = null;
\DDDBL\connect();
$this->db = \DDDBL\getDB();
- if (\DDDBL\isConnected()) {
+ if(\DDDBL\isConnected()) {
$this->connected = true;
}
- if (! $this->connected) {
+ if(! $this->connected) {
$this->db = null;
- if (! $install)
+ if(! $install)
system_unavailable();
}
$objPreparedQueryPool = new \DDDBL\DataObjectPool('Query-Definition');
# check if query do not exists till now, if so create its definition
- if (!$objPreparedQueryPool->exists($strQueryAlias))
+ if(!$objPreparedQueryPool->exists($strQueryAlias))
$objPreparedQueryPool->add($strQueryAlias, array('QUERY' => $sql,
'HANDLER' => $strHandler));
- if ((! $this->db) || (! $this->connected))
+ if((! $this->db) || (! $this->connected))
return false;
$this->error = '';
$r = \DDDBL\get($strQueryAlias);
# bad workaround to emulate the bizzare behavior of mysql_query
- if (in_array($strSQLType, array('INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'SET')))
+ if(in_array($strSQLType, array('INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'SET')))
$result = true;
$intErrorCode = false;
$a->save_timestamp($stamp1, "database");
- if (x($a->config,'system') && x($a->config['system'],'db_log')) {
+ if(x($a->config,'system') && x($a->config['system'],'db_log')) {
if (($duration > $a->config["system"]["db_loglimit"])) {
$duration = round($duration, 3);
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
}
}
- if ($intErrorCode)
+ if($intErrorCode)
$this->error = $intErrorCode;
- if (strlen($this->error)) {
+ if(strlen($this->error)) {
logger('dba: ' . $this->error);
}
- if ($this->debug) {
+ if($this->debug) {
$mesg = '';
- if ($result === false)
+ if($result === false)
$mesg = 'false';
- elseif ($result === true)
+ elseif($result === true)
$mesg = 'true';
else {
# this needs fixing, but is a bug itself
* These usually indicate SQL syntax errors that need to be resolved.
*/
- if (isset($result) AND ($result === false)) {
+ if(isset($result) AND ($result === false)) {
logger('dba: ' . printable($sql) . ' returned false.' . "\n" . $this->error);
- if (file_exists('dbfail.out'))
+ if(file_exists('dbfail.out'))
file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND);
}
- if (isset($result) AND (($result === true) || ($result === false)))
+ if(isset($result) AND (($result === true) || ($result === false)))
return $result;
if ($onlyquery) {
//$a->save_timestamp($stamp1, "database");
- if ($this->debug)
+ if($this->debug)
logger('dba: ' . printable(print_r($r, true)));
return($r);
}
}
public function escape($str) {
- if ($this->db && $this->connected) {
+ if($this->db && $this->connected) {
$strQuoted = $this->db->quote($str);
# this workaround is needed, because quote creates "'" and the beginning and the end
# of the string, which is correct. but until now the queries set this delimiter manually,
}
}}
-if (! function_exists('printable')) {
+if(! function_exists('printable')) {
function printable($s) {
$s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~",".", $s);
$s = str_replace("\x00",'.',$s);
- if (x($_SERVER,'SERVER_NAME'))
+ if(x($_SERVER,'SERVER_NAME'))
$s = escape_tags($s);
return $s;
}}
// Procedural functions
-if (! function_exists('dbg')) {
+if(! function_exists('dbg')) {
function dbg($state) {
global $db;
- if ($db)
+ if($db)
$db->dbg($state);
}}
-if (! function_exists('dbesc')) {
+if(! function_exists('dbesc')) {
function dbesc($str) {
global $db;
- if ($db && $db->connected)
+ if($db && $db->connected)
return($db->escape($str));
else
return(str_replace("'","\\'",$str));
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
// 'user', 1);
-if (! function_exists('q')) {
+if(! function_exists('q')) {
function q($sql) {
global $db;
$args = func_get_args();
unset($args[0]);
- if ($db && $db->connected) {
+ if($db && $db->connected) {
$stmt = @vsprintf($sql,$args); // Disabled warnings
//logger("dba: q: $stmt", LOGGER_ALL);
- if ($stmt === false)
+ if($stmt === false)
logger('dba: vsprintf error: ' . print_r(debug_backtrace(),true), LOGGER_DEBUG);
return $db->q($stmt);
}
*
*/
-if (! function_exists('dbq')) {
+if(! function_exists('dbq')) {
function dbq($sql) {
global $db;
- if ($db && $db->connected)
+ if($db && $db->connected)
$ret = $db->q($sql);
else
$ret = false;
// cast to int to avoid trouble.
-if (! function_exists('dbesc_array_cb')) {
+if(! function_exists('dbesc_array_cb')) {
function dbesc_array_cb(&$item, $key) {
- if (is_string($item))
+ if(is_string($item))
$item = dbesc($item);
}}
-if (! function_exists('dbesc_array')) {
+if(! function_exists('dbesc_array')) {
function dbesc_array(&$arr) {
- if (is_array($arr) && count($arr)) {
+ if(is_array($arr) && count($arr)) {
array_walk($arr,'dbesc_array_cb');
}
}}
-if (! function_exists('dba_timer')) {
+if(! function_exists('dba_timer')) {
function dba_timer() {
return microtime(true);
}}
$sql_rows = array();
$primary_keys = array();
- foreach ($fields AS $fieldname => $field) {
+ foreach($fields AS $fieldname => $field) {
$sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
if (x($field,'primary') and $field['primary']!=''){
$primary_keys[] = $fieldname;
function dbstructure_run(&$argv, &$argc) {
global $a, $db;
- if (is_null($a)){
+ if(is_null($a)){
$a = new App;
}
- if (is_null($db)) {
+ if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
$current = intval(DB_UPDATE_VERSION);
// run any left update_nnnn functions in update.php
- for ($x = $stored; $x < $current; $x ++) {
+ for($x = $stored; $x < $current; $x ++) {
$r = run_update_function($x);
if (!$r) break;
}
* @param array $owner Owner record
*
* @return string DFRN entries
- * @todo Add type-hints
*/
public static function entries($items,$owner) {
$root = self::add_header($doc, $owner, "dfrn:owner", "", false);
- if (! count($items)) {
+ if(! count($items))
return trim($doc->saveXML());
- }
- foreach ($items as $item) {
+ foreach($items as $item) {
$entry = self::entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]);
$root->appendChild($entry);
}
$starred = false; // not yet implemented, possible security issues
$converse = false;
- if ($public_feed && $a->argc > 2) {
- for ($x = 2; $x < $a->argc; $x++) {
- if ($a->argv[$x] == 'converse') {
+ if($public_feed && $a->argc > 2) {
+ for($x = 2; $x < $a->argc; $x++) {
+ if($a->argv[$x] == 'converse')
$converse = true;
- }
- if ($a->argv[$x] == 'starred') {
+ if($a->argv[$x] == 'starred')
$starred = true;
- }
- if ($a->argv[$x] == 'category' && $a->argc > ($x + 1) && strlen($a->argv[$x+1])) {
+ if($a->argv[$x] == 'category' && $a->argc > ($x + 1) && strlen($a->argv[$x+1]))
$category = $a->argv[$x+1];
- }
}
}
$sql_post_table = "";
- if (! $public_feed) {
+ if(! $public_feed) {
$sql_extra = '';
switch($direction) {
require_once('include/security.php');
$groups = init_groups_visitor($contact['id']);
- if (count($groups)) {
- for ($x = 0; $x < count($groups); $x ++)
+ if(count($groups)) {
+ for($x = 0; $x < count($groups); $x ++)
$groups[$x] = '<' . intval($groups[$x]) . '>' ;
$gs = implode('|', $groups);
- } else {
+ } else
$gs = '<<>>' ; // Impossible to match
- }
$sql_extra = sprintf("
AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
);
}
- if ($public_feed) {
+ if($public_feed)
$sort = 'DESC';
- } else {
+ else
$sort = 'ASC';
- }
- if (! strlen($last_update)) {
+ if(! strlen($last_update))
$last_update = 'now -30 days';
- }
- if (isset($category)) {
+ if(isset($category)) {
$sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($owner_id));
//$sql_extra .= file_tag_file_query('item',$category,'category');
}
- if ($public_feed) {
- if (! $converse) {
+ if($public_feed) {
+ if(! $converse)
$sql_extra .= " AND `contact`.`self` = 1 ";
- }
}
$check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
dbesc($sort)
);
- if (!dbm::is_result($r)) {
- logger("Query failed to execute, no result returned in " . __FUNCTION__);
- killme();
- }
-
// Will check further below if this actually returned results.
// We will provide an empty feed if that is the case.
$alternatelink = $owner['url'];
- if (isset($category)) {
+ if(isset($category))
$alternatelink .= "/category/".$category;
- }
- if ($public_feed) {
+ if ($public_feed)
$author = "dfrn:owner";
- } else {
+ else
$author = "author";
- }
$root = self::add_header($doc, $owner, $author, $alternatelink, true);
return $atom;
}
- foreach ($items as $item) {
+ foreach($items as $item) {
// prevent private email from leaking.
- if ($item['network'] == NETWORK_MAIL) {
+ if($item['network'] == NETWORK_MAIL)
continue;
- }
// public feeds get html, our own nodes use bbcode
- if ($public_feed) {
+ if($public_feed) {
$type = 'html';
// catch any email that's in a public conversation and make sure it doesn't leak
- if ($item['private']) {
+ if($item['private'])
continue;
- }
- } else {
+ } else
$type = 'text';
- }
$entry = self::entry($doc, $type, $item, $owner, true);
$root->appendChild($entry);
* @param array $owner Owner record
*
* @return string DFRN mail
- * @todo Add type-hints
*/
public static function mail($item, $owner) {
$doc = new DOMDocument('1.0', 'utf-8');
* @param array $owner Owner record
*
* @return string DFRN suggestions
- * @todo Add type-hints
*/
public static function fsuggest($item, $owner) {
$doc = new DOMDocument('1.0', 'utf-8');
* @param int $uid User ID
*
* @return string DFRN relocations
- * @todo Add type-hints
*/
public static function relocate($owner, $uid) {
/* get site pubkey. this could be a new installation with no site keys*/
$pubkey = get_config('system','site_pubkey');
- if (! $pubkey) {
+ if(! $pubkey) {
$res = new_keypair(1024);
set_config('system','site_prvkey', $res['prvkey']);
set_config('system','site_pubkey', $res['pubkey']);
$photos = array();
$ext = Photo::supportedTypes();
- foreach ($rp as $p) {
+ foreach($rp as $p)
$photos[$p['scale']] = app::get_baseurl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']];
- }
unset($rp, $ext);
* @param bool $public Is it a header for public posts?
*
* @return object XML root object
- * @todo Add type-hints
*/
private static function add_header($doc, $owner, $authorelement, $alternatelink = "", $public = false) {
- if ($alternatelink == "") {
+ if ($alternatelink == "")
$alternatelink = $owner['url'];
- }
$root = $doc->createElementNS(NAMESPACE_ATOM1, 'feed');
$doc->appendChild($root);
}
// For backward compatibility we keep this element
- if ($owner['page-flags'] == PAGE_COMMUNITY) {
+ if ($owner['page-flags'] == PAGE_COMMUNITY)
xml::add_element($doc, $root, "dfrn:community", 1);
- }
// The former element is replaced by this one
xml::add_element($doc, $root, "dfrn:account_type", $owner["account-type"]);
* @param string $authorelement Element name for the author
*
* @return object XML author object
- * @todo Add type-hints
*/
private static function add_author($doc, $owner, $authorelement, $public) {
$r = q("SELECT `id` FROM `profile` INNER JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE (`hidewall` OR NOT `net-publish`) AND `user`.`uid` = %d",
intval($owner['uid']));
- if (dbm::is_result($r)) {
+ if ($r)
$hidewall = true;
- } else {
+ else
$hidewall = false;
- }
$author = $doc->createElement($authorelement);
$uridate = datetime_convert('UTC', 'UTC', $owner['uri-date'].'+00:00', ATOM_TIME);
$picdate = datetime_convert('UTC', 'UTC', $owner['avatar-date'].'+00:00', ATOM_TIME);
- $attributes = array();
-
- if (!$public OR !$hidewall) {
+ if (!$public OR !$hidewall)
$attributes = array("dfrn:updated" => $namdate);
- }
+ else
+ $attributes = array();
xml::add_element($doc, $author, "name", $owner["name"], $attributes);
xml::add_element($doc, $author, "uri", app::get_baseurl().'/profile/'.$owner["nickname"], $attributes);
$attributes = array("rel" => "photo", "type" => "image/jpeg",
"media:width" => 175, "media:height" => 175, "href" => $owner['photo']);
- if (!$public OR !$hidewall) {
+ if (!$public OR !$hidewall)
$attributes["dfrn:updated"] = $picdate;
- }
xml::add_element($doc, $author, "link", "", $attributes);
$attributes["rel"] = "avatar";
xml::add_element($doc, $author, "link", "", $attributes);
- if ($hidewall) {
+ if ($hidewall)
xml::add_element($doc, $author, "dfrn:hide", "true");
- }
// The following fields will only be generated if the data isn't meant for a public feed
- if ($public) {
+ if ($public)
return $author;
- }
$birthday = feed_birthday($owner['uid'], $owner['timezone']);
INNER JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `profile`.`is-default` AND NOT `user`.`hidewall` AND `user`.`uid` = %d",
intval($owner['uid']));
- if (dbm::is_result($r)) {
+ if ($r) {
$profile = $r[0];
xml::add_element($doc, $author, "poco:displayName", $profile["name"]);
if (trim($profile["pub_keywords"]) != "") {
$keywords = explode(",", $profile["pub_keywords"]);
- foreach ($keywords AS $keyword) {
+ foreach ($keywords AS $keyword)
xml::add_element($doc, $author, "poco:tags", trim($keyword));
- }
}
xml::add_element($doc, $element, "poco:formatted", formatted_location($profile));
- if (trim($profile["locality"]) != "") {
+ if (trim($profile["locality"]) != "")
xml::add_element($doc, $element, "poco:locality", $profile["locality"]);
- }
- if (trim($profile["region"]) != "") {
+ if (trim($profile["region"]) != "")
xml::add_element($doc, $element, "poco:region", $profile["region"]);
- }
- if (trim($profile["country-name"]) != "") {
+ if (trim($profile["country-name"]) != "")
xml::add_element($doc, $element, "poco:country", $profile["country-name"]);
- }
$author->appendChild($element);
}
* @param array $items Item elements
*
* @return object XML author object
- * @todo Add type-hints
*/
private static function add_entry_author($doc, $element, $contact_url, $item) {
* @param string $activity activity value
*
* @return object XML activity object
- * @todo Add type-hints
*/
private static function create_activity($doc, $element, $activity) {
- if ($activity) {
+ if($activity) {
$entry = $doc->createElement($element);
$r = parse_xml_string($activity, false);
- if (!$r) {
+ if(!$r)
return false;
- }
- if ($r->type) {
+ if($r->type)
xml::add_element($doc, $entry, "activity:object-type", $r->type);
- }
- if ($r->id) {
+ if($r->id)
xml::add_element($doc, $entry, "id", $r->id);
- }
- if ($r->title) {
+ if($r->title)
xml::add_element($doc, $entry, "title", $r->title);
- }
-
- if ($r->link) {
- if (substr($r->link,0,1) == '<') {
- if (strstr($r->link,'&') && (! strstr($r->link,'&'))) {
+ if($r->link) {
+ if(substr($r->link,0,1) == '<') {
+ if(strstr($r->link,'&') && (! strstr($r->link,'&')))
$r->link = str_replace('&','&', $r->link);
- }
$r->link = preg_replace('/\<link(.*?)\"\>/','<link$1"/>',$r->link);
if (is_object($data)) {
foreach ($data->link AS $link) {
$attributes = array();
- foreach ($link->attributes() AS $parameter => $value) {
+ foreach ($link->attributes() AS $parameter => $value)
$attributes[$parameter] = $value;
- }
xml::add_element($doc, $entry, "link", "", $attributes);
}
}
xml::add_element($doc, $entry, "link", "", $attributes);
}
}
- if ($r->content) {
+ if($r->content)
xml::add_element($doc, $entry, "content", bbcode($r->content), array("type" => "html"));
- }
return $entry;
}
* @param array $item Item element
*
* @return object XML attachment object
- * @todo Add type-hints
*/
private static function get_attachment($doc, $root, $item) {
$arr = explode('[/attach],',$item['attach']);
- if (count($arr)) {
- foreach ($arr as $r) {
+ if(count($arr)) {
+ foreach($arr as $r) {
$matches = false;
$cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|',$r,$matches);
- if ($cnt) {
+ if($cnt) {
$attributes = array("rel" => "enclosure",
"href" => $matches[1],
"type" => $matches[3]);
- if (intval($matches[2])) {
+ if(intval($matches[2]))
$attributes["length"] = intval($matches[2]);
- }
- if (trim($matches[4]) != "") {
+ if(trim($matches[4]) != "")
$attributes["title"] = trim($matches[4]);
- }
xml::add_element($doc, $root, "link", "", $attributes);
}
* @param int $cid Contact ID of the recipient
*
* @return object XML entry object
- * @todo Add type-hints
*/
private static function entry($doc, $type, $item, $owner, $comment = false, $cid = 0) {
$mentioned = array();
- if (!$item['parent']) {
+ if(!$item['parent'])
return;
- }
- if ($item['deleted']) {
+ if($item['deleted']) {
$attributes = array("ref" => $item['uri'], "when" => datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME));
return xml::create_element($doc, "at:deleted-entry", "", $attributes);
}
$entry = $doc->createElement("entry");
- if ($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) {
+ if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid'])
$body = fix_private_photos($item['body'],$owner['uid'],$item,$cid);
- } else {
+ else
$body = $item['body'];
- }
// Remove the abstract element. It is only locally important.
$body = remove_abstract($body);
if ($type == 'html') {
$htmlbody = $body;
- if ($item['title'] != "") {
+ if ($item['title'] != "")
$htmlbody = "[b]".$item['title']."[/b]\n\n".$htmlbody;
- }
$htmlbody = bbcode($htmlbody, false, false, 7);
}
$dfrnowner = self::add_entry_author($doc, "dfrn:owner", $item["owner-link"], $item);
$entry->appendChild($dfrnowner);
- if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
+ if(($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
$parent = q("SELECT `guid` FROM `item` WHERE `id` = %d", intval($item["parent"]));
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
$attributes = array("ref" => $parent_item, "type" => "text/html",
// "comment-allow" is some old fashioned stuff for old Friendica versions.
// It is included in the rewritten code for completeness
- if ($comment) {
+ if ($comment)
xml::add_element($doc, $entry, "dfrn:comment-allow", intval($item['last-child']));
- }
- if ($item['location']) {
+ if($item['location'])
xml::add_element($doc, $entry, "dfrn:location", $item['location']);
- }
- if ($item['coord']) {
+ if($item['coord'])
xml::add_element($doc, $entry, "georss:point", $item['coord']);
- }
- if (($item['private']) || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) {
+ if(($item['private']) || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid']))
xml::add_element($doc, $entry, "dfrn:private", (($item['private']) ? $item['private'] : 1));
- }
- if ($item['extid']) {
+ if($item['extid'])
xml::add_element($doc, $entry, "dfrn:extid", $item['extid']);
- }
- if ($item['bookmark']) {
+ if($item['bookmark'])
xml::add_element($doc, $entry, "dfrn:bookmark", "true");
- }
- if ($item['app']) {
+ if($item['app'])
xml::add_element($doc, $entry, "statusnet:notice_info", "", array("local_id" => $item['id'], "source" => $item['app']));
- }
xml::add_element($doc, $entry, "dfrn:diaspora_guid", $item["guid"]);
// The signed text contains the content in Markdown, the sender handle and the signatur for the content
// It is needed for relayed comments to Diaspora.
- if ($item['signed_text']) {
+ if($item['signed_text']) {
$sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer'])));
xml::add_element($doc, $entry, "dfrn:diaspora_signature", $sign);
}
xml::add_element($doc, $entry, "activity:verb", construct_verb($item));
- if ($item['object-type'] != "") {
+ if ($item['object-type'] != "")
xml::add_element($doc, $entry, "activity:object-type", $item['object-type']);
- } elseif ($item['id'] == $item['parent']) {
+ elseif ($item['id'] == $item['parent'])
xml::add_element($doc, $entry, "activity:object-type", ACTIVITY_OBJ_NOTE);
- } else {
+ else
xml::add_element($doc, $entry, "activity:object-type", ACTIVITY_OBJ_COMMENT);
- }
$actobj = self::create_activity($doc, "activity:object", $item['object']);
- if ($actobj) {
+ if ($actobj)
$entry->appendChild($actobj);
- }
$actarg = self::create_activity($doc, "activity:target", $item['target']);
- if ($actarg) {
+ if ($actarg)
$entry->appendChild($actarg);
- }
$tags = item_getfeedtags($item);
- if (count($tags)) {
- foreach ($tags as $t) {
- if (($type != 'html') OR ($t[0] != "@")) {
+ if(count($tags)) {
+ foreach($tags as $t)
+ if (($type != 'html') OR ($t[0] != "@"))
xml::add_element($doc, $entry, "category", "", array("scheme" => "X-DFRN:".$t[0].":".$t[1], "term" => $t[2]));
- }
- }
}
- if (count($tags)) {
- foreach ($tags as $t) {
- if ($t[0] == "@") {
+ if(count($tags))
+ foreach($tags as $t)
+ if ($t[0] == "@")
$mentioned[$t[1]] = $t[1];
- }
- }
- }
foreach ($mentioned AS $mention) {
$r = q("SELECT `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s'",
intval($owner["uid"]),
dbesc(normalise_link($mention)));
-
- if (!dbm::is_result($r)) {
- /// @TODO Maybe some logging?
- killme();
- }
-
- if ($r[0]["forum"] OR $r[0]["prv"]) {
+ if ($r[0]["forum"] OR $r[0]["prv"])
xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
"href" => $mention));
- } else {
+ else
xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_PERSON,
"href" => $mention));
- }
}
self::get_attachment($doc, $entry, $item);
* @param bool $dissolve (to be documented)
*
* @return int Deliver status. -1 means an error.
- * @todo Add array type-hint for $owner, $contact
*/
public static function deliver($owner,$contact,$atom, $dissolve = false) {
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
- if ($contact['duplex'] && $contact['dfrn-id']) {
+ if($contact['duplex'] && $contact['dfrn-id'])
$idtosend = '0:' . $orig_id;
- }
- if ($contact['duplex'] && $contact['issued-id']) {
+ if($contact['duplex'] && $contact['issued-id'])
$idtosend = '1:' . $orig_id;
- }
+
$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);
logger('dfrn_deliver: ' . $xml, LOGGER_DATA);
- if (! $xml) {
+ if(! $xml)
return 3;
- }
- if (strpos($xml,'<?xml') === false) {
+ if(strpos($xml,'<?xml') === false) {
logger('dfrn_deliver: no valid XML returned');
logger('dfrn_deliver: returned XML: ' . $xml, LOGGER_DATA);
return 3;
$res = parse_xml_string($xml);
- if ((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id))) {
+ if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id)))
return (($res->status) ? $res->status : 3);
- }
$postvars = array();
$sent_dfrn_id = hex2bin((string) $res->dfrn_id);
logger("Remote rino version: ".$rino_remote_version." for ".$contact["url"], LOGGER_DEBUG);
- if ($owner['page-flags'] == PAGE_PRVGROUP) {
+ if($owner['page-flags'] == PAGE_PRVGROUP)
$page = 2;
- }
$final_dfrn_id = '';
- if ($perm) {
- if ((($perm == 'rw') && (! intval($contact['writable'])))
+ if($perm) {
+ if((($perm == 'rw') && (! intval($contact['writable'])))
|| (($perm == 'r') && (intval($contact['writable'])))) {
q("update contact set writable = %d where id = %d",
intval(($perm == 'rw') ? 1 : 0),
}
}
- if (($contact['duplex'] && strlen($contact['pubkey']))
+ if(($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
|| ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))) {
openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']);
$final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
- if (strpos($final_dfrn_id,':') == 1) {
+ if(strpos($final_dfrn_id,':') == 1)
$final_dfrn_id = substr($final_dfrn_id,2);
- }
- if ($final_dfrn_id != $orig_id) {
+ if($final_dfrn_id != $orig_id) {
logger('dfrn_deliver: wrong dfrn_id.');
// did not decode properly - cannot trust this site
return 3;
$postvars['dfrn_id'] = $idtosend;
$postvars['dfrn_version'] = DFRN_PROTOCOL_VERSION;
- if ($dissolve) {
+ if($dissolve)
$postvars['dissolve'] = '1';
- }
- if ((($contact['rel']) && ($contact['rel'] != CONTACT_IS_SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
+ if((($contact['rel']) && ($contact['rel'] != CONTACT_IS_SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
$postvars['data'] = $atom;
$postvars['perm'] = 'rw';
} else {
$postvars['ssl_policy'] = $ssl_policy;
- if ($page) {
+ if($page)
$postvars['page'] = $page;
- }
- if ($rino > 0 && $rino_remote_version > 0 && (! $dissolve)) {
+ if($rino>0 && $rino_remote_version>0 && (! $dissolve)) {
logger('rino version: '. $rino_remote_version);
switch($rino_remote_version) {
$postvars['rino'] = $rino_remote_version;
$postvars['data'] = bin2hex($data);
- //logger('rino: sent key = ' . $key, LOGGER_DEBUG);
+ #logger('rino: sent key = ' . $key, LOGGER_DEBUG);
- if ($dfrn_version >= 2.1) {
- if (($contact['duplex'] && strlen($contact['pubkey']))
+ if($dfrn_version >= 2.1) {
+ if(($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
- || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))) {
+ || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey'])))
openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']);
- } else {
+ else
openssl_private_encrypt($key,$postvars['key'],$contact['prvkey']);
- }
} else {
- if (($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
+ if(($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY))
openssl_private_encrypt($key,$postvars['key'],$contact['prvkey']);
- } else {
+ else
openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']);
- }
}
return -10;
}
- if (strpos($xml,'<?xml') === false) {
+ if(strpos($xml,'<?xml') === false) {
logger('dfrn_deliver: phase 2: no valid XML returned');
logger('dfrn_deliver: phase 2: returned XML: ' . $xml, LOGGER_DATA);
return 3;
}
- /// @TODO Really compare with > here? Maybe DateTime (which allows such comparison again) is much safer/correcter
if ($contact['term-date'] > NULL_DATE) {
logger("dfrn_deliver: $url back from the dead - removing mark for death");
require_once('include/Contact.php');
*
* @param array $contact Contact record
* @param string $birthday Birthday of the contact
- * @todo Add array type-hint for $contact
+ *
*/
private static function birthday_event($contact, $birthday) {
* @param bool $onlyfetch Should the data only be fetched or should it update the contact record as well
*
* @return Returns an array with relevant data of the author
- * @todo Find good type-hints for all parameter
*/
private static function fetchauthor($xpath, $context, $importer, $element, $onlyfetch, $xml = "") {
`name`, `nick`, `about`, `location`, `keywords`, `xmpp`, `bdyear`, `bd`, `hidden`, `contact-type`
FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",
intval($importer["uid"]), dbesc(normalise_link($author["link"])), dbesc(NETWORK_STATUSNET));
-
- if (dbm::is_result($r)) {
+ if ($r) {
$contact = $r[0];
$author["contact-id"] = $r[0]["id"];
$author["network"] = $r[0]["network"];
} else {
- if (!$onlyfetch) {
+ if (!$onlyfetch)
logger("Contact ".$author["link"]." wasn't found for user ".$importer["uid"]." XML: ".$xml, LOGGER_DEBUG);
- }
$author["contact-id"] = $importer["id"];
$author["network"] = $importer["network"];
$avatarlist = array();
/// @todo check if "avatar" or "photo" would be the best field in the specification
$avatars = $xpath->query($element."/atom:link[@rel='avatar']", $context);
- foreach ($avatars AS $avatar) {
+ foreach($avatars AS $avatar) {
$href = "";
$width = 0;
- foreach ($avatar->attributes AS $attributes) {
- /// @TODO Rewrite these similar if () to one switch
- if ($attributes->name == "href") {
+ foreach($avatar->attributes AS $attributes) {
+ if ($attributes->name == "href")
$href = $attributes->textContent;
- }
- if ($attributes->name == "width") {
+ if ($attributes->name == "width")
$width = $attributes->textContent;
- }
- if ($attributes->name == "updated") {
+ if ($attributes->name == "updated")
$contact["avatar-date"] = $attributes->textContent;
- }
}
- if (($width > 0) AND ($href != "")) {
+ if (($width > 0) AND ($href != ""))
$avatarlist[$width] = $href;
- }
}
if (count($avatarlist) > 0) {
krsort($avatarlist);
$author["avatar"] = current($avatarlist);
}
- if (dbm::is_result($r) AND !$onlyfetch) {
+ if ($r AND !$onlyfetch) {
logger("Check if contact details for contact ".$r[0]["id"]." (".$r[0]["nick"].") have to be updated.", LOGGER_DEBUG);
$poco = array("url" => $contact["url"]);
// When was the last change to name or uri?
$name_element = $xpath->query($element."/atom:name", $context)->item(0);
- foreach ($name_element->attributes AS $attributes) {
- if ($attributes->name == "updated") {
+ foreach($name_element->attributes AS $attributes)
+ if ($attributes->name == "updated")
$poco["name-date"] = $attributes->textContent;
- }
- }
$link_element = $xpath->query($element."/atom:link", $context)->item(0);
- foreach ($link_element->attributes AS $attributes) {
- if ($attributes->name == "updated") {
+ foreach($link_element->attributes AS $attributes)
+ if ($attributes->name == "updated")
$poco["uri-date"] = $attributes->textContent;
- }
- }
// Update contact data
$value = $xpath->evaluate($element."/dfrn:handle/text()", $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$poco["addr"] = $value;
- }
$value = $xpath->evaluate($element."/poco:displayName/text()", $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$poco["name"] = $value;
- }
$value = $xpath->evaluate($element."/poco:preferredUsername/text()", $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$poco["nick"] = $value;
- }
$value = $xpath->evaluate($element."/poco:note/text()", $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$poco["about"] = $value;
- }
$value = $xpath->evaluate($element."/poco:address/poco:formatted/text()", $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$poco["location"] = $value;
- }
/// @todo Only search for elements with "poco:type" = "xmpp"
$value = $xpath->evaluate($element."/poco:ims/poco:value/text()", $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$poco["xmpp"] = $value;
- }
/// @todo Add support for the following fields that we don't support by now in the contact table:
/// - poco:utcOffset
// If the contact isn't searchable then set the contact to "hidden".
// Problem: This can be manually overridden by the user.
- if ($hide) {
+ if ($hide)
$contact["hidden"] = true;
- }
// Save the keywords into the contact table
$tags = array();
$tagelements = $xpath->evaluate($element."/poco:tags/text()", $context);
- foreach ($tagelements AS $tag) {
+ foreach($tagelements AS $tag)
$tags[$tag->nodeValue] = $tag->nodeValue;
- }
- if (count($tags)) {
+ if (count($tags))
$poco["keywords"] = implode(", ", $tags);
- }
// "dfrn:birthday" contains the birthday converted to UTC
$old_bdyear = $contact["bdyear"];
$contact = array_merge($contact, $poco);
- if ($old_bdyear != $contact["bdyear"]) {
+ if ($old_bdyear != $contact["bdyear"])
self::birthday_event($contact, $birthday);
- }
// Get all field names
$fields = array();
- foreach ($r[0] AS $field => $data) {
+ foreach ($r[0] AS $field => $data)
$fields[$field] = $data;
- }
unset($fields["id"]);
unset($fields["uid"]);
// Update check for this field has to be done differently
$datefields = array("name-date", "uri-date");
- foreach ($datefields AS $field) {
+ foreach ($datefields AS $field)
if (strtotime($contact[$field]) > strtotime($r[0][$field])) {
logger("Difference for contact ".$contact["id"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$r[0][$field]."'", LOGGER_DEBUG);
$update = true;
}
- }
- foreach ($fields AS $field => $data) {
+ foreach ($fields AS $field => $data)
if ($contact[$field] != $r[0][$field]) {
logger("Difference for contact ".$contact["id"]." in field '".$field."'. New value: '".$contact[$field]."', old value '".$r[0][$field]."'", LOGGER_DEBUG);
$update = true;
}
- }
if ($update) {
logger("Update contact data for contact ".$contact["id"]." (".$contact["nick"].")", LOGGER_DEBUG);
* @param text $element element name
*
* @return string XML string
- * @todo Find good type-hints for all parameter
*/
private static function transform_activity($xpath, $activity, $element) {
- if (!is_object($activity)) {
+ if (!is_object($activity))
return "";
- }
$obj_doc = new DOMDocument("1.0", "utf-8");
$obj_doc->formatOutput = true;
xml::add_element($obj_doc, $obj_element, "type", $activity_type);
$id = $xpath->query("atom:id", $activity)->item(0);
- if (is_object($id)) {
+ if (is_object($id))
$obj_element->appendChild($obj_doc->importNode($id, true));
- }
$title = $xpath->query("atom:title", $activity)->item(0);
- if (is_object($title)) {
+ if (is_object($title))
$obj_element->appendChild($obj_doc->importNode($title, true));
- }
$links = $xpath->query("atom:link", $activity);
- if (is_object($links)) {
- foreach ($links AS $link) {
+ if (is_object($links))
+ foreach ($links AS $link)
$obj_element->appendChild($obj_doc->importNode($link, true));
- }
- }
$content = $xpath->query("atom:content", $activity)->item(0);
- if (is_object($content)) {
+ if (is_object($content))
$obj_element->appendChild($obj_doc->importNode($content, true));
- }
$obj_doc->appendChild($obj_element);
* @param object $xpath XPath object
* @param object $mail mail elements
* @param array $importer Record of the importer user mixed with contact of the content
- * @todo Find good type-hints for all parameter
*/
private static function process_mail($xpath, $mail, $importer) {
logger("Processing mails");
- /// @TODO Rewrite this to one statement
$msg = array();
$msg["uid"] = $importer["importer_uid"];
$msg["from-name"] = $xpath->query("dfrn:sender/dfrn:name/text()", $mail)->item(0)->nodeValue;
$r = dbq("INSERT INTO `mail` (`".implode("`, `", array_keys($msg))."`) VALUES (".implode(", ", array_values($msg)).")");
// send notifications.
- /// @TODO Arange this mess
+
$notif_params = array(
"type" => NOTIFY_MAIL,
"notify_flags" => $importer["notify-flags"],
* @param object $xpath XPath object
* @param object $suggestion suggestion elements
* @param array $importer Record of the importer user mixed with contact of the content
- * @todo Find good type-hints for all parameter
*/
private static function process_suggestion($xpath, $suggestion, $importer) {
$a = get_app();
logger("Processing suggestions");
- /// @TODO Rewrite this to one statement
$suggest = array();
$suggest["uid"] = $importer["importer_uid"];
$suggest["cid"] = $importer["id"];
dbesc(normalise_link($suggest["url"])),
intval($suggest["uid"])
);
-
- if (dbm::is_result($r)) {
- // Has already friend matching description
+ if (dbm::is_result($r))
return false;
- }
// Do we already have an fcontact record for this person?
intval($suggest["uid"]),
intval($fid)
);
- /// @TODO Really abort on valid result??? Maybe missed ! here?
- if (dbm::is_result($r)) {
+ if (dbm::is_result($r))
return false;
- }
}
- if (!$fid)
+ if(!$fid)
$r = q("INSERT INTO `fcontact` (`name`,`url`,`photo`,`request`) VALUES ('%s', '%s', '%s', '%s')",
dbesc($suggest["name"]),
dbesc($suggest["url"]),
dbesc($suggest["name"]),
dbesc($suggest["request"])
);
- if (dbm::is_result($r)) {
+ if (dbm::is_result($r))
$fid = $r[0]["id"];
- } else {
+ else
// database record did not get created. Quietly give up.
- killme();
- }
+ return false;
$hash = random_string();
* @param object $xpath XPath object
* @param object $relocation relocation elements
* @param array $importer Record of the importer user mixed with contact of the content
- * @todo Find good type-hints for all parameter
*/
private static function process_relocation($xpath, $relocation, $importer) {
logger("Processing relocations");
- /// @TODO Rewrite this to one statement
$relocate = array();
$relocate["uid"] = $importer["importer_uid"];
$relocate["cid"] = $importer["id"];
$relocate["poll"] = $xpath->query("dfrn:poll/text()", $relocation)->item(0)->nodeValue;
$relocate["sitepubkey"] = $xpath->query("dfrn:sitepubkey/text()", $relocation)->item(0)->nodeValue;
- if (($relocate["avatar"] == "") AND ($relocate["photo"] != "")) {
+ if (($relocate["avatar"] == "") AND ($relocate["photo"] != ""))
$relocate["avatar"] = $relocate["photo"];
- }
- if ($relocate["addr"] == "") {
+ if ($relocate["addr"] == "")
$relocate["addr"] = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "$3@$2", $relocate["url"]);
- }
// update contact
$r = q("SELECT `photo`, `url` FROM `contact` WHERE `id` = %d AND `uid` = %d;",
intval($importer["id"]),
intval($importer["importer_uid"]));
-
- if (!dbm::is_result($r)) {
- /// @todo Don't die quietly
- killme();
- }
+ if (!$r)
+ return false;
$old = $r[0];
update_contact_avatar($relocate["avatar"], $importer["importer_uid"], $importer["id"], true);
- if ($x === false) {
+ if ($x === false)
return false;
- }
// update items
/// @todo This is an extreme performance killer
$n, dbesc($f[0]),
intval($importer["importer_uid"]));
- if (dbm::is_result($r)) {
+ if ($r) {
$x = q("UPDATE `item` SET `%s` = '%s' WHERE `%s` = '%s' AND `uid` = %d",
$n, dbesc($f[1]),
$n, dbesc($f[0]),
intval($importer["importer_uid"]));
-
- if ($x === false) {
- return false;
- }
+ if ($x === false)
+ return false;
}
}
if (edited_timestamp_is_newer($current, $item)) {
// do not accept (ignore) an earlier edit than one we currently have.
- if (datetime_convert("UTC","UTC",$item["edited"]) < $current["edited"])
+ if(datetime_convert("UTC","UTC",$item["edited"]) < $current["edited"])
return(false);
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
$changed = true;
- if ($entrytype == DFRN_REPLY_RC) {
+ if ($entrytype == DFRN_REPLY_RC)
proc_run(PRIORITY_HIGH, "include/notifier.php","comment-import", $current["id"]);
- }
}
// update last-child if it changes
- if ($item["last-child"] AND ($item["last-child"] != $current["last-child"])) {
+ if($item["last-child"] AND ($item["last-child"] != $current["last-child"])) {
$r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(datetime_convert()),
dbesc($item["parent-uri"]),
if ($item["parent-uri"] != $item["uri"]) {
$community = false;
- if ($importer["page-flags"] == PAGE_COMMUNITY || $importer["page-flags"] == PAGE_PRVGROUP) {
+ if($importer["page-flags"] == PAGE_COMMUNITY || $importer["page-flags"] == PAGE_PRVGROUP) {
$sql_extra = "";
$community = true;
logger("possible community action");
- } else {
+ } else
$sql_extra = " AND `contact`.`self` AND `item`.`wall` ";
- }
// was the top-level post for this action written by somebody on this site?
// Specifically, the recipient?
dbesc($r[0]["parent-uri"]),
intval($importer["importer_uid"])
);
- if (dbm::is_result($r)) {
+ if (dbm::is_result($r))
$is_a_remote_action = true;
- }
}
// Does this have the characteristics of a community or private group action?
// valid community action. Also forum_mode makes it valid for sure.
// If neither, it's not.
- if ($is_a_remote_action && $community) {
- if ((!$r[0]["forum_mode"]) && (!$r[0]["wall"])) {
+ if($is_a_remote_action && $community) {
+ if((!$r[0]["forum_mode"]) && (!$r[0]["wall"])) {
$is_a_remote_action = false;
logger("not a community action");
}
}
- if ($is_a_remote_action) {
+ if ($is_a_remote_action)
return DFRN_REPLY_RC;
- } else {
+ else
return DFRN_REPLY;
- }
- } else {
+ } else
return DFRN_TOP_LEVEL;
- }
}
*/
private static function do_poke($item, $importer, $posted_id) {
$verb = urldecode(substr($item["verb"],strpos($item["verb"], "#")+1));
- if (!$verb) {
+ if(!$verb)
return;
- }
$xo = parse_xml_string($item["object"],false);
- if (($xo->type == ACTIVITY_OBJ_PERSON) && ($xo->id)) {
+ if(($xo->type == ACTIVITY_OBJ_PERSON) && ($xo->id)) {
// somebody was poked/prodded. Was it me?
- foreach ($xo->link as $l) {
+ foreach($xo->link as $l) {
$atts = $l->attributes();
switch($atts["rel"]) {
case "alternate":
}
}
- if ($Blink && link_compare($Blink,App::get_baseurl()."/profile/".$importer["nickname"])) {
+ if($Blink && link_compare($Blink,App::get_baseurl()."/profile/".$importer["nickname"])) {
// send a notification
notification(array(
// Big question: Do we need these functions? They were part of the "consume_feed" function.
// This function once was responsible for DFRN and OStatus.
- if (activity_match($item["verb"],ACTIVITY_FOLLOW)) {
+ if(activity_match($item["verb"],ACTIVITY_FOLLOW)) {
logger("New follower");
new_follower($importer, $contact, $item, $nickname);
return false;
}
- if (activity_match($item["verb"],ACTIVITY_UNFOLLOW)) {
+ if(activity_match($item["verb"],ACTIVITY_UNFOLLOW)) {
logger("Lost follower");
lose_follower($importer, $contact, $item);
return false;
}
- if (activity_match($item["verb"],ACTIVITY_REQ_FRIEND)) {
+ if(activity_match($item["verb"],ACTIVITY_REQ_FRIEND)) {
logger("New friend request");
new_follower($importer, $contact, $item, $nickname, true);
return false;
}
- if (activity_match($item["verb"],ACTIVITY_UNFRIEND)) {
+ if(activity_match($item["verb"],ACTIVITY_UNFRIEND)) {
logger("Lost sharer");
lose_sharer($importer, $contact, $item);
return false;
}
} else {
- if (($item["verb"] == ACTIVITY_LIKE)
+ if(($item["verb"] == ACTIVITY_LIKE)
|| ($item["verb"] == ACTIVITY_DISLIKE)
|| ($item["verb"] == ACTIVITY_ATTEND)
|| ($item["verb"] == ACTIVITY_ATTENDNO)
dbesc($item["verb"]),
dbesc($item["parent-uri"])
);
- if (dbm::is_result($r)) {
+ if (dbm::is_result($r))
return false;
- }
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
intval($item["uid"]),
dbesc($item["verb"]),
dbesc($item["parent-uri"])
);
- if (dbm::is_result($r)) {
+ if (dbm::is_result($r))
return false;
- }
- } else {
+ } else
$is_like = false;
- }
- if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
+ if(($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item["object"],false);
$xt = parse_xml_string($item["target"],false);
- if ($xt->type == ACTIVITY_OBJ_NOTE) {
+ if($xt->type == ACTIVITY_OBJ_NOTE) {
$r = q("SELECT `id`, `tag` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($xt->id),
intval($importer["importer_uid"])
);
- if (!dbm::is_result($r)) {
- killme();
- }
+ if (!dbm::is_result($r))
+ return false;
// extract tag, if not duplicate, add to parent item
- if ($xo->content) {
- if (!(stristr($r[0]["tag"],trim($xo->content)))) {
+ if($xo->content) {
+ if(!(stristr($r[0]["tag"],trim($xo->content)))) {
q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d",
dbesc($r[0]["tag"] . (strlen($r[0]["tag"]) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]'),
intval($r[0]["id"])
*
* @param object $links link elements
* @param array $item the item record
- * @todo Add type-hints
*/
private static function parse_links($links, &$item) {
$rel = "";
$length = "0";
$title = "";
foreach ($links AS $link) {
- foreach ($link->attributes AS $attributes) {
- /// @TODO Rewrite these repeated (same) if () statements to a switch()
- if ($attributes->name == "href") {
+ foreach($link->attributes AS $attributes) {
+ if ($attributes->name == "href")
$href = $attributes->textContent;
- }
- if ($attributes->name == "rel") {
+ if ($attributes->name == "rel")
$rel = $attributes->textContent;
- }
- if ($attributes->name == "type") {
+ if ($attributes->name == "type")
$type = $attributes->textContent;
- }
- if ($attributes->name == "length") {
+ if ($attributes->name == "length")
$length = $attributes->textContent;
- }
- if ($attributes->name == "title") {
+ if ($attributes->name == "title")
$title = $attributes->textContent;
- }
}
if (($rel != "") AND ($href != ""))
switch($rel) {
break;
case "enclosure":
$enclosure = $href;
- if (strlen($item["attach"])) {
+ if(strlen($item["attach"]))
$item["attach"] .= ",";
- }
$item["attach"] .= '[attach]href="'.$href.'" length="'.$length.'" type="'.$type.'" title="'.$title.'"[/attach]';
break;
* @param object $xpath XPath object
* @param object $entry entry elements
* @param array $importer Record of the importer user mixed with contact of the content
- * @todo Add type-hints
*/
private static function process_entry($header, $xpath, $entry, $importer) {
$item["body"] = limit_body_size($item["body"]);
/// @todo Do we really need this check for HTML elements? (It was copied from the old function)
- if ((strpos($item['body'],'<') !== false) && (strpos($item['body'],'>') !== false)) {
+ if((strpos($item['body'],'<') !== false) && (strpos($item['body'],'>') !== false)) {
$item['body'] = reltoabs($item['body'],$base_url);
$item["location"] = $xpath->query("dfrn:location/text()", $entry)->item(0)->nodeValue;
$georsspoint = $xpath->query("georss:point", $entry);
- if ($georsspoint) {
+ if ($georsspoint)
$item["coord"] = $georsspoint->item(0)->nodeValue;
- }
$item["private"] = $xpath->query("dfrn:private/text()", $entry)->item(0)->nodeValue;
$item["extid"] = $xpath->query("dfrn:extid/text()", $entry)->item(0)->nodeValue;
- if ($xpath->query("dfrn:bookmark/text()", $entry)->item(0)->nodeValue == "true") {
+ if ($xpath->query("dfrn:bookmark/text()", $entry)->item(0)->nodeValue == "true")
$item["bookmark"] = true;
- }
$notice_info = $xpath->query("statusnet:notice_info", $entry);
if ($notice_info AND ($notice_info->length > 0)) {
- foreach ($notice_info->item(0)->attributes AS $attributes) {
- if ($attributes->name == "source") {
+ foreach($notice_info->item(0)->attributes AS $attributes) {
+ if ($attributes->name == "source")
$item["app"] = strip_tags($attributes->textContent);
- }
}
}
// We store the data from "dfrn:diaspora_signature" in a different table, this is done in "item_store"
$dsprsig = unxmlify($xpath->query("dfrn:diaspora_signature/text()", $entry)->item(0)->nodeValue);
- if ($dsprsig != "") {
+ if ($dsprsig != "")
$item["dsprsig"] = $dsprsig;
- }
$item["verb"] = $xpath->query("activity:verb/text()", $entry)->item(0)->nodeValue;
- if ($xpath->query("activity:object-type/text()", $entry)->item(0)->nodeValue != "") {
+ if ($xpath->query("activity:object-type/text()", $entry)->item(0)->nodeValue != "")
$item["object-type"] = $xpath->query("activity:object-type/text()", $entry)->item(0)->nodeValue;
- }
$object = $xpath->query("activity:object", $entry)->item(0);
$item["object"] = self::transform_activity($xpath, $object, "object");
if (trim($item["object"]) != "") {
$r = parse_xml_string($item["object"], false);
- if (isset($r->type)) {
+ if (isset($r->type))
$item["object-type"] = $r->type;
- }
}
$target = $xpath->query("activity:target", $entry)->item(0);
foreach ($categories AS $category) {
$term = "";
$scheme = "";
- foreach ($category->attributes AS $attributes) {
- if ($attributes->name == "term") {
+ foreach($category->attributes AS $attributes) {
+ if ($attributes->name == "term")
$term = $attributes->textContent;
- }
- if ($attributes->name == "scheme") {
+ if ($attributes->name == "scheme")
$scheme = $attributes->textContent;
- }
}
if (($term != "") AND ($scheme != "")) {
$termhash = array_shift($parts);
$termurl = implode(":", $parts);
- if (strlen($item["tag"])) {
+ if(strlen($item["tag"]))
$item["tag"] .= ",";
- }
$item["tag"] .= $termhash."[url=".$termurl."]".$term."[/url]";
}
$enclosure = "";
$links = $xpath->query("atom:link", $entry);
- if ($links) {
+ if ($links)
self::parse_links($links, $item);
- }
// Is it a reply or a top level posting?
$item["parent-uri"] = $item["uri"];
$inreplyto = $xpath->query("thr:in-reply-to", $entry);
- if (is_object($inreplyto->item(0))) {
- foreach ($inreplyto->item(0)->attributes AS $attributes) {
- if ($attributes->name == "ref") {
+ if (is_object($inreplyto->item(0)))
+ foreach($inreplyto->item(0)->attributes AS $attributes)
+ if ($attributes->name == "ref")
$item["parent-uri"] = $attributes->textContent;
- }
- }
- }
// Get the type of the item (Top level post, reply or remote reply)
$entrytype = self::get_entry_type($importer, $item);
// Now assign the rest of the values that depend on the type of the message
if (in_array($entrytype, array(DFRN_REPLY, DFRN_REPLY_RC))) {
- if (!isset($item["object-type"])) {
+ if (!isset($item["object-type"]))
$item["object-type"] = ACTIVITY_OBJ_COMMENT;
- }
- if ($item["contact-id"] != $owner["contact-id"]) {
+ if ($item["contact-id"] != $owner["contact-id"])
$item["contact-id"] = $owner["contact-id"];
- }
- if (($item["network"] != $owner["network"]) AND ($owner["network"] != "")) {
+ if (($item["network"] != $owner["network"]) AND ($owner["network"] != ""))
$item["network"] = $owner["network"];
- }
- if ($item["contact-id"] != $author["contact-id"]) {
+ if ($item["contact-id"] != $author["contact-id"])
$item["contact-id"] = $author["contact-id"];
- }
- if (($item["network"] != $author["network"]) AND ($author["network"] != "")) {
+ if (($item["network"] != $author["network"]) AND ($author["network"] != ""))
$item["network"] = $author["network"];
- }
// This code was taken from the old DFRN code
// When activated, forums don't work.
// And: Why should we disallow commenting by followers?
// the behaviour is now similar to the Diaspora part.
- //if ($importer["rel"] == CONTACT_IS_FOLLOWER) {
+ //if($importer["rel"] == CONTACT_IS_FOLLOWER) {
// logger("Contact ".$importer["id"]." is only follower. Quitting", LOGGER_DEBUG);
// return;
//}
$item["type"] = "remote-comment";
$item["wall"] = 1;
} elseif ($entrytype == DFRN_TOP_LEVEL) {
- if (!isset($item["object-type"])) {
+ if (!isset($item["object-type"]))
$item["object-type"] = ACTIVITY_OBJ_NOTE;
- }
// Is it an event?
if ($item["object-type"] == ACTIVITY_OBJ_EVENT) {
logger("Item ".$item["uri"]." seems to contain an event.", LOGGER_DEBUG);
$ev = bbtoevent($item["body"]);
- if ((x($ev, "desc") || x($ev, "summary")) && x($ev, "start")) {
+ if((x($ev, "desc") || x($ev, "summary")) && x($ev, "start")) {
logger("Event in item ".$item["uri"]." was found.", LOGGER_DEBUG);
$ev["cid"] = $importer["id"];
$ev["uid"] = $importer["uid"];
dbesc($item["uri"]),
intval($importer["uid"])
);
- if (dbm::is_result($r)) {
+ if (dbm::is_result($r))
$ev["id"] = $r[0]["id"];
- }
$event_id = event_store($ev);
logger("Event ".$event_id." was stored", LOGGER_DEBUG);
if (dbm::is_result($current)) {
if (self::update_content($r[0], $item, $importer, $entrytype))
logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
- } else {
+ else
logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
- }
return;
}
$posted_id = item_store($item);
$parent = 0;
- if ($posted_id) {
+ if($posted_id) {
logger("Reply from contact ".$item["contact-id"]." was stored with id ".$posted_id, LOGGER_DEBUG);
$parent_uri = $r[0]["parent-uri"];
}
- if (!$is_like) {
+ if(!$is_like) {
$r1 = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `uid` = %d AND `parent` = %d",
dbesc(datetime_convert()),
intval($importer["importer_uid"]),
);
}
- if ($posted_id AND $parent AND ($entrytype == DFRN_REPLY_RC)) {
+ if($posted_id AND $parent AND ($entrytype == DFRN_REPLY_RC)) {
logger("Notifying followers about comment ".$posted_id, LOGGER_DEBUG);
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $posted_id);
}
return true;
}
} else { // $entrytype == DFRN_TOP_LEVEL
- if (!link_compare($item["owner-link"],$importer["url"])) {
+ if(!link_compare($item["owner-link"],$importer["url"])) {
// The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery,
// but otherwise there's a possible data mixup on the sender's system.
// the tgroup delivery code called from item_store will correct it if it's a forum,
$item["owner-avatar"] = $importer["thumb"];
}
- if (($importer["rel"] == CONTACT_IS_FOLLOWER) && (!tgroup_check($importer["importer_uid"], $item))) {
+ if(($importer["rel"] == CONTACT_IS_FOLLOWER) && (!tgroup_check($importer["importer_uid"], $item))) {
logger("Contact ".$importer["id"]." is only follower and tgroup check was negative.", LOGGER_DEBUG);
return;
}
logger("Item was stored with id ".$posted_id, LOGGER_DEBUG);
- if (stristr($item["verb"],ACTIVITY_POKE))
+ if(stristr($item["verb"],ACTIVITY_POKE))
self::do_poke($item, $importer, $posted_id);
}
}
logger("Processing deletions");
- foreach ($deletion->attributes AS $attributes) {
- if ($attributes->name == "ref") {
+ foreach($deletion->attributes AS $attributes) {
+ if ($attributes->name == "ref")
$uri = $attributes->textContent;
- }
- if ($attributes->name == "when") {
+ if ($attributes->name == "when")
$when = $attributes->textContent;
- }
}
- if ($when) {
+ if ($when)
$when = datetime_convert("UTC", "UTC", $when, "Y-m-d H:i:s");
- } else {
+ else
$when = datetime_convert("UTC", "UTC", "now", "Y-m-d H:i:s");
- }
- if (!$uri OR !$importer["id"]) {
+ if (!$uri OR !$importer["id"])
return false;
- }
/// @todo Only select the used fields
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` INNER JOIN `contact` on `item`.`contact-id` = `contact`.`id`
$entrytype = self::get_entry_type($importer, $item);
- if (!$item["deleted"]) {
+ if(!$item["deleted"])
logger('deleting item '.$item["id"].' uri='.$uri, LOGGER_DEBUG);
- } else {
+ else
return;
- }
- if ($item["object-type"] == ACTIVITY_OBJ_EVENT) {
+ if($item["object-type"] == ACTIVITY_OBJ_EVENT) {
logger("Deleting event ".$item["event-id"], LOGGER_DEBUG);
event_delete($item["event-id"]);
}
- if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
+ if(($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item["object"],false);
$xt = parse_xml_string($item["target"],false);
- if ($xt->type == ACTIVITY_OBJ_NOTE) {
+ if($xt->type == ACTIVITY_OBJ_NOTE) {
$i = q("SELECT `id`, `contact-id`, `tag` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($xt->id),
intval($importer["importer_uid"])
$author_remove = (($item["origin"] && $item["self"]) ? true : false);
$author_copy = (($item["origin"]) ? true : false);
- if ($owner_remove && $author_copy) {
+ if($owner_remove && $author_copy)
return;
- }
- if ($author_remove || $owner_remove) {
+ if($author_remove || $owner_remove) {
$tags = explode(',',$i[0]["tag"]);
$newtags = array();
- if (count($tags)) {
- foreach ($tags as $tag) {
- if (trim($tag) !== trim($xo->body)) {
+ if(count($tags)) {
+ foreach($tags as $tag)
+ if(trim($tag) !== trim($xo->body))
$newtags[] = trim($tag);
- }
- }
}
q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d",
dbesc(implode(',',$newtags)),
}
}
- if ($entrytype == DFRN_TOP_LEVEL) {
+ if($entrytype == DFRN_TOP_LEVEL) {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
`body` = '', `title` = ''
WHERE `parent-uri` = '%s' AND `uid` = %d",
create_tags_from_itemuri($uri, $importer["uid"]);
create_files_from_itemuri($uri, $importer["uid"]);
update_thread_uri($uri, $importer["importer_uid"]);
- if ($item["last-child"]) {
+ if($item["last-child"]) {
// ensure that last-child is set in case the comment that had it just got wiped.
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
dbesc(datetime_convert()),
}
// if this is a relayed delete, propagate it to other recipients
- if ($entrytype == DFRN_REPLY_RC) {
+ if($entrytype == DFRN_REPLY_RC) {
logger("Notifying followers about deletion of post ".$item["id"], LOGGER_DEBUG);
proc_run(PRIORITY_HIGH, "include/notifier.php","drop", $item["id"]);
}
if ($xml == "")
return;
- if ($importer["readonly"]) {
+ if($importer["readonly"]) {
// We aren't receiving stuff from this person. But we will quietly ignore them
// rather than a blatant "go away" message.
logger('ignoring contact '.$importer["id"]);
// Update the contact table if the data has changed
// The "atom:author" is only present in feeds
- if ($xpath->query("/atom:feed/atom:author")->length > 0) {
+ if ($xpath->query("/atom:feed/atom:author")->length > 0)
self::fetchauthor($xpath, $doc->firstChild, $importer, "atom:author", false, $xml);
- }
// Only the "dfrn:owner" in the head section contains all data
- if ($xpath->query("/atom:feed/dfrn:owner")->length > 0) {
+ if ($xpath->query("/atom:feed/dfrn:owner")->length > 0)
self::fetchauthor($xpath, $doc->firstChild, $importer, "dfrn:owner", false, $xml);
- }
logger("Import DFRN message for user ".$importer["uid"]." from contact ".$importer["id"], LOGGER_DEBUG);
if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) {
$accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()", $context)->item(0)->nodeValue);
- if ($accounttype != $importer["contact-type"]) {
+ if ($accounttype != $importer["contact-type"])
q("UPDATE `contact` SET `contact-type` = %d WHERE `id` = %d",
intval($accounttype),
intval($importer["id"])
);
- }
}
// is it a public forum? Private forums aren't supported with this method
// This is deprecated since 3.5.1
$forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()", $context)->item(0)->nodeValue);
- if ($forum != $importer["forum"]) {
+ if ($forum != $importer["forum"])
q("UPDATE `contact` SET `forum` = %d WHERE `forum` != %d AND `id` = %d",
intval($forum), intval($forum),
intval($importer["id"])
);
- }
$mails = $xpath->query("/atom:feed/dfrn:mail");
- foreach ($mails AS $mail) {
+ foreach ($mails AS $mail)
self::process_mail($xpath, $mail, $importer);
- }
$suggestions = $xpath->query("/atom:feed/dfrn:suggest");
- foreach ($suggestions AS $suggestion) {
+ foreach ($suggestions AS $suggestion)
self::process_suggestion($xpath, $suggestion, $importer);
- }
$relocations = $xpath->query("/atom:feed/dfrn:relocate");
- foreach ($relocations AS $relocation) {
+ foreach ($relocations AS $relocation)
self::process_relocation($xpath, $relocation, $importer);
- }
$deletions = $xpath->query("/atom:feed/at:deleted-entry");
- foreach ($deletions AS $deletion) {
+ foreach ($deletions AS $deletion)
self::process_deletion($xpath, $deletion, $importer);
- }
if (!$sort_by_date) {
$entries = $xpath->query("/atom:feed/atom:entry");
- foreach ($entries AS $entry) {
+ foreach ($entries AS $entry)
self::process_entry($header, $xpath, $entry, $importer);
- }
} else {
$newentries = array();
$entries = $xpath->query("/atom:feed/atom:entry");
// Now sort after the publishing date
ksort($newentries);
- foreach ($newentries AS $entry) {
+ foreach ($newentries AS $entry)
self::process_entry($header, $xpath, $entry, $importer);
- }
}
logger("Import done for user ".$importer["uid"]." from contact ".$importer["id"], LOGGER_DEBUG);
}
$servers = explode(",", $serverdata);
- foreach ($servers AS $server) {
+ foreach($servers AS $server) {
$server = trim($server);
$addr = "relay@".str_replace("http://", "", normalise_link($server));
$batch = $server."/receive/public";
$children = $basedom->children('https://joindiaspora.com/protocol');
- if ($children->header) {
+ if($children->header) {
$public = true;
$author_link = str_replace('acct:','',$children->header->author_id);
} else {
// figure out where in the DOM tree our data is hiding
- if ($dom->provenance->data)
+ if($dom->provenance->data)
$base = $dom->provenance;
- elseif ($dom->env->data)
+ elseif($dom->env->data)
$base = $dom->env;
- elseif ($dom->data)
+ elseif($dom->data)
$base = $dom;
if (!$base) {
$data = base64url_decode($data);
- if ($public)
+ if($public)
$inner_decrypted = $data;
else {
logger("Fetching diaspora key for: ".$handle);
$r = self::person_by_handle($handle);
- if ($r)
+ if($r)
return $r["pubkey"];
return "";
*/
private static function add_fcontact($arr, $update = false) {
- if ($update) {
+ if($update) {
$r = q("UPDATE `fcontact` SET
`name` = '%s',
`photo` = '%s',
// perhaps we were already sharing with this person. Now they're sharing with us.
// That makes us friends.
// Normally this should have handled by getting a request - but this could get lost
- if ($contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
+ if($contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
intval(CONTACT_IS_FRIEND),
intval($contact["id"]),
logger("defining user ".$contact["nick"]." as friend");
}
- if (($contact["blocked"]) || ($contact["readonly"]) || ($contact["archive"]))
+ if(($contact["blocked"]) || ($contact["readonly"]) || ($contact["archive"]))
return false;
- if ($contact["rel"] == CONTACT_IS_SHARING || $contact["rel"] == CONTACT_IS_FRIEND)
+ if($contact["rel"] == CONTACT_IS_SHARING || $contact["rel"] == CONTACT_IS_FRIEND)
return true;
- if ($contact["rel"] == CONTACT_IS_FOLLOWER)
- if (($importer["page-flags"] == PAGE_COMMUNITY) OR $is_comment)
+ if($contact["rel"] == CONTACT_IS_FOLLOWER)
+ if(($importer["page-flags"] == PAGE_COMMUNITY) OR $is_comment)
return true;
// Messages for the global users are always accepted
logger("Fetch post from ".$source_url, LOGGER_DEBUG);
$envelope = fetch_url($source_url);
- if ($envelope) {
+ if($envelope) {
logger("Envelope was fetched.", LOGGER_DEBUG);
$x = self::verify_magic_envelope($envelope);
if (!$x)
logger("Fetch post from ".$source_url, LOGGER_DEBUG);
$x = fetch_url($source_url);
- if (!$x)
+ if(!$x)
return false;
}
FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
intval($uid), dbesc($guid));
- if (!$r) {
+ if(!$r) {
$result = self::store_by_guid($guid, $contact["url"], $uid);
if (!$result) {
}
// If we are the origin of the parent we store the original data and notify our followers
- if ($message_id AND $parent_item["origin"]) {
+ if($message_id AND $parent_item["origin"]) {
// Formerly we stored the signed text, the signature and the author in different fields.
// We now store the raw data so that we are more flexible.
intval($importer["uid"]),
dbesc($guid)
);
- if ($c)
+ if($c)
$conversation = $c[0];
else {
$r = q("INSERT INTO `conv` (`uid`, `guid`, `creator`, `created`, `updated`, `subject`, `recips`)
dbesc($subject),
dbesc($participants)
);
- if ($r)
+ if($r)
$c = q("SELECT * FROM `conv` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
intval($importer["uid"]),
dbesc($guid)
);
- if ($c)
+ if($c)
$conversation = $c[0];
}
if (!$conversation) {
return;
}
- foreach ($messages as $mesg)
+ foreach($messages as $mesg)
self::receive_conversation_message($importer, $contact, $data, $msg, $mesg, $conversation);
return true;
logger("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
// If we are the origin of the parent we store the original data and notify our followers
- if ($message_id AND $parent_item["origin"]) {
+ if($message_id AND $parent_item["origin"]) {
// Formerly we stored the signed text, the signature and the author in different fields.
// We now store the raw data so that we are more flexible.
$handle_parts = explode("@", $author);
$nick = $handle_parts[0];
- if ($name === "")
+ if($name === "")
$name = $handle_parts[0];
- if ( preg_match("|^https?://|", $image_url) === 0)
+ if( preg_match("|^https?://|", $image_url) === 0)
$image_url = "http://".$handle_parts[1].$image_url;
update_contact_avatar($image_url, $importer["uid"], $contact["id"]);
// this is to prevent multiple birthday notifications in a single year
// if we already have a stored birthday and the 'm-d' part hasn't changed, preserve the entry, which will preserve the notify year
- if (substr($birthday,5) === substr($contact["bd"],5))
+ if(substr($birthday,5) === substr($contact["bd"],5))
$birthday = $contact["bd"];
$r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `name-date` = '%s', `bd` = '%s',
$a = get_app();
- if ($contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
+ if($contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
intval(CONTACT_IS_FRIEND),
intval($contact["id"]),
intval($importer["uid"])
);
- if ($r && !$r[0]["hide-friends"] && !$contact["hidden"] && intval(get_pconfig($importer["uid"], "system", "post_newfriend"))) {
+ if($r && !$r[0]["hide-friends"] && !$contact["hidden"] && intval(get_pconfig($importer["uid"], "system", "post_newfriend"))) {
$self = q("SELECT * FROM `contact` WHERE `self` AND `uid` = %d LIMIT 1",
intval($importer["uid"])
// they are not CONTACT_IS_FOLLOWER anymore but that's what we have in the array
- if ($self && $contact["rel"] == CONTACT_IS_FOLLOWER) {
+ if($self && $contact["rel"] == CONTACT_IS_FOLLOWER) {
$arr = array();
$arr["uri"] = $arr["parent-uri"] = item_new_uri($a->get_hostname(), $importer["uid"]);
$arr["deny_gid"] = $user[0]["deny_gid"];
$i = item_store($arr);
- if ($i)
+ if($i)
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
}
}
$def_gid = get_default_group($importer['uid'], $ret["network"]);
- if (intval($def_gid))
+ if(intval($def_gid))
group_add_member($importer["uid"], "", $contact_record["id"], $def_gid);
update_contact_avatar($ret["photo"], $importer['uid'], $contact_record["id"], true);
- if ($importer["page-flags"] == PAGE_NORMAL) {
+ if($importer["page-flags"] == PAGE_NORMAL) {
logger("Sending intra message for author ".$author.".", LOGGER_DEBUG);
);
$u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer["uid"]));
- if ($u) {
+ if($u) {
logger("Sending share message (Relation: ".$new_relation.") to author ".$author." - Contact: ".$contact_record["id"]." - User: ".$importer["uid"], LOGGER_DEBUG);
$ret = self::send_share($u[0], $contact_record);
$a = get_app();
$enabled = intval(get_config("system", "diaspora_enabled"));
- if (!$enabled)
+ if(!$enabled)
return 200;
$logid = random_string(4);
$body = html_entity_decode(bb2diaspora($body));
// Adding the title
- if (strlen($title))
+ if(strlen($title))
$body = "## ".html_entity_decode($title)."\n\n".$body;
if ($item["attach"]) {
$cnt = preg_match_all('/href=\"(.*?)\"(.*?)title=\"(.*?)\"/ism', $item["attach"], $matches, PREG_SET_ORDER);
- if (cnt) {
+ if(cnt) {
$body .= "\n".t("Attachments:")."\n";
- foreach ($matches as $mtch)
+ foreach($matches as $mtch)
$body .= "[".$mtch[3]."](".$mtch[1].")\n";
}
}
$kw = str_replace(' ',' ',$kw);
$arr = explode(' ',$profile['pub_keywords']);
if (count($arr)) {
- for ($x = 0; $x < 5; $x ++) {
+ for($x = 0; $x < 5; $x ++) {
if (trim($arr[$x]))
$tags .= '#'. trim($arr[$x]) .' ';
}
"searchable" => $searchable,
"tag_string" => $tags);
- foreach ($recips as $recip) {
+ foreach($recips as $recip) {
logger("Send updated profile data for user ".$uid." to contact ".$recip["id"], LOGGER_DEBUG);
self::build_and_transmit($profile, $recip, "profile", $message, false, "", true);
}
}
$r = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($contact['uid']));
- if (!dbm::is_result($r)) {
+ if(!$r)
return false;
- }
$contact["uprvkey"] = $r[0]['prvkey'];
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($post_id));
- if (!dbm::is_result($r)) {
+ if (!$r)
return false;
- }
- if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
+ if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE)))
return false;
- }
$message = self::construct_like($r[0], $contact);
$message["author_signature"] = self::signature($contact, $message);
$j = json_decode($x);
if (count($j->results)) {
- foreach ($j->results as $jj) {
+ foreach($j->results as $jj) {
// Check if the contact already exists
$exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
- if (dbm::is_result($exists)) {
+ if ($exists) {
logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND
if (!$result["success"]) {
return false;
}
-
$contacts = json_decode($result["body"]);
if ($contacts->status == 'ERROR') {
return false;
}
-
- foreach ($contacts->data AS $user) {
+ foreach($contacts->data AS $user) {
$contact = probe_url($user->site_address."/".$user->name);
if ($contact["network"] != NETWORK_PHANTOM) {
$contact["about"] = $user->description;
require_once('include/quoteconvert.php');
function email_connect($mailbox,$username,$password) {
- if (! function_exists('imap_open'))
+ if(! function_exists('imap_open'))
return false;
$mbox = @imap_open($mailbox,$username,$password);
function email_poll($mbox,$email_addr) {
- if (! ($mbox && $email_addr))
+ if(! ($mbox && $email_addr))
return array();
$search1 = @imap_search($mbox,'FROM "' . $email_addr . '"', SE_UID);
- if (! $search1)
+ if(! $search1)
$search1 = array();
$search2 = @imap_search($mbox,'TO "' . $email_addr . '"', SE_UID);
- if (! $search2)
+ if(! $search2)
$search2 = array();
$search3 = @imap_search($mbox,'CC "' . $email_addr . '"', SE_UID);
- if (! $search3)
+ if(! $search3)
$search3 = array();
$search4 = @imap_search($mbox,'BCC "' . $email_addr . '"', SE_UID);
- if (! $search4)
+ if(! $search4)
$search4 = array();
$res = array_unique(array_merge($search1,$search2,$search3,$search4));
$raw_header = str_replace("\r",'',$raw_header);
$ret = array();
$h = explode("\n",$raw_header);
- if (count($h))
- foreach ($h as $line ) {
+ if(count($h))
+ foreach($h as $line ) {
if (preg_match("/^[a-zA-Z]/", $line)) {
$key = substr($line,0,strpos($line,':'));
$value = substr($line,strpos($line,':')+1);
$struc = (($mbox && $uid) ? @imap_fetchstructure($mbox,$uid,FT_UID) : null);
- if (! $struc)
+ if(! $struc)
return $ret;
- if (! $struc->parts) {
+ if(! $struc->parts) {
$ret['body'] = email_get_part($mbox,$uid,$struc,0, 'html');
$html = $ret['body'];
else {
$text = '';
$html = '';
- foreach ($struc->parts as $ptop => $p) {
+ foreach($struc->parts as $ptop => $p) {
$x = email_get_part($mbox,$uid,$p,$ptop + 1, 'plain');
if ($x) {
$text .= $x;
function email_header_encode($in_str, $charset) {
- $out_str = $in_str;
+ $out_str = $in_str;
$need_to_convert = false;
- for ($x = 0; $x < strlen($in_str); $x ++) {
- if ((ord($in_str[$x]) == 0) || ((ord($in_str[$x]) > 128))) {
+ for($x = 0; $x < strlen($in_str); $x ++) {
+ if((ord($in_str[$x]) == 0) || ((ord($in_str[$x]) > 128))) {
$need_to_convert = true;
}
}
- if (! $need_to_convert)
+ if(! $need_to_convert)
return $in_str;
if ($out_str && $charset) {
$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);
+ } while($dups == true);
- /// @TODO One statement is enough
$datarray = array();
$datarray['hash'] = $hash;
$datarray['name'] = $params['source_name'];
function format_event_html($ev, $simple = false) {
- if (! ((is_array($ev)) && count($ev))) {
+ if(! ((is_array($ev)) && count($ev))) {
return '';
}
logger('parse_event: parse error: ' . $e);
}
- if (! $dom)
+ if(! $dom)
return $ret;
$items = $dom->getElementsByTagName('*');
- foreach ($items as $item) {
- if (attribute_contains($item->getAttribute('class'), 'vevent')) {
+ foreach($items as $item) {
+ if(attribute_contains($item->getAttribute('class'), 'vevent')) {
$level2 = $item->getElementsByTagName('*');
- foreach ($level2 as $x) {
- if (attribute_contains($x->getAttribute('class'),'dtstart') && $x->getAttribute('title')) {
+ foreach($level2 as $x) {
+ if(attribute_contains($x->getAttribute('class'),'dtstart') && $x->getAttribute('title')) {
$ret['start'] = $x->getAttribute('title');
- if (! strpos($ret['start'],'Z'))
+ if(! strpos($ret['start'],'Z'))
$ret['adjust'] = true;
}
- if (attribute_contains($x->getAttribute('class'),'dtend') && $x->getAttribute('title'))
+ if(attribute_contains($x->getAttribute('class'),'dtend') && $x->getAttribute('title'))
$ret['finish'] = $x->getAttribute('title');
- if (attribute_contains($x->getAttribute('class'),'description'))
+ if(attribute_contains($x->getAttribute('class'),'description'))
$ret['desc'] = $x->textContent;
- if (attribute_contains($x->getAttribute('class'),'location'))
+ if(attribute_contains($x->getAttribute('class'),'location'))
$ret['location'] = $x->textContent;
}
}
// sanitise
- if ((x($ret,'desc')) && ((strpos($ret['desc'],'<') !== false) || (strpos($ret['desc'],'>') !== false))) {
+ if((x($ret,'desc')) && ((strpos($ret['desc'],'<') !== false) || (strpos($ret['desc'],'>') !== false))) {
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$purifier = new HTMLPurifier($config);
$ret['desc'] = html2bbcode($purifier->purify($ret['desc']));
}
- if ((x($ret,'location')) && ((strpos($ret['location'],'<') !== false) || (strpos($ret['location'],'>') !== false))) {
+ if((x($ret,'location')) && ((strpos($ret['location'],'<') !== false) || (strpos($ret['location'],'>') !== false))) {
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$purifier = new HTMLPurifier($config);
$ret['location'] = html2bbcode($purifier->purify($ret['location']));
}
- if (x($ret,'start'))
+ if(x($ret,'start'))
$ret['start'] = datetime_convert('UTC','UTC',$ret['start']);
- if (x($ret,'finish'))
+ if(x($ret,'finish'))
$ret['finish'] = datetime_convert('UTC','UTC',$ret['finish']);
return $ret;
*/
function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
// Only allow events if there is a valid owner_id
- if ($owner_uid == 0) {
+ if($owner_uid == 0) {
return;
}
* @return array Event array for the template
*/
function process_events($arr) {
- $events = array();
+ $events=array();
$last_date = '';
$fmt = t('l, F j');
// 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');
*/
function get_feature_default($feature) {
$f = get_features();
- foreach ($f as $cat) {
- foreach ($cat as $feat) {
- if (is_array($feat) && $feat[0] === $feature)
+ foreach($f as $cat) {
+ foreach($cat as $feat) {
+ if(is_array($feat) && $feat[0] === $feature)
return $feat[3];
}
}
// removed any locked features and remove the entire category if this makes it empty
- if ($filtered) {
- foreach ($arr as $k => $x) {
+ if($filtered) {
+ foreach($arr as $k => $x) {
$has_items = false;
$kquantity = count($arr[$k]);
- for ($y = 0; $y < $kquantity; $y ++) {
- if (is_array($arr[$k][$y])) {
- if ($arr[$k][$y][4] === false) {
+ for($y = 0; $y < $kquantity; $y ++) {
+ if(is_array($arr[$k][$y])) {
+ if($arr[$k][$y][4] === false) {
$has_items = true;
}
else {
}
}
}
- if (! $has_items) {
+ if(! $has_items) {
unset($arr[$k]);
}
}
$header["contact-id"] = $contact["id"];
- if (!strlen($contact["notify"])) {
+ if(!strlen($contact["notify"])) {
// one way feed - no remote comment ability
$header["last-child"] = 0;
}
$type = "";
$title = "";
- foreach ($enclosure->attributes AS $attributes) {
+ foreach($enclosure->attributes AS $attributes) {
if ($attributes->name == "url") {
$href = $attributes->textContent;
} elseif ($attributes->name == "length") {
$type = $attributes->textContent;
}
}
- if (strlen($item["attach"])) {
+ if(strlen($item["attach"]))
$item["attach"] .= ',';
- }
$attachments[] = array("link" => $href, "type" => $type, "length" => $length);
function create_files_from_itemuri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
- if (count($messages)) {
+ if(count($messages)) {
foreach ($messages as $message)
create_files_from_item($message["id"]);
}
// setTemplateDir can be set to an array, which Smarty will parse in order.
// The order is thus very important here
$template_dirs = array('theme' => "view/theme/$theme/".SMARTY3_TEMPLATE_FOLDER."/");
- if ( x($a->theme_info,"extends") )
+ if( x($a->theme_info,"extends") )
$template_dirs = $template_dirs + array('extends' => "view/theme/".$a->theme_info["extends"]."/".SMARTY3_TEMPLATE_FOLDER."/");
$template_dirs = $template_dirs + array('base' => "view/".SMARTY3_TEMPLATE_FOLDER."/");
$this->setTemplateDir($template_dirs);
}
function parsed($template = '') {
- if ($template) {
+ if($template) {
return $this->fetch('string:' . $template);
}
return $this->fetch('file:' . $this->filename);
static $name ="smarty3";
public function __construct(){
- if (!is_writable('view/smarty3/')){
+ if(!is_writable('view/smarty3/')){
echo "<b>ERROR:</b> folder <tt>view/smarty3/</tt> must be writable by webserver."; killme();
}
}
// ITemplateEngine interface
public function replace_macros($s, $r) {
$template = '';
- if (gettype($s) === 'string') {
+ if(gettype($s) === 'string') {
$template = $s;
$s = new FriendicaSmarty();
}
call_hooks("template_vars", $arr);
$r = $arr['vars'];
- foreach ($r as $key=>$value) {
- if ($key[0] === '$') {
+ foreach($r as $key=>$value) {
+ if($key[0] === '$') {
$key = substr($key, 1);
}
$s->assign($key, $value);
function group_add($uid,$name) {
$ret = false;
- if (x($uid) && x($name)) {
+ if(x($uid) && x($name)) {
$r = group_byname($uid,$name); // check for dups
- if ($r !== false) {
+ if($r !== false) {
// This could be a problem.
// Let's assume we've just created a group which we once deleted
$z = q("SELECT * FROM `group` WHERE `id` = %d LIMIT 1",
intval($r)
);
- if (count($z) && $z[0]['deleted']) {
+ if(count($z) && $z[0]['deleted']) {
$r = q("UPDATE `group` SET `deleted` = 0 WHERE `uid` = %d AND `name` = '%s'",
intval($uid),
dbesc($name)
function group_rmv($uid,$name) {
$ret = false;
- if (x($uid) && x($name)) {
+ if(x($uid) && x($name)) {
$r = q("SELECT id FROM `group` WHERE `uid` = %d AND `name` = '%s' LIMIT 1",
intval($uid),
dbesc($name)
);
if (dbm::is_result($r))
$group_id = $r[0]['id'];
- if (! $group_id)
+ if(! $group_id)
return false;
// remove group from default posting lists
$user_info = $r[0];
$change = false;
- if ($user_info['def_gid'] == $group_id) {
+ if($user_info['def_gid'] == $group_id) {
$user_info['def_gid'] = 0;
$change = true;
}
- if (strpos($user_info['allow_gid'], '<' . $group_id . '>') !== false) {
+ if(strpos($user_info['allow_gid'], '<' . $group_id . '>') !== false) {
$user_info['allow_gid'] = str_replace('<' . $group_id . '>', '', $user_info['allow_gid']);
$change = true;
}
- if (strpos($user_info['deny_gid'], '<' . $group_id . '>') !== false) {
+ if(strpos($user_info['deny_gid'], '<' . $group_id . '>') !== false) {
$user_info['deny_gid'] = str_replace('<' . $group_id . '>', '', $user_info['deny_gid']);
$change = true;
}
- if ($change) {
+ if($change) {
q("UPDATE user SET def_gid = %d, allow_gid = '%s', deny_gid = '%s' WHERE uid = %d",
intval($user_info['def_gid']),
dbesc($user_info['allow_gid']),
}
function group_byname($uid,$name) {
- if ((! $uid) || (! strlen($name)))
+ if((! $uid) || (! strlen($name)))
return false;
$r = q("SELECT * FROM `group` WHERE `uid` = %d AND `name` = '%s' LIMIT 1",
intval($uid),
function group_rmv_member($uid,$name,$member) {
$gid = group_byname($uid,$name);
- if (! $gid)
+ if(! $gid)
return false;
- if (! ( $uid && $gid && $member))
+ if(! ( $uid && $gid && $member))
return false;
$r = q("DELETE FROM `group_member` WHERE `uid` = %d AND `gid` = %d AND `contact-id` = %d",
intval($uid),
function group_add_member($uid,$name,$member,$gid = 0) {
- if (! $gid)
+ if(! $gid)
$gid = group_byname($uid,$name);
- if ((! $gid) || (! $uid) || (! $member))
+ if((! $gid) || (! $uid) || (! $member))
return false;
$r = q("SELECT * FROM `group_member` WHERE `uid` = %d AND `gid` = %d AND `contact-id` = %d LIMIT 1",
function group_get_members($gid) {
$ret = array();
- if (intval($gid)) {
+ if(intval($gid)) {
$r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member`
INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
WHERE `gid` = %d AND `group_member`.`uid` = %d AND
function group_public_members($gid) {
$ret = 0;
- if (intval($gid)) {
+ if(intval($gid)) {
$r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member`
INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
WHERE `gid` = %d AND `group_member`.`uid` = %d
intval($_SESSION['uid'])
);
$member_of = array();
- if ($cid) {
+ if($cid) {
$member_of = groups_containing(local_user(),$cid);
}
}
function expand_groups($a,$check_dead = false, $use_gcontact = false) {
- if (! (is_array($a) && count($a)))
+ if(! (is_array($a) && count($a)))
return array();
$groups = implode(',', $a);
$groups = dbesc($groups);
$ret = array();
if (dbm::is_result($r))
- foreach ($r as $rr)
+ foreach($r as $rr)
$ret[] = $rr['contact-id'];
- if ($check_dead AND !$use_gcontact) {
+ if($check_dead AND !$use_gcontact) {
require_once('include/acl_selectors.php');
$ret = prune_deadguys($ret);
}
$ret = array();
if (dbm::is_result($r)) {
- foreach ($r as $rr) {
+ foreach($r as $rr)
$ret[] = $rr['gid'];
- }
}
return $ret;
return $default_group;
$g = q("SELECT `def_gid` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
- if ($g && intval($g[0]["def_gid"]))
+ if($g && intval($g[0]["def_gid"]))
$default_group = $g[0]["def_gid"];
return $default_group;
$newlines = array();
$level = 0;
- foreach ($lines as $line) {;
+ foreach($lines as $line) {;
$line = trim($line);
$startquote = false;
while (strpos("*".$line, '[quote]') > 0) {
dbesc($nickname)
);
- if (!$user && count($user) && !count($profiledata)) {
+ if(!$user && count($user) && !count($profiledata)) {
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
notice( t('Requested account is not available.') . EOL );
$a->error = 404;
$pdata = get_profiledata_by_nick($nickname, $user[0]['uid'], $profile);
- if (($pdata === false) || (!count($pdata)) && !count($profiledata)) {
+ if(($pdata === false) || (!count($pdata)) && !count($profiledata)) {
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
notice( t('Requested profile is not available.') . EOL );
$a->error = 404;
// fetch user tags if this isn't the default profile
- if (!$pdata['is-default']) {
+ if(!$pdata['is-default']) {
$x = q("SELECT `pub_keywords` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
intval($pdata['profile_uid'])
);
- if ($x && count($x))
+ if($x && count($x))
$pdata['pub_keywords'] = $x[0]['pub_keywords'];
}
require_once($theme_info_file);
}
- if (! (x($a->page,'aside')))
+ if(! (x($a->page,'aside')))
$a->page['aside'] = '';
- if (local_user() && local_user() == $a->profile['uid'] && $profiledata) {
+ if(local_user() && local_user() == $a->profile['uid'] && $profiledata) {
$a->page['aside'] .= replace_macros(get_markup_template('profile_edlink.tpl'),array(
'$editprofile' => t('Edit profile'),
'$profid' => $a->profile['id']
else
$a->page['aside'] .= profile_sidebar($a->profile, $block);
- /*if (! $block)
+ /*if(! $block)
$a->page['aside'] .= contact_block();*/
return;
* Includes all available profile data
*/
function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
- if (remote_user() && count($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $visitor) {
- if ($visitor['uid'] == $uid) {
+ if(remote_user() && count($_SESSION['remote'])) {
+ foreach($_SESSION['remote'] as $visitor) {
+ if($visitor['uid'] == $uid) {
$r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
intval($visitor['cid'])
);
$r = null;
- if ($profile) {
+ if($profile) {
$profile_int = intval($profile);
$r = q("SELECT `contact`.`id` AS `contact_id`, `profile`.`uid` AS `profile_uid`, `profile`.*,
`contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.*
$address = false;
// $pdesc = true;
- if ((! is_array($profile)) && (! count($profile)))
+ if((! is_array($profile)) && (! count($profile)))
return $o;
$profile['picdate'] = urlencode($profile['picdate']);
$connect = (($profile['uid'] != local_user()) ? t('Connect') : False);
// don't show connect link to authenticated visitors either
- if (remote_user() && count($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $visitor) {
- if ($visitor['uid'] == $profile['uid']) {
+ if(remote_user() && count($_SESSION['remote'])) {
+ foreach($_SESSION['remote'] as $visitor) {
+ if($visitor['uid'] == $profile['uid']) {
$connect = false;
break;
}
// Fetch the account type
$account_type = account_type($profile);
- if ((x($profile,'address') == 1)
+ if((x($profile,'address') == 1)
|| (x($profile,'location') == 1)
|| (x($profile,'locality') == 1)
|| (x($profile,'region') == 1)
$xmpp = ((x($profile,'xmpp') == 1) ? t('XMPP:') : False);
- if (($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) {
+ if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) {
$location = $pdesc = $gender = $marital = $homepage = $about = False;
}
if (!$block){
$contact_block = contact_block();
- if (is_array($a->profile) AND !$a->profile['hide-friends']) {
+ if(is_array($a->profile) AND !$a->profile['hide-friends']) {
$r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
intval($a->profile['uid']));
if (dbm::is_result($r))
}
$p = array();
- foreach ($profile as $k => $v) {
+ foreach($profile as $k => $v) {
$k = str_replace('-','_',$k);
$p[$k] = $v;
}
if (isset($p["photo"]))
$p["photo"] = proxy_url($p["photo"], false, PROXY_SIZE_SMALL);
- if ($a->theme['template_engine'] === 'internal')
+ if($a->theme['template_engine'] === 'internal')
$location = template_escape($location);
$tpl = get_markup_template('profile_vcard.tpl');
$a = get_app();
$o = '';
- if (! local_user() || $a->is_mobile || $a->is_tablet)
+ if(! local_user() || $a->is_mobile || $a->is_tablet)
return $o;
// $mobile_detect = new Mobile_Detect();
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
-// if ($is_mobile)
+// if($is_mobile)
// return $o;
$bd_format = t('g A l F d') ; // 8 AM Friday January 18
$istoday = false;
foreach ($r as $rr) {
- if (strlen($rr['name']))
+ if(strlen($rr['name']))
$total ++;
- if ((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
+ if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
$istoday = true;
}
$classtoday = $istoday ? ' birthday-today ' : '';
- if ($total) {
- foreach ($r as &$rr) {
- if (! strlen($rr['name']))
+ if($total) {
+ foreach($r as &$rr) {
+ if(! strlen($rr['name']))
continue;
// avoid duplicates
- if (in_array($rr['cid'],$cids))
+ if(in_array($rr['cid'],$cids))
continue;
$cids[] = $rr['cid'];
$today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
$sparkle = '';
$url = $rr['url'];
- if ($rr['network'] === NETWORK_DFRN) {
+ if($rr['network'] === NETWORK_DFRN) {
$sparkle = " sparkle";
$url = App::get_baseurl() . '/redir/' . $rr['cid'];
}
$a = get_app();
- if (! local_user() || $a->is_mobile || $a->is_tablet)
+ if(! local_user() || $a->is_mobile || $a->is_tablet)
return $o;
// $mobile_detect = new Mobile_Detect();
// $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
-// if ($is_mobile)
+// if($is_mobile)
// return $o;
$bd_format = t('g A l F d') ; // 8 AM Friday January 18
$now = strtotime('now');
$istoday = false;
foreach ($r as $rr) {
- if (strlen($rr['name']))
+ if(strlen($rr['name']))
$total ++;
$strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start'],'Y-m-d');
- if ($strt === datetime_convert('UTC',$a->timezone,'now','Y-m-d'))
+ if($strt === datetime_convert('UTC',$a->timezone,'now','Y-m-d'))
$istoday = true;
}
$classtoday = (($istoday) ? 'event-today' : '');
$skip = 0;
- foreach ($r as &$rr) {
+ foreach($r as &$rr) {
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
- if (strlen($title) > 35)
+ if(strlen($title) > 35)
$title = substr($title,0,32) . '... ';
$description = substr(strip_tags(bbcode($rr['desc'])),0,32) . '... ';
- if (! $description)
+ if(! $description)
$description = t('[No description]');
$strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start']);
- if (substr($strt,0,10) < datetime_convert('UTC',$a->timezone,'now','Y-m-d')) {
+ if(substr($strt,0,10) < datetime_convert('UTC',$a->timezone,'now','Y-m-d')) {
$skip++;
continue;
}
'$title' => t('Profile')
));
- if ($a->profile['name']) {
+ if($a->profile['name']) {
$tpl = get_markup_template('profile_advanced.tpl');
$profile['fullname'] = array( t('Full Name:'), $a->profile['name'] ) ;
- if ($a->profile['gender']) $profile['gender'] = array( t('Gender:'), $a->profile['gender'] );
+ if($a->profile['gender']) $profile['gender'] = array( t('Gender:'), $a->profile['gender'] );
- if (($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) {
+ if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) {
$year_bd_format = t('j F, Y');
$short_bd_format = t('j F');
}
- if ($age = age($a->profile['dob'],$a->profile['timezone'],'')) $profile['age'] = array( t('Age:'), $age );
+ if($age = age($a->profile['dob'],$a->profile['timezone'],'')) $profile['age'] = array( t('Age:'), $age );
- if ($a->profile['marital']) $profile['marital'] = array( t('Status:'), $a->profile['marital']);
+ if($a->profile['marital']) $profile['marital'] = array( t('Status:'), $a->profile['marital']);
/// @TODO Maybe use x() here, plus below?
if ($a->profile['with']) {
}
function get_my_url() {
- if (x($_SESSION,'my_url'))
+ if(x($_SESSION,'my_url'))
return $_SESSION['my_url'];
return false;
}
function zrl_init(App $a) {
$tmp_str = get_my_url();
- if (validate_url($tmp_str)) {
+ if(validate_url($tmp_str)) {
// Is it a DDoS attempt?
// The check fetches the cached value from gprobe to reduce the load for this system
}
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;
}
*/
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(local_user()) {
+ if((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid))
return local_user();
- }
}
return $uid;
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
- while (($img_st_close !== false) && ($img_end !== false)) {
+ while(($img_st_close !== false) && ($img_end !== false)) {
$img_st_close++; // make it point to AFTER the closing bracket
$img_end += $img_start;
"#$2", $item["body"]);
- foreach ($tags as $tag) {
+ foreach($tags as $tag) {
if (strpos($tag,'#') !== 0)
continue;
function get_item_contact($item,$contacts) {
if (! count($contacts) || (! is_array($item)))
return false;
- foreach ($contacts as $contact) {
+ foreach($contacts as $contact) {
if ($contact['id'] == $item['contact-id']) {
return $contact;
break; // NOTREACHED
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if ($cnt) {
- foreach ($matches as $mtch) {
+ foreach($matches as $mtch) {
if (link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
$mention = true;
logger('tag_deliver: mention found: ' . $mtch[2]);
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_len = ($img_start !== false ? strpos(substr($orig_body, $img_start + $img_st_close + 1), '[/img]') : false);
- while ( ($img_st_close !== false) && ($img_len !== false) ) {
+ while( ($img_st_close !== false) && ($img_len !== false) ) {
$img_st_close++; // make it point to AFTER the closing bracket
$image = substr($orig_body, $img_start + $img_st_close, $img_len);
$matches = false;
$cnt = preg_match_all('|\#\[url\=(.*?)\](.*?)\[\/url\]|',$item['tag'],$matches);
if ($cnt) {
- for ($x = 0; $x < $cnt; $x ++) {
+ for($x = 0; $x < $cnt; $x ++) {
if ($matches[1][$x])
$ret[$matches[2][$x]] = array('#',$matches[1][$x], $matches[2][$x]);
}
$matches = false;
$cnt = preg_match_all('|\@\[url\=(.*?)\](.*?)\[\/url\]|',$item['tag'],$matches);
if ($cnt) {
- for ($x = 0; $x < $cnt; $x ++) {
+ for($x = 0; $x < $cnt; $x ++) {
if ($matches[1][$x])
$ret[] = array('@',$matches[1][$x], $matches[2][$x]);
}
logger('expire: # items=' . count($r). "; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos");
- foreach ($r as $item) {
+ foreach($r as $item) {
// don't expire filed items
return;
if (count($items)) {
- foreach ($items as $item) {
+ foreach($items as $item) {
$owner = drop_item($item,false);
if ($owner && ! $uid)
$uid = $owner;
// check if logged in user is either the author or owner of this item
if (is_array($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $visitor) {
+ foreach($_SESSION['remote'] as $visitor) {
if ($visitor['uid'] == $item['uid'] && $visitor['cid'] == $item['contact-id']) {
$contact_id = $visitor['cid'];
break;
// so add any arguments as hidden inputs
$query = explode_querystring($a->query_string);
$inputs = array();
- foreach ($query['args'] as $arg) {
+ foreach($query['args'] as $arg) {
if (strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
$matches = false;
$cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER);
if ($cnt) {
- foreach ($matches as $mtch) {
+ foreach($matches as $mtch) {
file_tag_unsave_file($item['uid'],$item['id'],$mtch[1],true);
}
}
$cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER);
if ($cnt) {
- foreach ($matches as $mtch) {
+ foreach($matches as $mtch) {
file_tag_unsave_file($item['uid'],$item['id'],$mtch[1],false);
}
}
// If item has attachments, drop them
- foreach (explode(",",$item['attach']) as $attach){
+ foreach(explode(",",$item['attach']) as $attach){
preg_match("|attach/(\d+)|", $attach, $matches);
q("DELETE FROM `attach` WHERE `id` = %d AND `uid` = %d",
intval($matches[1]),
// Starting with the current month, get the first and last days of every
// month down to and including the month of the first post
- while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
+ while(substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
$dyear = intval(substr($dnow,0,4));
$dstart = substr($dnow,0,8) . '01';
$dend = substr($dnow,0,8) . get_dim(intval($dnow),intval(substr($dnow,5)));
$ret = array();
// Starting with the current month, get the first and last days of every
// month down to and including the month of the first post
- while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
+ while(substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
$dstart = substr($dnow,0,8) . '01';
$dend = substr($dnow,0,8) . get_dim(intval($dnow),intval(substr($dnow,5)));
$start_month = datetime_convert('','',$dstart,'Y-m-d');
// Provide some ability to lock a PHP function so that multiple processes
// can't run the function concurrently
-if (! function_exists('lock_function')) {
+if(! function_exists('lock_function')) {
function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
- if ( $wait_sec == 0 )
+ if( $wait_sec == 0 )
$wait_sec = 2; // don't let the user pick a value that's likely to crash the system
$got_lock = false;
dbesc($fn_name)
);
- if ((dbm::is_result($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) {
+ if((dbm::is_result($r)) AND (!$r[0]['locked'] OR (strtotime($r[0]['created']) < time() - 3600))) {
q("UPDATE `locks` SET `locked` = 1, `created` = '%s' WHERE `name` = '%s'",
dbesc(datetime_convert()),
dbesc($fn_name)
q("UNLOCK TABLES");
- if (($block) && (! $got_lock))
+ if(($block) && (! $got_lock))
sleep($wait_sec);
- } while (($block) && (! $got_lock) && ((time() - $start) < $timeout));
+ } while(($block) && (! $got_lock) && ((time() - $start) < $timeout));
logger('lock_function: function ' . $fn_name . ' with blocking = ' . $block . ' got_lock = ' . $got_lock . ' time = ' . (time() - $start), LOGGER_DEBUG);
}}
-if (! function_exists('block_on_function_lock')) {
+if(! function_exists('block_on_function_lock')) {
function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) {
- if ( $wait_sec == 0 )
+ if( $wait_sec == 0 )
$wait_sec = 2; // don't let the user pick a value that's likely to crash the system
$start = time();
do {
$r = q("SELECT locked FROM locks WHERE name = '%s' LIMIT 1",
- dbesc($fn_name)
- );
+ 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));
+ } while(dbm::is_result($r) && $r[0]['locked'] && ((time() - $start) < $timeout));
return;
}}
-if (! function_exists('unlock_function')) {
+if(! function_exists('unlock_function')) {
function unlock_function($fn_name) {
$r = q("UPDATE `locks` SET `locked` = 0, `created` = '%s' WHERE `name` = '%s'",
dbesc(NULL_DATE),
$a = get_app();
- if (! $recipient) return -1;
+ if(! $recipient) return -1;
- if (! strlen($subject))
+ if(! strlen($subject))
$subject = t('[no subject]');
$me = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval(local_user())
);
- if (! (count($me) && (count($contact)))) {
+ if(! (count($me) && (count($contact)))) {
return -2;
}
// look for any existing conversation structure
- if (strlen($replyto)) {
+ if(strlen($replyto)) {
$reply = true;
$r = q("select convid from mail where uid = %d and ( uri = '%s' or `parent-uri` = '%s' ) limit 1",
intval(local_user()),
$convid = $r[0]['convid'];
}
- if (! $convid) {
+ if(! $convid) {
// create a new conversation
$convid = $r[0]['id'];
}
- if (! $convid) {
+ if(! $convid) {
logger('send message: conversation not found.');
return -4;
}
- if (! strlen($replyto)) {
+ if(! strlen($replyto)) {
$replyto = $convuri;
}
$lines = array();
$lineno = 0;
- foreach ($arrbody as $i => $line) {
+ foreach($arrbody as $i => $line) {
$currquotelevel = 0;
$currline = $line;
while ((strlen($currline)>0) and ((substr($currline, 0, 1) == '>')
*
*/
- if (!(x($a->page,'nav')))
+ if(!(x($a->page,'nav')))
$a->page['nav'] = '';
$a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), array());
if (strlen(get_config('system', 'singleuser'))) {
$gdir = get_config('system', 'directory');
- if (strlen($gdir)) {
+ if(strlen($gdir)) {
$gdirpath = zrl($gdir, true);
}
} elseif (get_config('system', 'community_page_style') == CP_USERS_ON_SERVER) {
@curl_setopt($ch, CURLOPT_HEADER, true);
- if (x($opts,"cookiejar")) {
+ if(x($opts,"cookiejar")) {
curl_setopt($ch, CURLOPT_COOKIEJAR, $opts["cookiejar"]);
curl_setopt($ch, CURLOPT_COOKIEFILE, $opts["cookiejar"]);
}
@curl_setopt($ch, CURLOPT_RANGE, '0-'.$range);
}
- if (x($opts,'headers')){
+ if(x($opts,'headers')){
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
}
- if (x($opts,'nobody')){
+ if(x($opts,'nobody')){
@curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']);
}
- if (x($opts,'timeout')){
+ if(x($opts,'timeout')){
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
} else {
$curl_time = intval(get_config('system','curl_timeout'));
}
$prx = get_config('system','proxy');
- if (strlen($prx)) {
+ if(strlen($prx)) {
@curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
@curl_setopt($ch, CURLOPT_PROXY, $prx);
$prxusr = @get_config('system','proxyuser');
- if (strlen($prxusr))
+ if(strlen($prxusr))
@curl_setopt($ch, CURLOPT_PROXYUSERPWD, $prxusr);
}
- if ($binary)
+ if($binary)
@curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$a->set_curl_code(0);
// Pull out multiple headers, e.g. proxy and continuation headers
// allow for HTTP/2.x without fixing code
- while (preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/',$base)) {
+ while(preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/',$base)) {
$chunk = substr($base,0,strpos($base,"\r\n\r\n")+4);
$header .= $chunk;
$base = substr($base,strlen($chunk));
$a->set_curl_content_type($curl_info['content_type']);
$a->set_curl_headers($header);
- if ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
+ if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
$new_location_info = @parse_url($curl_info["redirect_url"]);
$old_location_info = @parse_url($curl_info["url"]);
if (preg_match('/(Location:|URI:)(.*?)\n/i', $header, $matches)) {
$newurl = trim(array_pop($matches));
}
- if (strpos($newurl,'/') === 0)
+ if(strpos($newurl,'/') === 0)
$newurl = $old_location_info["scheme"]."://".$old_location_info["host"].$newurl;
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
$redirects++;
$ret['return_code'] = $rc;
$ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false);
$ret['redirect_url'] = $url;
- if (! $ret['success']) {
+ if(! $ret['success']) {
$ret['error'] = curl_error($ch);
$ret['debug'] = $curl_info;
logger('z_fetch_url: error: ' . $url . ': ' . $ret['error'], LOGGER_DEBUG);
}
$ret['body'] = substr($s,strlen($header));
$ret['header'] = $header;
- if (x($opts,'debug')) {
+ if(x($opts,'debug')) {
$ret['debug'] = $curl_info;
}
@curl_close($ch);
$a = get_app();
$ch = curl_init($url);
- if (($redirects > 8) || (! $ch))
+ if(($redirects > 8) || (! $ch))
return false;
logger("post_url: start ".$url, LOGGER_DATA);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_USERAGENT, $a->get_useragent());
- if (intval($timeout)) {
+ if(intval($timeout)) {
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
}
else {
curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
}
- if (defined('LIGHTTPD')) {
- if (!is_array($headers)) {
+ if(defined('LIGHTTPD')) {
+ if(!is_array($headers)) {
$headers = array('Expect:');
} else {
- if (!in_array('Expect:', $headers)) {
+ if(!in_array('Expect:', $headers)) {
array_push($headers, 'Expect:');
}
}
}
- if ($headers)
+ if($headers)
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$check_cert = get_config('system','verifyssl');
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
$prx = get_config('system','proxy');
- if (strlen($prx)) {
+ if(strlen($prx)) {
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, $prx);
$prxusr = get_config('system','proxyuser');
- if (strlen($prxusr))
+ if(strlen($prxusr))
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $prxusr);
}
// Pull out multiple headers, e.g. proxy and continuation headers
// allow for HTTP/2.x without fixing code
- while (preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/',$base)) {
+ while(preg_match('/^HTTP\/[1-2].+? [1-5][0-9][0-9]/',$base)) {
$chunk = substr($base,0,strpos($base,"\r\n\r\n")+4);
$header .= $chunk;
$base = substr($base,strlen($chunk));
}
- if ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
+ if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
$matches = array();
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
$newurl = trim(array_pop($matches));
- if (strpos($newurl,'/') === 0)
+ if(strpos($newurl,'/') === 0)
$newurl = $old_location_info["scheme"] . "://" . $old_location_info["host"] . $newurl;
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
$redirects++;
$xml_message = ((strlen($message)) ? "\t<message>" . xmlify($message) . "</message>\r\n" : '');
- if ($st)
+ if($st)
logger('xml_status returning non_zero: ' . $st . " message=" . $message);
header( "Content-type: text/xml" );
*/
function http_status_exit($val, $description = array()) {
$err = '';
- if ($val >= 400) {
+ if($val >= 400) {
$err = 'Error';
if (!isset($description["title"]))
$description["title"] = $err." ".$val;
}
- if ($val >= 200 && $val < 300)
+ if($val >= 200 && $val < 300)
$err = 'OK';
logger('http_status_exit ' . $val);
* @return boolean True if it's a valid URL, fals if something wrong with it
*/
function validate_url(&$url) {
- if (get_config('system','disable_url_validation'))
+ if(get_config('system','disable_url_validation'))
return true;
// no naked subdomains (allow localhost for tests)
- if (strpos($url,'.') === false && strpos($url,'/localhost/') === false)
+ if(strpos($url,'.') === false && strpos($url,'/localhost/') === false)
return false;
- if (substr($url,0,4) != 'http')
+ if(substr($url,0,4) != 'http')
$url = 'http://' . $url;
/// @TODO Really supress function outcomes? Why not find them + debug them?
$h = @parse_url($url);
- if ((is_array($h)) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
+ if((is_array($h)) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
return true;
}
*/
function validate_email($addr) {
- if (get_config('system','disable_email_validation'))
+ if(get_config('system','disable_email_validation'))
return true;
- if (! strpos($addr,'@'))
+ if(! strpos($addr,'@'))
return false;
$h = substr($addr,strpos($addr,'@') + 1);
- if (($h) && (dns_get_record($h, DNS_A + DNS_CNAME + DNS_PTR + DNS_MX) || filter_var($h, FILTER_VALIDATE_IP) )) {
+ if(($h) && (dns_get_record($h, DNS_A + DNS_CNAME + DNS_PTR + DNS_MX) || filter_var($h, FILTER_VALIDATE_IP) )) {
return true;
}
return false;
$h = @parse_url($url);
- if (! $h) {
+ if(! $h) {
return false;
}
$str_allowed = get_config('system','allowed_sites');
- if (! $str_allowed)
+ if(! $str_allowed)
return true;
$found = false;
// always allow our own site
- if ($host == strtolower($_SERVER['SERVER_NAME']))
+ if($host == strtolower($_SERVER['SERVER_NAME']))
return true;
$fnmatch = function_exists('fnmatch');
$allowed = explode(',',$str_allowed);
- if (count($allowed)) {
- foreach ($allowed as $a) {
+ if(count($allowed)) {
+ foreach($allowed as $a) {
$pat = strtolower(trim($a));
- if (($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) {
+ if(($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) {
$found = true;
break;
}
*/
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;
$fnmatch = function_exists('fnmatch');
$allowed = explode(',',$str_allowed);
- if (count($allowed)) {
- foreach ($allowed as $a) {
+ if(count($allowed)) {
+ foreach($allowed as $a) {
$pat = strtolower(trim($a));
- if (($fnmatch && fnmatch($pat,$domain)) || ($pat == $domain)) {
+ if(($fnmatch && fnmatch($pat,$domain)) || ($pat == $domain)) {
$found = true;
break;
}
function parse_xml_string($s,$strict = true) {
/// @todo Move this function to the xml class
- if ($strict) {
- if (! strstr($s,'<?xml'))
+ if($strict) {
+ if(! strstr($s,'<?xml'))
return false;
$s2 = substr($s,strpos($s,'<?xml'));
}
//notice( t("Welcome back ") . $record['username'] . EOL);
$a->user = $record;
- if (strlen($a->user['timezone'])) {
+ if(strlen($a->user['timezone'])) {
date_default_timezone_set($a->user['timezone']);
$a->timezone = $a->user['timezone'];
}
$entries = $xpath->query("//span[$xattr]");
$xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed");
- foreach ($entries as $e) {
+ 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 {
intval($contact_id)
);
- if (! dbm::is_result($contacts)) {
+ if (! count($contacts)) {
return;
}
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'];
- }
+ // $datarray['parent-uri'] = $r[0]['uri'];
}
// Decoding the header
* @param bool $onlyfetch Only fetch the header without updating the contact entries
*
* @return array Array of author related entries for the item
- * @todo Add type-hints
*/
private function fetchauthor($xpath, $context, $importer, &$contact, $onlyfetch) {
- /// @TODO One statment is enough ...
$author = array();
$author["author-link"] = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
$author["author-name"] = $xpath->evaluate('atom:author/atom:name/text()', $context)->item(0)->nodeValue;
$aliaslink = $author["author-link"];
$alternate = $xpath->query("atom:author/atom:link[@rel='alternate']", $context)->item(0)->attributes;
- if (is_object($alternate)) {
- /// @TODO foreach () may only later work on objects that have iterator interface implemented, please check this
- foreach ($alternate AS $attributes) {
- if ($attributes->name == "href") {
+ if (is_object($alternate))
+ foreach($alternate AS $attributes)
+ if ($attributes->name == "href")
$author["author-link"] = $attributes->textContent;
- }
- }
- }
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'",
intval($importer["uid"]), dbesc(normalise_link($author["author-link"])),
dbesc(normalise_link($aliaslink)), dbesc(NETWORK_STATUSNET));
- if (dbm::is_result($r)) {
+ if ($r) {
$contact = $r[0];
$author["contact-id"] = $r[0]["id"];
- } else {
+ } else
$author["contact-id"] = $contact["id"];
- }
$avatarlist = array();
$avatars = $xpath->query("atom:author/atom:link[@rel='avatar']", $context);
- foreach ($avatars AS $avatar) {
+ foreach($avatars AS $avatar) {
$href = "";
$width = 0;
- foreach ($avatar->attributes AS $attributes) {
- if ($attributes->name == "href") {
+ foreach($avatar->attributes AS $attributes) {
+ if ($attributes->name == "href")
$href = $attributes->textContent;
- }
- if ($attributes->name == "width") {
+ if ($attributes->name == "width")
$width = $attributes->textContent;
- }
}
- if (($width > 0) AND ($href != "")) {
+ if (($width > 0) AND ($href != ""))
$avatarlist[$width] = $href;
- }
}
if (count($avatarlist) > 0) {
krsort($avatarlist);
}
$displayname = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
- if ($displayname != "") {
+ if ($displayname != "")
$author["author-name"] = $displayname;
- }
$author["owner-name"] = $author["author-name"];
$author["owner-link"] = $author["author-link"];
$author["owner-avatar"] = $author["author-avatar"];
// Only update the contacts if it is an OStatus contact
- if (dbm::is_result($r) AND !$onlyfetch AND ($contact["network"] == NETWORK_OSTATUS)) {
+ if ($r AND !$onlyfetch AND ($contact["network"] == NETWORK_OSTATUS)) {
// Update contact data
// $contact["poll"] = $value;
$value = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$contact["alias"] = $value;
- }
$value = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$contact["name"] = $value;
- }
$value = $xpath->evaluate('atom:author/poco:preferredUsername/text()', $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$contact["nick"] = $value;
- }
$value = $xpath->evaluate('atom:author/poco:note/text()', $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$contact["about"] = html2bbcode($value);
- }
$value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$contact["location"] = $value;
- }
if (($contact["name"] != $r[0]["name"]) OR ($contact["nick"] != $r[0]["nick"]) OR ($contact["about"] != $r[0]["about"]) OR
($contact["alias"] != $r[0]["alias"]) OR ($contact["location"] != $r[0]["location"])) {
* @param array $importer user record of the importing user
*
* @return array Array of author related entries for the item
- * @todo add type-hints
*/
public static function salmon_author($xml, $importer) {
- if ($xml == "") {
+ if ($xml == "")
return;
- }
$doc = new DOMDocument();
- $doc->loadXML($xml);
+ @$doc->loadXML($xml);
$xpath = new DomXPath($doc);
$xpath->registerNamespace('atom', NAMESPACE_ATOM1);
* @param array $importer user record of the importing user
* @param $contact
* @param array $hub Called by reference, returns the fetched hub data
- * @todo Add missing-type hint + determine type for $contact
*/
public static function import($xml,$importer,&$contact, &$hub) {
/// @todo this function is too long. It has to be split in many parts
logger("Import OStatus message", LOGGER_DEBUG);
- if ($xml == "") {
+ if ($xml == "")
return;
- }
//$tempfile = tempnam(get_temppath(), "import");
//file_put_contents($tempfile, $xml);
$doc = new DOMDocument();
- $doc->loadXML($xml);
+ @$doc->loadXML($xml);
$xpath = new DomXPath($doc);
$xpath->registerNamespace('atom', NAMESPACE_ATOM1);
$gub = "";
$hub_attributes = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0)->attributes;
- if (is_object($hub_attributes)) {
- foreach ($hub_attributes AS $hub_attribute) {
+ if (is_object($hub_attributes))
+ foreach($hub_attributes AS $hub_attribute)
if ($hub_attribute->name == "href") {
$hub = $hub_attribute->textContent;
logger("Found hub ".$hub, LOGGER_DEBUG);
}
- }
- }
- /// @TODO One statement is enough ...
$header = array();
$header["uid"] = $importer["uid"];
$header["network"] = NETWORK_OSTATUS;
// depending on that, the first node is different
$first_child = $doc->firstChild->tagName;
- if ($first_child == "feed") {
+ if ($first_child == "feed")
$entries = $xpath->query('/atom:feed/atom:entry');
- } else {
+ else
$entries = $xpath->query('/atom:entry');
- }
$conversation = "";
$conversationlist = array();
$mention = false;
// fetch the author
- if ($first_child == "feed") {
+ if ($first_child == "feed")
$author = self::fetchauthor($xpath, $doc->firstChild, $importer, $contact, false);
- } else {
+ else
$author = self::fetchauthor($xpath, $entry, $importer, $contact, false);
- }
$value = $xpath->evaluate('atom:author/poco:preferredUsername/text()', $context)->item(0)->nodeValue;
- if ($value != "") {
+ if ($value != "")
$nickname = $value;
- } else {
+ else
$nickname = $author["author-name"];
- }
$item = array_merge($header, $author);
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s'",
intval($importer["uid"]), dbesc($item["uri"]));
- if (dbm::is_result($r)) {
+ if ($r) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
continue;
}
if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) OR ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
$item["body"] = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
- } elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION) {
+ } elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION)
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
- }
$item["object"] = $xml;
$item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
}
// http://activitystrea.ms/schema/1.0/rsvp-yes
- if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE))) {
+ if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE)))
logger("Unhandled verb ".$item["verb"]." ".print_r($item, true));
- }
$item["created"] = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue;
$item["edited"] = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue;
$inreplyto = $xpath->query('thr:in-reply-to', $entry);
if (is_object($inreplyto->item(0))) {
- foreach ($inreplyto->item(0)->attributes AS $attributes) {
- if ($attributes->name == "ref") {
+ foreach($inreplyto->item(0)->attributes AS $attributes) {
+ if ($attributes->name == "ref")
$item["parent-uri"] = $attributes->textContent;
- }
- if ($attributes->name == "href") {
+ if ($attributes->name == "href")
$related = $attributes->textContent;
- }
}
}
$categories = $xpath->query('atom:category', $entry);
if ($categories) {
foreach ($categories AS $category) {
- foreach ($category->attributes AS $attributes)
+ foreach($category->attributes AS $attributes)
if ($attributes->name == "term") {
$term = $attributes->textContent;
- if (strlen($item["tag"]))
+ if(strlen($item["tag"]))
$item["tag"] .= ',';
$item["tag"] .= "#[url=".App::get_baseurl()."/search?tag=".$term."]".$term."[/url]";
}
$length = "0";
$title = "";
foreach ($links AS $link) {
- foreach ($link->attributes AS $attributes) {
+ foreach($link->attributes AS $attributes) {
if ($attributes->name == "href")
$href = $attributes->textContent;
if ($attributes->name == "rel")
if ($attributes->name == "title")
$title = $attributes->textContent;
}
- if (($rel != "") AND ($href != "")) {
+ if (($rel != "") AND ($href != ""))
switch($rel) {
case "alternate":
$item["plink"] = $href;
break;
case "enclosure":
$enclosure = $href;
- if (strlen($item["attach"]))
+ if(strlen($item["attach"]))
$item["attach"] .= ',';
$item["attach"] .= '[attach]href="'.$href.'" length="'.$length.'" type="'.$type.'" title="'.$title.'"[/attach]';
$mention = true;
break;
}
- }
}
}
$notice_info = $xpath->query('statusnet:notice_info', $entry);
if ($notice_info AND ($notice_info->length > 0)) {
- foreach ($notice_info->item(0)->attributes AS $attributes) {
- if ($attributes->name == "source") {
+ foreach($notice_info->item(0)->attributes AS $attributes) {
+ if ($attributes->name == "source")
$item["app"] = strip_tags($attributes->textContent);
- }
- if ($attributes->name == "local_id") {
+ if ($attributes->name == "local_id")
$local_id = $attributes->textContent;
- }
- if ($attributes->name == "repeat_of") {
+ if ($attributes->name == "repeat_of")
$repeat_of = $attributes->textContent;
- }
}
}
if (is_object($activityobjects)) {
$orig_uri = $xpath->query("activity:object/atom:id", $activityobjects)->item(0)->nodeValue;
- if (!isset($orig_uri)) {
+ if (!isset($orig_uri))
$orig_uri = $xpath->query('atom:id/text()', $activityobjects)->item(0)->nodeValue;
- }
$orig_links = $xpath->query("activity:object/atom:link[@rel='alternate']", $activityobjects);
- if ($orig_links AND ($orig_links->length > 0)) {
- foreach ($orig_links->item(0)->attributes AS $attributes) {
- if ($attributes->name == "href") {
+ if ($orig_links AND ($orig_links->length > 0))
+ foreach($orig_links->item(0)->attributes AS $attributes)
+ if ($attributes->name == "href")
$orig_link = $attributes->textContent;
- }
- }
- }
- if (!isset($orig_link)) {
+ if (!isset($orig_link))
$orig_link = $xpath->query("atom:link[@rel='alternate']", $activityobjects)->item(0)->nodeValue;
- }
- if (!isset($orig_link)) {
+ if (!isset($orig_link))
$orig_link = self::convert_href($orig_uri);
- }
$orig_body = $xpath->query('activity:object/atom:content/text()', $activityobjects)->item(0)->nodeValue;
-
- if (!isset($orig_body)) {
+ if (!isset($orig_body))
$orig_body = $xpath->query('atom:content/text()', $activityobjects)->item(0)->nodeValue;
- }
$orig_created = $xpath->query('atom:published/text()', $activityobjects)->item(0)->nodeValue;
$orig_edited = $xpath->query('atom:updated/text()', $activityobjects)->item(0)->nodeValue;
$item["verb"] = $xpath->query('activity:verb/text()', $activityobjects)->item(0)->nodeValue;
$item["object-type"] = $xpath->query('activity:object/activity:object-type/text()', $activityobjects)->item(0)->nodeValue;
-
- if (!isset($item["object-type"])) {
+ if (!isset($item["object-type"]))
$item["object-type"] = $xpath->query('activity:object-type/text()', $activityobjects)->item(0)->nodeValue;
- }
}
}
intval($importer["uid"]), dbesc($item["parent-uri"]));
}
}
-
- if (dbm::is_result($r)) {
+ if ($r) {
$item["type"] = 'remote-comment';
$item["gravity"] = GRAVITY_COMMENT;
}
- } else {
+ } else
$item["parent-uri"] = $item["uri"];
- }
$item_id = self::completion($conversation, $importer["uid"], $item, $self);
public static function convert_href($href) {
$elements = explode(":",$href);
- if ((count($elements) <= 2) OR ($elements[0] != "tag")) {
+ if ((count($elements) <= 2) OR ($elements[0] != "tag"))
return $href;
- }
$server = explode(",", $elements[1]);
$conversation = explode("=", $elements[2]);
- if ((count($elements) == 4) AND ($elements[2] == "post")) {
+ if ((count($elements) == 4) AND ($elements[2] == "post"))
return "http://".$server[0]."/notice/".$elements[3];
- }
- if ((count($conversation) != 2) OR ($conversation[1] =="")) {
+ if ((count($conversation) != 2) OR ($conversation[1] ==""))
return $href;
- }
- if ($elements[3] == "objectType=thread") {
+ if ($elements[3] == "objectType=thread")
return "http://".$server[0]."/conversation/".$conversation[1];
- } else {
+ else
return "http://".$server[0]."/notice/".$conversation[1];
- }
return $href;
}
* @brief Updates the gcontact table with actor data from the conversation
*
* @param object $actor The actor object that contains the contact data
- * @todo Add type-hint
*/
private function conv_fetch_actor($actor) {
// We set the generation to "3" since the data here is not as reliable as the data we get on other occasions
$contact = array("network" => NETWORK_OSTATUS, "generation" => 3);
- if (isset($actor->url)) {
+ if (isset($actor->url))
$contact["url"] = $actor->url;
- }
- if (isset($actor->displayName)) {
+ if (isset($actor->displayName))
$contact["name"] = $actor->displayName;
- }
- if (isset($actor->portablecontacts_net->displayName)) {
+ if (isset($actor->portablecontacts_net->displayName))
$contact["name"] = $actor->portablecontacts_net->displayName;
- }
- if (isset($actor->portablecontacts_net->preferredUsername)) {
+ if (isset($actor->portablecontacts_net->preferredUsername))
$contact["nick"] = $actor->portablecontacts_net->preferredUsername;
- }
- if (isset($actor->id)) {
+ if (isset($actor->id))
$contact["alias"] = $actor->id;
- }
- if (isset($actor->summary)) {
+ if (isset($actor->summary))
$contact["about"] = $actor->summary;
- }
- if (isset($actor->portablecontacts_net->note)) {
+ if (isset($actor->portablecontacts_net->note))
$contact["about"] = $actor->portablecontacts_net->note;
- }
- if (isset($actor->portablecontacts_net->addresses->formatted)) {
+ if (isset($actor->portablecontacts_net->addresses->formatted))
$contact["location"] = $actor->portablecontacts_net->addresses->formatted;
- }
- if (isset($actor->image->url)) {
+ if (isset($actor->image->url))
$contact["photo"] = $actor->image->url;
- }
- if (isset($actor->image->width)) {
+ if (isset($actor->image->width))
$avatarwidth = $actor->image->width;
- }
if (is_array($actor->status_net->avatarLinks))
foreach ($actor->status_net->avatarLinks AS $avatar) {
if ($conversation_id != "") {
$elements = explode(":", $conversation_id);
- if ((count($elements) <= 2) OR ($elements[0] != "tag")) {
+ if ((count($elements) <= 2) OR ($elements[0] != "tag"))
return $conversation_id;
- }
}
- if ($self == "") {
+ if ($self == "")
return "";
- }
$json = str_replace(".atom", ".json", $self);
$raw = fetch_url($json);
- if ($raw == "") {
+ if ($raw == "")
return "";
- }
$data = json_decode($raw);
- if (!is_object($data)) {
+ if (!is_object($data))
return "";
- }
$conversation_id = $data->statusnet_conversation_id;
$contact = q("SELECT `id`, `rel`, `network` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",
$uid, normalise_link($actor), NETWORK_STATUSNET);
- if (!dbm::is_result($contact)) {
+ if (!$contact)
$contact = q("SELECT `id`, `rel`, `network` FROM `contact` WHERE `uid` = %d AND `alias` IN ('%s', '%s') AND `network` != '%s'",
$uid, $actor, normalise_link($actor), NETWORK_STATUSNET);
- }
- if (dbm::is_result($contact)) {
+ if ($contact) {
logger("Found contact for url ".$actor, LOGGER_DEBUG);
$details["contact_id"] = $contact[0]["id"];
$details["network"] = $contact[0]["network"];
* @param array $item Data of the item that is to be posted
*
* @return integer The item id of the posted item array
- * @todo Add type-hints
*/
private function completion($conversation_url, $uid, $item = array(), $self = "") {
(SELECT `oid` FROM `term` WHERE `uid` = %d AND `otype` = %d AND `type` = %d AND `url` = '%s'))",
intval($uid), intval(TERM_OBJ_POST), intval(TERM_CONVERSATION), dbesc($conversation_url));
*/
- if (dbm::is_result($parents)) {
+ if ($parents)
$parent = $parents[0];
- } elseif (count($item) > 0) {
+ elseif (count($item) > 0) {
$parent = $item;
$parent["type"] = "remote";
$parent["verb"] = ACTIVITY_POST;
} else {
// Preset the parent
$r = q("SELECT `id` FROM `contact` WHERE `self` AND `uid`=%d", $uid);
- if (!dbm::is_result($r)) {
+ if (!$r)
return(-2);
- }
- /// @TODO one statement is enough ...
$parent = array();
$parent["id"] = 0;
$parent["parent"] = 0;
} elseif (!$conv_arr["success"] AND (substr($conv, 0, 8) == "https://")) {
$conv = str_replace("https://", "http://", $conv);
$conv_as = fetch_url($conv."?page=".$pageno);
- } else {
+ } else
$conv_as = $conv_arr["body"];
- }
$conv_as = str_replace(',"statusnet:notice_info":', ',"statusnet_notice_info":', $conv_as);
$conv_as = json_decode($conv_as);
$no_of_items = sizeof($items);
- if (is_array($conv_as->items)) {
- foreach ($conv_as->items AS $single_item) {
+ if (@is_array($conv_as->items))
+ foreach ($conv_as->items AS $single_item)
$items[$single_item->id] = $single_item;
- }
- }
- if ($no_of_items == sizeof($items)) {
+ if ($no_of_items == sizeof($items))
break;
- }
$pageno++;
}
return($item_stored);
- } else {
+ } else
return(-3);
- }
}
$items = array_reverse($items);
$r = q("SELECT `nurl` FROM `contact` WHERE `uid` = %d AND `self`", intval($uid));
-
- if (!dbm::is_result($r)) {
- logger("Failed query, uid=" . intval($uid) ." in " . __FUNCTION__);
- killme();
- }
-
$importer = $r[0];
$new_parent = true;
$mention = false;
- if (isset($single_conv->object->id)) {
+ if (isset($single_conv->object->id))
$single_conv->id = $single_conv->object->id;
- }
$plink = self::convert_href($single_conv->id);
- if (isset($single_conv->object->url)) {
+ if (isset($single_conv->object->url))
$plink = self::convert_href($single_conv->object->url);
- }
- if (!isset($single_conv->id)) {
+ if (@!$single_conv->id)
continue;
- }
logger("Got id ".$single_conv->id, LOGGER_DEBUG);
(SELECT `parent` FROM `item`
WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s','%s')) LIMIT 1",
intval($uid), dbesc($first_id), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN));
- if (dbm::is_result($new_parents)) {
+ if ($new_parents) {
if ($new_parents[0]["parent"] == $parent["parent"]) {
// Option 2: This post is already present inside our thread - but not as thread starter
logger("Option 2: uri present in our thread: ".$first_id, LOGGER_DEBUG);
if (isset($single_conv->context->inReplyTo->id)) {
$parent_exists = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s','%s') LIMIT 1",
intval($uid), dbesc($single_conv->context->inReplyTo->id), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN));
- if (dbm::is_result($parent_exists)) {
+ if ($parent_exists)
$parent_uri = $single_conv->context->inReplyTo->id;
- }
}
// This is the current way
if (isset($single_conv->object->inReplyTo->id)) {
$parent_exists = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s','%s') LIMIT 1",
intval($uid), dbesc($single_conv->object->inReplyTo->id), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN));
- if (dbm::is_result($parent_exists)) {
+ if ($parent_exists)
$parent_uri = $single_conv->object->inReplyTo->id;
- }
}
$message_exists = q("SELECT `id`, `parent`, `uri` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s','%s') LIMIT 1",
continue;
}
- if (is_array($single_conv->to)) {
- foreach ($single_conv->to AS $to) {
- if ($importer["nurl"] == normalise_link($to->id)) {
+ if (is_array($single_conv->to))
+ foreach($single_conv->to AS $to)
+ if ($importer["nurl"] == normalise_link($to->id))
$mention = true;
- }
- }
- }
$actor = $single_conv->actor->id;
- if (isset($single_conv->actor->url)) {
+ if (isset($single_conv->actor->url))
$actor = $single_conv->actor->url;
- }
$details = self::get_actor_details($actor, $uid, $parent["contact-id"]);
continue;
}
- /// @TODO One statment is okay (until if () )
$arr = array();
$arr["network"] = $details["network"];
$arr["uri"] = $single_conv->id;
$arr["created"] = $single_conv->published;
$arr["edited"] = $single_conv->published;
$arr["owner-name"] = $single_conv->actor->displayName;
-
- if ($arr["owner-name"] == '') {
+ if ($arr["owner-name"] == '')
$arr["owner-name"] = $single_conv->actor->contact->displayName;
- }
- if ($arr["owner-name"] == '') {
+ if ($arr["owner-name"] == '')
$arr["owner-name"] = $single_conv->actor->portablecontacts_net->displayName;
- }
$arr["owner-link"] = $actor;
$arr["owner-avatar"] = $single_conv->actor->image->url;
$arr["author-avatar"] = $single_conv->actor->image->url;
$arr["body"] = add_page_info_to_body(html2bbcode($single_conv->content));
- if (isset($single_conv->status_net->notice_info->source)) {
+ if (isset($single_conv->status_net->notice_info->source))
$arr["app"] = strip_tags($single_conv->status_net->notice_info->source);
- } elseif (isset($single_conv->statusnet->notice_info->source)) {
+ elseif (isset($single_conv->statusnet->notice_info->source))
$arr["app"] = strip_tags($single_conv->statusnet->notice_info->source);
- } elseif (isset($single_conv->statusnet_notice_info->source)) {
+ elseif (isset($single_conv->statusnet_notice_info->source))
$arr["app"] = strip_tags($single_conv->statusnet_notice_info->source);
- } elseif (isset($single_conv->provider->displayName)) {
+ elseif (isset($single_conv->provider->displayName))
$arr["app"] = $single_conv->provider->displayName;
- } else {
+ else
$arr["app"] = "OStatus";
- }
+
$arr["object"] = json_encode($single_conv);
$arr["verb"] = $parent["verb"];
// Is it a reshared item?
if (isset($single_conv->verb) AND ($single_conv->verb == "share") AND isset($single_conv->object)) {
- if (is_array($single_conv->object)) {
+ if (is_array($single_conv->object))
$single_conv->object = $single_conv->object[0];
- }
logger("Found reshared item ".$single_conv->object->id);
// $single_conv->object->context->conversation;
- if (isset($single_conv->object->object->id)) {
+ if (isset($single_conv->object->object->id))
$arr["uri"] = $single_conv->object->object->id;
- } else {
+ else
$arr["uri"] = $single_conv->object->id;
- }
- if (isset($single_conv->object->object->url)) {
+ if (isset($single_conv->object->object->url))
$plink = self::convert_href($single_conv->object->object->url);
- } else {
+ else
$plink = self::convert_href($single_conv->object->url);
- }
- if (isset($single_conv->object->object->content)) {
+ if (isset($single_conv->object->object->content))
$arr["body"] = add_page_info_to_body(html2bbcode($single_conv->object->object->content));
- } else {
+ else
$arr["body"] = add_page_info_to_body(html2bbcode($single_conv->object->content));
- }
$arr["plink"] = $plink;
$arr["edited"] = $single_conv->object->published;
$arr["author-name"] = $single_conv->object->actor->displayName;
- if ($arr["owner-name"] == '') {
+ if ($arr["owner-name"] == '')
$arr["author-name"] = $single_conv->object->actor->contact->displayName;
- }
$arr["author-link"] = $single_conv->object->actor->url;
$arr["author-avatar"] = $single_conv->object->actor->image->url;
$arr["coord"] = trim($single_conv->object->location->lat." ".$single_conv->object->location->lon);
}
- if ($arr["location"] == "") {
+ if ($arr["location"] == "")
unset($arr["location"]);
- }
- if ($arr["coord"] == "") {
+ if ($arr["coord"] == "")
unset($arr["coord"]);
- }
// Copy fields from given item array
if (isset($item["uri"]) AND (($item["uri"] == $arr["uri"]) OR ($item["uri"] == $single_conv->id))) {
$copy_fields = array("owner-name", "owner-link", "owner-avatar", "author-name", "author-link", "author-avatar",
"gravity", "body", "object-type", "object", "verb", "created", "edited", "coord", "tag",
"title", "attach", "app", "type", "location", "contact-id", "uri");
- foreach ($copy_fields AS $field) {
- if (isset($item[$field])) {
+ foreach ($copy_fields AS $field)
+ if (isset($item[$field]))
$arr[$field] = $item[$field];
- }
- }
}
logger('setting new parent to id '.$newitem);
$new_parents = q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($uid), intval($newitem));
- if (dbm::is_result($new_parents)) {
+ if ($new_parents)
$parent = $new_parents[0];
- }
}
}
$conversation_url = self::convert_href($conversation_url);
$messages = q("SELECT `uid`, `parent`, `created`, `received`, `guid` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
-
- if (!dbm::is_result($messages)) {
+ if (!$messages)
return;
- }
-
$message = $messages[0];
// Store conversation url if not done before
$conversation = q("SELECT `url` FROM `term` WHERE `uid` = %d AND `oid` = %d AND `otype` = %d AND `type` = %d",
intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_CONVERSATION));
- if (!dbm::is_result($conversation)) {
+ if (!$conversation) {
$r = q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`, `url`, `created`, `received`, `guid`) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s')",
intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_CONVERSATION),
dbesc($message["created"]), dbesc($conversation_url), dbesc($message["created"]), dbesc($message["received"]), dbesc($message["guid"]));
* @param array $item The item array of thw post
*
* @return string The guid if the post is a reshare
- * @todo Add type-hints
*/
private function get_reshared_guid($item) {
$body = trim($item["body"]);
// Skip if it isn't a pure repeated messages
// Does it start with a share?
- if (strpos($body, "[share") > 0) {
+ if (strpos($body, "[share") > 0)
return("");
- }
// Does it end with a share?
- if (strlen($body) > (strrpos($body, "[/share]") + 8)) {
+ if (strlen($body) > (strrpos($body, "[/share]") + 8))
return("");
- }
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
// Skip if there is no shared message in there
- if ($body == $attributes) {
+ if ($body == $attributes)
return(false);
- }
$guid = "";
preg_match("/guid='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "") {
+ if ($matches[1] != "")
$guid = $matches[1];
- }
preg_match('/guid="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "") {
+ if ($matches[1] != "")
$guid = $matches[1];
- }
return $guid;
}
$siteinfo = get_attached_data($body);
if (($siteinfo["type"] == "photo")) {
- if (isset($siteinfo["preview"])) {
+ if (isset($siteinfo["preview"]))
$preview = $siteinfo["preview"];
- } else {
+ else
$preview = $siteinfo["image"];
- }
// Is it a remote picture? Then make a smaller preview here
$preview = proxy_url($preview, false, PROXY_SIZE_SMALL);
$preview = str_replace(array("-0.jpg", "-0.png"), array("-2.jpg", "-2.png"), $preview);
$preview = str_replace(array("-1.jpg", "-1.png"), array("-2.jpg", "-2.png"), $preview);
- if (isset($siteinfo["url"])) {
+ if (isset($siteinfo["url"]))
$url = $siteinfo["url"];
- } else {
+ else
$url = $siteinfo["image"];
- }
$body = trim($siteinfo["text"])." [url]".$url."[/url]\n[img]".$preview."[/img]";
}
* @param array $owner Contact data of the poster
*
* @return object header root element
- * @todo Add type-hints
*/
private function add_header($doc, $owner) {
*
* @param object $doc XML document
* @param object $root XML root element where the hub links are added
- * @todo Add type-hints
*/
public static function hublinks($doc, $root) {
$hub = get_config('system','huburl');
$hubxml = '';
- if (strlen($hub)) {
+ if(strlen($hub)) {
$hubs = explode(',', $hub);
- if (count($hubs)) {
- foreach ($hubs as $h) {
+ if(count($hubs)) {
+ foreach($hubs as $h) {
$h = trim($h);
- if (! strlen($h)) {
+ if(! strlen($h))
continue;
- }
- if ($h === '[internal]') {
+ if ($h === '[internal]')
$h = App::get_baseurl() . '/pubsubhubbub';
- }
xml::add_element($doc, $root, "link", "", array("href" => $h, "rel" => "hub"));
}
}
* @param object $doc XML document
* @param object $root XML root element where the hub links are added
* @param array $item Data of the item that is to be posted
- * @todo Add type-hints
*/
private function get_attachment($doc, $root, $item) {
$o = "";
$arr = explode('[/attach],',$item['attach']);
- if (count($arr)) {
- foreach ($arr as $r) {
+ if(count($arr)) {
+ foreach($arr as $r) {
$matches = false;
$cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|',$r,$matches);
- if ($cnt) {
+ if($cnt) {
$attributes = array("rel" => "enclosure",
"href" => $matches[1],
"type" => $matches[3]);
- if (intval($matches[2])) {
+ if(intval($matches[2]))
$attributes["length"] = intval($matches[2]);
- }
- if (trim($matches[4]) != "") {
+ if(trim($matches[4]) != "")
$attributes["title"] = trim($matches[4]);
- }
xml::add_element($doc, $root, "link", "", $attributes);
}
* @param array $owner Contact data of the poster
*
* @return object author element
- * @todo Add type-hints
*/
private function add_author($doc, $owner) {
- $profile = null;
$r = q("SELECT `homepage` FROM `profile` WHERE `uid` = %d AND `is-default` LIMIT 1", intval($owner["uid"]));
- if (dbm::is_result($r)) {
+ if ($r)
$profile = $r[0];
- }
$author = $doc->createElement("author");
xml::add_element($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
* @param array $item Data of the item that is to be posted
*
* @return string activity
- * @todo Add type-hints
*/
function construct_verb($item) {
- if ($item['verb']) {
+ if ($item['verb'])
return $item['verb'];
- }
return ACTIVITY_POST;
}
* @param array $item Data of the item that is to be posted
*
* @return string Object type
- * @todo Add type-hints
*/
function construct_objecttype($item) {
- if (in_array($item['object-type'], array(ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT))) {
+ if (in_array($item['object-type'], array(ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT)))
return $item['object-type'];
- };
return ACTIVITY_OBJ_NOTE;
}
* @param array $contact Array of the contact that is added
*
* @return object Source element
- * @todo Add type-hints
*/
private function source_entry($doc, $contact) {
$source = $doc->createElement("source");
* @param array $owner Contact data of the poster
*
* @return array Contact array
- * @todo Add array type-hint for $owner
*/
private function contact_entry($url, $owner) {
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` IN (0, %d) ORDER BY `uid` DESC LIMIT 1",
dbesc(normalise_link($url)), intval($owner["uid"]));
- if (dbm::is_result($r)) {
+ if ($r) {
$contact = $r[0];
$contact["uid"] = -1;
- } else {
+ }
+
+ if (!$r) {
$r = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($url)));
- if (dbm::is_result($r)) {
+ if ($r) {
$contact = $r[0];
$contact["uid"] = -1;
$contact["success_update"] = $contact["updated"];
}
}
- if (!dbm::is_result($r)) {
- $contact = $owner;
- }
+ if (!$r)
+ $contact = owner;
if (!isset($contact["poll"])) {
$data = probe_url($url);
$contact["poll"] = $data["poll"];
- if (!$contact["alias"]) {
+ if (!$contact["alias"])
$contact["alias"] = $data["alias"];
- }
}
- if (!isset($contact["alias"])) {
+ if (!isset($contact["alias"]))
$contact["alias"] = $contact["url"];
- }
return $contact;
}
* @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
* @return object Entry element
- * @todo Add type-hints
*/
private function reshare_entry($doc, $item, $owner, $repeated_guid, $toplevel) {
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' AND NOT `private` AND `network` IN ('%s', '%s', '%s') LIMIT 1",
intval($owner["uid"]), dbesc($repeated_guid),
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));
-
- if (!dbm::is_result($r)) {
+ if ($r)
+ $repeated_item = $r[0];
+ else
return false;
- }
-
- $repeated_item = $r[0];
$contact = self::contact_entry($repeated_item['author-link'], $owner);
* @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
* @return object Entry element with "like"
- * @todo Add type-hints
*/
private function like_entry($doc, $item, $owner, $toplevel) {
* @param array $contact Contact data of the target
*
* @return object author element
- * @todo Add type-hints
*/
private function add_person_object($doc, $owner, $contact) {
* @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
* @return object Entry element
- * @todo Add type-hints
*/
private function follow_entry($doc, $item, $owner, $toplevel) {
* @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
* @return object Entry element
- * @todo Add type-hints
*/
private function note_entry($doc, $item, $owner, $toplevel) {
* @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
* @return string The title for the element
- * @todo Add type-hints
*/
private function entry_header($doc, &$entry, $owner, $toplevel) {
/// @todo Check if this title stuff is really needed (I guess not)
* @param string $title Title for the post
* @param string $verb The activity verb
* @param bool $complete Add the "status_net" element?
- * @todo Add type-hints
*/
private function entry_content($doc, $entry, $item, $owner, $title, $verb = "", $complete = true) {
- if ($verb == "") {
+ if ($verb == "")
$verb = self::construct_verb($item);
- }
xml::add_element($doc, $entry, "id", $item["uri"]);
xml::add_element($doc, $entry, "title", $title);
$body = self::format_picture_post($item['body']);
- if ($item['title'] != "") {
+ if ($item['title'] != "")
$body = "[b]".$item['title']."[/b]\n\n".$body;
- }
$body = bbcode($body, false, false, 7);
* @param array $item Data of the item that is to be posted
* @param array $owner Contact data of the poster
* @param $complete
- * @todo Add type-hints
*/
private function entry_footer($doc, $entry, $item, $owner, $complete = true) {
$thrparent = q("SELECT `guid`, `author-link`, `owner-link` FROM `item` WHERE `uid` = %d AND `uri` = '%s'",
intval($owner["uid"]),
dbesc($parent_item));
- if (dbm::is_result($thrparent)) {
+ if ($thrparent) {
$mentioned[$thrparent[0]["author-link"]] = $thrparent[0]["author-link"];
$mentioned[$thrparent[0]["owner-link"]] = $thrparent[0]["owner-link"];
}
$tags = item_getfeedtags($item);
- if (count($tags)) {
- foreach ($tags as $t) {
- if ($t[0] == "@") {
+ if(count($tags))
+ foreach($tags as $t)
+ if ($t[0] == "@")
$mentioned[$t[1]] = $t[1];
- }
- }
- }
// Make sure that mentions are accepted (GNU Social has problems with mixing HTTP and HTTPS)
$newmentions = array();
$r = q("SELECT `forum`, `prv` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s'",
intval($owner["uid"]),
dbesc(normalise_link($mention)));
- if ($r[0]["forum"] OR $r[0]["prv"]) {
+ if ($r[0]["forum"] OR $r[0]["prv"])
xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
"href" => $mention));
- } else {
+ else
xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_PERSON,
"href" => $mention));
- }
}
if (!$item["private"]) {
"href" => "http://activityschema.org/collection/public"));
}
- if (count($tags)) {
- foreach ($tags as $t) {
- if ($t[0] != "@") {
+ if(count($tags))
+ foreach($tags as $t)
+ if ($t[0] != "@")
xml::add_element($doc, $entry, "category", "", array("term" => $t[2]));
- }
- }
- }
self::get_attachment($doc, $entry, $item);
$owner = $r[0];
- if (!strlen($last_update))
+ if(!strlen($last_update))
$last_update = 'now -30 days';
$check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
require_once("include/dba.php");
-if (! function_exists('get_browser_language')) {
+if(! function_exists('get_browser_language')) {
/**
* @brief get the prefered language from the HTTP_ACCEPT_LANGUAGE header
*/
// check if we have translations for the preferred languages and pick the 1st that has
for ($i=0; $i<count($lang_list); $i++) {
$lang = $lang_list[$i];
- if (file_exists("view/lang/$lang") && is_dir("view/lang/$lang")) {
+ if(file_exists("view/lang/$lang") && is_dir("view/lang/$lang")) {
$preferred = $lang;
break;
}
$a->langsave = $lang;
- if ($language === $lang)
+ if($language === $lang)
return;
- if (isset($a->strings) && count($a->strings)) {
+ if(isset($a->strings) && count($a->strings)) {
$a->stringsave = $a->strings;
}
$a->strings = array();
function pop_lang() {
global $lang, $a;
- if ($lang === $a->langsave)
+ if($lang === $a->langsave)
return;
- if (isset($a->stringsave))
+ if(isset($a->stringsave))
$a->strings = $a->stringsave;
else
$a->strings = array();
// l
-if (! function_exists('load_translation_table')) {
+if(! function_exists('load_translation_table')) {
/**
* load string translation table for alternate language
*
// load enabled plugins strings
$plugins = q("SELECT name FROM addon WHERE installed=1;");
if ($plugins!==false) {
- foreach ($plugins as $p) {
+ foreach($plugins as $p) {
$name = $p['name'];
- if (file_exists("addon/$name/lang/$lang/strings.php")) {
+ if(file_exists("addon/$name/lang/$lang/strings.php")) {
include("addon/$name/lang/$lang/strings.php");
}
}
}
- if (file_exists("view/lang/$lang/strings.php")) {
+ if(file_exists("view/lang/$lang/strings.php")) {
include("view/lang/$lang/strings.php");
}
// translate string if translation exists
-if (! function_exists('t')) {
+if(! function_exists('t')) {
function t($s) {
$a = get_app();
- if (x($a->strings,$s)) {
+ if(x($a->strings,$s)) {
$t = $a->strings[$s];
return is_array($t)?$t[0]:$t;
}
return $s;
}}
-if (! function_exists('tt')){
+if(! function_exists('tt')){
function tt($singular, $plural, $count){
global $lang;
$a = get_app();
- if (x($a->strings,$singular)) {
+ if(x($a->strings,$singular)) {
$t = $a->strings[$singular];
$f = 'string_plural_select_' . str_replace('-','_',$lang);
- if (! function_exists($f))
+ if(! function_exists($f))
$f = 'string_plural_select_default';
$k = $f($count);
return is_array($t)?$t[$k]:$t;
// provide a fallback which will not collide with
// a function defined in any language file
-if (! function_exists('string_plural_select_default')) {
+if(! function_exists('string_plural_select_default')) {
function string_plural_select_default($n) {
return ($n != 1);
}}
$strings_file_paths[] = 'view/lang/en/strings.php';
}
asort($strings_file_paths);
- foreach ($strings_file_paths as $strings_file_path) {
+ foreach($strings_file_paths as $strings_file_path) {
$path_array = explode('/', $strings_file_path);
$langs[$path_array[2]] = $path_array[2];
}
);
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
- if (function_exists($plugin . '_uninstall')) {
+ if(function_exists($plugin . '_uninstall')) {
$func = $plugin . '_uninstall';
$func();
}
function install_plugin($plugin) {
// silently fail if plugin was removed
- if (! file_exists('addon/' . $plugin . '/' . $plugin . '.php'))
+ if(! file_exists('addon/' . $plugin . '/' . $plugin . '.php'))
return false;
logger("Addons: installing " . $plugin);
$t = @filemtime('addon/' . $plugin . '/' . $plugin . '.php');
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
- if (function_exists($plugin . '_install')) {
+ if(function_exists($plugin . '_install')) {
$func = $plugin . '_install';
$func();
// once most site tables have been updated.
// This way the system won't fall over dead during the update.
- if (file_exists('addon/' . $plugin . '/.hidden')) {
+ if(file_exists('addon/' . $plugin . '/.hidden')) {
q("UPDATE `addon` SET `hidden` = 1 WHERE `name` = '%s'",
dbesc($plugin)
);
// reload all updated plugins
-if (! function_exists('reload_plugins')) {
+if(! function_exists('reload_plugins')) {
function reload_plugins() {
$plugins = get_config('system','addon');
- if (strlen($plugins)) {
+ if(strlen($plugins)) {
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
if (dbm::is_result($r))
$parr = explode(',',$plugins);
- if (count($parr)) {
- foreach ($parr as $pl) {
+ if(count($parr)) {
+ foreach($parr as $pl) {
$pl = trim($pl);
$fname = 'addon/' . $pl . '/' . $pl . '.php';
- if (file_exists($fname)) {
+ if(file_exists($fname)) {
$t = @filemtime($fname);
- foreach ($installed as $i) {
- if (($i['name'] == $pl) && ($i['timestamp'] != $t)) {
+ foreach($installed as $i) {
+ if(($i['name'] == $pl) && ($i['timestamp'] != $t)) {
logger('Reloading plugin: ' . $i['name']);
@include_once($fname);
- if (function_exists($pl . '_uninstall')) {
+ if(function_exists($pl . '_uninstall')) {
$func = $pl . '_uninstall';
$func();
}
- if (function_exists($pl . '_install')) {
+ if(function_exists($pl . '_install')) {
$func = $pl . '_install';
$func();
}
* @param int $priority A priority (defaults to 0)
* @return mixed|bool
*/
-if (! function_exists('register_hook')) {
+if(! function_exists('register_hook')) {
function register_hook($hook,$file,$function,$priority=0) {
$r = q("SELECT * FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1",
* @param string $function the name of the function that the hook called
* @return array
*/
-if (! function_exists('unregister_hook')) {
+if(! function_exists('unregister_hook')) {
function unregister_hook($hook,$file,$function) {
$r = q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s'",
}}
-if (! function_exists('load_hooks')) {
+if(! function_exists('load_hooks')) {
function load_hooks() {
$a = get_app();
$a->hooks = array();
if (dbm::is_result($r)) {
foreach ($r as $rr) {
- if (! array_key_exists($rr['hook'],$a->hooks))
+ if(! array_key_exists($rr['hook'],$a->hooks))
$a->hooks[$rr['hook']] = array();
$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
}
//check if an app_menu hook exist for plugin $name.
//Return true if the plugin is an app
-if (! function_exists('plugin_is_app')) {
+if(! function_exists('plugin_is_app')) {
function plugin_is_app($name) {
$a = get_app();
- if (is_array($a->hooks) && (array_key_exists('app_menu',$a->hooks))) {
- foreach ($a->hooks['app_menu'] as $hook) {
- if ($hook[0] == 'addon/'.$name.'/'.$name.'.php')
+ if(is_array($a->hooks) && (array_key_exists('app_menu',$a->hooks))) {
+ foreach($a->hooks['app_menu'] as $hook) {
+ if($hook[0] == 'addon/'.$name.'/'.$name.'.php')
return true;
}
}
if ($r){
$ll = explode("\n", $m[0]);
- foreach ( $ll as $l ) {
+ foreach( $ll as $l ) {
$l = trim($l,"\t\n\r */");
if ($l!=""){
list($k,$v) = array_map("trim", explode(":",$l,2));
'unsupported' => false
);
- if (file_exists("view/theme/$theme/experimental"))
+ if(file_exists("view/theme/$theme/experimental"))
$info['experimental'] = true;
- if (file_exists("view/theme/$theme/unsupported"))
+ if(file_exists("view/theme/$theme/unsupported"))
$info['unsupported'] = true;
if (!is_file("view/theme/$theme/theme.php")) return $info;
if ($r){
$ll = explode("\n", $m[0]);
- foreach ( $ll as $l ) {
+ foreach( $ll as $l ) {
$l = trim($l,"\t\n\r */");
if ($l!=""){
list($k,$v) = array_map("trim", explode(":",$l,2));
*/
function get_theme_screenshot($theme) {
$exts = array('.png','.jpg');
- foreach ($exts as $ext) {
+ foreach($exts as $ext) {
if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
return(App::get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
}
$service_class = $r[0]['service_class'];
}
}
- if (! x($service_class))
+ if(! x($service_class))
return false; // everything is allowed
$arr = get_config('service_class',$service_class);
- if (! is_array($arr) || (! count($arr)))
+ if(! is_array($arr) || (! count($arr)))
return false;
return((array_key_exists($property,$arr)) ? $arr[$property] : false);
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;
}
*/
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);
"{$root}view/theme/$parent/$ext/$file",
"{$root}view/$ext/$file",
);
- foreach ($paths as $p) {
+ foreach($paths as $p) {
// strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php)
- if (strpos($p,'NOPATH') !== false) {
+ if(strpos($p,'NOPATH') !== false)
continue;
- } elseif (file_exists($p)) {
+ if(file_exists($p))
return $p;
- }
}
return '';
}
function poller_run($argv, $argc){
global $a, $db;
- if (is_null($a)) {
+ if(is_null($a)) {
$a = new App;
}
- if (is_null($db)) {
+ if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
return;
}
- if (($argc <= 1) OR ($argv[1] != "no_cron")) {
+ if(($argc <= 1) OR ($argv[1] != "no_cron")) {
poller_run_cron();
}
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"]));
// 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);
// Decrease the number of workers at higher load
$load = current_load();
- if ($load) {
+ if($load) {
$maxsysload = intval(Config::get("system", "maxloadavg", 50));
$maxworkers = $queues;
}
// Set the "gcontact-id" in the item table and add a new gcontact entry if needed
- foreach ($item_arr AS $item) {
+ foreach($item_arr AS $item) {
$gcontact_id = get_gcontact_id(array("url" => $item['author-link'], "network" => $item['network'],
"photo" => $item['author-avatar'], "name" => $item['author-name']));
q("UPDATE `item` SET `gcontact-id` = %d WHERE `uid` = %d AND `author-link` = '%s' AND `gcontact-id` = 0",
}
// Set the "gcontact-id" in the item table and add a new gcontact entry if needed
- foreach ($item_arr AS $item) {
+ foreach($item_arr AS $item) {
$author_id = get_contact($item["author-link"], 0);
$owner_id = get_contact($item["owner-link"], 0);
call_hooks('gender_selector', $select);
$o .= "<select name=\"gender$suffix\" id=\"gender-select$suffix\" size=\"1\" >";
- foreach ($select as $selection) {
- if ($selection !== 'NOTRANSLATION') {
+ foreach($select as $selection) {
+ if($selection !== 'NOTRANSLATION') {
$selected = (($selection == $current) ? ' selected="selected" ' : '');
$o .= "<option value=\"$selection\" $selected >$selection</option>";
}
call_hooks('sexpref_selector', $select);
$o .= "<select name=\"sexual$suffix\" id=\"sexual-select$suffix\" size=\"1\" >";
- foreach ($select as $selection) {
- if ($selection !== 'NOTRANSLATION') {
+ foreach($select as $selection) {
+ if($selection !== 'NOTRANSLATION') {
$selected = (($selection == $current) ? ' selected="selected" ' : '');
$o .= "<option value=\"$selection\" $selected >$selection</option>";
}
call_hooks('marital_selector', $select);
$o .= "<select name=\"marital\" id=\"marital-select\" size=\"1\" >";
- foreach ($select as $selection) {
- if ($selection !== 'NOTRANSLATION') {
+ foreach($select as $selection) {
+ if($selection !== 'NOTRANSLATION') {
$selected = (($selection == $current) ? ' selected="selected" ' : '');
$o .= "<option value=\"$selection\" $selected >$selection</option>";
}
global $a;
$r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
-
- if (!dbm::is_result($r)) {
+ if (!$r)
return;
- }
-
- $rr = $r[0];
+ else
+ $rr = $r[0];
logger("Generate feed of user ".$rr['nickname']." to ".$rr['callback_url']." - last updated ".$rr['last_update'], LOGGER_DEBUG);
// 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,
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 ",
intval($cid)
);
if (dbm::is_result($r)) {
- if ($batch && ($r[0]['total'] > $batch_queue)) {
+ 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;
}
$start = 0;
- while (($pos = strpos($message, '[quote', $start)) > 0) {
+ while(($pos = strpos($message, '[quote', $start)) > 0) {
$quotes[$pos] = -1;
$start = $pos + 7;
$startquotes++;
$endquotes = 0;
$start = 0;
- while (($pos = strpos($message, '[/quote]', $start)) > 0) {
+ while(($pos = strpos($message, '[/quote]', $start)) > 0) {
$start = $pos + 7;
$endquotes++;
}
$start = 0;
- while (($pos = strpos($message, '[/quote]', $start)) > 0) {
+ while(($pos = strpos($message, '[/quote]', $start)) > 0) {
$quotes[$pos] = 1;
$start = $pos + 7;
}
// prevent looping
- if (x($_REQUEST,'redir') && intval($_REQUEST['redir']))
+ if(x($_REQUEST,'redir') && intval($_REQUEST['redir']))
return;
- if ((! $contact_nick) || ($contact_nick === $a->user['nickname']))
+ if((! $contact_nick) || ($contact_nick === $a->user['nickname']))
return;
- if (local_user()) {
+ if(local_user()) {
// We need to find out if $contact_nick is a user on this hub, and if so, if I
// am a contact of that user. However, that user may have other contacts with the
$baseurl = App::get_baseurl();
$domain_st = strpos($baseurl, "://");
- if ($domain_st === false)
+ if($domain_st === false)
return;
$baseurl = substr($baseurl, $domain_st + 3);
$nurl = normalise_link($baseurl);
$dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
- if ($r[0]['duplex'] && $r[0]['issued-id']) {
+ if($r[0]['duplex'] && $r[0]['issued-id']) {
$orig_id = $r[0]['issued-id'];
$dfrn_id = '1:' . $orig_id;
}
- if ($r[0]['duplex'] && $r[0]['dfrn-id']) {
+ if($r[0]['duplex'] && $r[0]['dfrn-id']) {
$orig_id = $r[0]['dfrn-id'];
$dfrn_id = '0:' . $orig_id;
}
// ensure that we've got a valid ID. There may be some edge cases with forums and non-duplex mode
// that may have triggered some of the "went to {profile/intro} and got an RSS feed" issues
- if (strlen($dfrn_id) < 3)
+ if(strlen($dfrn_id) < 3)
return;
$sec = random_string();
$arr = Probe::lrdd($uri);
- if (is_array($arr)) {
- foreach ($arr as $a) {
- if ($a['@attributes']['rel'] === 'magic-public-key') {
+ if(is_array($arr)) {
+ foreach($arr as $a) {
+ if($a['@attributes']['rel'] === 'magic-public-key') {
$ret[] = $a['@attributes']['href'];
}
}
- } else {
+ }
+ else {
return '';
}
// does contact have a salmon endpoint?
- if (! strlen($url)) {
+ if(! strlen($url))
return;
- }
- if (! $owner['sprvkey']) {
+ if(! $owner['sprvkey']) {
logger(sprintf("user '%s' (%d) does not have a salmon private key. Send failed.",
$owner['username'],$owner['uid']));
return;
// check for success, e.g. 2xx
- if ($return_code > 299) {
+ if($return_code > 299) {
logger('compliant salmon failed. Falling back to status.net hack2');
$return_code = $a->get_curl_code();
- if ($return_code > 299) {
+ if($return_code > 299) {
logger('compliant salmon failed. Falling back to status.net hack3');
}
}
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);
}
$a->user = $user_record;
- if ($interactive) {
- /// @TODO Comparison of strings this way may lead to bugs/incompatiblities
+ if($interactive) {
if ($a->user['login_date'] <= NULL_DATE) {
$_SESSION['return_url'] = 'profile_photo/new';
$a->module = 'profile_photo';
info( t("Welcome ") . $a->user['username'] . EOL);
info( t('Please upload a profile photo.') . EOL);
- } else {
- info( t("Welcome back ") . $a->user['username'] . EOL);
}
+ else
+ info( t("Welcome back ") . $a->user['username'] . EOL);
}
$member_since = strtotime($a->user['register_date']);
-
- if (time() < ($member_since + ( 60 * 60 * 24 * 14))) {
+ if(time() < ($member_since + ( 60 * 60 * 24 * 14)))
$_SESSION['new_member'] = true;
- } else {
+ else
$_SESSION['new_member'] = false;
- }
-
- if (strlen($a->user['timezone'])) {
+ if(strlen($a->user['timezone'])) {
date_default_timezone_set($a->user['timezone']);
$a->timezone = $a->user['timezone'];
}
$master_record = $a->user;
- if ((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
+ if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
$r = q("select * from user where uid = %d limit 1",
intval($_SESSION['submanage'])
);
if (dbm::is_result($r))
$a->identities = array_merge($a->identities,$r);
- if ($login_initial)
+ if($login_initial)
logger('auth_identities: ' . print_r($a->identities,true), LOGGER_DEBUG);
- if ($login_refresh)
+ if($login_refresh)
logger('auth_identities refresh: ' . print_r($a->identities,true), LOGGER_DEBUG);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] .'"');
- if ($login_initial || $login_refresh) {
+ if($login_initial || $login_refresh) {
q("UPDATE `user` SET `login_date` = '%s' WHERE `uid` = %d",
dbesc(datetime_convert()),
* Profile owner - everything is visible
*/
- if (($local_user) && ($local_user == $owner_id)) {
+ if(($local_user) && ($local_user == $owner_id)) {
$sql = '';
}
* done this and passed the groups into this function.
*/
- elseif ($remote_user) {
+ elseif($remote_user) {
- if (! $remote_verified) {
+ if(! $remote_verified) {
$r = q("SELECT id FROM contact WHERE id = %d AND uid = %d AND blocked = 0 LIMIT 1",
intval($remote_user),
intval($owner_id)
$groups = init_groups_visitor($remote_user);
}
}
- if ($remote_verified) {
+ if($remote_verified) {
$gs = '<<>>'; // should be impossible to match
- if (is_array($groups) && count($groups)) {
- foreach ($groups as $g)
+ if(is_array($groups) && count($groups)) {
+ foreach($groups as $g)
$gs .= '|<' . intval($g) . '>';
}
* Profile owner - everything is visible
*/
- if ($local_user && ($local_user == $owner_id)) {
+ if($local_user && ($local_user == $owner_id)) {
$sql = '';
}
* done this and passed the groups into this function.
*/
- elseif ($remote_user) {
+ elseif($remote_user) {
- if (! $remote_verified) {
+ if(! $remote_verified) {
$r = q("SELECT id FROM contact WHERE id = %d AND uid = %d AND blocked = 0 LIMIT 1",
intval($remote_user),
intval($owner_id)
$groups = init_groups_visitor($remote_user);
}
}
- if ($remote_verified) {
+ if($remote_verified) {
$gs = '<<>>'; // should be impossible to match
- if (is_array($groups) && count($groups)) {
- foreach ($groups as $g) {
+ if(is_array($groups) && count($groups)) {
+ foreach($groups as $g)
$gs .= '|<' . intval($g) . '>';
- }
}
$sql = sprintf(
// DFRN contact. They are *not* neccessarily unique across the entire site.
-if (! function_exists('init_groups_visitor')) {
+if(! function_exists('init_groups_visitor')) {
function init_groups_visitor($contact_id) {
$groups = array();
$r = q("SELECT `gid` FROM `group_member`
intval($contact_id)
);
if (dbm::is_result($r)) {
- foreach ($r as $rr)
+ foreach($r as $rr)
$groups[] = $rr['gid'];
}
return $groups;
function poco_load_worker($cid, $uid, $zcid, $url) {
$a = get_app();
- if ($cid) {
- if ((! $url) || (! $uid)) {
+ if($cid) {
+ if((! $url) || (! $uid)) {
$r = q("select `poco`, `uid` from `contact` where `id` = %d limit 1",
intval($cid)
);
$uid = $r[0]['uid'];
}
}
- if (! $uid)
+ if(! $uid)
return;
}
- if (! $url)
+ if(! $url)
return;
$url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation' : '?fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation') ;
logger('poco_load: return code: ' . $a->get_curl_code(), LOGGER_DEBUG);
- if (($a->get_curl_code() > 299) || (! $s))
+ if(($a->get_curl_code() > 299) || (! $s))
return;
$j = json_decode($s);
logger('poco_load: json: ' . print_r($j,true),LOGGER_DATA);
- if (! isset($j->entry))
+ if(! isset($j->entry))
return;
$total = 0;
- foreach ($j->entry as $entry) {
+ foreach($j->entry as $entry) {
$total ++;
$profile_url = '';
}
if (isset($entry->tags)) {
- foreach ($entry->tags as $tag) {
+ foreach($entry->tags as $tag) {
$keywords = implode(", ", $tag);
}
}
$gcid = update_gcontact($gcontact);
- if (!$gcid)
+ if(!$gcid)
return $gcid;
$r = q("SELECT * FROM `glink` WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d LIMIT 1",
}
$lines = explode("\n",$serverret["header"]);
- if (count($lines)) {
- foreach ($lines as $line) {
+ if(count($lines)) {
+ foreach($lines as $line) {
$line = trim($line);
- if (stristr($line,'X-Diaspora-Version:')) {
+ if(stristr($line,'X-Diaspora-Version:')) {
$platform = "Diaspora";
$version = trim(str_replace("X-Diaspora-Version:", "", $line));
$version = trim(str_replace("x-diaspora-version:", "", $version));
$last_contact = datetime_convert();
}
- if (stristr($line,'Server: Mastodon')) {
+ if(stristr($line,'Server: Mastodon')) {
$platform = "Mastodon";
$network = NETWORK_OSTATUS;
// Mastodon doesn't reveal version numbers
function common_friends($uid,$cid,$start = 0,$limit=9999,$shuffle = false) {
- if ($shuffle)
+ if($shuffle)
$sql_extra = " order by rand() ";
else
$sql_extra = " order by `gcontact`.`name` asc ";
function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = false) {
- if ($shuffle)
+ if($shuffle)
$sql_extra = " order by rand() ";
else
$sql_extra = " order by `gcontact`.`name` asc ";
if (dbm::is_result($r)) {
foreach ($r as $rr) {
$base = substr($rr['poco'],0,strrpos($rr['poco'],'/'));
- if (! in_array($base,$done))
+ if(! in_array($base,$done))
poco_load(0,0,0,$base);
}
}
if ($last) {
$next = $last + (24 * 60 * 60);
- if ($next > time())
+ if($next > time())
return;
}
}
}
- /*
- * 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());
}
foreach ($data->entry AS $entry) {
$username = "";
if (isset($entry->urls)) {
- foreach ($entry->urls as $url)
+ foreach($entry->urls as $url)
if ($url->type == 'profile') {
$profile_url = $url->value;
$urlparts = parse_url($profile_url);
$name = $entry->displayName;
if (isset($entry->urls)) {
- foreach ($entry->urls as $url) {
+ foreach($entry->urls as $url) {
if ($url->type == 'profile') {
$profile_url = $url->value;
continue;
$updated = date("Y-m-d H:i:s", strtotime($entry->updated));
}
- if (isset($entry->network)) {
+ if(isset($entry->network)) {
$network = $entry->network;
}
- if (isset($entry->currentLocation)) {
+ if(isset($entry->currentLocation)) {
$location = $entry->currentLocation;
}
- if (isset($entry->aboutMe)) {
+ if(isset($entry->aboutMe)) {
$about = html2bbcode($entry->aboutMe);
}
- if (isset($entry->gender)) {
+ if(isset($entry->gender)) {
$gender = $entry->gender;
}
- if (isset($entry->generation) AND ($entry->generation > 0)) {
+ if(isset($entry->generation) AND ($entry->generation > 0)) {
$generation = ++$entry->generation;
}
- if (isset($entry->contactType) AND ($entry->contactType >= 0)) {
+ if(isset($entry->contactType) AND ($entry->contactType >= 0)) {
$contact_type = $entry->contactType;
}
- if (isset($entry->tags)) {
+ if(isset($entry->tags)) {
foreach ($entry->tags as $tag) {
$keywords = implode(", ", $tag);
}
if (substr(trim($tag), 0, 1) == "#") {
// try to ignore #039 or #1 or anything like that
- if (ctype_digit(substr(trim($tag),1)))
+ if(ctype_digit(substr(trim($tag),1)))
continue;
// try to ignore html hex escapes, e.g. #x2317
- if ((substr(trim($tag),1,1) == 'x' || substr(trim($tag),1,1) == 'X') && ctype_digit(substr(trim($tag),2)))
+ if((substr(trim($tag),1,1) == 'x' || substr(trim($tag),1,1) == 'X') && ctype_digit(substr(trim($tag),2)))
continue;
$type = TERM_HASHTAG;
$term = substr($tag, 1);
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) {
+ if(count($messages)) {
+ foreach ($messages as $message)
create_tags_from_item($message["id"]);
- }
}
}
function update_items() {
global $db;
- $messages = $db->q("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = ''", true);
+ $messages = $db->q("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = ''", true);
- logger("fetched messages: ".count($messages));
- while ($message = $db->qfetch()) {
+ logger("fetched messages: ".count($messages));
+ while ($message = $db->qfetch()) {
if ($message["uid"] == 0) {
$global = true;
intval($global), intval(TERM_OBJ_POST), intval($message["oid"]));
}
- $db->qclose();
+ $db->qclose();
$messages = $db->q("SELECT `guid` FROM `item` WHERE `uid` = 0", true);
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);
* {{ if <$var>==<val|$var> }}...[{{ else }} ...]{{ endif }}
* {{ if <$var>!=<val|$var> }}...[{{ else }} ...]{{ endif }}
*/
- private function _replcb_if ($args) {
+ private function _replcb_if($args) {
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) {
+ } else if (strpos($args[2], "!=") > 0) {
list($a, $b) = array_map("trim", explode("!=", $args[2]));
$a = $this->_get_var($a);
- if ($b[0] == "$") {
+ if ($b[0] == "$")
$b = $this->_get_var($b);
- }
$val = ($a != $b);
} else {
$val = $this->_get_var($args[2]);
* {{ for <$var> as $name }}...{{ endfor }}
* {{ for <$var> as $key=>$name }}...{{ endfor }}
*/
- private function _replcb_for ($args) {
+ private function _replcb_for($args) {
$m = array_map('trim', explode(" as ", $args[2]));
$x = explode("=>", $m[1]);
if (count($x) == 1) {
//$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();
}
$newctx = null;
}
- if ($tplfile[0] == "$") {
+ if ($tplfile[0] == "$")
$tplfile = $this->_get_var($tplfile);
- }
$this->_push_stack();
$r = $this->r;
require_once("mod/proxy.php");
-if (! function_exists('replace_macros')) {
+if(! function_exists('replace_macros')) {
/**
* This is our template processor
*
define('RANDOM_STRING_HEX', 0x00 );
define('RANDOM_STRING_TEXT', 0x01 );
-if (! function_exists('random_string')) {
+if(! function_exists('random_string')) {
function random_string($size = 64,$type = RANDOM_STRING_HEX) {
// generate a bit of entropy and run it through the whirlpool
$s = hash('whirlpool', (string) rand() . uniqid(rand(),true) . (string) rand(),(($type == RANDOM_STRING_TEXT) ? true : false));
return(substr($s,0,$size));
}}
-if (! function_exists('notags')) {
+if(! function_exists('notags')) {
/**
* This is our primary input filter.
*
-if (! function_exists('escape_tags')) {
+if(! function_exists('escape_tags')) {
/**
* use this on "body" or "content" input where angle chars shouldn't be removed,
* and allow them to be safely displayed.
// generate a string that's random, but usually pronounceable.
// used to generate initial passwords
-if (! function_exists('autoname')) {
+if(! function_exists('autoname')) {
/**
* generate a string that's random, but usually pronounceable.
* used to generate initial passwords
*/
function autoname($len) {
- if ($len <= 0)
+ if($len <= 0)
return '';
$vowels = array('a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u');
- if (mt_rand(0,5) == 4)
+ if(mt_rand(0,5) == 4)
$vowels[] = 'y';
$cons = array(
'kh', 'kl','kr','mn','pl','pr','rh','tr','qu','wh');
$start = mt_rand(0,2);
- if ($start == 0)
+ if($start == 0)
$table = $vowels;
else
$table = $cons;
$r = mt_rand(0,count($table) - 1);
$word .= $table[$r];
- if ($table == $vowels)
+ if($table == $vowels)
$table = array_merge($cons,$midcons);
else
$table = $vowels;
$word = substr($word,0,$len);
- foreach ($noend as $noe) {
- if ((strlen($word) > 2) && (substr($word,-2) == $noe)) {
+ foreach($noend as $noe) {
+ if((strlen($word) > 2) && (substr($word,-2) == $noe)) {
$word = substr($word,0,-1);
break;
}
}
- if (substr($word,-1) == 'q')
+ if(substr($word,-1) == 'q')
$word = substr($word,0,-1);
return $word;
}}
// escape text ($str) for XML transport
// returns escaped text.
-if (! function_exists('xmlify')) {
+if(! function_exists('xmlify')) {
/**
* escape text ($str) for XML transport
* @param string $str
/* $buffer = '';
$len = mb_strlen($str);
- for ($x = 0; $x < $len; $x ++) {
+ for($x = 0; $x < $len; $x ++) {
$char = mb_substr($str,$x,1);
switch( $char ) {
return($buffer);
}}
-if (! function_exists('unxmlify')) {
+if(! function_exists('unxmlify')) {
/**
* undo an xmlify
* @param string $s xml escaped text
return $ret;
}}
-if (! function_exists('hex2bin')) {
+if(! function_exists('hex2bin')) {
/**
* convenience wrapper, reverse the operation "bin2hex"
* @param string $s
* @return number
*/
function hex2bin($s) {
- if (! (is_string($s) && strlen($s)))
+ if(! (is_string($s) && strlen($s)))
return '';
- if (! ctype_xdigit($s)) {
+ if(! ctype_xdigit($s)) {
return($s);
}
return $data;
}
-if (! function_exists('paginate')) {
+if(! function_exists('paginate')) {
/**
* Automatic pagination.
*
}}
-if (! function_exists('alt_pager')) {
+if(! function_exists('alt_pager')) {
/**
* Alternative pager
* @param App $a App instance
}}
-if (! function_exists('scroll_loader')) {
+if(! function_exists('scroll_loader')) {
/**
* Loader for infinite scrolling
* @return string html for loader
));
}}
-if (! function_exists('expand_acl')) {
+if(! function_exists('expand_acl')) {
/**
* Turn user/group ACLs stored as angle bracketed text into arrays
*
// e.g. "<1><2><3>" => array(1,2,3);
$ret = array();
- if (strlen($s)) {
+ if(strlen($s)) {
$t = str_replace('<','',$s);
$a = explode('>',$t);
- foreach ($a as $aa) {
- if (intval($aa)) {
+ foreach($a as $aa) {
+ if(intval($aa))
$ret[] = intval($aa);
- }
}
}
return $ret;
}}
-if (! function_exists('sanitise_acl')) {
+if(! function_exists('sanitise_acl')) {
/**
* Wrap ACL elements in angle brackets for storage
* @param string $item
*/
function sanitise_acl(&$item) {
- if (intval($item))
+ if(intval($item))
$item = '<' . intval(notags(trim($item))) . '>';
else
unset($item);
}}
-if (! function_exists('perms2str')) {
+if(! function_exists('perms2str')) {
/**
* Convert an ACL array to a storable string
*
*/
function perms2str($p) {
$ret = '';
- if (is_array($p))
+ if(is_array($p))
$tmp = $p;
else
$tmp = explode(',',$p);
- if (is_array($tmp)) {
+ if(is_array($tmp)) {
array_walk($tmp,'sanitise_acl');
$ret = implode('',$tmp);
}
}}
-if (! function_exists('item_new_uri')) {
+if(! function_exists('item_new_uri')) {
/**
* generate a guaranteed unique (for this domain) item ID for ATOM
* safe from birthday paradox
dbesc($uri));
if (dbm::is_result($r))
$dups = true;
- } while ($dups == true);
+ } while($dups == true);
return $uri;
}}
// Generate a guaranteed unique photo ID.
// safe from birthday paradox
-if (! function_exists('photo_new_resource')) {
+if(! function_exists('photo_new_resource')) {
/**
* Generate a guaranteed unique photo ID.
* safe from birthday paradox
);
if (dbm::is_result($r))
$found = true;
- } while ($found == true);
+ } while($found == true);
return $resource;
}}
-if (! function_exists('load_view_file')) {
+if(! function_exists('load_view_file')) {
/**
* @deprecated
* wrapper to load a view template, checking for alternate
*/
function load_view_file($s) {
global $lang, $a;
- if (! isset($lang))
+ if(! isset($lang))
$lang = 'en';
$b = basename($s);
$d = dirname($s);
- if (file_exists("$d/$lang/$b")) {
+ if(file_exists("$d/$lang/$b")) {
$stamp1 = microtime(true);
$content = file_get_contents("$d/$lang/$b");
$a->save_timestamp($stamp1, "file");
$theme = current_theme();
- if (file_exists("$d/theme/$theme/$b")) {
+ if(file_exists("$d/theme/$theme/$b")) {
$stamp1 = microtime(true);
$content = file_get_contents("$d/theme/$theme/$b");
$a->save_timestamp($stamp1, "file");
return $content;
}}
-if (! function_exists('get_intltext_template')) {
+if(! function_exists('get_intltext_template')) {
/**
* load a view template, checking for alternate
* languages before falling back to the default
$a = get_app();
$engine = '';
- if ($a->theme['template_engine'] === 'smarty3')
+ if($a->theme['template_engine'] === 'smarty3')
$engine = "/smarty3";
- if (! isset($lang))
+ if(! isset($lang))
$lang = 'en';
- if (file_exists("view/lang/$lang$engine/$s")) {
+ if(file_exists("view/lang/$lang$engine/$s")) {
$stamp1 = microtime(true);
$content = file_get_contents("view/lang/$lang$engine/$s");
$a->save_timestamp($stamp1, "file");
return $content;
- } elseif (file_exists("view/lang/en$engine/$s")) {
+ } elseif(file_exists("view/lang/en$engine/$s")) {
$stamp1 = microtime(true);
$content = file_get_contents("view/lang/en$engine/$s");
$a->save_timestamp($stamp1, "file");
}
}}
-if (! function_exists('get_markup_template')) {
+if(! function_exists('get_markup_template')) {
/**
* load template $s
*
return $template;
}}
-if (! function_exists("get_template_file")) {
+if(! function_exists("get_template_file")) {
/**
*
* @param App $a
$theme = current_theme();
// Make sure $root ends with a slash /
- if ($root !== '' && $root[strlen($root)-1] !== '/')
+ if($root !== '' && $root[strlen($root)-1] !== '/')
$root = $root . '/';
- if (file_exists("{$root}view/theme/$theme/$filename"))
+ if(file_exists("{$root}view/theme/$theme/$filename"))
$template_file = "{$root}view/theme/$theme/$filename";
elseif (x($a->theme_info,"extends") && file_exists("{$root}view/theme/{$a->theme_info["extends"]}/$filename"))
$template_file = "{$root}view/theme/{$a->theme_info["extends"]}/$filename";
-if (! function_exists('attribute_contains')) {
+if(! function_exists('attribute_contains')) {
/**
* for html,xml parsing - let's say you've got
* an attribute foobar="class1 class2 class3"
*/
function attribute_contains($attr,$s) {
$a = explode(' ', $attr);
- if (count($a) && in_array($s,$a))
+ if(count($a) && in_array($s,$a))
return true;
return false;
}}
}}
-if (! function_exists('activity_match')) {
+if(! function_exists('activity_match')) {
/**
* Compare activity uri. Knows about activity namespace.
*
* @return boolean
*/
function activity_match($haystack,$needle) {
- if (($haystack === $needle) || ((basename($needle) === $haystack) && strstr($needle,NAMESPACE_ACTIVITY_SCHEMA)))
+ if(($haystack === $needle) || ((basename($needle) === $haystack) && strstr($needle,NAMESPACE_ACTIVITY_SCHEMA)))
return true;
return false;
}}
// and #hash tags.
if (preg_match_all('/([!#@][^\^ \x0D\x0A,;:?]+)([ \x0D\x0A,;:?]|$)/', $string, $matches)) {
- foreach ($matches[1] as $match) {
+ foreach($matches[1] as $match) {
if (strstr($match, ']')) {
// we might be inside a bbcode color tag - leave it alone
continue;
//
-if (! function_exists('qp')) {
+if(! function_exists('qp')) {
/**
* quick and dirty quoted_printable encoding
*
return str_replace ("%","=",rawurlencode($s));
}}
-if (! function_exists('contact_block')) {
+if(! function_exists('contact_block')) {
/**
* Get html for contact block.
*
$a = get_app();
$shown = get_pconfig($a->profile['uid'],'system','display_friend_count');
- if ($shown === false)
+ if($shown === false)
$shown = 24;
- if ($shown == 0)
+ if($shown == 0)
return;
- if ((! is_array($a->profile)) || ($a->profile['hide-friends']))
+ if((! is_array($a->profile)) || ($a->profile['hide-friends']))
return $o;
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
WHERE `uid` = %d AND NOT `self` AND NOT `blocked`
if (dbm::is_result($r)) {
$total = intval($r[0]['total']);
}
- if (! $total) {
+ if(! $total) {
$contacts = t('No contacts');
$micropro = Null;
$sparkle = '';
$redir = false;
- if ($redirect) {
+ if($redirect) {
$a = get_app();
$redirect_url = 'redir/' . $contact['id'];
- if (local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === NETWORK_DFRN)) {
+ if(local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === NETWORK_DFRN)) {
$redir = true;
$url = $redirect_url;
$sparkle = ' sparkle';
}
// If there is some js available we don't need the url
- if (x($contact,'click'))
+ if(x($contact,'click'))
$url = '';
return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),array(
-if (! function_exists('search')) {
+if(! function_exists('search')) {
/**
* search box
*
return replace_macros(get_markup_template('searchbox.tpl'), $values);
}}
-if (! function_exists('valid_email')) {
+if(! function_exists('valid_email')) {
/**
* Check if $x is a valid email string
*
function valid_email($x){
// Removed because Fabio told me so.
- //if (get_config('system','disable_email_validation'))
+ //if(get_config('system','disable_email_validation'))
// return true;
- if (preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x))
+ if(preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x))
return true;
return false;
}}
-if (! function_exists('linkify')) {
+if(! function_exists('linkify')) {
/**
* Replace naked text hyperlink with HTML formatted hyperlink
*
return $arr;
}
-if (! function_exists('day_translate')) {
+if(! function_exists('day_translate')) {
/**
* Translate days and months names
*
}}
-if (! function_exists('normalise_link')) {
+if(! function_exists('normalise_link')) {
/**
* Normalize url
*
-if (! function_exists('link_compare')) {
+if(! function_exists('link_compare')) {
/**
* Compare two URLs to see if they are the same, but ignore
* slight but hopefully insignificant differences such as if one
*
*/
function link_compare($a,$b) {
- if (strcasecmp(normalise_link($a),normalise_link($b)) === 0)
+ if(strcasecmp(normalise_link($a),normalise_link($b)) === 0)
return true;
return false;
}}
// Given an item array, convert the body element from bbcode to html and add smilie icons.
// If attach is true, also add icons for item attachments
-if (! function_exists('prepare_body')) {
+if(! function_exists('prepare_body')) {
/**
* Given an item array, convert the body element from bbcode to html and add smilie icons.
* If attach is true, also add icons for item attachments
$taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`",
intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
- foreach ($taglist as $tag) {
+ foreach($taglist as $tag) {
if ($tag["url"] == "")
$tag["url"] = $searchpath.strtolower($tag["term"]);
call_hooks('prepare_body', $prep_arr);
$s = $prep_arr['html'];
- if (! $attach) {
+ if(! $attach) {
// Replace the blockquotes with quotes that are used in mails
$mailquote = '<blockquote type="cite" class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">';
$s = str_replace(array('<blockquote>', '<blockquote class="spoiler">', '<blockquote class="author">'), array($mailquote, $mailquote, $mailquote), $s);
$as = '';
$vhead = false;
$arr = explode('[/attach],',$item['attach']);
- if (count($arr)) {
+ if(count($arr)) {
$as .= '<div class="body-attach">';
- foreach ($arr as $r) {
+ foreach($arr as $r) {
$matches = false;
$icon = '';
$cnt = preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|',$r,$matches, PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
+ if($cnt) {
+ foreach($matches as $mtch) {
$mime = $mtch[3];
- if ((local_user() == $item['uid']) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN))
+ if((local_user() == $item['uid']) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN))
$the_url = 'redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1];
else
$the_url = $mtch[1];
- if (strpos($mime, 'video') !== false) {
- if (!$vhead) {
+ if(strpos($mime, 'video') !== false) {
+ if(!$vhead) {
$vhead = true;
$a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), array(
'$baseurl' => z_root(),
}
$filetype = strtolower(substr( $mime, 0, strpos($mime,'/') ));
- if ($filetype) {
+ if($filetype) {
$filesubtype = strtolower(substr( $mime, strpos($mime,'/') + 1 ));
$filesubtype = str_replace('.', '-', $filesubtype);
}
$s = $s . $as;
// map
- if (strpos($s,'<div class="map">') !== false && $item['coord']) {
+ if(strpos($s,'<div class="map">') !== false && $item['coord']) {
$x = generate_map(trim($item['coord']));
if ($x) {
$s = preg_replace('/\<div class\=\"map\"\>/','$0' . $x,$s);
}}
-if (! function_exists('prepare_text')) {
+if(! function_exists('prepare_text')) {
/**
* Given a text string, convert from bbcode to html and add smilie icons.
*
require_once('include/bbcode.php');
- if (stristr($text,'[nosmile]'))
+ if(stristr($text,'[nosmile]'))
$s = bbcode($text);
else
$s = Smilies::replace(bbcode($text));
$matches = false; $first = true;
$cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
+ if($cnt) {
+ foreach($matches as $mtch) {
$categories[] = array(
'name' => xmlify(file_tag_decode($mtch[1])),
'url' => "#",
if (count($categories)) $categories[count($categories)-1]['last'] = true;
- if (local_user() == $item['uid']) {
+ if(local_user() == $item['uid']) {
$matches = false; $first = true;
$cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
+ if($cnt) {
+ foreach($matches as $mtch) {
$folders[] = array(
'name' => xmlify(file_tag_decode($mtch[1])),
'url' => "#",
return array($categories, $folders);
}
-if (! function_exists('get_plink')) {
+if(! function_exists('get_plink')) {
/**
* get private link for item
* @param array $item
return($ret);
}}
-if (! function_exists('unamp')) {
+if(! function_exists('unamp')) {
/**
* replace html amp entity with amp char
* @param string $s
}}
-if (! function_exists('return_bytes')) {
+if(! function_exists('return_bytes')) {
/**
* return number of bytes in size (K, M, G)
* @param string $size_str
$x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
dbesc($guid)
);
- if (! count($x))
+ if(! count($x))
$found = false;
} while ($found == true );
return $guid;
$s = strtr(base64_encode($s),'+/','-_');
- if ($strip_padding)
+ if($strip_padding)
$s = str_replace('=','',$s);
return $s;
*/
function base64url_decode($s) {
- if (is_array($s)) {
+ if(is_array($s)) {
logger('base64url_decode: illegal input: ' . print_r(debug_backtrace(), true));
return $s;
}
* // Uncomment if you find you need it.
*
* $l = strlen($s);
- * if (! strpos($s,'=')) {
+ * if(! strpos($s,'=')) {
* $m = $l % 4;
- * if ($m == 2)
+ * if($m == 2)
* $s .= '==';
- * if ($m == 3)
+ * if($m == 3)
* $s .= '=';
* }
*
$matches = null;
$r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER);
if ($r) {
- foreach ($matches as $mtch) {
- if ((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be')))
+ foreach($matches as $mtch) {
+ if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be')))
$s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s);
- elseif (stristr($mtch[1],'vimeo'))
+ elseif(stristr($mtch[1],'vimeo'))
$s = str_replace($mtch[0],'[vimeo]' . $mtch[1] . '[/vimeo]',$s);
}
}
* @return string
*/
function item_post_type($item) {
- if (intval($item['event-id']))
+ if(intval($item['event-id']))
return t('event');
- if (strlen($item['resource-id']))
+ if(strlen($item['resource-id']))
return t('photo');
- if (strlen($item['verb']) && $item['verb'] !== ACTIVITY_POST)
+ if(strlen($item['verb']) && $item['verb'] !== ACTIVITY_POST)
return t('activity');
- if ($item['id'] != $item['parent'])
+ if($item['id'] != $item['parent'])
return t('comment');
return t('post');
}
function file_tag_file_query($table,$s,$type = 'file') {
- if ($type == 'file')
+ if($type == 'file')
$str = preg_quote( '[' . str_replace('%','%%',file_tag_encode($s)) . ']' );
else
$str = preg_quote( '<' . str_replace('%','%%',file_tag_encode($s)) . '>' );
// ex. given music,video return <music><video> or [music][video]
function file_tag_list_to_file($list,$type = 'file') {
$tag_list = '';
- if (strlen($list)) {
+ if(strlen($list)) {
$list_array = explode(",",$list);
- if ($type == 'file') {
+ if($type == 'file') {
$lbracket = '[';
$rbracket = ']';
}
$rbracket = '>';
}
- foreach ($list_array as $item) {
- if (strlen($item)) {
+ foreach($list_array as $item) {
+ if(strlen($item)) {
$tag_list .= $lbracket . file_tag_encode(trim($item)) . $rbracket;
}
}
function file_tag_file_to_list($file,$type = 'file') {
$matches = false;
$list = '';
- if ($type == 'file') {
+ if($type == 'file') {
$cnt = preg_match_all('/\[(.*?)\]/',$file,$matches,PREG_SET_ORDER);
}
else {
$cnt = preg_match_all('/<(.*?)>/',$file,$matches,PREG_SET_ORDER);
}
- if ($cnt) {
- foreach ($matches as $mtch) {
- if (strlen($list))
+ if($cnt) {
+ foreach($matches as $mtch) {
+ if(strlen($list))
$list .= ',';
$list .= file_tag_decode($mtch[1]);
}
// $file_old - categories previously associated with an item
// $file_new - new list of categories for an item
- if (! intval($uid))
+ if(! intval($uid))
return false;
- if ($file_old == $file_new)
+ if($file_old == $file_new)
return true;
$saved = get_pconfig($uid,'system','filetags');
- if (strlen($saved)) {
- if ($type == 'file') {
+ if(strlen($saved)) {
+ if($type == 'file') {
$lbracket = '[';
$rbracket = ']';
$termtype = TERM_FILE;
$new_tags = array();
$check_new_tags = explode(",",file_tag_file_to_list($file_new,$type));
- foreach ($check_new_tags as $tag) {
- if (! stristr($saved,$lbracket . file_tag_encode($tag) . $rbracket))
+ foreach($check_new_tags as $tag) {
+ if(! stristr($saved,$lbracket . file_tag_encode($tag) . $rbracket))
$new_tags[] = $tag;
}
$deleted_tags = array();
$check_deleted_tags = explode(",",file_tag_file_to_list($file_old,$type));
- foreach ($check_deleted_tags as $tag) {
- if (! stristr($file_new,$lbracket . file_tag_encode($tag) . $rbracket))
+ foreach($check_deleted_tags as $tag) {
+ if(! stristr($file_new,$lbracket . file_tag_encode($tag) . $rbracket))
$deleted_tags[] = $tag;
}
- foreach ($deleted_tags as $key => $tag) {
+ foreach($deleted_tags as $key => $tag) {
$r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",
dbesc($tag),
intval(TERM_OBJ_POST),
}
}
- if ($saved != $filetags_updated) {
+ if($saved != $filetags_updated) {
set_pconfig($uid,'system','filetags', $filetags_updated);
}
return true;
}
else
- if (strlen($file_new)) {
+ if(strlen($file_new)) {
set_pconfig($uid,'system','filetags', $file_new);
}
return true;
require_once("include/files.php");
$result = false;
- if (! intval($uid))
+ if(! intval($uid))
return false;
$r = q("SELECT `file` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($item),
intval($uid)
);
if (dbm::is_result($r)) {
- if (! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']'))
+ if(! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']'))
q("UPDATE `item` SET `file` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'),
intval($item),
create_files_from_item($item);
$saved = get_pconfig($uid,'system','filetags');
- if ((! strlen($saved)) || (! stristr($saved,'[' . file_tag_encode($file) . ']')))
+ if((! strlen($saved)) || (! stristr($saved,'[' . file_tag_encode($file) . ']')))
set_pconfig($uid,'system','filetags',$saved . '[' . file_tag_encode($file) . ']');
info( t('Item filed') );
}
require_once("include/files.php");
$result = false;
- if (! intval($uid))
+ if(! intval($uid))
return false;
- if ($cat == true) {
+ if($cat == true) {
$pattern = '<' . file_tag_encode($file) . '>' ;
$termtype = TERM_CATEGORY;
} else {
function undo_post_tagging($s) {
$matches = null;
$cnt = preg_match_all('/([!#@])\[url=(.*?)\](.*?)\[\/url\]/ism',$s,$matches,PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
+ if($cnt) {
+ foreach($matches as $mtch) {
$s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s);
}
}
function is_a_date_arg($s) {
$i = intval($s);
- if ($i > 1900) {
+ if($i > 1900) {
$y = date('Y');
- if ($i <= $y+1 && strpos($s,'-') == 4) {
+ if($i <= $y+1 && strpos($s,'-') == 4) {
$m = intval(substr($s,5));
- if ($m > 0 && $m <= 12)
+ if($m > 0 && $m <= 12)
return true;
}
}
* @return string Formated html
*/
function text_highlight($s,$lang) {
- if ($lang === 'js')
+ if($lang === 'js')
$lang = 'javascript';
- if (! strpos('Text_Highlighter',get_include_path())) {
+ if(! strpos('Text_Highlighter',get_include_path())) {
set_include_path(get_include_path() . PATH_SEPARATOR . 'library/Text_Highlighter');
}
// it isn't present, nothing is highlighted. So we're going to see if it's present.
// If not, we'll add it, and then quietly remove it after we get the processed output back.
- if ($lang === 'php') {
- if (strpos('<?php',$s) !== 0) {
+ if($lang === 'php') {
+ if(strpos('<?php',$s) !== 0) {
$s = '<?php' . "\n" . $s;
$tag_added = true;
}
$o = $hl->highlight($s);
$o = str_replace([" ","\n"],[" ",''],$o);
- if ($tag_added) {
+ if($tag_added) {
$b = substr($o,0,strpos($o,'<li>'));
$e = substr($o,strpos($o,'</li>'));
$o = $b . $e;
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)."'";
}
// Updating a shadow item entry
$items = q("SELECT `id` FROM `item` WHERE `guid` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item["guid"]));
- if (!dbm::is_result($items)) {
+ if (!$items)
return;
- }
$result = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s' WHERE `id` = %d",
dbesc($item["title"]),
function delete_thread_uri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
- if (dbm::is_result($messages)) {
- foreach ($messages as $message) {
+ if(count($messages))
+ foreach ($messages as $message)
delete_thread($message["id"], $itemuri);
- }
- }
}
function delete_thread($itemid, $itemuri = "") {
$r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
- if (!dbm::is_result($r)) {
+ if (!$r)
return;
- }
- if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) }
+ if (!in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
return;
- }
$data = probe_url($r[0]["url"]);
if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
- if ($r[0]["server_url"] != "") {
+ if ($r[0]["server_url"] != "")
poco_check_server($r[0]["server_url"], $r[0]["network"]);
- }
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()), intval($contact_id));
return;
}
- if (($data["name"] == "") AND ($r[0]['name'] != "")) {
+ if (($data["name"] == "") AND ($r[0]['name'] != ""))
$data["name"] = $r[0]['name'];
- }
- if (($data["nick"] == "") AND ($r[0]['nick'] != "")) {
+ if (($data["nick"] == "") AND ($r[0]['nick'] != ""))
$data["nick"] = $r[0]['nick'];
- }
- if (($data["addr"] == "") AND ($r[0]['addr'] != "")) {
+ if (($data["addr"] == "") AND ($r[0]['addr'] != ""))
$data["addr"] = $r[0]['addr'];
- }
- if (($data["photo"] == "") AND ($r[0]['photo'] != "")) {
+ if (($data["photo"] == "") AND ($r[0]['photo'] != ""))
$data["photo"] = $r[0]['photo'];
- }
+
q("UPDATE `gcontact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `photo` = '%s'
WHERE `id` = %d",
$tmp_str = $openid_url;
- if ($using_invites) {
- if (! $invite_id) {
+ if($using_invites) {
+ if(! $invite_id) {
$result['message'] .= t('An invitation is required.') . EOL;
return $result;
}
$r = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($invite_id));
- if (! results($r)) {
+ if(! results($r)) {
$result['message'] .= t('Invitation could not be verified.') . EOL;
return $result;
}
}
- if ((! x($username)) || (! x($email)) || (! x($nickname))) {
- if ($openid_url) {
- if (! validate_url($tmp_str)) {
+ if((! x($username)) || (! x($email)) || (! x($nickname))) {
+ if($openid_url) {
+ if(! validate_url($tmp_str)) {
$result['message'] .= t('Invalid OpenID url') . EOL;
return $result;
}
return;
}
- if (! validate_url($tmp_str))
+ if(! validate_url($tmp_str))
$openid_url = '';
// collapse multiple spaces in name
$username = preg_replace('/ +/',' ',$username);
- if (mb_strlen($username) > 48)
+ if(mb_strlen($username) > 48)
$result['message'] .= t('Please use a shorter name.') . EOL;
- if (mb_strlen($username) < 3)
+ if(mb_strlen($username) < 3)
$result['message'] .= t('Name too short.') . EOL;
// I don't really like having this rule, but it cuts down
// So now we are just looking for a space in the full name.
$loose_reg = get_config('system','no_regfullname');
- if (! $loose_reg) {
+ if(! $loose_reg) {
$username = mb_convert_case($username,MB_CASE_TITLE,'UTF-8');
- if (! strpos($username,' '))
+ if(! strpos($username,' '))
$result['message'] .= t("That doesn't appear to be your full \x28First Last\x29 name.") . EOL;
}
- if (! allowed_email($email))
+ if(! allowed_email($email))
$result['message'] .= t('Your email domain is not among those allowed on this site.') . EOL;
- if ((! valid_email($email)) || (! validate_email($email)))
+ if((! valid_email($email)) || (! validate_email($email)))
$result['message'] .= t('Not a valid email address.') . EOL;
// Disallow somebody creating an account using openid that uses the admin email address,
$adminlist = explode(",", str_replace(" ", "", strtolower($a->config['admin_email'])));
- //if ((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0) && strlen($openid_url)) {
- if ((x($a->config,'admin_email')) && in_array(strtolower($email), $adminlist) && strlen($openid_url)) {
+ //if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0) && strlen($openid_url)) {
+ if((x($a->config,'admin_email')) && in_array(strtolower($email), $adminlist) && strlen($openid_url)) {
$r = q("SELECT * FROM `user` WHERE `email` = '%s' LIMIT 1",
dbesc($email)
);
$nickname = $arr['nickname'] = strtolower($nickname);
- if (! preg_match("/^[a-z0-9][a-z0-9\_]*$/",$nickname))
+ if(! preg_match("/^[a-z0-9][a-z0-9\_]*$/",$nickname))
$result['message'] .= t('Your "nickname" can only contain "a-z", "0-9" and "_".') . EOL;
$r = q("SELECT `uid` FROM `user`
if (dbm::is_result($r))
$result['message'] .= t('Nickname was once registered here and may not be re-used. Please choose another.') . EOL;
- if (strlen($result['message'])) {
+ if(strlen($result['message'])) {
return $result;
}
$keys = new_keypair(4096);
- if ($keys === false) {
+ if($keys === false) {
$result['message'] .= t('SERIOUS ERROR: Generation of security keys failed.') . EOL;
return $result;
}
$default_service_class = get_config('system','default_service_class');
- if (! $default_service_class)
+ if(! $default_service_class)
$default_service_class = '';
return $result;
}
- if (x($newuid) !== false) {
+ if(x($newuid) !== false) {
$r = q("INSERT INTO `profile` ( `uid`, `profile-name`, `is-default`, `name`, `photo`, `thumb`, `publish`, `net-publish` )
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, %d ) ",
intval($newuid),
);
}
- if (get_config('system', 'newuser_private') && $def_gid) {
+ if(get_config('system', 'newuser_private') && $def_gid) {
q("UPDATE `user` SET `allow_gid` = '%s' WHERE `uid` = %d",
dbesc("<" . $def_gid . ">"),
intval($newuid)
}
// if we have no OpenID photo try to look up an avatar
- if (! strlen($photo))
+ if(! strlen($photo))
$photo = avatar_img($email);
// unless there is no avatar-plugin loaded
- if (strlen($photo)) {
+ if(strlen($photo)) {
require_once('include/Photo.php');
$photo_failure = false;
$img = new Photo($img_str, $type);
- if ($img->is_valid()) {
+ if($img->is_valid()) {
$img->scaleImageSquare(175);
}
}
- foreach ($array as $key => $value) {
+ foreach($array as $key => $value) {
if (!isset($element) AND isset($xml)) {
$element = $xml;
}
//Set the attributes too.
if (isset($attributes) and $get_attributes) {
foreach ($attributes as $attr => $val) {
- if ($priority == 'tag') {
+ if($priority == 'tag') {
$attributes_data[$attr] = $val;
} else {
$result['@attributes'][$attr] = $val; // Set all the attributes in a array called 'attr'
/**
*
* Load the configuration file which contains our DB credentials.
- * Ignore errors. If the file doesn't exist or is empty, we are running in
- * installation mode.
+ * Ignore errors. If the file doesn't exist or is empty, we are running in installation mode.
*
*/
$install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false : true);
-// Only load config if found, don't surpress errors
-if (!$install) {
- include(".htconfig.php");
-}
+@include(".htconfig.php");
+
+
+
+
/**
*
require_once("include/dba.php");
-if (!$install) {
+if(!$install) {
$db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
unset($db_host, $db_user, $db_pass, $db_data);
if (dbm::is_result($r)) $_SESSION['language'] = $r[0]['language'];
}
-if ((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
+if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
$lang = $_SESSION['language'];
load_translation_table($lang);
}
-if ((x($_GET,'zrl')) && (!$install && !$maintenance)) {
+if((x($_GET,'zrl')) && (!$install && !$maintenance)) {
// Only continue when the given profile link seems valid
// Valid profile links contain a path with "/profile/" and no query parameters
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") AND
* further processing.
*/
-if (strlen($a->module)) {
+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');
//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;
- }
}
}
* Call module functions
*/
-if ($a->module_loaded) {
+if($a->module_loaded) {
$a->page['page_title'] = $a->module;
$placeholder = '';
- if (function_exists($a->module . '_init')) {
+ if(function_exists($a->module . '_init')) {
call_hooks($a->module . '_mod_init', $placeholder);
$func = $a->module . '_init';
$func($a);
}
- if (function_exists(str_replace('-','_',current_theme()) . '_init')) {
+ if(function_exists(str_replace('-','_',current_theme()) . '_init')) {
$func = str_replace('-','_',current_theme()) . '_init';
$func($a);
}
// elseif (x($a->theme_info,"extends") && file_exists("view/theme/".$a->theme_info["extends"]."/theme.php")) {
// require_once("view/theme/".$a->theme_info["extends"]."/theme.php");
-// if (function_exists(str_replace('-','_',$a->theme_info["extends"]) . '_init')) {
+// if(function_exists(str_replace('-','_',$a->theme_info["extends"]) . '_init')) {
// $func = str_replace('-','_',$a->theme_info["extends"]) . '_init';
// $func($a);
// }
// }
- if (($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
+ if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
&& (function_exists($a->module . '_post'))
&& (! x($_POST,'auth-params'))) {
call_hooks($a->module . '_mod_post', $_POST);
$func($a);
}
- if ((! $a->error) && (function_exists($a->module . '_afterpost'))) {
+ if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
call_hooks($a->module . '_mod_afterpost',$placeholder);
$func = $a->module . '_afterpost';
$func($a);
}
- if ((! $a->error) && (function_exists($a->module . '_content'))) {
+ if((! $a->error) && (function_exists($a->module . '_content'))) {
$arr = array('content' => $a->page['content']);
call_hooks($a->module . '_mod_content', $arr);
$a->page['content'] = $arr['content'];
$a->page['content'] .= $arr['content'];
}
- if (function_exists(str_replace('-','_',current_theme()) . '_content_loaded')) {
+ if(function_exists(str_replace('-','_',current_theme()) . '_content_loaded')) {
$func = str_replace('-','_',current_theme()) . '_content_loaded';
$func($a);
}
// 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.
-if (stristr( implode("",$_SESSION['sysmsg']), t('Permission denied'))) {
+if(stristr( implode("",$_SESSION['sysmsg']), t('Permission denied'))) {
header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
}
*
*/
-/*if (x($_SESSION,'sysmsg')) {
+/*if(x($_SESSION,'sysmsg')) {
$a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
. ((x($a->page,'content')) ? $a->page['content'] : '');
$_SESSION['sysmsg']="";
unset($_SESSION['sysmsg']);
}
-if (x($_SESSION,'sysmsg_info')) {
+if(x($_SESSION,'sysmsg_info')) {
$a->page['content'] = "<div id=\"sysmsg_info\" class=\"info-message\">{$_SESSION['sysmsg_info']}</div>\r\n"
. ((x($a->page,'content')) ? $a->page['content'] : '');
$_SESSION['sysmsg_info']="";
*
*/
-if ($a->module != 'install' && $a->module != 'maintenance') {
+if($a->module != 'install' && $a->module != 'maintenance') {
nav($a);
}
* Add a "toggle mobile" link if we're using a mobile device
*/
-if ($a->is_mobile || $a->is_tablet) {
- if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
+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(
- '$toggle_link' => $link,
- '$toggle_text' => t('toggle mobile')
- ));
+ '$toggle_link' => $link,
+ '$toggle_text' => t('toggle mobile')
+ ));
}
/**
* 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));
echo substr($target->saveHTML(), 6, -8);
- if (!$a->is_backend()) {
+ if (!$a->is_backend())
session_write_close();
- }
exit;
}
}
// If there is no page template use the default page template
-if (!$template) {
+if(!$template) {
$template = theme_include("default.php");
}
}
$taglist = array();
- foreach ($tags AS $tag) {
+ foreach($tags AS $tag) {
$taglist[] = $tag;
}
function acctlink_init(App $a) {
- if (x($_GET,'addr')) {
+ if(x($_GET,'addr')) {
$addr = trim($_GET['addr']);
$res = probe_url($addr);
//logger('acctlink: ' . print_r($res,true));
- if ($res['url']) {
+ if($res['url']) {
goaway($res['url']);
killme();
}
$allowed_theme_list = Config::get('system', 'allowed_themes');
foreach ($files as $file) {
- if (file_exists($file.'/unsupported'))
+ if (intval(file_exists($file.'/unsupported')))
continue;
- }
$f = basename($file);
if ($a->argc>2) {
$uid = $a->argv[3];
$user = q("SELECT `username`, `blocked` FROM `user` WHERE `uid` = %d", intval($uid));
- if (!dbm::is_result($user)) {
+ if (count($user) == 0) {
notice('User not found'.EOL);
goaway('admin/users');
return ''; // NOTREACHED
* @param int $result
*/
function toggle_theme(&$themes,$th,&$result) {
- for ($x = 0; $x < count($themes); $x ++) {
+ for($x = 0; $x < count($themes); $x ++) {
if ($themes[$x]['name'] === $th) {
if ($themes[$x]['allowed']) {
$themes[$x]['allowed'] = 0;
* @return int
*/
function theme_status($themes,$th) {
- for ($x = 0; $x < count($themes); $x ++) {
+ for($x = 0; $x < count($themes); $x ++) {
if ($themes[$x]['name'] === $th) {
if ($themes[$x]['allowed']) {
return 1;
continue;
}
- $is_experimental = file_exists($file.'/experimental');
- $is_supported = (!file_exists($file.'/unsupported'));
- $is_allowed = in_array($f,$allowed_themes);
+ $is_experimental = intval(file_exists($file.'/experimental'));
+ $is_supported = 1-(intval(file_exists($file.'/unsupported')));
+ $is_allowed = intval(in_array($f,$allowed_themes));
if ($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes")) {
$themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
$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);
$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']);
return;
}
- if (count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
+ if(count($a->user) && x($a->user,'uid') && $a->user['uid'] != local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
<?php
function apps_content(App $a) {
- $privateaddons = get_config('config','private_addons');
- if ($privateaddons === "1") {
- if ((! (local_user()))) {
- info( t("You must be logged in to use addons. "));
- return;
- }
- }
+ $privateaddons = get_config('config','private_addons');
+ if ($privateaddons === "1") {
+ if((! (local_user()))) {
+ info( t("You must be logged in to use addons. "));
+ return;};
+}
- $title = t('Applications');
+ $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,
));
+
+
+
}
function attach_init(App $a) {
- if ($a->argc != 2) {
+ if($a->argc != 2) {
notice( t('Item not available.') . EOL);
return;
}
// error in Chrome for filenames with commas in them
header('Content-type: ' . $r[0]['filetype']);
header('Content-length: ' . $r[0]['filesize']);
- if (isset($_GET['attachment']) && $_GET['attachment'] === '0')
+ if(isset($_GET['attachment']) && $_GET['attachment'] === '0')
header('Content-disposition: filename="' . $r[0]['filename'] . '"');
else
header('Content-disposition: attachment; filename="' . $r[0]['filename'] . '"');
$o .= '<br /><br />';
- if (x($_REQUEST,'text')) {
+ if(x($_REQUEST,'text')) {
$text = trim($_REQUEST['text']);
$o .= "<h2>" . t("Source input: ") . "</h2>" . EOL. EOL;
}
- if (x($_REQUEST,'d2bbtext')) {
+ if(x($_REQUEST,'d2bbtext')) {
$d2bbtext = trim($_REQUEST['d2bbtext']);
$o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL. EOL;
require_once('include/redir.php');
function cal_init(App $a) {
- if ($a->argc > 1)
+ if($a->argc > 1)
auto_redir($a, $a->argv[1]);
- if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
$o = '';
- if ($a->argc > 1) {
+ if($a->argc > 1) {
$nick = $a->argv[1];
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
dbesc($nick)
);
- if (! count($user))
+ if(! count($user))
return;
$a->data['user'] = $user[0];
$cal_widget = widget_events();
- if (! x($a->page,'aside'))
+ if(! x($a->page,'aside'))
$a->page['aside'] = '';
$a->page['aside'] .= $vcard_widget;
// 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
$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') {
+ if($a->argc == 4) {
+ if($a->argv[2] == 'export') {
$mode = 'export';
$format = $a->argv[3];
}
$owner_uid = $a->data['user']['uid'];
$nick = $a->data['user']['nickname'];
- if (is_array($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $v) {
- if ($v['uid'] == $a->profile['profile_uid']) {
+ if(is_array($_SESSION['remote'])) {
+ foreach($_SESSION['remote'] as $v) {
+ if($v['uid'] == $a->profile['profile_uid']) {
$contact_id = $v['cid'];
break;
}
}
}
- if ($contact_id) {
+ if($contact_id) {
$groups = init_groups_visitor($contact_id);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
$remote_contact = true;
}
}
- if (! $remote_contact) {
- if (local_user()) {
+ if(! $remote_contact) {
+ if(local_user()) {
$contact_id = $_SESSION['cid'];
$contact = $a->contact;
}
}
$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
- if ($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
+ if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) {
notice( t('Access to this profile has been restricted.') . EOL);
return;
}
$tabs .= profile_tabs($a,false, $a->data['user']['nickname']);
// The view mode part is similiar to /mod/events.php
- if ($mode == 'view') {
+ if($mode == 'view') {
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
- if (! $y)
+ if(! $y)
$y = intval($thisyear);
- if (! $m)
+ if(! $m)
$m = intval($thismonth);
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
- if ($y < 1901)
+ if($y < 1901)
$y = 1900;
- if ($y > 2099)
+ if($y > 2099)
$y = 2100;
$nextyear = $y;
$nextmonth = $m + 1;
- if ($nextmonth > 12) {
+ if($nextmonth > 12) {
$nextmonth = 1;
$nextyear ++;
}
$prevyear = $y;
- if ($m > 1)
+ if($m > 1)
$prevmonth = $m - 1;
else {
$prevmonth = 12;
$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();
}
// Get rid of dashes in key names, Smarty3 can't handle them
- foreach ($events as $key => $event) {
+ foreach($events as $key => $event) {
$event_item = array();
- foreach ($event['item'] as $k => $v) {
+ foreach($event['item'] as $k => $v) {
$k = str_replace('-','_',$k);
$event_item[$k] = $v;
}
return $o;
}
- if ($mode == 'export') {
- if (! (intval($owner_uid))) {
+ if($mode == 'export') {
+ if(! (intval($owner_uid))) {
notice( t('User not found'));
return;
}
// Test permissions
// Respect the export feature setting for all other /cal pages if it's not the own profile
- if ( ((local_user() !== intval($owner_uid))) && ! feature_enabled($owner_uid, "export_calendar")) {
+ if( ((local_user() !== intval($owner_uid))) && ! feature_enabled($owner_uid, "export_calendar")) {
notice( t('Permission denied.') . EOL);
goaway('cal/' . $nick);
}
$evexport = event_export($owner_uid, $format);
if (!$evexport["success"]) {
- if ($evexport["content"])
+ if($evexport["content"])
notice( t('This calendar format is not supported') );
else
notice( t('No exportable data found'));
return;
}
- if (! $cid) {
- if (get_my_url()) {
+ if(! $cid) {
+ if(get_my_url()) {
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
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 ($update)
return;
- if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
return;
}
- if (get_config('system','community_page_style') == CP_NO_COMMUNITY_PAGE) {
+ if(get_config('system','community_page_style') == CP_NO_COMMUNITY_PAGE) {
notice( t('Not available.') . EOL);
return;
}
$o .= '<h3>' . t('Community') . '</h3>';
- if (! $update) {
+ if(! $update) {
nav_set_selected('community');
}
- if (x($a->data,'search'))
+ if(x($a->data,'search'))
$search = notags(trim($a->data['search']));
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
$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
$o .= conversation($a, $s, 'community', $update);
- $o .= alt_pager($a, count($r));
+ $o .= alt_pager($a, count($r));
return $o;
}
killme();
}
- if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
+ if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
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]))) {
+ if(($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
intval($a->argv[1]),
$group = $r[0];
$members = group_get_members($group['id']);
$preselected = array();
- if (count($members)) {
- foreach ($members as $member) {
+ if(count($members)) {
+ foreach($members as $member)
$preselected[] = $member['id'];
- }
}
- if ($change) {
- if (in_array($change,$preselected)) {
+ 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);
}
}
$contact_id = 0;
- if ((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
+ if((($a->argc == 2) && intval($a->argv[1])) OR (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
$contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()),
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) {
+ foreach($orig_records as $orig_record) {
$contact_id = $orig_record['id'];
if (x($_POST, 'contacts_batch_update')) {
_contact_update($contact_id);
$count_actions++;
}
}
-
- if ($count_actions > 0) {
+ 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');
}
intval(local_user())
);
- if (! dbm::is_result($orig_record)) {
- /// @TODO EOL really needed?
+ if (! count($orig_record)) {
notice( t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
$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']));
intval($contact_id),
intval(local_user())
);
- /// @TODO Decide to use dbm::is_result() here, what does $r include?
- if ($r) {
+ if($r)
info( t('Contact updated.') . EOL);
- } else {
+ else
notice( t('Failed to update contact record.') . EOL);
- }
- $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ $r = q("select * from contact where id = %d and uid = %d limit 1",
intval($contact_id),
intval(local_user())
);
-
- if (dbm::is_result($r)) {
+ if($r && dbm::is_result($r))
$a->data['contact'] = $r[0];
- }
return;
/*contact actions*/
function _contact_update($contact_id) {
$r = q("SELECT `uid`, `url`, `network` FROM `contact` WHERE `id` = %d", intval($contact_id));
- if (!dbm::is_result($r)) {
+ if (!$r)
return;
- }
$uid = $r[0]["uid"];
- if ($uid != local_user()) {
+ if ($uid != local_user())
return;
- }
if ($r[0]["network"] == NETWORK_OSTATUS) {
$result = new_contact($uid, $r[0]["url"], false);
- if ($result['success']) {
+ if ($result['success'])
$r = q("UPDATE `contact` SET `subhub` = 1 WHERE `id` = %d",
intval($contact_id));
- }
- } else {
+ } else
// pull feed and consume it, which should subscribe to the hub.
proc_run(PRIORITY_HIGH, "include/onepoll.php", $contact_id, "force");
- }
}
function _contact_update_profile($contact_id) {
$r = q("SELECT `uid`, `url`, `network` FROM `contact` WHERE `id` = %d", intval($contact_id));
- if (!dbm::is_result($r)) {
+ if (!$r)
return;
- }
$uid = $r[0]["uid"];
- if ($uid != local_user()) {
+ if ($uid != local_user())
return;
- }
$data = probe_url($r[0]["url"]);
// "Feed" or "Unknown" is mostly a sign of communication problems
- if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) AND ($data["network"] != $r[0]["network"])) {
+ if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) AND ($data["network"] != $r[0]["network"]))
return;
- }
$updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm",
"poco", "network", "alias");
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 != "") {
+ foreach($update AS $key => $value) {
+ 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),
return;
}
- if ($a->argc == 3) {
+ if($a->argc == 3) {
$contact_id = intval($a->argv[1]);
- if (! $contact_id) {
+ if(! $contact_id)
return;
- }
$cmd = $a->argv[2];
intval(local_user())
);
- if (! dbm::is_result($orig_record)) {
+ if(! count($orig_record)) {
notice( t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
}
- if ($cmd === 'update') {
+ if($cmd === 'update') {
_contact_update($contact_id);
goaway('contacts/' . $contact_id);
// NOTREACHED
}
- if ($cmd === 'updateprofile') {
+ if($cmd === 'updateprofile') {
_contact_update_profile($contact_id);
goaway('crepair/' . $contact_id);
// NOTREACHED
}
- if ($cmd === 'block') {
+ 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);
return; // NOTREACHED
}
- if ($cmd === 'ignore') {
+ 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);
}
- if ($cmd === 'archive') {
+ 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);
return; // NOTREACHED
}
- if ($cmd === 'drop') {
+ if($cmd === 'drop') {
// Check if we should do HTML-based delete confirmation
- if ($_REQUEST['confirm']) {
+ if($_REQUEST['confirm']) {
// <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs
$query = explode_querystring($a->query_string);
$inputs = array();
- foreach ($query['args'] as $arg) {
- if (strpos($arg, 'confirm=') === false) {
+ foreach($query['args'] as $arg) {
+ if(strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
}
if ($_REQUEST['canceled']) {
if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']);
- } else {
+ }
+ else {
goaway('contacts');
}
}
info( t('Contact has been removed.') . EOL );
if (x($_SESSION,'return_url')) {
goaway('' . $_SESSION['return_url']);
- } else {
+ }
+ else {
goaway('contacts');
}
return; // NOTREACHED
$_SESSION['return_url'] = $a->query_string;
- if ((x($a->data,'contact')) && (is_array($a->data['contact']))) {
+ if((x($a->data,'contact')) && (is_array($a->data['contact']))) {
$contact_id = $a->data['contact']['id'];
$contact = $a->data['contact'];
break;
}
- if (!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
+ if(!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
$relation_text = "";
$relation_text = sprintf($relation_text,htmlentities($contact['name']));
- if (($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
+ if(($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
$url = "redir/{$contact['id']}";
$sparkle = ' class="sparkle" ';
}
? 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') : '');
$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"),
$ignored = false;
$all = false;
- if (($a->argc == 2) && ($a->argv[1] === 'all')) {
+ if(($a->argc == 2) && ($a->argv[1] === 'all')) {
$sql_extra = '';
$all = true;
- } elseif (($a->argc == 2) && ($a->argv[1] === 'blocked')) {
+ }
+ elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
$sql_extra = " AND `blocked` = 1 ";
$blocked = true;
- } elseif (($a->argc == 2) && ($a->argv[1] === 'hidden')) {
+ }
+ elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
$sql_extra = " AND `hidden` = 1 ";
$hidden = true;
- } elseif (($a->argc == 2) && ($a->argv[1] === 'ignored')) {
+ }
+ elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
$sql_extra = " AND `readonly` = 1 ";
$ignored = true;
- } elseif (($a->argc == 2) && ($a->argv[1] === 'archived')) {
+ }
+ elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
$sql_extra = " AND `archive` = 1 ";
$archived = true;
- } else {
- $sql_extra = " AND `blocked` = 0 ";
}
+ else
+ $sql_extra = " AND `blocked` = 0 ";
$search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
$nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : '');
$tab_tpl = get_markup_template('common_tabs.tpl');
$t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
+
+
$searching = false;
- if ($search) {
+ if($search) {
$search_hdr = $search;
$search_txt = dbesc(protect_sprintf(preg_quote($search)));
$searching = true;
}
$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']));
// 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,
function contact_posts($a, $contact_id) {
$r = q("SELECT `url` FROM `contact` WHERE `id` = %d", intval($contact_id));
- if (dbm::is_result($r)) {
+ if ($r) {
$contact = $r[0];
$a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
- } else {
+ } else
$profile = "";
- }
$tab_str = contacts_tab($a, $contact_id, 1);
default:
break;
}
- if (($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
+ if(($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
$url = "redir/{$rr['id']}";
$sparkle = ' class="sparkle" ';
- } else {
+ }
+ else {
$url = $rr['url'];
$sparkle = '';
}
$contact_action = array();
// Provide friend suggestion only for Friendica contacts
- if ($contact['network'] === NETWORK_DFRN) {
+ if($contact['network'] === NETWORK_DFRN) {
$contact_actions['suggest'] = array(
'label' => t('Suggest friends'),
'url' => 'fsuggest/' . $contact['id'],
);
}
- if ($poll_enabled) {
+ if($poll_enabled) {
$contact_actions['update'] = array(
'label' => t('Update now'),
'url' => 'contacts/' . $contact['id'] . '/update',
$nouveau = false;
- if ($a->argc > 1) {
- for ($x = 1; $x < $a->argc; $x ++) {
- if (is_a_date_arg($a->argv[$x])) {
- if ($datequery) {
+ if($a->argc > 1) {
+ for($x = 1; $x < $a->argc; $x ++) {
+ if(is_a_date_arg($a->argv[$x])) {
+ 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 . '>');
}
- if (x($_GET,'search') || x($_GET,'file'))
+ if(x($_GET,'search') || x($_GET,'file'))
$nouveau = true;
- if ($cid)
+ if($cid)
$def_acl = array('allow_cid' => '<' . intval($cid) . '>');
- if ($nets) {
+ if($nets) {
$r = q("select id from contact where uid = %d and network = '%s' and self = 0",
intval(local_user()),
dbesc($nets)
$str = '';
if (dbm::is_result($r))
- foreach ($r as $rr)
+ foreach($r as $rr)
$str .= '<' . $rr['id'] . '>';
- if (strlen($str))
+ if(strlen($str))
$def_acl = array('allow_cid' => $str);
}
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) ";
- if ($group) {
+ if($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($group),
intval($_SESSION['uid'])
);
if (! dbm::is_result($r)) {
- if ($update)
+ if($update)
killme();
notice( t('No such group') . EOL );
goaway(App::get_baseurl(true) . '/network');
}
$contacts = expand_groups(array($group));
- if ((is_array($contacts)) && count($contacts)) {
+ if((is_array($contacts)) && count($contacts)) {
$contact_str = implode(',',$contacts);
}
else {
'$title' => sprintf( t('Group: %s'), $r[0]['name'])
)) . $o;
}
- elseif ($cid) {
+ elseif($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d
AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
$sql_extra3 = '';
- if ($datequery) {
+ if($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
}
- if ($datequery2) {
+ if($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
}
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
$sql_table = "`item`";
- if (x($_GET,'search')) {
+ if(x($_GET,'search')) {
$search = escape_tags($_GET['search']);
- if (strpos($search,'#') === 0) {
+ if(strpos($search,'#') === 0) {
$tag = true;
$search = substr($search,1);
}
if (get_config('system','only_tag_search'))
$tag = true;
- if ($tag) {
+ if($tag) {
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
//$sql_table = "`term` INNER JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
}
}
- if (strlen($file)) {
+ if(strlen($file)) {
$sql_extra .= file_tag_file_query('item',unxmlify($file));
}
- if ($conv) {
+ if($conv) {
$myurl = App::get_baseurl() . '/profile/'. $a->user['nickname'];
$myurl = substr($myurl,strpos($myurl,'://')+3);
$myurl = str_replace('www.','',$myurl);
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
- if ($nouveau) {
+ if($nouveau) {
// "New Item View" - show all items unthreaded in reverse created date order
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
// Normal conversation view
- if ($order === 'post')
+ if($order === 'post')
$ordering = "`created`";
else
$ordering = "`commented`";
$parents_str = '';
if (dbm::is_result($r)) {
- foreach ($r as $rr)
- if (! in_array($rr['item_id'],$parents_arr))
+ foreach($r as $rr)
+ if(! in_array($rr['item_id'],$parents_arr))
$parents_arr[] = $rr['item_id'];
$parents_str = implode(', ', $parents_arr);
);
}
- if ($mode === 'network') {
+ if($mode === 'network') {
$profile_owner = local_user();
$page_writeable = true;
}
- if ($mode === 'profile') {
+ if($mode === 'profile') {
$profile_owner = $a->profile['profile_uid'];
$page_writeable = can_write_wall($a,$profile_owner);
}
- if ($mode === 'notes') {
+ if($mode === 'notes') {
$profile_owner = local_user();
$page_writeable = true;
}
- if ($mode === 'display') {
+ if($mode === 'display') {
$profile_owner = $a->profile['uid'];
$page_writeable = can_write_wall($a,$profile_owner);
}
- if ($mode === 'community') {
+ if($mode === 'community') {
$profile_owner = 0;
$page_writeable = false;
}
- if ($update)
+ if($update)
$return_url = $_SESSION['return_url'];
else
$return_url = $_SESSION['return_url'] = $a->query_string;
$threads = array();
$threadsid = -1;
- if ($items && count($items)) {
+ if($items && count($items)) {
- if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
+ if($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
// "New Item View" on network page or search page results
// - just loop through the items and format them minimally for display
//$tpl = get_markup_template('search_item.tpl');
$tpl = 'search_item.tpl';
- foreach ($items as $item) {
+ foreach($items as $item) {
$threadsid++;
$comment = '';
$owner_name = '';
$sparkle = '';
- if ($mode === 'search' || $mode === 'community') {
- if (((activity_match($item['verb'],ACTIVITY_LIKE))
+ if($mode === 'search' || $mode === 'community') {
+ if(((activity_match($item['verb'],ACTIVITY_LIKE))
|| (activity_match($item['verb'],ACTIVITY_DISLIKE))
|| activity_match($item['verb'],ACTIVITY_ATTEND)
|| activity_match($item['verb'],ACTIVITY_ATTENDNO)
$nickname = $a->user['nickname'];
// prevent private email from leaking.
- if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
+ if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
continue;
$profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
- if ($item['author-link'] && (! $item['author-name']))
+ if($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link'];
$sp = false;
$profile_link = best_link_url($item,$sp);
- if ($profile_link === 'mailbox')
+ if($profile_link === 'mailbox')
$profile_link = '';
- if ($sp)
+ if($sp)
$sparkle = ' sparkle';
else
$profile_link = zrl($profile_link);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
localize_item($item);
- if ($mode === 'network-new')
+ if($mode === 'network-new')
$dropping = true;
else
$dropping = false;
$body = prepare_body($item,true);
- if ($a->theme['template_engine'] === 'internal') {
+ if($a->theme['template_engine'] === 'internal') {
$name_e = template_escape($profile_name);
$title_e = template_escape($item['title']);
$body_e = template_escape($body);
// Store the result in the $comments array
$comments = array();
- foreach ($items as $item) {
- if ((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) {
- if (! x($comments,$item['parent']))
+ foreach($items as $item) {
+ if((intval($item['gravity']) == 6) && ($item['id'] != $item['parent'])) {
+ if(! x($comments,$item['parent']))
$comments[$item['parent']] = 1;
else
$comments[$item['parent']] += 1;
- } elseif (! x($comments,$item['parent']))
+ } elseif(! x($comments,$item['parent']))
$comments[$item['parent']] = 0; // avoid notices later on
}
// map all the like/dislike/attendance activities for each parent item
// Store these in the $alike and $dlike arrays
- foreach ($items as $item) {
+ foreach($items as $item) {
builtin_activity_puller($item, $conv_responses);
}
$blowhard_count = 0;
- foreach ($items as $item) {
+ foreach($items as $item) {
$comment = '';
$template = $tpl;
// We've already parsed out like/dislike for special treatment. We can ignore them now
- if (((activity_match($item['verb'],ACTIVITY_LIKE))
+ if(((activity_match($item['verb'],ACTIVITY_LIKE))
|| (activity_match($item['verb'],ACTIVITY_DISLIKE)
|| activity_match($item['verb'],ACTIVITY_ATTEND)
|| activity_match($item['verb'],ACTIVITY_ATTENDNO)
// If a single author has more than 3 consecutive top-level posts, squash the remaining ones.
// If there are more than two comments, squash all but the last 2.
- if ($toplevelpost) {
+ if($toplevelpost) {
$item_writeable = (($item['writable'] || $item['self']) ? true : false);
else {
// prevent private email reply to public conversation from leaking.
- if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
+ if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
continue;
$comments_seen ++;
$show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false);
- if (($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
+ if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
if (!$comments_collapsed){
$threads[$threadsid]['num_comments'] = sprintf( tt('%d comment','%d comments',$comments[$item['parent']]),$comments[$item['parent']] );
$comment_firstcollapsed = true;
}
}
- if (($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
+ if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
$comment_lastcollapsed = true;
}
$osparkle = '';
- if (($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {
+ if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {
- if ($item['wall']) {
+ if($item['wall']) {
// On the network page, I am the owner. On the display page it will be the profile owner.
// This will have been stored in $a->page_contact by our calling page.
$commentww = 'ww';
}
- if ((! $item['wall']) && $item['owner-link']) {
+ if((! $item['wall']) && $item['owner-link']) {
$owner_linkmatch = (($item['owner-link']) && link_compare($item['owner-link'],$item['author-link']));
$alias_linkmatch = (($item['alias']) && link_compare($item['alias'],$item['author-link']));
$owner_namematch = (($item['owner-name']) && $item['owner-name'] == $item['author-name']);
- if ((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
+ if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
// The author url doesn't match the owner (typically the contact)
// and also doesn't match the contact alias.
$template = $wallwall;
$commentww = 'ww';
// If it is our contact, use a friendly redirect link
- if ((link_compare($item['owner-link'],$item['url']))
+ if((link_compare($item['owner-link'],$item['url']))
&& ($item['network'] === NETWORK_DFRN)) {
$owner_url = $redirect_url;
$osparkle = ' sparkle';
$likebuttons = '';
$shareable = ((($profile_owner == local_user()) && ($item['private'] != 1)) ? true : false);
- if ($page_writeable) {
-/* if ($toplevelpost) { */
+ if($page_writeable) {
+/* if($toplevelpost) { */
$likebuttons = array(
'like' => array( t("I like this \x28toggle\x29"), t("like")),
'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")),
$qc = $qcomment = null;
- if (in_array('qcomment',$a->plugins)) {
+ if(in_array('qcomment',$a->plugins)) {
$qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
$qcomment = (($qc) ? explode("\n",$qc) : null);
}
- if (($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
+ if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
$comment = replace_macros($cmnt_tpl,array(
'$return_path' => '',
'$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''),
$drop = '';
$dropping = false;
- if ((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
+ if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
$dropping = true;
$drop = array(
$profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
- if ($item['author-link'] && (! $item['author-name']))
+ if($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link'];
$sp = false;
// 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) {
+ if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno';
$response_verbs[] = 'attendmaybe';
- if ($page_writeable) {
+ if($page_writeable) {
$isevent = true;
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
}
$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);
$tags=array();
- foreach (explode(',',$item['tag']) as $tag){
+ foreach(explode(',',$item['tag']) as $tag){
$tag = trim($tag);
- if ($tag!="") {
- $tags[] = bbcode($tag);
- }
+ if ($tag!="") $tags[] = bbcode($tag);
}
// Build the HTML
$body = prepare_body($item,true);
//$tmp_item = replace_macros($template,
- if ($a->theme['template_engine'] === 'internal') {
+ if($a->theme['template_engine'] === 'internal') {
$body_e = template_escape($body);
$text_e = strip_tags(template_escape($body));
$name_e = template_escape($profile_name);
$title_e = template_escape($item['title']);
$location_e = template_escape($location);
$owner_name_e = template_escape($owner_name);
- } else {
+ }
+ else {
$body_e = $body;
$text_e = strip_tags($body);
$name_e = $profile_name;
$contact_id = 0;
- if (($a->argc == 2) && intval($a->argv[1])) {
+ if(($a->argc == 2) && intval($a->argv[1])) {
$contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
intval(local_user()),
}
}
- if (! x($a->page,'aside')) {
+ if(! x($a->page,'aside'))
$a->page['aside'] = '';
- }
- if ($contact_id) {
+ if($contact_id) {
$a->data['contact'] = $r[0];
$contact = $r[0];
profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
return;
}
- // Init $r here if $cid is not set
- $r = false;
-
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- if ($cid) {
+ if($cid) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($cid),
intval(local_user())
local_user()
);
- if ($photo) {
+ if($photo) {
logger('mod-crepair: updating photo from ' . $photo);
require_once("include/Photo.php");
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;
}
$cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- if ($cid) {
+ if($cid) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($cid),
intval(local_user())
$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())
);
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)
// 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);
function dfrn_confirm_post(App $a, $handsfree = null) {
- if (is_array($handsfree)) {
+ if(is_array($handsfree)) {
/*
* We were called directly from dfrn_request due to automatic friend acceptance.
}
else {
- if ($a->argc > 1)
+ if($a->argc > 1)
$node = $a->argv[1];
}
*
*/
- if (! x($_POST,'source_url')) {
+ if(! x($_POST,'source_url')) {
$uid = ((is_array($handsfree)) ? $handsfree['uid'] : local_user());
- if (! $uid) {
+ if(! $uid) {
notice( t('Permission denied.') . EOL );
return;
}
intval($uid)
);
- if (! $user) {
+ if(! $user) {
notice( t('Profile not found.') . EOL );
return;
}
// These data elements may come from either the friend request notification form or $handsfree array.
- if (is_array($handsfree)) {
+ if(is_array($handsfree)) {
logger('Confirm in handsfree mode');
$dfrn_id = $handsfree['dfrn_id'];
$intro_id = $handsfree['intro_id'];
*
*/
- if (strlen($dfrn_id))
+ if(strlen($dfrn_id))
$cid = 0;
logger('Confirming request for dfrn_id (issued) ' . $dfrn_id);
- if ($cid)
+ if($cid)
logger('Confirming follower with contact_id: ' . $cid);
$network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS);
- if ($contact['network'])
+ if($contact['network'])
$network = $contact['network'];
- if ($network === NETWORK_DFRN) {
+ if($network === NETWORK_DFRN) {
/*
*
openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey);
$params['source_url'] = bin2hex($params['source_url']);
- if ($aes_allow && function_exists('openssl_encrypt')) {
+ if($aes_allow && function_exists('openssl_encrypt')) {
openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey);
$params['aes_key'] = bin2hex($params['aes_key']);
$params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key));
}
$params['dfrn_version'] = DFRN_PROTOCOL_VERSION ;
- if ($duplex == 1)
+ if($duplex == 1)
$params['duplex'] = 1;
- if ($user[0]['page-flags'] == PAGE_COMMUNITY)
+ if($user[0]['page-flags'] == PAGE_COMMUNITY)
$params['page'] = 1;
- if ($user[0]['page-flags'] == PAGE_PRVGROUP)
+ if($user[0]['page-flags'] == PAGE_PRVGROUP)
$params['page'] = 2;
logger('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA);
$leading_junk = substr($res,0,strpos($res,'<?xml'));
$res = substr($res,strpos($res,'<?xml'));
- if (! strlen($res)) {
+ if(! strlen($res)) {
// No XML at all, this exchange is messed up really bad.
// We shouldn't proceed, because the xml parser might choke,
return;
}
- if (strlen($leading_junk) && get_config('system','debugging')) {
+ if(strlen($leading_junk) && get_config('system','debugging')) {
// This might be more common. Mixed error text and some XML.
// If we're configured for debugging, show the text. Proceed in either case.
notice( t('Unexpected response from remote site: ') . EOL . $leading_junk . EOL );
}
- if (stristr($res, "<status")===false) {
+ if(stristr($res, "<status")===false) {
// wrong xml! stop here!
notice( t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL );
return;
switch($status) {
case 0:
info( t("Confirmation completed successfully.") . EOL);
- if (strlen($message))
+ if(strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
case 1:
case 2:
notice( t("Temporary failure. Please wait and try again.") . EOL);
- if (strlen($message))
+ if(strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
case 3:
notice( t("Introduction failed or was revoked.") . EOL);
- if (strlen($message))
+ if(strlen($message))
notice( t('Remote site reported: ') . $message . EOL);
break;
}
- if (($status == 0) && ($intro_id)) {
+ if(($status == 0) && ($intro_id)) {
// Success. Delete the notification.
}
- if ($status != 0)
+ if($status != 0)
return;
}
logger('dfrn_confirm: confirm - imported photos');
- if ($network === NETWORK_DFRN) {
+ if($network === NETWORK_DFRN) {
$new_relation = CONTACT_IS_FOLLOWER;
- if (($relation == CONTACT_IS_SHARING) || ($duplex))
+ if(($relation == CONTACT_IS_SHARING) || ($duplex))
$new_relation = CONTACT_IS_FRIEND;
- if (($relation == CONTACT_IS_SHARING) && ($duplex))
+ if(($relation == CONTACT_IS_SHARING) && ($duplex))
$duplex = 0;
$r = q("UPDATE `contact` SET `rel` = %d,
dbesc(NETWORK_DFRN),
intval($contact_id)
);
- } else {
+ }
+ else {
// $network !== NETWORK_DFRN
$notify = (($contact['notify']) ? $contact['notify'] : '');
$poll = (($contact['poll']) ? $contact['poll'] : '');
- if ((! $contact['notify']) || (! $contact['poll'])) {
+ if((! $contact['notify']) || (! $contact['poll'])) {
$arr = Probe::lrdd($contact['url']);
- if (count($arr)) {
- foreach ($arr as $link) {
- if ($link['@attributes']['rel'] === 'salmon')
+ if(count($arr)) {
+ foreach($arr as $link) {
+ if($link['@attributes']['rel'] === 'salmon')
$notify = $link['@attributes']['href'];
- if ($link['@attributes']['rel'] === NAMESPACE_FEED)
+ if($link['@attributes']['rel'] === NAMESPACE_FEED)
$poll = $link['@attributes']['href'];
}
}
$new_relation = $contact['rel'];
$writable = $contact['writable'];
- if ($network === NETWORK_DIASPORA) {
- if ($duplex)
+ if($network === NETWORK_DIASPORA) {
+ if($duplex)
$new_relation = CONTACT_IS_FRIEND;
else
$new_relation = CONTACT_IS_FOLLOWER;
- if ($new_relation != CONTACT_IS_FOLLOWER)
+ if($new_relation != CONTACT_IS_FOLLOWER)
$writable = 1;
}
intval($uid)
);
- if ((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
+ if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) {
require_once('include/items.php');
intval($uid)
);
- if (count($self)) {
+ if(count($self)) {
$arr = array();
$arr['guid'] = get_guid(32);
$arr['deny_gid'] = $user[0]['deny_gid'];
$i = item_store($arr);
- if ($i)
+ if($i)
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
}
}
}
$def_gid = get_default_group($uid, $contact["network"]);
- if ($contact && intval($def_gid))
+ if($contact && intval($def_gid))
group_add_member($uid, '', $contact['id'], $def_gid);
// Let's send our user to the contact editor in case they want to
$local_uid = $r[0]['uid'];
- if (! strstr($my_prvkey,'PRIVATE KEY')) {
+ if(! strstr($my_prvkey,'PRIVATE KEY')) {
$message = t('Our site encryption key is apparently messed up.');
xml_status(3,$message);
}
openssl_private_decrypt($source_url,$decrypted_source_url,$my_prvkey);
- if (! strlen($decrypted_source_url)) {
+ if(! strlen($decrypted_source_url)) {
$message = t('Empty site URL was provided or URL could not be decrypted by us.');
xml_status(3,$message);
// NOTREACHED
dbesc($decrypted_source_url),
intval($local_uid)
);
- if (!dbm::is_result($ret)) {
- if (strstr($decrypted_source_url,'http:')) {
+ if(! count($ret)) {
+ if(strstr($decrypted_source_url,'http:'))
$newurl = str_replace('http:','https:',$decrypted_source_url);
- } else {
+ else
$newurl = str_replace('https:','http:',$decrypted_source_url);
- }
$ret = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
dbesc($newurl),
intval($local_uid)
);
- if (!dbm::is_result($ret)) {
+ if(! count($ret)) {
// this is either a bogus confirmation (?) or we deleted the original introduction.
$message = t('Contact record was not found for you on our site.');
xml_status(3,$message);
$foreign_pubkey = $ret[0]['site-pubkey'];
$dfrn_record = $ret[0]['id'];
- if (! $foreign_pubkey) {
+ if(! $foreign_pubkey) {
$message = sprintf( t('Site public key not available in contact record for URL %s.'), $newurl);
xml_status(3,$message);
}
$decrypted_dfrn_id = "";
openssl_public_decrypt($dfrn_id,$decrypted_dfrn_id,$foreign_pubkey);
- if (strlen($aes_key)) {
+ if(strlen($aes_key)) {
$decrypted_aes_key = "";
openssl_private_decrypt($aes_key,$decrypted_aes_key,$my_prvkey);
$dfrn_pubkey = openssl_decrypt($public_key,'AES-256-CBC',$decrypted_aes_key);
// It's possible that the other person also requested friendship.
// If it is a duplex relationship, ditch the issued-id if one exists.
- if ($duplex) {
+ if($duplex) {
$r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d",
intval($dfrn_record)
);
if (dbm::is_result($r))
$combined = $r[0];
- if ((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
+ if((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) {
$mutual = ($new_relation == CONTACT_IS_FRIEND);
notification(array(
'type' => NOTIFY_CONFIRM,
// Send a new friend post if we are allowed to...
- if ($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) {
+ if($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) {
$r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
intval($local_uid)
);
- if ((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
+ if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) {
require_once('include/items.php');
intval($local_uid)
);
- if (dbm::is_result($self)) {
+ if(count($self)) {
$arr = array();
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid);
$arr['deny_gid'] = $user[0]['deny_gid'];
$i = item_store($arr);
- if ($i) {
+ if($i)
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
- }
}
}
$prv = (($page == 2) ? 1 : 0);
$writable = (-1);
- if ($dfrn_version >= 2.21) {
+ if($dfrn_version >= 2.21) {
$writable = (($perm === 'rw') ? 1 : 0);
}
$direction = (-1);
- if (strpos($dfrn_id,':') == 1) {
+ if(strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
logger("Remote rino version: ".$rino_remote." for ".$importer["url"], LOGGER_DEBUG);
- if ((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
+ if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d",
intval(($writable == (-1)) ? $importer['writable'] : $writable),
intval($forum),
intval($prv),
intval($importer['id'])
);
- if ($writable != (-1))
+ if($writable != (-1))
$importer['writable'] = $writable;
$importer['forum'] = $page;
}
logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']);
logger('dfrn_notify: data: ' . $data, LOGGER_DATA);
- if ($dissolve == 1) {
+ if($dissolve == 1) {
/*
* Relationship is dissolved permanently
// If we are setup as a soapbox we aren't accepting input from this person
// This behaviour is deactivated since it really doesn't make sense to even disallow comments
// The check if someone is a friend or simply a follower is done in a later place so it needn't to be done here
- //if ($importer['page-flags'] == PAGE_SOAPBOX)
+ //if($importer['page-flags'] == PAGE_SOAPBOX)
// xml_status(0);
$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);
- if (strlen($key)) {
+ if(strlen($key)) {
// if local rino is lower than remote rino, abort: should not happen!
// but only for $remote_rino > 1, because old code did't send rino version
logger('rino: md5 raw key: ' . md5($rawkey));
$final_key = '';
- if ($dfrn_version >= 2.1) {
- if ((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) {
+ if($dfrn_version >= 2.1) {
+ if((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) {
openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']);
}
else {
}
}
else {
- if ((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) {
+ if((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) {
openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']);
}
else {
function dfrn_notify_content(App $a) {
- if (x($_GET,'dfrn_id')) {
+ if(x($_GET,'dfrn_id')) {
// initial communication from external contact, $direction is their direction.
// If this is a duplex communication, ours will be the opposite.
logger('dfrn_notify: new notification dfrn_id=' . $dfrn_id);
$direction = (-1);
- if (strpos($dfrn_id,':') == 1) {
+ if(strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
$pub_key = trim($r[0]['pubkey']);
$dplx = intval($r[0]['duplex']);
- if ((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) {
+ if((($dplx) && (strlen($prv_key))) || ((strlen($prv_key)) && (!(strlen($pub_key))))) {
openssl_private_encrypt($hash,$challenge,$prv_key);
openssl_private_encrypt($id_str,$encrypted_id,$prv_key);
- } elseif (strlen($pub_key)) {
+ }
+ elseif(strlen($pub_key)) {
openssl_public_encrypt($hash,$challenge,$pub_key);
openssl_public_encrypt($id_str,$encrypted_id,$pub_key);
- } else {
- $status = 1;
}
+ else
+ $status = 1;
$challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id);
$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);
// if requested rino is higher than enabled local rino, reply with local rino
if ($rino_remote < $rino) $rino = $rino_remote;
- if ((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
+ if((($r[0]['rel']) && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
$perm = 'rw';
- } else {
+ }
+ else {
$perm = 'r';
}
$direction = (-1);
- if (strpos($dfrn_id,':') == 1) {
+ if(strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
$hidewall = false;
- if (($dfrn_id === '') && (! x($_POST,'dfrn_id'))) {
- if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if(($dfrn_id === '') && (! x($_POST,'dfrn_id'))) {
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
http_status_exit(403);
}
$user = '';
- if ($a->argc > 1) {
+ if($a->argc > 1) {
$r = q("SELECT `hidewall`,`nickname` FROM `user` WHERE `user`.`nickname` = '%s' LIMIT 1",
dbesc($a->argv[1])
);
killme();
}
- if (($type === 'profile') && (! strlen($sec))) {
+ if(($type === 'profile') && (! strlen($sec))) {
$sql_extra = '';
switch($direction) {
logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA);
- if (strlen($s)) {
+ if(strlen($s)) {
$xml = parse_xml_string($s);
- if ((int) $xml->status == 1) {
+ if((int) $xml->status == 1) {
$_SESSION['authenticated'] = 1;
- if (! x($_SESSION,'remote'))
+ if(! x($_SESSION,'remote'))
$_SESSION['remote'] = array();
$_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']);
$_SESSION['visitor_home'] = $r[0]['url'];
$_SESSION['visitor_handle'] = $r[0]['addr'];
$_SESSION['visitor_visiting'] = $r[0]['uid'];
- if (!$quiet)
+ if(!$quiet)
info( sprintf(t('%1$s welcomes %2$s'), $r[0]['username'] , $r[0]['name']) . EOL);
// Visitors get 1 day session.
$session_id = session_id();
}
- if ($type === 'profile-check' && $dfrn_version < 2.2 ) {
+ if($type === 'profile-check' && $dfrn_version < 2.2 ) {
- if ((strlen($challenge)) && (strlen($sec))) {
+ if((strlen($challenge)) && (strlen($sec))) {
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
// NOTREACHED
}
$orig_id = $r[0]['dfrn_id'];
- if (strpos($orig_id, ':'))
+ if(strpos($orig_id, ':'))
$orig_id = substr($orig_id,2);
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
$final_dfrn_id = '';
- if (($contact['duplex']) && strlen($contact['prvkey'])) {
+ if(($contact['duplex']) && strlen($contact['prvkey'])) {
openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']);
openssl_private_decrypt($challenge,$decoded_challenge,$contact['prvkey']);
}
$final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
- if (strpos($final_dfrn_id,':') == 1)
+ if(strpos($final_dfrn_id,':') == 1)
$final_dfrn_id = substr($final_dfrn_id,2);
- if ($final_dfrn_id != $orig_id) {
+ if($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
// did not decode properly - cannot trust this site
xml_status(3, 'Bad decryption');
$dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
$perm = ((x($_POST,'perm')) ? $_POST['perm'] : 'r');
- if ($ptype === 'profile-check') {
+ if($ptype === 'profile-check') {
- if ((strlen($challenge)) && (strlen($sec))) {
+ if((strlen($challenge)) && (strlen($sec))) {
logger('dfrn_poll: POST: profile-check');
// NOTREACHED
}
$orig_id = $r[0]['dfrn_id'];
- if (strpos($orig_id, ':'))
+ if(strpos($orig_id, ':'))
$orig_id = substr($orig_id,2);
$c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
$final_dfrn_id = '';
- if (($contact['duplex']) && strlen($contact['prvkey'])) {
+ if(($contact['duplex']) && strlen($contact['prvkey'])) {
openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']);
openssl_private_decrypt($challenge,$decoded_challenge,$contact['prvkey']);
}
$final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
- if (strpos($final_dfrn_id,':') == 1)
+ if(strpos($final_dfrn_id,':') == 1)
$final_dfrn_id = substr($final_dfrn_id,2);
- if ($final_dfrn_id != $orig_id) {
+ if($final_dfrn_id != $orig_id) {
logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG);
// did not decode properly - cannot trust this site
xml_status(3, 'Bad decryption');
}
$direction = (-1);
- if (strpos($dfrn_id,':') == 1) {
+ if(strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
$contact_id = $r[0]['id'];
- if ($type === 'reputation' && strlen($url)) {
+ if($type === 'reputation' && strlen($url)) {
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
dbesc($url),
intval($owner_uid)
$reputation = $r[0]['rating'];
$text = $r[0]['reason'];
- if ($r[0]['id'] == $contact_id) { // inquiring about own reputation not allowed
+ if($r[0]['id'] == $contact_id) { // inquiring about own reputation not allowed
$reputation = 0;
$text = '';
}
// Update the writable flag if it changed
logger('dfrn_poll: post request feed: ' . print_r($_POST,true),LOGGER_DATA);
- if ($dfrn_version >= 2.21) {
- if ($perm === 'rw')
+ if($dfrn_version >= 2.21) {
+ if($perm === 'rw')
$writable = 1;
else
$writable = 0;
- if ($writable != $contact['writable']) {
+ if($writable != $contact['writable']) {
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d",
intval($writable),
intval($contact_id)
$quiet = ((x($_GET,'quiet')) ? true : false);
$direction = (-1);
- if (strpos($dfrn_id,':') == 1) {
+ if(strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
$dfrn_id = substr($dfrn_id,2);
}
- if ($dfrn_id != '') {
+ if($dfrn_id != '') {
// initial communication from external contact
$hash = random_string();
$r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time()));
- if ($type !== 'profile') {
+ if($type !== 'profile') {
$r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` )
VALUES( '%s', '%s', '%s', '%s', '%s' ) ",
dbesc($hash),
$sql_extra = '';
switch($direction) {
case (-1):
- if ($type === 'profile')
+ if($type === 'profile')
$sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", dbesc($dfrn_id),dbesc($dfrn_id));
else
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id));
$encrypted_id = '';
$id_str = $my_id . '.' . mt_rand(1000,9999);
- if (($r[0]['duplex'] && strlen($r[0]['pubkey'])) || (! strlen($r[0]['prvkey']))) {
+ if(($r[0]['duplex'] && strlen($r[0]['pubkey'])) || (! strlen($r[0]['prvkey']))) {
openssl_public_encrypt($hash,$challenge,$r[0]['pubkey']);
openssl_public_encrypt($id_str,$encrypted_id,$r[0]['pubkey']);
}
$encrypted_id = '';
}
- if (($type === 'profile') && (strlen($sec))) {
+ if(($type === 'profile') && (strlen($sec))) {
// URL reply
- if ($dfrn_version < 2.2) {
+ if($dfrn_version < 2.2) {
$s = fetch_url($r[0]['poll']
. '?dfrn_id=' . $encrypted_id
. '&type=profile-check'
logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA);
- if (strlen($s) && strstr($s,'<?xml')) {
+ if(strlen($s) && strstr($s,'<?xml')) {
$xml = parse_xml_string($s);
logger('dfrn_poll: secure profile: sec: ' . $xml->sec . ' expecting ' . $sec);
- if (((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) {
+ if(((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) {
$_SESSION['authenticated'] = 1;
- if (! x($_SESSION,'remote'))
+ if(! x($_SESSION,'remote'))
$_SESSION['remote'] = array();
$_SESSION['remote'][] = array('cid' => $r[0]['id'],'uid' => $r[0]['uid'],'url' => $r[0]['url']);
$_SESSION['visitor_id'] = $r[0]['id'];
$_SESSION['visitor_home'] = $r[0]['url'];
$_SESSION['visitor_visiting'] = $r[0]['uid'];
- if (!$quiet)
+ if(!$quiet)
info( sprintf(t('%1$s welcomes %2$s'), $r[0]['username'] , $r[0]['name']) . EOL);
// Visitors get 1 day session.
$session_id = session_id();
function dfrn_request_init(App $a) {
- if ($a->argc > 1)
+ if($a->argc > 1)
$which = $a->argv[1];
profile_load($a,$which);
*/
function dfrn_request_post(App $a) {
- if (($a->argc != 2) || (! count($a->profile))) {
+ if(($a->argc != 2) || (! count($a->profile))) {
logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile));
return;
}
- if (x($_POST, 'cancel')) {
+ if(x($_POST, 'cancel')) {
goaway(z_root());
}
*
*/
- if ((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) {
+ if((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) {
/*
* Ensure this is a valid request
*/
- if (local_user() && ($a->user['nickname'] == $a->argv[1]) && (x($_POST,'dfrn_url'))) {
+ if(local_user() && ($a->user['nickname'] == $a->argv[1]) && (x($_POST,'dfrn_url'))) {
$dfrn_url = notags(trim($_POST['dfrn_url']));
$blocked = 1;
$pending = 1;
- if (x($dfrn_url)) {
+ if(x($dfrn_url)) {
/*
* Lookup the contact based on their URL (which is the only unique thing we have at the moment)
);
if (dbm::is_result($r)) {
- if (strlen($r[0]['dfrn-id'])) {
+ if(strlen($r[0]['dfrn-id'])) {
/*
* We don't need to be here. It has already happened.
$contact_record = $r[0];
}
- if (is_array($contact_record)) {
+ if(is_array($contact_record)) {
$r = q("UPDATE `contact` SET `ret-aes` = %d, hidden = %d WHERE `id` = %d",
intval($aes_allow),
intval($hidden),
);
if (dbm::is_result($r)) {
$def_gid = get_default_group(local_user(), $r[0]["network"]);
- if (intval($def_gid))
+ if(intval($def_gid))
group_add_member(local_user(), '', $r[0]['id'], $def_gid);
if (isset($photo))
*
*/
- if (! (is_array($a->profile) && count($a->profile))) {
+ if(! (is_array($a->profile) && count($a->profile))) {
notice( t('Profile unavailable.') . EOL);
return;
}
$pending = 1;
- if ( x($_POST,'dfrn_url')) {
+ if( x($_POST,'dfrn_url')) {
/*
* Block friend request spam
*/
- if ($maxreq) {
+ if($maxreq) {
$r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d",
dbesc(datetime_convert('UTC','UTC','now - 24 hours')),
intval($uid)
);
if (dbm::is_result($r)) {
foreach ($r as $rr) {
- if (! $rr['rel']) {
+ if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d AND NOT `self`",
intval($rr['cid'])
);
);
if (dbm::is_result($r)) {
foreach ($r as $rr) {
- if (! $rr['rel']) {
+ if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d AND NOT `self`",
intval($rr['cid'])
);
$real_name = (x($_POST,'realname') ? notags(trim($_POST['realname'])) : '');
$url = trim($_POST['dfrn_url']);
- if (! strlen($url)) {
+ if(! strlen($url)) {
notice( t("Invalid locator") . EOL );
return;
}
$hcard = '';
- if ($email_follow) {
+ if($email_follow) {
- if (! validate_email($url)) {
+ if(! validate_email($url)) {
notice( t('Invalid email address.') . EOL);
return;
}
$rel = CONTACT_IS_FOLLOWER;
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
- if (get_config('system','dfrn_only'))
+ if(get_config('system','dfrn_only'))
$mail_disabled = 1;
- if (! $mail_disabled) {
+ if(! $mail_disabled) {
$failed = false;
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($uid)
logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG);
- if ($network === NETWORK_DFRN) {
+ if($network === NETWORK_DFRN) {
$ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1",
intval($uid),
dbesc($url)
);
if (dbm::is_result($ret)) {
- if (strlen($ret[0]['issued-id'])) {
+ if(strlen($ret[0]['issued-id'])) {
notice( t('You have already introduced yourself here.') . EOL );
return;
}
- elseif ($ret[0]['rel'] == CONTACT_IS_FRIEND) {
+ elseif($ret[0]['rel'] == CONTACT_IS_FRIEND) {
notice( sprintf( t('Apparently you are already friends with %s.'), $a->profile['name']) . EOL);
return;
}
$issued_id = random_string();
- if (is_array($contact_record)) {
+ if(is_array($contact_record)) {
// There is a contact record but no issued-id, so this
// is a reciprocal introduction from a known contact
$r = q("UPDATE `contact` SET `issued-id` = '%s' WHERE `id` = %d",
return $o;
}
- elseif ((x($_GET,'confirm_key')) && strlen($_GET['confirm_key'])) {
+ elseif((x($_GET,'confirm_key')) && strlen($_GET['confirm_key'])) {
// we are the requestee and it is now safe to send our user their introduction,
// We could just unblock it, but first we have to jump through a few hoops to
$auto_confirm = false;
if (dbm::is_result($r)) {
- if (($r[0]['page-flags'] != PAGE_NORMAL) && ($r[0]['page-flags'] != PAGE_PRVGROUP))
+ if(($r[0]['page-flags'] != PAGE_NORMAL) && ($r[0]['page-flags'] != PAGE_PRVGROUP))
$auto_confirm = true;
- if (! $auto_confirm) {
+ if(! $auto_confirm) {
notification(array(
'type' => NOTIFY_INTRO,
));
}
- if ($auto_confirm) {
+ if($auto_confirm) {
require_once('mod/dfrn_confirm.php');
$handsfree = array(
'uid' => $r[0]['uid'],
}
- if (! $auto_confirm) {
+ if(! $auto_confirm) {
// If we are auto_confirming, this record will have already been nuked
// in dfrn_confirm_post()
* Normal web request. Display our user's introduction form.
*/
- if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
- if (! get_config('system','local_block')) {
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if(! get_config('system','local_block')) {
notice( t('Public access denied.') . EOL);
return;
}
function directory_init(App $a) {
$a->set_pager_itemspage(60);
- if (local_user()) {
+ if(local_user()) {
require_once('include/contact_widgets.php');
$a->page['aside'] .= findpeople_widget();
function directory_post(App $a) {
- if (x($_POST,'search'))
+ if(x($_POST,'search'))
$a->data['search'] = $_POST['search'];
}
require_once("mod/proxy.php");
- if ((get_config('system','block_public')) && (! local_user()) && (! remote_user()) ||
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user()) ||
(get_config('system','block_local_dir')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
return;
$o = '';
nav_set_selected('directory');
- if (x($a->data,'search'))
+ if(x($a->data,'search'))
$search = notags(trim($a->data['search']));
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
$gdirpath = '';
$dirurl = get_config('system','directory');
- if (strlen($dirurl)) {
+ if(strlen($dirurl)) {
$gdirpath = zrl($dirurl,true);
}
- if ($search) {
+ if($search) {
$search = dbesc($search);
$sql_extra = " AND ((`profile`.`name` LIKE '%$search%') OR
$pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
$details = '';
- if (strlen($rr['locality']))
+ if(strlen($rr['locality']))
$details .= $rr['locality'];
- if (strlen($rr['region'])) {
- if (strlen($rr['locality']))
+ if(strlen($rr['region'])) {
+ if(strlen($rr['locality']))
$details .= ', ';
$details .= $rr['region'];
}
- if (strlen($rr['country-name'])) {
- if (strlen($details))
+ if(strlen($rr['country-name'])) {
+ if(strlen($details))
$details .= ', ';
$details .= $rr['country-name'];
}
-// if (strlen($rr['dob'])) {
-// if (($years = age($rr['dob'],$rr['timezone'],'')) != 0)
+// if(strlen($rr['dob'])) {
+// if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
// $details .= '<br />' . t('Age: ') . $years ;
// }
-// if (strlen($rr['gender']))
+// if(strlen($rr['gender']))
// $details .= '<br />' . t('Gender: ') . $rr['gender'];
$profile = $rr;
- if ((x($profile,'address') == 1)
+ if((x($profile,'address') == 1)
|| (x($profile,'locality') == 1)
|| (x($profile,'region') == 1)
|| (x($profile,'postal-code') == 1)
$about = ((x($profile,'about') == 1) ? t('About:') : False);
- if ($a->theme['template_engine'] === 'internal') {
+ if($a->theme['template_engine'] === 'internal') {
$location_e = template_escape($location);
}
else {
unset($profile);
unset($location);
- if (! $arr['entry']) {
+ if(! $arr['entry'])
continue;
- }
$entries[] = $arr['entry'];
$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);
}
$tpl = get_markup_template("jot.tpl");
- if (($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))))
+ if(($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))))
$lockstate = 'lock';
else
$lockstate = 'unlock';
$mail_enabled = false;
$pubmail_enabled = false;
- if (! $mail_disabled) {
+ if(! $mail_disabled) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user())
);
if (dbm::is_result($r)) {
$mail_enabled = true;
- if (intval($r[0]['pubmail']))
+ if(intval($r[0]['pubmail']))
$pubmail_enabled = true;
}
}
// I don't think there's any need for the $jotnets when editing the post,
// and including them makes it difficult for the JS-free theme, so let's
// disable them
-/* if ($mail_enabled) {
+/* if($mail_enabled) {
$selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
$jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
. t("Post to Email") . '</div>';
$c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval(local_user())
);
- if (dbm::is_result($c)) {
+ if (count($c)) {
$self = $c[0]['id'];
} else {
$self = 0;
$str_contact_deny = perms2str($_POST['contact_deny']);
// Undo the pseudo-contact of self, since there are real contacts now
- if (strpos($str_contact_allow, '<' . $self . '>') !== false) {
+ if (strpos($str_contact_allow, '<' . $self . '>') !== false ) {
$str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow);
}
// Make sure to set the `private` field as true. This is necessary to
$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;
// 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'];}
$types = Photo::supportedTypes();
$ext = $types[$rr['type']];
- if ($a->theme['template_engine'] === 'internal') {
+ if($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']);
- } else {
+ }
+ else {
$filename_e = $rr['filename'];
}
logger('filer: tag ' . $term . ' item ' . $item_id);
- if ($item_id && strlen($term)){
+ if($item_id && strlen($term)){
// file item
file_tag_save_file(local_user(),$item_id,$term);
} else {
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
$sql_extra = '';
- if (x($a->config,'admin_nickname')) {
+ if(x($a->config,'admin_nickname')) {
$sql_extra = sprintf(" AND nickname = '%s' ",dbesc($a->config['admin_nickname']));
}
if (isset($a->config['admin_email']) && $a->config['admin_email']!=''){
}
$visible_plugins = array();
- if (is_array($a->plugins) && count($a->plugins)) {
+ if(is_array($a->plugins) && count($a->plugins)) {
$r = q("select * from addon where hidden = 0");
if (dbm::is_result($r))
- foreach ($r as $rr)
+ foreach($r as $rr)
$visible_plugins[] = $rr['name'];
}
Config::load('feature_lock');
$locked_features = array();
- if (is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
- foreach ($a->config['feature_lock'] as $k => $v) {
- if ($k === 'config_loaded')
+ if(is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
+ foreach($a->config['feature_lock'] as $k => $v) {
+ if($k === 'config_loaded')
continue;
$locked_features[$k] = intval($v);
}
$o .= '<p></p>';
$visible_plugins = array();
- if (is_array($a->plugins) && count($a->plugins)) {
+ if(is_array($a->plugins) && count($a->plugins)) {
$r = q("select * from addon where hidden = 0");
if (dbm::is_result($r))
- foreach ($r as $rr)
+ foreach($r as $rr)
$visible_plugins[] = $rr['name'];
}
- if (count($visible_plugins)) {
+ if(count($visible_plugins)) {
$o .= '<p>' . t('Installed plugins/addons/apps:') . '</p>';
$sorted = $visible_plugins;
$s = '';
sort($sorted);
- foreach ($sorted as $p) {
- if (strlen($p)) {
- if (strlen($s)) {
- $s .= ', ';
- }
+ foreach($sorted as $p) {
+ if(strlen($p)) {
+ if(strlen($s)) $s .= ', ';
$s .= $p;
}
}
$note = escape_tags(trim($_POST['note']));
- if ($new_contact) {
+ if($new_contact) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($new_contact),
intval(local_user())
return;
}
- if ($a->argc != 2) {
+ if($a->argc != 2)
return;
- }
$contact_id = intval($a->argv[1]);
}
function group_init(App $a) {
- if (local_user()) {
+ if(local_user()) {
require_once('include/group.php');
$a->page['aside'] = group_side('contacts','group','extended',(($a->argc > 1) ? intval($a->argv[1]) : 0));
}
return;
}
- if (($a->argc == 2) && ($a->argv[1] === 'new')) {
+ if(($a->argc == 2) && ($a->argv[1] === 'new')) {
check_form_security_token_redirectOnErr('/group/new', 'group_edit');
$name = notags(trim($_POST['groupname']));
// 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');
'$gid' => 'new',
'$form_security_token' => get_form_security_token("group_edit"),
));
+
+
}
if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
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]))) {
$group = $r[0];
$members = group_get_members($group['id']);
$preselected = array();
- if (count($members)) {
- foreach ($members as $member) {
+ if(count($members)) {
+ foreach($members as $member)
$preselected[] = $member['id'];
- }
}
- if ($change) {
- if (in_array($change,$preselected)) {
+ 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);
}
$members = group_get_members($group['id']);
$preselected = array();
- if (count($members)) {
- foreach ($members as $member)
+ if(count($members)) {
+ foreach($members as $member)
$preselected[] = $member['id'];
}
}
}
- if (! isset($group)) {
+ if(! isset($group))
return;
- }
$groupeditor = array(
'label_members' => t('Members'),
$sec_token = addslashes(get_form_security_token('group_member_change'));
$textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
- foreach ($members as $member) {
- if ($member['url']) {
+ foreach($members as $member) {
+ if($member['url']) {
$member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;';
$groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode);
- } else {
- group_rmv_member(local_user(),$group['name'],$member['id']);
}
+ else
+ group_rmv_member(local_user(),$group['name'],$member['id']);
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `self` ORDER BY `name` ASC",
if (dbm::is_result($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
- foreach ($r as $member) {
- if (! in_array($member['id'],$preselected)) {
+ foreach($r as $member) {
+ if(! in_array($member['id'],$preselected)) {
$member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . ',\'' . $sec_token . '\'); return true;';
$groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode);
}
$context['$groupeditor'] = $groupeditor;
$context['$desc'] = t('Click on a contact to add or remove.');
- if ($change) {
+ if($change) {
$tpl = get_markup_template('groupeditor.tpl');
echo replace_macros($tpl, $context);
killme();
$path = '';
// looping through the argv keys bigger than 0 to build
// a path relative to /help
- for ($x = 1; $x < argc(); $x ++) {
- if (strlen($path)) {
+ for($x = 1; $x < argc(); $x ++) {
+ if(strlen($path))
$path .= '/';
- }
$path .= argv($x);
}
$title = basename($path);
$toc="<style>aside ul {padding-left: 1em;}aside h1{font-size:2em}</style><h2>TOC</h2><ul id='toc'>";
$lastlevel=1;
$idnum = array(0,0,0,0,0,0,0);
- foreach ($lines as &$line){
+ foreach($lines as &$line){
if (substr($line,0,2)=="<h") {
$level = substr($line,2,1);
if ($level!="r") {
$level = intval($level);
if ($level<$lastlevel) {
- for ($k=$level;$k<$lastlevel; $k++) {
- $toc.="</ul>";
- }
- for ($k=$level+1;$k<count($idnum);$k++) {
- $idnum[$k]=0;
- }
- }
- if ($level>$lastlevel) {
- $toc.="<ul>";
+ for($k=$level;$k<$lastlevel; $k++) $toc.="</ul>";
+ for($k=$level+1;$k<count($idnum);$k++) $idnum[$k]=0;
}
+ if ($level>$lastlevel) $toc.="<ul>";
$idnum[$level]++;
$id = implode("_", array_slice($idnum,1,$level));
$href = App::get_baseurl()."/help/{$filename}#{$id}";
}
}
}
- for ($k=0;$k<$lastlevel; $k++) $toc.="</ul>";
+ for($k=0;$k<$lastlevel; $k++) $toc.="</ul>";
$html = implode("\n",$lines);
$a->page['aside'] = $toc.$a->page['aside'];
<?php
-if (! function_exists('home_init')) {
+if(! function_exists('home_init')) {
function home_init(App $a) {
$ret = array();
}}
-if (! function_exists('home_content')) {
+if(! function_exists('home_content')) {
function home_content(App $a) {
$o = '';
header("Content-type: text/xml");
$pubkey = get_config('system','site_pubkey');
- if (! $pubkey) {
+ if(! $pubkey) {
$res = new_keypair(1024);
set_config('system','site_prvkey', $res['prvkey']);
$datatype = (x($_REQUEST,'datatype') ?$_REQUEST['datatype'] : "json");
// Get out if the system doesn't have public access allowed
- if (intval(get_config('system','block_public')))
+ if(intval(get_config('system','block_public')))
http_status_exit(401);
// Return the raw content of the template. We use this to make templates usable for js functions.
// If a contact is connected the url is internally changed to "redir/CID". We need the pure url to search for
// the contact. So we strip out the contact id from the internal url and look in the contact table for
// the real url (nurl)
- if (local_user() && strpos($profileurl, "redir/") === 0) {
+ if(local_user() && strpos($profileurl, "redir/") === 0) {
$cid = intval(substr($profileurl, 6));
$r = q("SELECT `nurl`, `self` FROM `contact` WHERE `id` = '%d' LIMIT 1", intval($cid));
$profileurl = ($r[0]["nurl"] ? $r[0]["nurl"] : "");
// if it's the url containing https it should be converted to http
$nurl = normalise_link(clean_contact_url($profileurl));
- if ($nurl) {
+ if($nurl) {
// Search for contact data
$contact = get_contact_details_by_url($nurl);
}
- if (!is_array($contact))
+ if(!is_array($contact))
return;
// Get the photo_menu - the menu if possible contact actions
- if (local_user())
+ if(local_user())
$actions = contact_photo_menu($contact);
'account_type' => account_type($contact),
'actions' => $actions,
);
- if ($datatype == "html") {
+ if($datatype == "html") {
$t = get_markup_template("hovercard.tpl");
$o = replace_macros($t, array(
$filename = $t->filename;
// Get the content of the template file
- if (file_exists($filename)) {
+ if(file_exists($filename)) {
$content = file_get_contents($filename);
return $content;
$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);
}
require_once("include/dba.php");
unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true);
- /*if (get_db_errno()) {
+ /*if(get_db_errno()) {
unset($db);
$db = new dba($dbhost, $dbuser, $dbpass, '', true);
- if (! get_db_errno()) {
+ if(! get_db_errno()) {
$r = q("CREATE DATABASE '%s'",
dbesc($dbdata)
);
$db_return_text .= $txt;
}
- if ($db && $db->connected) {
+ if($db && $db->connected) {
$r = q("SELECT COUNT(*) as `total` FROM `user`");
if (dbm::is_result($r) && $r[0]['total']) {
$tpl = get_markup_template('install.tpl');
check_add($checks, t('Command line PHP').($passed?" (<tt>$phpath</tt>)":""), $passed, false, $help);
- if ($passed) {
+ if($passed) {
$cmd = "$phpath -v";
$result = trim(shell_exec($cmd));
$passed2 = ( strpos($result, "(cli)") !== false );
list($result) = explode("\n", $result);
$help = "";
- if (!$passed2) {
+ if(!$passed2) {
$help .= t('PHP executable is not the php cli binary (could be cgi-fgci version)'). EOL;
$help .= t('Found PHP version: ')."<tt>$result</tt>";
}
$result = trim(shell_exec($cmd));
$passed3 = $result == $str;
$help = "";
- if (!$passed3) {
+ if(!$passed3) {
$help .= t('The command line version of PHP on your system does not have "register_argc_argv" enabled.'). EOL;
$help .= t('This is required for message delivery to work.');
}
$ck_funcs[6]['help'] = t('Error, XML PHP module required but not installed.');
}
- /*if ((x($_SESSION,'sysmsg')) && is_array($_SESSION['sysmsg']) && count($_SESSION['sysmsg']))
+ /*if((x($_SESSION,'sysmsg')) && is_array($_SESSION['sysmsg']) && count($_SESSION['sysmsg']))
notice( t('Please see the file "INSTALL.txt".') . EOL);*/
}
/* $str = file_get_contents('database.sql');
$arr = explode(';',$str);
$errors = false;
- foreach ($arr as $a) {
- if (strlen(trim($a))) {
+ foreach($arr as $a) {
+ if(strlen(trim($a))) {
$r = @$db->q(trim($a));
- if (false === $r) {
+ if(false === $r) {
$errors .= t('Errors encountered creating database tables.') . $a . EOL;
}
}
$total ++;
$current_invites ++;
set_pconfig(local_user(),'system','sent_invites',$current_invites);
- if ($current_invites > $max_invites) {
+ if($current_invites > $max_invites) {
notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL);
return;
}
function item_post(App $a) {
- if ((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter')))
+ if((! local_user()) && (! remote_user()) && (! x($_REQUEST,'commenter')))
return;
require_once('include/security.php');
$uid = local_user();
- if (x($_REQUEST,'dropitems')) {
+ if(x($_REQUEST,'dropitems')) {
$arr_drop = explode(',',$_REQUEST['dropitems']);
drop_items($arr_drop);
$json = array('success' => 1);
$parent = $r[0]['id'];
// multi-level threading - preserve the info but re-parent to our single level threading
- //if (($parid) && ($parid != $parent))
+ //if(($parid) && ($parid != $parent))
$thr_parent = $parent_uri;
if ($parent_item['contact-id'] && $uid) {
}
}
- if ($parent) logger('mod_item: item_post parent=' . $parent);
+ if($parent) logger('mod_item: item_post parent=' . $parent);
$profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0);
$post_id = ((x($_REQUEST,'post_id')) ? intval($_REQUEST['post_id']) : 0);
// First check that the parent exists and it is a wall item.
- if ((x($_REQUEST,'commenter')) && ((! $parent) || (! $parent_item['wall']))) {
+ if((x($_REQUEST,'commenter')) && ((! $parent) || (! $parent_item['wall']))) {
notice( t('Permission denied.') . EOL) ;
- if (x($_REQUEST,'return'))
+ if(x($_REQUEST,'return'))
goaway($return_path);
killme();
}
- if ((! can_write_wall($a,$profile_uid)) && (! $allow_moderated)) {
+ if((! can_write_wall($a,$profile_uid)) && (! $allow_moderated)) {
notice( t('Permission denied.') . EOL) ;
- if (x($_REQUEST,'return'))
+ if(x($_REQUEST,'return'))
goaway($return_path);
killme();
}
$orig_post = null;
- if ($post_id) {
+ if($post_id) {
$i = q("SELECT * FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($profile_uid),
intval($post_id)
if (dbm::is_result($r))
$user = $r[0];
- if ($orig_post) {
+ if($orig_post) {
$str_group_allow = $orig_post['allow_gid'];
$str_contact_allow = $orig_post['allow_cid'];
$str_group_deny = $orig_post['deny_gid'];
// use the user default permissions - as they won't have
// been supplied via a form.
- if (($api_source)
+ if(($api_source)
&& (! array_key_exists('contact_allow',$_REQUEST))
&& (! array_key_exists('group_allow',$_REQUEST))
&& (! array_key_exists('contact_deny',$_REQUEST))
$private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
- if ($user['hidewall'])
+ if($user['hidewall'])
$private = 2;
// If this is a comment, set the permissions from the parent.
- if ($parent_item) {
+ if($parent_item) {
// for non native networks use the network of the original post as network of the item
if (($parent_item['network'] != NETWORK_DIASPORA)
// if using the API, we won't see pubmail_enable - figure out if it should be set
- if ($api_source && $profile_uid && $profile_uid == local_user() && (! $private)) {
+ if($api_source && $profile_uid && $profile_uid == local_user() && (! $private)) {
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
- if (! $mail_disabled) {
+ if(! $mail_disabled) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user())
);
}
}
- if (! strlen($body)) {
- if ($preview)
+ if(! strlen($body)) {
+ if($preview)
killme();
info( t('Empty post discarded.') . EOL );
- if (x($_REQUEST,'return'))
+ if(x($_REQUEST,'return'))
goaway($return_path);
killme();
}
}
- if (strlen($categories)) {
+ if(strlen($categories)) {
// get the "fileas" tags for this post
$filedas = file_tag_file_to_list($categories, 'file');
}
$categories_old = $categories;
$categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category');
$categories_new = $categories;
- if (strlen($filedas)) {
+ if(strlen($filedas)) {
// append the fileas stuff to the new categories list
$categories .= file_tag_list_to_file($filedas, 'file');
}
$self = false;
$contact_id = 0;
- if ((local_user()) && (local_user() == $profile_uid)) {
+ if((local_user()) && (local_user() == $profile_uid)) {
$self = true;
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval($_SESSION['uid']));
}
- elseif (remote_user()) {
- if (is_array($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $v) {
- if ($v['uid'] == $profile_uid) {
+ elseif(remote_user()) {
+ if(is_array($_SESSION['remote'])) {
+ foreach($_SESSION['remote'] as $v) {
+ if($v['uid'] == $profile_uid) {
$contact_id = $v['cid'];
break;
}
}
}
- if ($contact_id) {
+ if($contact_id) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($contact_id)
);
// get contact info for owner
- if ($profile_uid == local_user()) {
+ if($profile_uid == local_user()) {
$contact_record = $author;
}
else {
$post_type = notags(trim($_REQUEST['type']));
- if ($post_type === 'net-comment') {
- if ($parent_item !== null) {
- if ($parent_item['wall'] == 1)
+ if($post_type === 'net-comment') {
+ if($parent_item !== null) {
+ if($parent_item['wall'] == 1)
$post_type = 'wall-comment';
else
$post_type = 'remote-comment';
$match = null;
- if ((! $preview) && preg_match_all("/\[img([\=0-9x]*?)\](.*?)\[\/img\]/",$body,$match)) {
+ if((! $preview) && preg_match_all("/\[img([\=0-9x]*?)\](.*?)\[\/img\]/",$body,$match)) {
$images = $match[2];
- if (count($images)) {
+ if(count($images)) {
$objecttype = ACTIVITY_OBJ_IMAGE;
$match = false;
- if ((! $preview) && preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) {
+ if((! $preview) && preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) {
$attaches = $match[1];
- if (count($attaches)) {
- foreach ($attaches as $attach) {
+ if(count($attaches)) {
+ foreach($attaches as $attach) {
$r = q("SELECT * FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($profile_uid),
intval($attach)
$private_forum = false;
- if (count($tags)) {
- foreach ($tags as $tag) {
+ 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
$fullnametagged = false;
- for ($x = 0; $x < count($tagged); $x ++) {
- if (stristr($tagged[$x],$tag . ' ')) {
+ for($x = 0; $x < count($tagged); $x ++) {
+ if(stristr($tagged[$x],$tag . ' ')) {
$fullnametagged = true;
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']) {
$datarray['last-child'] = 1;
$datarray['visible'] = 1;
- if ($orig_post) {
+ if($orig_post)
$datarray['edit'] = true;
- }
// Search for hashtags
item_body_set_hashtags($datarray);
// preview mode - prepare the body for display and send it via json
- if ($preview) {
+ if($preview) {
require_once('include/conversation.php');
// We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID.
call_hooks('post_local',$datarray);
- if (x($datarray,'cancel')) {
+ if(x($datarray,'cancel')) {
logger('mod_item: post cancelled by plugin.');
- if ($return_path) {
+ if($return_path) {
goaway($return_path);
}
// Fill the cache field
put_item_in_cache($datarray);
- if ($orig_post) {
+ if($orig_post) {
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($datarray['title']),
dbesc($datarray['body']),
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
proc_run(PRIORITY_HIGH, "include/notifier.php", 'edit_post', $post_id);
- if ((x($_REQUEST,'return')) && strlen($return_path)) {
+ if((x($_REQUEST,'return')) && strlen($return_path)) {
logger('return: ' . $return_path);
goaway($return_path);
}
// update filetags in pconfig
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
- if ($parent) {
+ if($parent) {
// This item is the last leaf and gets the comment box, clear any ancestors
$r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d AND `last-child` AND `id` != %d",
intval($parent)
);
- if ($contact_record != $author) {
+ if($contact_record != $author) {
notification(array(
'type' => NOTIFY_COMMENT,
'notify_flags' => $user['notify-flags'],
intval($parent),
intval($post_id));
- if ($contact_record != $author) {
+ if($contact_record != $author) {
notification(array(
'type' => NOTIFY_WALL,
'notify_flags' => $user['notify-flags'],
'to_email' => $user['email'],
'uid' => $user['uid'],
'item' => $datarray,
- 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
+ 'link' => App::get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
call_hooks('post_local_end', $datarray);
- if (strlen($emailcc) && $profile_uid == local_user()) {
+ if(strlen($emailcc) && $profile_uid == local_user()) {
$erecips = explode(',', $emailcc);
- if (count($erecips)) {
- foreach ($erecips as $recip) {
+ if(count($erecips)) {
+ foreach($erecips as $recip) {
$addr = trim($recip);
- if (! strlen($addr))
+ if(! strlen($addr))
continue;
$disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
. '<br />';
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);
$r = q("SELECT `alias`, `name` FROM `contact` WHERE `nurl` = '%s' AND `alias` != '' AND `uid` = 0",
normalise_link($matches[1]));
-
- if (!dbm::is_result($r)) {
+ if (!$r)
$r = q("SELECT `alias`, `name` FROM `gcontact` WHERE `nurl` = '%s' AND `alias` != ''",
normalise_link($matches[1]));
-
- }
- if (dbm::is_result($r)) {
+ if ($r)
$data = $r[0];
- } else {
+ else
$data = probe_url($matches[1]);
- }
if ($data["alias"] != "") {
$newtag = '@[url='.$data["alias"].']'.$data["name"].'[/url]';
- if (!stristr($str_tags,$newtag)) {
- if (strlen($str_tags)) {
+ if(!stristr($str_tags,$newtag)) {
+ if(strlen($str_tags))
$str_tags .= ',';
- }
$str_tags .= $newtag;
}
}
);
// Then check in the contact table for the url
- if (!dbm::is_result($r)) {
+ if (!$r)
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `contact`
WHERE `nurl` = '%s' AND `uid` = %d AND
(`network` != '%s' OR (`notify` != '' AND `alias` != ''))
intval($profile_uid),
dbesc(NETWORK_OSTATUS)
);
- }
// Then check in the global contacts for the address
if (!$r)
);
// Then check in the global contacts for the url
- if (!dbm::is_result($r)) {
+ if (!$r)
$r = q("SELECT `url`, `nick`, `name`, `alias`, `network`, `notify` FROM `gcontact`
WHERE `nurl` = '%s' AND (`network` != '%s' OR (`notify` != '' AND `alias` != ''))
LIMIT 1",
dbesc(normalise_link($name)),
dbesc(NETWORK_OSTATUS)
);
- }
- if (!dbm::is_result($r)) {
+ if (!$r) {
$probed = probe_url($name);
if ($result['network'] != NETWORK_PHANTOM) {
update_gcontact($probed);
}
//select someone by attag or nick and the name passed in the current network
- if (!dbm::is_result($r) AND ($network != "")) {
+ if(!$r AND ($network != ""))
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
dbesc($name),
dbesc($name),
dbesc($network),
intval($profile_uid)
);
- }
//select someone from this user's contacts by name in the current network
- if (!dbm::is_result($r) AND ($network != "")) {
+ if (!$r AND ($network != ""))
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
dbesc($name),
dbesc($network),
intval($profile_uid)
);
- }
//select someone by attag or nick and the name passed in
- if (!dbm::is_result($r)) {
+ if(!$r)
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
dbesc($name),
dbesc($name),
intval($profile_uid)
);
- }
+
//select someone from this user's contacts by name
- if (!dbm::is_result($r)) {
+ if(!$r)
$r = q("SELECT `id`, `url`, `nick`, `name`, `alias`, `network` FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
dbesc($name),
intval($profile_uid)
);
- }
}
- if (dbm::is_result($r)) {
- if (strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"]))) {
+ if ($r) {
+ if(strlen($inform) AND (isset($r[0]["notify"]) OR isset($r[0]["id"])))
$inform .= ',';
- }
- if (isset($r[0]["id"])) {
+ if (isset($r[0]["id"]))
$inform .= 'cid:' . $r[0]["id"];
- } elseif (isset($r[0]["notify"])) {
+ elseif (isset($r[0]["notify"]))
$inform .= $r[0]["notify"];
- }
$profile = $r[0]["url"];
$alias = $r[0]["alias"];
$newname = $r[0]["nick"];
if (($newname == "") OR (($r[0]["network"] != NETWORK_OSTATUS) AND ($r[0]["network"] != NETWORK_TWITTER)
- AND ($r[0]["network"] != NETWORK_STATUSNET) AND ($r[0]["network"] != NETWORK_APPNET))) {
+ AND ($r[0]["network"] != NETWORK_STATUSNET) AND ($r[0]["network"] != NETWORK_APPNET)))
$newname = $r[0]["name"];
- }
}
//if there is an url for this persons profile
$newtag = '@[url='.$profile.']'.$newname.'[/url]';
$body = str_replace('@'.$name, $newtag, $body);
//append tag to str_tags
- if (! stristr($str_tags,$newtag)) {
- if (strlen($str_tags)) {
+ if(! stristr($str_tags,$newtag)) {
+ if(strlen($str_tags))
$str_tags .= ',';
- }
$str_tags .= $newtag;
}
// Status.Net seems to require the numeric ID URL in a mention if the person isn't
// subscribed to you. But the nickname URL is OK if they are. Grrr. We'll tag both.
- if (strlen($alias)) {
+ if(strlen($alias)) {
$newtag = '@[url='.$alias.']'.$newname.'[/url]';
- if (! stristr($str_tags,$newtag)) {
- if (strlen($str_tags)) {
+ if(! stristr($str_tags,$newtag)) {
+ if(strlen($str_tags))
$str_tags .= ',';
- }
$str_tags .= $newtag;
}
}
require_once('include/like.php');
function like_content(App $a) {
- if (! local_user() && ! remote_user()) {
+ if(! local_user() && ! remote_user()) {
return false;
}
$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'] : '');
function like_content_return($baseurl, $return_path) {
- if ($return_path) {
+ if($return_path) {
$rand = '_=' . time();
- if (strpos($return_path, '?')) {
- $rand = "&$rand";
- } else {
- $rand = "?$rand";
- }
+ if(strpos($return_path, '?')) $rand = "&$rand";
+ else $rand = "?$rand";
goaway($baseurl . "/" . $return_path . $rand);
}
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>';
$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" >';
$item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
}
- if (! $item_id)
+ if(! $item_id)
killme();
if (!in_array($type, array('item','photo','event')))
call_hooks('lockview_content', $item);
- if ($item['uid'] != local_user()) {
+ if($item['uid'] != local_user()) {
echo t('Remote privacy information not available.') . '<br />';
killme();
}
- if (($item['private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid']))
+ if(($item['private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid']))
&& (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) {
echo t('Remote privacy information not available.') . '<br />';
$o = t('Visible to:') . '<br />';
$l = array();
- if (count($allowed_groups)) {
+ if(count($allowed_groups)) {
$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)) {
+ 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'];
- }
- }
}
- if (count($deny_groups)) {
+ if(count($deny_groups)) {
$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)) {
+ 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>';
- }
- }
}
<?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);
}
function lostpass_post(App $a) {
$loginame = notags(trim($_POST['login-name']));
- if (! $loginame)
+ if(! $loginame)
goaway(z_root());
$r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' ) AND `verified` = 1 AND `blocked` = 0 LIMIT 1",
dbesc($new_password_encoded),
intval($uid)
);
- if ($r)
+ if($r)
info( t('Password reset request issued. Check your email.') . EOL);
function lostpass_content(App $a) {
- if (x($_GET,'verify')) {
+
+ if(x($_GET,'verify')) {
$verify = $_GET['verify'];
$hash = hash('whirlpool', $verify);
$uid = local_user();
$orig_record = $a->user;
- if ((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
- $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+ if((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) {
+ $r = q("select * from user where uid = %d limit 1",
intval($_SESSION['submanage'])
);
if (dbm::is_result($r)) {
}
}
- $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;
- if (count($submanage)) {
- foreach ($submanage as $m) {
- if ($identity == $m['mid']) {
+ if(count($submanage)) {
+ foreach($submanage as $m) {
+ if($identity == $m['mid']) {
$limited_id = $m['mid'];
break;
}
}
}
- if ($limited_id) {
+ if($limited_id) {
$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']),
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);
if (! dbm::is_result($r)) {
return;
}
- if (! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
+ if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) {
notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
return;
}
$params = array();
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
- if ($tags) {
+ if($tags) {
$params['s'] = $tags;
- if ($a->pager['page'] != 1)
+ if($a->pager['page'] != 1)
$params['p'] = $a->pager['page'];
- if (strlen(get_config('system','directory')))
+ if(strlen(get_config('system','directory')))
$x = post_url(get_server().'/msearch', $params);
else
$x = post_url(App::get_baseurl() . '/msearch', $params);
$j = json_decode($x);
- if ($j->total) {
+ if($j->total) {
$a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page);
}
- if (count($j->results)) {
+ if(count($j->results)) {
$id = 0;
- foreach ($j->results as $jj) {
+ foreach($j->results as $jj) {
$match_nurl = normalise_link($jj->url);
$match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1",
intval(local_user()),
// fake it to go back to the input form if no recipient listed
- if ($norecip) {
+ if($norecip) {
$a->argc = 2;
$a->argv[1] = 'new';
- } else {
- goaway($_SESSION['return_url']);
}
+ else
+ goaway($_SESSION['return_url']);
}
// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
// is identical to the code in include/conversation.php
-if (! function_exists('item_extract_images')) {
+if(! function_exists('item_extract_images')) {
function item_extract_images($body) {
$saved_image = array();
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
- while (($img_st_close !== false) && ($img_end !== false)) {
+ while(($img_st_close !== false) && ($img_end !== false)) {
$img_st_close++; // make it point to AFTER the closing bracket
$img_end += $img_start;
- if (! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
+ if(! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
// This is an embedded image
$saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
$cnt++;
- } else {
- $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
}
+ else
+ $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
$orig_body = substr($orig_body, $img_end + strlen('[/img]'));
- if ($orig_body === false) {// in case the body ends on a closing image tag
+ if($orig_body === false) // in case the body ends on a closing image tag
$orig_body = '';
- }
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
return array('body' => $new_body, 'images' => $saved_image);
}}
-if (! function_exists('item_redir_and_replace_images')) {
+if(! function_exists('item_redir_and_replace_images')) {
function item_redir_and_replace_images($body, $images, $cid) {
$origbody = $body;
$newbody = '';
- for ($i = 0; $i < count($images); $i++) {
+ for($i = 0; $i < count($images); $i++) {
$search = '/\[url\=(.*?)\]\[!#saved_image' . $i . '#!\]\[\/url\]' . '/is';
$replace = '[url=' . z_path() . '/redir/' . $cid
. '?f=1&url=' . '$1' . '][!#saved_image' . $i . '#!][/url]' ;
));
- if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) {
- if (! intval($a->argv[2]))
+ if(($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) {
+ if(! intval($a->argv[2]))
return;
// Check if we should do HTML-based delete confirmation
- if ($_REQUEST['confirm']) {
+ if($_REQUEST['confirm']) {
// <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs
$query = explode_querystring($a->query_string);
$inputs = array();
- foreach ($query['args'] as $arg) {
- if (strpos($arg, 'confirm=') === false) {
+ foreach($query['args'] as $arg) {
+ if(strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
}
));
}
// Now check how the user responded to the confirmation query
- if ($_REQUEST['canceled']) {
+ if($_REQUEST['canceled']) {
goaway($_SESSION['return_url']);
}
$cmd = $a->argv[1];
- if ($cmd === 'drop') {
+ if($cmd === 'drop') {
$r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]),
intval(local_user())
// as we will never again have the info we need to re-create it.
// We'll just have to orphan it.
- //if ($convid) {
+ //if($convid) {
// q("delete from conv where id = %d limit 1",
// intval($convid)
// );
//}
- if ($r) {
+ if($r)
info( t('Conversation removed.') . EOL );
- }
}
//goaway(App::get_baseurl(true) . '/message' );
goaway($_SESSION['return_url']);
}
- if (($a->argc > 1) && ($a->argv[1] === 'new')) {
+ if(($a->argc > 1) && ($a->argv[1] === 'new')) {
$o .= $header;
$prename = $preurl = $preid = '';
- if ($preselect) {
+ if($preselect) {
$r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval(local_user()),
intval($a->argv[2])
return $o;
}
- if (($a->argc > 1) && (intval($a->argv[1]))) {
+ if(($a->argc > 1) && (intval($a->argv[1]))) {
$o .= $header;
$convid = $r[0]['convid'];
$sql_extra = sprintf(" and `mail`.`parent-uri` = '%s' ", dbesc($r[0]['parent-uri']));
- if ($convid)
+ if($convid)
$sql_extra = sprintf(" and ( `mail`.`parent-uri` = '%s' OR `mail`.`convid` = '%d' ) ",
dbesc($r[0]['parent-uri']),
intval($convid)
intval(local_user())
);
}
- if (! count($messages)) {
+ if(! count($messages)) {
notice( t('Message not available.') . EOL );
return $o;
}
$seen = 0;
$unknown = false;
- foreach ($messages as $message) {
- if ($message['unknown']) {
+ foreach($messages as $message) {
+ if($message['unknown'])
$unknown = true;
- }
- if ($message['from-url'] == $myprofile) {
+ if($message['from-url'] == $myprofile) {
$from_url = $myprofile;
$sparkle = '';
} elseif ($message['contact-id'] != 0) {
$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') {
+ if($a->theme['template_engine'] === 'internal') {
$from_name_e = template_escape($message['from-name']);
$subject_e = template_escape($message['title']);
$body_e = template_escape(Smilies::replace(bbcode($message['body'])));
}
$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'],
- 'from_name' => $from_name_e,
- 'from_url' => $from_url,
- 'sparkle' => $sparkle,
+ 'id' => $message['id'],
+ 'from_name' => $from_name_e,
+ 'from_url' => $from_url,
+ 'sparkle' => $sparkle,
'from_photo' => proxy_url($from_photo, false, PROXY_SIZE_THUMB),
- 'subject' => $subject_e,
- 'body' => $body_e,
- 'delete' => t('Delete message'),
- 'to_name' => $to_name_e,
- 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
- 'ago' => relative_date($message['created']),
+ 'subject' => $subject_e,
+ 'body' => $body_e,
+ 'delete' => t('Delete message'),
+ 'to_name' => $to_name_e,
+ 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
+ 'ago' => relative_date($message['created']),
);
$seen = $message['seen'];
$tpl = get_markup_template('mail_display.tpl');
- if ($a->theme['template_engine'] === 'internal') {
+ if($a->theme['template_engine'] === 'internal') {
$subjtxt_e = template_escape($message['title']);
- } else {
+ }
+ else {
$subjtxt_e = $message['title'];
}
$myprofile = App::get_baseurl().'/profile/' . $a->user['nickname'];
- foreach ($msg as $rr) {
+ foreach($msg as $rr) {
- if ($rr['unknown'])
+ if($rr['unknown'])
$participants = sprintf( t("Unknown sender - %s"),$rr['from-name']);
elseif (link_compare($rr['from-url'], $myprofile))
$participants = sprintf( t("You and %s"), $rr['name']);
else
$participants = sprintf(t("%s and You"), $rr['from-name']);
- if ($a->theme['template_engine'] === 'internal') {
+ if($a->theme['template_engine'] === 'internal') {
$subject_e = template_escape((($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'));
$body_e = template_escape($rr['body']);
$to_name_e = template_escape($rr['name']);
function modexp_init(App $a) {
- if ($a->argc != 2)
+ if($a->argc != 2)
killme();
$nick = $a->argv[1];
$uid = local_user();
$verb = notags(trim($_GET['verb']));
- if (! $verb)
+ if(! $verb)
return;
$verbs = get_mood_verbs();
- if (! in_array($verb,$verbs))
+ if(! in_array($verb,$verbs))
return;
$activity = ACTIVITY_MOOD . '#' . urlencode($verb);
logger('mood: verb ' . $verb, LOGGER_DEBUG);
- if ($parent) {
+ if($parent) {
$r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid
from item where id = %d and parent = %d and uid = %d limit 1",
intval($parent),
$arr['body'] = $action;
$item_id = item_store($arr);
- if ($item_id) {
+ if($item_id) {
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
intval($uid),
$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');
$startrec = (($page+1) * $perpage) - $perpage;
$search = $_POST['s'];
- if (! strlen($search))
+ if(! strlen($search))
killme();
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ",
);
if (dbm::is_result($r)) {
- foreach ($r as $rr)
+ foreach($r as $rr)
$results[] = array(
'name' => $rr['name'],
'url' => App::get_baseurl() . '/profile/' . $rr['nickname'],
if ($remember_group) {
$net_baseurl .= '/' . $last_sel_groups; // Note that the group number must come before the "/new" tab selection
- } elseif ($sel_groups !== false) {
+ } elseif($sel_groups !== false) {
$net_baseurl .= '/' . $sel_groups;
}
- if ($remember_tab) {
+ if($remember_tab) {
// redirect if current selected tab is '/network' and
// last selected tab is _not_ '/network?f=&order=comment'.
// and this isn't a date query
parse_str( $dest_qs, $dest_qa);
$net_args = array_merge($net_args, $dest_qa);
}
- else if ($sel_tabs[4] === 'active') {
+ else if($sel_tabs[4] === 'active') {
// The '/new' tab is selected
$net_baseurl .= '/new';
}
- if ($remember_net) {
+ if($remember_net) {
$net_args['nets'] = $last_sel_nets;
}
- else if ($sel_nets!==false) {
+ else if($sel_nets!==false) {
$net_args['nets'] = $sel_nets;
}
- if ($remember_tab || $remember_net || $remember_group) {
+ if($remember_tab || $remember_net || $remember_group) {
$net_args = array_merge($query_array, $net_args);
$net_queries = build_querystring($net_args);
}
}
- if (x($_GET['nets']) && $_GET['nets'] === 'all')
+ if(x($_GET['nets']) && $_GET['nets'] === 'all')
unset($_GET['nets']);
$group_id = (($a->argc > 1 && is_numeric($a->argv[1])) ? intval($a->argv[1]) : 0);
require_once('include/items.php');
require_once('include/ForumManager.php');
- if (! x($a->page,'aside'))
+ if(! x($a->page,'aside'))
$a->page['aside'] = '';
$search = ((x($_GET,'search')) ? escape_tags($_GET['search']) : '');
- if (x($_GET,'save')) {
+ if(x($_GET,'save')) {
$r = qu("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()),
dbesc($search)
);
}
}
- if (x($_GET,'remove')) {
+ if(x($_GET,'remove')) {
q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s'",
intval(local_user()),
dbesc($search)
}
// search terms header
- if (x($_GET,'search')) {
+ if(x($_GET,'search')) {
$a->page['content'] .= replace_macros(get_markup_template("section_title.tpl"),array(
'$title' => sprintf( t('Results for: %s'), $search)
));
function saved_searches($search) {
- if (! feature_enabled(local_user(),'savedsearch'))
+ if(! feature_enabled(local_user(),'savedsearch'))
return '';
$a = get_app();
$spam_active = '';
$postord_active = '';
- if (($a->argc > 1 && $a->argv[1] === 'new')
+ if(($a->argc > 1 && $a->argv[1] === 'new')
|| ($a->argc > 2 && $a->argv[2] === 'new')) {
$new_active = 'active';
}
- if (x($_GET,'search')) {
+ if(x($_GET,'search')) {
$search_active = 'active';
}
- if (x($_GET,'star')) {
+ if(x($_GET,'star')) {
$starred_active = 'active';
}
- if (x($_GET,'bmark')) {
+ if(x($_GET,'bmark')) {
$bookmarked_active = 'active';
}
- if (x($_GET,'conv')) {
+ if(x($_GET,'conv')) {
$conv_active = 'active';
}
- if (x($_GET,'spam')) {
+ if(x($_GET,'spam')) {
$spam_active = 'active';
}
function network_query_get_sel_net() {
$network = false;
- if (x($_GET,'nets')) {
+ if(x($_GET,'nets')) {
$network = $_GET['nets'];
}
function network_query_get_sel_group(App $a) {
$group = false;
- if ($a->argc >= 2 && is_numeric($a->argv[1])) {
+ if($a->argc >= 2 && is_numeric($a->argv[1])) {
$group = $a->argv[1];
}
$nouveau = false;
- if ($a->argc > 1) {
- for ($x = 1; $x < $a->argc; $x ++) {
- if (is_a_date_arg($a->argv[$x])) {
- if ($datequery) {
+ if($a->argc > 1) {
+ for($x = 1; $x < $a->argc; $x ++) {
+ if(is_a_date_arg($a->argv[$x])) {
+ 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 . '>');
}
- if (x($_GET,'search') || x($_GET,'file'))
+ if(x($_GET,'search') || x($_GET,'file'))
$nouveau = true;
- if ($cid)
+ if($cid)
$def_acl = array('allow_cid' => '<' . intval($cid) . '>');
- if ($nets) {
+ if($nets) {
$r = qu("SELECT `id` FROM `contact` WHERE `uid` = %d AND network = '%s' AND `self` = 0",
intval(local_user()),
dbesc($nets)
$str = '';
if (dbm::is_result($r))
- foreach ($r as $rr)
+ foreach($r as $rr)
$str .= '<' . $rr['id'] . '>';
- if (strlen($str))
+ if(strlen($str))
$def_acl = array('allow_cid' => $str);
}
set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
- if (!$update AND !$rawmode) {
+ if(!$update AND !$rawmode) {
$tabs = network_tabs($a);
$o .= $tabs;
- if ($group) {
- if (($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
+ if($group) {
+ if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
notice(sprintf(tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
"Warning: This group contains %s members from a network that doesn't allow non public messages.",
$t), $t).EOL);
$sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : '');
- if ($group) {
+ if($group) {
$r = qu("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($group),
intval($_SESSION['uid'])
);
if (! dbm::is_result($r)) {
- if ($update)
+ if($update)
killme();
notice( t('No such group') . EOL );
goaway('network/0');
$contacts = expand_groups(array($group));
$gcontacts = expand_groups(array($group), false, true);
- if ((is_array($contacts)) && count($contacts)) {
+ if((is_array($contacts)) && count($contacts)) {
$contact_str_self = "";
$gcontact_str_self = "";
)) . $o;
}
- elseif ($cid) {
+ elseif($cid) {
$r = qu("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `contact-type`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
AND (NOT `blocked` OR `pending`) LIMIT 1",
'id' => 'network',
)) . $o;
- if ($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
+ if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
notice( t('Private messages to this person are at risk of public disclosure.') . EOL);
}
}
}
- if ((! $group) && (! $cid) && (! $update) && (! get_config('theme','hide_eventlist'))) {
+ if((! $group) && (! $cid) && (! $update) && (! get_config('theme','hide_eventlist'))) {
$o .= get_birthdays();
$o .= get_events();
}
- if ($datequery) {
+ if($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
}
- if ($datequery2) {
+ if($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
}
$order_mode = "received";
$tag = false;
- if (x($_GET,'search')) {
+ if(x($_GET,'search')) {
$search = escape_tags($_GET['search']);
- if (strpos($search,'#') === 0) {
+ if(strpos($search,'#') === 0) {
$tag = true;
$search = substr($search,1);
}
if (get_config('system','only_tag_search'))
$tag = true;
- if ($tag) {
+ if($tag) {
$sql_extra = "";
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
$order_mode = "id";
}
}
- if (strlen($file)) {
+ if(strlen($file)) {
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
$sql_order = "`item`.`id`";
$order_mode = "id";
}
- if ($conv)
+ if($conv)
$sql_extra3 .= " AND $sql_table.`mention`";
- if ($update) {
+ if($update) {
// only setup pagination on initial page view
$pager_sql = '';
// now that we have the user settings, see if the theme forces
// a maximum item number which is lower then the user choice
- if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network))
+ if(($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network))
$itemspage_network = $a->force_max_items;
$a->set_pager_itemspage($itemspage_network);
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
}
- if ($nouveau) {
+ if($nouveau) {
$simple_update = (($update) ? " AND `item`.`unseen` " : '');
if ($sql_order == "")
// Normal conversation view
- if ($order === 'post') {
+ if($order === 'post') {
$ordering = "`created`";
if ($sql_order == "")
$order_mode = "created";
$sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
// Fetch a page full of parent items for this page
- if ($update) {
+ if($update) {
if (get_config("system", "like_no_comment"))
$sql_extra4 = " AND `item`.`verb` = '".ACTIVITY_POST."'";
else
$date_offset = "";
if (dbm::is_result($r)) {
- foreach ($r as $rr)
- if (! in_array($rr['item_id'],$parents_arr))
+ foreach($r as $rr)
+ if(! in_array($rr['item_id'],$parents_arr))
$parents_arr[] = $rr['item_id'];
$parents_str = implode(", ", $parents_arr);
$a->page_offset = $date_offset;
- if ($parents_str)
+ if($parents_str)
$update_unseen = ' WHERE uid = ' . intval(local_user()) . ' AND unseen = 1 AND parent IN ( ' . dbesc($parents_str) . ' )';
}
),
);
- if (feature_enabled(local_user(),'personal_tab')) {
+ if(feature_enabled(local_user(),'personal_tab')) {
$tabs[] = array(
'label' => t('Personal'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1',
);
}
- if (feature_enabled(local_user(),'new_tab')) {
+ if(feature_enabled(local_user(),'new_tab')) {
$tabs[] = array(
'label' => t('New'),
'url' => str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
);
}
- if (feature_enabled(local_user(),'link_tab')) {
+ if(feature_enabled(local_user(),'link_tab')) {
$tabs[] = array(
'label' => t('Shared Links'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1',
);
}
- if (feature_enabled(local_user(),'star_posts')) {
+ if(feature_enabled(local_user(),'star_posts')) {
$tabs[] = array(
'label' => t('Starred'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1',
}
// save selected tab, but only if not in search or file mode
- if (!x($_GET,'search') && !x($_GET,'file')) {
+ if(!x($_GET,'search') && !x($_GET,'file')) {
set_pconfig( local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) );
}
$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;
$o .= '<li>' . '<a target="newmember" href="contacts">' . t('Group Your Contacts') . '</a><br />' . t('Once you have made some friends, organize them into private conversation groups from the sidebar of your Contacts page and then you can interact with each group privately on your Network page.') . '</li>' . EOL;
- if (get_config('system', 'newuser_private')) {
+ if(get_config('system', 'newuser_private')) {
$o .= '<li>' . '<a target="newmember" href="help/Groups-and-Privacy">' . t("Why Aren't My Posts Public?") . '</a><br />' . t("Friendica respects your privacy. By default, your posts will only show up to people you've added as friends. For more information, see the help section from the link above.") . '</li>' . EOL;
}
$plugins = get_config("system","addon");
$plugins_arr = array();
- if ($plugins) {
+ if($plugins) {
$plugins_arr = explode(",",str_replace(" ", "",$plugins));
$idx = array_search($plugin, $plugins_arr);
$last = get_config('nodeinfo','last_calucation');
- if ($last) {
+ if($last) {
// Calculate every 24 hours
$next = $last + (24 * 60 * 60);
- if ($next > time()) {
+ if($next > time()) {
logger("calculation intervall not reached");
return;
}
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')) {
+ if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
$which = $a->user['nickname'];
$profile = $a->argv[1];
}
$o ="";
$o .= profile_tabs($a,True);
- if (! $update) {
+ if(! $update) {
$o .= '<h3>' . t('Personal Notes') . '</h3>';
$commpage = 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
$request_id = (($a->argc > 1) ? $a->argv[1] : 0);
- if ($request_id === "all")
+ if($request_id === "all")
return;
- if ($request_id) {
+ if($request_id) {
$r = q("SELECT * FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($request_id),
$fid = $r[0]['fid'];
- if ($_POST['submit'] == t('Discard')) {
+ if($_POST['submit'] == t('Discard')) {
$r = q("DELETE FROM `intro` WHERE `id` = %d",
intval($intro_id)
);
- if (! $fid) {
+ if(! $fid) {
// The check for blocked and pending is in case the friendship was already approved
// and we just want to get rid of the now pointless notification
}
goaway('notifications/intros');
}
- if ($_POST['submit'] == t('Ignore')) {
+ if($_POST['submit'] == t('Ignore')) {
$r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d",
intval($intro_id));
goaway('notifications/intros');
$startrec = ($page * $perpage) - $perpage;
// Get introductions
- if ( (($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
+ if( (($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
nav_set_selected('introductions');
$notif_header = t('Notifications');
$notifs = $nm->introNotifs($all, $startrec, $perpage);
// Get the network notifications
- } elseif (($a->argc > 1) && ($a->argv[1] == 'network')) {
+ } else if (($a->argc > 1) && ($a->argv[1] == 'network')) {
$notif_header = t('Network Notifications');
$notifs = $nm->networkNotifs($show, $startrec, $perpage);
// Get the system notifications
- } elseif (($a->argc > 1) && ($a->argv[1] == 'system')) {
+ } else if (($a->argc > 1) && ($a->argv[1] == 'system')) {
$notif_header = t('System Notifications');
$notifs = $nm->systemNotifs($show, $startrec, $perpage);
// Get the personal notifications
- } elseif (($a->argc > 1) && ($a->argv[1] == 'personal')) {
+ } else if (($a->argc > 1) && ($a->argv[1] == 'personal')) {
$notif_header = t('Personal Notifications');
$notifs = $nm->personalNotifs($show, $startrec, $perpage);
// Get the home notifications
- } elseif (($a->argc > 1) && ($a->argv[1] == 'home')) {
+ } else if (($a->argc > 1) && ($a->argv[1] == 'home')) {
$notif_header = t('Home Notifications');
$notifs = $nm->homeNotifs($show, $startrec, $perpage);
$notifs['page'] = $a->pager['page'];
// Json output
- if (intval($json) === 1)
+ if(intval($json) === 1)
json_return_and_die($notifs);
$notif_tpl = get_markup_template('notifications.tpl');
// Process the data for template creation
- if ($notifs['ident'] === 'introductions') {
+ if($notifs['ident'] === 'introductions') {
$sugg = get_markup_template('suggestions.tpl');
$tpl = get_markup_template("intros.tpl");
$knowyou = '';
$dfrn_text = '';
- if ($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) {
- if ($it['network'] === NETWORK_DFRN) {
+ if($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) {
+ if($it['network'] === NETWORK_DFRN) {
$lbl_knowyou = t('Claims to be known to you: ');
$knowyou = (($it['knowyou']) ? t('yes') : t('no'));
$helptext = t('Shall your connection be bidirectional or not?');
}
}
- if ($notifs['total'] == 0)
+ if($notifs['total'] == 0)
info( t('No introductions.') . EOL);
// Normal notifications (no introductions)
// It doesn't make sense to show the Show unread / Show all link visible if the user is on the
// "Show all" page and there are no notifications. So we will hide it.
- if ($show == 0 || intval($show) && $notifs['total'] > 0) {
+ if($show == 0 || intval($show) && $notifs['total'] > 0) {
$notif_show_lnk = array(
'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ),
'text' => ($show ? t('Show unread') : t('Show all')),
}
// 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(
function openid_content(App $a) {
$noid = get_config('system','no_openid');
- if ($noid)
+ if($noid)
goaway(z_root());
logger('mod_openid ' . print_r($_REQUEST,true), LOGGER_DATA);
- if ((x($_GET,'openid_mode')) && (x($_SESSION,'openid'))) {
+ if((x($_GET,'openid_mode')) && (x($_SESSION,'openid'))) {
$openid = new LightOpenID;
- if ($openid->validate()) {
+ if($openid->validate()) {
$authid = $_REQUEST['openid_identity'];
- if (! strlen($authid)) {
+ if(! strlen($authid)) {
logger( t('OpenID protocol error. No ID returned.') . EOL);
goaway(z_root());
}
if ($k === 'namePerson/friendly') {
$nick = notags(trim($v));
}
- if ($k === 'namePerson/first') {
+ if($k === 'namePerson/first') {
$first = notags(trim($v));
}
- if ($k === 'namePerson') {
+ if($k === 'namePerson') {
$args .= '&username=' . notags(trim($v));
}
if ($k === 'contact/email') {
$redirects = 0;
// Fetch the header of the URL
$result = z_fetch_url($url, false, $redirects, array("novalidate" => true, "nobody" => true));
- if ($result["success"]) {
+ if($result["success"]) {
// Convert the header fields into an array
$hdrs = array();
$h = explode("\n", $result["header"]);
$type = $hdrs["Content-Type"];
}
if ($type) {
- if (stripos($type, "image/") !== false) {
+ if(stripos($type, "image/") !== false) {
echo $br . "[img]" . $url . "[/img]" . $br;
killme();
}
header('Etag: '.$_SERVER['HTTP_IF_NONE_MATCH']);
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
header("Cache-Control: max-age=31536000");
- if (function_exists('header_remove')) {
+ if(function_exists('header_remove')) {
header_remove('Last-Modified');
header_remove('Expires');
header_remove('Cache-Control');
$default = 'images/person-175.jpg';
- if (isset($type)) {
+ if(isset($type)) {
/**
$data = $r[0]['data'];
$mimetype = $r[0]['type'];
}
- if (! isset($data)) {
+ if(! isset($data)) {
$data = file_get_contents($default);
$mimetype = 'image/jpeg';
}
- } else {
+ }
+ else {
/**
* Other photos
*/
$resolution = 0;
- foreach ( Photo::supportedTypes() as $m=>$e){
+ foreach( Photo::supportedTypes() as $m=>$e){
$photo = str_replace(".$e",'',$photo);
}
- if (substr($photo,-2,1) == '-') {
+ if(substr($photo,-2,1) == '-') {
$resolution = intval(substr($photo,-1,1));
$photo = substr($photo,0,-2);
}
}
}
- if (! isset($data)) {
- if (isset($resolution)) {
+ if(! isset($data)) {
+ if(isset($resolution)) {
switch($resolution) {
case 4:
// Resize only if its not a GIF
if ($mime != "image/gif") {
$ph = new Photo($data, $mimetype);
- if ($ph->is_valid()) {
- if (isset($customres) && $customres > 0 && $customres < 500) {
+ if($ph->is_valid()) {
+ if(isset($customres) && $customres > 0 && $customres < 500) {
$ph->scaleImageSquare($customres);
}
$data = $ph->imageString();
}
}
- if (function_exists('header_remove')) {
+ if(function_exists('header_remove')) {
header_remove('Pragma');
header_remove('pragma');
}
header("Content-type: ".$mimetype);
- if ($prvcachecontrol) {
+ if($prvcachecontrol) {
// it is a private photo that they have no permission to view.
// tell the browser not to cache it, in case they authenticate
// 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 ",
intval($owner_uid)
);
- if (dbm::is_result($prvnxt)) {
+ if (count($prvnxt)) {
for($z = 0; $z < count($prvnxt); $z++) {
if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
$prv = $z - 1;
$nxt = $z + 1;
- if ($prv < 0) {
+ if ($prv < 0)
$prv = count($prvnxt) - 1;
- }
- if ($nxt >= count($prvnxt)) {
+ if ($nxt >= count($prvnxt))
$nxt = 0;
- }
break;
}
}
}
}
- 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
if ($all_events) {
$str_now = datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d');
- foreach ($ev as $x) {
+ foreach($ev as $x) {
$bd = false;
if ($x['type'] === 'birthday') {
$birthdays ++;
function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen)
{
$notifications = array();
- foreach ($notifs as $key => $notif) {
+ foreach($notifs as $key => $notif) {
$notifications[$key . ':note'] = $notif['message'];
$notifications[$key . ':@attributes'] = array(
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,
- 'urls' => false,
- 'updated' => false,
+ 'id' => false,
+ 'displayName' => false,
+ 'urls' => false,
+ 'updated' => false,
'preferredUsername' => false,
- 'photos' => false,
- 'aboutMe' => false,
- 'currentLocation' => false,
- 'network' => false,
- 'gender' => false,
- 'tags' => false,
- 'address' => false,
- 'contactType' => false,
- 'generation' => false
+ 'photos' => false,
+ 'aboutMe' => false,
+ 'currentLocation' => false,
+ 'network' => false,
+ 'gender' => false,
+ 'tags' => false,
+ 'address' => false,
+ 'contactType' => false,
+ 'generation' => false
);
if ((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) {
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'];
}
} else {
$entry['updated'] = $rr['updated'];
}
-
$entry['updated'] = date("c", strtotime($entry['updated']));
}
if ($fields_ret['photos']) {
if ($fields_ret['contactType']) {
$entry['contactType'] = intval($rr['contact-type']);
}
-
$ret['entry'][] = $entry;
}
} else {
} else {
http_status_exit(500);
}
-
logger("End of poco", LOGGER_DEBUG);
if ($format === 'xml') {
} else {
http_status_exit(500);
}
-
}
$target = $r[0];
- if ($parent) {
+ if($parent) {
$r = q("SELECT `uri`, `private`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`
FROM `item` WHERE `id` = %d AND `parent` = %d AND `uid` = %d LIMIT 1",
intval($parent),
$arr['object'] .= '</link></object>' . "\n";
$item_id = item_store($arr);
- if ($item_id) {
+ if($item_id) {
//q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
// dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
// intval($uid),
$name = '';
$id = '';
- if (intval($_GET['c'])) {
+ if(intval($_GET['c'])) {
$r = q("SELECT `id`,`name` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($_GET['c']),
intval(local_user())
$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');
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",
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);
function pretheme_init(App $a) {
- if ($_REQUEST['theme']) {
+ if($_REQUEST['theme']) {
$theme = $_REQUEST['theme'];
$info = get_theme_info($theme);
- if ($info) {
+ if($info) {
// unfortunately there will be no translation for this string
$desc = $info['description'];
$version = $info['version'];
$credits = $info['credits'];
- } else {
+ }
+ else {
$desc = '';
$version = '';
$credits = '';
$o .= '<br /><br />';
- if (x($_GET,'addr')) {
+ if(x($_GET,'addr')) {
$addr = trim($_GET['addr']);
$res = probe_url($addr);
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;
}
$profile = 0;
- if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
+ 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);
}
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
$userblock = (($a->profile['hidewall'] && (! local_user()) && (! remote_user())) ? true : false);
- if ((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
+ if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
}
if (x($a->profile,'openidserver')) {
if ((! $blocked) && (! $userblock)) {
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
- if (strlen($keywords))
+ if(strlen($keywords))
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
}
}
// now that we have the user settings, see if the theme forces
// a maximum item number which is lower then the user choice
- if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network))
+ if(($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network))
$itemspage_network = $a->force_max_items;
$a->set_pager_itemspage($itemspage_network);
$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
$items = array();
}
- if ($is_owner && (! $update) && (! get_config('theme','hide_eventlist'))) {
+ if($is_owner && (! $update) && (! get_config('theme','hide_eventlist'))) {
$o .= get_birthdays();
$o .= get_events();
}
- if ($is_owner) {
+ if($is_owner) {
$r = q("UPDATE `item` SET `unseen` = 0
WHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d",
intval(local_user())
check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
- if ((x($_POST,'cropfinal')) && ($_POST['cropfinal'] == 1)) {
+ if((x($_POST,'cropfinal')) && ($_POST['cropfinal'] == 1)) {
// unless proven otherwise
$is_default_profile = 1;
- if ($_REQUEST['profile']) {
+ if($_REQUEST['profile']) {
$r = q("select id, `is-default` from profile where id = %d and uid = %d limit 1",
intval($_REQUEST['profile']),
intval(local_user())
// phase 2 - we have finished cropping
- if ($a->argc != 2) {
+ if($a->argc != 2) {
notice( t('Image uploaded but image cropping failed.') . EOL );
return;
}
$image_id = $a->argv[1];
- if (substr($image_id,-2,1) == '-') {
+ if(substr($image_id,-2,1) == '-') {
$scale = substr($image_id,-1,1);
$image_id = substr($image_id,0,-2);
}
$base_image = $r[0];
$im = new Photo($base_image['data'], $base_image['type']);
- if ($im->is_valid()) {
+ if($im->is_valid()) {
$im->cropImage(175,$srcX,$srcY,$srcW,$srcH);
$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, $is_default_profile);
// If setting for the default profile, unset the profile photo flag from any other photos I own
- if ($is_default_profile) {
+ if($is_default_profile) {
$r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
dbesc($base_image['resource-id']),
intval(local_user())
}
-if (! function_exists('profile_photo_content')) {
+if(! function_exists('profile_photo_content')) {
function profile_photo_content(App $a) {
if (! local_user()) {
$newuser = false;
- if ($a->argc == 2 && $a->argv[1] === 'new')
+ if($a->argc == 2 && $a->argv[1] === 'new')
$newuser = true;
- if ( $a->argv[1]=='use'){
+ if( $a->argv[1]=='use'){
if ($a->argc<3){
notice( t('Permission denied.') . EOL );
return;
}
$havescale = false;
foreach ($r as $rr) {
- if ($rr['scale'] == 5)
+ if($rr['scale'] == 5)
$havescale = true;
}
);
- if (! x($a->config,'imagecrop')) {
+ if(! x($a->config,'imagecrop')) {
$tpl = get_markup_template('profile_photo.tpl');
}}
-if (! function_exists('profile_photo_crop_ui_head')) {
+if(! function_exists('profile_photo_crop_ui_head')) {
function profile_photo_crop_ui_head(App $a, $ph) {
$max_length = get_config('system','max_image_length');
if (! $max_length) {
return;
}
- if (($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
+ if(($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
intval($a->argv[2]),
intval(local_user())
intval($a->argv[2]),
intval(local_user())
);
- if ($r) {
+ if($r)
info(t('Profile deleted.').EOL);
- }
goaway('profiles');
return; // NOTREACHED
- if (($a->argc > 1) && ($a->argv[1] === 'new')) {
+ if(($a->argc > 1) && ($a->argv[1] === 'new')) {
check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
);
info( t('New profile created.') . EOL);
- if (count($r3) == 1)
+ if(count($r3) == 1)
goaway('profiles/'.$r3[0]['id']);
goaway('profiles');
}
- if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
+ if(($a->argc > 2) && ($a->argv[1] === 'clone')) {
check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
intval(local_user()),
intval($a->argv[2])
);
- if (! dbm::is_result($r1)) {
+ if(! dbm::is_result($r1)) {
notice( t('Profile unavailable to clone.') . EOL);
killme();
return;
}
- if (($a->argc > 1) && (intval($a->argv[1]))) {
+ if(($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]),
intval(local_user())
call_hooks('profile_post', $_POST);
- if (($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
+ if(($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
$orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]),
intval(local_user())
);
- if (! count($orig)) {
+ if(! count($orig)) {
notice( t('Profile not found.') . EOL);
return;
}
$is_default = (($orig[0]['is-default']) ? 1 : 0);
$profile_name = notags(trim($_POST['profile_name']));
- if (! strlen($profile_name)) {
+ if(! strlen($profile_name)) {
notice( t('Profile Name is required.') . EOL);
return;
}
$dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated?
$y = substr($dob,0,4);
- if ((! ctype_digit($y)) || ($y < 1900))
+ if((! ctype_digit($y)) || ($y < 1900))
$ignore_year = true;
else
$ignore_year = false;
- if ($dob != '0000-00-00') {
- if (strpos($dob,'0000-') === 0) {
+ if($dob != '0000-00-00') {
+ if(strpos($dob,'0000-') === 0) {
$ignore_year = true;
$dob = substr($dob,5);
}
$dob = datetime_convert('UTC','UTC',(($ignore_year) ? '1900-' . $dob : $dob),(($ignore_year) ? 'm-d' : 'Y-m-d'));
- if ($ignore_year)
+ if($ignore_year)
$dob = '0000-' . $dob;
}
$name = notags(trim($_POST['name']));
- if (! strlen($name)) {
+ if(! strlen($name)) {
$name = '[No Name]';
}
- if ($orig[0]['name'] != $name)
+ if($orig[0]['name'] != $name)
$namechanged = true;
$with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
- if (! strlen($howlong)) {
+ if(! strlen($howlong)) {
$howlong = NULL_DATE;
} else {
$howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong);
$withchanged = false;
- if (strlen($with)) {
- if ($with != strip_tags($orig[0]['with'])) {
+ if(strlen($with)) {
+ if($with != strip_tags($orig[0]['with'])) {
$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://'))) {
+ 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) {
- if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
+ if(count($links)) {
+ foreach($links as $link) {
+ if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
$prf = $link['@attributes']['href'];
}
}
}
- } else {
+ }
+ else {
$newname = $lookup;
-/* if (strstr($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())
dbesc($newname),
intval(local_user())
);
- if (! $r) {
+ if(! $r) {
$r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
dbesc($lookup),
intval(local_user())
}
}
- if ($prf) {
+ if($prf) {
$with = str_replace($lookup,'<a href="' . $prf . '">' . $newname . '</a>', $with);
- if (strpos($with,'@') === 0)
+ if(strpos($with,'@') === 0)
$with = substr($with,1);
}
}
$changes = array();
$value = '';
- if ($is_default) {
- if ($marital != $orig[0]['marital']) {
+ if($is_default) {
+ if($marital != $orig[0]['marital']) {
$changes[] = '[color=#ff0000]♥[/color] ' . t('Marital Status');
$value = $marital;
}
- if ($withchanged) {
+ if($withchanged) {
$changes[] = '[color=#ff0000]♥[/color] ' . t('Romantic Partner');
$value = strip_tags($with);
}
- if ($likes != $orig[0]['likes']) {
+ if($likes != $orig[0]['likes']) {
$changes[] = t('Likes');
$value = $likes;
}
- if ($dislikes != $orig[0]['dislikes']) {
+ if($dislikes != $orig[0]['dislikes']) {
$changes[] = t('Dislikes');
$value = $dislikes;
}
- if ($work != $orig[0]['work']) {
+ if($work != $orig[0]['work']) {
$changes[] = t('Work/Employment');
}
- if ($religion != $orig[0]['religion']) {
+ if($religion != $orig[0]['religion']) {
$changes[] = t('Religion');
$value = $religion;
}
- if ($politic != $orig[0]['politic']) {
+ if($politic != $orig[0]['politic']) {
$changes[] = t('Political Views');
$value = $politic;
}
- if ($gender != $orig[0]['gender']) {
+ if($gender != $orig[0]['gender']) {
$changes[] = t('Gender');
$value = $gender;
}
- if ($sexual != $orig[0]['sexual']) {
+ if($sexual != $orig[0]['sexual']) {
$changes[] = t('Sexual Preference');
$value = $sexual;
}
- if ($xmpp != $orig[0]['xmpp']) {
+ if($xmpp != $orig[0]['xmpp']) {
$changes[] = t('XMPP');
$value = $xmpp;
}
- if ($homepage != $orig[0]['homepage']) {
+ if($homepage != $orig[0]['homepage']) {
$changes[] = t('Homepage');
$value = $homepage;
}
- if ($interest != $orig[0]['interest']) {
+ if($interest != $orig[0]['interest']) {
$changes[] = t('Interests');
$value = $interest;
}
- if ($address != $orig[0]['address']) {
+ if($address != $orig[0]['address']) {
$changes[] = t('Address');
// New address not sent in notifications, potential privacy issues
// in case this leaks to unintended recipients. Yes, it's in the public
// profile but that doesn't mean we have to broadcast it to everybody.
}
- if ($locality != $orig[0]['locality'] || $region != $orig[0]['region']
+ if($locality != $orig[0]['locality'] || $region != $orig[0]['region']
|| $country_name != $orig[0]['country-name']) {
$changes[] = t('Location');
$comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' ');
intval(local_user())
);
- if ($r) {
+ if($r)
info( t('Profile updated.') . EOL);
- }
- if ($namechanged && $is_default) {
+ if($namechanged && $is_default) {
$r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc($name),
dbesc(datetime_convert()),
);
}
- if ($is_default) {
+ if($is_default) {
$location = formatted_location(array("locality" => $locality, "region" => $region, "country-name" => $country_name));
q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
function profile_activity($changed, $value) {
$a = get_app();
- if (! local_user() || ! is_array($changed) || ! count($changed))
+ if(! local_user() || ! is_array($changed) || ! count($changed))
return;
- if ($a->user['hidewall'] || get_config('system','block_public'))
+ if($a->user['hidewall'] || get_config('system','block_public'))
return;
- if (! get_pconfig(local_user(),'system','post_profilechange'))
+ if(! get_pconfig(local_user(),'system','post_profilechange'))
return;
require_once('include/items.php');
intval(local_user())
);
- if (! count($self))
+ if(! count($self))
return;
$arr = array();
$changes = '';
$t = count($changed);
$z = 0;
- foreach ($changed as $ch) {
- if (strlen($changes)) {
+ foreach($changed as $ch) {
+ if(strlen($changes)) {
if ($z == ($t - 1))
$changes .= t(' and ');
else
$prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]';
- if ($t == 1 && strlen($value)) {
+ if($t == 1 && strlen($value)) {
$message = sprintf( t('%1$s changed %2$s to “%3$s”'), $A, $changes, $value);
$message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof);
}
$o = '';
- if (($a->argc > 1) && (intval($a->argv[1]))) {
+ if(($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]),
intval(local_user())
$detailled_profile = (get_pconfig(local_user(),'system','detailled_profile') AND $personal_account);
$f = get_config('system','birthday_input_format');
- if (! $f)
+ if(! $f)
$f = 'ymd';
$is_default = (($r[0]['is-default']) ? 1 : 0);
else {
//If we don't support multi profiles, don't display this list.
- if (!feature_enabled(local_user(),'multi_profiles')){
+ if(!feature_enabled(local_user(),'multi_profiles')){
$r = q(
"SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
local_user()
}
- if ($a->argc < 2) {
+ if($a->argc < 2) {
notice( t('Invalid profile identifier.') . EOL );
return;
}
// Switch to text mod 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;
- if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
+ if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
$r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0
AND `network` = '%s' AND `id` = %d AND `uid` = %d LIMIT 1",
dbesc(NETWORK_DFRN),
}
- if (($a->argc > 1) && (intval($a->argv[1]))) {
+ if(($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
intval($a->argv[1]),
intval(local_user())
$ingroup = array();
if (dbm::is_result($r))
- foreach ($r as $member)
+ foreach($r as $member)
$ingroup[] = $member['id'];
$members = $r;
- if ($change) {
- if (in_array($change,$ingroup)) {
+ if($change) {
+ if(in_array($change,$ingroup)) {
q("UPDATE `contact` SET `profile-id` = 0 WHERE `id` = %d AND `uid` = %d",
intval($change),
intval(local_user())
$ingroup = array();
if (dbm::is_result($r))
- foreach ($r as $member)
+ foreach($r as $member)
$ingroup[] = $member['id'];
}
}
$o .= '<div id="prof-update-wrapper">';
- if ($change)
+ if($change)
$o = '';
$o .= '<div id="prof-members-title">';
$textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
- foreach ($members as $member) {
- if ($member['url']) {
+ foreach($members as $member) {
+ if($member['url']) {
$member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
$o .= micropro($member,true,'mpprof', $textmode);
}
if (dbm::is_result($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
- foreach ($r as $member) {
- if (! in_array($member['id'],$ingroup)) {
+ foreach($r as $member) {
+ if(! in_array($member['id'],$ingroup)) {
$member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
$o .= micropro($member,true,'mpprof',$textmode);
}
$o .= '</div><div id="prof-all-contacts-end"></div>';
- if ($change) {
+ if($change) {
echo $o;
killme();
}
function hub_return($valid,$body) {
- if ($valid) {
+ if($valid) {
header($_SERVER["SERVER_PROTOCOL"] . ' 200 ' . 'OK');
echo $body;
killme();
$nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : '');
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 );
- if ($_SERVER['REQUEST_METHOD'] === 'GET') {
+ if($_SERVER['REQUEST_METHOD'] === 'GET') {
$hub_mode = ((x($_GET,'hub_mode')) ? notags(trim($_GET['hub_mode'])) : '');
$hub_topic = ((x($_GET,'hub_topic')) ? notags(trim($_GET['hub_topic'])) : '');
}
if ($hub_topic)
- if (! link_compare($hub_topic,$r[0]['poll'])) {
+ if(! link_compare($hub_topic,$r[0]['poll'])) {
logger('pubsub: hub topic ' . $hub_topic . ' != ' . $r[0]['poll']);
// should abort but let's humour them.
}
// We must initiate an unsubscribe request with a verify_token.
// Don't allow outsiders to unsubscribe us.
- if ($hub_mode === 'unsubscribe') {
- if (! strlen($hub_verify)) {
+ if($hub_mode === 'unsubscribe') {
+ if(! strlen($hub_verify)) {
logger('pubsub: bogus unsubscribe');
hub_return(false, '');
}
logger('pubsub: user-agent: ' . $_SERVER['HTTP_USER_AGENT'] );
logger('pubsub: data: ' . $xml, LOGGER_DATA);
-// if (! stristr($xml,'<?xml')) {
+// if(! stristr($xml,'<?xml')) {
// logger('pubsub_post: bad xml');
// hub_post_return();
// }
// 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 = '';
// [hub_secret] => af11...
// [hub_topic] => http://friendica.local/dfrn_poll/sazius
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ if($_SERVER['REQUEST_METHOD'] === 'POST') {
$hub_mode = post_var('hub_mode');
$hub_callback = post_var('hub_callback');
$hub_verify = post_var('hub_verify');
// check for valid hub_mode
if ($hub_mode === 'subscribe') {
$subscribe = 1;
- } elseif ($hub_mode === 'unsubscribe') {
+ } else if ($hub_mode === 'unsubscribe') {
$subscribe = 0;
} else {
logger("pubsubhubbub: invalid hub_mode=$hub_mode, ignoring.");
$contact = $r[0];
// sanity check that topic URLs are the same
- if (!link_compare($hub_topic, $contact['poll'])) {
+ if(!link_compare($hub_topic, $contact['poll'])) {
logger('pubsubhubbub: hub topic ' . $hub_topic . ' != ' .
$contact['poll']);
http_status_exit(404);
$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();
);
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') " : "");
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);
$enabled = intval(get_config('system','diaspora_enabled'));
- if (! $enabled) {
+ if(! $enabled) {
logger('mod-diaspora: disabled');
http_status_exit(500);
}
$public = false;
- if (($a->argc == 2) && ($a->argv[1] === 'public')) {
+ if(($a->argc == 2) && ($a->argv[1] === 'public')) {
$public = true;
}
else {
- if ($a->argc != 3 || $a->argv[1] !== 'users')
+ if($a->argc != 3 || $a->argv[1] !== 'users')
http_status_exit(500);
$guid = $a->argv[2];
logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
- if (! $xml)
+ if(! $xml)
http_status_exit(500);
logger('mod-diaspora: message is okay', LOGGER_DEBUG);
logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
- if (! is_array($msg))
+ if(! is_array($msg))
http_status_exit(500);
logger('mod-diaspora: dispatching', LOGGER_DEBUG);
$ret = 0;
- if ($public) {
+ if($public) {
Diaspora::dispatch_public($msg);
} else {
$ret = Diaspora::dispatch($importer,$msg);
// traditional DFRN
- if ( $con_url || (local_user() && $a->argc > 1 && intval($a->argv[1])) ) {
+ if( $con_url || (local_user() && $a->argc > 1 && intval($a->argv[1])) ) {
- if ($con_url) {
+ if($con_url) {
$con_url = str_replace('https', 'http', $con_url);
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
intval(local_user())
);
- if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
+ if((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
goaway(z_root());
$cid = $r[0]['id'];
intval(local_user())
);
- if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
+ if((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
goaway(z_root());
}
$dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
- if ($r[0]['duplex'] && $r[0]['issued-id']) {
+ if($r[0]['duplex'] && $r[0]['issued-id']) {
$orig_id = $r[0]['issued-id'];
$dfrn_id = '1:' . $orig_id;
}
- if ($r[0]['duplex'] && $r[0]['dfrn-id']) {
+ if($r[0]['duplex'] && $r[0]['dfrn-id']) {
$orig_id = $r[0]['dfrn-id'];
$dfrn_id = '0:' . $orig_id;
}
require_once('include/bbcode.php');
require_once('include/user.php');
-if (! function_exists('register_post')) {
+if(! function_exists('register_post')) {
function register_post(App $a) {
global $lang;
call_hooks('register_post', $arr);
$max_dailies = intval(get_config('system','max_daily_registrations'));
- if ($max_dailies) {
+ if($max_dailies) {
$r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
- if ($r && $r[0]['total'] >= $max_dailies) {
+ if($r && $r[0]['total'] >= $max_dailies) {
return;
}
}
default:
case REGISTER_CLOSED:
- if ((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) {
+ if((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) {
notice( t('Permission denied.') . EOL );
return;
}
$result = create_user($arr);
- if (! $result['success']) {
+ if(! $result['success']) {
notice($result['message']);
return;
}
$user = $result['user'];
- if ($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
+ if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
$url = App::get_baseurl() . '/profile/' . $user['nickname'];
proc_run(PRIORITY_LOW, "include/directory.php", $url);
}
$invite_id = ((x($_POST,'invite_id')) ? notags(trim($_POST['invite_id'])) : '');
- if ( $a->config['register_policy'] == REGISTER_OPEN ) {
+ if( $a->config['register_policy'] == REGISTER_OPEN ) {
- if ($using_invites && $invite_id) {
+ if($using_invites && $invite_id) {
q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
}
$user['username'],
$result['password']);
- if ($res) {
+ if($res) {
info( t('Registration successful. Please check your email for further instructions.') . EOL ) ;
goaway(z_root());
} else {
goaway(z_root());
}
}
- elseif ($a->config['register_policy'] == REGISTER_APPROVE) {
- if (! strlen($a->config['admin_email'])) {
+ elseif($a->config['register_policy'] == REGISTER_APPROVE) {
+ if(! strlen($a->config['admin_email'])) {
notice( t('Your registration can not be processed.') . EOL);
goaway(z_root());
}
);
// invite system
- if ($using_invites && $invite_id) {
+ if($using_invites && $invite_id) {
q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
}
-if (! function_exists('register_content')) {
+if(! function_exists('register_content')) {
function register_content(App $a) {
// logged in users can register others (people/pages/groups)
$block = get_config('system','block_extended_register');
- if (local_user() && ($block)) {
+ if(local_user() && ($block)) {
notice("Permission denied." . EOL);
return;
}
- if ((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
+ if((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
notice("Permission denied." . EOL);
return;
}
$max_dailies = intval(get_config('system','max_daily_registrations'));
- if ($max_dailies) {
+ if($max_dailies) {
$r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
- if ($r && $r[0]['total'] >= $max_dailies) {
+ if($r && $r[0]['total'] >= $max_dailies) {
logger('max daily registrations exceeded.');
notice( t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL);
return;
}
}
- 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']);
$noid = get_config('system','no_openid');
- if ($noid) {
+ if($noid) {
$oidhtml = '';
$fillwith = '';
$fillext = '';
$realpeople = ''; // t('Members of this network prefer to communicate with real people who use their real names.');
- if (get_config('system','publish_all')) {
+ if(get_config('system','publish_all')) {
$profile_publish_reg = '<input type="hidden" name="profile_publish_reg" value="1" />';
}
else {
pop_lang();
- if ($res) {
+ if($res) {
info( t('Account approved.') . EOL );
return true;
}
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'])
function salmon_return($val) {
- if ($val >= 400)
+ if($val >= 400)
$err = 'Error';
- if ($val >= 200 && $val < 300)
+ if($val >= 200 && $val < 300)
$err = 'OK';
logger('mod-salmon returns ' . $val);
// figure out where in the DOM tree our data is hiding
- if ($dom->provenance->data)
+ if($dom->provenance->data)
$base = $dom->provenance;
- elseif ($dom->env->data)
+ elseif($dom->env->data)
$base = $dom->env;
- elseif ($dom->data)
+ elseif($dom->data)
$base = $dom;
- if (! $base) {
+ if(! $base) {
logger('mod-salmon: unable to locate salmon data in xml ');
http_status_exit(400);
}
$author = ostatus::salmon_author($data,$importer);
$author_link = $author["author-link"];
- if (! $author_link) {
+ if(! $author_link) {
logger('mod-salmon: Could not retrieve author URI.');
http_status_exit(400);
}
$key = get_salmon_key($author_link,$keyhash);
- if (! $key) {
+ if(! $key) {
logger('mod-salmon: Could not retrieve author key.');
http_status_exit(400);
}
$verify = rsa_verify($compliant_format,$signature,$pubkey);
- if (! $verify) {
+ if(! $verify) {
logger('mod-salmon: message did not verify using protocol. Trying padding hack.');
$verify = rsa_verify($signed_data,$signature,$pubkey);
}
- if (! $verify) {
+ if(! $verify) {
logger('mod-salmon: message did not verify using padding. Trying old statusnet hack.');
$verify = rsa_verify($stnet_signed_data,$signature,$pubkey);
}
- if (! $verify) {
+ if(! $verify) {
logger('mod-salmon: Message did not verify. Discarding.');
http_status_exit(400);
}
);
if (! dbm::is_result($r)) {
logger('mod-salmon: Author unknown to us.');
- if (get_pconfig($importer['uid'],'system','ostatus_autofriend')) {
+ if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) {
$result = new_contact($importer['uid'],$author_link);
- if ($result['success']) {
+ if($result['success']) {
$r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s')
AND `uid` = %d LIMIT 1",
dbesc(NETWORK_OSTATUS),
// Have we ignored the person?
// If so we can not accept this post.
- //if ((dbm::is_result($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
+ //if((dbm::is_result($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
if (dbm::is_result($r) && $r[0]['blocked']) {
logger('mod-salmon: Ignoring this author.');
http_status_exit(202);
$o = '';
- if (! feature_enabled(local_user(),'savedsearch'))
+ if(! feature_enabled(local_user(),'savedsearch'))
return $o;
$r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
- if (local_user()) {
- if (x($_GET,'save') && $search) {
+ if(local_user()) {
+ if(x($_GET,'save') && $search) {
$r = q("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()),
dbesc($search)
);
}
}
- if (x($_GET,'remove') && $search) {
+ if(x($_GET,'remove') && $search) {
q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()),
dbesc($search)
function search_post(App $a) {
- if (x($_POST,'search'))
+ if(x($_POST,'search'))
$a->data['search'] = $_POST['search'];
}
function search_content(App $a) {
- if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
return;
}
- if (get_config('system','local_search') AND !local_user()) {
+ if(get_config('system','local_search') AND !local_user()) {
http_status_exit(403,
array("title" => t("Public access denied."),
"description" => t("Only logged in users are permitted to perform a search.")));
nav_set_selected('search');
- if (x($a->data,'search'))
+ if(x($a->data,'search'))
$search = notags(trim($a->data['search']));
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
$tag = false;
- if (x($_GET,'tag')) {
+ if(x($_GET,'tag')) {
$tag = true;
$search = ((x($_GET,'tag')) ? notags(trim(rawurldecode($_GET['tag']))) : '');
}
'$content' => search($search,'search-box','search',((local_user()) ? true : false), false)
));
- if (strpos($search,'#') === 0) {
+ if(strpos($search,'#') === 0) {
$tag = true;
$search = substr($search,1);
}
- if (strpos($search,'@') === 0) {
+ if(strpos($search,'@') === 0) {
return dirfind_content($a);
}
- if (strpos($search,'!') === 0) {
+ if(strpos($search,'!') === 0) {
return dirfind_content($a);
}
- if (x($_GET,'search-option'))
+ if(x($_GET,'search-option'))
switch($_GET['search-option']) {
case 'fulltext':
break;
break;
}
- if (! $search)
+ if(! $search)
return $o;
if (get_config('system','only_tag_search'))
// OR your own posts if you are a logged in member
// No items will be shown if the member has a blocked profile wall.
- if ($tag) {
+ if($tag) {
logger("Start tag search for '".$search."'", LOGGER_DEBUG);
$r = q("SELECT %s
}
- if ($tag)
+ if($tag)
$title = sprintf( t('Items tagged with: %s'), $search);
else
$title = sprintf( t('Results for: %s'), $search);
),
);
- if (get_features()) {
+ if(get_features()) {
$tabs[] = array(
'label' => t('Additional features'),
'url' => 'settings/features',
return;
}
- if (($a->argc > 1) && ($a->argv[1] == 'addon')) {
+ if(($a->argc > 1) && ($a->argv[1] == 'addon')) {
check_form_security_token_redirectOnErr('/settings/addon', 'settings_addon');
call_hooks('plugin_settings_post', $_POST);
return;
}
- if (($a->argc > 1) && ($a->argv[1] == 'connectors')) {
+ if(($a->argc > 1) && ($a->argv[1] == 'connectors')) {
check_form_security_token_redirectOnErr('/settings/connectors', 'settings_connectors');
- if (x($_POST, 'general-submit')) {
+ if(x($_POST, 'general-submit')) {
set_pconfig(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening']));
set_pconfig(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow']));
set_pconfig(local_user(), 'ostatus', 'default_group', $_POST['group-selection']);
set_pconfig(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
- } elseif (x($_POST, 'imap-submit')) {
+ } elseif(x($_POST, 'imap-submit')) {
$mail_server = ((x($_POST,'mail_server')) ? $_POST['mail_server'] : '');
$mail_port = ((x($_POST,'mail_port')) ? $_POST['mail_port'] : '');
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
- if (get_config('system','dfrn_only'))
+ if(get_config('system','dfrn_only'))
$mail_disabled = 1;
- if (! $mail_disabled) {
+ if(! $mail_disabled) {
$failed = false;
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval(local_user())
intval(local_user())
);
}
- if (strlen($mail_pass)) {
+ if(strlen($mail_pass)) {
$pass = '';
openssl_public_encrypt($mail_pass,$pass,$a->user['pubkey']);
q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d",
$eacct = $r[0];
require_once('include/email.php');
$mb = construct_mailbox_name($eacct);
- if (strlen($eacct['server'])) {
+ if(strlen($eacct['server'])) {
$dcrpass = '';
openssl_private_decrypt(hex2bin($eacct['pass']),$dcrpass,$a->user['prvkey']);
$mbox = email_connect($mb,$mail_user,$dcrpass);
unset($dcrpass);
- if (! $mbox) {
+ if(! $mbox) {
$failed = true;
notice( t('Failed to connect with email account using the settings provided.') . EOL);
}
}
}
- if (! $failed)
+ if(! $failed)
info( t('Email settings updated.') . EOL);
}
}
if (($a->argc > 1) && ($a->argv[1] === 'features')) {
check_form_security_token_redirectOnErr('/settings/features', 'settings_features');
- foreach ($_POST as $k => $v) {
- if (strpos($k,'feature_') === 0) {
+ foreach($_POST as $k => $v) {
+ if(strpos($k,'feature_') === 0) {
set_pconfig(local_user(),'feature',substr($k,8),((intval($v)) ? 1 : 0));
}
}
$itemspage_mobile_network = 100;
}
- if ($mobile_theme !== '') {
+ if($mobile_theme !== '') {
set_pconfig(local_user(),'system','mobile_theme',$mobile_theme);
}
call_hooks('settings_post', $_POST);
- if ((x($_POST,'password')) || (x($_POST,'confirm'))) {
+ if((x($_POST,'password')) || (x($_POST,'confirm'))) {
$newpass = $_POST['password'];
$confirm = $_POST['confirm'];
$oldpass = hash('whirlpool', $_POST['opassword']);
$err = false;
- if ($newpass != $confirm ) {
+ if($newpass != $confirm ) {
notice( t('Passwords do not match. Password unchanged.') . EOL);
$err = true;
}
- if ((! x($newpass)) || (! x($confirm))) {
+ if((! x($newpass)) || (! x($confirm))) {
notice( t('Empty passwords are not allowed. Password unchanged.') . EOL);
$err = true;
- }
+ }
- // check if the old password was supplied correctly before
- // changing it to the new value
- $r = q("SELECT `password` FROM `user`WHERE `uid` = %d LIMIT 1", intval(local_user()));
- if (!dbm::is_result($r)) {
- /// @todo Don't quit silently here
- killme();
- } elseif ( $oldpass != $r[0]['password'] ) {
- notice( t('Wrong password.') . EOL);
- $err = true;
- }
+ // 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'] ) {
+ notice( t('Wrong password.') . EOL);
+ $err = true;
+ }
- if (! $err) {
+ if(! $err) {
$password = hash('whirlpool',$newpass);
$r = q("UPDATE `user` SET `password` = '%s' WHERE `uid` = %d",
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);
- }
}
}
$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;
$name_change = false;
- if ($username != $a->user['username']) {
+ 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']) {
+ if($email != $a->user['email']) {
$email_changed = true;
// check for the correct password
$r = q("SELECT `password` FROM `user`WHERE `uid` = %d LIMIT 1", intval(local_user()));
$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')) {
+ //if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0)) {
+ if(x($a->config,'admin_email')) {
$adminlist = explode(",", str_replace(" ", "", strtolower($a->config['admin_email'])));
if (in_array(strtolower($email), $adminlist)) {
$err .= t(' Cannot change to that email.');
}
}
- if (strlen($err)) {
+ if(strlen($err)) {
notice($err . EOL);
return;
}
- if ($timezone != $a->user['timezone'] && strlen($timezone)) {
- date_default_timezone_set($timezone);
+ if($timezone != $a->user['timezone']) {
+ if(strlen($timezone))
+ date_default_timezone_set($timezone);
}
$str_group_allow = perms2str($_POST['group_allow']);
// If openid has changed or if there's an openid but no openidserver, try and discover it.
- if ($openid != $a->user['openid'] || (strlen($openid) && (! strlen($openidserver)))) {
+ if($openid != $a->user['openid'] || (strlen($openid) && (! strlen($openidserver)))) {
$tmp_str = $openid;
- if (strlen($tmp_str) && validate_url($tmp_str)) {
+ if(strlen($tmp_str) && validate_url($tmp_str)) {
logger('updating openidserver');
require_once('library/openid.php');
$open_id_obj = new LightOpenID;
$open_id_obj->identity = $openid;
$openidserver = $open_id_obj->discover($open_id_obj->identity);
- } else {
- $openidserver = '';
}
+ else
+ $openidserver = '';
}
set_pconfig(local_user(),'expire','items', $expire_items);
set_pconfig(local_user(),'system','email_textonly', $email_textonly);
- if ($page_flags == PAGE_PRVGROUP) {
+ if($page_flags == PAGE_PRVGROUP) {
$hidewall = 1;
- if ((! $str_contact_allow) && (! $str_group_allow) && (! $str_contact_deny) && (! $str_group_deny)) {
- if ($def_gid) {
+ if((! $str_contact_allow) && (! $str_group_allow) && (! $str_contact_deny) && (! $str_group_deny)) {
+ 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);
}
}
dbesc($language),
intval(local_user())
);
- if ($r) {
+ if($r)
info( t('Settings updated.') . EOL);
- }
// clear session language
unset($_SESSION['language']);
);
- if ($name_change) {
+ if($name_change) {
q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self`",
dbesc($username),
dbesc(datetime_convert()),
return;
}
+
+
if (($a->argc > 1) && ($a->argv[1] === 'oauth')) {
if (($a->argc > 2) && ($a->argv[2] === 'add')) {
return $o;
}
- if (($a->argc > 3) && ($a->argv[2] === 'delete')) {
+ if(($a->argc > 3) && ($a->argv[2] === 'delete')) {
check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
$r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
}
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
- if (get_config('system','dfrn_only'))
+ if(get_config('system','dfrn_only'))
$mail_disabled = 1;
- if (! $mail_disabled) {
+ if(! $mail_disabled) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
local_user()
);
}
$opt_tpl = get_markup_template("field_yesno.tpl");
- if (get_config('system','publish_all')) {
+ if(get_config('system','publish_all')) {
$profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
} else {
$profile_in_dir = replace_macros($opt_tpl,array(
function share_init(App $a) {
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- if ((! $post_id) || (! local_user()))
+ if((! $post_id) || (! local_user()))
killme();
$r = q("SELECT item.*, contact.network FROM `item`
intval($post_id),
intval(local_user())
);
- if (! dbm::is_result($r) || ($r[0]['private'] == 1))
+ if(! dbm::is_result($r) || ($r[0]['private'] == 1))
killme();
if (strpos($r[0]['body'], "[/share]") !== false) {
if ($a->argv[1]==="json"){
$tmp = Smilies::get_list();
$results = array();
- for ($i = 0; $i < count($tmp['texts']); $i++) {
+ for($i = 0; $i < count($tmp['texts']); $i++) {
$results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
}
json_return_and_die($results);
- } else {
+ }
+ else {
return Smilies::replace('',true);
}
}
function subthread_content(App $a) {
- if (! local_user() && ! remote_user()) {
+ if(! local_user() && ! remote_user()) {
return;
}
dbesc($item_id)
);
- if (! $item_id || (! dbm::is_result($r))) {
+ if(! $item_id || (! dbm::is_result($r))) {
logger('subthread: no item ' . $item_id);
return;
}
$owner_uid = $item['uid'];
- if (! can_write_wall($a,$owner_uid)) {
+ if(! can_write_wall($a,$owner_uid)) {
return;
}
$remote_owner = null;
- if (! $item['wall']) {
+ if(! $item['wall']) {
// The top level post may have been written by somebody on another system
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($item['contact-id']),
function tagger_content(App $a) {
- if (! local_user() && ! remote_user()) {
+ if(! local_user() && ! remote_user()) {
return;
}
// no commas allowed
$term = str_replace(array(',',' '),array('','_'),$term);
- if (! $term)
+ if(! $term)
return;
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
dbesc($item_id)
);
- if (! $item_id || (! dbm::is_result($r))) {
+ if(! $item_id || (! dbm::is_result($r))) {
logger('tagger: no item ' . $item_id);
return;
}
$blocktags = $r[0]['blocktags'];
}
- if (local_user() != $owner_uid)
+ if(local_user() != $owner_uid)
return;
$r = q("select * from contact where self = 1 and uid = %d limit 1",
// );
- if (! $item['visible']) {
+ if(! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']),
intval($owner_uid)
intval($item['id']),
dbesc($term)
);
- if ((! $blocktags) && $t[0]['tcount']==0 ) {
+ if((! $blocktags) && $t[0]['tcount']==0 ) {
/*q("update item set tag = '%s' where id = %d",
dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($item['id'])
intval($r[0]['id']),
dbesc($term)
);
- if (count($x) && !$x[0]['blocktags'] && $t[0]['tcount']==0){
+ if(count($x) && !$x[0]['blocktags'] && $t[0]['tcount']==0){
q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)",
- intval($r[0]['id']),
- $term_objtype,
- TERM_HASHTAG,
- dbesc($term),
- dbesc(App::get_baseurl() . '/search?tag=' . $term),
- intval($owner_uid)
- );
+ intval($r[0]['id']),
+ $term_objtype,
+ TERM_HASHTAG,
+ dbesc($term),
+ dbesc(App::get_baseurl() . '/search?tag=' . $term),
+ intval($owner_uid)
+ );
}
- /*if (count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
+ /*if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
q("update item set tag = '%s' where id = %d",
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . App::get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($r[0]['id'])
$result = array();
$r = q($query);
if (dbm::is_result($r)) {
- foreach ($r as $rr){
+ foreach($r as $rr){
$p = array();
- foreach ($rr as $k => $v) {
+ foreach($rr as $k => $v) {
$p[$k] = $v;
}
$result[] = $p;
$result = array();
$r = q($query);
if (dbm::is_result($r)) {
- foreach ($r as $rr) {
- foreach ($rr as $k => $v) {
+ foreach($r as $rr) {
+ foreach($rr as $k => $v) {
$result[$k] = $v;
}
}
intval(500)
);
/*if (dbm::is_result($r)) {
- foreach ($r as $rr)
- foreach ($rr as $k => $v)
+ foreach($r as $rr)
+ foreach($rr as $k => $v)
$item[][$k] = $v;
}*/
function videos_init(App $a) {
- if ($a->argc > 1)
+ if($a->argc > 1)
auto_redir($a, $a->argv[1]);
- if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
$o = '';
- if ($a->argc > 1) {
+ if($a->argc > 1) {
$nick = $a->argv[1];
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
dbesc($nick)
);
- if (!dbm::is_result($user)) {
+ if(! count($user))
return;
- }
$a->data['user'] = $user[0];
$a->profile_uid = $user[0]['uid'];
intval($a->data['user']['uid'])
);
- if (count($albums)) {
+ if(count($albums)) {
$a->data['albums'] = $albums;
$albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
- if ($albums_visible) {
+ if($albums_visible) {
$o .= '<div id="sidebar-photos-albums" class="widget">';
$o .= '<h3>' . '<a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
$o .= '<ul>';
- foreach ($albums as $album) {
+ foreach($albums as $album) {
// don't show contact photos. We once translated this name, but then you could still access it under
// a different language setting. Now we store the name in English and check in English (and translated for legacy albums).
- if ((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
+ if((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
continue;
$o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>';
}
$o .= '</ul>';
}
- if (local_user() && $a->data['user']['uid'] == local_user()) {
+ if(local_user() && $a->data['user']['uid'] == local_user()) {
$o .= '<div id="photo-albums-upload-link"><a href="' . App::get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
}
$o .= '</div>';
}*/
- if (! x($a->page,'aside'))
+ if(! x($a->page,'aside'))
$a->page['aside'] = '';
$a->page['aside'] .= $vcard_widget;
// videos/name/video/xxxxx/edit
- if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
return;
}
require_once('include/security.php');
require_once('include/conversation.php');
- if (! x($a->data,'user')) {
+ if(! x($a->data,'user')) {
notice( t('No videos selected') . EOL );
return;
}
// Parse arguments
//
- if ($a->argc > 3) {
+ if($a->argc > 3) {
$datatype = $a->argv[2];
$datum = $a->argv[3];
}
- elseif (($a->argc > 2) && ($a->argv[2] === 'upload'))
+ elseif(($a->argc > 2) && ($a->argv[2] === 'upload'))
$datatype = 'upload';
else
$datatype = 'summary';
- if ($a->argc > 4)
+ if($a->argc > 4)
$cmd = $a->argv[4];
else
$cmd = 'view';
$community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
- if ((local_user()) && (local_user() == $owner_uid))
+ if((local_user()) && (local_user() == $owner_uid))
$can_post = true;
else {
- if ($community_page && remote_user()) {
- if (is_array($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $v) {
- if ($v['uid'] == $owner_uid) {
+ if($community_page && remote_user()) {
+ if(is_array($_SESSION['remote'])) {
+ foreach($_SESSION['remote'] as $v) {
+ if($v['uid'] == $owner_uid) {
$contact_id = $v['cid'];
break;
}
}
}
- if ($contact_id) {
+ if($contact_id) {
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
// perhaps they're visiting - but not a community page, so they wouldn't have write access
- if (remote_user() && (! $visitor)) {
+ if(remote_user() && (! $visitor)) {
$contact_id = 0;
- if (is_array($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $v) {
- if ($v['uid'] == $owner_uid) {
+ if(is_array($_SESSION['remote'])) {
+ foreach($_SESSION['remote'] as $v) {
+ if($v['uid'] == $owner_uid) {
$contact_id = $v['cid'];
break;
}
}
}
- if ($contact_id) {
+ if($contact_id) {
$groups = init_groups_visitor($contact_id);
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
}
}
- if (! $remote_contact) {
- if (local_user()) {
+ if(! $remote_contact) {
+ if(local_user()) {
$contact_id = $_SESSION['cid'];
$contact = $a->contact;
}
}
- if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
+ if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
notice( t('Access to this item is restricted.') . EOL);
return;
}
//
- if ($datatype === 'upload') {
+ if($datatype === 'upload') {
return; // no uploading for now
// DELETED -- look at mod/photos.php if you want to implement
}
- if ($datatype === 'album') {
+ if($datatype === 'album') {
return; // no albums for now
}
- if ($datatype === 'video') {
+ if($datatype === 'video') {
return; // no single video view for now
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();
function viewcontacts_init(App $a) {
- if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
nav_set_selected('home');
- if ($a->argc > 1) {
+ if($a->argc > 1) {
$nick = $a->argv[1];
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
dbesc($nick)
function viewcontacts_content(App $a) {
require_once("mod/proxy.php");
- if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
return;
}
// tabs
$o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']);
- if (((! count($a->profile)) || ($a->profile['hide-friends']))) {
+ if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
notice( t('Permission denied.') . EOL);
return $o;
}
$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);
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- if (! $item_id) {
+ if(! $item_id) {
$a->error = 404;
notice( t('Item not found.') . EOL);
return;
);
if (dbm::is_result($r))
- if (is_ajax()) {
+ if(is_ajax()) {
echo str_replace("\n",'<br />',$r[0]['body']);
killme();
} else {
$r_json = (x($_GET,'response') && $_GET['response']=='json');
- if ($a->argc > 1) {
+ if($a->argc > 1) {
$nick = $a->argv[1];
$r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
dbesc($nick)
$page_owner_nick = $r[0]['nickname'];
$community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
- if ((local_user()) && (local_user() == $page_owner_uid))
+ if((local_user()) && (local_user() == $page_owner_uid))
$can_post = true;
else {
- if ($community_page && remote_user()) {
+ if($community_page && remote_user()) {
$contact_id = 0;
- if (is_array($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $v) {
- if ($v['uid'] == $page_owner_uid) {
+ if(is_array($_SESSION['remote'])) {
+ foreach($_SESSION['remote'] as $v) {
+ if($v['uid'] == $page_owner_uid) {
$contact_id = $v['cid'];
break;
}
}
}
- if ($contact_id) {
+ if($contact_id) {
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
}
}
}
- if (! $can_post) {
+ if(! $can_post) {
if ($r_json) {
echo json_encode(array('error'=>t('Permission denied.')));
killme();
killme();
}
- if (! x($_FILES,'userfile')) {
+ if(! x($_FILES,'userfile')) {
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
}
* Then Filesize gets <= 0.
*/
- if ($filesize <=0) {
+ if($filesize <=0) {
$msg = t('Sorry, maybe your upload is bigger than the PHP configuration allows') . EOL .(t('Or - did you try to upload an empty file?'));
if ($r_json) {
echo json_encode(array('error'=>$msg));
killme();
}
- if (($maxfilesize) && ($filesize > $maxfilesize)) {
+ if(($maxfilesize) && ($filesize > $maxfilesize)) {
$msg = sprintf(t('File exceeds size limit of %s'), formatBytes($maxfilesize));
if ($r_json) {
echo json_encode(array('error'=>$msg));
@unlink($src);
- if (! $r) {
+ if(! $r) {
$msg = t('File upload failed.');
if ($r_json) {
echo json_encode(array('error'=>$msg));
$r_json = (x($_GET,'response') && $_GET['response']=='json');
- if ($a->argc > 1) {
- if (! x($_FILES,'media')) {
+ if($a->argc > 1) {
+ if(! x($_FILES,'media')) {
$nick = $a->argv[1];
$r = q("SELECT `user`.*, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
dbesc($nick)
$page_owner_nick = $r[0]['nickname'];
$community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
- if ((local_user()) && (local_user() == $page_owner_uid))
+ if((local_user()) && (local_user() == $page_owner_uid))
$can_post = true;
else {
- if ($community_page && remote_user()) {
+ if($community_page && remote_user()) {
$contact_id = 0;
- if (is_array($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $v) {
- if ($v['uid'] == $page_owner_uid) {
+ if(is_array($_SESSION['remote'])) {
+ foreach($_SESSION['remote'] as $v) {
+ if($v['uid'] == $page_owner_uid) {
$contact_id = $v['cid'];
break;
}
}
}
- if ($contact_id) {
+ if($contact_id) {
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
}
- if (! $can_post) {
+ if(! $can_post) {
if ($r_json) {
echo json_encode(array('error'=>t('Permission denied.')));
killme();
killme();
}
- if (! x($_FILES,'userfile') && ! x($_FILES,'media')){
+ if(! x($_FILES,'userfile') && ! x($_FILES,'media')){
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
}
}
$src = "";
- if (x($_FILES,'userfile')) {
+ if(x($_FILES,'userfile')) {
$src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
$filetype = $_FILES['userfile']['type'];
}
- elseif (x($_FILES,'media')) {
+ elseif(x($_FILES,'media')) {
if (is_array($_FILES['media']['tmp_name']))
$src = $_FILES['media']['tmp_name'][0];
else
$maximagesize = get_config('system','maximagesize');
- if (($maximagesize) && ($filesize > $maximagesize)) {
+ if(($maximagesize) && ($filesize > $maximagesize)) {
$msg = sprintf( t('Image exceeds size limit of %s'), formatBytes($maximagesize));
if ($r_json) {
echo json_encode(array('error'=>$msg));
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
- if (! $ph->is_valid()) {
+ if(! $ph->is_valid()) {
$msg = t('Unable to process image.');
if ($r_json) {
echo json_encode(array('error'=>$msg));
@unlink($src);
$max_length = get_config('system','max_image_length');
- if (! $max_length)
+ if(! $max_length)
$max_length = MAX_IMAGE_LENGTH;
- if ($max_length > 0) {
+ if($max_length > 0) {
$ph->scaleImage($max_length);
logger("File upload: Scaling picture to new size ".$max_length, LOGGER_DEBUG);
}
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 0, 0, $defperm);
- if (! $r) {
+ if(! $r) {
$msg = t('Image upload failed.');
if ($r_json) {
echo json_encode(array('error'=>$msg));
killme();
}
- if ($width > 640 || $height > 640) {
+ 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) {
+ if($width > 320 || $height > 320) {
$ph->scaleImage(320);
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 2, 0, $defperm);
- if ($r AND ($smallest == 0)) {
+ if($r AND ($smallest == 0))
$smallest = 2;
- }
}
$basename = basename($filename);
if (!$desktopmode) {
$r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo` WHERE `resource-id` = '%s' ORDER BY `width` DESC LIMIT 1", $hash);
- if (!dbm::is_result($r)) {
+ if (!$r){
if ($r_json) {
echo json_encode(array('error'=>''));
killme();
function wallmessage_post(App $a) {
$replyto = get_my_url();
- if (! $replyto) {
+ if(! $replyto) {
notice( t('Permission denied.') . EOL);
return;
}
$body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : '');
$recipient = (($a->argc > 1) ? notags($a->argv[1]) : '');
- if ((! $recipient) || (! $body)) {
+ if((! $recipient) || (! $body)) {
return;
}
$user = $r[0];
- if (! intval($user['unkmail'])) {
+ if(! intval($user['unkmail'])) {
notice( t('Permission denied.') . EOL);
return;
}
intval($user['uid'])
);
- if ($r[0]['total'] > $user['cntunkmail']) {
+ if($r[0]['total'] > $user['cntunkmail']) {
notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
return;
}
function wallmessage_content(App $a) {
- if (! get_my_url()) {
+ if(! get_my_url()) {
notice( t('Permission denied.') . EOL);
return;
}
$recipient = (($a->argc > 1) ? $a->argv[1] : '');
- if (! $recipient) {
+ if(! $recipient) {
notice( t('No recipient.') . EOL);
return;
}
$user = $r[0];
- if (! intval($user['unkmail'])) {
+ if(! intval($user['unkmail'])) {
notice( t('Permission denied.') . EOL);
return;
}
- $r = q("SELECT COUNT(*) AS `total` FROM `mail` WHERE `uid` = %d AND `created` > UTC_TIMESTAMP() - INTERVAL 1 DAY AND `unknown` = 1",
+ $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
intval($user['uid'])
);
- if (!dbm::is_result($r)) {
- ///@TODO Output message to use of failed query
- return;
- } elseif ($r[0]['total'] > $user['cntunkmail']) {
+ if($r[0]['total'] > $user['cntunkmail']) {
notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
return;
}
$o .= '<br /><br />';
- if (x($_GET,'addr')) {
+ if(x($_GET,'addr')) {
$addr = trim($_GET['addr']);
$res = Probe::lrdd($addr);
$o .= '<pre>';
$uri = urldecode(notags(trim($_GET['uri'])));
- if (substr($uri,0,4) === 'http') {
+ if(substr($uri,0,4) === 'http') {
$acct = false;
$name = basename($uri);
} 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,'@'));
}
<?php
-if (class_exists('BaseObject')) {
+if(class_exists('BaseObject'))
return;
-}
require_once('boot.php');
* Same as get_app from boot.php
*/
public function get_app() {
- if (self::$app) {
+ if(self::$app)
return self::$app;
- }
self::$app = get_app();
<?php
-if (class_exists('Conversation')) {
+if(class_exists('Conversation'))
return;
-}
require_once('boot.php');
require_once('object/BaseObject.php');
* Set the mode we'll be displayed on
*/
private function set_mode($mode) {
- if ($this->get_mode() == $mode)
+ if($this->get_mode() == $mode)
return;
$a = $this->get_app();
*/
public function add_thread($item) {
$item_id = $item->get_id();
- if (!$item_id) {
+ if(!$item_id) {
logger('[ERROR] Conversation::add_thread : Item has no ID!!', LOGGER_DEBUG);
return false;
}
- if ($this->get_thread($item->get_id())) {
+ if($this->get_thread($item->get_id())) {
logger('[WARN] Conversation::add_thread : Thread already exists ('. $item->get_id() .').', LOGGER_DEBUG);
return false;
}
/*
* Only add will be displayed
*/
- if ($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
+ if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
logger('[WARN] Conversation::add_thread : Thread is a mail ('. $item->get_id() .').', LOGGER_DEBUG);
return false;
}
- if ($item->get_data_value('verb') === ACTIVITY_LIKE || $item->get_data_value('verb') === ACTIVITY_DISLIKE) {
+ if($item->get_data_value('verb') === ACTIVITY_LIKE || $item->get_data_value('verb') === ACTIVITY_DISLIKE) {
logger('[WARN] Conversation::add_thread : Thread is a (dis)like ('. $item->get_id() .').', LOGGER_DEBUG);
return false;
}
$i = 0;
- foreach ($this->threads as $item) {
- if ($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid')) {
+ foreach($this->threads as $item) {
+ if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid'))
continue;
- }
$item_data = $item->get_template_data($conv_responses);
- if (!$item_data) {
+ if(!$item_data) {
logger('[ERROR] Conversation::get_template_data : Failed to get item template data ('. $item->get_id() .').', LOGGER_DEBUG);
return false;
}
* _ false on failure
*/
private function get_thread($id) {
- foreach ($this->threads as $item) {
- if ($item->get_id() == $id) {
+ foreach($this->threads as $item) {
+ if($item->get_id() == $id)
return $item;
- }
}
return false;
<?php
-if (class_exists('Item')) {
+if(class_exists('Item'))
return;
-}
require_once('object/BaseObject.php');
require_once('include/text.php');
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
$searchpath = "search?tag=";
- $tags = array();
+ $tags=array();
$hashtags = array();
$mentions = array();
- /*foreach (explode(',',$item['tag']) as $tag){
+ /*foreach(explode(',',$item['tag']) as $tag){
$tag = trim($tag);
if ($tag!="") {
$t = bbcode($tag);
$tags[] = $t;
- if ($t[0] == '#')
+ if($t[0] == '#')
$hashtags[] = $t;
- elseif ($t[0] == '@')
+ elseif($t[0] == '@')
$mentions[] = $t;
}
}*/
}
$tagger = '';
- if (feature_enabled($conv->get_profile_owner(),'commtag')) {
+ if(feature_enabled($conv->get_profile_owner(),'commtag')) {
$tagger = array(
'add' => t("add tag"),
'class' => "",
*/
protected function set_parent($item) {
$parent = $this->get_parent();
- if ($parent) {
+ if($parent) {
$parent->remove_child($this);
}
$this->parent = $item;
$conv = $this->get_conversation();
$this->wall_to_wall = false;
- if ($this->is_toplevel()) {
- if ($conv->get_mode() !== 'profile') {
- if ($this->get_data_value('wall') AND !$this->get_data_value('self')) {
+ if($this->is_toplevel()) {
+ if($conv->get_mode() !== 'profile') {
+ if($this->get_data_value('wall') AND !$this->get_data_value('self')) {
// On the network page, I am the owner. On the display page it will be the profile owner.
// This will have been stored in $a->page_contact by our calling page.
// Put this person as the wall owner of the wall-to-wall notice.
$this->owner_photo = $a->page_contact['thumb'];
$this->owner_name = $a->page_contact['name'];
$this->wall_to_wall = true;
- } elseif ($this->get_data_value('owner-link')) {
+ } elseif($this->get_data_value('owner-link')) {
$owner_linkmatch = (($this->get_data_value('owner-link')) && link_compare($this->get_data_value('owner-link'),$this->get_data_value('author-link')));
$alias_linkmatch = (($this->get_data_value('alias')) && link_compare($this->get_data_value('alias'),$this->get_data_value('author-link')));
*/
-if (($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) {
+if(($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1]))
echo $_SERVER["argv"][1];
-} else {
+else
echo '';
-}
<?php
-/**
- * this test tests the contains_attribute function
- *
- * @package test.util
- */
-
-/** required, it is the file under test */
-require_once('include/text.php');
-
-/**
- * TestCase for the contains_attribute function
- *
- * @author Alexander Kampmann
- * @package test.util
- */
+/**\r
+ * this test tests the contains_attribute function\r
+ *\r
+ * @package test.util\r
+ */\r
+\r
+/** required, it is the file under test */\r
+require_once('include/text.php');\r
+\r
+/**\r
+ * TestCase for the contains_attribute function\r
+ *\r
+ * @author Alexander Kampmann\r
+ * @package test.util\r
+ */\r
class ContainsAttributeTest extends PHPUnit_Framework_TestCase {
- /**
- * test attribute contains
- */
- public function testAttributeContains1() {
- $testAttr="class1 notclass2 class3";
- $this->assertTrue(attribute_contains($testAttr, "class3"));
- $this->assertFalse(attribute_contains($testAttr, "class2"));
- }
-
- /**
- * test attribute contains
- */
- public function testAttributeContains2() {
- $testAttr="class1 not-class2 class3";
- $this->assertTrue(attribute_contains($testAttr, "class3"));
- $this->assertFalse(attribute_contains($testAttr, "class2"));
- }
+ /**\r
+ * test attribute contains\r
+ */\r
+ public function testAttributeContains1() {\r
+ $testAttr="class1 notclass2 class3";\r
+ $this->assertTrue(attribute_contains($testAttr, "class3"));\r
+ $this->assertFalse(attribute_contains($testAttr, "class2"));\r
+ }\r
+ \r
+ /**\r
+ * test attribute contains\r
+ */\r
+ public function testAttributeContains2() {\r
+ $testAttr="class1 not-class2 class3";\r
+ $this->assertTrue(attribute_contains($testAttr, "class3"));\r
+ $this->assertFalse(attribute_contains($testAttr, "class2"));\r
+ }\r
/**
* test with empty input
- */
- public function testAttributeContainsEmpty() {
- $testAttr="";
- $this->assertFalse(attribute_contains($testAttr, "class2"));
- }
+ */\r
+ public function testAttributeContainsEmpty() {\r
+ $testAttr="";\r
+ $this->assertFalse(attribute_contains($testAttr, "class2"));\r
+ }\r
/**
* test input with special chars
- */
- public function testAttributeContainsSpecialChars() {
- $testAttr="--... %\$ä() /(=?}";
- $this->assertFalse(attribute_contains($testAttr, "class2"));
+ */\r
+ public function testAttributeContainsSpecialChars() {\r
+ $testAttr="--... %\$ä() /(=?}";\r
+ $this->assertFalse(attribute_contains($testAttr, "class2"));\r
}
}
\ No newline at end of file
/** required, it is the file under test */
require_once('include/text.php');
-/**
- * TestCase for the expand_acl function
- *
- * @author Alexander Kampmann
- * @package test.util
- */
+/**\r
+ * TestCase for the expand_acl function\r
+ *\r
+ * @author Alexander Kampmann\r
+ * @package test.util\r
+ */\r
class ExpandAclTest extends PHPUnit_Framework_TestCase {
- /**
- * test expand_acl, perfect input
- */
- public function testExpandAclNormal() {
- $text='<1><2><3>';
- $this->assertEquals(array(1, 2, 3), expand_acl($text));
- }
+ /**\r
+ * test expand_acl, perfect input\r
+ */\r
+ public function testExpandAclNormal() {\r
+ $text='<1><2><3>';\r
+ $this->assertEquals(array(1, 2, 3), expand_acl($text));\r
+ }\r
/**
* test with a big number
- */
- public function testExpandAclBigNumber() {
- $text='<1><'.PHP_INT_MAX.'><15>';
- $this->assertEquals(array(1, PHP_INT_MAX, 15), expand_acl($text));
- }
+ */\r
+ public function testExpandAclBigNumber() {\r
+ $text='<1><'.PHP_INT_MAX.'><15>';\r
+ $this->assertEquals(array(1, PHP_INT_MAX, 15), expand_acl($text));\r
+ }\r
/**
* test with a string in it.
*
* TODO: is this valid input? Otherwise: should there be an exception?
- */
- public function testExpandAclString() {
- $text="<1><279012><tt>";
- $this->assertEquals(array(1, 279012), expand_acl($text));
- }
+ */\r
+ public function testExpandAclString() {\r
+ $text="<1><279012><tt>"; \r
+ $this->assertEquals(array(1, 279012), expand_acl($text));\r
+ }\r
/**
* test with a ' ' in it.
*
* TODO: is this valid input? Otherwise: should there be an exception?
- */
- public function testExpandAclSpace() {
- $text="<1><279 012><32>";
- $this->assertEquals(array(1, "279", "32"), expand_acl($text));
- }
+ */\r
+ public function testExpandAclSpace() {\r
+ $text="<1><279 012><32>"; \r
+ $this->assertEquals(array(1, "279", "32"), expand_acl($text));\r
+ }\r
/**
* test empty input
- */
- public function testExpandAclEmpty() {
- $text="";
- $this->assertEquals(array(), expand_acl($text));
- }
+ */\r
+ public function testExpandAclEmpty() {\r
+ $text=""; \r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
/**
* test invalid input, no < at all
*
* TODO: should there be an exception?
- */
- public function testExpandAclNoBrackets() {
- $text="According to documentation, that's invalid. "; //should be invalid
- $this->assertEquals(array(), expand_acl($text));
- }
+ */\r
+ public function testExpandAclNoBrackets() {\r
+ $text="According to documentation, that's invalid. "; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
- /**
- * test invalid input, just open <
- *
- * TODO: should there be an exception?
- */
- public function testExpandAclJustOneBracket1() {
- $text="<Another invalid string"; //should be invalid
- $this->assertEquals(array(), expand_acl($text));
- }
+ /**\r
+ * test invalid input, just open <\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclJustOneBracket1() {\r
+ $text="<Another invalid string"; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
- /**
- * test invalid input, just close >
- *
- * TODO: should there be an exception?
- */
- public function testExpandAclJustOneBracket2() {
- $text="Another invalid> string"; //should be invalid
- $this->assertEquals(array(), expand_acl($text));
- }
+ /**\r
+ * test invalid input, just close >\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclJustOneBracket2() {\r
+ $text="Another invalid> string"; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
- /**
- * test invalid input, just close >
- *
- * TODO: should there be an exception?
- */
- public function testExpandAclCloseOnly() {
- $text="Another> invalid> string>"; //should be invalid
- $this->assertEquals(array(), expand_acl($text));
- }
+ /**\r
+ * test invalid input, just close >\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclCloseOnly() {\r
+ $text="Another> invalid> string>"; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
- /**
- * test invalid input, just open <
- *
- * TODO: should there be an exception?
- */
- public function testExpandAclOpenOnly() {
- $text="<Another< invalid string<"; //should be invalid
- $this->assertEquals(array(), expand_acl($text));
- }
+ /**\r
+ * test invalid input, just open <\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclOpenOnly() {\r
+ $text="<Another< invalid string<"; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
- /**
- * test invalid input, open and close do not match
- *
- * TODO: should there be an exception?
- */
- public function testExpandAclNoMatching1() {
- $text="<Another<> invalid <string>"; //should be invalid
- $this->assertEquals(array(), expand_acl($text));
- }
+ /**\r
+ * test invalid input, open and close do not match\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclNoMatching1() {\r
+ $text="<Another<> invalid <string>"; //should be invalid\r
+ $this->assertEquals(array(), expand_acl($text));\r
+ }\r
- /**
- * test invalid input, open and close do not match
- *
- * TODO: should there be an exception?
- */
- public function testExpandAclNoMatching2() {
- $text="<1>2><3>";
+ /**\r
+ * test invalid input, open and close do not match\r
+ *\r
+ * TODO: should there be an exception?\r
+ */\r
+ public function testExpandAclNoMatching2() {\r
+ $text="<1>2><3>";\r
// The angles are delimiters which aren't important
// the important thing is the numeric content, this returns array(1,2,3) currently
// we may wish to eliminate 2 from the results, though it isn't harmful
// It would be a better test to figure out if there is any ACL input which can
// produce this $text and fix that instead.
-// $this->assertEquals(array(), expand_acl($text));
+// $this->assertEquals(array(), expand_acl($text));\r
}
- /**
- * test invalid input, empty <>
- *
- * TODO: should there be an exception? Or array(1, 3)
+ /**\r
+ * test invalid input, empty <>\r
+ *\r
+ * TODO: should there be an exception? Or array(1, 3)\r
* (This should be array(1,3) - mike)
- */
- public function testExpandAclEmptyMatch() {
- $text="<1><><3>";
- $this->assertEquals(array(1,3), expand_acl($text));
+ */\r
+ public function testExpandAclEmptyMatch() {\r
+ $text="<1><><3>";\r
+ $this->assertEquals(array(1,3), expand_acl($text));\r
}
}
\ No newline at end of file
$args=func_get_args();
//last parameter is always (in this test) uid, so, it should be 11
- if ($args[count($args)-1]!=11) {
+ if($args[count($args)-1]!=11) {
return;
}
- if (3==count($args)) {
+ if(3==count($args)) {
//first call in handle_body, id only
- if ($result[0]['id']==$args[1]) {
+ if($result[0]['id']==$args[1]) {
return $result;
}
//second call in handle_body, name
- if ($result[0]['name']===$args[1]) {
+ if($result[0]['name']===$args[1]) {
return $result;
}
}
//third call in handle_body, nick or attag
- if ($result[0]['nick']===$args[2] || $result[0]['attag']===$args[1]) {
+ if($result[0]['nick']===$args[2] || $result[0]['attag']===$args[1]) {
return $result;
}
}
$inform='';
$str_tags='';
- foreach ($tags as $tag) {
+ foreach($tags as $tag) {
handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
}
$inform='';
$str_tags='';
- foreach ($tags as $tag) {
+ foreach($tags as $tag) {
handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
}
$inform='';
$str_tags='';
- foreach ($tags as $tag) {
+ foreach($tags as $tag) {
handle_tag($this->a, $text, $inform, $str_tags, 11, $tag);
}
<?php
-/**
- * this file contains tests for the template engine
- *
- * @package test.util
- */
-
-/** required, it is the file under test */
+/**\r
+ * this file contains tests for the template engine\r
+ *\r
+ * @package test.util\r
+ */\r
+\r
+/** required, it is the file under test */\r
require_once('include/template_processor.php');
require_once('include/text.php');
public $theme_info=array();
}
-if (!function_exists('current_theme')) {
-function current_theme() {
- return 'clean';
+if(!function_exists('current_theme')) {
+function current_theme() {\r
+ return 'clean';\r
}
}
-if (!function_exists('x')) {
+if(!function_exists('x')) {
function x($s,$k = NULL) {
return false;
}
}
-if (!function_exists('get_app')) {
+if(!function_exists('get_app')) {
function get_app() {
return new TemplateMockApp();
}
}
-/**
- * TestCase for the template engine
- *
- * @author Alexander Kampmann
- * @package test.util
- */
+/**\r
+ * TestCase for the template engine\r
+ *\r
+ * @author Alexander Kampmann\r
+ * @package test.util\r
+ */\r
class TemplateTest extends PHPUnit_Framework_TestCase {
public function setUp() {
$this->assertEquals('Hello Anna!', $text);
}
- public function testSimpleVariableInt() {
- $tpl='There are $num new messages!';
-
- $text=replace_macros($tpl, array('$num'=>172));
-
- $this->assertEquals('There are 172 new messages!', $text);
+ public function testSimpleVariableInt() {\r
+ $tpl='There are $num new messages!';\r
+\r
+ $text=replace_macros($tpl, array('$num'=>172));\r
+\r
+ $this->assertEquals('There are 172 new messages!', $text);\r
}
- public function testConditionalElse() {
- $tpl='There{{ if $num!=1 }} are $num new messages{{ else }} is 1 new message{{ endif }}!';
-
+ public function testConditionalElse() {\r
+ $tpl='There{{ if $num!=1 }} are $num new messages{{ else }} is 1 new message{{ endif }}!';\r
+\r
$text1=replace_macros($tpl, array('$num'=>1));
- $text22=replace_macros($tpl, array('$num'=>22));
-
+ $text22=replace_macros($tpl, array('$num'=>22));\r
+\r
$this->assertEquals('There is 1 new message!', $text1);
- $this->assertEquals('There are 22 new messages!', $text22);
+ $this->assertEquals('There are 22 new messages!', $text22);\r
}
- public function testConditionalNoElse() {
- $tpl='{{ if $num!=0 }}There are $num new messages!{{ endif }}';
-
- $text0=replace_macros($tpl, array('$num'=>0));
- $text22=replace_macros($tpl, array('$num'=>22));
-
- $this->assertEquals('', $text0);
- $this->assertEquals('There are 22 new messages!', $text22);
+ public function testConditionalNoElse() {\r
+ $tpl='{{ if $num!=0 }}There are $num new messages!{{ endif }}';\r
+\r
+ $text0=replace_macros($tpl, array('$num'=>0));\r
+ $text22=replace_macros($tpl, array('$num'=>22));\r
+\r
+ $this->assertEquals('', $text0);\r
+ $this->assertEquals('There are 22 new messages!', $text22);\r
}
- public function testConditionalFail() {
- $tpl='There {{ if $num!=1 }} are $num new messages{{ else }} is 1 new message{{ endif }}!';
-
- $text1=replace_macros($tpl, array());
-
- //$this->assertEquals('There is 1 new message!', $text1);
+ public function testConditionalFail() {\r
+ $tpl='There {{ if $num!=1 }} are $num new messages{{ else }} is 1 new message{{ endif }}!';\r
+\r
+ $text1=replace_macros($tpl, array());\r
+\r
+ //$this->assertEquals('There is 1 new message!', $text1);\r
}
- public function testSimpleFor() {
- $tpl='{{ for $messages as $message }} $message {{ endfor }}';
-
- $text=replace_macros($tpl, array('$messages'=>array('message 1', 'message 2')));
-
- $this->assertEquals(' message 1 message 2 ', $text);
+ public function testSimpleFor() {\r
+ $tpl='{{ for $messages as $message }} $message {{ endfor }}';\r
+\r
+ $text=replace_macros($tpl, array('$messages'=>array('message 1', 'message 2')));\r
+\r
+ $this->assertEquals(' message 1 message 2 ', $text);\r
}
- public function testFor() {
- $tpl='{{ for $messages as $message }} from: $message.from to $message.to {{ endfor }}';
-
- $text=replace_macros($tpl, array('$messages'=>array(array('from'=>'Mike', 'to'=>'Alex'), array('from'=>'Alex', 'to'=>'Mike'))));
-
- $this->assertEquals(' from: Mike to Alex from: Alex to Mike ', $text);
+ public function testFor() {\r
+ $tpl='{{ for $messages as $message }} from: $message.from to $message.to {{ endfor }}';\r
+\r
+ $text=replace_macros($tpl, array('$messages'=>array(array('from'=>'Mike', 'to'=>'Alex'), array('from'=>'Alex', 'to'=>'Mike'))));\r
+\r
+ $this->assertEquals(' from: Mike to Alex from: Alex to Mike ', $text);\r
}
- public function testKeyedFor() {
- $tpl='{{ for $messages as $from=>$to }} from: $from to $to {{ endfor }}';
-
- $text=replace_macros($tpl, array('$messages'=>array('Mike'=>'Alex', 'Sven'=>'Mike')));
-
- $this->assertEquals(' from: Mike to Alex from: Sven to Mike ', $text);
+ public function testKeyedFor() {\r
+ $tpl='{{ for $messages as $from=>$to }} from: $from to $to {{ endfor }}';\r
+ \r
+ $text=replace_macros($tpl, array('$messages'=>array('Mike'=>'Alex', 'Sven'=>'Mike')));\r
+ \r
+ $this->assertEquals(' from: Mike to Alex from: Sven to Mike ', $text);\r
}
- public function testForEmpty() {
- $tpl='messages: {{for $messages as $message}} from: $message.from to $message.to {{ endfor }}';
-
- $text=replace_macros($tpl, array('$messages'=>array()));
-
- $this->assertEquals('messages: ', $text);
+ public function testForEmpty() {\r
+ $tpl='messages: {{for $messages as $message}} from: $message.from to $message.to {{ endfor }}';\r
+\r
+ $text=replace_macros($tpl, array('$messages'=>array()));\r
+\r
+ $this->assertEquals('messages: ', $text);\r
}
- public function testForWrongType() {
- $tpl='messages: {{for $messages as $message}} from: $message.from to $message.to {{ endfor }}';
-
- $text=replace_macros($tpl, array('$messages'=>11));
-
- $this->assertEquals('messages: ', $text);
+ public function testForWrongType() {\r
+ $tpl='messages: {{for $messages as $message}} from: $message.from to $message.to {{ endfor }}';\r
+\r
+ $text=replace_macros($tpl, array('$messages'=>11));\r
+\r
+ $this->assertEquals('messages: ', $text);\r
}
- public function testForConditional() {
- $tpl='new messages: {{for $messages as $message}}{{ if $message.new }} $message.text{{endif}}{{ endfor }}';
-
+ public function testForConditional() {\r
+ $tpl='new messages: {{for $messages as $message}}{{ if $message.new }} $message.text{{endif}}{{ endfor }}';\r
+\r
$text=replace_macros($tpl, array('$messages'=>array(
array('new'=>true, 'text'=>'new message'),
- array('new'=>false, 'text'=>'old message'))));
-
- $this->assertEquals('new messages: new message', $text);
+ array('new'=>false, 'text'=>'old message'))));\r
+\r
+ $this->assertEquals('new messages: new message', $text);\r
}
- public function testConditionalFor() {
- $tpl='{{ if $enabled }}new messages:{{for $messages as $message}} $message.text{{ endfor }}{{endif}}';
-
+ public function testConditionalFor() {\r
+ $tpl='{{ if $enabled }}new messages:{{for $messages as $message}} $message.text{{ endfor }}{{endif}}';\r
+ \r
$text=replace_macros($tpl, array('$enabled'=>true,
- '$messages'=>array(
- array('new'=>true, 'text'=>'new message'),
- array('new'=>false, 'text'=>'old message'))));
-
- $this->assertEquals('new messages: new message old message', $text);
- }
-
- public function testFantasy() {
- $tpl='Fantasy: {{fantasy $messages}}';
-
- $text=replace_macros($tpl, array('$messages'=>'no no'));
-
- $this->assertEquals('Fantasy: {{fantasy no no}}', $text);
- }
-
- public function testInc() {
- $tpl='{{inc field_input.tpl with $field=$myvar}}{{ endinc }}';
-
- $text=replace_macros($tpl, array('$myvar'=>array('myfield', 'label', 'value', 'help')));
-
+ '$messages'=>array(\r
+ array('new'=>true, 'text'=>'new message'),\r
+ array('new'=>false, 'text'=>'old message'))));\r
+ \r
+ $this->assertEquals('new messages: new message old message', $text);\r
+ }
+
+ public function testFantasy() {\r
+ $tpl='Fantasy: {{fantasy $messages}}';\r
+\r
+ $text=replace_macros($tpl, array('$messages'=>'no no'));\r
+\r
+ $this->assertEquals('Fantasy: {{fantasy no no}}', $text);\r
+ }
+
+ public function testInc() {\r
+ $tpl='{{inc field_input.tpl with $field=$myvar}}{{ endinc }}';\r
+\r
+ $text=replace_macros($tpl, array('$myvar'=>array('myfield', 'label', 'value', 'help')));\r
+\r
$this->assertEquals(" \n"
." <div class='field input'>\n"
." <label for='id_myfield'>label</label>\n"
." <input name='myfield' id='id_myfield' value=\"value\">\n"
." <span class='field_help'>help</span>\n"
- ." </div>\n", $text);
+ ." </div>\n", $text);\r
}
- public function testIncNoVar() {
- $tpl='{{inc field_input.tpl }}{{ endinc }}';
-
- $text=replace_macros($tpl, array('$field'=>array('myfield', 'label', 'value', 'help')));
-
- $this->assertEquals(" \n <div class='field input'>\n <label for='id_myfield'>label</label>\n"
- ." <input name='myfield' id='id_myfield' value=\"value\">\n"
- ." <span class='field_help'>help</span>\n"
- ." </div>\n", $text);
+ public function testIncNoVar() {\r
+ $tpl='{{inc field_input.tpl }}{{ endinc }}';\r
+\r
+ $text=replace_macros($tpl, array('$field'=>array('myfield', 'label', 'value', 'help')));\r
+\r
+ $this->assertEquals(" \n <div class='field input'>\n <label for='id_myfield'>label</label>\n"\r
+ ." <input name='myfield' id='id_myfield' value=\"value\">\n"\r
+ ." <span class='field_help'>help</span>\n"\r
+ ." </div>\n", $text);\r
}
- public function testDoubleUse() {
- $tpl='Hello $name! {{ if $enabled }} I love you! {{ endif }}';
-
- $text=replace_macros($tpl, array('$name'=>'Anna', '$enabled'=>false));
-
+ public function testDoubleUse() {\r
+ $tpl='Hello $name! {{ if $enabled }} I love you! {{ endif }}';\r
+ \r
+ $text=replace_macros($tpl, array('$name'=>'Anna', '$enabled'=>false));\r
+ \r
$this->assertEquals('Hello Anna! ', $text);
- $tpl='Hey $name! {{ if $enabled }} I hate you! {{ endif }}';
-
- $text=replace_macros($tpl, array('$name'=>'Max', '$enabled'=>true));
-
- $this->assertEquals('Hey Max! I hate you! ', $text);
+ $tpl='Hey $name! {{ if $enabled }} I hate you! {{ endif }}';\r
+ \r
+ $text=replace_macros($tpl, array('$name'=>'Max', '$enabled'=>true));\r
+ \r
+ $this->assertEquals('Hey Max! I hate you! ', $text);\r
}
- public function testIncDouble() {
+ public function testIncDouble() {\r
$tpl='{{inc field_input.tpl with $field=$var1}}{{ endinc }}'
- .'{{inc field_input.tpl with $field=$var2}}{{ endinc }}';
-
+ .'{{inc field_input.tpl with $field=$var2}}{{ endinc }}';\r
+ \r
$text=replace_macros($tpl, array('$var1'=>array('myfield', 'label', 'value', 'help'),
- '$var2'=>array('myfield2', 'label2', 'value2', 'help2')));
-
- $this->assertEquals(" \n"
- ." <div class='field input'>\n"
- ." <label for='id_myfield'>label</label>\n"
- ." <input name='myfield' id='id_myfield' value=\"value\">\n"
- ." <span class='field_help'>help</span>\n"
+ '$var2'=>array('myfield2', 'label2', 'value2', 'help2')));\r
+ \r
+ $this->assertEquals(" \n"\r
+ ." <div class='field input'>\n"\r
+ ." <label for='id_myfield'>label</label>\n"\r
+ ." <input name='myfield' id='id_myfield' value=\"value\">\n"\r
+ ." <span class='field_help'>help</span>\n"\r
." </div>\n"
." \n"
." <div class='field input'>\n"
." <label for='id_myfield2'>label2</label>\n"
." <input name='myfield2' id='id_myfield2' value=\"value2\">\n"
." <span class='field_help'>help2</span>\n"
- ." </div>\n", $text);
+ ." </div>\n", $text);\r
}
}
\ No newline at end of file
$this->assertEquals($text, $retext);
}
- /**
- * xmlify and put in a document
- */
- public function testXmlifyDocument() {
- $tag="<tag>I want to break</tag>";
+ /**\r
+ * xmlify and put in a document\r
+ */\r
+ public function testXmlifyDocument() {\r
+ $tag="<tag>I want to break</tag>";\r
$xml=xmlify($tag);
- $text='<text>'.$xml.'</text>';
+ $text='<text>'.$xml.'</text>'; \r
$xml_parser=xml_parser_create();
//should be possible to parse it
$this->assertEquals(array('TEXT'=>array(0)),
$index);
- $this->assertEquals(array(array('tag'=>'TEXT', 'type'=>'complete', 'level'=>1, 'value'=>$tag)),
+ $this->assertEquals(array(array('tag'=>'TEXT', 'type'=>'complete', 'level'=>1, 'value'=>$tag)),\r
$values);
- xml_parser_free($xml_parser);
+ xml_parser_free($xml_parser); \r
}
/**
*/
-/// @TODO These old updates need to have UPDATE_SUCCESS returned on success?
+
function update_1000() {
q("ALTER TABLE `item` DROP `like`, DROP `dislike` ");
if (dbm::is_result($r)) {
foreach ($r as $rr) {
$ph = new Photo($rr['data']);
- if ($ph->is_valid()) {
+ if($ph->is_valid()) {
$ph->scaleImage(48);
$ph->store($rr['uid'],$rr['contact-id'],$rr['resource-id'],$rr['filename'],$rr['album'],6,(($rr['profile']) ? 1 : 0));
}
$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_1031() {
// Repair any bad links that slipped into the item table
$r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
- if (dbm::is_result($r)) {
+ if($r && dbm::is_result($r)) {
foreach ($r as $rr) {
- if (strstr($rr['object'],'type="http')) {
+ if(strstr($rr['object'],'type="http')) {
q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
dbesc(str_replace('type="http','href="http',$rr['object'])),
intval($rr['id'])
}
function update_1037() {
+
q("ALTER TABLE `contact` CHANGE `lrdd` `alias` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ");
+
}
function update_1038() {
- q("ALTER TABLE `item` ADD `plink` CHAR( 255 ) NOT NULL AFTER `target` ");
+ q("ALTER TABLE `item` ADD `plink` CHAR( 255 ) NOT NULL AFTER `target` ");
}
function update_1039() {
}
function update_1066() {
- $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) {
+ $r = q("ALTER TABLE `item` ADD `received` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `edited` ");
+ if($r)
q("ALTER TABLE `item` ADD INDEX ( `received` ) ");
- }
$r = q("UPDATE `item` SET `received` = `edited` WHERE 1");
}
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`");
}
$x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
dbesc($guid)
);
- if (!dbm::is_result($x)) {
+ if(! count($x))
$found = false;
- }
} while ($found == true );
q("UPDATE `user` SET `guid` = '%s' WHERE `uid` = %d",
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'])
);
$x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
intval($rr['id'])
);
-
- if (dbm::is_result($x)) {
+ if(count($x))
q("UPDATE `item` SET `commented` = '%s' WHERE `id` = %d",
dbesc($x[0]['cdate']),
intval($rr['id'])
);
- }
}
}
}
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'])
);
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` ) ");
$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`) ");
}
function update_1122() {
- q("ALTER TABLE `notify` ADD `hash` CHAR( 64 ) NOT NULL AFTER `id` ,
+q("ALTER TABLE `notify` ADD `hash` CHAR( 64 ) NOT NULL AFTER `id` ,
ADD INDEX ( `hash` ) ");
}
function update_1123() {
- set_config('system','allowed_themes','dispy,quattro,testbubble,vier,darkbubble,darkzero,duepuntozero,greenzero,purplezero,quattro-green,slackr');
+set_config('system','allowed_themes','dispy,quattro,testbubble,vier,darkbubble,darkzero,duepuntozero,greenzero,purplezero,quattro-green,slackr');
}
function update_1124() {
- q("ALTER TABLE `item` ADD INDEX (`author-name`) ");
+q("alter table item add index (`author-name`) ");
}
function update_1125() {
`receiver-uid` INT NOT NULL,
INDEX ( `master-parent-item` ),
INDEX ( `receiver-uid` )
- ) DEFAULT CHARSET=utf8");
+ ) ENGINE = MyISAM DEFAULT CHARSET=utf8");
}
function update_1126() {
INDEX ( `spam` ),
INDEX ( `ham` ),
INDEX ( `term` )
- ) DEFAULT CHARSET=utf8");
+ ) ENGINE = MyISAM DEFAULT CHARSET=utf8");
}
function update_1128() {
- q("ALTER TABLE `spam` ADD `date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `term` ");
+ q("alter table spam add `date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `term` ");
}
function update_1129() {
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` CHAR( 255 ) NOT NULL,
INDEX ( `username` )
-) ");
+) ENGINE = MYISAM ");
}
function update_1133() {
- q("ALTER TABLE `user` ADD `unkmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `blocktags` , ADD INDEX ( `unkmail` ) ");
- q("ALTER TABLE `user` ADD `cntunkmail` INT NOT NULL DEFAULT '10' AFTER `unkmail` , ADD INDEX ( `cntunkmail` ) ");
- q("ALTER TABLE `mail` ADD `unknown` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `replied` , ADD INDEX ( `unknown` ) ");
+q("ALTER TABLE `user` ADD `unkmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `blocktags` , ADD INDEX ( `unkmail` ) ");
+q("ALTER TABLE `user` ADD `cntunkmail` INT NOT NULL DEFAULT '10' AFTER `unkmail` , ADD INDEX ( `cntunkmail` ) ");
+q("ALTER TABLE `mail` ADD `unknown` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `replied` , ADD INDEX ( `unknown` ) ");
}
function update_1134() {
// 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']) {
+ 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'])
);
}
}
- if (! $found) {
+ if(! $found) {
$arr[] = $rr;
}
}
}
$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']) {
+ 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'])
);
}
}
- if (! $found) {
+ if(! $found) {
$arr[] = $rr;
}
}
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_SUCCESS ;
- }
-
- 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_FAILED ;
+ return UPDATE_SUCCESS ;
}
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_SUCCESS ;
- }
-
- 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_FAILED ;
+ 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_SUCCESS ;
- }
-
- return UPDATE_FAILED ;
+ $r = q("alter table glink add zcid int(11) not null after gcid, add index(zcid) ");
+ if(! $r)
+ return UPDATE_FAILED ;
+ return UPDATE_SUCCESS ;
}
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_SUCCESS ;
- }
-
- 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_FAILED ;
+ return UPDATE_SUCCESS ;
}
function update_1143() {
- $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 ;
+ $r = q("alter table user add def_gid int(11) not null default '0' after service_class");
+ if(! $r)
+ return UPDATE_FAILED ;
+ return UPDATE_SUCCESS ;
}
function update_1144() {
- $r = q("ALTER TABLE `contact` ADD `prv` TINYINT(1) NOT NULL DEFAULT '0' AFTER `forum`");
-
- if ($r) {
- return UPDATE_SUCCESS ;
- }
-
- return UPDATE_FAILED ;
+ $r = q("alter table contact add prv tinyint(1) not null default '0' after forum");
+ if(! $r)
+ return UPDATE_FAILED ;
+ return UPDATE_SUCCESS ;
}
function update_1145() {
- $r = q("ALTER TABLE `profile` ADD `howlong` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `with`");
-
- if ($r) {
- return UPDATE_SUCCESS ;
- }
-
- return UPDATE_FAILED ;
+ $r = q("alter table profile add howlong datetime not null default '0001-01-01 00:00:00' after `with`");
+ if(! $r)
+ return UPDATE_FAILED ;
+ 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_SUCCESS ;
- }
-
- return UPDATE_FAILED ;
+ $r = q("alter table profile add hometown char(255) not null after `country-name`, add index ( `hometown` ) ");
+ if(! $r)
+ return UPDATE_FAILED ;
+ return UPDATE_SUCCESS ;
}
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_SUCCESS ;
- }
-
- return UPDATE_FAILED ;
+ if((! $r1) || (! $r2) || (! $r3))
+ return UPDATE_FAILED ;
+ 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_SUCCESS ;
- }
-
- return UPDATE_FAILED ;
+ $r = q("ALTER TABLE photo ADD type CHAR(128) NOT NULL DEFAULT 'image/jpeg' AFTER filename");
+ if (!$r)
+ return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
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_SUCCESS;
- }
-
- 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_FAILED;
+ return UPDATE_SUCCESS;
}
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_SUCCESS ;
- }
-
- 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_FAILED;
+ return UPDATE_SUCCESS;
}
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'
- ) DEFAULT CHARSET=utf8 ");
-
- if ($r) {
- return UPDATE_SUCCESS ;
- }
-
- 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'
+ ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
+ if (!$r)
+ return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
function update_1152() {
KEY `otype` ( `otype` ),
KEY `type` ( `type` ),
KEY `term` ( `term` )
- ) DEFAULT CHARSET=utf8 ");
-
- if ($r) {
- return UPDATE_SUCCESS;
- }
-
- return UPDATE_FAILED;
+ ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
+ if (!$r)
+ return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
function update_1153() {
$r = q("ALTER TABLE `hook` ADD `priority` INT(11) UNSIGNED NOT NULL DEFAULT '0'");
- if ($r) {
- return UPDATE_SUCCESS;
- }
-
- return UPDATE_FAILED;
+ if(!$r) return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
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_SUCCESS;
- }
-
- return UPDATE_FAILED;
+ if(!$r) return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
function update_1155() {
$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;
}
$r = q("ALTER TABLE `photo` ADD `datasize` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `width` ,
ADD INDEX ( `datasize` ) ");
- if ($r) {
- return UPDATE_SUCCESS;
- }
-
- return UPDATE_FAILED;
+ if(!$r) return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
function update_1157() {
- $r = q("CREATE TABLE IF NOT EXISTS `dsprphotoq` (
+ $r = q("CREATE TABLE IF NOT EXISTS `dsprphotoq` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(11) NOT NULL,
`msg` mediumtext NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=utf8"
);
- if ($r) {
+ if($r)
return UPDATE_SUCCESS;
- }
-
- return UPDATE_FAILED;
}
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;
}
ADD INDEX (`uid`),
ADD INDEX (`aid`)");
- if ($r) {
- return UPDATE_SUCCESS;
- }
+ if(!$r)
+ return UPDATE_FAILED;
- return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
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_SUCCESS;
- }
+ if(!$r)
+ return UPDATE_FAILED;
- return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
function update_1161() {
$r = q("ALTER TABLE `pconfig` ADD INDEX (`cat`)");
- if ($r) {
- return UPDATE_SUCCESS;
- }
+ if(!$r)
+ return UPDATE_FAILED;
- return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
function update_1162() {
$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;
+ return UPDATE_SUCCESS;
}
function update_1164() {
set_config('system', 'maintenance', 1);
function update_1165() {
$r = q("CREATE TABLE IF NOT EXISTS `push_subscriber` (
- `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `uid` INT NOT NULL,
- `callback_url` CHAR( 255 ) NOT NULL,
- `topic` CHAR( 255 ) NOT NULL,
- `nickname` CHAR( 255 ) NOT NULL,
- `push` INT NOT NULL,
- `last_update` DATETIME NOT NULL,
- `secret` CHAR( 255 ) NOT NULL
- ) DEFAULT CHARSET=utf8 ");
-
- if ($r) {
- return UPDATE_SUCCESS;
- }
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ `uid` INT NOT NULL,
+ `callback_url` CHAR( 255 ) NOT NULL,
+ `topic` CHAR( 255 ) NOT NULL,
+ `nickname` CHAR( 255 ) NOT NULL,
+ `push` INT NOT NULL,
+ `last_update` DATETIME NOT NULL,
+ `secret` CHAR( 255 ) NOT NULL
+ ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
+ if (!$r)
+ return UPDATE_FAILED;
- return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
function update_1166() {
`name` CHAR(255) NOT NULL,
`avatar` CHAR(255) NOT NULL,
INDEX (`url`)
- ) DEFAULT CHARSET=utf8 ");
-
- if ($r) {
- return UPDATE_SUCCESS;
- }
+ ) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
+ if (!$r)
+ return UPDATE_FAILED;
- return UPDATE_FAILED;
+ return UPDATE_SUCCESS;
}
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;
+ return UPDATE_SUCCESS;
}
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 ;
+ return UPDATE_SUCCESS;
}
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");
$plugins = get_config('system','addon');
$plugins_arr = array();
- if ($plugins) {
+ if($plugins) {
$plugins_arr = explode(",",str_replace(" ", "",$plugins));
$idx = array_search($plugin, $plugins_arr);
$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);
}
echo "New DB VERSION: " . DB_UPDATE_VERSION . "\n";
-if ($build != DB_UPDATE_VERSION) {
+if($build != DB_UPDATE_VERSION) {
echo "Updating database...";
check_db($a);
echo "Done\n";
*/
function namesList($fileset) {
$fsparam="";
- foreach ($fileset as $file) {
+ foreach($fileset as $file) {
$fsparam=$fsparam.",".$file;
}
return $fsparam;
function runs($fileset) {
$fsParam=namesList($fileset);
exec('docblox -t phpdoc_out -f '.$fsParam);
- if (file_exists("phpdoc_out/index.html")) {
+ if(file_exists("phpdoc_out/index.html")) {
echo "\n Subset ".$fsParam." is okay. \n";
exec('rm -r phpdoc_out');
return true;
//filter working subsets...
$parts=array_filter($parts, "runs");
//melt remaining parts together
- if (is_array($parts)) {
+ if(is_array($parts)) {
return array_reduce($parts, "array_merge", array());
}
return array();
$filelist=array();
//loop over all files in $dir
-while ($dh=opendir($dir)) {
- while ($file=readdir($dh)) {
- if (is_dir($dir."/".$file)) {
+while($dh=opendir($dir)) {
+ while($file=readdir($dh)) {
+ if(is_dir($dir."/".$file)) {
//add to directory stack
- if ($file!=".." && $file!=".") {
+ if($file!=".." && $file!=".") {
array_push($dirstack, $dir."/".$file);
echo "dir ".$dir."/".$file."\n";
}
} else {
//test if it is a source file and add to filelist
- if (substr($file, strlen($file)-4)==".php") {
+ if(substr($file, strlen($file)-4)==".php") {
array_push($filelist, $dir."/".$file);
echo $dir."/".$file."\n";
}
}
//check the entire set
-if (runs($filelist)) {
+if(runs($filelist)) {
echo "I can not detect a problem. \n";
exit;
}
echo $i."/".count($fileset)." elements remaining. \n";
$res=reduce($res, count($res)/2);
shuffle($res);
-} while (count($res)<$i);
+} while(count($res)<$i);
//check one file after another
$needed=array();
-while (count($res)!=0) {
+while(count($res)!=0) {
$file=array_pop($res);
- if (runs(array_merge($res, $needed))) {
+ if(runs(array_merge($res, $needed))) {
echo "needs: ".$file." and file count ".count($needed);
array_push($needed, $file);
}
$files = array_merge($files,glob('mod/*'),glob('include/*'),glob('addon/*/*'));
- foreach ($files as $file) {
+ foreach($files as $file) {
$str = file_get_contents($file);
$pat = '| t\(([^\)]*)\)|';
preg_match_all($patt, $str, $matchestt);
- if (count($matches)){
- foreach ($matches[1] as $match) {
- if (! in_array($match,$arr))
+ if(count($matches)){
+ foreach($matches[1] as $match) {
+ if(! in_array($match,$arr))
$arr[] = $match;
}
}
- if (count($matchestt)){
- foreach ($matchestt[1] as $match) {
+ if(count($matchestt)){
+ foreach($matchestt[1] as $match) {
$matchtkns = preg_split("|[ \t\r\n]*,[ \t\r\n]*|",$match);
if (count($matchtkns)==3 && !in_array($matchtkns,$arr)){
$arr[] = $matchtkns;
';
- foreach ($arr as $a) {
+ foreach($arr as $a) {
if (is_array($a)){
- if (substr($a[1],0,1) == '$') {
+ if(substr($a[1],0,1) == '$')
continue;
- }
$s .= '$a->strings[' . $a[0] . "] = array(\n";
$s .= "\t0 => ". $a[0]. ",\n";
$s .= "\t1 => ". $a[1]. ",\n";
$s .= ");\n";
} else {
- if (substr($a,0,1) == '$') {
- continue;
- }
+ if(substr($a,0,1) == '$')
+ continue;
$s .= '$a->strings[' . $a . '] = '. $a . ';' . "\n";
}
}
$zones = timezone_identifiers_list();
- foreach ($zones as $zone) {
+ foreach($zones as $zone)
$s .= '$a->strings[\'' . $zone . '\'] = \'' . $zone . '\';' . "\n";
- }
-
+
echo $s;
\ No newline at end of file
DEFINE("NORM_REGEXP", "|[\\\]|");
- if (! class_exists('App')) {
+ if(! class_exists('App')) {
class TmpA {
public $strings = Array();
}
}
$infile = file($phpfile);
- foreach ($infile as $l) {
+ foreach($infile as $l) {
$l = trim($l);
if (startsWith($l, 'function string_plural_select_')) {
$lang = str_replace( 'function string_plural_select_' , '', str_replace( '($n){','', $l) );
$norm_base_msgids = array();
$base_f = file("util/messages.po") or die("No base messages.po\n");
$_f = 0; $_mid = ""; $_mids = array();
- foreach ( $base_f as $l) {
+ foreach( $base_f as $l) {
$l = trim($l);
//~ print $l."\n";
}
$warnings = "";
- foreach ($a->strings as $key=>$str) {
+ foreach($a->strings as $key=>$str) {
$msgid = massage_string($key);
if (preg_match("|%[sd0-9](\$[sn])*|", $msgid)) {
$pofile = $argv[1];
$outfile = dirname($pofile)."/strings.php";
- if (strstr($outfile,'util')) {
+ if(strstr($outfile,'util'))
$lang = 'en';
- } else {
+ else
$lang = str_replace('-','_',basename(dirname($pofile)));
- }
foreach ($infile as $l) {
$l = str_replace('\"', DQ_ESCAPE, $l);
$len = strlen($l);
- if ($l[0]=="#") {
- $l="";
- }
- if (substr($l,0,15) == '"Plural-Forms: '){
+ if ($l[0]=="#") $l="";
+ if (substr($l,0,15)=='"Plural-Forms: '){
$match=Array();
preg_match("|nplurals=([0-9]*); *plural=(.*)[;\\\\]|", $l, $match);
$cond = str_replace('n','$n',$match[2]);
// define plural select function if not already defined
$fnname = 'string_plural_select_' . $lang;
- $out .= 'if (! function_exists("'.$fnname.'")) {'."\n";
+ $out .= 'if(! function_exists("'.$fnname.'")) {'."\n";
$out .= 'function '. $fnname . '($n){'."\n";
$out .= ' return '.$cond.';'."\n";
$out .= '}}'."\n";
}
- if ($k!="" && substr($l,0,7) == "msgstr "){
- if ($ink) {
- $ink = False;
- $out .= '$a->strings["'.$k.'"] = ';
- }
- if ($inv) {
- $inv = False;
- $out .= '"'.$v.'"';
- }
+
+
+
+ if ($k!="" && substr($l,0,7)=="msgstr "){
+ if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
+ if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
$v = substr($l,8,$len-10);
$v = preg_replace_callback($escape_s_exp,'escape_s',$v);
$inv = True;
//$out .= $v;
}
- if ($k!="" && substr($l,0,7) == "msgstr["){
- if ($ink) {
- $ink = False;
- $out .= '$a->strings["'.$k.'"] = ';
- }
- if ($inv) {
- $inv = False;
- $out .= '"'.$v.'"';
- }
+ if ($k!="" && substr($l,0,7)=="msgstr["){
+ if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
+ if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
if (!$arr) {
$arr=True;
if (substr($l,0,6)=="msgid_") { $ink = False; $out .= '$a->strings["'.$k.'"] = '; };
+
if ($ink) {
$k .= trim($l,"\"\r\n");
$k = preg_replace_callback($escape_s_exp,'escape_s',$k);
}
if (substr($l,0,6)=="msgid "){
- if ($inv) {
- $inv = False;
- $out .= '"'.$v.'"';
- }
- if ($k != "") {
- $out .= $arr?");\n":";\n";
- }
- $arr = False;
+ if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
+ if ($k!="") $out .= $arr?");\n":";\n";
+ $arr=False;
$k = str_replace("msgid ","",$l);
if ($k != '""' ) {
$k = trim($k,"\"\r\n");
}
- if ($inv) {
- $inv = False;
- $out .= '"'.$v.'"';
- }
- if ($k!="") {
- $out .= $arr?");\n":";\n";
- }
+ if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
+ if ($k!="") $out .= $arr?");\n":";\n";
$out = str_replace(DQ_ESCAPE, '\"', $out);
file_put_contents($outfile, $out);
<?php
-// Tired of chasing typos and finding them after a commit.
-// Run this from cmdline in basedir and quickly see if we've
-// got any parse errors in our application files.
-
-
-error_reporting(E_ERROR | E_WARNING | E_PARSE );
-ini_set('display_errors', '1');
-ini_set('log_errors','0');
-
-include 'boot.php';
-
-$a = new App();
-
-if (x($a->config,'php_path')) {
- $phpath = $a->config['php_path'];
-} else {
- $phpath = 'php';
-}
-
-echo "Directory: mod\n";
-$files = glob('mod/*.php');
-foreach ($files as $file) {
- passthru("$phpath -l $file", $ret); $ret===0 or die();
-}
-
-echo "Directory: include\n";
-$files = glob('include/*.php');
-foreach ($files as $file) {
- passthru("$phpath -l $file", $ret); $ret===0 or die();
-}
-
-echo "Directory: object\n";
-$files = glob('object/*.php');
-foreach ($files as $file) {
- passthru("$phpath -l $file", $ret); $ret===0 or die();
-}
-
-echo "Directory: addon\n";
-$dirs = glob('addon/*');
-
-foreach ($dirs as $dir) {
- $addon = basename($dir);
- $files = glob($dir . '/' . $addon . '.php');
- foreach ($files as $file) {
- passthru("$phpath -l $file", $ret); $ret===0 or die();
+ // Tired of chasing typos and finding them after a commit.
+ // Run this from cmdline in basedir and quickly see if we've
+ // got any parse errors in our application files.
+
+
+ error_reporting(E_ERROR | E_WARNING | E_PARSE );
+ ini_set('display_errors', '1');
+ ini_set('log_errors','0');
+
+ include 'boot.php';
+
+ $a = new App();
+
+ if(x($a->config,'php_path'))
+ $phpath = $a->config['php_path'];
+ else
+ $phpath = 'php';
+
+
+ echo "Directory: mod\n";
+ $files = glob('mod/*.php');
+ foreach($files as $file) {
+ passthru("$phpath -l $file", $ret); $ret===0 or die();
+ }
+
+ echo "Directory: include\n";
+ $files = glob('include/*.php');
+ foreach($files as $file) {
+ passthru("$phpath -l $file", $ret); $ret===0 or die();
+ }
+
+ echo "Directory: object\n";
+ $files = glob('object/*.php');
+ foreach($files as $file) {
+ passthru("$phpath -l $file", $ret); $ret===0 or die();
+ }
+
+ echo "Directory: addon\n";
+ $dirs = glob('addon/*');
+
+ foreach($dirs as $dir) {
+ $addon = basename($dir);
+ $files = glob($dir . '/' . $addon . '.php');
+ foreach($files as $file) {
+ passthru("$phpath -l $file", $ret); $ret===0 or die();
+ }
}
-}
-echo "String files\n";
-echo 'util/strings.php' . "\n";
-passthru("$phpath -l util/strings.php", $ret); $ret===0 or die();
+ echo "String files\n";
-$files = glob('view/lang/*/strings.php');
-foreach ($files as $file) {
- passthru("$phpath -l $file", $ret); $ret===0 or die();
-}
+ echo 'util/strings.php' . "\n";
+ passthru("$phpath -l util/strings.php", $ret); $ret===0 or die();
+
+ $files = glob('view/lang/*/strings.php');
+ foreach($files as $file) {
+ passthru("$phpath -l $file", $ret); $ret===0 or die();
+ }
set_template_engine($a, 'smarty3');
-$colorset = get_pconfig( local_user(), 'duepuntozero','colorset');
-if (!$colorset) {
- $colorset = get_config('duepuntozero', 'colorset'); // user setting have priority, then node settings
-}
-if ($colorset) {
- if ($colorset == 'greenzero') {
- $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/greenzero.css" type="text/css" media="screen" />'."\n";
- }
- if ($colorset == 'purplezero') {
- $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/purplezero.css" type="text/css" media="screen" />'."\n";
- }
- if ($colorset == 'easterbunny') {
- $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/easterbunny.css" type="text/css" media="screen" />'."\n";
- }
- if ($colorset == 'darkzero') {
- $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/darkzero.css" type="text/css" media="screen" />'."\n";
- }
- if ($colorset == 'comix') {
- $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/comix.css" type="text/css" media="screen" />'."\n";
- }
- if ($colorset == 'slackr') {
- $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/slackr.css" type="text/css" media="screen" />'."\n";
- }
-}
+ $colorset = get_pconfig( local_user(), 'duepuntozero','colorset');
+ if (!$colorset)
+ $colorset = get_config('duepuntozero', 'colorset'); // user setting have priority, then node settings
+ if ($colorset) {
+ if ($colorset == 'greenzero')
+ $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/greenzero.css" type="text/css" media="screen" />'."\n";
+ if ($colorset == 'purplezero')
+ $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/purplezero.css" type="text/css" media="screen" />'."\n";
+ if ($colorset == 'easterbunny')
+ $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/easterbunny.css" type="text/css" media="screen" />'."\n";
+ if ($colorset == 'darkzero')
+ $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/darkzero.css" type="text/css" media="screen" />'."\n";
+ if ($colorset == 'comix')
+ $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/comix.css" type="text/css" media="screen" />'."\n";
+ if ($colorset == 'slackr')
+ $a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/slackr.css" type="text/css" media="screen" />'."\n";
+ }
$a->page['htmlhead'] .= <<< EOT
<script>
function insertFormatting(BBcode, id) {
/**
* A color utility that helps manipulate HEX colors
- * @todo convert space -> tab
*/
class Color {
$color = str_replace("#", "", $hex);
// Make sure it's 6 digits
- if ( strlen($color) === 3 ) {
+ if( strlen($color) === 3 ) {
$color = $color[0].$color[0].$color[1].$color[1].$color[2].$color[2];
- } elseif ( strlen($color) != 6 ) {
+ } else if( strlen($color) != 6 ) {
throw new Exception("HEX color needs to be 6 or 3 digits long");
}
*/
public static function hslToHex( $hsl = array() ){
// Make sure it's HSL
- if (empty($hsl) || !isset($hsl["H"]) || !isset($hsl["S"]) || !isset($hsl["L"]) ) {
+ if(empty($hsl) || !isset($hsl["H"]) || !isset($hsl["S"]) || !isset($hsl["L"]) ) {
throw new Exception("Param was not an HSL array");
}
list($H,$S,$L) = array( $hsl['H']/360,$hsl['S'],$hsl['L'] );
- if ( $S == 0 ) {
+ if( $S == 0 ) {
$r = $L * 255;
$g = $L * 255;
$b = $L * 255;
} else {
- if ($L<0.5) {
+ if($L<0.5) {
$var_2 = $L*(1+$S);
} else {
$var_2 = ($L+$S) - ($S*$L);
*/
public static function rgbToHex( $rgb = array() ){
// Make sure it's RGB
- if (empty($rgb) || !isset($rgb["R"]) || !isset($rgb["G"]) || !isset($rgb["B"]) ) {
+ if(empty($rgb) || !isset($rgb["R"]) || !isset($rgb["G"]) || !isset($rgb["B"]) ) {
throw new Exception("Param was not an RGB array");
}
*/
public function makeGradient( $amount = self::DEFAULT_ADJUST ) {
// Decide which color needs to be made
- if ( $this->isLight() ) {
+ if( $this->isLight() ) {
$lightColor = $this->_hex;
$darkColor = $this->darken($amount);
} else {
*/
private function _darken( $hsl, $amount = self::DEFAULT_ADJUST){
// Check if we were provided a number
- if ( $amount ) {
+ if( $amount ) {
$hsl['L'] = ($hsl['L'] * 100) - $amount;
$hsl['L'] = ($hsl['L'] < 0) ? 0:$hsl['L']/100;
} else {
*/
private function _lighten( $hsl, $amount = self::DEFAULT_ADJUST){
// Check if we were provided a number
- if ( $amount ) {
+ if( $amount ) {
$hsl['L'] = ($hsl['L'] * 100) + $amount;
$hsl['L'] = ($hsl['L'] > 100) ? 1:$hsl['L']/100;
} else {
* @return int
*/
private static function _huetorgb( $v1,$v2,$vH ) {
- if ( $vH < 0 ) {
+ if( $vH < 0 ) {
$vH += 1;
}
- if ( $vH > 1 ) {
+ if( $vH > 1 ) {
$vH -= 1;
}
- if ( (6*$vH) < 1 ) {
+ if( (6*$vH) < 1 ) {
return ($v1 + ($v2 - $v1) * 6 * $vH);
}
- if ( (2*$vH) < 1 ) {
+ if( (2*$vH) < 1 ) {
return $v2;
}
- if ( (3*$vH) < 2 ) {
+ if( (3*$vH) < 2 ) {
return ($v1 + ($v2-$v1) * ( (2/3)-$vH ) * 6);
}
$color = str_replace("#", "", $hex);
// Make sure it's 6 digits
- if ( strlen($color) == 3 ) {
+ if( strlen($color) == 3 ) {
$color = $color[0].$color[0].$color[1].$color[1].$color[2].$color[2];
- } elseif ( strlen($color) != 6 ) {
+ } else if( strlen($color) != 6 ) {
throw new Exception("HEX color needs to be 6 or 3 digits long");
}
$occurence = 1;
$p = bb_find_open_close($body_info['html'], "<a", ">");
- while ($p !== false && ($occurence++ < 500)) {
+ while($p !== false && ($occurence++ < 500)) {
$link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']);
$matches = array();
preg_match("/\/photos\/[\w]+\/image\/([\w]+)/", $link, $matches);
- if ($matches) {
+ if($matches) {
// Replace the link for the photo's page with a direct link to the photo itself
$newlink = str_replace($matches[0], "/photo/{$matches[1]}", $link);
$occurence = 1;
$p = bb_find_open_close($body_info['html'], "<a", ">");
- while ($p !== false && ($occurence++ < 500)) {
+ while($p !== false && ($occurence++ < 500)) {
$link = substr($body_info['html'], $p['start'], $p['end'] - $p['start']);
$matches = array();
preg_match("/\/photos\/[\w]+\/image\/([\w]+)/", $link, $matches);
- if ($matches) {
+ if($matches) {
// Replace the link for the photo's page with a direct link to the photo itself
$newlink = str_replace($matches[0], "/photo/{$matches[1]}", $link);