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

@@ -109,15 +109,52 @@ class _dashboard extends \IPS\Dispatcher\Controller
/* Warnings */
$warnings = array();
$dir = @dir( '/' );
if ( $dir instanceof \Directory )
{
$warnings[] = array(
'title' => \IPS\Member::loggedIn()->language()->addToStack('open_basedir_title'),
'description' => \IPS\Member::loggedIn()->language()->addToStack('open_basedir_desc'),
);
}
$functionsToDisable = array( 'exec', 'system', 'passhtru', 'pcntl_exec', 'popen', 'proc_open', 'shell_exec' );
$showingFunctionWarning = FALSE;
foreach ( $functionsToDisable as $k => $function )
{
if ( function_exists( $function ) )
{
$showingFunctionWarning = TRUE;
}
else
{
unset( $functionsToDisable[ $k ] );
}
}
if ( $showingFunctionWarning )
{
$warnings[] = array(
'title' => \IPS\Member::loggedIn()->language()->addToStack('disable_functions_title'),
'description' => \IPS\Member::loggedIn()->language()->addToStack('disable_functions_desc', FALSE, array( 'sprintf' => array( implode( ', ', $functionsToDisable ) ) ) ),
);
}
if ( !\IPS\IN_DEV and ini_get( 'display_errors' ) )
{
$warnings[] = array(
'title' => \IPS\Member::loggedIn()->language()->addToStack('display_errors_title'),
'description' => \IPS\Member::loggedIn()->language()->addToStack('display_errors_desc'),
'risk' => "medium",
);
}
$tasks = \IPS\Db::i()->select( '*', 'core_tasks', 'lock_count >= 3' );
$keys = array();
foreach( $tasks as $task )
{
$keys[] = $task['key'];
}
if ( !empty( $keys ) )
{
$warnings[] = array(
@@ -143,6 +180,50 @@ class _dashboard extends \IPS\Dispatcher\Controller
);
}
if( !\IPS\Settings::i()->orig_tables_checked )
{
/* Check if we have any orig_* tables */
$tables = \IPS\Db::i()->getTables( 'orig_' . \IPS\Db::i()->prefix );
/* If we don't have any, we're good. Set a flag so we don't check this every dashboard load. */
if( !count( $tables ) )
{
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 1 ), array( 'conf_key=?', 'orig_tables_checked' ) );
unset( \IPS\Data\Store::i()->settings );
}
else
{
/* Determine if the background queue task has already been launched */
try
{
\IPS\Db::i()->select( '*', 'core_queue', array( "`key`=?", 'CleanupOrigTables' ) )->first();
$inProgress = TRUE;
}
catch( \UnderflowException $e )
{
$inProgress = FALSE;
}
/* Launch the task if we clicked to do so */
if( !$inProgress AND isset( \IPS\Request::i()->cleanupOrigTables ) AND \IPS\Request::i()->cleanupOrigTables )
{
\IPS\Task::queue( 'core', 'CleanupOrigTables', array( 'originalCount' => count( $tables ) ), 5 );
$inProgress = TRUE;
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('orig_tables_rebuilding');
}
if( !$inProgress )
{
$warnings[] = array(
'title' => \IPS\Member::loggedIn()->language()->addToStack('block_core_OrigTables'),
'description' => \IPS\Member::loggedIn()->language()->addToStack('orig_cleanup_suggested')
);
}
}
}
/* Check Tasks */
try
{
@@ -155,21 +236,21 @@ class _dashboard extends \IPS\Dispatcher\Controller
if( \IPS\Settings::i()->task_use_cron == 'cron' )
{
$warnings[] = array(
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_broken' ),
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_cron_broken_desc' )
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasksrun_broken' ),
'description' => \IPS\Member::loggedIn()->language()->addToStack( \IPS\CIC ? 'dashboard_tasks_cron_broken_desc_cic' : 'dashboard_tasks_cron_broken_desc' )
);
}
elseif( \IPS\Settings::i()->task_use_cron == 'web' )
{
$warnings[] = array(
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_broken' ),
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasksrun_broken' ),
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_web_broken_desc' )
);
}
else
{
$warnings[] = array(
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_broken' ),
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasksrun_broken' ),
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_not_enough_desc' )
);
}
@@ -184,8 +265,10 @@ class _dashboard extends \IPS\Dispatcher\Controller
'description' => \IPS\Member::loggedIn()->language()->addToStack('dasbhoard_tasks_site_offline_desc')
);
}
/* If there have been more than 10 datastore failurs in the last hour, or if an instant test fails, show a message */
/* If there have been more than 10 datastore failures in the last hour, or if an instant test fails, 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 */
@@ -197,13 +280,92 @@ class _dashboard extends \IPS\Dispatcher\Controller
);
}
}
if ( \IPS\CIC )
{
try
{
$cicEmails = \IPS\Data\Cache::i()->getWithExpire( 'cicEmailUsage', TRUE );
}
catch( \OutOfRangeException $e )
{
preg_match( '/^\/var\/www\/html\/(.+?)(?:\/|$)/i', \IPS\ROOT_PATH, $matches );
try
{
$cicEmails = \IPS\Http\Url::external( "http://ips-cic-email.invisioncic.com/blocked.php?account={$matches[1]}" )->request()->get()->decodeJson();
}
catch( \Exception $e )
{
/* Request failed, so assume okay and try again in an hour */
$cicEmails = array( 'status' => 'OKAY', 'time' => time() );
}
\IPS\Data\Cache::i()->storeWithExpire( 'cicEmailUsage', $cicEmails, \IPS\DateTime::create()->add( new \DateInterval( 'PT1H' ) ), true );
}
if ( isset( $cicEmails['status'] ) AND $cicEmails['status'] == 'BLOCKED' )
{
$warnings[] = array(
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_cic_email_quota' ),
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_cic_email_quota_desc' )
);
}
}
/* Cache Check */
if ( \IPS\CACHE_METHOD AND \IPS\CACHE_METHOD != 'None' AND \IPS\Data\Cache::i() instanceof \IPS\Data\Cache\None )
{
$warnings[] = array(
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_invalid_cachesetup' ),
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_invalid_cachesetup_desc' )
);
}
/* Get new core update available data */
$update = \IPS\Application::load( 'core' )->availableUpgrade( TRUE );
$update = \IPS\Application::load( 'core' )->availableUpgrade( TRUE );
/* Determine if there are any new features to show */
$latestFeatureId = \IPS\Application::load( 'core' )->newFeature();
$features = array();
try
{
$latestSeenFeature = \IPS\Db::i()->select( 'feature_id', 'core_members_feature_seen', array( 'member_id=?', \IPS\Member::loggedIn()->member_id ) )->first();
}
catch( \UnderflowException $e )
{
$latestSeenFeature = 0;
}
if( $latestFeatureId AND ( !$latestSeenFeature OR $latestSeenFeature < $latestFeatureId ) )
{
try
{
$features = json_encode( \IPS\Http\Url::ips('newFeatures')->setQueryString( array( 'since' => (int) $latestSeenFeature ) )->request()->get()->decodeJson() );
/* Reset our last feature ID information so this doesn't show on subsequent page loads */
\IPS\Db::i()->replace( 'core_members_feature_seen', array( 'member_id' => \IPS\Member::loggedIn()->member_id, 'feature_id' => $latestFeatureId ) );
}
catch( \RuntimeException $e ){}
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('dashboard');
\IPS\Output::i()->customHeader = \IPS\Theme::i()->getTemplate( 'dashboard' )->dashboardHeader( $info, $blocks );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'dashboard' )->dashboard( $update, $toShow, $blocks, $info, $bulletins, $warnings );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'dashboard' )->dashboard( $update, $features, $toShow, $blocks, $info, $bulletins, $warnings );
}
/**
* Reset the latest features we've seen so that we can see them again
*
* @return void
*/
public function whatsNew()
{
\IPS\Db::i()->delete( 'core_members_feature_seen', array( 'member_id=?', \IPS\Member::loggedIn()->member_id ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=overview&controller=dashboard" ) );
}
/**
@@ -234,9 +396,12 @@ class _dashboard extends \IPS\Dispatcher\Controller
$blocks[ \IPS\Member::loggedIn()->member_id ] = $toShow;
\IPS\Settings::i()->acp_dashboard_blocks = json_encode( $blocks );
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => \IPS\Settings::i()->acp_dashboard_blocks ), array( 'conf_key=?', 'acp_dashboard_blocks' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'acp_dashboard_blocks' => json_encode( $blocks ) ) );
}
/* Upon initial upgrade to 4.3 the key won't exist, so apply to bg queue by default */
elseif( !array_key_exists( 'collapsed', $toShow ) )
{
$toShow['collapsed'] = array( 'core_BackgroundQueue' );
}
if( $return === TRUE )
@@ -292,20 +457,17 @@ class _dashboard extends \IPS\Dispatcher\Controller
$saveBlocks = \IPS\Request::i()->blocks;
if( !isset( $saveBlocks['main'] ) )
foreach( array( 'main', 'side', 'collapsed' ) as $saveKey )
{
$saveBlocks['main'] = array();
}
if( !isset( $saveBlocks['side'] ) )
{
$saveBlocks['side'] = array();
if( !isset( $saveBlocks[ $saveKey ] ) )
{
$saveBlocks[ $saveKey ] = array();
}
}
$blocks[ \IPS\Member::loggedIn()->member_id ] = $saveBlocks;
\IPS\Settings::i()->acp_dashboard_blocks = json_encode( $blocks );
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => \IPS\Settings::i()->acp_dashboard_blocks ), array( 'conf_key=?', 'acp_dashboard_blocks' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'acp_dashboard_blocks' => json_encode( $blocks ) ) );
if( \IPS\Request::i()->isAjax() )
{