aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
Diffstat (limited to 'boot.php')
-rwxr-xr-xboot.php220
1 files changed, 166 insertions, 54 deletions
diff --git a/boot.php b/boot.php
index b2c8fa9ea..4e266f4f1 100755
--- a/boot.php
+++ b/boot.php
@@ -27,7 +27,6 @@
* documented.
*/
-
require_once('include/config.php');
require_once('include/network.php');
require_once('include/plugin.php');
@@ -52,12 +51,21 @@ define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1131 );
+/**
+ * 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.
+ *
+ * @var string
+ */
define ( 'EOL', '<br>' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
//define ( 'NULL_DATE', '0000-00-00 00:00:00' );
define ( 'TEMPLATE_BUILD_PATH', 'store/[data]/smarty3' );
-define ( 'DIRECTORY_MODE_NORMAL', 0x0000); // This is technically DIRECTORY_MODE_TERTIARY, but it's the default, hence 0x0000
+define ( 'DIRECTORY_MODE_NORMAL', 0x0000); // This is technically DIRECTORY_MODE_TERTIARY, but it's the default, hence 0x0000
define ( 'DIRECTORY_MODE_PRIMARY', 0x0001);
define ( 'DIRECTORY_MODE_SECONDARY', 0x0002);
define ( 'DIRECTORY_MODE_STANDALONE', 0x0100);
@@ -75,7 +83,8 @@ $DIRECTORY_FALLBACK_SERVERS = array(
'https://zotid.net',
'https://redmatrix.nl',
'https://red.zottel.red',
- 'https://red.pixelbits.de'
+ 'https://red.pixelbits.de',
+ 'https://whogotzot.com'
);
@@ -232,6 +241,8 @@ define ( 'PHOTO_XCHAN', 0x0002 );
define ( 'PHOTO_THING', 0x0004 );
define ( 'PHOTO_ADULT', 0x0008 );
+define ( 'PHOTO_FLAG_OS', 0x4000 );
+
/**
* Menu types
*/
@@ -569,7 +580,7 @@ define ( 'ITEM_RSS', 0x8000); // Item comes from a feed. Use this t
define ( 'DBTYPE_MYSQL', 0 );
define ( 'DBTYPE_POSTGRES', 1 );
-
+
/**
*
* Reverse the effect of magic_quotes_gpc if it is enabled.
@@ -613,10 +624,10 @@ function startup() {
}
/**
- *
* class: App
*
- * Our main application structure for the life of this page
+ * @brief Our main application structure for the life of this page.
+ *
* Primarily deals with the URL that got us here
* and tries to make some sense of it, and
* stores our page contents and config storage
@@ -682,11 +693,15 @@ class App {
public $force_max_items = 0;
public $theme_thread_allow = true;
- // An array for all theme-controllable parameters
- // Mostly unimplemented yet. Only options 'template_engine' and
- // beyond are used.
-
- private $theme = array(
+ /**
+ * @brief An array for all theme-controllable parameters
+ *
+ * Mostly unimplemented yet. Only options 'template_engine' and
+ * beyond are used.
+ *
+ * @var array
+ */
+ private $theme = array(
'sourcename' => '',
'videowidth' => 425,
'videoheight' => 350,
@@ -696,9 +711,17 @@ class App {
'template_engine' => 'smarty3',
);
- // array of registered template engines ('name'=>'class name')
+ /**
+ * array of registered template engines ('name'=>'class name')
+ *
+ * @var array
+ */
public $template_engines = array();
- // array of instanced template engines ('name'=>'instance')
+ /**
+ * array of instanced template engines ('name'=>'instance')
+ *
+ * @var array
+ */
public $template_engine_instance = array();
private $ldelim = array(
@@ -715,7 +738,9 @@ class App {
private $baseurl;
private $path;
-
+ /**
+ * App constructor.
+ */
function __construct() {
// we'll reset this after we read our config file
date_default_timezone_set('UTC');
@@ -758,8 +783,8 @@ class App {
set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
- if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
- $this->query_string = substr($_SERVER['QUERY_STRING'],2);
+ if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
+ $this->query_string = substr($_SERVER['QUERY_STRING'], 2);
// removing trailing / - maybe a nginx problem
if (substr($this->query_string, 0, 1) == "/")
$this->query_string = substr($this->query_string, 1);
@@ -769,8 +794,8 @@ class App {
// unix style "homedir"
- if(substr($this->cmd,0,1) === '~')
- $this->cmd = 'channel/' . substr($this->cmd,1);
+ if(substr($this->cmd, 0, 1) === '~')
+ $this->cmd = 'channel/' . substr($this->cmd, 1);
/**
@@ -854,7 +879,6 @@ class App {
}
function set_baseurl($url) {
-
if(is_array($this->config)
&& array_key_exists('system',$this->config)
&& is_array($this->config['system'])
@@ -887,7 +911,7 @@ class App {
}
function set_path($p) {
- $this->path = trim(trim($p),'/');
+ $this->path = trim(trim($p), '/');
}
function get_path() {
@@ -1029,6 +1053,7 @@ class App {
* return engine defined by theme, or default
*
* @param string $name Template engine name
+ *
* @return object Template Engine instance
*/
function template_engine($name = ''){
@@ -1055,6 +1080,11 @@ class App {
echo "template engine <tt>$template_engine</tt> is not registered!\n"; killme();
}
+ /**
+ * @brief Returns the active template engine.
+ *
+ * @return string
+ */
function get_template_engine() {
return $this->theme['template_engine'];
}
@@ -1096,9 +1126,13 @@ class App {
} // End App class
-// retrieve the App structure
-// useful in functions which require it but don't get it passed to them
-
+/**
+ * @brief Retrieve the App structure.
+ *
+ * Useful in functions which require it but don't get it passed to them
+ *
+ * @return App
+ */
function get_app() {
global $a;
return $a;
@@ -1116,7 +1150,8 @@ function get_app() {
*
* @param string|array $s variable to check
* @param string $k key inside the array to check
- * @return bool
+ *
+ * @return bool|int
*/
function x($s, $k = null) {
if($k != null) {
@@ -1166,24 +1201,43 @@ function z_path() {
return $base;
}
+/**
+ * @brief Returns the baseurl.
+ *
+ * @see App::get_baseurl()
+ *
+ * @return string
+ */
function z_root() {
global $a;
return $a->get_baseurl();
}
+/**
+ * @brief Return absolut URL for given $path.
+ *
+ * @param string $path
+ *
+ * @return string
+ */
function absurl($path) {
- if(strpos($path,'/') === 0)
+ if(strpos($path, '/') === 0)
return z_path() . $path;
return $path;
}
-function os_mkdir($path,$mode = 0777,$recursive = false) {
+function os_mkdir($path, $mode = 0777, $recursive = false) {
$oldumask = @umask(0);
@mkdir($path, $mode, $recursive);
@umask($oldumask);
}
+/**
+ * @brief Function to check if request was an AJAX (xmlhttprequest) request.
+ *
+ * @return boolean
+ */
function is_ajax() {
return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
}
@@ -1331,11 +1385,11 @@ function check_config(&$a) {
else
$installed = array();
- $plugins = get_config('system','addon');
+ $plugins = get_config('system', 'addon');
$plugins_arr = array();
if($plugins)
- $plugins_arr = explode(',',str_replace(' ', '',$plugins));
+ $plugins_arr = explode(',', str_replace(' ', '', $plugins));
$a->plugins = $plugins_arr;
@@ -1343,7 +1397,7 @@ function check_config(&$a) {
if(count($installed)) {
foreach($installed as $i) {
- if(! in_array($i['name'],$plugins_arr)) {
+ if(! in_array($i['name'], $plugins_arr)) {
unload_plugin($i['name']);
}
else {
@@ -1354,7 +1408,7 @@ function check_config(&$a) {
if(count($plugins_arr)) {
foreach($plugins_arr as $p) {
- if(! in_array($p,$installed_arr)) {
+ if(! in_array($p, $installed_arr)) {
load_plugin($p);
}
}
@@ -1364,7 +1418,7 @@ function check_config(&$a) {
}
-function fix_system_urls($oldurl,$newurl) {
+function fix_system_urls($oldurl, $newurl) {
require_once('include/crypto.php');
@@ -1455,7 +1509,7 @@ function login($register = false, $form_id = 'main-login', $hiddens=false) {
$a = get_app();
$o = '';
$reg = false;
- $reglink = get_config('system','register_link');
+ $reglink = get_config('system', 'register_link');
if(! strlen($reglink))
$reglink = 'register';
@@ -1471,9 +1525,11 @@ function login($register = false, $form_id = 'main-login', $hiddens=false) {
$tpl = get_markup_template("logout.tpl");
}
else {
- $a->page['htmlhead'] .= replace_macros(get_markup_template("login_head.tpl"),array(
- '$baseurl' => $a->get_baseurl(true)
- ));
+// There's no such thing as login_head.tpl, has never been in Red, removed from Friendica 1 Jun 2013...
+
+// $a->page['htmlhead'] .= replace_macros(get_markup_template("login_head.tpl"), array(
+// '$baseurl' => $a->get_baseurl(true)
+// ));
$tpl = get_markup_template("login.tpl");
if(strlen($a->query_string))
@@ -1500,16 +1556,17 @@ function login($register = false, $form_id = 'main-login', $hiddens=false) {
}
-// Used to end the current process, after saving session state.
-
+/**
+ * @brief Used to end the current process, after saving session state.
+ */
function killme() {
session_write_close();
exit;
}
-
-// redirect to another URL and terminate this process.
-
+/**
+ * @brief Redirect to another URL and terminate this process.
+ */
function goaway($s) {
header("Location: $s");
killme();
@@ -1531,7 +1588,7 @@ function get_account_id() {
}
/**
- * @brief Returns the entity id of locally logged in user or false.
+ * @brief Returns the entity id (channel_id) of locally logged in user or false.
*
* Returns authenticated numeric channel_id if authenticated and connected to
* a channel or 0. Sometimes referred to as $uid in the code.
@@ -1545,22 +1602,28 @@ function local_user() {
return false;
}
-
-// Returns contact id of authenticated site visitor or false
-
+/**
+ * @brief Returns contact id (visitor_id) of authenticated site visitor or false.
+ *
+ * @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 $_SESSION['visitor_id'];
+
return false;
}
-
-// contents of $s are displayed prominently on the page the next time
-// a page is loaded. Usually used for errors or alerts.
-
+/**
+ * Contents of $s are displayed prominently on the page the next time
+ * a page is loaded. Usually used for errors or alerts.
+ *
+ * @param string $s Text to display
+ */
function notice($s) {
$a = get_app();
if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array();
+
if($a->interactive) {
// shameless plug, permission is denied and they have no identity.
// There's a fairly good chance that they've not got zot.
@@ -1571,7 +1634,13 @@ function notice($s) {
}
}
-
+/**
+ * Contents of $s are displayed prominently on the page the next time a page is
+ * loaded. Usually used for information.
+ * For error and alerts use notice().
+ *
+ * @param string $s Text to display
+ */
function info($s) {
$a = get_app();
if(! x($_SESSION, 'sysmsg_info')) $_SESSION['sysmsg_info'] = array();
@@ -1735,13 +1804,19 @@ function current_theme(){
/**
- * Return full URL to theme which is currently in effect.
+ * @brief Return full URL to theme which is currently in effect.
+ *
* Provide a sane default if nothing is chosen or the specified theme does not exist.
+ *
+ * @param bool $installing default false
+ *
+ * @return string
*/
-
function current_theme_url($installing = false) {
global $a;
+
$t = current_theme();
+
$opts = '';
$opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
$opts .= ((x($a->layout,'schema')) ? '&schema=' . $a->layout['schema'] : '');
@@ -1760,10 +1835,12 @@ function current_theme_url($installing = false) {
*/
function is_site_admin() {
$a = get_app();
+
if((intval($_SESSION['authenticated']))
&& (is_array($a->account))
&& ($a->account['account_roles'] & ACCOUNT_ROLE_ADMIN))
return true;
+
return false;
}
@@ -1815,6 +1892,7 @@ function load_contact_links($uid) {
*
* @param array $params mapped array with query parameters
* @param string $name of parameter, default null
+ *
* @return string
*/
function build_querystring($params, $name = null) {
@@ -1856,6 +1934,11 @@ function dba_timer() {
return microtime(true);
}
+/**
+ * @brief Returns xchan_hash from the observer.
+ *
+ * @return string Empty if no observer, otherwise xchan_hash from observer
+ */
function get_observer_hash() {
$observer = get_app()->get_observer();
if(is_array($observer))
@@ -1891,6 +1974,7 @@ function curPageURL() {
*
* @param App $a global application object
* @param string $navname
+ *
* @return mixed
*/
function get_custom_nav(&$a, $navname) {
@@ -2042,12 +2126,20 @@ function construct_page(&$a) {
);
}
-
+/**
+ * @brief Returns RedMatrix's root directory.
+ *
+ * @return string
+ */
function appdirpath() {
return dirname(__FILE__);
}
-
+/**
+ * @brief Set a pageicon.
+ *
+ * @param string $icon
+ */
function head_set_icon($icon) {
global $a;
@@ -2055,6 +2147,11 @@ function head_set_icon($icon) {
// logger('head_set_icon: ' . $icon);
}
+/**
+ * @brief Get the pageicon.
+ *
+ * @return string absolut path to pageicon
+ */
function head_get_icon() {
global $a;
@@ -2065,9 +2162,24 @@ function head_get_icon() {
return $icon;
}
+/**
+ * @brief Return the Realm of the directory.
+ *
+ * @return string
+ */
function get_directory_realm() {
if($x = get_config('system', 'directory_realm'))
return $x;
return DIRECTORY_REALM;
}
+
+
+/**
+ * @brief return relative date of last completed poller execution
+ */
+
+function get_poller_runtime() {
+ $t = get_config('system','lastpoll');
+ return relative_date($t);
+}