Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

+92
View File
@@ -0,0 +1,92 @@
//<?php
class cms_hook_Output extends _HOOK_CLASS_
{
/**
* Display Error Screen
*
* @param string $message language key for error message
* @param mixed $code Error code
* @param int $httpStatusCode HTTP Status Code
* @param string $adminMessage language key for error message to show to admins
* @param array $httpHeaders Additional HTTP Headers
* @param string $extra Additional information (such as API error)
* @return void
*/
public function error( $message, $code, $httpStatusCode=500, $adminMessage=NULL, $httpHeaders=array(), $extra=NULL )
{
if ( ! isset( \IPS\Settings::i()->cms_error_page ) or ! \IPS\Settings::i()->cms_error_page )
{
parent::error( $message, $code, $httpStatusCode, $adminMessage, $httpHeaders, $extra );
}
/* If we just logged out, we don't want to show a "no permission" error */
if ( isset( \IPS\Request::i()->_fromLogout ) )
{
$this->redirect( \IPS\Settings::i()->base_url );
}
/* If we're in an external script, just show a simple message */
if ( !\IPS\Dispatcher::hasInstance() )
{
\IPS\Session\Front::i();
$this->sendOutput( \IPS\Member::loggedIn()->language()->get( $message ), $httpStatusCode, 'text/html', $httpHeaders, FALSE );
return;
}
if ( \IPS\Dispatcher::i()->controllerLocation !== 'front' )
{
parent::error( $message, $code, $httpStatusCode, $adminMessage, $httpHeaders, $extra );
}
/* Work out the title */
$title = "{$httpStatusCode}_error_title";
$title = \IPS\Member::loggedIn()->language()->checkKeyExists( $title ) ? \IPS\Member::loggedIn()->language()->addToStack( $title ) : \IPS\Member::loggedIn()->language()->addToStack( 'error_title' );
/* Which message are we showing? */
if( \IPS\Member::loggedIn()->isAdmin() and $adminMessage )
{
$message = $adminMessage;
}
if ( \IPS\Member::loggedIn()->language()->checkKeyExists( $message ) )
{
$message = \IPS\Member::loggedIn()->language()->addToStack( $message );
}
/* Replace language stack keys with actual content */
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $message );
/* Log */
$level = intval( \substr( $code, 0, 1 ) );
if( !\IPS\Session::i()->userAgent->spider )
{
if( $code and \IPS\Settings::i()->error_log_level and $level >= \IPS\Settings::i()->error_log_level )
{
\IPS\Db::i()->insert( 'core_error_logs', array(
'log_member' => \IPS\Member::loggedIn()->member_id ?: 0,
'log_date' => time(),
'log_error' => $message,
'log_error_code' => $code,
'log_ip_address' => \IPS\Request::i()->ipAddress(),
'log_request_uri' => $_SERVER['REQUEST_URI'],
) );
}
if( \IPS\Settings::i()->error_notify_level and $level >= \IPS\Settings::i()->error_notify_level )
{
\IPS\Email::buildFromTemplate( 'core', 'error_log', array( $code, $message ) )->send( \IPS\Settings::i()->email_in );
}
}
/* If this is an AJAX request, send a JSON response */
if( \IPS\Request::i()->isAjax() )
{
$this->json( $message, $httpStatusCode );
}
/* Send output */
\IPS\cms\Pages\Page::errorPage( $title, $message, $code, $httpStatusCode, $httpHeaders );
}
}
+1 -1
View File
@@ -32,7 +32,7 @@ class cms_hook_Url extends _HOOK_CLASS_
{
if ( isset( $this->data['path'] ) and mb_strpos( $this->data['path'], 'index.php?' ) )
{
$query = ( isset( $this->data['query'] ) ? $this->data['query'] : '' );
$query = ( isset( $this->data['query'] ) ? ltrim( $this->data['query'], '/' ) : '' );
}
else
{
+39
View File
@@ -0,0 +1,39 @@
//<?php
class cms_hook_websiteUrl extends _HOOK_CLASS_
{
/* !Hook Data - DO NOT REMOVE */
public static function hookData() {
return array_merge_recursive( array (
'globalTemplate' =>
array (
0 =>
array (
'selector' => 'html > body > meta[itemprop=\'url\']',
'type' => 'replace',
'content' => '{{if \IPS\Settings::i()->cms_use_different_gateway AND \IPS\Settings::i()->cms_root_page_url}}
<meta itemprop="url" content="{setting="cms_root_page_url"}">
{{else}}
<meta itemprop="url" content="{setting="base_url"}">
{{endif}}',
),
),
), parent::hookData() );
}
/* End Hook Data */
}