mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
php8 warnings
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Zotlabs\Web;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Extend\Route;
|
||||
use Exception;
|
||||
|
||||
@@ -43,7 +44,7 @@ class Router {
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
$module = \App::$module;
|
||||
$module = App::$module;
|
||||
$modname = "Zotlabs\\Module\\" . ucfirst($module);
|
||||
|
||||
if(strlen($module)) {
|
||||
@@ -60,7 +61,7 @@ class Router {
|
||||
include_once($route[0]);
|
||||
if(class_exists($modname)) {
|
||||
$this->controller = new $modname;
|
||||
\App::$module_loaded = true;
|
||||
App::$module_loaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,15 +69,15 @@ class Router {
|
||||
|
||||
// legacy plugins - this can be removed when they have all been converted
|
||||
|
||||
if(! (\App::$module_loaded)) {
|
||||
if(is_array(\App::$plugins) && in_array($module,\App::$plugins) && file_exists("addon/{$module}/{$module}.php")) {
|
||||
if(! (App::$module_loaded)) {
|
||||
if(is_array(App::$plugins) && in_array($module, App::$plugins) && file_exists("addon/{$module}/{$module}.php")) {
|
||||
include_once("addon/{$module}/{$module}.php");
|
||||
if(class_exists($modname)) {
|
||||
$this->controller = new $modname;
|
||||
\App::$module_loaded = true;
|
||||
App::$module_loaded = true;
|
||||
}
|
||||
elseif(function_exists($module . '_module')) {
|
||||
\App::$module_loaded = true;
|
||||
App::$module_loaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,40 +87,40 @@ class Router {
|
||||
* Otherwise, look for the standard program module
|
||||
*/
|
||||
|
||||
if(! (\App::$module_loaded)) {
|
||||
if(! (App::$module_loaded)) {
|
||||
try {
|
||||
$filename = 'Zotlabs/SiteModule/'. ucfirst($module). '.php';
|
||||
if(file_exists($filename)) {
|
||||
// This won't be picked up by the autoloader, so load it explicitly
|
||||
require_once($filename);
|
||||
$this->controller = new $modname;
|
||||
\App::$module_loaded = true;
|
||||
App::$module_loaded = true;
|
||||
}
|
||||
else {
|
||||
$filename = 'Zotlabs/Module/'. ucfirst($module). '.php';
|
||||
if(file_exists($filename)) {
|
||||
$this->controller = new $modname;
|
||||
\App::$module_loaded = true;
|
||||
App::$module_loaded = true;
|
||||
}
|
||||
}
|
||||
if(! \App::$module_loaded)
|
||||
throw new \Exception('Module not found');
|
||||
if(! App::$module_loaded)
|
||||
throw new Exception('Module not found');
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
catch(Exception $e) {
|
||||
if(file_exists("mod/site/{$module}.php")) {
|
||||
include_once("mod/site/{$module}.php");
|
||||
\App::$module_loaded = true;
|
||||
App::$module_loaded = true;
|
||||
}
|
||||
elseif(file_exists("mod/{$module}.php")) {
|
||||
include_once("mod/{$module}.php");
|
||||
\App::$module_loaded = true;
|
||||
App::$module_loaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$x = [
|
||||
'module' => $module,
|
||||
'installed' => \App::$module_loaded,
|
||||
'installed' => App::$module_loaded,
|
||||
'controller' => $this->controller
|
||||
];
|
||||
/**
|
||||
@@ -136,7 +137,7 @@ class Router {
|
||||
*/
|
||||
call_hooks('module_loaded', $x);
|
||||
if($x['installed']) {
|
||||
\App::$module_loaded = true;
|
||||
App::$module_loaded = true;
|
||||
$this->controller = $x['controller'];
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ class Router {
|
||||
* The URL provided does not resolve to a valid module.
|
||||
*/
|
||||
|
||||
if(! (\App::$module_loaded)) {
|
||||
if(! (App::$module_loaded)) {
|
||||
|
||||
// undo the setting of a letsencrypt acme-challenge rewrite rule
|
||||
// which blocks access to our .well-known routes.
|
||||
@@ -160,7 +161,7 @@ class Router {
|
||||
|
||||
$x = [
|
||||
'module' => $module,
|
||||
'installed' => \App::$module_loaded,
|
||||
'installed' => App::$module_loaded,
|
||||
'controller' => $this->controller
|
||||
];
|
||||
call_hooks('page_not_found',$x);
|
||||
@@ -181,14 +182,14 @@ class Router {
|
||||
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
|
||||
$tpl = get_markup_template('404.tpl');
|
||||
\App::$page['content'] = replace_macros($tpl, array(
|
||||
App::$page['content'] = replace_macros($tpl, array(
|
||||
'$message' => t('Page not found.')
|
||||
));
|
||||
|
||||
// pretend this is a module so it will initialise the theme
|
||||
\App::$module = '404';
|
||||
\App::$module_loaded = true;
|
||||
\App::$error = true;
|
||||
App::$module = '404';
|
||||
App::$module_loaded = true;
|
||||
App::$error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,9 +204,9 @@ class Router {
|
||||
* Call module functions
|
||||
*/
|
||||
|
||||
if(\App::$module_loaded) {
|
||||
if(App::$module_loaded) {
|
||||
|
||||
\App::$page['page_title'] = \App::$module;
|
||||
App::$page['page_title'] = App::$module;
|
||||
$placeholder = '';
|
||||
|
||||
/*
|
||||
@@ -216,13 +217,13 @@ class Router {
|
||||
*/
|
||||
|
||||
$arr = array('init' => true, 'replace' => false);
|
||||
call_hooks(\App::$module . '_mod_init', $arr);
|
||||
call_hooks(App::$module . '_mod_init', $arr);
|
||||
if(! $arr['replace']) {
|
||||
if($this->controller && method_exists($this->controller,'init')) {
|
||||
$this->controller->init();
|
||||
}
|
||||
elseif(function_exists(\App::$module . '_init')) {
|
||||
$func = \App::$module . '_init';
|
||||
elseif(function_exists(App::$module . '_init')) {
|
||||
$func = App::$module . '_init';
|
||||
$func($a);
|
||||
}
|
||||
}
|
||||
@@ -258,41 +259,41 @@ class Router {
|
||||
$func = str_replace('-', '_', $current_theme[0]) . '_init';
|
||||
$func($a);
|
||||
}
|
||||
elseif (x(\App::$theme_info, 'extends') && file_exists('view/theme/' . \App::$theme_info['extends'] . '/php/theme.php')) {
|
||||
require_once('view/theme/' . \App::$theme_info['extends'] . '/php/theme.php');
|
||||
if(function_exists(str_replace('-', '_', \App::$theme_info['extends']) . '_init')) {
|
||||
$func = str_replace('-', '_', \App::$theme_info['extends']) . '_init';
|
||||
elseif (x(App::$theme_info, 'extends') && file_exists('view/theme/' . App::$theme_info['extends'] . '/php/theme.php')) {
|
||||
require_once('view/theme/' . App::$theme_info['extends'] . '/php/theme.php');
|
||||
if(function_exists(str_replace('-', '_', App::$theme_info['extends']) . '_init')) {
|
||||
$func = str_replace('-', '_', App::$theme_info['extends']) . '_init';
|
||||
$func($a);
|
||||
}
|
||||
}
|
||||
|
||||
if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! \App::$error) && (! x($_POST, 'auth-params'))) {
|
||||
call_hooks(\App::$module . '_mod_post', $_POST);
|
||||
if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! App::$error) && (! x($_POST, 'auth-params'))) {
|
||||
call_hooks(App::$module . '_mod_post', $_POST);
|
||||
|
||||
if($this->controller && method_exists($this->controller,'post')) {
|
||||
$this->controller->post();
|
||||
}
|
||||
elseif(function_exists(\App::$module . '_post')) {
|
||||
$func = \App::$module . '_post';
|
||||
elseif(function_exists(App::$module . '_post')) {
|
||||
$func = App::$module . '_post';
|
||||
$func($a);
|
||||
}
|
||||
}
|
||||
|
||||
if(! \App::$error) {
|
||||
$arr = array('content' => \App::$page['content'], 'replace' => false);
|
||||
call_hooks(\App::$module . '_mod_content', $arr);
|
||||
if(! App::$error) {
|
||||
$arr = array('content' => App::$page['content'], 'replace' => false);
|
||||
call_hooks(App::$module . '_mod_content', $arr);
|
||||
|
||||
if(! $arr['replace']) {
|
||||
if($this->controller && method_exists($this->controller,'get')) {
|
||||
$arr = array('content' => $this->controller->get());
|
||||
}
|
||||
elseif(function_exists(\App::$module . '_content')) {
|
||||
$func = \App::$module . '_content';
|
||||
elseif(function_exists(App::$module . '_content')) {
|
||||
$func = App::$module . '_content';
|
||||
$arr = array('content' => $func($a));
|
||||
}
|
||||
}
|
||||
call_hooks(\App::$module . '_mod_aftercontent', $arr);
|
||||
\App::$page['content'] = (($arr['replace']) ? $arr['content'] : \App::$page['content'] . $arr['content']);
|
||||
call_hooks(App::$module . '_mod_aftercontent', $arr);
|
||||
App::$page['content'] = ((isset($arr['replace'])) ? $arr['content'] : App::$page['content'] . $arr['content']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ class WebServer {
|
||||
// now that we've been through the module content, see if the page reported
|
||||
// a permission problem and if so, a 403 response would seem to be in order.
|
||||
|
||||
if(is_array($_SESSION['sysmsg']) && stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
|
||||
if(isset($_SESSION['sysmsg']) && is_array($_SESSION['sysmsg']) && stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.'));
|
||||
}
|
||||
|
||||
@@ -137,9 +137,9 @@ class WebServer {
|
||||
|
||||
private function create_channel_links() {
|
||||
|
||||
/* Initialise the Link: response header if this is a channel page.
|
||||
/* Initialise the Link: response header if this is a channel page.
|
||||
* This cannot be done inside the channel module because some protocol
|
||||
* addons over-ride the module functions and these links are common
|
||||
* addons over-ride the module functions and these links are common
|
||||
* to all protocol drivers; thus doing it here avoids duplication.
|
||||
*/
|
||||
|
||||
@@ -156,7 +156,7 @@ class WebServer {
|
||||
'url' => z_root() . '/.well-known/webfinger?f=&resource=acct%3A' . argv(1) . '%40' . \App::get_hostname()
|
||||
],
|
||||
];
|
||||
$x = [ 'channel_address' => argv(1), 'channel_links' => \App::$channel_links ];
|
||||
$x = [ 'channel_address' => argv(1), 'channel_links' => \App::$channel_links ];
|
||||
call_hooks('channel_links', $x );
|
||||
\App::$channel_links = $x['channel_links'];
|
||||
header('Link: ' . \App::get_channel_links());
|
||||
|
||||
4
boot.php
4
boot.php
@@ -1758,7 +1758,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)
|
||||
@@ -2252,6 +2252,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)
|
||||
|
||||
@@ -17,6 +17,9 @@ function nav($template = 'default') {
|
||||
if(!(x(App::$page,'nav')))
|
||||
App::$page['nav'] = '';
|
||||
|
||||
if(! isset(App::$page['htmlhead']))
|
||||
App::$page['htmlhead'] = '';
|
||||
|
||||
App::$page['htmlhead'] .= '<script>$(document).ready(function() { $("#nav-search-text").search_autocomplete(\'' . z_root() . '/acl' . '\');});</script>';
|
||||
|
||||
$is_owner = (((local_channel()) && ((App::$profile_uid == local_channel()) || (App::$profile_uid == 0))) ? true : false);
|
||||
@@ -45,8 +48,9 @@ function nav($template = 'default') {
|
||||
$nav_apps = [];
|
||||
$navbar_apps = [];
|
||||
$channel_apps = [];
|
||||
|
||||
$channel_apps[] = channel_apps($is_owner, App::$profile['channel_address']);
|
||||
|
||||
if(isset(App::$profile['channel_address']))
|
||||
$channel_apps[] = channel_apps($is_owner, App::$profile['channel_address']);
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,9 +61,9 @@ function nav($template = 'default') {
|
||||
|
||||
$banner = get_config('system','banner');
|
||||
|
||||
if($banner === false)
|
||||
if($banner === false)
|
||||
$banner = get_config('system','sitename');
|
||||
|
||||
|
||||
call_hooks('get_banner',$banner);
|
||||
|
||||
App::$page['header'] .= replace_macros(get_markup_template('hdr.tpl'), array(
|
||||
@@ -74,7 +78,7 @@ function nav($template = 'default') {
|
||||
|
||||
/**
|
||||
* Display login or logout
|
||||
*/
|
||||
*/
|
||||
|
||||
$nav['usermenu'] = [];
|
||||
$userinfo = null;
|
||||
@@ -102,19 +106,19 @@ function nav($template = 'default') {
|
||||
|
||||
$nav['settings'] = array('settings', t('Settings'),"", t('Account/Channel Settings'),'settings_nav_btn');
|
||||
|
||||
|
||||
|
||||
if($chans && count($chans) > 1 && feature_enabled(local_channel(),'nav_channel_select'))
|
||||
$nav['channels'] = $chans;
|
||||
|
||||
$nav['logout'] = ['logout',t('Logout'), "", t('End this session'),'logout_nav_btn'];
|
||||
|
||||
|
||||
// user menu
|
||||
$nav['usermenu'][] = ['profile/' . $channel['channel_address'], t('View Profile'), ((\App::$nav_sel['raw_name'] == 'Profile') ? 'active' : ''), t('Your profile page'),'profile_nav_btn'];
|
||||
$nav['usermenu'][] = ['profile/' . $channel['channel_address'], t('View Profile'), ((App::$nav_sel['raw_name'] == 'Profile') ? 'active' : ''), t('Your profile page'),'profile_nav_btn'];
|
||||
|
||||
if(feature_enabled(local_channel(),'multi_profiles'))
|
||||
$nav['usermenu'][] = ['profiles', t('Edit Profiles'), ((\App::$nav_sel['raw_name'] == 'Profiles') ? 'active' : '') , t('Manage/Edit profiles'),'profiles_nav_btn'];
|
||||
$nav['usermenu'][] = ['profiles', t('Edit Profiles'), ((App::$nav_sel['raw_name'] == 'Profiles') ? 'active' : '') , t('Manage/Edit profiles'),'profiles_nav_btn'];
|
||||
else
|
||||
$nav['usermenu'][] = ['profiles/' . $prof[0]['id'], t('Edit Profile'), ((\App::$nav_sel['raw_name'] == 'Profiles') ? 'active' : ''), t('Edit your profile'),'profiles_nav_btn'];
|
||||
$nav['usermenu'][] = ['profiles/' . $prof[0]['id'], t('Edit Profile'), ((App::$nav_sel['raw_name'] == 'Profiles') ? 'active' : ''), t('Edit your profile'),'profiles_nav_btn'];
|
||||
|
||||
}
|
||||
else {
|
||||
@@ -127,7 +131,7 @@ function nav($template = 'default') {
|
||||
$nav['login'] = login(true,'main-login',false,false);
|
||||
$nav['loginmenu'][] = ['login',t('Login'),'',t('Sign in'),'login_nav_btn'];
|
||||
App::$page['content'] .= replace_macros(get_markup_template('nav_login.tpl'),
|
||||
[
|
||||
[
|
||||
'$nav' => $nav,
|
||||
'userinfo' => $userinfo
|
||||
]
|
||||
@@ -198,8 +202,8 @@ function nav($template = 'default') {
|
||||
|
||||
call_hooks('nav', $x);
|
||||
|
||||
// Not sure the best place to put this on the page. So I'm implementing it but leaving it
|
||||
// turned off until somebody discovers this and figures out a good location for it.
|
||||
// Not sure the best place to put this on the page. So I'm implementing it but leaving it
|
||||
// turned off until somebody discovers this and figures out a good location for it.
|
||||
$powered_by = '';
|
||||
|
||||
$url = '';
|
||||
@@ -342,7 +346,7 @@ function nav($template = 'default') {
|
||||
));
|
||||
|
||||
if(x($_SESSION, 'reload_avatar') && $observer) {
|
||||
// The avatar has been changed on the server but the browser doesn't know that,
|
||||
// The avatar has been changed on the server but the browser doesn't know that,
|
||||
// force the browser to reload the image from the server instead of its cache.
|
||||
$tpl = get_markup_template('force_image_reload.tpl');
|
||||
|
||||
@@ -358,7 +362,7 @@ function nav($template = 'default') {
|
||||
|
||||
/*
|
||||
* Set a menu item in navbar as selected
|
||||
*
|
||||
*
|
||||
*/
|
||||
function nav_set_selected($raw_name, $settings_url = ''){
|
||||
App::$nav_sel['raw_name'] = $raw_name;
|
||||
@@ -384,7 +388,7 @@ function channel_apps($is_owner = false, $nickname = null) {
|
||||
if($channel && is_null($nickname))
|
||||
$nickname = $channel['channel_address'];
|
||||
|
||||
$uid = ((App::$profile['profile_uid']) ? App::$profile['profile_uid'] : local_channel());
|
||||
$uid = ((isset(App::$profile['profile_uid'])) ? App::$profile['profile_uid'] : local_channel());
|
||||
|
||||
if(! get_pconfig($uid, 'system', 'channelapps','1'))
|
||||
return;
|
||||
@@ -529,7 +533,7 @@ function channel_apps($is_owner = false, $nickname = null) {
|
||||
'icon' => 'newspaper-o'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($p['view_wiki'] && Apps::system_app_installed($uid, 'Wiki')) {
|
||||
$tabs[] = [
|
||||
@@ -544,9 +548,9 @@ function channel_apps($is_owner = false, $nickname = null) {
|
||||
|
||||
$arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs);
|
||||
|
||||
call_hooks('channel_apps', $arr);
|
||||
call_hooks('channel_apps', $arr);
|
||||
|
||||
return replace_macros(get_markup_template('profile_tabs.tpl'),
|
||||
return replace_macros(get_markup_template('profile_tabs.tpl'),
|
||||
[
|
||||
'$tabs' => $arr['tabs'],
|
||||
'$name' => App::$profile['channel_name'],
|
||||
|
||||
@@ -912,7 +912,7 @@ function script_path() {
|
||||
|
||||
// Some proxy setups may require using http_host
|
||||
|
||||
if(isset(App::$config['system']['script_path_use_http_host']) && intval(App::$config['system']['script_path_use_http_host']))
|
||||
if(intval(App::$config['system']['script_path_use_http_host']))
|
||||
$server_var = 'HTTP_HOST';
|
||||
else
|
||||
$server_var = 'SERVER_NAME';
|
||||
@@ -929,8 +929,9 @@ function script_path() {
|
||||
}
|
||||
|
||||
function head_add_js($src, $priority = 0) {
|
||||
if(! is_array(App::$js_sources[$priority]))
|
||||
App::$js_sources[$priority] = array();
|
||||
if(isset(App::$js_sources[$priority]) && !is_array(App::$js_sources[$priority]))
|
||||
App::$js_sources[$priority] = [];
|
||||
|
||||
App::$js_sources[$priority][] = $src;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ function authenticate_success($user_record, $channel = null, $login_initial = fa
|
||||
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$lastlog_updated = false;
|
||||
$uid_to_load = null;
|
||||
|
||||
if (x($user_record, 'account_id')) {
|
||||
App::$account = $user_record;
|
||||
|
||||
Reference in New Issue
Block a user