Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+132 -129
View File
@@ -48,32 +48,32 @@ use function trait_exists;
* Class to contain Invision Community autoloader and exception handler
*/
class IPS
{
{
/**
* @brief Unique key for this suite (used in http requests to defy browser caching)
*/
public static ?string $suiteUniqueKey = NULL;
/**
* @brief Developer Code to be added to all namespaces
*/
private static string $inDevCode = '';
/**
* @brief Namespaces developer code has been imported to
*/
private static array $inDevCodeImportedTo = array();
/**
* @brief Vendors to use PSR-0 autoloader for
*/
public static array $PSR0Namespaces = array();
/**
* @brief Community in the Cloud configuration
*/
public static array $cicConfig = array();
/**
* @brief IPS Applications
*/
@@ -117,7 +117,7 @@ class IPS
{
$redisMaxConnectionAttempts = (int) self::$cicConfig['redis']['max_connection_attempts'];
}
$redisConfig = self::compileCicRedisConfig();
}
@@ -136,12 +136,12 @@ class IPS
}
else
{
$uniqueKey = preg_match( '/^\/var\/www\/html\/(.+?)$/i', __DIR__, $matches ) ? str_replace( '/', '', $matches[1] ) : mb_substr( md5( '13_chocapikk' . '$Rev: 3023$'), 10, 10 );
$uniqueKey = preg_match( '/^\/var\/www\/html\/(.+?)$/i', __DIR__, $matches ) ? str_replace( '/', '', $matches[1] ) : mb_substr( md5( '13_mafia' . '$Rev: 3023$'), 10, 10 );
}
}
else
{
$uniqueKey = mb_substr( md5( '13_chocapikk' . '$Rev: 3023$'), 10, 10 );
$uniqueKey = mb_substr( md5( '13_mafia' . '$Rev: 3023$'), 10, 10 );
}
$staticKey = null;
@@ -149,61 +149,61 @@ class IPS
{
$staticKey = self::$cicConfig['static_key'];
}
// ==========================================================================================
// Default system constants. Any of these can be modified by defining them in a constants.php
// file placed in the root directory (doing this allows their values to remain unchanged by
// future upgrades)
return array(
//--------------------------------------------------------------------------------------
// GENERAL OPTIONS: CAN BE CHANGED
// We would like to make these "actual" settings but we need their values before doing
// any other initialisation.
// Use beta releases?
// If enabled, the upgrader in the AdminCP will prompt you to upgrade to beta releases
// in addition to normal releases.
'USE_DEVELOPMENT_BUILDS' => FALSE,
// Recovery mode
// Will turn off third party customisations if one is causing an issue that prevents
// accessing the AdminCP. See https://remoteservices.invisionpower.com/docs/recovery_mode
'RECOVERY_MODE' => FALSE,
// Disable two-factor authentication?
// Can be used if you ever lock yourself out of your account
'DISABLE_MFA' => FALSE,
// Error page
// If a really bad error occurs, this is our final fallback for what to show. You can
// change it if you want to translate or otherwise customise it.
'ERROR_PAGE' => 'error.php',
// Upgrading page
// Is shown when upgrade is in process. You can change it if you want to translate
// or otherwise customise it.
'UPGRADING_PAGE' => 'admin/upgrade/upgrading.html',
// Disable login for the upgrader?
// The upgrader can only use the standard login handler so if you have turned that off
// and are using entirely a different login handler, you'll need to enable this so you
// can access the upgrader. See https://remoteservices.invisionpower.com/docs/upgrader_login_help
'BYPASS_UPGRADER_LOGIN' => FALSE,
// Commerce license key API settings
// See https://remoteservices.invisionpower.com/docs/licenseapi
'NEXUS_LKEY_API_DISABLE' => TRUE,
'NEXUS_LKEY_API_CHECK_IP' => TRUE,
'NEXUS_LKEY_API_DISABLE' => TRUE,
'NEXUS_LKEY_API_CHECK_IP' => TRUE,
'NEXUS_LKEY_API_ALLOW_IP_OVERRIDE' => FALSE,
// Encryption key
// In some places we encrypt data. By default the key we use for that is based off
// the database name and password, but that means if you ever change those, the data
// won't be able to be read. So if you *do* change those, you can set this constant
// to md5( old_database_pass + old_database_name ) to fix that.
'TEXT_ENCRYPTION_KEY' => $staticKey,
// Data storage / caching settings
// To change any of the below, go to [AdminCP > System > Advanced Configuration >
// Data storage] and follow the instructions - it will give you a new constants.php
@@ -224,18 +224,21 @@ class IPS
// Sitemap
'SITEMAP_MAX_PER_FILE' => 500, // Maximum number of entries per sitemap file
// Archiving
'DISABLE_ARCHIVING' => FALSE, // Disables archiving and unarchives everything
//--------------------------------------------------------------------------------------
// SERVER ENVIRONMENT OPTIONS: CAN BE CHANGED IF YOU'RE 100% SURE YOU KNOW WHAT YOU'RE DOING
// These constants normally never need to be changed (hence not settings) but sometimes
// we come accross an unusual sever environment where that isn't the case.
// Disable IP address checking when validating the AdminCP sessions?
// See https://remoteservices.invisionpower.com/docs/disable_ip_check
'BYPASS_ACP_IP_CHECK' => FALSE,
// Number of seconds to consider AdminCP sessions valid for
'ACP_SESSION_TIMEOUT' => 3600,
// File permissions
// For example: when making folders for files to be uploaded to, what permissions
// that should be created with
@@ -243,17 +246,17 @@ class IPS
'FOLDER_PERMISSION_NO_WRITE' => 0755, // Non-writeable folders
'IPS_FILE_PERMISSION' => 0666, // Writeable files
'FILE_PERMISSION_NO_WRITE' => 0644, // Non-writeable files
// Log directory
// Normally logging information gets written to the database, but if the database itself
// is down, we fallback to writing to disk. This sets the directory to use.
// {root} can be used for the site's root directory
'LOG_FALLBACK_DIR' => '{root}/uploads/logs',
// Temp directory
// A directory where we can throw temporary files
'TEMP_DIRECTORY' => sys_get_temp_dir(),
// Cookie settings
// The correct value for most of these are automatically detected so customising the
// values should not be necessary except where doing very special customisations like
@@ -262,13 +265,13 @@ class IPS
'COOKIE_PREFIX' => 'ips4_', // A prefix added to all cookie names to prevent conflicts
'COOKIE_PATH' => NULL, // Path from domain to set cookies to. Defaults to wherever the community is
'COOKIE_BYPASS_SSLONLY' => FALSE, // If site is running on https, we set cookies as "secure" (i.e. only sent in https requests) unless this is TRUE
// Threshold for "basic search mode"
// Very big database tables can be very slow to search, so if a value is set here, and
// the core_search_index table has more rows than whatever its value is, we default to
// limiting searches to the last year on the form and via quick search (but users can change) and only sorting by newest, relevance is not an option.
'USE_MYSQL_SEARCH_OPTIMIZED_MODE' => FALSE,
// Maximum number of emails per batch
// Note: changing this will have very little practical effect because the batches will just
// get processed quicker - turning it down won't allow you to workaround server limitation
@@ -289,10 +292,10 @@ class IPS
'REBUILD_SLOW' => 50, // For routines that take a while
'REBUILD_NORMAL' => 250, // For most routines
'REBUILD_QUICK' => 500, // For routines that are fast
// Rate limit (in seconds) for bots on searching
'BOT_SEARCH_FLOOD_SECONDS' => 30,
// Upgrader settings
// When running the upgrader, if it needs to run a query against a table that matches either
// of these conditions, it will tell you to run the query manually (i.e. at the command line)
@@ -305,7 +308,7 @@ class IPS
'DEFAULT_REQUEST_TIMEOUT' => 10, // Default where no other timeout is set
'LONG_REQUEST_TIMEOUT' => 30, // Used for specific API-based calls where we expect a slightly longer response time
'VERY_LONG_REQUEST_TIMEOUT' => 300, // Used for specific API-based calls where we expect a significantly longer response time
// "Don't Write Anything To Disk" Mode
// Can be used for cluster environments where nothing should be written to disk.
// Disables things like installing applications/plugins/themes and writing log files
@@ -313,7 +316,7 @@ class IPS
// to disable log writing, but not in the AdminCP, so installing things is still
// available (facilitated by `IPS::resyncIPSCloud()`)
'NO_WRITES' => ( isset( $_SERVER['IPS_CIC'] ) and !isset( $_SERVER['IPS_CIC_ACP'] ) AND !isset( $_SERVER['IPS_CLOUD2'] ) ),
// How long a task is late running before the admin gets a notification
// CiC is longer as CiC is more closely monitored and delayed tasks are not a symptom of a hosting issue
'TASK_OVERDUE_HOURS' => 36,
@@ -321,23 +324,29 @@ class IPS
// Number of replies when a topic is considered large
'LARGE_TOPIC_REPLIES' => 10000,
// Number of replies when a topic gets locked and split off into another topic
'LARGE_TOPIC_LOCK' => 100000,
// Maximum number of replies that can be made before the topic gets auto-locked
'LARGE_TOPIC_WARNING' => 50,
//--------------------------------------------------------------------------------------
// DEPRECATED OPTIONS: CHANGE AT YOUR OWN RISK
// These constants were once customisable but their fucntionality should now be
// considered deprecated.
// These ones don't do anything at all, but we keep them just in case any third
// party stuff if referencing them
'CONNECT_MASTER_KEY' => NULL,
'CONNECT_MASTER_KEY' => NULL,
'CONNECT_NOSYNC_NAMES' => FALSE,
//--------------------------------------------------------------------------------------
// DEVELOPERS/DEBUGGING: ONLY CHANGE IN LOCAL TEST SITES
// These constants are for developers working on applications and plugins, or debugging.
// They should never be used outside of a local test site as they will cause significant
// speed slow downs, reveal potentially sensitive debugging information, and make
// some features behave unexepectedly
// Enable Developer mode?
// Requires Developer Tools files to be present. See
// https://remoteservices.invisionpower.com/docs/in_dev for more information
@@ -348,13 +357,13 @@ class IPS
// get logged out of the ACP in between requests while working.
// Has no effect if IN_DEV is FALSE
'DEV_DISABLE_ACP_SESSION_TIMEOUT' => FALSE,
// Hide developer mode tools?
// Makes Developer Mode not look like Developer Mode so that IPS developers can take
// screenshots from Developer Mode installs without it looking unappealing.
// Has no effect if IN_DEV is FALSE
'DEV_HIDE_DEV_TOOLS' => FALSE,
// Whoops error handler settings
// When in developer mode, Whoops overrides the normal error handler to provide more
// debugging information. These allow you to change aspects of it.
@@ -367,46 +376,46 @@ class IPS
// Used in developer/test installs to prevent actually sending emails or for debugging
// purposes
'EMAIL_DEBUG_PATH' => NULL,
// Path to where Java is installed
// Needed if you want to build the core application (java will execute a .jar file)
'JAVA_PATH' => "",
// Use friendly URL cache in developer mode?
// Usually should be left off so developers can add new friendly URL definitions
// without rebuilding, but will need to be turned off to test the friendly URL
// configuation features.
// Has no effect if IN_DEV is FALSE
'DEV_USE_FURL_CACHE' => FALSE,
// Use the cache for the "Create" menu in developer mode? Usually should be left
// Use the cache for the "Create" menu in developer mode? Usually should be left
// off so developers can add things to the menu without rebuilding
// Has no effect if IN_DEV is FALSE
'DEV_USE_MENU_CACHE' => FALSE,
// Enable CSS debugging?
// Normally CSS files get loaded all in a single request (as they would in production)
// but this can be used to request them separately for debugging purposes.
// Has no effect if IN_DEV is FALSE
'DEV_DEBUG_CSS' => FALSE,
// Enable JavaScript debugging?
// Dumps lots of information into the console for debugging purposes.
'DEBUG_JS' => FALSE, // This one is used if Developer Mode is OFF (which is why it's FALSE by default)
'DEV_DEBUG_JS' => TRUE, // This one is used if Developer Mode is ON (which is why it's TRUE by default)
// Enable template debugging?
// When in developer mode, templates normally get executed with eval() but that can be
// difficult to debug if it causes an error. With this turned on, each template will get
// written to a PHP file and then that file will be included.
'DEBUG_TEMPLATES' => FALSE,
'DEBUG_CUSTOM_TEMPLATES' => FALSE,
// Enable debug logging?
// Throughout the code we call \IPS\Log::debug() with debug infotmation, but by default
// this doesn't do anything. Turn this on to make that information get logged.
'DEBUG_LOG' => FALSE,
// Enable logging of output headers?
// Logs every header the server is sending (if supported by the server) for
// debugging purposes
@@ -415,7 +424,7 @@ class IPS
// Show debug messages for GraphQL API errors?
// By default, ALL GraphQL errors will show "Internal Server Error". This option will provide more information.
'DEBUG_GRAPHQL' => FALSE,
// Show database queries?
// If enabled, a sidebar is added to every page showing all database queries that page
// is running for debugging purposes
@@ -431,28 +440,27 @@ class IPS
// If enabled, a "Test" caching method will be enabled that just writes cache data to
// somewhere on disk for debugging purposes
'TEST_CACHING' => FALSE,
// Enable test/sandbox mode for Commerce payment gateways?
// Sets all payment gateways into test/sandbox mode and makes a generic "Test Gateway"
// which just acts as if a payment was successful available. Is used in development
// so they can be tested without actually taking any money.
'NEXUS_TEST_GATEWAYS' => FALSE,
// Request two-factor authentication every time
// Normally after performing two-factor authentication you won't be asked again in the
// same session. This overrides that for testing purposes.
'DEV_FORCE_MFA' => FALSE,
// OAuth functionality requires https?
// Used for testing only. Never disable this in a real install - it's a huge security issue.
'OAUTH_REQUIRES_HTTPS' => TRUE,
// Upgrader testing
// All of these are just used by IPS developers to test aspects of the upgrader
'TEST_DELTA_ZIP' => '', // The path to a zip file which will be used by the upgrader rather than downloading a zip from IPS servers
'TEST_DELTA_DETAILS' => NULL, // Array of responses to use for the various version difference tools the upgrader does rather than actually calling them
'DELTA_FORCE_FTP' => FALSE, // Will force the upgrader to ask for FTP details, even if it would be able to just write the files
'UPGRADE_MD5_CHECK' => TRUE, // Can be used to prevent the upgrader checking that the files that are present are correct
'IPS_PASSWORD' => NULL, // Used to authenticate with delta system's backend
'IPS_ALPHA_BUILD' => FALSE, // Are we submitting an alpha build to the delta system's backend?
@@ -464,17 +472,17 @@ class IPS
// These constants only exist so that if their values need to change we only need to
// update one single place rather than everywhere in the code. You should never need
// to change them.
// Is this community running on an Invision Community in the Cloud?
// Used to hardcode some settings, tweak certain explainations of how to do things, etc.
'CIC' => isset( $_SERVER['IPS_CIC'] ),
'CIC2' => ( isset( $_SERVER['IPS_CLOUD2'] ) AND isset( $_SERVER['IPS_CLOUD2_ID'] ) ),
'CIC_EXPERIMENTAL' => FALSE,
'SITE_FILES_PATH' => $sitePath,
// Root path to community
'ROOT_PATH' => __DIR__, // Please use \IPS\Application::getRootPath() instead of the constant in 3rd party code
// Random strings that change every time Invision Community is built
// Used as a prefix in some data storage and cache engines to prevent conflicts, cache
// busting in URLs to resources, etc.
@@ -484,29 +492,29 @@ class IPS
// CACHEBUST_KEY to be a "for reals, will change every release" one. DO NOT set a value
// for it in constants.php
'SUITE_UNIQUE_KEY' => $uniqueKey,
'CACHEBUST_KEY' => mb_substr( md5( '13_chocapikk' . '$Rev: 3023$'), 10, 10 ),
'CACHEBUST_KEY' => mb_substr( md5( '13_mafia' . '$Rev: 3023$'), 10, 10 ),
// Thumbnail size
// This needs to be hardcoded rather than configurable because it's the smallest size that
// will still work based on how we actually use these images.
'PHOTO_THUMBNAIL_SIZE' => 240, // For profile photos. The max we display is 120x120, so this allows for double size for high dpi screens
'THUMBNAIL_SIZE' => '500x500', // For other random things like Downloads screenshots and Pages record images. Is just a generic reasonable size.
// Default theme ID
// It isn't really possible to change this but we have it defined as a constant rather
// than putting "1" everywhere in the code just in case. If you deleted theme ID 1 and attempt to
// build a custom application as a developer, you may need to override this value to specify a new
// default/unmodified theme.
'DEFAULT_THEME_ID' => 1,
// ADDITINAL OAUTH REDIRECT WHICH CAN BE USED FOR DEBUGGING PURPOSES
'DEBUG_OAUTH_REDIRECTS' => [],
//--------------------------------------------------------------------------------------
// SPECIAL MODES: NEVER CHANGE
// These constants are set in certain areas so the framework knows it needs to behave
// differently. They should NEVER be changed globally - very bad things will happen if you do.
// Toggle for if uncaught exceptions should (if enabled) be reported back to IPS
// We set it false here and then enable it at the top of our own scripts so that
// any third-party code which is using the IPS framework *doesn't* have it enabled
@@ -530,7 +538,7 @@ class IPS
);
// ==========================================================================================
}
/**
* Initiate Invision Community constants, autoloader and exception handler
*
@@ -546,7 +554,7 @@ class IPS
/* Define the IN_IPB constant - this needs to be in the global namespace for backwards compatibility */
define( 'IN_IPB', TRUE );
/* Load constants.php */
if ( isset( $_SERVER['IPS_CLOUD2'] ) AND isset( $_SERVER['IPS_CLOUD2_ID'] ) )
{
@@ -564,19 +572,14 @@ class IPS
}
/* Load in our CiC functions */
if ( isset( $_SERVER['IPS_CLOUD2'] ) AND isset( $_SERVER['IPS_CLOUD2_ID'] ) AND file_exists( "/var/www/sitefiles/{$_SERVER['IPS_CLOUD2_ID']}/applications/cloud/sources/functions.php" ) )
{
/* If we are uploading the cloud app manually, we need this */
@include_once( "/var/www/sitefiles/{$_SERVER['IPS_CLOUD2_ID']}/applications/cloud/sources/functions.php" );
}
else if( file_exists( __DIR__ . '/applications/cloud/sources/functions.php' ) )
if( ( isset( $_SERVER['IPS_CLOUD2'] ) AND isset( $_SERVER['IPS_CLOUD2_ID'] ) ) OR file_exists( __DIR__ . '/applications/cloud/sources/functions.php' ) )
{
@require_once( __DIR__ . '/applications/cloud/sources/functions.php' );
}
/* Do we have a CiC config */
self::unpackCicConfig();
/* Import and set defaults */
$defaultConstants = static::defaultConstants();
@@ -597,10 +600,10 @@ class IPS
{
self::$inDevCode = file_get_contents( ROOT_PATH . '/dev/function_overrides.php' );
}
/* Set autoloader */
spl_autoload_register( '\IPS\IPS::autoloader', true, true );
/* Set error handlers */
if ( IN_DEV AND DEV_USE_WHOOPS and file_exists( ROOT_PATH . '/dev/Whoops/Run.php' ) )
{
@@ -640,26 +643,26 @@ class IPS
{
/* Separate by namespace */
$bits = explode( '\\', ltrim( $classname, '\\' ) );
/* If this doesn't belong to us, try a PSR-0 loader or ignore it */
$vendorName = array_shift( $bits );
if( $vendorName !== 'IPS' )
{
{
if ( isset( self::$PSR0Namespaces[ $vendorName ] ) )
{
@include_once( self::$PSR0Namespaces[ $vendorName ] . DIRECTORY_SEPARATOR . implode( DIRECTORY_SEPARATOR, $bits ) . '.php' );
}
return;
}
/* Work out what namespace we're in */
$class = array_pop( $bits );
$namespace = empty( $bits ) ? 'IPS' : ( 'IPS\\' . implode( '\\', $bits ) );
$inDevCode = '';
if( !class_exists( "{$namespace}\\{$class}", FALSE ) )
{
{
/* Locate file */
$path = '';
$sourcesDirSet = FALSE;
@@ -703,10 +706,10 @@ class IPS
}
$sourcesDirSet = TRUE;
}
$path .= "{$bit}/";
}
/* Load it */
$path = substr( $path, 0, -1 ) . '.php';
if( !file_exists( $path ) )
@@ -718,19 +721,19 @@ class IPS
}
}
require_once( $path );
/* Is it an interface? */
if ( interface_exists( "{$namespace}\\{$class}", FALSE ) )
{
return;
}
/* Is it a trait? */
if ( trait_exists( "{$namespace}\\{$class}", FALSE ) )
{
return;
}
/* Is it an enumeration? */
if ( function_exists( 'enum_exists' ) AND enum_exists( "{$namespace}\\{$class}", FALSE ) )
{
@@ -742,7 +745,7 @@ class IPS
{
return;
}
/* Doesn't exist? */
if( !class_exists( "{$namespace}\\{$class}", FALSE ) )
{
@@ -750,7 +753,7 @@ class IPS
}
}
}
/**
* Determine if a file is a part of a third party application or plugin
*
@@ -760,15 +763,15 @@ class IPS
public static function isThirdParty( string $path ): bool
{
$bits = explode( '/', $path );
if ( $bits[0] === 'applications' AND isset( $bits[1] ) AND in_array( $bits[1], static::$ipsApps ) )
{
return FALSE;
}
return TRUE;
}
/**
* @brief $lastError Last error
*/
@@ -788,7 +791,7 @@ class IPS
public static function errorHandler( $errno, $errstr, $errfile, $errline, $trace=NULL )
{
self::$lastError = new ErrorException( $errstr, $errno, 0, $errfile, $errline );
/* We don't care about these in production */
if ( in_array( $errno, array( E_WARNING, E_NOTICE, E_STRICT, E_DEPRECATED ) ) )
{
@@ -800,10 +803,10 @@ class IPS
{
return false;
}
throw self::$lastError;
}
/**
* Exception Handler
*
@@ -818,26 +821,26 @@ class IPS
{
$showMessage = TRUE;
}
$log = static::getExceptionDetails( $exception );
/* Log it (unless it's a MySQL server error) */
if( ! ( $exception instanceof \IPS\Db\Exception and $exception->isServerError() ) )
{
Log::log( $log, 'uncaught_exception' );
}
/* Report it */
try
{
if (
if (
!IN_DEV
and REPORT_EXCEPTIONS === TRUE
and Settings::i()->diagnostics_reporting
and !Settings::i()->theme_designer_mode
and !self::exceptionWasThrownByThirdParty( $exception )
and ( !method_exists( $exception, 'isThirdPartyError' ) or !$exception->isThirdPartyError() )
and ( !method_exists( $exception, 'isServerError' ) or !$exception->isServerError() )
and !self::exceptionWasThrownByThirdParty( $exception )
and ( !method_exists( $exception, 'isThirdPartyError' ) or !$exception->isThirdPartyError() )
and ( !method_exists( $exception, 'isServerError' ) or !$exception->isServerError() )
and !( $exception instanceof ParseError )
)
{
@@ -845,7 +848,7 @@ class IPS
}
}
catch ( \Exception $e ) { }
/* Try to display a friendly error page */
try
{
@@ -898,7 +901,7 @@ class IPS
return $log;
}
/**
* Should a given exception be reported to IPS? Filter out 3rd party etc.
*
@@ -916,7 +919,7 @@ class IPS
'line' => $exception->getLine(),
'backtrace' => str_replace( ROOT_PATH, '', $exception->getTraceAsString() )
) );
if ( $response->httpResponseCode == 410 )
{
Settings::i()->changeValues( array( 'diagnostics_reporting' => 0 ) );
@@ -950,7 +953,7 @@ class IPS
require ROOT_PATH . '/' . ERROR_PAGE;
exit;
}
/**
* Small utility function to check if a class has a trait as PHP doesn't have an operator
* for this and the monkey patching means we can't use class_uses() directly
@@ -961,18 +964,18 @@ class IPS
*/
public static function classUsesTrait( $class, $trait )
{
do
{
do
{
if ( in_array( $trait, class_uses( $class ) ) )
{
return TRUE;
}
}
while( $class = get_parent_class( $class ) );
return FALSE;
}
}
/**
* Get license key data
*
@@ -1014,7 +1017,7 @@ class IPS
catch( \IPS\Db\Exception $e ) {}
return NULL;
}
/* Get the cached value */
$response = NULL;
$cached = NULL;
@@ -1043,7 +1046,7 @@ class IPS
}
}
}
/* If we can't use the cache, call the actual server */
if ( $response === NULL )
{
@@ -1051,7 +1054,7 @@ class IPS
{
/* Prevent a race condition and set the next check cycle to be 10 mins from the 21 day cut off in case this request fails */
Store::i()->license_data = [ 'fetched' => mt_rand( time() - 1813830, time() - 1813770 ), 'data' => $cached['data'] ?? NULL ];
/* Actually call the server */
$response = Url::ips( 'license/' . trim( Settings::i()->ipb_reg_number ) )->request()->get();
if ( $response->httpResponseCode == 404 )
@@ -1093,12 +1096,12 @@ class IPS
/* We wipe the data to prevent a race condition, but the license server failed so restore the data and set to try again in 1 day */
Store::i()->license_data = array( 'fetched' => time() - 1728000, 'data' => ( isset( $cached['data'] ) ? $cached['data'] : NULL ) );
}
/* If the server is offline right now, use the cached value from above */
$response = $cached;
}
}
/* Check it's good */
if ( !empty( $response['legacy'] ) )
{
@@ -1183,11 +1186,11 @@ class IPS
/* AdminCP Notifications table may not exist yet if upgrading */
catch( \IPS\Db\Exception $e ) {}
}
/* Return */
return $response;
}
/**
* Check license key
*
@@ -1200,7 +1203,7 @@ class IPS
{
// For what? :)
return;
$test = FALSE;
if ( mb_substr( $val, -12 ) === '-TESTINSTALL' )
{
@@ -1208,7 +1211,7 @@ class IPS
$val = mb_substr( $val, 0, -12 );
}
$urlKey = $test ? 'test_url' : 'url';
try
{
$response = Url::ips( 'license/' . $val )->setQueryString( $urlKey, $url )->request()->get();
@@ -1220,7 +1223,7 @@ class IPS
{
throw new DomainException( 'license_key_legacy' );
}
if ( !$response[ $urlKey ] )
{
Url::ips( 'license/' . $val )->request()->post( array(
@@ -1236,15 +1239,15 @@ class IPS
) );
}
else
{
{
throw new DomainException( $test ? 'license_key_test_active' : 'license_key_active' );
}
}
break;
case 404:
throw new DomainException( 'license_key_not_found' );
default:
throw new DomainException( 'license_generic_error' );
}
@@ -1262,7 +1265,7 @@ class IPS
* @return string|NULL string = application directory
*/
public static function exceptionWasThrownByThirdParty( $exception )
{
{
$trace = $exception->getTraceAsString();
/* Did this happen in a custom app? */
@@ -1317,7 +1320,7 @@ class IPS
applyLatestFilesIPSCloud( $version );
}
}
/**
* Get CiCloud User
*
@@ -1348,7 +1351,7 @@ class IPS
/**
* Compile Redis Config
*
*
* @return array
*/
final public static function compileCicRedisConfig()
@@ -1375,7 +1378,7 @@ class IPS
return TRUE;
}
/**
* Check third party
*
@@ -1387,10 +1390,10 @@ class IPS
{
return checkThirdParty( $upgrade );
}
return TRUE;
}
/**
* Is Managed
*
@@ -1402,7 +1405,7 @@ class IPS
{
return isManaged();
}
return FALSE;
}