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

+59 -35
View File
@@ -11,7 +11,7 @@
namespace IPS\core\Setup;
/* 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;
@@ -30,6 +30,12 @@ class _Install
public static function systemRequirements()
{
$return = array();
/* We don't need to check the CIC platform */
if( \IPS\CIC )
{
return array( 'recommendations' => array(), 'requirements' => array() );
}
/* PHP Version */
$phpVersion = PHP_VERSION;
@@ -53,16 +59,25 @@ class _Install
$return['requirements']['PHP']['version']['message'] = \IPS\Member::loggedIn()->language()->addToStack( 'requirements_php_version_success', FALSE, array( 'sprintf' => array( $phpVersion ) ) );
$return['advice']['php'] = \IPS\Member::loggedIn()->language()->addToStack( 'requirements_php_version_advice', FALSE, array( 'sprintf' => array( $phpVersion, $requirements['php']['recommended'] ) ) );
}
/* We require file_uploads otherwise lots of stuff won't work */
if( !ini_get('file_uploads') OR mb_strtolower( ini_get('file_uploads') ) == 'off' )
{
$return['requirements']['PHP'][] = array(
'success' => FALSE,
'message' => \IPS\Member::loggedIn()->language()->addToStack( 'requirements_file_uploads' ),
);
}
/* cURL or allow_url_fopen */
if ( extension_loaded('curl') and $version = curl_version() and version_compare( $version['version'], '7.36', '>=' ) )
if ( \extension_loaded('curl') and $version = curl_version() and version_compare( $version['version'], '7.36', '>=' ) )
{
$return['requirements']['PHP'][] = array(
'success' => TRUE,
'message' => \IPS\Member::loggedIn()->language()->addToStack( 'requirements_curl_success' ),
);
}
elseif ( function_exists('fsockopen') )
elseif ( \function_exists('fsockopen') )
{
$return['requirements']['PHP'][] = array(
'success' => TRUE,
@@ -80,9 +95,9 @@ class _Install
}
/* mbstring can be configured with --disable-mbregex */
if ( extension_loaded( 'mbstring' ) )
if ( \extension_loaded( 'mbstring' ) )
{
if ( function_exists( 'mb_eregi' ) )
if ( \function_exists( 'mb_eregi' ) )
{
$return['requirements']['PHP'][] = array(
'success' => TRUE,
@@ -121,7 +136,7 @@ class _Install
{
foreach ( $extensions as $extension )
{
if ( extension_loaded( $extension ) )
if ( \extension_loaded( $extension ) )
{
$return['requirements']['PHP'][] = array(
'success' => TRUE,
@@ -149,12 +164,6 @@ class _Install
}
}
/* Recommend GD freetype */
if( extension_loaded('gd') AND !function_exists( 'imagettfbbox' ) )
{
$return['advice'][] = \IPS\Member::loggedIn()->language()->addToStack( 'requirements_missing_imagettfbbox' );
}
/* Memory Limit */
$_memoryLimit = @ini_get('memory_limit');
$memoryLimit = $_memoryLimit;
@@ -163,19 +172,19 @@ class _Install
preg_match( "#^(\d+)(\w+)$#", mb_strtolower($memoryLimit), $match );
if( $match[2] == 'g' )
{
$memoryLimit = intval( $memoryLimit ) * 1024 * 1024 * 1024;
$memoryLimit = \intval( $memoryLimit ) * 1024 * 1024 * 1024;
}
else if ( $match[2] == 'm' )
{
$memoryLimit = intval( $memoryLimit ) * 1024 * 1024;
$memoryLimit = \intval( $memoryLimit ) * 1024 * 1024;
}
else if ( $match[2] == 'k' )
{
$memoryLimit = intval( $memoryLimit ) * 1024;
$memoryLimit = \intval( $memoryLimit ) * 1024;
}
else
{
$memoryLimit = intval( $memoryLimit );
$memoryLimit = \intval( $memoryLimit );
}
}
if ( $memoryLimit >= ( 128 * 1024 * 1024 ) OR $memoryLimit == -1 )
@@ -194,7 +203,7 @@ class _Install
}
/* Suhosin */
if ( extension_loaded( 'suhosin' ) )
if ( \extension_loaded( 'suhosin' ) )
{
foreach ( array(
'suhosin.post.max_vars' => 4096,
@@ -301,7 +310,7 @@ class _Install
public function __construct( $apps, $defaultApp, $baseUrl, $path, $db, $adminName, $adminPass, $adminEmail, $diagnostics=TRUE )
{
/* Have core app? */
if ( !in_array( 'core', $apps ) )
if ( !\in_array( 'core', $apps ) )
{
throw new \InvalidArgumentException( 'NO_CORE_APP' );
}
@@ -347,7 +356,7 @@ class _Install
/**
* Process
*
* @param array Multiple-Redirector Data
* @param array $data Multi-redirector data
* @return array|null Multiple-Redirector Data or NULL indicates done
*/
public function process( $data )
@@ -359,7 +368,7 @@ class _Install
}
/* Run the step */
$step = intval( $data[0] );
$step = \intval( $data[0] );
if ( $step == 13 )
{
@@ -369,7 +378,8 @@ class _Install
{
throw new \BadMethodCallException( 'NO_STEP' );
}
$response = call_user_func( array( $this, "step{$step}" ), $data );
$stepFunction = "step{$step}";
$response = $this->$stepFunction( $data );
return array( $response, ( $this->customTitle ) ? $this->customTitle : \IPS\Member::loggedIn()->language()->addToStack( 'install_step_' . $step ), ( ( ( 100/12 ) * $data[0] + ( ( 100/12 ) / 100 * $this->stepProgress ) ) ) ?: 1 );
}
@@ -377,7 +387,7 @@ class _Install
/**
* App Looper
*
* @param array data Multiple-Redirector Data
* @param array $data Multiple-Redirector Data
* @param callback $code Code to execute for each app
* @return array Data to Multiple-Redirector Data
*/
@@ -388,7 +398,7 @@ class _Install
$returnNext = FALSE;
foreach ( $this->apps as $app )
{
$this->stepProgress += ( 100 / count( $this->apps ) );
$this->stepProgress += ( 100 / \count( $this->apps ) );
if ( !isset( $data[1] ) )
{
@@ -396,9 +406,9 @@ class _Install
}
elseif ( $data[1] == $app )
{
$val = call_user_func( $code, $app );
$val = $code( $app );
if ( is_array( $val ) )
if ( \is_array( $val ) )
{
return $val;
}
@@ -420,12 +430,13 @@ class _Install
* Step 1
* Create database
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step1( $data )
{
$this->stepProgress = 0;
$perAppProgress = floor( 100 / count( $this->apps ) );
$perAppProgress = floor( 100 / \count( $this->apps ) );
$returnNext = FALSE;
foreach ( $this->apps as $app )
@@ -448,9 +459,9 @@ class _Install
if ( file_exists( \IPS\ROOT_PATH . "/applications/{$app}/data/schema.json" ) )
{
$schema = json_decode( file_get_contents( \IPS\ROOT_PATH . "/applications/{$app}/data/schema.json" ), TRUE );
if ( count( $schema ) )
if ( \count( $schema ) )
{
$perTableProgress = ( $perAppProgress / count( $schema ) );
$perTableProgress = ( $perAppProgress / \count( $schema ) );
$i = 0;
foreach( $schema as $dbTable )
{
@@ -470,7 +481,7 @@ class _Install
{
$adminName = $this->adminName;
\IPS\Db::i()->insert( $dbTable['name'], array_map( function( $column ) use( $adminName ) {
if( !is_string( $column ) )
if( !\is_string( $column ) )
{
return $column;
}
@@ -513,7 +524,7 @@ class _Install
}
}
if( isset( $instruction['params'][1] ) and is_array( $instruction['params'][1] ) )
if( isset( $instruction['params'][1] ) and \is_array( $instruction['params'][1] ) )
{
$groups = array_filter( iterator_to_array( \IPS\Db::i()->select( 'g_id', 'core_groups' ) ), function( $groupId ) {
if( $groupId == 2 )
@@ -532,8 +543,10 @@ class _Install
}
}
}
call_user_func_array( array( \IPS\Db::i(), $instruction['method'] ), $instruction['params'] );
$method = $instruction['method'];
$params = $instruction['params'];
\IPS\Db::i()->$method( ...$params );
}
}
@@ -552,6 +565,7 @@ class _Install
* Step 2
* Insert application and module data
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step2( $data )
@@ -616,6 +630,7 @@ class _Install
* Step 3
* Insert Settings
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step3( $data )
@@ -647,6 +662,7 @@ class _Install
* Step 4
* Create admin account
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step4( $data )
@@ -679,6 +695,7 @@ class _Install
* Step 5
* Create Tasks
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step5( $data )
@@ -695,12 +712,13 @@ class _Install
* Step 6
* Install default Language
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step6( $data )
{
/* Install the default language */
$locales = array( 'en_US', 'en_US.utf8', 'en_US.UTF8', 'english' );
$locales = array( 'en_US', 'en_US.UTF-8', 'en_US.UTF8', 'en_US.utf8', 'english' );
foreach ( $locales as $k => $localeCode )
{
try
@@ -738,6 +756,7 @@ class _Install
* Step 7
* Create Languages
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step7( $data )
@@ -767,6 +786,7 @@ class _Install
* Step 8
* Create Email Templates
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step8( $data )
@@ -782,6 +802,7 @@ class _Install
* Step 9
* Create Themes
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step9( $data )
@@ -818,6 +839,7 @@ class _Install
* Step 10
* Create Javascript
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step10( $data )
@@ -848,6 +870,7 @@ class _Install
* Step 11
* Create Search Keywords
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step11( $data )
@@ -863,6 +886,7 @@ class _Install
* Step 12
* Install any widgets/extensions that need adding on install
*
* @param array $data Multi-redirector data
* @return array Multiple-Redirector Data
*/
protected function step12( $data )
@@ -919,7 +943,7 @@ class _Install
);
}
if( count( $inserts ) )
if( \count( $inserts ) )
{
\IPS\Db::i()->insert( 'core_emoticons', $inserts );
}
@@ -929,7 +953,7 @@ class _Install
{
$fileObj = \IPS\File::create( 'core_Reaction', "react_{$reaction}.png", file_get_contents( \IPS\ROOT_PATH . '/' . \IPS\CP_DIRECTORY . "/install/reaction/react_{$reaction}.png" ), 'reactions', FALSE, NULL, FALSE );
$id = \IPS\Db::i()->insert( 'core_reactions', array(
'reaction_value' => ( in_array( $reaction, array( 'confused', 'sad' ) ) ) ? 0 : 1,
'reaction_value' => ( \in_array( $reaction, array( 'confused', 'sad' ) ) ) ? 0 : 1,
'reaction_icon' => (string) $fileObj,
'reaction_position' => ++$position,
'reaction_enabled' => 1,