mirror of
https://github.com/friendica/friendica
synced 2025-11-15 20:59:13 +01:00
Revert "Coding convention applied - part 1"
This commit is contained in:
parent
9c2c483996
commit
7b352f3f74
181 changed files with 3507 additions and 4338 deletions
457
boot.php
457
boot.php
|
|
@ -560,12 +560,12 @@ class App {
|
|||
* 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',
|
||||
);
|
||||
|
||||
|
|
@ -654,7 +654,7 @@ class App {
|
|||
|
||||
|
||||
$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') ||
|
||||
|
|
@ -662,12 +662,12 @@ class App {
|
|||
(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
|
||||
|
|
@ -675,7 +675,7 @@ class App {
|
|||
*/
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
@ -711,6 +711,7 @@ class App {
|
|||
// fix query_string
|
||||
$this->query_string = str_replace($this->cmd."&",$this->cmd."?", $this->query_string);
|
||||
|
||||
|
||||
// unix style "homedir"
|
||||
|
||||
if (substr($this->cmd,0,1) === '~') {
|
||||
|
|
@ -741,10 +742,11 @@ class App {
|
|||
|
||||
$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';
|
||||
|
|
@ -758,9 +760,8 @@ class App {
|
|||
$this->pager['page'] = ((x($_GET,'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
|
||||
$this->pager['itemspage'] = 50;
|
||||
$this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
|
||||
if ($this->pager['start'] < 0) {
|
||||
if($this->pager['start'] < 0)
|
||||
$this->pager['start'] = 0;
|
||||
}
|
||||
$this->pager['total'] = 0;
|
||||
|
||||
/*
|
||||
|
|
@ -792,17 +793,14 @@ class App {
|
|||
|
||||
$basepath = get_config("system", "basepath");
|
||||
|
||||
if ($basepath == "") {
|
||||
if ($basepath == "")
|
||||
$basepath = dirname(__FILE__);
|
||||
}
|
||||
|
||||
if ($basepath == "") {
|
||||
if ($basepath == "")
|
||||
$basepath = $_SERVER["DOCUMENT_ROOT"];
|
||||
}
|
||||
|
||||
if ($basepath == "") {
|
||||
if ($basepath == "")
|
||||
$basepath = $_SERVER["PWD"];
|
||||
}
|
||||
|
||||
return($basepath);
|
||||
}
|
||||
|
|
@ -866,7 +864,7 @@ class App {
|
|||
function set_baseurl($url) {
|
||||
$parsed = @parse_url($url);
|
||||
|
||||
if ($parsed) {
|
||||
if($parsed) {
|
||||
$this->scheme = $parsed['scheme'];
|
||||
|
||||
$hostname = $parsed['host'];
|
||||
|
|
@ -878,7 +876,7 @@ class App {
|
|||
}
|
||||
|
||||
if (file_exists(".htpreconfig.php")) {
|
||||
include(".htpreconfig.php");
|
||||
@include(".htpreconfig.php");
|
||||
}
|
||||
|
||||
if (get_config('config', 'hostname') != '') {
|
||||
|
|
@ -892,9 +890,8 @@ class App {
|
|||
}
|
||||
|
||||
function get_hostname() {
|
||||
if (get_config('config','hostname') != "") {
|
||||
if (get_config('config','hostname') != "")
|
||||
$this->hostname = get_config('config','hostname');
|
||||
}
|
||||
|
||||
return $this->hostname;
|
||||
}
|
||||
|
|
@ -929,49 +926,44 @@ class App {
|
|||
$interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000);
|
||||
|
||||
// If the update is "deactivated" set it to the highest integer number (~24 days)
|
||||
if ($interval < 0) {
|
||||
if ($interval < 0)
|
||||
$interval = 2147483647;
|
||||
}
|
||||
|
||||
if ($interval < 10000) {
|
||||
if($interval < 10000)
|
||||
$interval = 40000;
|
||||
}
|
||||
|
||||
// compose the page title from the sitename and the
|
||||
// current module called
|
||||
if (!$this->module=='') {
|
||||
$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);
|
||||
|
|
@ -993,9 +985,8 @@ class App {
|
|||
}
|
||||
|
||||
function init_page_end() {
|
||||
if (!isset($this->page['end'])) {
|
||||
if(!isset($this->page['end']))
|
||||
$this->page['end'] = '';
|
||||
}
|
||||
$tpl = get_markup_template('end.tpl');
|
||||
$this->page['end'] = replace_macros($tpl,array(
|
||||
'$baseurl' => $this->get_baseurl() // FIXME for z_path!!!!
|
||||
|
|
@ -1031,13 +1022,13 @@ class App {
|
|||
|
||||
// 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'",
|
||||
|
|
@ -1092,7 +1083,7 @@ class App {
|
|||
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";
|
||||
|
|
@ -1121,7 +1112,7 @@ class App {
|
|||
}
|
||||
|
||||
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];
|
||||
|
|
@ -1150,7 +1141,7 @@ class App {
|
|||
|
||||
switch($engine) {
|
||||
case 'smarty3':
|
||||
if (is_writable('view/smarty3/'))
|
||||
if(is_writable('view/smarty3/'))
|
||||
$this->theme['template_engine'] = 'smarty3';
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1168,9 +1159,8 @@ class App {
|
|||
}
|
||||
|
||||
function save_timestamp($stamp, $value) {
|
||||
if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler']) {
|
||||
if (!isset($this->config['system']['profiler']) || !$this->config['system']['profiler'])
|
||||
return;
|
||||
}
|
||||
|
||||
$duration = (float)(microtime(true)-$stamp);
|
||||
|
||||
|
|
@ -1252,9 +1242,8 @@ class App {
|
|||
array_shift($trace);
|
||||
|
||||
$callstack = array();
|
||||
foreach ($trace AS $func) {
|
||||
foreach ($trace AS $func)
|
||||
$callstack[] = $func["function"];
|
||||
}
|
||||
|
||||
return implode(", ", $callstack);
|
||||
}
|
||||
|
|
@ -1276,33 +1265,31 @@ class App {
|
|||
* @return bool Is it a known backend?
|
||||
*/
|
||||
function is_backend() {
|
||||
static $backend = array(
|
||||
"_well_known",
|
||||
"api",
|
||||
"dfrn_notify",
|
||||
"fetch",
|
||||
"hcard",
|
||||
"hostxrd",
|
||||
"nodeinfo",
|
||||
"noscrape",
|
||||
"p",
|
||||
"poco",
|
||||
"post",
|
||||
"proxy",
|
||||
"pubsub",
|
||||
"pubsubhubbub",
|
||||
"receive",
|
||||
"rsd_xml",
|
||||
"salmon",
|
||||
"statistics_json",
|
||||
"xrd",
|
||||
);
|
||||
$backend = array();
|
||||
$backend[] = "_well_known";
|
||||
$backend[] = "api";
|
||||
$backend[] = "dfrn_notify";
|
||||
$backend[] = "fetch";
|
||||
$backend[] = "hcard";
|
||||
$backend[] = "hostxrd";
|
||||
$backend[] = "nodeinfo";
|
||||
$backend[] = "noscrape";
|
||||
$backend[] = "p";
|
||||
$backend[] = "poco";
|
||||
$backend[] = "post";
|
||||
$backend[] = "proxy";
|
||||
$backend[] = "pubsub";
|
||||
$backend[] = "pubsubhubbub";
|
||||
$backend[] = "receive";
|
||||
$backend[] = "rsd_xml";
|
||||
$backend[] = "salmon";
|
||||
$backend[] = "statistics_json";
|
||||
$backend[] = "xrd";
|
||||
|
||||
if (in_array($this->module, $backend)) {
|
||||
if (in_array($this->module, $backend))
|
||||
return(true);
|
||||
} else {
|
||||
else
|
||||
return($this->backend);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1315,15 +1302,13 @@ class App {
|
|||
if ($this->is_backend()) {
|
||||
$process = "backend";
|
||||
$max_processes = get_config('system', 'max_processes_backend');
|
||||
if (intval($max_processes) == 0) {
|
||||
if (intval($max_processes) == 0)
|
||||
$max_processes = 5;
|
||||
}
|
||||
} else {
|
||||
$process = "frontend";
|
||||
$max_processes = get_config('system', 'max_processes_frontend');
|
||||
if (intval($max_processes) == 0) {
|
||||
if (intval($max_processes) == 0)
|
||||
$max_processes = 20;
|
||||
}
|
||||
}
|
||||
|
||||
$processlist = dbm::processlist();
|
||||
|
|
@ -1348,15 +1333,13 @@ class App {
|
|||
if ($this->is_backend()) {
|
||||
$process = "backend";
|
||||
$maxsysload = intval(get_config('system', 'maxloadavg'));
|
||||
if ($maxsysload < 1) {
|
||||
if ($maxsysload < 1)
|
||||
$maxsysload = 50;
|
||||
}
|
||||
} else {
|
||||
$process = "frontend";
|
||||
$maxsysload = intval(get_config('system','maxloadavg_frontend'));
|
||||
if ($maxsysload < 1) {
|
||||
if ($maxsysload < 1)
|
||||
$maxsysload = 50;
|
||||
}
|
||||
}
|
||||
|
||||
$load = current_load();
|
||||
|
|
@ -1392,17 +1375,16 @@ class App {
|
|||
// add baseurl to args. cli scripts can't construct it
|
||||
$args[] = $this->get_baseurl();
|
||||
|
||||
for ($x = 0; $x < count($args); $x ++) {
|
||||
for($x = 0; $x < count($args); $x ++)
|
||||
$args[$x] = escapeshellarg($args[$x]);
|
||||
}
|
||||
|
||||
$cmdline = implode($args," ");
|
||||
|
||||
if (get_config('system','proc_windows')) {
|
||||
if(get_config('system','proc_windows'))
|
||||
proc_close(proc_open('cmd /c start /b ' . $cmdline,array(),$foo,dirname(__FILE__)));
|
||||
} else {
|
||||
else
|
||||
proc_close(proc_open($cmdline." &",array(),$foo,dirname(__FILE__)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1479,17 +1461,17 @@ function get_app() {
|
|||
* @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;
|
||||
|
|
@ -1517,9 +1499,8 @@ function clean_urls() {
|
|||
function z_path() {
|
||||
$base = App::get_baseurl();
|
||||
|
||||
if (! clean_urls()) {
|
||||
if(! clean_urls())
|
||||
$base .= '/?q=';
|
||||
}
|
||||
|
||||
return $base;
|
||||
}
|
||||
|
|
@ -1544,9 +1525,8 @@ function z_root() {
|
|||
* @return string
|
||||
*/
|
||||
function absurl($path) {
|
||||
if (strpos($path,'/') === 0) {
|
||||
if(strpos($path,'/') === 0)
|
||||
return z_path() . $path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
|
@ -1562,13 +1542,12 @@ function is_ajax() {
|
|||
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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1587,12 +1566,10 @@ function check_url(App $a) {
|
|||
// and www.example.com vs example.com.
|
||||
// We will only change the url to an ip address if there is no existing setting
|
||||
|
||||
if (! x($url)) {
|
||||
if(! x($url))
|
||||
$url = set_config('system','url',App::get_baseurl());
|
||||
}
|
||||
if ((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname))) {
|
||||
if((! link_compare($url,App::get_baseurl())) && (! preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$a->get_hostname)))
|
||||
$url = set_config('system','url',App::get_baseurl());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -1603,14 +1580,13 @@ function check_url(App $a) {
|
|||
*/
|
||||
function update_db(App $a) {
|
||||
$build = get_config('system','build');
|
||||
if (! x($build)) {
|
||||
if(! x($build))
|
||||
$build = set_config('system','build',DB_UPDATE_VERSION);
|
||||
}
|
||||
|
||||
if ($build != DB_UPDATE_VERSION) {
|
||||
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.
|
||||
|
|
@ -1620,13 +1596,12 @@ function update_db(App $a) {
|
|||
// 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());
|
||||
|
||||
|
|
@ -1634,18 +1609,15 @@ function update_db(App $a) {
|
|||
// conflits with new routine)
|
||||
for ($x = $stored; $x < NEW_UPDATE_ROUTINE_VERSION; $x++) {
|
||||
$r = run_update_function($x);
|
||||
if (!$r) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($stored < NEW_UPDATE_ROUTINE_VERSION) {
|
||||
$stored = NEW_UPDATE_ROUTINE_VERSION;
|
||||
if (!$r) break;
|
||||
}
|
||||
if ($stored < NEW_UPDATE_ROUTINE_VERSION) $stored = NEW_UPDATE_ROUTINE_VERSION;
|
||||
|
||||
|
||||
// run new update routine
|
||||
// it update the structure in one call
|
||||
$retval = update_structure(false, true);
|
||||
if ($retval) {
|
||||
if($retval) {
|
||||
update_fail(
|
||||
DB_UPDATE_VERSION,
|
||||
$retval
|
||||
|
|
@ -1656,11 +1628,9 @@ function update_db(App $a) {
|
|||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1670,7 +1640,7 @@ function update_db(App $a) {
|
|||
}
|
||||
|
||||
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.
|
||||
|
|
@ -1681,9 +1651,8 @@ function run_update_function($x) {
|
|||
// delete the config entry to try again.
|
||||
|
||||
$t = get_config('database','update_' . $x);
|
||||
if ($t !== false) {
|
||||
if($t !== false)
|
||||
return false;
|
||||
}
|
||||
set_config('database','update_' . $x, time());
|
||||
|
||||
// call the specific update
|
||||
|
|
@ -1691,7 +1660,7 @@ function run_update_function($x) {
|
|||
$func = 'update_' . $x;
|
||||
$retval = $func();
|
||||
|
||||
if ($retval) {
|
||||
if($retval) {
|
||||
//send the administrator an e-mail
|
||||
update_fail(
|
||||
$x,
|
||||
|
|
@ -1724,40 +1693,39 @@ function run_update_function($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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1817,9 +1785,10 @@ function login($register = false, $hiddens=false) {
|
|||
|
||||
$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)
|
||||
));
|
||||
|
|
@ -1831,29 +1800,29 @@ function login($register = false, $hiddens=false) {
|
|||
|
||||
$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'),
|
||||
|
||||
));
|
||||
|
||||
|
|
@ -1867,9 +1836,8 @@ function login($register = false, $hiddens=false) {
|
|||
*/
|
||||
function killme() {
|
||||
|
||||
if (!get_app()->is_backend()) {
|
||||
if (!get_app()->is_backend())
|
||||
session_write_close();
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
|
@ -1878,9 +1846,8 @@ function killme() {
|
|||
* @brief Redirect to another URL and terminate this process.
|
||||
*/
|
||||
function goaway($s) {
|
||||
if (!strstr(normalise_link($s), "http://")) {
|
||||
if (!strstr(normalise_link($s), "http://"))
|
||||
$s = App::get_baseurl()."/".$s;
|
||||
}
|
||||
|
||||
header("Location: $s");
|
||||
killme();
|
||||
|
|
@ -1928,9 +1895,8 @@ function public_contact() {
|
|||
* @return int|bool visitor_id or false
|
||||
*/
|
||||
function remote_user() {
|
||||
if ((x($_SESSION,'authenticated')) && (x($_SESSION,'visitor_id'))) {
|
||||
if((x($_SESSION,'authenticated')) && (x($_SESSION,'visitor_id')))
|
||||
return intval($_SESSION['visitor_id']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1943,12 +1909,9 @@ function remote_user() {
|
|||
*/
|
||||
function notice($s) {
|
||||
$a = get_app();
|
||||
if (! x($_SESSION,'sysmsg')) {
|
||||
$_SESSION['sysmsg'] = array();
|
||||
}
|
||||
if ($a->interactive) {
|
||||
if(! x($_SESSION,'sysmsg')) $_SESSION['sysmsg'] = array();
|
||||
if($a->interactive)
|
||||
$_SESSION['sysmsg'][] = $s;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1961,16 +1924,12 @@ function notice($s) {
|
|||
function info($s) {
|
||||
$a = get_app();
|
||||
|
||||
if (local_user() AND get_pconfig(local_user(),'system','ignore_info')) {
|
||||
if (local_user() AND get_pconfig(local_user(),'system','ignore_info'))
|
||||
return;
|
||||
}
|
||||
|
||||
if (! x($_SESSION,'sysmsg_info')) {
|
||||
$_SESSION['sysmsg_info'] = array();
|
||||
}
|
||||
if ($a->interactive) {
|
||||
if(! x($_SESSION,'sysmsg_info')) $_SESSION['sysmsg_info'] = array();
|
||||
if($a->interactive)
|
||||
$_SESSION['sysmsg_info'][] = $s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2032,9 +1991,8 @@ function proc_run($cmd){
|
|||
$arr = array('args' => $args, 'run_cmd' => true);
|
||||
|
||||
call_hooks("proc_run", $arr);
|
||||
if (!$arr['run_cmd'] OR !count($args)) {
|
||||
if (!$arr['run_cmd'] OR !count($args))
|
||||
return;
|
||||
}
|
||||
|
||||
$priority = PRIORITY_MEDIUM;
|
||||
$dont_fork = get_config("system", "worker_dont_fork");
|
||||
|
|
@ -2057,13 +2015,12 @@ function proc_run($cmd){
|
|||
$found = q("SELECT `id` FROM `workerqueue` WHERE `parameter` = '%s'",
|
||||
dbesc($parameters));
|
||||
|
||||
if (!dbm::is_result($found)) {
|
||||
if (!$found)
|
||||
q("INSERT INTO `workerqueue` (`parameter`, `created`, `priority`)
|
||||
VALUES ('%s', '%s', %d)",
|
||||
dbesc($parameters),
|
||||
dbesc(datetime_convert()),
|
||||
intval($priority));
|
||||
}
|
||||
|
||||
// Should we quit and wait for the poller to be called as a cronjob?
|
||||
if ($dont_fork) {
|
||||
|
|
@ -2076,14 +2033,12 @@ function proc_run($cmd){
|
|||
// Get number of allowed number of worker threads
|
||||
$queues = intval(get_config("system", "worker_queues"));
|
||||
|
||||
if ($queues == 0) {
|
||||
if ($queues == 0)
|
||||
$queues = 4;
|
||||
}
|
||||
|
||||
// If there are already enough workers running, don't fork another one
|
||||
if ($workers[0]["workers"] >= $queues) {
|
||||
if ($workers[0]["workers"] >= $queues)
|
||||
return;
|
||||
}
|
||||
|
||||
// Now call the poller to execute the jobs that we just added to the queue
|
||||
$args = array("include/poller.php", "no_cron");
|
||||
|
|
@ -2100,22 +2055,20 @@ function current_theme(){
|
|||
|
||||
// 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();
|
||||
|
|
@ -2136,44 +2089,38 @@ function current_theme(){
|
|||
}
|
||||
$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?
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -2190,9 +2137,8 @@ function current_theme_url() {
|
|||
$t = current_theme();
|
||||
|
||||
$opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
|
||||
if (file_exists('view/theme/' . $t . '/style.php')) {
|
||||
if (file_exists('view/theme/' . $t . '/style.php'))
|
||||
return('view/theme/'.$t.'/style.pcss'.$opts);
|
||||
}
|
||||
|
||||
return('view/theme/'.$t.'/style.css');
|
||||
}
|
||||
|
|
@ -2221,9 +2167,8 @@ function feed_birthday($uid,$tz) {
|
|||
|
||||
$birthday = '';
|
||||
|
||||
if (! strlen($tz)) {
|
||||
if(! strlen($tz))
|
||||
$tz = 'UTC';
|
||||
}
|
||||
|
||||
$p = q("SELECT `dob` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($uid)
|
||||
|
|
@ -2231,14 +2176,13 @@ function feed_birthday($uid,$tz) {
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -2256,8 +2200,8 @@ function is_site_admin() {
|
|||
|
||||
$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;
|
||||
}
|
||||
|
|
@ -2272,16 +2216,16 @@ function is_site_admin() {
|
|||
*/
|
||||
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&";
|
||||
|
|
@ -2293,7 +2237,7 @@ function build_querystring($params, $name=null) {
|
|||
|
||||
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 {
|
||||
|
|
@ -2302,14 +2246,13 @@ function explode_querystring($query) {
|
|||
}
|
||||
|
||||
$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);
|
||||
|
|
@ -2328,9 +2271,7 @@ function explode_querystring($query) {
|
|||
*/
|
||||
function curPageURL() {
|
||||
$pageURL = 'http';
|
||||
if ($_SERVER["HTTPS"] == "on") {
|
||||
$pageURL .= "s";
|
||||
}
|
||||
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
|
||||
$pageURL .= "://";
|
||||
if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") {
|
||||
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
||||
|
|
@ -2342,7 +2283,7 @@ function curPageURL() {
|
|||
|
||||
function random_digits($digits) {
|
||||
$rn = '';
|
||||
for ($i = 0; $i < $digits; $i++) {
|
||||
for($i = 0; $i < $digits; $i++) {
|
||||
$rn .= rand(0,9);
|
||||
}
|
||||
return $rn;
|
||||
|
|
@ -2351,9 +2292,8 @@ function random_digits($digits) {
|
|||
function get_server() {
|
||||
$server = get_config("system", "directory");
|
||||
|
||||
if ($server == "") {
|
||||
if ($server == "")
|
||||
$server = "http://dir.friendi.ca";
|
||||
}
|
||||
|
||||
return($server);
|
||||
}
|
||||
|
|
@ -2361,9 +2301,8 @@ function get_server() {
|
|||
function get_cachefile($file, $writemode = true) {
|
||||
$cache = get_itemcachepath();
|
||||
|
||||
if ((! $cache) || (! is_dir($cache))) {
|
||||
if ((! $cache) || (! is_dir($cache)))
|
||||
return("");
|
||||
}
|
||||
|
||||
$subfolder = $cache."/".substr($file, 0, 2);
|
||||
|
||||
|
|
@ -2385,29 +2324,24 @@ function clear_cache($basepath = "", $path = "") {
|
|||
$path = $basepath;
|
||||
}
|
||||
|
||||
if (($path == "") OR (!is_dir($path))) {
|
||||
if (($path == "") OR (!is_dir($path)))
|
||||
return;
|
||||
}
|
||||
|
||||
if (substr(realpath($path), 0, strlen($basepath)) != $basepath) {
|
||||
if (substr(realpath($path), 0, strlen($basepath)) != $basepath)
|
||||
return;
|
||||
}
|
||||
|
||||
$cachetime = (int)get_config('system','itemcache_duration');
|
||||
if ($cachetime == 0) {
|
||||
if ($cachetime == 0)
|
||||
$cachetime = 86400;
|
||||
}
|
||||
|
||||
if (is_writable($path)){
|
||||
if ($dh = opendir($path)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
$fullpath = $path."/".$file;
|
||||
if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != "..")) {
|
||||
if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != ".."))
|
||||
clear_cache($basepath, $fullpath);
|
||||
}
|
||||
if ((filetype($fullpath) == "file") and (filectime($fullpath) < (time() - $cachetime))) {
|
||||
if ((filetype($fullpath) == "file") and (filectime($fullpath) < (time() - $cachetime)))
|
||||
unlink($fullpath);
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
|
|
@ -2417,9 +2351,8 @@ function clear_cache($basepath = "", $path = "") {
|
|||
function get_itemcachepath() {
|
||||
// Checking, if the cache is deactivated
|
||||
$cachetime = (int)get_config('system','itemcache_duration');
|
||||
if ($cachetime < 0) {
|
||||
if ($cachetime < 0)
|
||||
return "";
|
||||
}
|
||||
|
||||
$itemcache = get_config('system','itemcache');
|
||||
if (($itemcache != "") AND App::directory_usable($itemcache)) {
|
||||
|
|
@ -2430,7 +2363,7 @@ function get_itemcachepath() {
|
|||
|
||||
if ($temppath != "") {
|
||||
$itemcache = $temppath."/itemcache";
|
||||
if (!file_exists($itemcache) && !is_dir($itemcache)) {
|
||||
if(!file_exists($itemcache) && !is_dir($itemcache)) {
|
||||
mkdir($itemcache);
|
||||
}
|
||||
|
||||
|
|
@ -2522,7 +2455,7 @@ function set_template_engine(App $a, $engine = 'internal') {
|
|||
$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]);
|
||||
|
|
@ -2534,42 +2467,37 @@ function validate_include(&$file) {
|
|||
|
||||
$file = realpath($file);
|
||||
|
||||
if (strpos($file, getcwd()) !== 0) {
|
||||
if (strpos($file, getcwd()) !== 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
$file = str_replace(getcwd()."/", "", $file, $count);
|
||||
if ($count != 1) {
|
||||
if ($count != 1)
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($orig_file !== $file) {
|
||||
if ($orig_file !== $file)
|
||||
return false;
|
||||
}
|
||||
|
||||
$valid = false;
|
||||
if (strpos($file, "include/") === 0) {
|
||||
if (strpos($file, "include/") === 0)
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
if (strpos($file, "addon/") === 0) {
|
||||
if (strpos($file, "addon/") === 0)
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
// Simply return flag
|
||||
return ($valid);
|
||||
if (!$valid)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function current_load() {
|
||||
if (!function_exists('sys_getloadavg')) {
|
||||
if (!function_exists('sys_getloadavg'))
|
||||
return false;
|
||||
}
|
||||
|
||||
$load_arr = sys_getloadavg();
|
||||
|
||||
if (!is_array($load_arr)) {
|
||||
if (!is_array($load_arr))
|
||||
return false;
|
||||
}
|
||||
|
||||
return max($load_arr[0], $load_arr[1]);
|
||||
}
|
||||
|
|
@ -2590,9 +2518,8 @@ function argc() {
|
|||
* @return string Value of the argv key
|
||||
*/
|
||||
function argv($x) {
|
||||
if (array_key_exists($x,get_app()->argv)) {
|
||||
if(array_key_exists($x,get_app()->argv))
|
||||
return get_app()->argv[$x];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// authorisation to do this.
|
||||
|
||||
function user_remove($uid) {
|
||||
if (! $uid)
|
||||
if(! $uid)
|
||||
return;
|
||||
logger('Removing user: ' . $uid);
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ function user_remove($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());
|
||||
|
|
@ -122,13 +122,11 @@ function terminate_friendship($user,$self,$contact) {
|
|||
// This provides for the possibility that their database is temporarily messed
|
||||
// up or some other transient event and that there's a possibility we could recover from it.
|
||||
|
||||
function mark_for_death(array $contact) {
|
||||
function mark_for_death($contact) {
|
||||
|
||||
if ($contact['archive']) {
|
||||
if($contact['archive'])
|
||||
return;
|
||||
}
|
||||
|
||||
/// @TODO Comparison of strings this way may lead to bugs/incompatibility, better switch to DateTime
|
||||
if ($contact['term-date'] <= NULL_DATE) {
|
||||
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
|
|
@ -153,7 +151,7 @@ function mark_for_death(array $contact) {
|
|||
/// 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
|
||||
|
|
@ -485,7 +483,7 @@ function random_profile() {
|
|||
|
||||
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)
|
||||
|
|
@ -777,18 +775,18 @@ function posts_from_contact_url(App $a, $contact_url) {
|
|||
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'];
|
||||
|
|
@ -810,7 +808,7 @@ function account_type($contact) {
|
|||
// "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']))
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class PConfig {
|
|||
$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>!";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class DirSearch {
|
|||
*/
|
||||
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;
|
||||
|
|
@ -33,11 +33,10 @@ class DirSearch {
|
|||
$ostatus = NETWORK_DFRN;
|
||||
|
||||
// check if we search only communities or every contact
|
||||
if ($mode === "community") {
|
||||
if($mode === "community")
|
||||
$extra_sql = " AND `community`";
|
||||
} else {
|
||||
else
|
||||
$extra_sql = "";
|
||||
}
|
||||
|
||||
$search .= "%";
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class ForumManager {
|
|||
if (!$contacts)
|
||||
return($forumlist);
|
||||
|
||||
foreach ($contacts as $contact) {
|
||||
foreach($contacts as $contact) {
|
||||
$forumlist[] = array(
|
||||
'url' => $contact['url'],
|
||||
'name' => $contact['name'],
|
||||
|
|
@ -76,7 +76,7 @@ class ForumManager {
|
|||
*/
|
||||
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 = '';
|
||||
|
|
@ -92,7 +92,7 @@ class ForumManager {
|
|||
|
||||
$id = 0;
|
||||
|
||||
foreach ($contacts as $contact) {
|
||||
foreach($contacts as $contact) {
|
||||
|
||||
$selected = (($cid == $contact['id']) ? ' forum-selected' : '');
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ class ForumManager {
|
|||
public static function profile_advanced($uid) {
|
||||
|
||||
$profile = intval(feature_enabled($uid,'forumlist_profile'));
|
||||
if (! $profile)
|
||||
if(! $profile)
|
||||
return;
|
||||
|
||||
$o = '';
|
||||
|
|
@ -151,20 +151,16 @@ class ForumManager {
|
|||
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class NotificationsManager {
|
|||
*/
|
||||
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']);
|
||||
|
|
@ -58,7 +58,7 @@ class NotificationsManager {
|
|||
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) {
|
||||
|
|
@ -67,7 +67,7 @@ class NotificationsManager {
|
|||
|
||||
$aOrder = explode(" ", $order);
|
||||
$asOrder = array();
|
||||
foreach ($aOrder as $o) {
|
||||
foreach($aOrder as $o) {
|
||||
$dir = "asc";
|
||||
if ($o[0]==="-") {
|
||||
$dir = "desc";
|
||||
|
|
@ -81,7 +81,7 @@ class NotificationsManager {
|
|||
}
|
||||
$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",
|
||||
|
|
@ -369,7 +369,7 @@ class NotificationsManager {
|
|||
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`
|
||||
|
|
@ -406,7 +406,7 @@ class NotificationsManager {
|
|||
$notifs = array();
|
||||
$sql_seen = "";
|
||||
|
||||
if ($seen === 0)
|
||||
if($seen === 0)
|
||||
$sql_seen = " AND `item`.`unseen` = 1 ";
|
||||
|
||||
|
||||
|
|
@ -445,7 +445,7 @@ class NotificationsManager {
|
|||
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",
|
||||
|
|
@ -478,7 +478,7 @@ class NotificationsManager {
|
|||
$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`
|
||||
|
|
@ -530,7 +530,7 @@ class NotificationsManager {
|
|||
$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`
|
||||
|
|
@ -569,7 +569,7 @@ class NotificationsManager {
|
|||
$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`,
|
||||
|
|
@ -608,7 +608,7 @@ class NotificationsManager {
|
|||
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`
|
||||
|
|
@ -644,7 +644,7 @@ class NotificationsManager {
|
|||
$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`,
|
||||
|
|
@ -682,7 +682,7 @@ class NotificationsManager {
|
|||
private function introTotal($all = false) {
|
||||
$sql_extra = "";
|
||||
|
||||
if (!$all)
|
||||
if(!$all)
|
||||
$sql_extra = " AND `ignore` = 0 ";
|
||||
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `intro`
|
||||
|
|
@ -716,7 +716,7 @@ class NotificationsManager {
|
|||
$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
|
||||
|
|
@ -756,12 +756,12 @@ class NotificationsManager {
|
|||
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 : ''));
|
||||
|
||||
|
|
@ -793,7 +793,7 @@ class NotificationsManager {
|
|||
$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'] = "";
|
||||
|
|
|
|||
|
|
@ -564,15 +564,15 @@ class Probe {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
|
@ -858,7 +858,7 @@ class Probe {
|
|||
|
||||
$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);
|
||||
|
||||
|
|
@ -1133,17 +1133,15 @@ class Probe {
|
|||
$password = '';
|
||||
openssl_private_decrypt(hex2bin($r[0]['pass']), $password,$x[0]['prvkey']);
|
||||
$mbox = email_connect($mailbox,$r[0]['user'], $password);
|
||||
if (!$mbox) {
|
||||
if(!mbox)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$msgs = email_poll($mbox, $uri);
|
||||
logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG);
|
||||
|
||||
if (!count($msgs)) {
|
||||
if (!count($msgs))
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
|
||||
|
|
@ -1159,26 +1157,23 @@ class Probe {
|
|||
$data["poll"] = 'email '.random_string();
|
||||
|
||||
$x = email_msg_meta($mbox, $msgs[0]);
|
||||
if (stristr($x[0]->from, $uri)) {
|
||||
if(stristr($x[0]->from, $uri))
|
||||
$adr = imap_rfc822_parse_adrlist($x[0]->from, '');
|
||||
} elseif (stristr($x[0]->to, $uri)) {
|
||||
elseif(stristr($x[0]->to, $uri))
|
||||
$adr = imap_rfc822_parse_adrlist($x[0]->to, '');
|
||||
}
|
||||
if (isset($adr)) {
|
||||
foreach ($adr as $feadr) {
|
||||
if ((strcasecmp($feadr->mailbox, $data["name"]) == 0)
|
||||
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"]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class Smilies {
|
|||
* @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;
|
||||
|
||||
|
|
@ -135,9 +135,9 @@ class Smilies {
|
|||
$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>';
|
||||
}
|
||||
}
|
||||
|
|
@ -170,13 +170,11 @@ class Smilies {
|
|||
* @todo: Rework because it doesn't work correctly
|
||||
*/
|
||||
private function preg_heart($x) {
|
||||
if (strlen($x[1]) == 1) {
|
||||
if(strlen($x[1]) == 1)
|
||||
return $x[0];
|
||||
}
|
||||
$t = '';
|
||||
for ($cnt = 0; $cnt < strlen($x[1]); $cnt ++) {
|
||||
for($cnt = 0; $cnt < strlen($x[1]); $cnt ++)
|
||||
$t .= '<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-heart.gif" alt="<3" />';
|
||||
}
|
||||
$r = str_replace($x[0],$t,$x[0]);
|
||||
return $r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
|
|||
|
||||
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 = '';
|
||||
|
|
@ -88,13 +88,13 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
|
|||
$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);
|
||||
|
|
@ -113,24 +113,23 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
|
|||
|
||||
$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";
|
||||
|
|
@ -186,14 +185,14 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
|
|||
|
||||
$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);
|
||||
|
||||
|
|
@ -205,7 +204,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
|
|||
} 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";
|
||||
|
|
@ -288,7 +287,7 @@ function prune_deadguys($arr) {
|
|||
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']))
|
||||
|
|
@ -319,25 +318,25 @@ function populate_acl($user = null, $show_jotnets = false) {
|
|||
$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>';
|
||||
}
|
||||
|
|
@ -380,20 +379,20 @@ function construct_acl_data(App $a, $user) {
|
|||
|
||||
$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
|
||||
|
|
@ -420,8 +419,8 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
|
||||
// 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'];
|
||||
}
|
||||
|
|
@ -511,7 +510,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
intval($count)
|
||||
);
|
||||
|
||||
foreach ($r as $g){
|
||||
foreach($r as $g){
|
||||
// logger('acl: group: ' . $g['name'] . ' members: ' . $g['uids']);
|
||||
$groups[] = array(
|
||||
"type" => "g",
|
||||
|
|
@ -547,7 +546,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
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')
|
||||
|
|
@ -666,7 +665,7 @@ function acl_lookup(App $a, $out_type = 'json') {
|
|||
|
||||
call_hooks('acl_lookup_end', $results);
|
||||
|
||||
if ($out_type === 'html') {
|
||||
if($out_type === 'html') {
|
||||
$o = array(
|
||||
'tot' => $results['tot'],
|
||||
'start' => $results['start'],
|
||||
|
|
|
|||
|
|
@ -154,9 +154,9 @@ use \Friendica\Core\Config;
|
|||
|
||||
|
||||
// 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;
|
||||
|
|
@ -199,7 +199,7 @@ use \Friendica\Core\Config;
|
|||
|
||||
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 {
|
||||
|
|
@ -215,7 +215,7 @@ use \Friendica\Core\Config;
|
|||
$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');
|
||||
|
|
@ -334,7 +334,7 @@ use \Friendica\Core\Config;
|
|||
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.")";
|
||||
|
|
@ -457,7 +457,7 @@ use \Friendica\Core\Config;
|
|||
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' ";
|
||||
|
|
@ -465,7 +465,7 @@ use \Friendica\Core\Config;
|
|||
}
|
||||
|
||||
// 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 == "")
|
||||
|
|
@ -476,7 +476,7 @@ use \Friendica\Core\Config;
|
|||
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 == "")
|
||||
|
|
@ -486,7 +486,7 @@ use \Friendica\Core\Config;
|
|||
$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' ";
|
||||
|
|
@ -496,7 +496,7 @@ use \Friendica\Core\Config;
|
|||
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 == "")
|
||||
|
|
@ -593,7 +593,7 @@ use \Friendica\Core\Config;
|
|||
}
|
||||
}
|
||||
|
||||
if ($uinfo[0]['self']) {
|
||||
if($uinfo[0]['self']) {
|
||||
|
||||
if ($uinfo[0]['network'] == "")
|
||||
$uinfo[0]['network'] = NETWORK_DFRN;
|
||||
|
|
@ -648,7 +648,7 @@ use \Friendica\Core\Config;
|
|||
$starred = $r[0]['count'];
|
||||
|
||||
|
||||
if (! $uinfo[0]['self']) {
|
||||
if(! $uinfo[0]['self']) {
|
||||
$countfriends = 0;
|
||||
$countfollowers = 0;
|
||||
$starred = 0;
|
||||
|
|
@ -923,7 +923,7 @@ use \Friendica\Core\Config;
|
|||
$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();
|
||||
|
|
@ -964,9 +964,9 @@ use \Friendica\Core\Config;
|
|||
|
||||
// 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();
|
||||
|
|
@ -989,16 +989,16 @@ use \Friendica\Core\Config;
|
|||
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)
|
||||
|
|
@ -1066,11 +1066,11 @@ use \Friendica\Core\Config;
|
|||
$_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;
|
||||
}
|
||||
|
||||
|
|
@ -1115,13 +1115,13 @@ use \Friendica\Core\Config;
|
|||
|
||||
$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();
|
||||
}
|
||||
|
|
@ -2469,7 +2469,7 @@ use \Friendica\Core\Config;
|
|||
|
||||
$ret = Array();
|
||||
|
||||
foreach ($r as $item) {
|
||||
foreach($r as $item) {
|
||||
|
||||
localize_item($item);
|
||||
list($status_user, $owner_user) = api_item_get_user($a,$item);
|
||||
|
|
@ -2641,9 +2641,9 @@ use \Friendica\Core\Config;
|
|||
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
|
||||
|
|
@ -2655,7 +2655,7 @@ use \Friendica\Core\Config;
|
|||
);
|
||||
|
||||
$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"]);
|
||||
|
|
@ -2697,7 +2697,7 @@ use \Friendica\Core\Config;
|
|||
$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()) : '');
|
||||
|
|
@ -2737,13 +2737,13 @@ use \Friendica\Core\Config;
|
|||
|
||||
$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"])
|
||||
|
|
@ -2761,7 +2761,7 @@ use \Friendica\Core\Config;
|
|||
return;
|
||||
|
||||
$ids = array();
|
||||
foreach ($r as $rr)
|
||||
foreach($r as $rr)
|
||||
if ($stringify_ids)
|
||||
$ids[] = $rr['id'];
|
||||
else
|
||||
|
|
@ -2967,7 +2967,7 @@ use \Friendica\Core\Config;
|
|||
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). "'";
|
||||
}
|
||||
|
||||
|
|
@ -2978,14 +2978,14 @@ use \Friendica\Core\Config;
|
|||
);
|
||||
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']));
|
||||
|
|
@ -3092,7 +3092,7 @@ use \Friendica\Core\Config;
|
|||
|
||||
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)));
|
||||
|
|
@ -3183,11 +3183,11 @@ use \Friendica\Core\Config;
|
|||
|
||||
$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;
|
||||
}
|
||||
|
|
@ -3927,7 +3927,7 @@ use \Friendica\Core\Config;
|
|||
$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']));
|
||||
|
|
|
|||
|
|
@ -1061,7 +1061,7 @@ function z_mime_content_type($filename) {
|
|||
);
|
||||
|
||||
$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];
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
|
|||
// 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." ";
|
||||
|
|
@ -193,7 +193,7 @@ function unescape_underscores_in_links($m) {
|
|||
|
||||
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
|
||||
|
|
@ -209,7 +209,7 @@ function format_event_diaspora($ev) {
|
|||
$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 ))
|
||||
|
|
@ -217,7 +217,7 @@ function format_event_diaspora($ev) {
|
|||
$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";
|
||||
|
||||
|
|
|
|||
|
|
@ -206,33 +206,30 @@ function bb_spacefy($st) {
|
|||
// 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 );
|
||||
|
||||
|
|
@ -241,35 +238,34 @@ function bb_find_open_close($s, $open, $close, $occurance = 1) {
|
|||
|
||||
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;
|
||||
|
|
@ -281,12 +277,12 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) {
|
|||
|
||||
$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);
|
||||
|
|
@ -299,7 +295,7 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) {
|
|||
return $string;
|
||||
}
|
||||
|
||||
if (! function_exists('bb_extract_images')) {
|
||||
if(! function_exists('bb_extract_images')) {
|
||||
function bb_extract_images($body) {
|
||||
|
||||
$saved_image = array();
|
||||
|
|
@ -310,12 +306,12 @@ function bb_extract_images($body) {
|
|||
$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));
|
||||
|
|
@ -328,7 +324,7 @@ function bb_extract_images($body) {
|
|||
|
||||
$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');
|
||||
|
|
@ -341,7 +337,7 @@ function bb_extract_images($body) {
|
|||
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;
|
||||
|
|
@ -623,7 +619,7 @@ function bb_DiasporaLinks($match) {
|
|||
function bb_RemovePictureLinks($match) {
|
||||
$text = Cache::get($match[1]);
|
||||
|
||||
if (is_null($text)){
|
||||
if(is_null($text)){
|
||||
$a = get_app();
|
||||
|
||||
$stamp1 = microtime(true);
|
||||
|
|
@ -677,7 +673,7 @@ function bb_expand_links($match) {
|
|||
function bb_CleanPictureLinksSub($match) {
|
||||
$text = Cache::get($match[1]);
|
||||
|
||||
if (is_null($text)){
|
||||
if(is_null($text)){
|
||||
$a = get_app();
|
||||
|
||||
$stamp1 = microtime(true);
|
||||
|
|
@ -728,7 +724,7 @@ function bb_CleanPictureLinks($text) {
|
|||
}
|
||||
|
||||
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];
|
||||
|
|
@ -818,7 +814,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
|
||||
$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
|
||||
|
|
@ -1136,7 +1132,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
// 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);
|
||||
|
|
@ -1182,7 +1178,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
$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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function cli_startup() {
|
|||
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');
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function contact_reputation($current) {
|
|||
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";
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ function contact_poll_interval($current, $disabled = false) {
|
|||
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";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ function findpeople_widget() {
|
|||
|
||||
$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;
|
||||
|
|
@ -108,7 +108,7 @@ function networks_widget($baseurl,$selected = '') {
|
|||
}
|
||||
}
|
||||
|
||||
if (count($nets) < 2)
|
||||
if(count($nets) < 2)
|
||||
return '';
|
||||
|
||||
return replace_macros(get_markup_template('nets.tpl'),array(
|
||||
|
|
@ -140,7 +140,7 @@ function fileas_widget($baseurl,$selected = '') {
|
|||
$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' : ''));
|
||||
}
|
||||
|
|
@ -172,11 +172,10 @@ function categories_widget($baseurl,$selected = '') {
|
|||
|
||||
$matches = false;
|
||||
$terms = array();
|
||||
$cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER);
|
||||
|
||||
if ($cnt) {
|
||||
foreach ($matches as $mtch) {
|
||||
$unescaped = xmlify(file_tag_decode($mtch[1]));
|
||||
$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' : ''));
|
||||
}
|
||||
}
|
||||
|
|
@ -196,29 +195,29 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
|
||||
$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()))
|
||||
);
|
||||
|
|
@ -228,26 +227,22 @@ function common_friends_visitor_widget($profile_uid) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($cid == 0 && $zcid == 0) {
|
||||
if($cid == 0 && $zcid == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
|
||||
if ($cid) {
|
||||
if($cid)
|
||||
$t = count_common_friends($profile_uid,$cid);
|
||||
} else {
|
||||
else
|
||||
$t = count_common_friends_zcid($profile_uid,$zcid);
|
||||
}
|
||||
if (! $t) {
|
||||
if(! $t)
|
||||
return;
|
||||
}
|
||||
|
||||
if ($cid) {
|
||||
if($cid)
|
||||
$r = common_friends($profile_uid,$cid,0,5,true);
|
||||
} else {
|
||||
else
|
||||
$r = common_friends_zcid($profile_uid,$zcid,0,5,true);
|
||||
}
|
||||
|
||||
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
|
||||
'$desc' => sprintf( tt("%d contact in common", "%d contacts in common", $t), $t),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ require_once("include/acl_selectors.php");
|
|||
// 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();
|
||||
|
|
@ -18,12 +18,12 @@ function item_extract_images($body) {
|
|||
$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));
|
||||
|
|
@ -36,7 +36,7 @@ function item_extract_images($body) {
|
|||
|
||||
$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');
|
||||
|
|
@ -49,7 +49,7 @@ function item_extract_images($body) {
|
|||
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;
|
||||
|
|
@ -57,7 +57,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
|
|||
|
||||
$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
|
||||
|
|
@ -66,7 +66,7 @@ function item_redir_and_replace_images($body, $images, $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);
|
||||
|
|
@ -96,7 +96,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
|
|||
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' ?".">";
|
||||
|
|
@ -126,7 +126,7 @@ function localize_item(&$item){
|
|||
}
|
||||
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];
|
||||
|
|
@ -137,19 +137,19 @@ function localize_item(&$item){
|
|||
|
||||
$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);
|
||||
|
|
@ -187,7 +187,7 @@ function localize_item(&$item){
|
|||
}
|
||||
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;
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ function localize_item(&$item){
|
|||
}
|
||||
if (stristr($item['verb'],ACTIVITY_MOOD)) {
|
||||
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
|
||||
if (! $verb)
|
||||
if(! $verb)
|
||||
return;
|
||||
|
||||
$Aname = $item['author-name'];
|
||||
|
|
@ -262,7 +262,7 @@ function localize_item(&$item){
|
|||
}
|
||||
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];
|
||||
|
|
@ -289,7 +289,7 @@ function localize_item(&$item){
|
|||
$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'])
|
||||
|
|
@ -307,17 +307,16 @@ function localize_item(&$item){
|
|||
}
|
||||
}
|
||||
$matches = null;
|
||||
if (preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
|
||||
foreach ($matches as $mtch) {
|
||||
if (! strpos($mtch[1],'zrl=')) {
|
||||
if(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']);
|
||||
}
|
||||
|
|
@ -344,9 +343,9 @@ function localize_item(&$item){
|
|||
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);
|
||||
}
|
||||
|
|
@ -361,14 +360,14 @@ function visible_activity($item) {
|
|||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -466,7 +465,7 @@ function item_condition() {
|
|||
*
|
||||
*/
|
||||
|
||||
if (!function_exists('conversation')) {
|
||||
if(!function_exists('conversation')) {
|
||||
function conversation(App $a, $items, $mode, $update, $preview = false) {
|
||||
|
||||
require_once('include/bbcode.php');
|
||||
|
|
@ -481,23 +480,22 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
|
||||
$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).
|
||||
|
|
@ -522,14 +520,14 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
. "'; 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.
|
||||
|
||||
|
|
@ -539,40 +537,40 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
|
@ -596,9 +594,9 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
|
||||
$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
|
||||
|
|
@ -606,17 +604,17 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
// $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;
|
||||
}
|
||||
|
||||
|
|
@ -628,8 +626,8 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$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'];
|
||||
|
|
@ -638,11 +636,11 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$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'];
|
||||
|
||||
|
||||
|
|
@ -654,7 +652,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$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"]);
|
||||
|
|
@ -671,9 +669,9 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
|
||||
$sp = false;
|
||||
$profile_link = best_link_url($item,$sp);
|
||||
if ($profile_link === 'mailbox')
|
||||
if($profile_link === 'mailbox')
|
||||
$profile_link = '';
|
||||
if ($sp)
|
||||
if($sp)
|
||||
$sparkle = ' sparkle';
|
||||
else
|
||||
$profile_link = zrl($profile_link);
|
||||
|
|
@ -700,7 +698,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
$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;
|
||||
|
|
@ -725,7 +723,7 @@ function conversation(App $a, $items, $mode, $update, $preview = 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);
|
||||
|
|
@ -820,18 +818,18 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
// 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;
|
||||
}
|
||||
|
||||
|
|
@ -841,10 +839,10 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -852,7 +850,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
|
||||
$item['pagedrop'] = $page_dropping;
|
||||
|
||||
if ($item['id'] == $item['parent']) {
|
||||
if($item['id'] == $item['parent']) {
|
||||
$item_object = new Item($item);
|
||||
$conv->add_thread($item_object);
|
||||
}
|
||||
|
|
@ -860,7 +858,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
|||
|
||||
$threads = $conv->get_template_data($conv_responses);
|
||||
|
||||
if (!$threads) {
|
||||
if(!$threads) {
|
||||
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
|
||||
$threads = array();
|
||||
}
|
||||
|
|
@ -896,8 +894,8 @@ function best_link_url($item,&$sparkle,$ssl_state = false) {
|
|||
$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'];
|
||||
|
|
@ -912,7 +910,7 @@ function item_photo_menu($item)
|
|||
{
|
||||
$ssl_state = false;
|
||||
|
||||
if (local_user()) {
|
||||
if(local_user()) {
|
||||
$ssl_state = true;
|
||||
}
|
||||
|
||||
|
|
@ -946,7 +944,7 @@ function item_photo_menu($item)
|
|||
$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';
|
||||
|
|
@ -1014,9 +1012,9 @@ function item_photo_menu($item)
|
|||
* @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 = '';
|
||||
|
||||
|
|
@ -1041,9 +1039,9 @@ function builtin_activity_puller($item, &$conv_responses) {
|
|||
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" ';
|
||||
}
|
||||
|
|
@ -1052,18 +1050,18 @@ function builtin_activity_puller($item, &$conv_responses) {
|
|||
|
||||
$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']] ++;
|
||||
|
|
@ -1087,12 +1085,12 @@ function builtin_activity_puller($item, &$conv_responses) {
|
|||
// $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
|
||||
|
|
@ -1116,16 +1114,16 @@ function format_like($cnt,$arr,$type,$id) {
|
|||
}
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
|
@ -1213,17 +1211,17 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
|
|||
|
||||
// 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';
|
||||
|
|
@ -1304,20 +1302,20 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1328,8 +1326,8 @@ function get_item_children($arr, $parent) {
|
|||
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']);
|
||||
}
|
||||
}
|
||||
|
|
@ -1337,16 +1335,16 @@ function sort_item_children($items) {
|
|||
}
|
||||
|
||||
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();
|
||||
|
|
@ -1355,40 +1353,35 @@ function conv_sort($arr,$order) {
|
|||
|
||||
// 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');
|
||||
|
|
@ -1398,12 +1391,12 @@ function conv_sort($arr,$order) {
|
|||
}
|
||||
|
||||
$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;*/
|
||||
}
|
||||
}
|
||||
|
|
@ -1425,11 +1418,9 @@ function sort_thr_commented($a,$b) {
|
|||
}
|
||||
|
||||
function find_thread_parent_index($arr,$x) {
|
||||
foreach ($arr as $k => $v) {
|
||||
if ($v['id'] == $x['parent']) {
|
||||
foreach($arr as $k => $v)
|
||||
if($v['id'] == $x['parent'])
|
||||
return $k;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1443,16 +1434,17 @@ function render_location_dummy($item) {
|
|||
|
||||
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']);
|
||||
|
|
@ -1460,10 +1452,9 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
|
|||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($ret as $key) {
|
||||
if ($key['count'] == true) {
|
||||
foreach($ret as $key) {
|
||||
if ($key['count'] == true)
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$ret['count'] = $count;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ function cron_run(&$argv, &$argc){
|
|||
$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;
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ function cron_run(&$argv, &$argc){
|
|||
$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();
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ function cron_expire_and_remove_users() {
|
|||
// 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']));
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ function cron_poll_contacts($argc, $argv) {
|
|||
// 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)
|
||||
|
|
@ -210,7 +210,7 @@ function cron_poll_contacts($argc, $argv) {
|
|||
continue;
|
||||
}
|
||||
|
||||
foreach ($res as $contact) {
|
||||
foreach($res as $contact) {
|
||||
|
||||
$xml = false;
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ function cron_poll_contacts($argc, $argv) {
|
|||
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
|
||||
}
|
||||
|
||||
if ($contact['priority'] AND !$force) {
|
||||
if($contact['priority'] AND !$force) {
|
||||
|
||||
$update = false;
|
||||
|
||||
|
|
@ -244,24 +244,24 @@ function cron_poll_contacts($argc, $argv) {
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
@ -289,16 +289,14 @@ function cron_clear_cache(App $a) {
|
|||
|
||||
$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();
|
||||
|
|
@ -317,9 +315,7 @@ function cron_clear_cache(App $a) {
|
|||
clear_cache($a->get_basepath(), $a->get_basepath()."/proxy");
|
||||
|
||||
$cachetime = get_config('system','proxy_cache_time');
|
||||
if (!$cachetime) {
|
||||
$cachetime = PROXY_DEFAULT_TIME;
|
||||
}
|
||||
if (!$cachetime) $cachetime = PROXY_DEFAULT_TIME;
|
||||
|
||||
q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%" AND `created` < NOW() - INTERVAL %d SECOND', $cachetime);
|
||||
}
|
||||
|
|
@ -332,30 +328,26 @@ function cron_clear_cache(App $a) {
|
|||
|
||||
// Maximum table size in megabyte
|
||||
$max_tablesize = intval(get_config('system','optimize_max_tablesize')) * 1000000;
|
||||
if ($max_tablesize == 0) {
|
||||
if ($max_tablesize == 0)
|
||||
$max_tablesize = 100 * 1000000; // Default are 100 MB
|
||||
}
|
||||
|
||||
if ($max_tablesize > 0) {
|
||||
// Minimum fragmentation level in percent
|
||||
$fragmentation_level = intval(get_config('system','optimize_fragmentation')) / 100;
|
||||
if ($fragmentation_level == 0) {
|
||||
if ($fragmentation_level == 0)
|
||||
$fragmentation_level = 0.3; // Default value is 30%
|
||||
}
|
||||
|
||||
// Optimize some tables that need to be optimized
|
||||
$r = q("SHOW TABLE STATUS");
|
||||
foreach ($r as $table) {
|
||||
foreach($r as $table) {
|
||||
|
||||
// Don't optimize tables that are too large
|
||||
if ($table["Data_length"] > $max_tablesize) {
|
||||
if ($table["Data_length"] > $max_tablesize)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't optimize empty tables
|
||||
if ($table["Data_length"] == 0) {
|
||||
if ($table["Data_length"] == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calculate fragmentation
|
||||
$fragmentation = $table["Data_free"] / ($table["Data_length"] + $table["Index_length"]);
|
||||
|
|
@ -363,9 +355,8 @@ function cron_clear_cache(App $a) {
|
|||
logger("Table ".$table["Name"]." - Fragmentation level: ".round($fragmentation * 100, 2), LOGGER_DEBUG);
|
||||
|
||||
// Don't optimize tables that needn't to be optimized
|
||||
if ($fragmentation < $fragmentation_level) {
|
||||
if ($fragmentation < $fragmentation_level)
|
||||
continue;
|
||||
}
|
||||
|
||||
// So optimize it
|
||||
logger("Optimize Table ".$table["Name"], LOGGER_DEBUG);
|
||||
|
|
@ -425,11 +416,9 @@ function cron_repair_database() {
|
|||
|
||||
// Update the global contacts for local users
|
||||
$r = q("SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired`");
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r AS $user) {
|
||||
if (dbm::is_result($r))
|
||||
foreach ($r AS $user)
|
||||
update_gcontact_for_user($user["uid"]);
|
||||
}
|
||||
}
|
||||
|
||||
/// @todo
|
||||
/// - remove thread entries without item
|
||||
|
|
|
|||
|
|
@ -8,25 +8,23 @@ function cronhooks_run(&$argv, &$argc){
|
|||
require_once('include/datetime.php');
|
||||
|
||||
if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
|
||||
foreach ($a->hooks["cron"] as $hook) {
|
||||
foreach ($a->hooks["cron"] as $hook)
|
||||
if ($hook[1] == $argv[1]) {
|
||||
logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG);
|
||||
call_single_hook($a, $name, $hook, $data);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$last = get_config('system', 'last_cronhook');
|
||||
|
||||
$poll_interval = intval(get_config('system','cronhook_interval'));
|
||||
if (! $poll_interval) {
|
||||
if(! $poll_interval)
|
||||
$poll_interval = 9;
|
||||
}
|
||||
|
||||
if ($last) {
|
||||
if($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
if ($next > time()) {
|
||||
if($next > time()) {
|
||||
logger('cronhook intervall not reached');
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ function rsa_sign($data,$key,$alg = 'sha256') {
|
|||
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;
|
||||
|
|
@ -34,7 +34,7 @@ function rsa_verify($data,$sig,$key,$alg = 'sha256') {
|
|||
$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;
|
||||
|
|
@ -186,12 +186,12 @@ function salmon_key($pubkey) {
|
|||
|
||||
|
||||
|
||||
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;
|
||||
|
|
@ -200,12 +200,12 @@ function aes_decrypt($val,$ky)
|
|||
}}
|
||||
|
||||
|
||||
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;
|
||||
|
|
@ -237,12 +237,12 @@ function new_keypair($bits) {
|
|||
);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ use \Friendica\Core\Config;
|
|||
* @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;
|
||||
|
|
@ -39,23 +39,23 @@ function select_timezone($current = 'America/Los_Angeles') {
|
|||
|
||||
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) . '">';
|
||||
|
|
@ -114,11 +114,11 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
|
|||
// 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
|
||||
|
|
@ -126,7 +126,7 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
|
|||
// 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));
|
||||
}
|
||||
|
|
@ -169,9 +169,9 @@ function dob($dob) {
|
|||
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'));
|
||||
|
|
@ -279,9 +279,9 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke
|
|||
$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') : '';
|
||||
|
|
@ -290,14 +290,14 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke
|
|||
$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;
|
||||
|
|
@ -394,11 +394,11 @@ function relative_date($posted_date, $format = null) {
|
|||
* @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');
|
||||
|
|
@ -407,7 +407,7 @@ function age($dob,$owner_tz = '',$viewer_tz = '') {
|
|||
$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;
|
||||
|
|
@ -430,10 +430,10 @@ function get_dim($y,$m) {
|
|||
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];
|
||||
|
|
@ -486,12 +486,10 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
|||
|
||||
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
|
||||
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
|
||||
if (! $y) {
|
||||
if(! $y)
|
||||
$y = $thisyear;
|
||||
}
|
||||
if (! $m) {
|
||||
if(! $m)
|
||||
$m = intval($thismonth);
|
||||
}
|
||||
|
||||
$dn = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
|
||||
$f = get_first_dim($y,$m);
|
||||
|
|
@ -500,33 +498,29 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
|||
$dow = 0;
|
||||
$started = false;
|
||||
|
||||
if (($y == $thisyear) && ($m == $thismonth)) {
|
||||
if(($y == $thisyear) && ($m == $thismonth))
|
||||
$tddate = intval(datetime_convert('UTC',date_default_timezone_get(),'now','j'));
|
||||
}
|
||||
|
||||
$str_month = day_translate($mtab[$m]);
|
||||
$o = '<table class="calendar' . $class . '">';
|
||||
$o .= "<caption>$str_month $y</caption><tr>";
|
||||
for ($a = 0; $a < 7; $a ++) {
|
||||
for($a = 0; $a < 7; $a ++)
|
||||
$o .= '<th>' . mb_substr(day_translate($dn[$a]),0,3,'UTF-8') . '</th>';
|
||||
}
|
||||
|
||||
$o .= '</tr><tr>';
|
||||
|
||||
while ($d <= $l) {
|
||||
if (($dow == $f) && (! $started)) {
|
||||
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 {
|
||||
|
|
@ -535,16 +529,14 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
|||
|
||||
$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";
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ $objDDDBLResultHandler->add('PDOStatement', array('HANDLER' => $cloPDOStatementR
|
|||
*
|
||||
*/
|
||||
|
||||
if (! class_exists('dba')) {
|
||||
if(! class_exists('dba')) {
|
||||
class dba {
|
||||
|
||||
private $debug = 0;
|
||||
|
|
@ -66,9 +66,9 @@ class dba {
|
|||
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;
|
||||
|
|
@ -81,13 +81,13 @@ class dba {
|
|||
\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();
|
||||
}
|
||||
|
||||
|
|
@ -109,11 +109,11 @@ class dba {
|
|||
$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 = '';
|
||||
|
|
@ -124,7 +124,7 @@ class dba {
|
|||
$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;
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ class dba {
|
|||
|
||||
$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);
|
||||
|
|
@ -149,20 +149,20 @@ class dba {
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
|
@ -182,13 +182,13 @@ class dba {
|
|||
* 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) {
|
||||
|
|
@ -199,7 +199,7 @@ class dba {
|
|||
|
||||
//$a->save_timestamp($stamp1, "database");
|
||||
|
||||
if ($this->debug)
|
||||
if($this->debug)
|
||||
logger('dba: ' . printable(print_r($r, true)));
|
||||
return($r);
|
||||
}
|
||||
|
|
@ -223,7 +223,7 @@ class dba {
|
|||
}
|
||||
|
||||
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,
|
||||
|
|
@ -238,27 +238,27 @@ class dba {
|
|||
}
|
||||
}}
|
||||
|
||||
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));
|
||||
|
|
@ -271,17 +271,17 @@ function dbesc($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);
|
||||
}
|
||||
|
|
@ -303,11 +303,11 @@ function q($sql) {
|
|||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
|
|
@ -321,21 +321,21 @@ function dbq($sql) {
|
|||
// 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);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ function db_create_table($name, $fields, $charset, $verbose, $action, $indexes=n
|
|||
|
||||
$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;
|
||||
|
|
@ -1621,11 +1621,11 @@ function db_definition($charset) {
|
|||
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);
|
||||
|
|
@ -1650,7 +1650,7 @@ function dbstructure_run(&$argv, &$argc) {
|
|||
$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;
|
||||
}
|
||||
|
|
|
|||
709
include/dfrn.php
709
include/dfrn.php
|
|
@ -41,7 +41,6 @@ class dfrn {
|
|||
* @param array $owner Owner record
|
||||
*
|
||||
* @return string DFRN entries
|
||||
* @todo Add type-hints
|
||||
*/
|
||||
public static function entries($items,$owner) {
|
||||
|
||||
|
|
@ -50,11 +49,10 @@ class dfrn {
|
|||
|
||||
$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);
|
||||
}
|
||||
|
|
@ -84,17 +82,14 @@ class dfrn {
|
|||
$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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +115,7 @@ class dfrn {
|
|||
|
||||
$sql_post_table = "";
|
||||
|
||||
if (! $public_feed) {
|
||||
if(! $public_feed) {
|
||||
|
||||
$sql_extra = '';
|
||||
switch($direction) {
|
||||
|
|
@ -153,13 +148,12 @@ class dfrn {
|
|||
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>' )
|
||||
|
|
@ -174,26 +168,23 @@ class dfrn {
|
|||
);
|
||||
}
|
||||
|
||||
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');
|
||||
|
|
@ -216,11 +207,6 @@ class dfrn {
|
|||
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.
|
||||
|
||||
|
|
@ -231,15 +217,13 @@ class dfrn {
|
|||
|
||||
$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);
|
||||
|
||||
|
|
@ -254,24 +238,21 @@ class dfrn {
|
|||
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);
|
||||
|
|
@ -292,7 +273,6 @@ class dfrn {
|
|||
* @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');
|
||||
|
|
@ -327,7 +307,6 @@ class dfrn {
|
|||
* @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');
|
||||
|
|
@ -355,13 +334,12 @@ class dfrn {
|
|||
* @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']);
|
||||
|
|
@ -372,9 +350,8 @@ class dfrn {
|
|||
$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);
|
||||
|
||||
|
|
@ -413,13 +390,11 @@ class dfrn {
|
|||
* @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);
|
||||
|
|
@ -462,9 +437,8 @@ class dfrn {
|
|||
}
|
||||
|
||||
// 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"]);
|
||||
|
|
@ -487,7 +461,6 @@ class dfrn {
|
|||
* @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) {
|
||||
|
||||
|
|
@ -495,11 +468,10 @@ class dfrn {
|
|||
$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);
|
||||
|
||||
|
|
@ -507,11 +479,10 @@ class dfrn {
|
|||
$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);
|
||||
|
|
@ -520,23 +491,20 @@ class dfrn {
|
|||
$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']);
|
||||
|
||||
|
|
@ -551,7 +519,7 @@ class dfrn {
|
|||
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"]);
|
||||
|
|
@ -579,9 +547,8 @@ class dfrn {
|
|||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -598,17 +565,14 @@ class dfrn {
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
@ -626,7 +590,6 @@ class dfrn {
|
|||
* @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) {
|
||||
|
||||
|
|
@ -667,32 +630,25 @@ class dfrn {
|
|||
* @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);
|
||||
|
||||
|
|
@ -701,9 +657,8 @@ class dfrn {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -712,9 +667,8 @@ class dfrn {
|
|||
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;
|
||||
}
|
||||
|
|
@ -730,26 +684,23 @@ class dfrn {
|
|||
* @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);
|
||||
}
|
||||
|
|
@ -768,28 +719,25 @@ class dfrn {
|
|||
* @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);
|
||||
|
|
@ -797,9 +745,8 @@ class dfrn {
|
|||
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);
|
||||
}
|
||||
|
|
@ -810,7 +757,7 @@ class dfrn {
|
|||
$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",
|
||||
|
|
@ -838,100 +785,78 @@ class dfrn {
|
|||
|
||||
// "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);
|
||||
|
|
@ -948,7 +873,6 @@ class dfrn {
|
|||
* @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) {
|
||||
|
||||
|
|
@ -956,20 +880,16 @@ class dfrn {
|
|||
|
||||
$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);
|
||||
|
||||
|
|
@ -1008,11 +928,10 @@ class dfrn {
|
|||
|
||||
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;
|
||||
|
|
@ -1020,9 +939,8 @@ class dfrn {
|
|||
|
||||
$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);
|
||||
|
|
@ -1034,14 +952,13 @@ class dfrn {
|
|||
|
||||
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),
|
||||
|
|
@ -1051,7 +968,7 @@ class dfrn {
|
|||
}
|
||||
}
|
||||
|
||||
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']);
|
||||
|
|
@ -1063,11 +980,10 @@ class dfrn {
|
|||
|
||||
$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;
|
||||
|
|
@ -1075,12 +991,11 @@ class dfrn {
|
|||
|
||||
$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 {
|
||||
|
|
@ -1090,12 +1005,11 @@ class dfrn {
|
|||
|
||||
$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) {
|
||||
|
|
@ -1133,25 +1047,23 @@ class dfrn {
|
|||
$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']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1176,13 +1088,12 @@ class dfrn {
|
|||
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');
|
||||
|
|
@ -1199,7 +1110,7 @@ class dfrn {
|
|||
*
|
||||
* @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) {
|
||||
|
||||
|
|
@ -1243,7 +1154,6 @@ class dfrn {
|
|||
* @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 = "") {
|
||||
|
||||
|
|
@ -1255,15 +1165,13 @@ class dfrn {
|
|||
`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"];
|
||||
|
|
@ -1274,81 +1182,66 @@ class dfrn {
|
|||
$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
|
||||
|
|
@ -1364,20 +1257,17 @@ class dfrn {
|
|||
|
||||
// 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"];
|
||||
|
|
@ -1407,15 +1297,13 @@ class dfrn {
|
|||
|
||||
$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"]);
|
||||
|
|
@ -1426,19 +1314,17 @@ class dfrn {
|
|||
|
||||
// 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);
|
||||
|
|
@ -1480,12 +1366,10 @@ class dfrn {
|
|||
* @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;
|
||||
|
|
@ -1496,26 +1380,21 @@ class dfrn {
|
|||
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);
|
||||
|
||||
|
|
@ -1532,13 +1411,11 @@ class dfrn {
|
|||
* @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;
|
||||
|
|
@ -1558,7 +1435,7 @@ class dfrn {
|
|||
$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"],
|
||||
|
|
@ -1585,14 +1462,12 @@ class dfrn {
|
|||
* @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"];
|
||||
|
|
@ -1609,11 +1484,8 @@ class dfrn {
|
|||
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?
|
||||
|
||||
|
|
@ -1631,12 +1503,10 @@ class dfrn {
|
|||
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"]),
|
||||
|
|
@ -1648,12 +1518,11 @@ class dfrn {
|
|||
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();
|
||||
|
|
@ -1695,13 +1564,11 @@ class dfrn {
|
|||
* @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"];
|
||||
|
|
@ -1718,23 +1585,18 @@ class dfrn {
|
|||
$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];
|
||||
|
||||
|
|
@ -1790,9 +1652,8 @@ class dfrn {
|
|||
|
||||
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
|
||||
|
|
@ -1807,15 +1668,13 @@ class dfrn {
|
|||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1841,7 +1700,7 @@ class dfrn {
|
|||
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",
|
||||
|
|
@ -1858,13 +1717,12 @@ class dfrn {
|
|||
|
||||
$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"]),
|
||||
|
|
@ -1892,13 +1750,12 @@ class dfrn {
|
|||
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?
|
||||
|
|
@ -1922,9 +1779,8 @@ class dfrn {
|
|||
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?
|
||||
|
|
@ -1932,22 +1788,20 @@ class dfrn {
|
|||
// 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1960,15 +1814,14 @@ class dfrn {
|
|||
*/
|
||||
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":
|
||||
|
|
@ -1979,7 +1832,7 @@ class dfrn {
|
|||
}
|
||||
}
|
||||
|
||||
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(
|
||||
|
|
@ -2027,28 +1880,28 @@ class dfrn {
|
|||
|
||||
// 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)
|
||||
|
|
@ -2064,9 +1917,8 @@ class dfrn {
|
|||
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"]),
|
||||
|
|
@ -2074,31 +1926,28 @@ class dfrn {
|
|||
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"])
|
||||
|
|
@ -2117,7 +1966,6 @@ class dfrn {
|
|||
*
|
||||
* @param object $links link elements
|
||||
* @param array $item the item record
|
||||
* @todo Add type-hints
|
||||
*/
|
||||
private static function parse_links($links, &$item) {
|
||||
$rel = "";
|
||||
|
|
@ -2126,23 +1974,17 @@ class dfrn {
|
|||
$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) {
|
||||
|
|
@ -2151,9 +1993,8 @@ class dfrn {
|
|||
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;
|
||||
|
|
@ -2168,7 +2009,6 @@ class dfrn {
|
|||
* @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) {
|
||||
|
||||
|
|
@ -2219,7 +2059,7 @@ class dfrn {
|
|||
$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);
|
||||
|
||||
|
|
@ -2248,24 +2088,21 @@ class dfrn {
|
|||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2273,24 +2110,21 @@ class dfrn {
|
|||
|
||||
// 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);
|
||||
|
|
@ -2301,14 +2135,12 @@ class dfrn {
|
|||
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 != "")) {
|
||||
|
|
@ -2317,9 +2149,8 @@ class dfrn {
|
|||
$termhash = array_shift($parts);
|
||||
$termurl = implode(":", $parts);
|
||||
|
||||
if (strlen($item["tag"])) {
|
||||
if(strlen($item["tag"]))
|
||||
$item["tag"] .= ",";
|
||||
}
|
||||
|
||||
$item["tag"] .= $termhash."[url=".$termurl."]".$term."[/url]";
|
||||
}
|
||||
|
|
@ -2330,52 +2161,43 @@ class dfrn {
|
|||
$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;
|
||||
//}
|
||||
|
|
@ -2385,15 +2207,14 @@ class dfrn {
|
|||
$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"];
|
||||
|
|
@ -2406,9 +2227,8 @@ class dfrn {
|
|||
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);
|
||||
|
|
@ -2426,9 +2246,8 @@ class dfrn {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -2436,7 +2255,7 @@ class dfrn {
|
|||
$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);
|
||||
|
||||
|
|
@ -2451,7 +2270,7 @@ class dfrn {
|
|||
$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"]),
|
||||
|
|
@ -2465,7 +2284,7 @@ class dfrn {
|
|||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
@ -2473,7 +2292,7 @@ class dfrn {
|
|||
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,
|
||||
|
|
@ -2484,7 +2303,7 @@ class dfrn {
|
|||
$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;
|
||||
}
|
||||
|
|
@ -2497,7 +2316,7 @@ class dfrn {
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -2513,23 +2332,19 @@ class dfrn {
|
|||
|
||||
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`
|
||||
|
|
@ -2547,23 +2362,22 @@ class dfrn {
|
|||
|
||||
$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"])
|
||||
|
|
@ -2576,18 +2390,15 @@ class dfrn {
|
|||
$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)),
|
||||
|
|
@ -2599,7 +2410,7 @@ class dfrn {
|
|||
}
|
||||
}
|
||||
|
||||
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",
|
||||
|
|
@ -2623,7 +2434,7 @@ class dfrn {
|
|||
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()),
|
||||
|
|
@ -2644,7 +2455,7 @@ class dfrn {
|
|||
}
|
||||
// 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"]);
|
||||
}
|
||||
|
|
@ -2664,7 +2475,7 @@ class dfrn {
|
|||
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"]);
|
||||
|
|
@ -2697,14 +2508,12 @@ class dfrn {
|
|||
// 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);
|
||||
|
||||
|
|
@ -2712,50 +2521,43 @@ class dfrn {
|
|||
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");
|
||||
|
|
@ -2767,9 +2569,8 @@ class dfrn {
|
|||
// 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class Diaspora {
|
|||
|
||||
$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";
|
||||
|
|
@ -181,7 +181,7 @@ class Diaspora {
|
|||
|
||||
$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 {
|
||||
|
|
@ -217,11 +217,11 @@ class Diaspora {
|
|||
|
||||
// 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) {
|
||||
|
|
@ -254,7 +254,7 @@ class Diaspora {
|
|||
$data = base64url_decode($data);
|
||||
|
||||
|
||||
if ($public)
|
||||
if($public)
|
||||
$inner_decrypted = $data;
|
||||
else {
|
||||
|
||||
|
|
@ -556,7 +556,7 @@ class Diaspora {
|
|||
logger("Fetching diaspora key for: ".$handle);
|
||||
|
||||
$r = self::person_by_handle($handle);
|
||||
if ($r)
|
||||
if($r)
|
||||
return $r["pubkey"];
|
||||
|
||||
return "";
|
||||
|
|
@ -612,7 +612,7 @@ class Diaspora {
|
|||
*/
|
||||
private static function add_fcontact($arr, $update = false) {
|
||||
|
||||
if ($update) {
|
||||
if($update) {
|
||||
$r = q("UPDATE `fcontact` SET
|
||||
`name` = '%s',
|
||||
`photo` = '%s',
|
||||
|
|
@ -796,7 +796,7 @@ class Diaspora {
|
|||
// 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"]),
|
||||
|
|
@ -806,12 +806,12 @@ class Diaspora {
|
|||
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
|
||||
|
|
@ -969,7 +969,7 @@ class Diaspora {
|
|||
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)
|
||||
|
|
@ -985,7 +985,7 @@ class Diaspora {
|
|||
logger("Fetch post from ".$source_url, LOGGER_DEBUG);
|
||||
|
||||
$x = fetch_url($source_url);
|
||||
if (!$x)
|
||||
if(!$x)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1042,7 +1042,7 @@ class Diaspora {
|
|||
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) {
|
||||
|
|
@ -1303,7 +1303,7 @@ class Diaspora {
|
|||
}
|
||||
|
||||
// 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.
|
||||
|
|
@ -1480,7 +1480,7 @@ class Diaspora {
|
|||
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`)
|
||||
|
|
@ -1493,13 +1493,13 @@ class Diaspora {
|
|||
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) {
|
||||
|
|
@ -1507,7 +1507,7 @@ class Diaspora {
|
|||
return;
|
||||
}
|
||||
|
||||
foreach ($messages as $mesg)
|
||||
foreach($messages as $mesg)
|
||||
self::receive_conversation_message($importer, $contact, $data, $msg, $mesg, $conversation);
|
||||
|
||||
return true;
|
||||
|
|
@ -1637,7 +1637,7 @@ class Diaspora {
|
|||
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.
|
||||
|
|
@ -1812,10 +1812,10 @@ class Diaspora {
|
|||
$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"]);
|
||||
|
|
@ -1830,7 +1830,7 @@ class Diaspora {
|
|||
// 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',
|
||||
|
|
@ -1876,7 +1876,7 @@ class Diaspora {
|
|||
|
||||
$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"]),
|
||||
|
|
@ -1889,7 +1889,7 @@ class Diaspora {
|
|||
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"])
|
||||
|
|
@ -1897,7 +1897,7 @@ class Diaspora {
|
|||
|
||||
// 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"]);
|
||||
|
|
@ -1928,7 +1928,7 @@ class Diaspora {
|
|||
$arr["deny_gid"] = $user[0]["deny_gid"];
|
||||
|
||||
$i = item_store($arr);
|
||||
if ($i)
|
||||
if($i)
|
||||
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
|
||||
}
|
||||
}
|
||||
|
|
@ -2067,12 +2067,12 @@ class Diaspora {
|
|||
|
||||
$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);
|
||||
|
||||
|
|
@ -2122,7 +2122,7 @@ class Diaspora {
|
|||
);
|
||||
|
||||
$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);
|
||||
|
||||
|
|
@ -2748,7 +2748,7 @@ class Diaspora {
|
|||
$a = get_app();
|
||||
|
||||
$enabled = intval(get_config("system", "diaspora_enabled"));
|
||||
if (!$enabled)
|
||||
if(!$enabled)
|
||||
return 200;
|
||||
|
||||
$logid = random_string(4);
|
||||
|
|
@ -3087,14 +3087,14 @@ class Diaspora {
|
|||
$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";
|
||||
}
|
||||
}
|
||||
|
|
@ -3587,7 +3587,7 @@ class Diaspora {
|
|||
$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]) .' ';
|
||||
}
|
||||
|
|
@ -3609,7 +3609,7 @@ class Diaspora {
|
|||
"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);
|
||||
}
|
||||
|
|
@ -3632,20 +3632,17 @@ class Diaspora {
|
|||
}
|
||||
|
||||
$r = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($contact['uid']));
|
||||
if (!dbm::is_result($r)) {
|
||||
if(!$r)
|
||||
return false;
|
||||
}
|
||||
|
||||
$contact["uprvkey"] = $r[0]['prvkey'];
|
||||
|
||||
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($post_id));
|
||||
if (!dbm::is_result($r)) {
|
||||
if (!$r)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE))) {
|
||||
if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE)))
|
||||
return false;
|
||||
}
|
||||
|
||||
$message = self::construct_like($r[0], $contact);
|
||||
$message["author_signature"] = self::signature($contact, $message);
|
||||
|
|
|
|||
|
|
@ -189,10 +189,10 @@ function discover_directory($search) {
|
|||
$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
|
||||
|
|
@ -245,14 +245,12 @@ function gs_search_user($search) {
|
|||
if (!$result["success"]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$contacts = json_decode($result["body"]);
|
||||
|
||||
if ($contacts->status == 'ERROR') {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($contacts->data AS $user) {
|
||||
foreach($contacts->data AS $user) {
|
||||
$contact = probe_url($user->site_address."/".$user->name);
|
||||
if ($contact["network"] != NETWORK_PHANTOM) {
|
||||
$contact["about"] = $user->description;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ require_once('include/msgclean.php');
|
|||
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);
|
||||
|
|
@ -14,23 +14,23 @@ function email_connect($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));
|
||||
|
|
@ -57,8 +57,8 @@ function email_msg_headers($mbox,$uid) {
|
|||
$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);
|
||||
|
|
@ -79,10 +79,10 @@ function email_get_msg($mbox,$uid, $reply) {
|
|||
|
||||
$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'];
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ function email_get_msg($mbox,$uid, $reply) {
|
|||
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;
|
||||
|
|
@ -206,16 +206,16 @@ function email_get_part($mbox,$uid,$p,$partno, $subtype) {
|
|||
|
||||
|
||||
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; | ||||