1
1
Fork 0
friendica_2019-12_sharedHos.../boot.php

204 lines
5 KiB
PHP
Raw Normal View History

2010-07-02 01:48:07 +02:00
<?php
/**
2022-01-02 08:27:47 +01:00
* @copyright Copyright (C) 2010-2022, 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/>.
*
2015-12-24 01:31:17 +01:00
* Friendica is a communications platform for integrated social communications
* utilising decentralised communications and linkage to several indie social
* projects - as well as popular mainstream providers.
*
2015-12-24 01:31:17 +01:00
* Our mission is to free our friends and families from the clutches of
* data-harvesting corporations, and pave the way to a future where social
* communications are free and open and flow between alternate providers as
* easily as email does today.
*/
2010-07-02 01:48:07 +02:00
use Friendica\Model\Contact;
define('FRIENDICA_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'Giant Rhubarb');
2022-06-11 10:06:02 +02:00
define('FRIENDICA_VERSION', '2022.09-dev');
define('DFRN_PROTOCOL_VERSION', '2.23');
define('NEW_TABLE_STRUCTURE_VERSION', 1288);
2017-12-14 22:13:02 +01:00
/**
2020-01-19 07:05:23 +01:00
* Constant with a HTML line break.
*
* Contains a HTML line break (br) element and a real carriage return with line
* feed for the source.
* This can be used in HTML and JavaScript where needed a line break.
*/
define('EOL', "<br />\r\n");
2011-08-17 05:05:02 +02:00
/**
* @name CP
*
* Type of the community page
* @{
*/
define('CP_NO_INTERNAL_COMMUNITY', -2);
define('CP_NO_COMMUNITY_PAGE', -1);
define('CP_USERS_ON_SERVER', 0);
define('CP_GLOBAL_COMMUNITY', 1);
define('CP_USERS_AND_GLOBAL', 2);
/**
* @}
*/
2010-12-10 13:04:35 +01:00
/**
* @name Gravity
*
* Item weight for query ordering
* @{
2010-12-10 13:04:35 +01:00
*/
define('GRAVITY_PARENT', 0);
2018-06-27 20:09:33 +02:00
define('GRAVITY_ACTIVITY', 3);
define('GRAVITY_COMMENT', 6);
2018-06-27 20:09:33 +02:00
define('GRAVITY_UNKNOWN', 9);
/* @}*/
/**
* @name Priority
*
* Process priority for the worker
* @{
*/
define('PRIORITY_UNDEFINED', 0);
define('PRIORITY_CRITICAL', 10);
define('PRIORITY_HIGH', 20);
define('PRIORITY_MEDIUM', 30);
define('PRIORITY_LOW', 40);
define('PRIORITY_NEGLIGIBLE', 50);
2020-12-08 22:58:32 +01:00
define('PRIORITIES', [PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE]);
/* @}*/
// Normally this constant is defined - but not if "pcntl" isn't installed
2017-03-19 09:04:04 +01:00
if (!defined("SIGTERM")) {
define("SIGTERM", 15);
2017-03-19 09:04:04 +01:00
}
2017-05-03 04:42:29 +02:00
/**
* Depending on the PHP version this constant does exist - or not.
* See here: http://php.net/manual/en/curl.constants.php#117928
*/
if (!defined('CURLE_OPERATION_TIMEDOUT')) {
define('CURLE_OPERATION_TIMEDOUT', CURLE_OPERATION_TIMEOUTED);
}
2010-11-24 08:42:45 +01:00
if (!function_exists('exif_imagetype')) {
function exif_imagetype($file)
{
$size = getimagesize($file);
return $size[2];
}
}
2015-12-24 01:31:17 +01:00
/**
2020-01-19 07:05:23 +01:00
* Returns the user id of locally logged in user or false.
*
2015-12-24 01:31:17 +01:00
* @return int|bool user id or false
*/
function local_user()
{
if (!empty($_SESSION['authenticated']) && !empty($_SESSION['uid'])) {
2015-12-24 01:31:17 +01:00
return intval($_SESSION['uid']);
}
2015-12-24 01:31:17 +01:00
return false;
}
2010-07-02 01:48:07 +02:00
/**
2020-01-19 07:05:23 +01:00
* 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 && !empty($_SESSION['authenticated'])) {
if (!empty($_SESSION['my_address'])) {
// Local user
$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, false));
}
} elseif (empty($_SESSION['authenticated'])) {
$public_contact_id = false;
}
return $public_contact_id;
}
2015-12-24 01:31:17 +01:00
/**
* Returns public contact id of authenticated site visitor or false
*
2015-12-24 01:31:17 +01:00
* @return int|bool visitor_id or false
*/
2019-09-28 11:59:08 +02:00
function remote_user()
{
2019-09-24 00:13:20 +02:00
if (empty($_SESSION['authenticated'])) {
return false;
}
2019-09-28 11:59:08 +02:00
if (!empty($_SESSION['visitor_id'])) {
2015-12-24 01:31:17 +01:00
return intval($_SESSION['visitor_id']);
}
2019-09-24 00:13:20 +02:00
2015-12-24 01:31:17 +01:00
return false;
}
2010-07-02 01:48:07 +02:00
2015-12-24 01:31:17 +01:00
/**
2020-01-19 07:05:23 +01:00
* Show an error message to user.
2015-12-24 01:31:17 +01:00
*
* This function save text in session, to be shown to the user at next page load
*
* @param string $s - Text of notice
*/
function notice($s)
{
if (empty($_SESSION)) {
return;
}
if (empty($_SESSION['sysmsg'])) {
$_SESSION['sysmsg'] = [];
}
2021-07-24 12:09:39 +02:00
$_SESSION['sysmsg'][] = $s;
}
2015-12-24 01:31:17 +01:00
/**
2020-01-19 07:05:23 +01:00
* Show an info message to user.
2015-12-24 01:31:17 +01:00
*
* This function save text in session, to be shown to the user at next page load
*
* @param string $s - Text of notice
*/
function info($s)
{
2021-07-24 12:09:39 +02:00
if (empty($_SESSION)) {
return;
}
if (empty($_SESSION['sysmsg_info'])) {
$_SESSION['sysmsg_info'] = [];
}
2021-07-24 12:09:39 +02:00
$_SESSION['sysmsg_info'][] = $s;
2015-12-24 01:31:17 +01:00
}