X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=6f036d846e90887faa62cc21baf2256bb7224cfc;hb=8cb9d51fa889aa27b98a535f6c771665069dd77a;hp=74830e4300d768d5435e34212ce6011d6d5fc306;hpb=77e8c44016a5c327e61e93724b8921cfd600b66c;p=friendica.git diff --git a/boot.php b/boot.php index 74830e4300..6f036d846e 100644 --- a/boot.php +++ b/boot.php @@ -39,7 +39,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5.2-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1215 ); +define ( 'DB_UPDATE_VERSION', 1216 ); /** * @brief Constant with a HTML line break. @@ -441,10 +441,17 @@ define('SR_SCOPE_ALL', 'all'); define('SR_SCOPE_TAGS', 'tags'); /* @}*/ +/** + * Lowest possible date time value + */ + +define ('NULL_DATE', '0001-01-01 00:00:00'); + + // Normally this constant is defined - but not if "pcntl" isn't installed -if (!defined("SIGTERM")) +if (!defined("SIGTERM")) { define("SIGTERM", 15); - +} /** * * Reverse the effect of magic_quotes_gpc if it is enabled. @@ -1853,11 +1860,35 @@ function goaway($s) { * @return int|bool user id or false */ function local_user() { - if((x($_SESSION,'authenticated')) && (x($_SESSION,'uid'))) + if (x($_SESSION, 'authenticated') && x($_SESSION, 'uid')) { return intval($_SESSION['uid']); + } return false; } +/** + * @brief Returns the public contact id of logged in user or false. + * + * @return int|bool public contact id or false + */ +function public_contact() { + static $public_contact_id = false; + + if (!$public_contact_id && x($_SESSION, 'authenticated')) { + if (x($_SESSION, 'my_address')) { + // Local user + $public_contact_id = intval(get_contact($_SESSION['my_address'], 0)); + } else if (x($_SESSION, 'visitor_home')) { + // Remote user + $public_contact_id = intval(get_contact($_SESSION['visitor_home'], 0)); + } + } else if (!x($_SESSION, 'authenticated')) { + $public_contact_id = false; + } + + return $public_contact_id; +} + /** * @brief Returns contact id of authenticated site visitor or false * @@ -1997,7 +2028,7 @@ function proc_run($cmd){ } // Checking number of workers - $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'"); + $workers = q("SELECT COUNT(*) AS `workers` FROM `workerqueue` WHERE `executed` > '%s'", dbesc(NULL_DATE)); // Get number of allowed number of worker threads $queues = intval(get_config("system", "worker_queues"));