Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\support;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _errorLogs extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -32,16 +37,16 @@ class _errorLogs extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'system_logs_view' );
parent::execute();
}
/**
* Manage Error Logs
* Get table
*
* @return void
* @param \IPS\Http\Url $url The URL where the table will be displayed
* @return \IPS\Helpers\Table\Db
*/
protected function manage()
public static function table( \IPS\Http\Url $url )
{
/* Create the table */
$table = new \IPS\Helpers\Table\Db( 'core_error_logs', \IPS\Http\Url::internal( 'app=core&module=support&controller=errorLogs' ) );
$table = new \IPS\Helpers\Table\Db( 'core_error_logs', $url );
$table->langPrefix = 'errorlogs_';
$table->include = array( 'log_error_code', 'log_error', 'log_ip_address', 'log_request_uri', 'log_member', 'log_date' );
$table->mainColumn = 'log_error_code';
@@ -85,7 +90,6 @@ class _errorLogs extends \IPS\Dispatcher\Controller
$table->sortBy = $table->sortBy ?: 'log_date';
$table->sortDirection = $table->sortDirection ?: 'desc';
/* Search */
$table->advancedSearch = array(
'log_member' => \IPS\Helpers\Table\SEARCH_MEMBER,
'log_ip_address' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
@@ -96,7 +100,16 @@ class _errorLogs extends \IPS\Dispatcher\Controller
);
$table->quickSearch = 'log_error';
/* Add a button for settings */
return $table;
}
/**
* Manage Error Logs
*
* @return void
*/
protected function manage()
{
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'support', 'diagnostic_log_settings' ) )
{
\IPS\Output::i()->sidebar['actions'] = array(
@@ -109,9 +122,8 @@ class _errorLogs extends \IPS\Dispatcher\Controller
);
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('errorlogs');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'errorlogs', (string) $table );
\IPS\Output::i()->output = (string) static::table( \IPS\Http\Url::internal( 'app=core&module=support&controller=errorLogs' ) );
}
/**
@@ -134,12 +146,9 @@ class _errorLogs extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Radio( 'error_log_level', \IPS\Settings::i()->error_log_level, FALSE, array( 'options' => $levelOptions ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'error_notify_level', \IPS\Settings::i()->error_notify_level, FALSE, array( 'min' => 1, 'max' => 5, 'unlimited' => 0, 'unlimitedLang' => 'none' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('error_log_level_prefix'), \IPS\Member::loggedIn()->language()->addToStack('error_log_level_suffix') ) );
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'staff', 'error_prune' ) )
{
$form->add( new \IPS\Helpers\Form\Number( 'prune_log_error', \IPS\Settings::i()->prune_log_error, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_log_error' ) );
$form->add( new \IPS\Helpers\Form\Interval( 'prune_log_error', \IPS\Settings::i()->prune_log_error, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_log_error' ) );
}
if ( $values = $form->values() )
@@ -12,7 +12,7 @@
namespace IPS\core\modules\admin\support;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _hookedFiles extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -12,7 +12,7 @@
namespace IPS\core\modules\admin\support;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _recovery extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Recover
*
@@ -41,11 +46,13 @@ class _recovery extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'no_writes', '1C342/2', 403, '' );
}
\IPS\Session::i()->csrfCheck();
/* We are, let's set up a multi-redirect to disable things. At the end of the process, we'll list everything we did. */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'recovery_mode' );
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( 'app=core&module=support&controller=recovery' ), function( $step )
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( 'app=core&module=support&controller=recovery' )->csrf(), function( $step )
{
$step = intval( $step );
$step = \intval( $step );
switch( $step )
{
@@ -55,7 +62,7 @@ class _recovery extends \IPS\Dispatcher\Controller
/* Disable All non-IPS Applications */
foreach( \IPS\Application::applications() AS $app )
{
if ( !in_array( $app->directory, \IPS\Application::$ipsApps ) )
if ( !\in_array( $app->directory, \IPS\IPS::$ipsApps ) )
{
$app->_enabled = FALSE;
$appDisabled[] = $app->_id;
@@ -99,7 +106,6 @@ class _recovery extends \IPS\Dispatcher\Controller
/* Set this account to use that theme */
\IPS\Member::loggedIn()->skin = $theme->id;
\IPS\Member::loggedIn()->acp_skin = $theme->id;
\IPS\Member::loggedIn()->save();
$themeReset = TRUE;
@@ -0,0 +1,134 @@
<?php
/**
* @brief Redis Info
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 19 Oct 2018
*/
namespace IPS\core\modules\admin\support;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Redis info
*/
class _redis extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
* @return void
*/
public function execute()
{
/* Not accessible for CIC */
if( \IPS\CIC )
{
\IPS\Output::i()->error( 'no_module_permission', '2C394/3', 403, '' );
}
\IPS\Dispatcher::i()->checkAcpPermission( 'redis_data' );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=support&controller=support' ), \IPS\Member::loggedIn()->language()->addToStack('support') );
parent::execute();
}
/**
* Info screen
*
* @return void
*/
protected function manage()
{
$redis = NULL;
$info = NULL;
$datasource = array();
if ( \IPS\CACHE_METHOD == 'Redis' or \IPS\STORE_METHOD == 'Redis' )
{
$info = \IPS\Redis::i()->info();
$data = array( 'type' => 'redis_datastore', 'count' => NULL, 'enabled' => false );
if ( \IPS\STORE_METHOD == 'Redis' )
{
$data['enabled'] = true;
/* Lets ensure we have in the cache */
$data['count'] = \count( \IPS\Redis::i()->debugGetKeys( \IPS\Redis::i()->get( 'redisKey_store' ) . '_str_*', TRUE ) );
}
$datasource[] = $data;
$data = array( 'type' => 'redis_cache', 'count' => NULL, 'enabled' => false );
if ( \IPS\CACHE_METHOD == 'Redis' )
{
$data['enabled'] = true;
/* Lets ensure we have something */
$data['count'] = \count( \IPS\Redis::i()->debugGetKeys( \IPS\Redis::i()->get( 'redisKey' ) . '_*', TRUE ) );
}
$datasource[] = $data;
/* And now sessions */
if ( \IPS\CACHE_METHOD == 'Redis' and \IPS\REDIS_ENABLED )
{
$datasource[] = array( 'type' => 'redis_sessions', 'count' => \count( \IPS\Redis::i()->debugGetKeys( 'session_id_*', TRUE ) ), 'enabled' => true );
$datasource[] = array( 'type' => 'redis_topic_views', 'count' => \IPS\Redis::i()->zSize('topic_views'), 'enabled' => true );
}
else
{
$datasource[] = array( 'type' => 'redis_sessions' , 'count' => NULL, 'enabled' => false );
$datasource[] = array( 'type' => 'redis_topic_views', 'count' => NULL, 'enabled' => false );
}
}
/* Not using redis then are we? */
if ( $info === NULL )
{
\IPS\Output::i()->error( 'redis_not_enabled', '2C394/2', 403, '' );
}
$table = new \IPS\Helpers\Table\Custom( $datasource, \IPS\Http\Url::internal( 'app=core&module=support&controller=redis' ) );
$table->langPrefix = 'redis_table_';
/* Custom parsers */
$table->parsers = array(
'type' => function( $val, $row )
{
return \IPS\Member::loggedIn()->language()->addToStack( $val );
},
'count' => function( $val, $row )
{
return \intval( $val );
},
'enabled' => function( $val, $row )
{
return \IPS\Theme::i()->getTemplate( 'support' )->redisEnabledBadge( $val );
}
);
\IPS\Output::i()->sidebar['actions']['settings'] = array(
'icon' => 'cog',
'link' => \IPS\Http\Url::internal( '&app=core&module=settings&controller=advanced&tab=datastore' ),
'title' => 'redis_settings',
);
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('redis_info');
\IPS\Output::i()->output = \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->redis( $info, $table );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\support;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -21,7 +21,15 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
* sql
*/
class _sql extends \IPS\Dispatcher\Controller
{
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* @brief Maximum number of results to select
*/
const SELECT_LIMIT = 100;
/**
@@ -74,7 +82,7 @@ class _sql extends \IPS\Dispatcher\Controller
'view' => array(
'icon' => 'search',
'title' => 'view',
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=sql&do=query' )->setQueryString( 'q', "SELECT * FROM {$row['name']}" )
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=sql&do=query' )->setQueryString( 'q', "SELECT * FROM {$row['name']}" )->csrf()
),
);
};
@@ -85,7 +93,7 @@ class _sql extends \IPS\Dispatcher\Controller
$form->add( new \IPS\Helpers\Form\TextArea( 'sql_toolbox_query', NULL, TRUE, array( 'class' => 'ipsField_codeInput' ) ) );
/* Display */
\IPS\Output::i()->output .= $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'support' ) ), 'queryFormTemplate' ) ) . (string) $table;
\IPS\Output::i()->output .= $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'support' ), 'queryFormTemplate' ) ) . (string) $table;
}
/**
@@ -95,6 +103,8 @@ class _sql extends \IPS\Dispatcher\Controller
*/
protected function query()
{
\IPS\Session::i()->csrfCheck();
/* Select from table */
$query = NULL;
if ( isset( \IPS\Request::i()->q ) )
@@ -147,7 +157,7 @@ class _sql extends \IPS\Dispatcher\Controller
$pagination = NULL;
if ( $result->num_rows > static::SELECT_LIMIT and !preg_match( "/^EXPLAIN/i", $q ) and !preg_match( "/^SHOW/i", $q ) and !preg_match( "/LIMIT[ 0-9,]+$/i", $q ) )
{
$page = isset( \IPS\Request::i()->page ) ? intval( \IPS\Request::i()->page ) : 1;
$page = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
if( $page < 1 )
{
@@ -155,7 +165,7 @@ class _sql extends \IPS\Dispatcher\Controller
}
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
\IPS\Http\Url::internal( 'app=core&module=support&controller=sql&do=query' )->setQueryString( 'q', $query ),
\IPS\Http\Url::internal( 'app=core&module=support&controller=sql&do=query' )->setQueryString( 'q', $query )->csrf(),
ceil( $result->num_rows / static::SELECT_LIMIT ),
$page,
static::SELECT_LIMIT
@@ -192,6 +202,6 @@ class _sql extends \IPS\Dispatcher\Controller
}
/* Display */
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'support' )->toolboxResults( $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'support' ) ), 'queryFormTemplate' ) ), $queries, $results );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'support' )->toolboxResults( $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'support' ), 'queryFormTemplate' ) ), $queries, $results );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\support;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _support extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -39,16 +44,26 @@ class _support extends \IPS\Dispatcher\Controller
* @return void
*/
protected function manage()
{
{
$redis = NULL;
if ( \IPS\CACHE_METHOD == 'Redis' or \IPS\STORE_METHOD == 'Redis' )
{
$redis = \IPS\Redis::i()->info();
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('get_support');
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('admin_support.js', 'core', 'admin') );
\IPS\Output::i()->output = \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->support( new \IPS\Helpers\Wizard( array( 'type_of_problem' => array( $this, '_typeOfProblem' ), 'self_service' => array( $this, '_selfService' ), 'contact_support' => array( $this, '_contactSupport' ) ), \IPS\Http\Url::internal('app=core&module=support&controller=support') ), \IPS\Db::i()->select( 'COUNT(*)', 'core_hooks' )->first() );
\IPS\Output::i()->sidebar['actions']['systemcheck'] = array(
'icon' => 'search',
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=support&do=systemCheck' ),
'title' => 'requirements_checker',
);
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->support( (string) new \IPS\Helpers\Wizard( array( 'type_of_problem' => array( $this, '_typeOfProblem' ), 'self_service' => array( $this, '_selfService' ), 'contact_support' => array( $this, '_contactSupport' ) ), \IPS\Http\Url::internal('app=core&module=support&controller=support') ), \IPS\Db::i()->select( 'COUNT(*)', 'core_hooks' )->first(), $redis );
if( !\IPS\CIC )
{
\IPS\Output::i()->sidebar['actions']['systemcheck'] = array(
'icon' => 'search',
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=support&do=systemCheck' ),
'title' => 'requirements_checker',
);
}
}
/**
@@ -131,7 +146,7 @@ class _support extends \IPS\Dispatcher\Controller
}
catch ( \Exception $e ) { }
if ( count( $searchResults ) or count( $guides ) )
if ( \count( $searchResults ) or \count( $guides ) )
{
return \IPS\Theme::i()->getTemplate( 'support' )->advice( $searchResults, $guides );
}
@@ -172,21 +187,27 @@ class _support extends \IPS\Dispatcher\Controller
*/
protected function _clearCaches()
{
/* Clear JS Maps first */
\IPS\Output::clearJsFiles();
/* Reset theme maps to make sure bad data hasn't been cached by visits mid-setup */
\IPS\Theme::deleteCompiledCss();
foreach( \IPS\Theme::themes() as $id => $set )
/* Don't clear CSS/JS when we click "check again" or the page will be broken - it's unnecessary anyways */
if( !isset( \IPS\Request::i()->checkAgain ) )
{
/* Invalidate template disk cache */
$set->cache_key = md5( microtime() . mt_rand( 0, 1000 ) );
$set->save();
/* Clear JS Maps first */
\IPS\Output::clearJsFiles();
/* Reset theme maps to make sure bad data hasn't been cached by visits mid-setup */
\IPS\Theme::deleteCompiledCss();
\IPS\Theme::deleteCompiledResources();
foreach( \IPS\Theme::themes() as $id => $set )
{
/* Invalidate template disk cache */
$set->cache_key = md5( microtime() . mt_rand( 0, 1000 ) );
$set->save();
}
}
\IPS\Data\Store::i()->clearAll();
\IPS\Data\Cache::i()->clearAll();
\IPS\Output\Cache::i()->clearAll();
\IPS\Member::clearCreateMenu();
}
@@ -200,7 +221,7 @@ class _support extends \IPS\Dispatcher\Controller
{
$changesToMake = array();
foreach ( \IPS\Application::applications() as $app )
foreach ( \IPS\Application::enabledApplications() as $app )
{
$changesToMake = array_merge( $changesToMake, $app->databaseCheck() );
}
@@ -225,6 +246,8 @@ class _support extends \IPS\Dispatcher\Controller
*/
protected function databasefail()
{
\IPS\Session::i()->csrfCheck();
$changesToMake = $this->_databaseChecker();
\IPS\Output::i()->httpHeaders['X-IPS-FormNoSubmit'] = "true";
@@ -245,13 +268,20 @@ class _support extends \IPS\Dispatcher\Controller
$errors[] = $e->getMessage();
}
}
if ( count( $erroredQueries ) )
if ( \count( $erroredQueries ) )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->fixDatabase( $erroredQueries, $errors );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->fixDatabase( $erroredQueries, $errors, \IPS\Request::i()->_upgradeVersion );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=support&controller=support') );
if ( isset( \IPS\Request::i()->_upgradeVersion ) and \IPS\Request::i()->_upgradeVersion )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=system&controller=upgrade&_chosenVersion=' . \IPS\Request::i()->_upgradeVersion ) );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=support&controller=support') );
}
}
}
else
@@ -262,13 +292,20 @@ class _support extends \IPS\Dispatcher\Controller
$queries[] = $query['query'];
}
if ( count( $queries ) )
if ( \count( $queries ) )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->fixDatabase( $queries, NULL );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->fixDatabase( $queries, NULL, \IPS\Request::i()->_upgradeVersion );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=support&controller=support') );
if ( isset( \IPS\Request::i()->_upgradeVersion ) and \IPS\Request::i()->_upgradeVersion )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=system&controller=upgrade&_chosenVersion=' . \IPS\Request::i()->_upgradeVersion ) );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=support&controller=support') );
}
}
}
}
@@ -296,7 +333,7 @@ class _support extends \IPS\Dispatcher\Controller
/**
* Step 2: Self Service - Requirements Checker (Includes File Permissions)
*
* @param array $requirements Requirements to check
* @param array $check Requirements to check
* @return array Necessary changes
*/
protected function _requirementsChecker( $check )
@@ -335,7 +372,7 @@ class _support extends \IPS\Dispatcher\Controller
if( \IPS\Settings::i()->getFromConfGlobal('sql_utf8mb4') !== TRUE )
{
$return[] = \IPS\Member::loggedIn()->language()->addToStack('utf8mb4_generic_explain');
$return[] = \IPS\Member::loggedIn()->language()->addToStack(\IPS\CIC ? 'utf8mb4_generic_explain_cic' : 'utf8mb4_generic_explain' );
}
return $return;
@@ -378,28 +415,49 @@ class _support extends \IPS\Dispatcher\Controller
*/
protected function _thirdPartyCustomizations()
{
return ( count( $this->_thirdPartyApps() ) or count( $this->_thirdPartyPlugins() ) or $this->_thirdPartyTheme() or $this->_thirdPartyEditor() or count( $this->_thirdPartyAds() ) );
return [
'apps' => $this->_thirdPartyApps( TRUE ),
'plugins' => $this->_thirdPartyPlugins( TRUE ),
'theme' => $this->_thirdPartyTheme(),
'editor' => $this->_thirdPartyEditor(),
'ads' => $this->_thirdPartyAds()
];
}
/**
* Step 2: Self Service - Get third-party applications
*
* @param bool $separateMarketplace If TRUE, will separate ones installed from the marketplace and custom ones
* @return array
*/
protected function _thirdPartyApps()
protected function _thirdPartyApps( $separateMarketplace = FALSE )
{
if ( \IPS\NO_WRITES )
{
return array();
}
$apps = array();
$apps = $separateMarketplace ? [ 'marketplace' => [], 'custom' => [] ] : [];
foreach ( \IPS\Application::applications() as $app )
{
if ( $app->enabled and !in_array( $app->directory, \IPS\Application::$ipsApps ) )
if ( $app->enabled and !\in_array( $app->directory, \IPS\IPS::$ipsApps ) )
{
$apps[] = $app;
if ( $separateMarketplace )
{
if ( $app->marketplace_id )
{
$apps['marketplace'][] = $app;
}
else
{
$apps['custom'][] = $app;
}
}
else
{
$apps[] = $app;
}
}
}
@@ -409,22 +467,37 @@ class _support extends \IPS\Dispatcher\Controller
/**
* Step 2: Self Service - Get third-party plugins
*
* @param bool $separateMarketplace If TRUE, will separate ones installed from the marketplace and custom ones
* @return array
*/
protected function _thirdPartyPlugins()
protected function _thirdPartyPlugins( $separateMarketplace = FALSE )
{
if ( \IPS\NO_WRITES )
{
return array();
}
$plugins = array();
$plugins = $separateMarketplace ? [ 'marketplace' => [], 'custom' => [] ] : [];
foreach ( \IPS\Plugin::plugins() as $plugin )
{
if ( $plugin->enabled )
{
$plugins[] = $plugin;
if ( $separateMarketplace )
{
if ( $plugin->marketplace_id )
{
$plugins['marketplace'][] = $plugin;
}
else
{
$plugins['custom'][] = $plugin;
}
}
else
{
$plugins[] = $plugin;
}
}
}
@@ -468,6 +541,8 @@ class _support extends \IPS\Dispatcher\Controller
*/
protected function thirdparty()
{
\IPS\Session::i()->csrfCheck();
/* Init */
$disabledApps = array();
$disabledPlugins = array();
@@ -498,12 +573,12 @@ class _support extends \IPS\Dispatcher\Controller
$disabledPluginNames[ $plugin->id ] = $plugin->_title;
}
if( count( $this->_thirdPartyApps() ) )
if( \count( $this->_thirdPartyApps() ) )
{
\IPS\Application::postToggleEnable();
}
if( count( $this->_thirdPartyPlugins() ) )
if( \count( $this->_thirdPartyPlugins() ) )
{
\IPS\Plugin::postToggleEnable( TRUE );
}
@@ -521,13 +596,6 @@ class _support extends \IPS\Dispatcher\Controller
\IPS\Lang::saveCustom( 'core', "core_theme_set_title_" . $newTheme->id, "IPS Default" );
\IPS\Member::loggedIn()->skin = $newTheme->id;
if( \IPS\Member::loggedIn()->acp_skin !== NULL )
{
$_SESSION['old_acp_theme'] = \IPS\Member::loggedIn()->acp_skin;
\IPS\Member::loggedIn()->acp_skin = $newTheme->id;
}
\IPS\Member::loggedIn()->save();
$restoredDefaultTheme = TRUE;
@@ -569,7 +637,7 @@ class _support extends \IPS\Dispatcher\Controller
'enableApps' => implode( ',', $disabledApps ),
'enablePlugins' => implode( ',', $disabledPlugins ),
'deleteTheme' => $restoredDefaultTheme ? $newTheme->id : 0,
'restoreEditor' => intval( $restoredEditor ),
'restoreEditor' => \intval( $restoredEditor ),
'enableAds' => implode( ',', $disabledAds )
) )
);
@@ -582,6 +650,8 @@ class _support extends \IPS\Dispatcher\Controller
*/
protected function thirdpartyEnable()
{
\IPS\Session::i()->csrfCheck();
/* Theme */
if ( isset( \IPS\Request::i()->deleteTheme ) and \IPS\Request::i()->deleteTheme )
{
@@ -590,14 +660,6 @@ class _support extends \IPS\Dispatcher\Controller
\IPS\Theme::load( \IPS\Request::i()->deleteTheme )->delete();
}
catch ( \Exception $e ) {}
if( isset( $_SESSION['old_acp_theme'] ) )
{
\IPS\Member::loggedIn()->acp_skin = $_SESSION['old_acp_theme'];
\IPS\Member::loggedIn()->save();
unset( $_SESSION['old_acp_theme'] );
}
}
/* Apps */
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\support;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _systemLogs extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -128,7 +133,7 @@ class _systemLogs extends \IPS\Dispatcher\Controller
'delete' => array(
'title' => 'delete',
'icon' => 'times-circle',
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs&do=delete' )->setQueryString( 'id', $row['id'] ),
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs&do=delete' )->setQueryString( 'id', $row['id'] )->csrf(),
'data' => array( 'delete' => '' )
)
);
@@ -159,7 +164,7 @@ class _systemLogs extends \IPS\Dispatcher\Controller
/* Delete button */
\IPS\Output::i()->sidebar['actions']['delete'] = array(
'icon' => 'times-circle',
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs&do=delete' )->setQueryString( 'id', $log->id ),
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs&do=delete' )->setQueryString( 'id', $log->id )->csrf(),
'title' => 'delete',
'data' => array( 'confirm' => '' )
);
@@ -254,7 +259,7 @@ class _systemLogs extends \IPS\Dispatcher\Controller
'delete' => array(
'title' => 'delete',
'icon' => 'times-circle',
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs&do=deleteFile' )->setQueryString( 'file', $row['file'] ),
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs&do=deleteFile' )->setQueryString( 'file', $row['file'] )->csrf(),
'data' => array( 'delete' => '' )
)
);
@@ -290,7 +295,7 @@ class _systemLogs extends \IPS\Dispatcher\Controller
/* Delete button */
\IPS\Output::i()->sidebar['actions']['delete'] = array(
'icon' => 'times-circle',
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs&do=deleteFile' )->setQueryString( 'file', \IPS\Request::i()->file ),
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs&do=deleteFile' )->setQueryString( 'file', \IPS\Request::i()->file )->csrf(),
'title' => 'delete',
'data' => array( 'confirm' => '' )
);
@@ -309,6 +314,8 @@ class _systemLogs extends \IPS\Dispatcher\Controller
*/
protected function deleteFile()
{
\IPS\Session::i()->csrfCheck();
/* NO_WRITES check */
if ( \IPS\NO_WRITES )
{
@@ -343,7 +350,12 @@ class _systemLogs extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'diagnostic_log_settings' );
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Number( 'prune_log_system', \IPS\Settings::i()->prune_log_system, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_log_moderator' ) );
$form->add( new \IPS\Helpers\Form\Interval( 'prune_log_system', \IPS\Settings::i()->prune_log_system, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
if( $val > 0 AND $val < 7 )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 6 ) ) ) );
}
}, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_log_moderator' ) );
if ( $values = $form->values() )
{
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\support;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _utf8mb4 extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -57,11 +62,11 @@ class _utf8mb4 extends \IPS\Dispatcher\Controller
/* Display Wizard */
$supportController = new support;
\IPS\Output::i()->output = new \IPS\Helpers\Wizard( array(
\IPS\Output::i()->output = (string) new \IPS\Helpers\Wizard( array(
'utf8mb4_converter_intro' => array( $this, '_introduction' ),
'utf8mb4_converter_convert' => array( $this, '_convert' ),
'utf8mb4_converter_finish' => array( $this, '_finish' ),
), \IPS\Http\Url::internal( 'app=core&module=support&controller=utf8mb4' ) );
), \IPS\Http\Url::internal( 'app=core&module=support&controller=utf8mb4' )->csrf() );
}
/**
@@ -92,6 +97,8 @@ class _utf8mb4 extends \IPS\Dispatcher\Controller
*/
public function _convert( $wizardData )
{
\IPS\Session::i()->csrfCheck();
if ( isset( \IPS\Request::i()->finished ) )
{
return $wizardData;
@@ -105,7 +112,7 @@ class _utf8mb4 extends \IPS\Dispatcher\Controller
try
{
/* If this is the first run, do the database itself... */
if ( !is_array( $mrData ) )
if ( !\is_array( $mrData ) )
{
$databaseName = \IPS\Settings::i()->sql_database;
\IPS\Db::i()->query("ALTER DATABASE `{$databaseName}` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;");
@@ -120,7 +127,7 @@ class _utf8mb4 extends \IPS\Dispatcher\Controller
/* Do each table */
$select = \IPS\Settings::i()->sql_tbl_prefix ? ( new \IPS\Db\Select( "SHOW TABLES LIKE '" . \IPS\Db::i()->escape_string( \IPS\Settings::i()->sql_tbl_prefix ) . "%'", array(), \IPS\Db::i() ) ) : ( new \IPS\Db\Select( "SHOW TABLES", array(), \IPS\Db::i() ) );
$totalCount = count( $select );
$totalCount = \count( $select );
$i = 0;
foreach ( $select as $table )
{
@@ -128,7 +135,7 @@ class _utf8mb4 extends \IPS\Dispatcher\Controller
$table = mb_substr( $table, mb_strlen( \IPS\Settings::i()->sql_tbl_prefix ) );
/* If we've already done it, skip to next */
if ( in_array( $table, $mrData['done'] ) )
if ( \in_array( $table, $mrData['done'] ) )
{
continue;
}
@@ -181,7 +188,7 @@ class _utf8mb4 extends \IPS\Dispatcher\Controller
$hasText = false;
foreach( $indexData['columns'] as $column )
{
if ( in_array( mb_strtolower( $tableDefinition['columns'][ $column ]['type'] ), array( 'mediumtext', 'text' ) ) )
if ( \in_array( mb_strtolower( $tableDefinition['columns'][ $column ]['type'] ), array( 'mediumtext', 'text' ) ) )
{
$hasText = true;
}
@@ -219,7 +226,7 @@ class _utf8mb4 extends \IPS\Dispatcher\Controller
/* Do each column */
foreach ( $tableDefinition['columns'] as $columnName => $columnData )
{
if( in_array( \strtoupper( $columnData['type'] ), array( 'CHAR', 'VARCHAR', 'TINYTEXT', 'TEXT', 'MEDIUMTEXT', 'LONGTEXT', 'ENUM', 'SET' ) ) )
if( \in_array( \strtoupper( $columnData['type'] ), array( 'CHAR', 'VARCHAR', 'TINYTEXT', 'TEXT', 'MEDIUMTEXT', 'LONGTEXT', 'ENUM', 'SET' ) ) )
{
if( $tableDefinition['columns'][ $columnName ]['collation'] !== 'utf8mb4_unicode_ci' )
{
@@ -285,6 +292,8 @@ class _utf8mb4 extends \IPS\Dispatcher\Controller
*/
public function _finish( $data )
{
\IPS\Session::i()->log( 'acplog__ran_utf8mb4_converter' );
return \IPS\Theme::i()->getTemplate('support')->finishUtf8Mb4Conversion();
}
}