<?php
/**
- * @file boot.php
- * This file defines some global constants and includes the central App class.
- */
-
-/**
- * Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Friendica is a communications platform for integrated social communications
* utilising decentralised communications and linkage to several indie social
* easily as email does today.
*/
-use Friendica\Core\Config;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
-use Friendica\Model\Term;
+use Friendica\Model\Notification;
use Friendica\Util\BasePath;
use Friendica\Util\DateTimeFormat;
define('FRIENDICA_PLATFORM', 'Friendica');
-define('FRIENDICA_CODENAME', 'Dalmatian Bellflower');
-define('FRIENDICA_VERSION', '2020.03-dev');
+define('FRIENDICA_CODENAME', 'Siberian Iris');
+define('FRIENDICA_VERSION', '2021.09-rc');
define('DFRN_PROTOCOL_VERSION', '2.23');
-define('NEW_UPDATE_ROUTINE_VERSION', 1170);
+define('NEW_TABLE_STRUCTURE_VERSION', 1288);
/**
* Constant with a HTML line break.
define('MAX_LIKERS', 75);
/**
- * @name Notify
+ * @name Notification
*
* Email notification options
* @{
*/
-define('NOTIFY_INTRO', 1);
-define('NOTIFY_CONFIRM', 2);
-define('NOTIFY_WALL', 4);
-define('NOTIFY_COMMENT', 8);
-define('NOTIFY_MAIL', 16);
-define('NOTIFY_SUGGEST', 32);
-define('NOTIFY_PROFILE', 64);
-define('NOTIFY_TAGSELF', 128);
-define('NOTIFY_TAGSHARE', 256);
-define('NOTIFY_POKE', 512);
-define('NOTIFY_SHARE', 1024);
-
-define('SYSTEM_EMAIL', 16384);
-
-define('NOTIFY_SYSTEM', 32768);
+/** @deprecated since 2020.03, use Notification\Type::INTRO instead */
+define('NOTIFY_INTRO', Notification\Type::INTRO);
+/** @deprecated since 2020.03, use Notification\Type::CONFIRM instead */
+define('NOTIFY_CONFIRM', Notification\Type::CONFIRM);
+/** @deprecated since 2020.03, use Notification\Type::WALL instead */
+define('NOTIFY_WALL', Notification\Type::WALL);
+/** @deprecated since 2020.03, use Notification\Type::COMMENT instead */
+define('NOTIFY_COMMENT', Notification\Type::COMMENT);
+/** @deprecated since 2020.03, use Notification\Type::MAIL instead */
+define('NOTIFY_MAIL', Notification\Type::MAIL);
+/** @deprecated since 2020.03, use Notification\Type::SUGGEST instead */
+define('NOTIFY_SUGGEST', Notification\Type::SUGGEST);
+/** @deprecated since 2020.03, use Notification\Type::PROFILE instead */
+define('NOTIFY_PROFILE', Notification\Type::PROFILE);
+/** @deprecated since 2020.03, use Notification\Type::TAG_SELF instead */
+define('NOTIFY_TAGSELF', Notification\Type::TAG_SELF);
+/** @deprecated since 2020.03, use Notification\Type::TAG_SHARE instead */
+define('NOTIFY_TAGSHARE', Notification\Type::TAG_SHARE);
+/** @deprecated since 2020.03, use Notification\Type::POKE instead */
+define('NOTIFY_POKE', Notification\Type::POKE);
+/** @deprecated since 2020.03, use Notification\Type::SHARE instead */
+define('NOTIFY_SHARE', Notification\Type::SHARE);
+
+/** @deprecated since 2020.12, use Notification\Type::SYSTEM instead */
+define('NOTIFY_SYSTEM', Notification\Type::SYSTEM);
/* @}*/
-
-/** @deprecated since 2019.03, use Term::UNKNOWN instead */
-define('TERM_UNKNOWN', Term::UNKNOWN);
-/** @deprecated since 2019.03, use Term::HASHTAG instead */
-define('TERM_HASHTAG', Term::HASHTAG);
-/** @deprecated since 2019.03, use Term::MENTION instead */
-define('TERM_MENTION', Term::MENTION);
-/** @deprecated since 2019.03, use Term::CATEGORY instead */
-define('TERM_CATEGORY', Term::CATEGORY);
-/** @deprecated since 2019.03, use Term::PCATEGORY instead */
-define('TERM_PCATEGORY', Term::PCATEGORY);
-/** @deprecated since 2019.03, use Term::FILE instead */
-define('TERM_FILE', Term::FILE);
-/** @deprecated since 2019.03, use Term::SAVEDSEARCH instead */
-define('TERM_SAVEDSEARCH', Term::SAVEDSEARCH);
-/** @deprecated since 2019.03, use Term::CONVERSATION instead */
-define('TERM_CONVERSATION', Term::CONVERSATION);
-
-/** @deprecated since 2019.03, use Term::OBJECT_TYPE_POST instead */
-define('TERM_OBJ_POST', Term::OBJECT_TYPE_POST);
-/** @deprecated since 2019.03, use Term::OBJECT_TYPE_PHOTO instead */
-define('TERM_OBJ_PHOTO', Term::OBJECT_TYPE_PHOTO);
-
/**
* @name Gravity
*
define('PRIORITY_MEDIUM', 30);
define('PRIORITY_LOW', 40);
define('PRIORITY_NEGLIGIBLE', 50);
+define('PRIORITIES', [PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE]);
/* @}*/
/**
if (!$public_contact_id && !empty($_SESSION['authenticated'])) {
if (!empty($_SESSION['my_address'])) {
// Local user
- $public_contact_id = intval(Contact::getIdForURL($_SESSION['my_address'], 0, true));
+ $public_contact_id = intval(Contact::getIdForURL($_SESSION['my_address'], 0, false));
} elseif (!empty($_SESSION['visitor_home'])) {
// Remote user
- $public_contact_id = intval(Contact::getIdForURL($_SESSION['visitor_home'], 0, true));
+ $public_contact_id = intval(Contact::getIdForURL($_SESSION['visitor_home'], 0, false));
}
} elseif (empty($_SESSION['authenticated'])) {
$public_contact_id = false;
}
/**
- * Returns contact id of authenticated site visitor or false
+ * Returns public contact id of authenticated site visitor or false
*
* @return int|bool visitor_id or false
*/
return;
}
- $a = DI::app();
if (empty($_SESSION['sysmsg'])) {
$_SESSION['sysmsg'] = [];
}
- if ($a->interactive) {
- $_SESSION['sysmsg'][] = $s;
- }
+
+ $_SESSION['sysmsg'][] = $s;
}
/**
*/
function info($s)
{
- $a = DI::app();
-
- if (local_user() && DI::pConfig()->get(local_user(), 'system', 'ignore_info')) {
+ if (empty($_SESSION)) {
return;
}
if (empty($_SESSION['sysmsg_info'])) {
$_SESSION['sysmsg_info'] = [];
}
- if ($a->interactive) {
- $_SESSION['sysmsg_info'][] = $s;
- }
+
+ $_SESSION['sysmsg_info'][] = $s;
}
function feed_birthday($uid, $tz)
$tz = 'UTC';
}
- $profile = DBA::selectFirst('profile', ['dob'], ['is-default' => true, 'uid' => $uid]);
+ $profile = DBA::selectFirst('profile', ['dob'], ['uid' => $uid]);
if (DBA::isResult($profile)) {
$tmp_dob = substr($profile['dob'], 5);
if (intval($tmp_dob)) {
{
$a = DI::app();
- $admin_email = Config::get('config', 'admin_email');
+ $admin_email = DI::config()->get('config', 'admin_email');
$adminlist = explode(',', str_replace(' ', '', $admin_email));
- return local_user() && $admin_email && in_array($a->user['email'] ?? '', $adminlist);
-}
-
-function explode_querystring($query)
-{
- $arg_st = strpos($query, '?');
- if ($arg_st !== false) {
- $base = substr($query, 0, $arg_st);
- $arg_st += 1;
- } else {
- $base = '';
- $arg_st = 0;
- }
-
- $args = explode('&', substr($query, $arg_st));
- foreach ($args as $k => $arg) {
- /// @TODO really compare type-safe here?
- if ($arg === '') {
- unset($args[$k]);
- }
- }
- $args = array_values($args);
-
- if (!$base) {
- $base = $args[0];
- unset($args[0]);
- $args = array_values($args);
- }
-
- return [
- 'base' => $base,
- 'args' => $args,
- ];
+ return local_user() && $admin_email && DBA::exists('user', ['uid' => $a->getLoggedInUserId(), 'email' => $adminlist]);
}
/**
function get_temppath()
{
- $temppath = Config::get("system", "temppath");
+ $temppath = DI::config()->get("system", "temppath");
if (($temppath != "") && System::isDirectoryUsable($temppath)) {
// We have a temp path and it is usable
if (System::isDirectoryUsable($new_temppath)) {
// The new path is usable, we are happy
- Config::set("system", "temppath", $new_temppath);
+ DI::config()->set("system", "temppath", $new_temppath);
return $new_temppath;
} else {
// We can't create a subdirectory, strange.
return '';
}
-function get_cachefile($file, $writemode = true)
-{
- $cache = get_itemcachepath();
-
- if ((!$cache) || (!is_dir($cache))) {
- return "";
- }
-
- $subfolder = $cache . "/" . substr($file, 0, 2);
-
- $cachepath = $subfolder . "/" . $file;
-
- if ($writemode) {
- if (!is_dir($subfolder)) {
- mkdir($subfolder);
- chmod($subfolder, 0777);
- }
- }
-
- return $cachepath;
-}
-
-function clear_cache($basepath = "", $path = "")
-{
- if ($path == "") {
- $basepath = get_itemcachepath();
- $path = $basepath;
- }
-
- if (($path == "") || (!is_dir($path))) {
- return;
- }
-
- if (substr(realpath($path), 0, strlen($basepath)) != $basepath) {
- return;
- }
-
- $cachetime = (int) Config::get('system', 'itemcache_duration');
- 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") && ($file != ".") && ($file != "..")) {
- clear_cache($basepath, $fullpath);
- }
- if ((filetype($fullpath) == "file") && (filectime($fullpath) < (time() - $cachetime))) {
- unlink($fullpath);
- }
- }
- closedir($dh);
- }
- }
-}
-
-function get_itemcachepath()
-{
- // Checking, if the cache is deactivated
- $cachetime = (int) Config::get('system', 'itemcache_duration');
- if ($cachetime < 0) {
- return "";
- }
-
- $itemcache = Config::get('system', 'itemcache');
- if (($itemcache != "") && System::isDirectoryUsable($itemcache)) {
- return BasePath::getRealPath($itemcache);
- }
-
- $temppath = get_temppath();
-
- if ($temppath != "") {
- $itemcache = $temppath . "/itemcache";
- if (!file_exists($itemcache) && !is_dir($itemcache)) {
- mkdir($itemcache);
- }
-
- if (System::isDirectoryUsable($itemcache)) {
- Config::set("system", "itemcache", $itemcache);
- return $itemcache;
- }
- }
- return "";
-}
-
/**
* Returns the path where spool files are stored
*
*/
function get_spoolpath()
{
- $spoolpath = Config::get('system', 'spoolpath');
+ $spoolpath = DI::config()->get('system', 'spoolpath');
if (($spoolpath != "") && System::isDirectoryUsable($spoolpath)) {
// We have a spool path and it is usable
return $spoolpath;
if (System::isDirectoryUsable($spoolpath)) {
// The new path is usable, we are happy
- Config::set("system", "spoolpath", $spoolpath);
+ DI::config()->set("system", "spoolpath", $spoolpath);
return $spoolpath;
} else {
// We can't create a subdirectory, strange.