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

@@ -11,35 +11,53 @@
namespace IPS\core\modules\admin\settings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Application;
use IPS\core\AdminNotification;
use IPS\Data\Store;
use IPS\Dispatcher;
use IPS\Dispatcher\Controller;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Text;
use IPS\Http\Url;
use IPS\IPS;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Settings;
use IPS\Theme;
use function defined;
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;
}
/**
* licensekey
*/
class _licensekey extends \IPS\Dispatcher\Controller
class licensekey extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* @brief Data about the license key from the store
*/
protected $licenseData = array();
protected array $licenseData = array();
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'licensekey_manage' );
Dispatcher::i()->checkAcpPermission( 'licensekey_manage' );
parent::execute();
}
@@ -48,42 +66,43 @@ class _licensekey extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
/* Get license info. If license info is empty, refresh it. */
$licenseData = \IPS\IPS::licenseKey();
$licenseData = IPS::licenseKey();
/* If no license key has been supplied yet just show the form */
if( !\IPS\Settings::i()->ipb_reg_number )
if( !Settings::i()->ipb_reg_number )
{
return $this->settings();
$this->settings();
return;
}
/* Init */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('license_settings');
\IPS\Output::i()->sidebar['actions'] = array(
Output::i()->title = Member::loggedIn()->language()->addToStack('license_settings');
Output::i()->sidebar['actions'] = array(
'refresh' => array(
'icon' => 'refresh',
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=licensekey&do=refresh' )->csrf(),
'link' => Url::internal( 'app=core&module=settings&controller=licensekey&do=refresh' )->csrf(),
'title' => 'license_refresh',
),
'remove' => array(
'icon' => 'pencil',
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=licensekey&do=settings' ),
'link' => Url::internal( 'app=core&module=settings&controller=licensekey&do=settings' ),
'title' => 'license_change',
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('license_change') )
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('license_change') )
),
);
/* If we have a license key, but the server doesn't recognise it, show an error */
if ( !$licenseData )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( 'license_not_recognised', 'error' );
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->message( 'license_not_recognised', 'error' );
}
/* Otherwise show the normal info */
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'licensekey', 'core' )->overview( $licenseData );
Output::i()->output = Theme::i()->getTemplate( 'licensekey', 'core' )->overview( $licenseData );
}
}
@@ -92,22 +111,22 @@ class _licensekey extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function refresh()
protected function refresh() : void
{
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
/* Fetch the license key data and update our local storage */
\IPS\IPS::licenseKey( TRUE );
IPS::licenseKey( TRUE );
/* Return the overview screen afterwards */
if ( isset( \IPS\Request::i()->return ) and \IPS\Request::i()->return === 'cloud' and \IPS\Application::appIsEnabled('cloud') )
if ( isset( Request::i()->return ) and Request::i()->return === 'cloud' and Application::appIsEnabled('cloud') )
{
\IPS\cloud\Application::toggleDisabledApps();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cloud&module=smartcommunity&controller=smartcommunity' ), 'cloud_license_refreshed' );
Output::i()->redirect( Url::internal( 'app=cloud&module=smartcommunity&controller=smartcommunity' ), 'cloud_license_refreshed' );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=licensekey' ), 'license_key_refreshed' );
Output::i()->redirect( Url::internal( 'app=core&module=settings&controller=licensekey' ), 'license_key_refreshed' );
}
}
@@ -116,32 +135,12 @@ class _licensekey extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function settings()
protected function settings() : void
{
$form = new \IPS\Helpers\Form;
$form->addHeader('ipb_license_edit_main');
$form->add( new \IPS\Helpers\Form\Text( 'ipb_reg_number', \IPS\Settings::i()->ipb_reg_number, TRUE ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_active', \IPS\Settings::i()->ipb_license_active ) );
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_expires', \IPS\Settings::i()->ipb_license_expires ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_cloud', \IPS\Settings::i()->ipb_license_cloud ) );
$form->addHeader('ipb_license_urls');
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_url', \IPS\Settings::i()->ipb_license_url ) );
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_test_url', \IPS\Settings::i()->ipb_license_test_url ) );
$form->addHeader('ipb_license_components');
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_forums', \IPS\Settings::i()->ipb_license_product_forums ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_calendar', \IPS\Settings::i()->ipb_license_product_calendar ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_blog', \IPS\Settings::i()->ipb_license_product_blog ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_gallery', \IPS\Settings::i()->ipb_license_product_gallery ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_downloads', \IPS\Settings::i()->ipb_license_product_downloads ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_cms', \IPS\Settings::i()->ipb_license_product_cms ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_nexus', \IPS\Settings::i()->ipb_license_product_nexus ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_copyright', \IPS\Settings::i()->ipb_license_product_copyright ) );
$form->addHeader('ipb_license_services');
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_chat_limit', \IPS\Settings::i()->ipb_license_chat_limit ) );
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_support', \IPS\Settings::i()->ipb_license_support ) );
$form = new Form;
$form->add( new Text( 'ipb_reg_number', NULL, TRUE, array(), function( $val ){
IPS::checkLicenseKey( $val, Settings::i()->base_url );
} ) );
if ( $values = $form->values() )
{
@@ -153,17 +152,17 @@ class _licensekey extends \IPS\Dispatcher\Controller
}
$form->saveAsSettings( $values );
\IPS\Session::i()->log( 'acplogs__license_settings' );
Session::i()->log( 'acplogs__license_settings' );
/* Refresh the locally stored license info */
unset( \IPS\Data\Store::i()->license_data );
unset( Store::i()->license_data );
\IPS\core\AdminNotification::remove( 'core', 'License', 'missing' );
AdminNotification::remove( 'core', 'License', 'missing' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=licensekey' ), 'saved' );
Output::i()->redirect( Url::internal( 'app=core&module=settings&controller=licensekey' ), 'saved' );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('license_settings');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'menu__core_settings_licensekey', $form );
Output::i()->title = Member::loggedIn()->language()->addToStack('license_settings');
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'menu__core_settings_licensekey', $form );
}
}