Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,16 +11,31 @@
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
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\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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader: License
|
||||
*/
|
||||
class _license extends \IPS\Dispatcher\Controller
|
||||
class license extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -28,12 +43,12 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* Check license key */
|
||||
if( \IPS\Db::i()->checkForTable( 'core_store' ) )
|
||||
if( Db::i()->checkForTable( 'core_store' ) )
|
||||
{
|
||||
$licenseData = \IPS\IPS::licenseKey( TRUE );
|
||||
$licenseData = IPS::licenseKey( TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -41,10 +56,10 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$license = \IPS\Db::i()->select( '*', 'cache_store', array( 'cs_key=?', 'licenseData' ) )->first();
|
||||
$license = Db::i()->select( '*', 'cache_store', array( 'cs_key=?', 'licenseData' ) )->first();
|
||||
$licenseData = unserialize( $license['cs_value'] );
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception $e ){}
|
||||
}
|
||||
|
||||
if( isset( $licenseData['key'] ) AND !isset( $licenseData['expires'] ) )
|
||||
@@ -64,10 +79,9 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
if ( !$active )
|
||||
{
|
||||
$response = NULL;
|
||||
$active = NULL;
|
||||
$form = new \IPS\Helpers\Form( 'licensekey', 'continue' );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ipb_reg_number', NULL, TRUE, array(), function( $val ){
|
||||
\IPS\IPS::checkLicenseKey( $val, \IPS\Settings::i()->base_url );
|
||||
$form = new Form( 'licensekey', 'continue' );
|
||||
$form->add( new Text( 'ipb_reg_number', NULL, TRUE, array(), function( $val ){
|
||||
IPS::checkLicenseKey( $val, Settings::i()->base_url );
|
||||
} ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
@@ -83,10 +97,10 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Refresh the locally stored license info */
|
||||
if( \IPS\Db::i()->checkForTable( 'core_store' ) )
|
||||
if( Db::i()->checkForTable( 'core_store' ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->license_data );
|
||||
$licenseData = \IPS\IPS::licenseKey();
|
||||
unset( Store::i()->license_data );
|
||||
$licenseData = IPS::licenseKey();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -107,29 +121,29 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
if( $active )
|
||||
{
|
||||
/* Clear any caches or else we might not see new versions on the next screen */
|
||||
if ( isset( \IPS\Data\Store::i()->applications ) )
|
||||
if ( isset( Store::i()->applications ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->applications );
|
||||
unset( Store::i()->applications );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=applications" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
Output::i()->redirect( Url::internal( "controller=applications" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('license');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->license( $form, $active );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('license');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->license( $form, $active );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve license data from license server
|
||||
*
|
||||
* @return mixed
|
||||
* @return array|null
|
||||
*/
|
||||
protected function getLicenseData()
|
||||
protected function getLicenseData() : ?array
|
||||
{
|
||||
/* Call the main server */
|
||||
try
|
||||
{
|
||||
$response = \IPS\Http\Url::ips( 'license/' . \IPS\Settings::i()->ipb_reg_number )->request()->get();
|
||||
$response = Url::ips( 'license/' . Settings::i()->ipb_reg_number )->request()->get();
|
||||
if ( $response->httpResponseCode == 404 )
|
||||
{
|
||||
$licenseData = NULL;
|
||||
@@ -139,7 +153,7 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
$licenseData = $response->decodeJson();
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$licenseData = NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user