Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\modules\admin\settings;
|
||||
|
||||
/* 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,10 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _advanced extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
@@ -45,11 +49,13 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
\IPS\Request::i()->tab = isset( \IPS\Request::i()->tab ) ? \IPS\Request::i()->tab : 'settings';
|
||||
if ( $pos = mb_strpos( \IPS\Request::i()->tab, '-' ) )
|
||||
{
|
||||
$activeTabContents = call_user_func( array( $this, '_manage' . mb_ucfirst( mb_substr( \IPS\Request::i()->tab, 0, $pos ) ) ), mb_substr( \IPS\Request::i()->tab, $pos + 1 ) );
|
||||
$tabMethod = '_manage' . mb_ucfirst( mb_substr( \IPS\Request::i()->tab, 0, $pos ) );
|
||||
$activeTabContents = $this->$tabMethod( mb_substr( \IPS\Request::i()->tab, $pos + 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$activeTabContents = call_user_func( array( $this, '_manage' . mb_ucfirst( \IPS\Request::i()->tab ) ) );
|
||||
$tabMethod = '_manage' . mb_ucfirst( \IPS\Request::i()->tab );
|
||||
$activeTabContents = $this->$tabMethod();
|
||||
}
|
||||
|
||||
/* If this is an AJAX request, just return it */
|
||||
@@ -85,12 +91,19 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/* Are we just checking the constants? */
|
||||
if ( isset( \IPS\Request::i()->checkConstants ) )
|
||||
{
|
||||
{
|
||||
$cacheConfig = \IPS\CACHE_CONFIG;
|
||||
|
||||
if ( \IPS\Request::i()->store_method === 'Redis' or \IPS\Request::i()->cache_method === 'Redis' )
|
||||
{
|
||||
$cacheConfig = \IPS\REDIS_CONFIG;
|
||||
}
|
||||
|
||||
/* If we've changed anything, explain to the admin they have to update */
|
||||
if ( \IPS\Request::i()->store_method !== \IPS\STORE_METHOD or \IPS\Request::i()->store_config !== \IPS\STORE_CONFIG or \IPS\Request::i()->cache_method !== \IPS\CACHE_METHOD or \IPS\Request::i()->cache_config !== \IPS\CACHE_CONFIG or \IPS\Request::i()->cache_guest_page != \IPS\CACHE_PAGE_TIMEOUT )
|
||||
if ( \IPS\Request::i()->store_method !== \IPS\STORE_METHOD or \IPS\Request::i()->store_config !== \IPS\STORE_CONFIG or \IPS\Request::i()->cache_method !== \IPS\CACHE_METHOD or \IPS\Request::i()->cache_config !== $cacheConfig or \IPS\Request::i()->cache_guest_page != \IPS\CACHE_PAGE_TIMEOUT )
|
||||
{
|
||||
$downloadUrl = \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&do=downloadDatastoreConstants' )->setQueryString( array( 'store_method' => \IPS\Request::i()->store_method, 'store_config' => \IPS\Request::i()->store_config, 'cache_method' => \IPS\Request::i()->cache_method, 'cache_config' => \IPS\Request::i()->cache_config, 'cache_guest_page' => \IPS\Request::i()->cache_guest_page ) );
|
||||
$checkUrl = \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&tab=datastore&checkConstants=1' )->setQueryString( array( 'store_method' => \IPS\Request::i()->store_method, 'store_config' => \IPS\Request::i()->store_config, 'cache_method' => \IPS\Request::i()->cache_method, 'cache_config' => \IPS\Request::i()->cache_config, 'cache_guest_page' => \IPS\Request::i()->cache_guest_page ) );
|
||||
$checkUrl = \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&tab=datastore&checkConstants=1' )->setQueryString( array( 'store_method' => \IPS\Request::i()->store_method, 'store_config' => \IPS\Request::i()->store_config, 'cache_method' => \IPS\Request::i()->cache_method, 'cache_config' => \IPS\Request::i()->cache_config, 'cache_guest_page' => \IPS\Request::i()->cache_guest_page ) )->csrf();
|
||||
return \IPS\Theme::i()->getTemplate( 'settings' )->dataStoreChange( $downloadUrl, $checkUrl, TRUE );
|
||||
}
|
||||
/* Otherwise just log and redirect */
|
||||
@@ -111,9 +124,10 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Init */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->attributes['data-controller'] = 'core.admin.system.settings';
|
||||
|
||||
/* If the datastore isn't working properly, show a message */
|
||||
if( !\IPS\Data\Store::i()->test() OR \IPS\Db::i()->select( 'COUNT(*)', 'core_log', array( '`category`=? AND `time`>?', 'datastore', \IPS\DateTime::create()->sub( new \DateInterval( 'PT1H' ) )->getTimestamp() ) )->first() >= 10 )
|
||||
if( !\IPS\Data\Store::testStore() OR \IPS\Db::i()->select( 'COUNT(*)', 'core_log', array( '`category`=? AND `time`>?', 'datastore', \IPS\DateTime::create()->sub( new \DateInterval( 'PT1H' ) )->getTimestamp() ) )->first() >= 10 )
|
||||
{
|
||||
/* Have we just recently updated the configuration? If so, ignore this warning for 24 hours */
|
||||
if( \IPS\Settings::i()->last_data_store_update < \IPS\DateTime::create()->sub( new \DateInterval( 'PT24H' ) )->getTimestamp() )
|
||||
@@ -147,7 +161,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( !$input->htmlId )
|
||||
{
|
||||
$input->htmlId = md5( mt_rand() );
|
||||
$input->htmlId = 'id_' . $input->name;
|
||||
}
|
||||
|
||||
$extra[] = $input;
|
||||
@@ -188,7 +202,26 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$options['Test'] = 'datastore_method_Test';
|
||||
}
|
||||
$existingConfiguration = json_decode( \IPS\CACHE_CONFIG, TRUE );
|
||||
|
||||
$cacheConfig = \IPS\CACHE_CONFIG;
|
||||
|
||||
if ( \defined( '\IPS\REDIS_CONFIG' ) and ( \IPS\STORE_METHOD == 'Redis' OR \IPS\CACHE_METHOD == 'Redis' ) )
|
||||
{
|
||||
$cacheConfig = \IPS\REDIS_CONFIG;
|
||||
}
|
||||
|
||||
$existingConfiguration = json_decode( $cacheConfig, TRUE );
|
||||
|
||||
/* Remove deprecated options if they're not in use @todo 4.6 */
|
||||
$deprecatedCacheMethods = array( 'Apc', 'Memcache', 'Wincache', 'Xcache' );
|
||||
foreach( $deprecatedCacheMethods as $cache )
|
||||
{
|
||||
if( $cache !== \IPS\CACHE_METHOD )
|
||||
{
|
||||
unset( $options[ $cache ] );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $options as $k => $v )
|
||||
{
|
||||
$class = 'IPS\Data\Cache\\' . $k;
|
||||
@@ -203,13 +236,19 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( !$input->htmlId )
|
||||
{
|
||||
$input->htmlId = md5( mt_rand() );
|
||||
$input->htmlId = 'id_' . $input->name;
|
||||
}
|
||||
|
||||
$extra[] = $input;
|
||||
$toggles[ $k ][] = $input->htmlId;
|
||||
$cacheConfigurationFields[ $k ][ $inputKey ] = $input->name;
|
||||
}
|
||||
|
||||
/* Deprecated Warnings */
|
||||
if( \in_array( $k, $deprecatedCacheMethods ) )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["datastore_method_{$k}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'datastore_method_deprecated', FALSE, array( 'sprintf' => array( $k ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'cache_method', \IPS\CACHE_METHOD, TRUE, array(
|
||||
@@ -224,7 +263,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'redis_enabled', \IPS\REDIS_ENABLED, FALSE, array(), NULL, NULL, NULL, 'redis_enabled' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'cache_guest_page', \IPS\CACHE_PAGE_TIMEOUT, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'disable' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('for'), \IPS\Member::loggedIn()->language()->addToStack('seconds'), 'cache_guest_page' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'cache_guest_page', \IPS\CACHE_PAGE_TIMEOUT, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::SECONDS, 'unlimited' => 0, 'unlimitedLang' => 'disable' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('for'), NULL, 'cache_guest_page' ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -274,10 +313,11 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Reset the last update flag for data store */
|
||||
\IPS\Settings::i()->changeValues( array( 'last_data_store_update' => time() ) );
|
||||
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'dataStorageBroken' );
|
||||
|
||||
/* Display */
|
||||
$downloadUrl = \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&do=downloadDatastoreConstants' )->setQueryString( array( 'store_method' => $values['datastore_method'], 'store_config' => str_replace( '\\/', '/', json_encode( $storeConfiguration ) ), 'cache_method' => $values['cache_method'], 'cache_config' => json_encode( $cacheConfiguration ), 'cache_guest_page' => $values['cache_guest_page'], 'redis_enabled' => $values['redis_enabled'] ) );
|
||||
$checkUrl = \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&tab=datastore&checkConstants=1' )->setQueryString( array( 'store_method' => $values['datastore_method'], 'store_config' => str_replace( '\\/', '/', json_encode( $storeConfiguration ) ), 'cache_method' => $values['cache_method'], 'cache_config' => json_encode( $cacheConfiguration ), 'cache_guest_page' => $values['cache_guest_page'], 'redis_enabled' => $values['redis_enabled'] ) );
|
||||
$checkUrl = \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&tab=datastore&checkConstants=1' )->setQueryString( array( 'store_method' => $values['datastore_method'], 'store_config' => str_replace( '\\/', '/', json_encode( $storeConfiguration ) ), 'cache_method' => $values['cache_method'], 'cache_config' => json_encode( $cacheConfiguration ), 'cache_guest_page' => $values['cache_guest_page'], 'redis_enabled' => $values['redis_enabled'] ) )->csrf();
|
||||
return \IPS\Theme::i()->getTemplate( 'settings' )->dataStoreChange( $downloadUrl, $checkUrl );
|
||||
}
|
||||
/* Otherwise just log and redirect */
|
||||
@@ -287,7 +327,9 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&tab=datastore' ), 'saved' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('admin_system.js', 'core', 'admin') );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -303,11 +345,11 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
$output = "<?php\n\n";
|
||||
foreach ( \IPS\IPS::defaultConstants() as $k => $v )
|
||||
{
|
||||
$val = constant( 'IPS\\' . $k );
|
||||
$val = \constant( 'IPS\\' . $k );
|
||||
|
||||
if ( $val !== $v and !in_array( $k, array( 'STORE_METHOD', 'STORE_CONFIG', 'CACHE_METHOD', 'CACHE_CONFIG', 'CACHE_PAGE_TIMEOUT', 'SUITE_UNIQUE_KEY', 'READ_WRITE_SEPARATION', 'REDIS_ENABLED', 'REPORT_EXCEPTIONS' ) ) )
|
||||
if ( $val !== $v and !\in_array( $k, array( 'STORE_METHOD', 'STORE_CONFIG', 'CACHE_METHOD', 'CACHE_CONFIG', 'CACHE_PAGE_TIMEOUT', 'SUITE_UNIQUE_KEY', 'READ_WRITE_SEPARATION', 'REDIS_ENABLED', 'REDIS_CONFIG', 'REPORT_EXCEPTIONS' ) ) )
|
||||
{
|
||||
$output .= "define( '{$k}', " . var_export( $val, TRUE ) . " );\n";
|
||||
$output .= "\\define( '{$k}', " . var_export( $val, TRUE ) . " );\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,33 +365,41 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
|
||||
if( isset( $matches[1] ) )
|
||||
{
|
||||
$output .= "define( 'READ_WRITE_SEPARATION', " . $matches[1] . " );\n";
|
||||
$output .= "\\define( 'READ_WRITE_SEPARATION', " . $matches[1] . " );\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output .= "\n";
|
||||
$output .= "define( 'REDIS_ENABLED', " . var_export( (boolean) \IPS\Request::i()->redis_enabled, TRUE ) . " );\n";
|
||||
$output .= "define( 'STORE_METHOD', " . var_export( \IPS\Request::i()->store_method, TRUE ) . " );\n";
|
||||
$output .= "define( 'STORE_CONFIG', " . var_export( \IPS\Request::i()->store_config, TRUE ) . " );\n";
|
||||
$output .= "define( 'CACHE_METHOD', " . var_export( \IPS\Request::i()->cache_method, TRUE ) . " );\n";
|
||||
$output .= "define( 'CACHE_CONFIG', " . var_export( \IPS\Request::i()->cache_config, TRUE ) . " );\n";
|
||||
$output .= "define( 'CACHE_PAGE_TIMEOUT', " . var_export( (int) \IPS\Request::i()->cache_guest_page, TRUE ) . " );\n";
|
||||
$output .= "define( 'SUITE_UNIQUE_KEY', " . var_export( mb_substr( md5( mt_rand() ), 10, 10 ), TRUE ) . " );\n"; // Regenerate the unique key so there's no conflicts
|
||||
$output .= "\\define( 'REDIS_ENABLED', " . var_export( (boolean) \IPS\Request::i()->redis_enabled, TRUE ) . " );\n";
|
||||
$output .= "\\define( 'STORE_METHOD', " . var_export( \IPS\Request::i()->store_method, TRUE ) . " );\n";
|
||||
$output .= "\\define( 'STORE_CONFIG', " . var_export( \IPS\Request::i()->store_config, TRUE ) . " );\n";
|
||||
$output .= "\\define( 'CACHE_METHOD', " . var_export( \IPS\Request::i()->cache_method, TRUE ) . " );\n";
|
||||
|
||||
if ( \IPS\Request::i()->store_method === 'Redis' or \IPS\Request::i()->cache_method === 'Redis' )
|
||||
{
|
||||
$output .= "\\define( 'REDIS_CONFIG', " . var_export( \IPS\Request::i()->cache_config, TRUE ) . " );\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$output .= "\\define( 'CACHE_CONFIG', " . var_export( \IPS\Request::i()->cache_config, TRUE ) . " );\n";
|
||||
}
|
||||
|
||||
$output .= "\\define( 'CACHE_PAGE_TIMEOUT', " . var_export( (int) \IPS\Request::i()->cache_guest_page, TRUE ) . " );\n";
|
||||
$output .= "\\define( 'SUITE_UNIQUE_KEY', " . var_export( mb_substr( md5( mt_rand() ), 10, 10 ), TRUE ) . " );\n"; // Regenerate the unique key so there's no conflicts
|
||||
$output .= "\n\n\n";
|
||||
|
||||
\IPS\Output::i()->sendOutput( $output, 200, 'text/x-php', array( 'Content-Disposition' => 'attachment; filename=constants.php' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Settings
|
||||
* Get setting to configure tasks
|
||||
*
|
||||
* @return string
|
||||
* @param \IPS\Form $form Form to add the setting to
|
||||
* @return void
|
||||
*/
|
||||
protected function _manageSettings()
|
||||
public static function taskSetting( $form )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_server' );
|
||||
|
||||
/* Generate a cron key if we don't have one */
|
||||
if ( !\IPS\Settings::i()->task_cron_key )
|
||||
{
|
||||
@@ -398,9 +448,6 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
|
||||
/* Build and show form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->addHeader('task_manager');
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'task_use_cron', \IPS\CIC ? 'ips' : \IPS\Settings::i()->task_use_cron, FALSE, $options, function ( $val )
|
||||
{
|
||||
$cronFile = \IPS\ROOT_PATH . '/applications/core/interface/task/task.php';
|
||||
@@ -409,6 +456,26 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack('task_use_cron_executable', FALSE, array( 'sprintf' => array( $cronFile ) ) ) );
|
||||
}
|
||||
}, NULL, NULL, 'task_use_cron' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _manageSettings()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_server' );
|
||||
|
||||
/* Build and show form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_settings.js', 'core', 'admin' ) );
|
||||
$form->attributes['data-controller'] = 'core.admin.settings.advanced';
|
||||
$form->hiddenValues['rebuildPosts'] = \IPS\Request::i()->rebuildPosts ?: 0;
|
||||
$form->addHeader('task_manager');
|
||||
|
||||
static::taskSetting( $form );
|
||||
|
||||
$form->addHeader( 'security_header_ips' );
|
||||
if ( !\IPS\CIC )
|
||||
{
|
||||
@@ -419,8 +486,20 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['match_ipaddress_warning'] = \IPS\Member::loggedIn()->language()->addToStack('ip_override_warn');
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'clickjackprevention', \IPS\Settings::i()->clickjackprevention, FALSE, array(
|
||||
'options' => array(
|
||||
'xframe' => 'clickjackprevention_xframe',
|
||||
'csp' => 'clickjackprevention_csp',
|
||||
'none' => 'clickjackprevention_none',
|
||||
),
|
||||
'toggles' => array(
|
||||
'csp' => array( 'csp_header' )
|
||||
)
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'csp_header', \IPS\Settings::i()->csp_header, FALSE, array( 'placeholder' => "default-src *; frame-ancestors 'self' *.example.com" ), NULL, NULL, NULL, 'csp_header' ) );
|
||||
$form->addHeader('performance_settings');
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'widget_cache_ttl', ( isset( \IPS\Settings::i()->widget_cache_ttl ) ) ? \IPS\Settings::i()->widget_cache_ttl : 60, FALSE, array( 'min' => 60 ), NULL, \IPS\Member::loggedIn()->language()->addToStack('for'), \IPS\Member::loggedIn()->language()->addToStack('seconds') ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'widget_cache_ttl', ( isset( \IPS\Settings::i()->widget_cache_ttl ) ) ? \IPS\Settings::i()->widget_cache_ttl : 60, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::SECONDS, 'min' => 60 ), NULL, \IPS\Member::loggedIn()->language()->addToStack('for'), NULL ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'lazy_load_enabled', \IPS\Settings::i()->lazy_load_enabled, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'auto_polling_enabled', \IPS\Settings::i()->auto_polling_enabled, FALSE ) );
|
||||
|
||||
if ( ! \IPS\CIC )
|
||||
@@ -440,7 +519,40 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$form->saveAsSettings();
|
||||
/* Run the rebuild posts routine */
|
||||
if( $values['rebuildPosts'] )
|
||||
{
|
||||
/* Remove any existing rebuilds */
|
||||
\IPS\Db::i()->delete( 'core_queue', \IPS\Db::i()->in( '`key`', array( 'RebuildLazyLoad', 'RebuildLazyLoadNonContent' ) ) );
|
||||
|
||||
/* Unset task datastore */
|
||||
unset( \IPS\Data\Store::i()->currentLazyLoadRebuild );
|
||||
|
||||
$enableDisable = $values['lazy_load_enabled'] ? TRUE : FALSE;
|
||||
foreach ( \IPS\Content::routedClasses( FALSE, TRUE ) as $class )
|
||||
{
|
||||
if( isset( $class::$databaseColumnMap['content'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'RebuildLazyLoad', array( 'class' => $class, 'status' => $enableDisable ), 4 );
|
||||
}
|
||||
catch( \OutOfRangeException $ex ) { }
|
||||
}
|
||||
}
|
||||
|
||||
foreach( \IPS\Application::allExtensions( 'core', 'EditorLocations', FALSE, NULL, NULL, TRUE, TRUE ) as $_key => $extension )
|
||||
{
|
||||
if( method_exists( $extension, 'rebuildLazyLoad' ) )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'RebuildLazyLoadNonContent', array( 'extension' => $_key, 'status' => $enableDisable ), 4 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset( $values['rebuildPosts'] );
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
\IPS\Session::i()->log( 'acplogs__advanced_server_edited' );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&tab=settings' ), 'saved' );
|
||||
@@ -475,7 +587,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
$table->quickSearch = function( $val )
|
||||
{
|
||||
$matches = \IPS\Member::loggedIn()->language()->searchCustom( 'task__', $val, TRUE );
|
||||
if ( count( $matches ) )
|
||||
if ( \count( $matches ) )
|
||||
{
|
||||
return array( '(' . \IPS\Db::i()->in( '`key`', array_keys( $matches ) ) . " OR `key` LIKE '%{$val}%')" );
|
||||
}
|
||||
@@ -552,7 +664,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
$return = array( 'unlock' => array(
|
||||
'icon' => 'unlock',
|
||||
'title' => 'task_manager_unlock',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=settings&controller=advanced&do=unlockTask&id={$row['id']}" )
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=settings&controller=advanced&do=unlockTask&id={$row['id']}" )->csrf()
|
||||
) );
|
||||
}
|
||||
else
|
||||
@@ -560,7 +672,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
$return = array( 'run' => array(
|
||||
'icon' => 'play-circle',
|
||||
'title' => 'task_manager_run',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=settings&controller=advanced&do=runTask&id={$row['id']}" )
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=settings&controller=advanced&do=runTask&id={$row['id']}" )->csrf()
|
||||
) );
|
||||
}
|
||||
$return['logs'] = array(
|
||||
@@ -595,7 +707,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_tasks' );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'prune_log_tasks', \IPS\Settings::i()->prune_log_tasks, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_log_tasks' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'prune_log_tasks', \IPS\Settings::i()->prune_log_tasks, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_log_tasks' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -616,6 +728,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
protected function runTask()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_tasks' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('task_manager');
|
||||
|
||||
@@ -635,11 +748,11 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( is_array( $output ) )
|
||||
if ( \is_array( $output ) )
|
||||
{
|
||||
$output = implode( "\n", array_map( array( \IPS\Member::loggedIn()->language(), 'addToStack' ), $output ) );
|
||||
}
|
||||
elseif ( !is_string( $output ) and !is_numeric( $output ) )
|
||||
elseif ( !\is_string( $output ) and !\is_numeric( $output ) )
|
||||
{
|
||||
$output = var_export( $output, TRUE );
|
||||
}
|
||||
@@ -655,6 +768,10 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'advancedsettings' )->taskResult( FALSE, \IPS\Member::loggedIn()->language()->addToStack( $e->getMessage(), FALSE ), $task->id );
|
||||
}
|
||||
catch ( \RuntimeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'task_running_error', '2C124/7', 404, '', array(), \IPS\IPS::getExceptionDetails( $e ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'task_class_not_found', '2C124/1', 404, '' );
|
||||
@@ -662,7 +779,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
catch( \Exception $e )
|
||||
{
|
||||
\IPS\Log::log( $e, 'uncaught_exception' );
|
||||
\IPS\Output::i()->error( $e->getMessage(), '4C124/6', 404, '' );
|
||||
\IPS\Output::i()->error( $e->getMessage() ?: 'task_running_error', '4C124/6', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,6 +791,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
protected function unlockTask()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_tasks' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -716,11 +834,11 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
'log' => function ( $val, $row )
|
||||
{
|
||||
$val = json_decode( $val );
|
||||
if ( is_array( $val ) )
|
||||
if ( \is_array( $val ) )
|
||||
{
|
||||
$val = implode( "\n", array_map( array( \IPS\Member::loggedIn()->language(), 'addToStack' ), $val ) );
|
||||
}
|
||||
elseif ( !is_string( $val ) and !is_numeric( $val ) )
|
||||
elseif ( !\is_string( $val ) and !\is_numeric( $val ) )
|
||||
{
|
||||
$val = var_export( $val, TRUE );
|
||||
}
|
||||
@@ -766,7 +884,8 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
$definition = \IPS\Http\Url\Friendly::furlDefinition();
|
||||
|
||||
$customConfiguration = \IPS\Settings::i()->furl_configuration ? json_decode( \IPS\Settings::i()->furl_configuration, TRUE ) : array();
|
||||
|
||||
$table = new \IPS\Helpers\Table\Custom( $definition, \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&tab=furl' ) );
|
||||
$table->include = array( 'friendly', 'real' );
|
||||
$table->limit = 100;
|
||||
@@ -809,17 +928,17 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
)
|
||||
);
|
||||
|
||||
if( \IPS\Settings::i()->furl_configuration AND $config = json_decode( \IPS\Settings::i()->furl_configuration, TRUE ) AND count( $config ) )
|
||||
if( $customConfiguration AND \count( $customConfiguration ) )
|
||||
{
|
||||
$table->rootButtons['revert'] = array(
|
||||
'icon' => 'undo',
|
||||
'title' => 'furl_revert',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&do=furlRevert' ),
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&do=furlRevert' )->csrf(),
|
||||
'data' => array( 'confirm' => '' )
|
||||
);
|
||||
}
|
||||
|
||||
$table->rowButtons = function( $row, $k ) use ( $definition )
|
||||
$table->rowButtons = function( $row, $k ) use ( $definition, $customConfiguration )
|
||||
{
|
||||
$return = array(
|
||||
'edit' => array(
|
||||
@@ -830,12 +949,12 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
)
|
||||
);
|
||||
|
||||
if( isset( $definition[ $k ]['custom'] ) )
|
||||
if( isset( $definition[ $k ]['custom'] ) OR isset( $customConfiguration[ $k ] ) )
|
||||
{
|
||||
$return['revert'] = array(
|
||||
'icon' => 'undo',
|
||||
'title' => 'revert',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=settings&controller=advanced&do=furlDelete&key={$k}" ),
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=settings&controller=advanced&do=furlDelete&key={$k}" )->csrf(),
|
||||
'data' => array( 'confirm' => '', 'confirmMessage' => \IPS\Member::loggedIn()->language()->addToStack('revert_confirm') )
|
||||
);
|
||||
}
|
||||
@@ -882,6 +1001,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
$appIsDefault = FALSE;
|
||||
$alias = NULL;
|
||||
$verify = NULL;
|
||||
$seoPagination = NULL;
|
||||
$friendly = $values['furl_friendly'];
|
||||
if ( \IPS\Request::i()->key )
|
||||
{
|
||||
@@ -894,7 +1014,12 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$verify = $currentDefinition[ \IPS\Request::i()->key ]['verify'];
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $currentDefinition[ \IPS\Request::i()->key ]['seoPagination'] ) )
|
||||
{
|
||||
$seoPagination = $currentDefinition[ \IPS\Request::i()->key ]['seoPagination'];
|
||||
}
|
||||
|
||||
if ( isset( $currentDefinition[ \IPS\Request::i()->key ]['with_top_level'] ) )
|
||||
{
|
||||
$appIsDefault = TRUE;
|
||||
@@ -911,8 +1036,8 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$save = \IPS\Http\Url\Friendly::buildFurlDefinition( $friendly, $values['furl_real'], $appTopLevel, $appIsDefault, $alias, TRUE, $verify );
|
||||
|
||||
$save = \IPS\Http\Url\Friendly::buildFurlDefinition( $friendly, $values['furl_real'], $appTopLevel, $appIsDefault, $alias, TRUE, $verify, NULL, $seoPagination );
|
||||
|
||||
if ( \IPS\Request::i()->key )
|
||||
{
|
||||
@@ -955,6 +1080,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
protected function furlDelete()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_furls' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
@@ -983,6 +1109,7 @@ class _advanced extends \IPS\Dispatcher\Controller
|
||||
protected function furlRevert()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_furls' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
\IPS\Settings::i()->changeValues( array( 'furl_configuration' => NULL ) );
|
||||
unset( \IPS\Data\Store::i()->furl_configuration );
|
||||
|
||||
Reference in new issue
Block a user