Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -45,11 +45,11 @@ 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'.ucfirst( mb_substr( \IPS\Request::i()->tab, 0, $pos ) ) ), mb_substr( \IPS\Request::i()->tab, $pos + 1 ) );
$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 ) );
}
else
{
$activeTabContents = call_user_func( array( $this, '_manage'.ucfirst( \IPS\Request::i()->tab ) ) );
$activeTabContents = call_user_func( array( $this, '_manage' . mb_ucfirst( \IPS\Request::i()->tab ) ) );
}
/* If this is an AJAX request, just return it */
@@ -99,10 +99,7 @@ class _advanced extends \IPS\Dispatcher\Controller
/* Clear it */
\IPS\Data\Cache::i()->clearAll();
\IPS\Data\Store::i()->clearAll();
/* Enable/disable the clearcaches task */
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => intval( \IPS\CACHE_METHOD === 'None' and \IPS\CACHE_PAGE_TIMEOUT ) ), "`key`='clearcache'" );
/* Log and redirect */
\IPS\Session::i()->log( 'acplogs__datastore_settings_updated' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&tab=datastore' ), 'saved' );
@@ -149,7 +146,7 @@ class _advanced extends \IPS\Dispatcher\Controller
{
if ( !$input->htmlId )
{
$input->htmlId = md5( uniqid() );
$input->htmlId = md5( mt_rand() );
}
$extra[] = $input;
@@ -170,7 +167,7 @@ class _advanced extends \IPS\Dispatcher\Controller
/* Cache */
$extra = array();
$toggles = array();
$toggles = array( 'Redis' => array( 'redis_enabled' ) );
$disabled = array();
$cacheConfigurationFields = array();
$options = array(
@@ -200,7 +197,7 @@ class _advanced extends \IPS\Dispatcher\Controller
{
if ( !$input->htmlId )
{
$input->htmlId = md5( uniqid() );
$input->htmlId = md5( mt_rand() );
}
$extra[] = $input;
@@ -218,6 +215,9 @@ class _advanced extends \IPS\Dispatcher\Controller
{
$form->add( $input );
}
$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' ) );
/* Handle submissions */
@@ -242,7 +242,7 @@ class _advanced extends \IPS\Dispatcher\Controller
}
/* If we've changed anything, explain to the admin they have to update */
if ( $values['datastore_method'] !== \IPS\STORE_METHOD or str_replace( '\\/', '/', json_encode( $storeConfiguration ) ) !== \IPS\STORE_CONFIG or $values['cache_method'] !== \IPS\CACHE_METHOD or json_encode( $cacheConfiguration ) !== \IPS\CACHE_CONFIG or $values['cache_guest_page'] !== \IPS\CACHE_PAGE_TIMEOUT )
if ( $values['datastore_method'] !== \IPS\STORE_METHOD or str_replace( '\\/', '/', json_encode( $storeConfiguration ) ) !== \IPS\STORE_CONFIG or $values['cache_method'] !== \IPS\CACHE_METHOD or json_encode( $cacheConfiguration ) !== \IPS\CACHE_CONFIG or $values['cache_guest_page'] !== \IPS\CACHE_PAGE_TIMEOUT or \IPS\REDIS_ENABLED != (boolean) $values['redis_enabled'] )
{
/* Connect to cache engine if we can and invalidate any existing caches */
try
@@ -256,17 +256,22 @@ class _advanced extends \IPS\Dispatcher\Controller
}
}
catch( \Exception $e ){}
/* Enable/disable the clearcaches task */
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => intval( $values['cache_method'] === 'None' and $values['cache_guest_page'] ) ), "`key`='clearcache'" );
/* Invalidate any existing datastore records */
try
{
$classname = 'IPS\Data\Store\\' . $values['datastore_method'];
$instance = new $classname( $storeConfiguration );
$instance->clearAll();
}
catch( \Exception $e ){}
/* Reset the last update flag for data store */
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => time() ), array( 'conf_key=?', 'last_data_store_update' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'last_data_store_update' => time() ) );
/* 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'] ) );
$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'] ) );
$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'] ) );
return \IPS\Theme::i()->getTemplate( 'settings' )->dataStoreChange( $downloadUrl, $checkUrl );
}
/* Otherwise just log and redirect */
@@ -293,19 +298,38 @@ class _advanced extends \IPS\Dispatcher\Controller
foreach ( \IPS\IPS::defaultConstants() as $k => $v )
{
$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' ) ) )
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' ) ) )
{
$output .= "define( '{$k}', " . var_export( $val, TRUE ) . " );\n";
}
}
/* We have to treat READ_WRITE_SEPARATION special because admin/index.php always disables it */
if( \file_exists( \IPS\ROOT_PATH . '/constants.php' ) )
{
$constants = \file_get_contents( \IPS\ROOT_PATH . '/constants.php' );
/* Did we sniff the constant out with a quick check? */
if( mb_strpos( $constants, 'READ_WRITE_SEPARATION' ) )
{
preg_match( "/define\(\s*?['\"]READ_WRITE_SEPARATION[\"']\s*?,\s*?(.+?)\);/i", $constants, $matches );
if( isset( $matches[1] ) )
{
$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( uniqid() ), 10, 10 ), TRUE ) . " );\n"; // Regenerate the unique key so there's no conflicts
$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' ) );
@@ -323,9 +347,7 @@ class _advanced extends \IPS\Dispatcher\Controller
/* Generate a cron key if we don't have one */
if ( !\IPS\Settings::i()->task_cron_key )
{
\IPS\Settings::i()->task_cron_key = md5( uniqid() );
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => \IPS\Settings::i()->task_cron_key ), array( 'conf_key=?', 'task_cron_key' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'task_cron_key' => md5( mt_rand() ) ) );
}
/* Sort stuff out for the cron setting */
@@ -372,6 +394,7 @@ 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';
@@ -380,6 +403,17 @@ 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' ) );
$form->addHeader( 'security_header_ips' );
if ( !\IPS\CIC )
{
$form->add( new \IPS\Helpers\Form\YesNo( 'xforward_matching', \IPS\Settings::i()->xforward_matching, FALSE ) );
}
$form->add( new \IPS\Helpers\Form\YesNo( 'match_ipaddress', \IPS\Settings::i()->match_ipaddress, FALSE ) );
if( \IPS\BYPASS_ACP_IP_CHECK === TRUE )
{
\IPS\Member::loggedIn()->language()->words['match_ipaddress_warning'] = \IPS\Member::loggedIn()->language()->addToStack('ip_override_warn');
}
$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\YesNo( 'auto_polling_enabled', \IPS\Settings::i()->auto_polling_enabled, FALSE ) );
@@ -417,11 +451,18 @@ class _advanced extends \IPS\Dispatcher\Controller
{
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_tasks' );
$table = new \IPS\Helpers\Table\Db( 'core_tasks', \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&do=tasks' ) );
$table = new \IPS\Helpers\Table\Db( 'core_tasks', \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&do=tasks' ), array( array( 'a.app_enabled=1' ) ) );
$table->joins = array(
array( 'select' => 'a.app_enabled', 'from' => array( 'core_applications', 'a' ), 'where' => "a.app_directory=app" )
);
$table->langPrefix = 'task_manager_';
$table->include = array( 'app', 'key', 'frequency', 'next_run', 'last_run' );
$table->mainColumn = 'key';
$table->quickSearch = 'key';
$table->primarySortBy = 'enabled';
$table->primarySortDirection = 'DESC';
$table->sortBy = $table->sortBy ?: 'next_run';
$table->sortDirection = $table->sortDirection ?: 'asc';
$table->quickSearch = function( $val )
@@ -429,11 +470,11 @@ class _advanced extends \IPS\Dispatcher\Controller
$matches = \IPS\Member::loggedIn()->language()->searchCustom( 'task__', $val, TRUE );
if ( count( $matches ) )
{
return '(' . \IPS\Db::i()->in( '`key`', array_keys( $matches ) ) . " OR `key` LIKE '%{$val}%')";
return array( '(' . \IPS\Db::i()->in( '`key`', array_keys( $matches ) ) . " OR `key` LIKE '%{$val}%')" );
}
else
{
return "`key` LIKE '%{$val}%'";
return array( "`key` LIKE '%" . \IPS\Db::i()->escape_string( $val ) . "%'" );
}
};
@@ -603,6 +644,10 @@ class _advanced extends \IPS\Dispatcher\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'advancedsettings' )->taskResult( TRUE, $output, $task->id );
}
}
catch( \RuntimeException $e )
{
\IPS\Output::i()->error( 'task_class_not_found', '4C124/6', 404, '' );
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2C124/1', 404, '' );
@@ -803,7 +848,14 @@ class _advanced extends \IPS\Dispatcher\Controller
}
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Text( 'furl_friendly', $current ? $current['friendly'] : '', FALSE, array(), NULL, \IPS\Settings::i()->base_url . ( \IPS\Settings::i()->htaccess_mod_rewrite ? '' : 'index.php?/' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'furl_friendly', $current ? $current['friendly'] : '', FALSE, array( 'placeholder' => \IPS\Member::loggedIn()->language()->addToStack('furl_friendly_placeholder') ), function( $val )
{
if( mb_substr( $val, 0, 3 ) == '{?}' )
{
throw new \DomainException( 'furl_too_greedy' );
}
},
\IPS\Settings::i()->base_url . ( \IPS\Settings::i()->htaccess_mod_rewrite ? '' : 'index.php?/' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'furl_real', $current ? $current['real'] : '', FALSE, array(), NULL, \IPS\Settings::i()->base_url . 'index.php?' ) );
if ( $values = $form->values() )
@@ -853,15 +905,17 @@ class _advanced extends \IPS\Dispatcher\Controller
}
else
{
$key = 'key' . ( count( $furl ) + 1 );
ksort( $furl );
$keys = array_keys( $furl );
$lastKey = str_replace( 'key', '', end( $keys ) );
$key = 'key' . ( $lastKey + 1 );
$furl[ $key ] = $save;
}
\IPS\Session::i()->log( 'acplogs__advanced_furl_edited' );
$newValue = json_encode( $furl );
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $newValue ), array( 'conf_key=?', 'furl_configuration' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'furl_configuration' => $newValue ) );
/* Clear Sidebar Caches */
\IPS\Widget::deleteCaches();
@@ -895,8 +949,7 @@ class _advanced extends \IPS\Dispatcher\Controller
{
unset( $furlDefinition[ \IPS\Request::i()->key ] );
$newValue = json_encode( $furlDefinition );
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $newValue ), array( 'conf_key=?', 'furl_configuration' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'furl_configuration' => $newValue ) );
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
@@ -916,8 +969,7 @@ class _advanced extends \IPS\Dispatcher\Controller
{
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_furls' );
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => NULL ), array( 'conf_key=?', 'furl_configuration' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'furl_configuration' => NULL ) );
unset( \IPS\Data\Store::i()->furl_configuration );
/* Clear guest page caches */