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

+127 -12
View File
@@ -11,7 +11,7 @@
namespace IPS\core\tasks;
/* 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;
@@ -26,6 +26,11 @@ class _updatecheck extends \IPS\Task
* @brief Type to send to update server
*/
public $type = 'task';
/**
* @brief Cache marketplace controller
*/
protected $_marketplaceController = null;
/**
* Execute
@@ -54,30 +59,40 @@ class _updatecheck extends \IPS\Task
{
$url = $url->setQueryString( 'development', 1 );
}
if ( \IPS\IPS_ALPHA_BUILD )
{
$url = $url->setQueryString( 'alpha', 1 );
}
try
{
$response = $url->setQueryString( 'version', $version )->request()->get()->decodeJson();
$coreApp = \IPS\Application::load('core');
$currentDetails = json_decode( $coreApp->update_version, TRUE );
$coreApp->update_version = json_encode( $response );
$coreApp->update_last_check = time();
$coreApp->save();
/* Send a notification email if the last available release just changed */
if ( $updates = $coreApp->availableUpgrade() and count( $updates ) and \IPS\Settings::i()->upgrade_email AND $currentDetails['version'] != $response['version'] )
/* Send a notification if new version is available */
if ( $updates = $coreApp->availableUpgrade() and \count( $updates ) )
{
\IPS\Email::buildFromTemplate( 'core', 'upgrade', array( $updates, $coreApp->availableUpgrade( TRUE )['version'] ), \IPS\Email::TYPE_LIST )->send( explode( ',', \IPS\Settings::i()->upgrade_email ) );
\IPS\core\AdminNotification::send( 'core', 'NewVersion', NULL, FALSE );
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'NewVersion' );
}
}
catch ( \Exception $e ) { }
$updateChecked = [];
/* Do everything else */
foreach ( \IPS\Db::i()->union(
array(
\IPS\Db::i()->select( "'core_applications' AS `table`, app_directory AS `id`, app_update_check AS `url`, app_update_last_check AS `last`, app_long_version AS `current`", 'core_applications', "( app_update_check<>'' AND app_update_check IS NOT NULL )" ),
\IPS\Db::i()->select( "'core_plugins' AS `table`, plugin_id AS id, plugin_update_check as url, plugin_update_check_last AS last, plugin_version_long AS `current`", 'core_plugins', "plugin_update_check<>'' AND plugin_update_check IS NOT NULL" ),
\IPS\Db::i()->select( "'core_themes' AS `table`, set_id AS `id`, set_update_check AS `url`, set_update_last_check AS `last`, set_long_version AS `current`", 'core_themes', "set_update_check<>'' AND set_update_check IS NOT NULL" )
\IPS\Db::i()->select( "'core_applications' AS `table`, app_directory AS `id`, app_update_check AS `url`, app_update_last_check AS `last`, app_long_version AS `current`, app_marketplace_id as `marketplace_id`", 'core_applications', "( app_update_check<>'' AND app_update_check IS NOT NULL ) OR app_marketplace_id IS NOT NULL" ),
\IPS\Db::i()->select( "'core_plugins' AS `table`, plugin_id AS id, plugin_update_check as url, plugin_update_check_last AS last, plugin_version_long AS `current`, plugin_marketplace_id as `marketplace_id`", 'core_plugins', "(plugin_update_check<>'' AND plugin_update_check IS NOT NULL ) OR plugin_marketplace_id IS NOT NULL" ),
\IPS\Db::i()->select( "'core_themes' AS `table`, set_id AS `id`, set_update_check AS `url`, set_update_last_check AS `last`, set_long_version AS `current`, set_marketplace_id as `marketplace_id`", 'core_themes', "(set_update_check<>'' AND set_update_check IS NOT NULL ) OR set_marketplace_id IS NOT NULL" ),
\IPS\Db::i()->select( "'core_sys_lang' AS `table`, lang_id AS `id`, `lang_update_url` AS `url`, `lang_update_check` AS `last`, `lang_version_long` AS `current`, `lang_marketplace_id` as `marketplace_id`", "core_sys_lang", "(lang_update_url<>'' AND lang_update_url IS NOT NULL ) OR lang_marketplace_id IS NOT NULL" )
),
'last ASC',
3
@@ -89,6 +104,8 @@ class _updatecheck extends \IPS\Task
$dataColumn = 'app_update_version';
$timeColumn = 'app_update_last_check';
$idColumn = 'app_directory';
$updateChecked[] = 'applications';
$object = \IPS\Application::load( $row['id'] );
/* Account for legacy applications */
try
@@ -110,7 +127,9 @@ class _updatecheck extends \IPS\Task
$dataColumn = 'plugin_update_check_data';
$timeColumn = 'plugin_update_check_last';
$idColumn = 'plugin_id';
$source = \IPS\Plugin::load( $row['id'] )->name;
$object = \IPS\Plugin::load( $row['id'] );
$source = $object->name;
$updateChecked[] = 'plugins';
break;
case 'core_themes':
@@ -119,14 +138,55 @@ class _updatecheck extends \IPS\Task
$idColumn = 'set_id';
$key = "core_theme_set_title_{$row['id']}";
$source = \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( $key );
$updateChecked[] = 'themes';
break;
case 'core_sys_lang':
$dataColumn = 'lang_update_data';
$timeColumn = 'lang_update_check';
$idColumn = 'lang_id';
$source = \IPS\Lang::load( $row['id'] )->name;
$updateChecked[] = 'languages';
break;
}
try
{
/* Query the marketplace */
if( $row['marketplace_id'] )
{
if( $this->_marketplaceController === null )
{
$this->_marketplaceController = new \IPS\core\modules\admin\marketplace\marketplace;
}
/* Get update information */
try
{
$response = $this->_marketplaceController->_updateCheck( $row['marketplace_id'], $row['current'] );
}
catch( \Throwable $e )
{
throw new \RuntimeException( $e->getMessage(), $e->getCode() );
}
/* Use a local update URL */
$response['updateurl'] = (string) \IPS\Http\Url::internal("app=core&module=marketplace&controller=marketplace&do=viewFile&id={$row['marketplace_id']}");
if( isset( $object ) AND isset( $response['disableresource'] ) AND $response['disableresource'] === TRUE )
{
$object->_enabled = FALSE;
$object->save();
}
}
/* Query the applications update URL */
$url = \IPS\Http\Url::external( $row['url'] )->setQueryString( array( 'version' => $row['current'], 'ips_version' => $version ) );
$response = $url->request()->get()->decodeJson();
else
{
$url = \IPS\Http\Url::external( $row['url'] )->setQueryString( array( 'version' => $row['current'], 'ips_version' => $version ) );
$response = $url->request()->get()->decodeJson();
}
/* Unset the object so it isn't present for next update check. */
unset( $object );
/* Did we get all the information we need? */
if ( !isset( $response['version'], $response['longversion'], $response['released'], $response['updateurl'] ) )
@@ -157,6 +217,61 @@ class _updatecheck extends \IPS\Task
), array( "{$idColumn}=?", $row['id'] ) );
}
}
/* Reset Menu Cache */
foreach( $updateChecked as $type )
{
$key = 'updatecount_' . $type;
unset( \IPS\Data\Store::i()->$key, \IPS\Data\Store::i()->$type );
}
/* Check for bulletins while we're here */
try
{
$bulletins = \IPS\Http\Url::ips('bulletin')->request()->get()->decodeJson();
$knownBulletins = iterator_to_array( \IPS\Db::i()->select( 'id', 'core_ips_bulletins' ) );
foreach ( $bulletins as $id => $bulletin )
{
if ( \in_array( $id, $knownBulletins ) )
{
break;
}
try
{
if ( @eval( $bulletin['conditions'] ) )
{
\IPS\core\AdminNotification::send( 'core', 'Bulletin', $id, FALSE );
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'Bulletin', $id );
}
}
catch ( \Exception $e )
{
\IPS\Log::log( $e, 'bulletin' );
}
catch ( \Throwable $e )
{
\IPS\Log::log( $e, 'bulletin' );
}
\IPS\Db::i()->insert( 'core_ips_bulletins', array(
'id' => $id,
'title' => $bulletin['title'],
'body' => $bulletin['body'],
'severity' => $bulletin['severity'],
'style' => $bulletin['style'],
'dismissible' => $bulletin['dismissible'],
'link' => $bulletin['link'],
'conditions' => $bulletin['conditions'],
'cached' => time()
) );
}
}
catch( \RuntimeException $e ) { }
if ( !empty( $fails ) )
{