Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+65 -58
View File
@@ -11,16 +11,37 @@
namespace IPS\core\tasks;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\Application;
use IPS\convert\App;
use IPS\Db;
use IPS\File;
use IPS\Http\Url;
use IPS\IPS;
use IPS\Lang;
use IPS\Login;
use IPS\nexus\Gateway;
use IPS\Settings;
use IPS\Task;
use IPS\Theme;
use function defined;
use function get_class;
use function in_array;
use function strpos;
use function strtolower;
use function substr;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* usagereporting Task
*/
class _usagereporting extends \IPS\Task
class usagereporting extends Task
{
/**
* Execute
@@ -31,19 +52,19 @@ class _usagereporting extends \IPS\Task
* Tasks should execute within the time of a normal HTTP request.
*
* @return mixed Message to log or NULL
* @throws \IPS\Task\Exception
* @throws Task\Exception
*/
public function execute()
public function execute() : mixed
{
/* Check usage reporting is enabled */
if ( !\IPS\Settings::i()->usage_reporting )
if ( !Settings::i()->usage_reporting )
{
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'usagereporting' ) );
Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'usagereporting' ) );
return NULL;
}
/* Check this isn't a test install */
$licenseData = \IPS\IPS::licenseKey();
$licenseData = IPS::licenseKey();
if ( \IPS\IN_DEV or !$licenseData or mb_substr( $licenseData['key'], -12 ) === '-TESTINSTALL' )
{
return NULL;
@@ -52,13 +73,13 @@ class _usagereporting extends \IPS\Task
/* Send the report */
try
{
$response = \IPS\Http\Url::external('https://invisionpowerdiagnostics.com/usage/')->request(2)->post( $this->buildReport() ); // Timeout is deliberately very low because we don't care if it times out (but not 0 because we still need to let the DNS resolve)
$response = Url::external('https://invisionpowerdiagnostics.com/usage/')->request(2)->post( $this->buildReport() ); // Timeout is deliberately very low because we don't care if it times out (but not 0 because we still need to let the DNS resolve)
/* If the server has asked us to stop sending reports, then turn it off */
if ( $response->httpResponseCode == 410 )
{
\IPS\Settings::i()->changeValues( array( 'usage_reporting' => 0 ) );
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'usagereporting' ) );
Settings::i()->changeValues( array( 'usage_reporting' => 0 ) );
Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'usagereporting' ) );
}
}
catch ( \IPS\Http\Request\Exception $e )
@@ -74,33 +95,33 @@ class _usagereporting extends \IPS\Task
*
* @return array
*/
final protected function buildReport()
final protected function buildReport() : array
{
/* Identifier which allows us to keep separate reports from this community
from other reports (so we can see how communities change things as they grow) but
does NOT allow us to identify which community is sending the report */
$report = array( 'anonymized_id' => md5( \IPS\Settings::i()->base_url . \IPS\Settings::i()->site_secret_key ) );
$report = array( 'anonymized_id' => md5( Settings::i()->base_url . Settings::i()->site_secret_key ) );
/* Community data */
$licenseData = \IPS\IPS::licenseKey(); // this is just to know if it is *active* and if it is CiC - we don't actually send the license key
$licenseData = IPS::licenseKey(); // this is just to know if it is *active* and if it is CiC - we don't actually send the license key
$report['community'] = array(
'version' => \IPS\Application::load('core')->version,
'installed' => date( 'Y-m-d', \IPS\Settings::i()->board_start ),
'active_license'=> $licenseData ? ( (bool) $licenseData['active'] ) : FALSE,
'cloud' => $licenseData ? ( (bool) $licenseData['cloud'] ) : FALSE,
'version' => Application::load('core')->version,
'installed' => date( 'Y-m-d', Settings::i()->board_start ),
'active_license'=> $licenseData && $licenseData['active'],
'cloud' => $licenseData && $licenseData['cloud'],
);
/* Server Data */
$report['server'] = array(
'php_version' => PHP_VERSION_ID,
'php_extensions' => get_loaded_extensions(),
'mysql_version' => \IPS\Db::i()->server_version,
'mysql_version' => Db::i()->server_version,
'os' => PHP_OS,
);
/* Apps */
$report['apps'] = array();
foreach ( \IPS\Application::applications() as $app )
foreach ( Application::applications() as $app )
{
if ( $app->enabled )
{
@@ -108,41 +129,31 @@ class _usagereporting extends \IPS\Task
}
}
/* Plugins */
$report['plugins'] = array();
foreach ( \IPS\Plugin::plugins() as $plugin )
{
if ( $plugin->enabled )
{
$report['plugins'][ $plugin->location ] = $plugin->version_long;
}
}
/* Themes */
$report['themes'] = array();
foreach ( \IPS\Theme::themes() as $theme )
foreach ( Theme::themes() as $theme )
{
$settings = array();
foreach ( $theme->settings as $k => $v )
{
if ( \in_array( $k, array( 'responsive', 'rounded_photos', 'social_links', 'sidebar_position', 'sidebar_responsive', 'enable_fluid_width', 'fluid_width_size', 'js_incclude', 'ajax_pagination', 'cm_store_view', 'body_font', 'headline_font' ) ) )
if ( in_array( $k, array( 'responsive', 'rounded_photos', 'social_links', 'sidebar_position', 'sidebar_responsive', 'enable_fluid_width', 'fluid_width_size', 'js_incclude', 'ajax_pagination', 'cm_store_view', 'body_font', 'headline_font' ) ) )
{
$settings[ $k ] = $v;
}
}
$report['themes'][] = array(
'customised' => \IPS\Db::i()->select( 'COUNT(*)', 'core_theme_templates', array( 'template_set_id=?', $theme->id ) )->first(),
'customised' => Db::i()->select( 'COUNT(*)', 'core_theme_templates', array( 'template_set_id=?', $theme->id ) )->first(),
'settings' => $settings,
);
}
/* Languages */
$report['languages'] = array();
foreach ( \IPS\Lang::languages() as $lang )
foreach ( Lang::languages() as $lang )
{
$localeDot = \strpos( $lang->short, '.' );
$langKey = $localeDot ? \substr( $lang->short, 0, $localeDot ) : $lang->short;
$localeDot = strpos( $lang->short, '.' );
$langKey = $localeDot ? substr( $lang->short, 0, $localeDot ) : $lang->short;
if ( !isset( $report['languages'][ $langKey ] ) )
{
@@ -152,9 +163,9 @@ class _usagereporting extends \IPS\Task
}
/* Settings */
foreach ( \IPS\Db::i()->select( array( 'conf_key', 'conf_value', 'conf_default', 'conf_app', 'conf_report' ), 'core_sys_conf_settings', 'conf_report IS NOT NULL' ) as $row )
foreach ( Db::i()->select( array( 'conf_key', 'conf_value', 'conf_default', 'conf_app', 'conf_report' ), 'core_sys_conf_settings', 'conf_report IS NOT NULL' ) as $row )
{
if ( \in_array( $row['conf_app'], \IPS\IPS::$ipsApps ) and \IPS\Application::appIsEnabled( $row['conf_app'] ) )
if ( in_array( $row['conf_app'], IPS::$ipsApps ) and Application::appIsEnabled( $row['conf_app'] ) )
{
if ( $row['conf_report'] == 'full' )
{
@@ -168,15 +179,15 @@ class _usagereporting extends \IPS\Task
}
/* Database counts */
foreach ( \IPS\IPS::$ipsApps as $app )
foreach ( IPS::$ipsApps as $app )
{
if ( \IPS\Application::appIsEnabled( $app ) and file_exists( \IPS\ROOT_PATH . "/applications/{$app}/data/schema.json" ) )
if ( Application::appIsEnabled( $app ) and file_exists( \IPS\ROOT_PATH . "/applications/{$app}/data/schema.json" ) )
{
foreach ( json_decode( file_get_contents( \IPS\ROOT_PATH . "/applications/{$app}/data/schema.json" ), TRUE ) as $table => $data )
{
if ( isset( $data['reporting'] ) and $data['reporting'] === 'count' )
{
$report['tables'][ $table ] = \IPS\Db::i()->select( 'COUNT(*)', $table )->first();
$report['tables'][ $table ] = Db::i()->select( 'COUNT(*)', $table )->first();
}
}
}
@@ -184,11 +195,11 @@ class _usagereporting extends \IPS\Task
/* File storage configurations */
$report['files'] = array( 'amazon' => 0, 'database' => 0, 'filesystem' => 0, 'ftp' => 0, 'other' => 0 );
foreach ( \IPS\Application::allExtensions( 'core', 'FileStorage', FALSE ) as $k => $v )
foreach ( Application::allExtensions( 'core', 'FileStorage', FALSE ) as $k => $v )
{
try
{
$class = \strtolower( \substr( \get_class( \IPS\File::getClass( $k ) ), 9 ) );
$class = strtolower( substr( get_class( File::getClass( $k ) ), 9 ) );
if ( isset( $report['files'][ $class ] ) )
{
@@ -199,7 +210,7 @@ class _usagereporting extends \IPS\Task
$report['files']['other']++;
}
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
}
/* Login methods */
@@ -221,9 +232,9 @@ class _usagereporting extends \IPS\Task
$report['login'][ $v ] = 0;
}
$report['login']['other'] = 0;
foreach ( \IPS\Login::methods() as $method )
foreach ( Login::methods() as $method )
{
$class = \get_class( $method );
$class = get_class( $method );
if ( array_key_exists( $class, $loginMethods ) )
{
$report['login'][ $loginMethods[ $class ] ]++;
@@ -236,19 +247,15 @@ class _usagereporting extends \IPS\Task
/* Payment methods */
$report['paymethods'] = array();
if ( \IPS\Application::appIsEnabled('nexus') )
if ( Application::appIsEnabled('nexus') )
{
$report['paymethods'] = array( 'authorizenet_aim' => 0, 'authorizenet_dpm' => 0, 'manual' => 0, 'paypal_standard' => 0, 'paypal_pro' => 0, 'stripe_card' => 0, 'stripe_native' => 0, 'stripe_alipay' => 0, 'stripe_bancontact' => 0, 'stripe_giropay' => 0, 'stripe_ideal' => 0, 'stripe_sofort' => 0, 'test' => 0, 'twocheckout' => 0, 'other' => 0 );
foreach ( \IPS\nexus\Gateway::roots() as $gateway )
$report['paymethods'] = array( 'manual' => 0, 'paypal_standard' => 0, 'paypal_pro' => 0, 'stripe_card' => 0, 'stripe_native' => 0, 'stripe_alipay' => 0, 'stripe_bancontact' => 0, 'stripe_giropay' => 0, 'stripe_ideal' => 0, 'stripe_sofort' => 0, 'test' => 0, 'other' => 0 );
foreach ( Gateway::roots() as $gateway )
{
$class = \strtolower( \substr( \get_class( $gateway ), 18 ) );
$class = strtolower( substr( get_class( $gateway ), 18 ) );
$settings = json_decode( $gateway->settings, TRUE );
if ( $class === 'authorizenet' )
{
$class = ( $settings['method'] === 'AIM' ) ? 'authorizenet_aim' : 'authorizenet_dpm';
}
elseif ( $class === 'paypal' )
if ( $class === 'paypal' )
{
$class = ( $settings['type'] === 'paypal' ) ? 'paypal_standard' : 'paypal_pro';
}
@@ -271,12 +278,12 @@ class _usagereporting extends \IPS\Task
/* Converters */
$report['converters'] = array();
if ( \IPS\Application::appIsEnabled('convert') )
if ( Application::appIsEnabled('convert') )
{
foreach( \IPS\convert\App::apps() as $app )
foreach( App::apps() as $app )
{
/* Some legacy converters may not have the correct sw key */
if( !\in_array( $app->sw, \IPS\IPS::$ipsApps ) OR !$app->finished )
if( !in_array( $app->sw, IPS::$ipsApps ) OR !$app->finished )
{
continue;
}