Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief Advanced Settings
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 10 June 2013
* @version SVN_VERSION_NUMBER
*/
@@ -63,11 +63,11 @@ class _advanced extends \IPS\Dispatcher\Controller
/* Build tab list */
$tabs = array();
$tabs['settings'] = 'server_environment';
if ( \IPS\Settings::i()->use_friendly_urls )
if ( \IPS\Settings::i()->use_friendly_urls and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'advanced_manage_furls' ) )
{
$tabs['furl'] = 'furls';
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'datastore' ) )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'datastore' ) and !\IPS\CIC )
{
$tabs['datastore'] = 'data_store';
}
@@ -116,6 +116,16 @@ class _advanced extends \IPS\Dispatcher\Controller
/* Init */
$form = new \IPS\Helpers\Form;
/* 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 )
{
/* 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() )
{
$form->addMessage( 'dashboard_datastore_broken_settings', 'ipsMessage ipsMessage_warning' );
}
}
/* Cold storage */
$extra = array();
$toggles = array();
@@ -250,6 +260,10 @@ class _advanced extends \IPS\Dispatcher\Controller
/* 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'" );
/* 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 );
/* 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'] ) );
@@ -274,6 +288,8 @@ class _advanced extends \IPS\Dispatcher\Controller
*/
protected function downloadDatastoreConstants()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'datastore' );
$output = "<?php\n\n";
foreach ( \IPS\IPS::defaultConstants() as $k => $v )
{
@@ -314,22 +330,54 @@ class _advanced extends \IPS\Dispatcher\Controller
}
/* Sort stuff out for the cron setting */
\IPS\Member::loggedIn()->language()->words['task_use_cron_warning'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'task_use_cron_warning', FALSE ), PHP_BINDIR . '/php -d memory_limit=-1 -d max_execution_time=0 ' . \IPS\ROOT_PATH . '/applications/core/interface/task/task.php ' . \IPS\Settings::i()->task_cron_key );
$cronOptions = array( 'togglesOn' => array( 'task_use_cron_warning' ) );
if ( \IPS\CIC )
{
$options = array( 'options' => array(
'ips' => 'task_method_ips'
) );
}
else
{
\IPS\Member::loggedIn()->language()->words['task_method_cron_warning'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'task_method_cron_warning', FALSE ), PHP_BINDIR . '/php -d memory_limit=-1 -d max_execution_time=0 ' . \IPS\ROOT_PATH . '/applications/core/interface/task/task.php ' . \IPS\Settings::i()->task_cron_key );
\IPS\Member::loggedIn()->language()->words['task_method_web_warning'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'task_method_web_warning', FALSE ), \IPS\Http\Url::internal( 'applications/core/interface/task/web.php?key=' . \IPS\Settings::i()->task_cron_key, 'none' ) );
$options = array(
'options' => array(
'normal' => 'task_method_normal',
'cron' => 'task_method_cron',
'web' => 'task_method_web',
),
'toggles' => array(
'cron' => array( 'task_use_cron_cron_warning' ),
'web' => array( 'task_use_cron_web_warning' )
)
);
}
/* Build and show form */
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\YesNo( 'task_use_cron', \IPS\Settings::i()->task_use_cron, FALSE, $cronOptions, function ( $val )
$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';
if ( $val and ( mb_strtoupper( mb_substr( PHP_OS, 0, 3 ) ) !== 'WIN' AND !is_executable( $cronFile ) ) )
if ( $val == 'cron' and ( mb_strtoupper( mb_substr( PHP_OS, 0, 3 ) ) !== 'WIN' AND !is_executable( $cronFile ) ) )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack('task_use_cron_executable', FALSE, array( 'sprintf' => array( $cronFile ) ) ) );
}
}, NULL, NULL, 'task_use_cron' ) );
$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 ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'theme_disk_cache_templates', \IPS\Settings::i()->theme_disk_cache_templates, FALSE, array( 'togglesOn' => array( 'theme_disk_cache_path' ) ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'theme_disk_cache_path', \IPS\Settings::i()->theme_disk_cache_path ? \IPS\Settings::i()->theme_disk_cache_path : \IPS\ROOT_PATH . '/uploads', FALSE, array(), function( $val )
{
if ( \IPS\Request::i()->theme_disk_cache_templates_checkbox )
{
if ( ! is_dir( \IPS\Request::i()->theme_disk_cache_path ) or ! is_readable( \IPS\Request::i()->theme_disk_cache_path ) or ! is_writable( \IPS\Request::i()->theme_disk_cache_path ) )
{
throw new \InvalidArgumentException( 'theme_disk_cache_path_wrong' );
}
}
}, NULL, NULL, 'theme_disk_cache_path' ) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
@@ -351,7 +399,7 @@ class _advanced extends \IPS\Dispatcher\Controller
$table = new \IPS\Helpers\Table\Db( 'core_tasks', \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&do=tasks' ) );
$table->langPrefix = 'task_manager_';
$table->include = array( 'app', 'key', 'frequency', 'next_run' );
$table->include = array( 'app', 'key', 'frequency', 'next_run', 'last_run' );
$table->mainColumn = 'key';
$table->quickSearch = 'key';
$table->sortBy = $table->sortBy ?: 'next_run';
@@ -361,11 +409,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 ) );
return '(' . \IPS\Db::i()->in( '`key`', array_keys( $matches ) ) . " OR `key` LIKE '%{$val}%')";
}
else
{
return '1=0';
return "`key` LIKE '%{$val}%'";
}
};
@@ -376,6 +424,10 @@ class _advanced extends \IPS\Dispatcher\Controller
{
return $val ? \IPS\Application::load( $val )->_title : \IPS\Plugin::load( $row['plugin'] )->name;
}
catch ( \UnexpectedValueException $e )
{
return NULL;
}
catch ( \OutOfRangeException $e )
{
return NULL;
@@ -418,6 +470,10 @@ class _advanced extends \IPS\Dispatcher\Controller
{
return (string) \IPS\DateTime::ts( $row['next_run'] ?: time() );
}
},
'last_run' => function ( $v, $row )
{
return (string) $row['last_run'] ? \IPS\DateTime::ts( $row['last_run'] ) : \IPS\Member::loggedIn()->language()->addToStack( 'never' );
}
);
@@ -468,6 +524,8 @@ class _advanced extends \IPS\Dispatcher\Controller
*/
protected function taskSettings()
{
\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' ) );
@@ -627,7 +685,8 @@ class _advanced extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'furl_in_dev', '1C124/5', 403, '' );
}
$definition = \IPS\Http\Url::furlDefinition();
$definition = \IPS\Http\Url\Friendly::furlDefinition();
$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;
@@ -645,14 +704,9 @@ class _advanced extends \IPS\Dispatcher\Controller
preg_match_all( '/{([@#])(.+?)}/', $row['friendly'], $matches );
if ( !empty( $matches[0] ) )
{
if ( $val )
{
$val .= '&';
}
foreach ( $matches[0] as $i => $m )
{
$val .= $matches[ 2 ][ $i ] . '=<strong><em>' . ( $matches[ 1 ][ $i ] == '#' ? '123' : 'abc' ) . '</em></strong>';
$val .= '&' . $matches[ 2 ][ $i ] . '=<strong><em>' . ( $matches[ 1 ][ $i ] == '#' ? '123' : 'abc' ) . '</em></strong>';
}
$val .= '</strong>';
}
@@ -684,7 +738,7 @@ class _advanced extends \IPS\Dispatcher\Controller
'data' => array( 'confirm' => '' )
);
}
$table->rowButtons = function( $row, $k ) use ( $definition )
{
$return = array(
@@ -698,17 +752,17 @@ class _advanced extends \IPS\Dispatcher\Controller
if( isset( $definition[ $k ]['custom'] ) )
{
$return['delete'] = array(
'icon' => 'times-circle',
'title' => 'delete',
$return['revert'] = array(
'icon' => 'undo',
'title' => 'revert',
'link' => \IPS\Http\Url::internal( "app=core&module=settings&controller=advanced&do=furlDelete&key={$k}" ),
'data' => array( 'delete' => '' )
'data' => array( 'confirm' => '', 'confirmMessage' => \IPS\Member::loggedIn()->language()->addToStack('revert_confirm') )
);
}
return $return;
};
return ( \IPS\Request::i()->advancedSearchForm ? '' : \IPS\Theme::i()->getTemplate('global')->message( 'furl_warning', 'warning' ) ) . $table;
}
@@ -722,7 +776,7 @@ class _advanced extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_furls' );
$current = NULL;
$config = \IPS\Http\Url::furlDefinition();
$config = \IPS\Http\Url\Friendly::furlDefinition();
if ( \IPS\Request::i()->key )
{
$current = ( isset( $config[ \IPS\Request::i()->key ] ) ) ? $config[ \IPS\Request::i()->key ] : NULL;
@@ -736,20 +790,51 @@ class _advanced extends \IPS\Dispatcher\Controller
{
$furl = \IPS\Settings::i()->furl_configuration ? json_decode( \IPS\Settings::i()->furl_configuration, TRUE ) : array();
$currentDefinition = \IPS\Http\Url::furlDefinition();
$save = \IPS\Request::i()->key ? $currentDefinition[ \IPS\Request::i()->key ] : array();
$save['friendly'] = $values['furl_friendly'];
$save['real'] = $values['furl_real'];
$save['custom'] = true;
$currentDefinition = \IPS\Http\Url\Friendly::furlDefinition();
$appTopLevel = NULL;
$appIsDefault = FALSE;
$alias = NULL;
$verify = NULL;
$friendly = $values['furl_friendly'];
if ( \IPS\Request::i()->key )
{
if ( isset( $currentDefinition[ \IPS\Request::i()->key ]['alias'] ) )
{
$alias = $currentDefinition[ \IPS\Request::i()->key ]['alias'];
}
if ( isset( $currentDefinition[ \IPS\Request::i()->key ]['verify'] ) )
{
$verify = $currentDefinition[ \IPS\Request::i()->key ]['verify'];
}
if ( isset( $currentDefinition[ \IPS\Request::i()->key ]['with_top_level'] ) )
{
$appIsDefault = TRUE;
$appTopLevel = mb_substr( $currentDefinition[ \IPS\Request::i()->key ]['with_top_level'], 0, -mb_strlen( $currentDefinition[ \IPS\Request::i()->key ]['friendly'] . '/' ) );
}
if ( isset( $currentDefinition[ \IPS\Request::i()->key ]['without_top_level'] ) )
{
$appIsDefault = FALSE;
if ( $currentDefinition[ \IPS\Request::i()->key ]['without_top_level'] )
{
$appTopLevel = mb_substr( $currentDefinition[ \IPS\Request::i()->key ]['friendly'], 0, -mb_strlen( $currentDefinition[ \IPS\Request::i()->key ]['without_top_level'] . '/' ) );
$friendly = rtrim( preg_replace( '/^' . preg_quote( $appTopLevel, '/' ) . '(\/|$)/', '', $friendly ), '/' );
}
}
}
$save = \IPS\Http\Url\Friendly::buildFurlDefinition( $friendly, $values['furl_real'], $appTopLevel, $appIsDefault, $alias, TRUE, $verify );
if ( \IPS\Request::i()->key )
{
$furl[ \IPS\Request::i()->key ] = $save;
}
else
{
$furl[] = $save;
$key = 'key' . ( count( $furl ) + 1 );
$furl[ $key ] = $save;
}
\IPS\Session::i()->log( 'acplogs__advanced_furl_edited' );
@@ -781,6 +866,9 @@ class _advanced extends \IPS\Dispatcher\Controller
protected function furlDelete()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_furls' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
$furlDefinition = \IPS\Settings::i()->furl_configuration ? json_decode( \IPS\Settings::i()->furl_configuration, TRUE ) : array();
if( isset( $furlDefinition[ \IPS\Request::i()->key ] ) )