aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
Diffstat (limited to 'boot.php')
-rw-r--r--[-rwxr-xr-x]boot.php129
1 files changed, 84 insertions, 45 deletions
diff --git a/boot.php b/boot.php
index 6c70c90e5..2145b30b1 100755..100644
--- a/boot.php
+++ b/boot.php
@@ -28,6 +28,8 @@
*/
// composer autoloader for all namespaced Classes
+use Zotlabs\Lib\Crypto;
+
require_once('vendor/autoload.php');
require_once('include/config.php');
@@ -48,12 +50,13 @@ require_once('include/xchan.php');
require_once('include/hubloc.php');
require_once('include/attach.php');
require_once('include/bbcode.php');
+require_once('include/items.php');
define ( 'PLATFORM_NAME', 'hubzilla' );
-define ( 'STD_VERSION', '5.1.9' );
+define ( 'STD_VERSION', '6.3.4' );
define ( 'ZOT_REVISION', '6.0' );
-define ( 'DB_UPDATE_VERSION', 1239 );
+define ( 'DB_UPDATE_VERSION', 1248 );
define ( 'PROJECT_BASE', __DIR__ );
@@ -82,11 +85,16 @@ define ( 'DIRECTORY_MODE_STANDALONE', 0x0100); // A detached (off the grid) hub
define ( 'DIRECTORY_REALM', 'RED_GLOBAL');
define ( 'DIRECTORY_FALLBACK_MASTER', 'https://hub.netzgemeinde.eu');
-$DIRECTORY_FALLBACK_SERVERS = array(
- 'https://hub.netzgemeinde.eu',
- 'https://zotsite.net',
- 'https://hub.libranet.de'
-);
+
+function get_directory_fallback_servers() {
+ $ret = [
+ 'https://hub.netzgemeinde.eu',
+ 'https://zotsite.net',
+ 'https://hub.libranet.de'
+ ];
+
+ return $ret;
+}
/**
@@ -355,6 +363,7 @@ define ( 'UPDATE_FLAGS_UPDATED', 0x0001);
define ( 'UPDATE_FLAGS_FORCED', 0x0002);
define ( 'UPDATE_FLAGS_DELETED', 0x1000);
+define ( 'HUBLOC_OFFLINE', 0x0001);
define ( 'DROPITEM_NORMAL', 0);
define ( 'DROPITEM_PHASE1', 1);
@@ -433,7 +442,7 @@ define ( 'TERM_FORUM', 11 );
define ( 'TERM_EMOJI', 12 );
define ( 'TERM_OBJ_POST', 1 );
-define ( 'TERM_OBJ_PHOTO', 2 );
+define ( 'TERM_OBJ_FILE', 2 );
define ( 'TERM_OBJ_PROFILE', 3 );
define ( 'TERM_OBJ_CHANNEL', 4 );
define ( 'TERM_OBJ_OBJECT', 5 );
@@ -595,6 +604,7 @@ define ( 'DBTYPE_POSTGRES', 1 );
function sys_boot() {
+
// our central App object
App::init();
@@ -675,14 +685,18 @@ function sys_boot() {
function startup() {
- error_reporting(E_ERROR | E_WARNING | E_PARSE);
+ error_reporting(E_ALL & ~E_NOTICE);
+
+ if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
+ error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
+ }
// Some hosting providers block/disable this
@set_time_limit(0);
if(function_exists ('ini_set')) {
// This has to be quite large to deal with embedded private photos
- @ini_set('pcre.backtrack_limit', 500000);
+ //@ini_set('pcre.backtrack_limit', 500000);
// Use cookies to store the session ID on the client side
@ini_set('session.use_only_cookies', 1);
@@ -1170,16 +1184,24 @@ class App {
if($interval < 10000)
$interval = 80000;
- if(! x(self::$page,'title'))
+ if(! isset(self::$page['title']) && isset(self::$config['system']['sitename']))
self::$page['title'] = self::$config['system']['sitename'];
- $pagemeta = [ 'og:title' => self::$page['title'] ];
+ if(isset(self::$page['title']))
+ $pagemeta = [ 'og:title' => self::$page['title'] ];
call_hooks('page_meta',$pagemeta);
- foreach ($pagemeta as $metaproperty => $metavalue) {
- self::$meta->set($metaproperty,$metavalue);
+
+ if($pagemeta) {
+ foreach ($pagemeta as $metaproperty => $metavalue) {
+ self::$meta->set($metaproperty,$metavalue);
+ }
}
+ // webmanifest
+ head_add_link(['rel' => 'manifest', 'href' => '/manifest.json']);
+ self::$meta->set('application-name', Zotlabs\Lib\System::get_platform_name());
+
self::$meta->set('generator', Zotlabs\Lib\System::get_platform_name());
head_add_link(['rel' => 'shortcut icon', 'href' => head_get_icon()]);
@@ -1213,10 +1235,11 @@ class App {
'$linkrel' => head_get_links(),
'$js_strings' => js_strings(),
'$zid' => get_my_address(),
- '$channel_id' => self::$profile['uid'],
- '$auto_save_draft' => ((feature_enabled(self::$profile['uid'], 'auto_save_draft')) ? "true" : "false")
+ '$channel_id' => self::$profile['uid'] ?? 0,
+ '$auto_save_draft' => ((isset(self::$profile['uid']) && feature_enabled(self::$profile['uid'], 'auto_save_draft')) ? "true" : "false"),
+ '$module' => App::$module
]
- ) . self::$page['htmlhead'];
+ ) . ((isset(self::$page['htmlhead'])) ? self::$page['htmlhead'] : '');
// always put main.js at the end
self::$page['htmlhead'] .= head_get_main_js();
@@ -1418,9 +1441,12 @@ function os_mkdir($path, $mode = 0777, $recursive = false) {
*/
function rrmdir($path) {
if(is_dir($path) === true) {
- $files = array_diff(scandir($path), array('.', '..'));
- foreach($files as $file) {
- rrmdir(realpath($path) . '/' . $file);
+ $dir_entries = scandir($path);
+ if (is_array($dir_entries)) {
+ $files = array_diff($dir_entries, array('.', '..'));
+ foreach($files as $file) {
+ rrmdir(realpath($path) . '/' . $file);
+ }
}
return rmdir($path);
}
@@ -1564,7 +1590,7 @@ function fix_system_urls($oldurl, $newurl) {
dbesc($channel_address . '@' . $rhs),
dbesc($newurl),
dbesc(str_replace($oldurl,$newurl,$rv['hubloc_id_url'])),
- dbesc(($rv['hubloc_network'] === 'zot6') ? \Zotlabs\Lib\Libzot::sign($newurl,$c[0]['channel_prvkey']) : base64url_encode(rsa_sign($newurl,$c[0]['channel_prvkey']))),
+ dbesc(($rv['hubloc_network'] === 'zot6') ? \Zotlabs\Lib\Libzot::sign($newurl,$c[0]['channel_prvkey']) : base64url_encode(Crypto::sign($newurl,$c[0]['channel_prvkey']))),
dbesc($newhost),
dbesc(($rv['hubloc_network'] === 'zot6') ? $newurl . '/zot' : $newurl . '/post'),
dbesc($rv['xchan_hash']),
@@ -1692,21 +1718,24 @@ function login($register = false, $form_id = 'main-login', $hiddens = false, $lo
$_SESSION['login_return_url'] = App::$query_string;
}
- $o .= replace_macros($tpl,array(
+ $email_required = get_config('system', 'verify_email');
+ $lname_label = (($email_required) ? t('Email or nickname') : t('Nickname'));
+
+ $o .= replace_macros($tpl, [
'$dest_url' => $dest_url,
'$login_page' => $login_page,
'$logout' => t('Logout'),
'$login' => t('Login'),
'$remote_login' => t('Remote Authentication'),
'$form_id' => $form_id,
- '$lname' => array('username', t('Login/Email') , '', ''),
- '$lpassword' => array('password', t('Password'), '', ''),
- '$remember_me' => array((($login_page) ? 'remember' : 'remember_me'), t('Remember me'), '', '',array(t('No'),t('Yes'))),
+ '$lname' => ['username', $lname_label],
+ '$lpassword' => ['password', t('Password')],
+ '$remember_me' => [(($login_page) ? 'remember' : 'remember_me'), t('Remember me'), '', '', [t('No'),t('Yes')]],
'$hiddens' => $hiddens,
'$register' => $reg,
'$lostpass' => t('Forgot your password?'),
- '$lostlink' => t('Password Reset'),
- ));
+ '$lostlink' => (($email_required) ? t('Password Reset') : ''),
+ ]);
/**
* @hooks login_hook
@@ -1750,7 +1779,7 @@ function shutdown() {
*/
function get_account_id() {
- if(intval($_SESSION['account_id']))
+ if(isset($_SESSION['account_id']))
return intval($_SESSION['account_id']);
if(App::$account)
@@ -2017,7 +2046,7 @@ function proc_run(){
}
$args = array_map('escapeshellarg',$args);
- $cmdline = implode($args," ");
+ $cmdline = implode(' ', $args);
if(is_windows()) {
$cwd = getcwd();
@@ -2057,12 +2086,10 @@ function is_site_admin() {
if(! session_id())
return false;
- if($_SESSION['delegate'])
+ if(isset($_SESSION['delegate']))
return false;
- if((intval($_SESSION['authenticated']))
- && (is_array(App::$account))
- && (App::$account['account_roles'] & ACCOUNT_ROLE_ADMIN))
+ if(isset($_SESSION['authenticated']) && is_array(App::$account) && (App::$account['account_roles'] & ACCOUNT_ROLE_ADMIN))
return true;
return false;
@@ -2098,7 +2125,7 @@ function load_contact_links($uid) {
// logger('load_contact_links');
- $r = q("SELECT abook_id, abook_flags, abook_my_perms, abook_their_perms, xchan_hash, xchan_photo_m, xchan_name, xchan_url, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d ",
+ $r = q("SELECT abook_id, abook_flags, abook_my_perms, abook_their_perms, xchan_hash, xchan_photo_m, xchan_name, xchan_url, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and xchan_deleted = 0",
intval($uid)
);
if($r) {
@@ -2244,6 +2271,8 @@ function load_pdl() {
$n = 'mod_' . App::$module . '.pdl' ;
$u = App::$comanche->get_channel_id();
+ $s = '';
+
if($u)
$s = get_pconfig($u, 'system', $n);
if(! $s)
@@ -2299,13 +2328,14 @@ function construct_page() {
$navbar = get_pconfig($uid,'system','navbar',$navbar);
}
- if($comanche && App::$layout['navbar']) {
+ if($comanche && isset(App::$layout['navbar'])) {
$navbar = App::$layout['navbar'];
}
if (App::$module == 'setup') {
$installing = true;
- } else {
+ }
+ else {
nav($navbar);
}
@@ -2338,7 +2368,7 @@ function construct_page() {
App::build_pagehead();
- if(App::$page['pdl_content']) {
+ if(isset(App::$page['pdl_content'])) {
App::$page['content'] = App::$comanche->region(App::$page['content']);
}
@@ -2402,14 +2432,15 @@ function construct_page() {
// security headers - see https://securityheaders.io
- if(App::get_scheme() === 'https' && App::$config['system']['transport_security_header'])
+ if(App::get_scheme() === 'https' && isset(App::$config['system']['transport_security_header']) && intval(App::$config['system']['transport_security_header']) == 1)
header("Strict-Transport-Security: max-age=31536000");
- if(App::$config['system']['content_security_policy']) {
- $cspsettings = Array (
- 'script-src' => Array ("'self'","'unsafe-inline'","'unsafe-eval'"),
- 'style-src' => Array ("'self'","'unsafe-inline'")
- );
+ if(isset(App::$config['system']['content_security_policy']) && intval(App::$config['system']['content_security_policy']) == 1) {
+ $cspsettings = [
+ 'script-src' => [ "'self'", "'unsafe-inline'", "'unsafe-eval'" ],
+ 'style-src' => [ "'self'", "'unsafe-inline'" ],
+ 'frame-src' => [ "'self'" ]
+ ];
call_hooks('content_security_policy',$cspsettings);
// Legitimate CSP directives (cxref: https://content-security-policy.com/)
@@ -2435,13 +2466,21 @@ function construct_page() {
header($cspheader);
}
- if(App::$config['system']['x_security_headers']) {
+ if(isset(App::$config['system']['x_security_headers'])) {
header("X-Frame-Options: SAMEORIGIN");
header("X-Xss-Protection: 1; mode=block;");
header("X-Content-Type-Options: nosniff");
}
- if(App::$config['system']['public_key_pins']) {
+ if (isset(App::$config['system']['perm_policy_header']) && App::$config['system']['perm_policy_header']) {
+ header("Permissions-Policy: " . App::$config['system']['perm_policy_header']);
+ }
+ else {
+ // opt-out this site from federated browser surveillance
+ header("Permissions-Policy: interest-cohort=()");
+ }
+
+ if(isset(App::$config['system']['public_key_pins'])) {
header("Public-Key-Pins: " . App::$config['system']['public_key_pins']);
}