Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Hosting;
|
||||
|
||||
/* 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;
|
||||
@@ -23,6 +23,19 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _Server extends \IPS\Node\Model
|
||||
{
|
||||
/**
|
||||
* Server Types
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function serverTypes()
|
||||
{
|
||||
return array(
|
||||
'Cpanel' => 'IPS\nexus\Hosting\Cpanel\Server',
|
||||
'None' => 'IPS\nexus\Hosting\None\Server',
|
||||
);
|
||||
}
|
||||
|
||||
/* !ActiveRecord */
|
||||
|
||||
/**
|
||||
@@ -60,7 +73,8 @@ class _Server extends \IPS\Node\Model
|
||||
public static function constructFromData( $data, $updateMultitonStoreIfExists = TRUE )
|
||||
{
|
||||
/* Initiate an object */
|
||||
$classname = 'IPS\\nexus\Hosting\\' . mb_ucfirst( $data['server_type'] ) . '\\Server';
|
||||
$availableTypes = static::serverTypes();
|
||||
$classname = $availableTypes[ mb_ucfirst( $data['server_type'] ) ];
|
||||
$obj = new $classname;
|
||||
$obj->_new = FALSE;
|
||||
|
||||
@@ -110,6 +124,16 @@ class _Server extends \IPS\Node\Model
|
||||
{
|
||||
$this->_data['extra'] = json_encode( $extra );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_type()
|
||||
{
|
||||
return ( isset( $this->_data['type'] ) ) ? mb_ucfirst( $this->_data['type'] ) : '';
|
||||
}
|
||||
|
||||
/* !Node */
|
||||
|
||||
@@ -151,16 +175,12 @@ class _Server extends \IPS\Node\Model
|
||||
$types = array();
|
||||
$extraFields = array();
|
||||
$toggles = array();
|
||||
foreach ( new \DirectoryIterator( \IPS\ROOT_PATH . '/applications/nexus/sources/Hosting' ) as $file )
|
||||
foreach ( static::serverTypes() as $key => $class )
|
||||
{
|
||||
if ( !$file->isDot() and mb_substr( $file, 0, 1 ) !== '.' and $file->isDir() )
|
||||
{
|
||||
$types[ mb_strtolower( $file ) ] = 'nexus_server_' . $file;
|
||||
|
||||
$class = 'IPS\nexus\Hosting\\' . mb_ucfirst( $file ) . '\Server';
|
||||
$extraFields[ mb_strtolower( mb_substr( $file, 0, -4 ) ) ] = $class::extraFormFields( $this );
|
||||
$toggles[ mb_strtolower( $file ) ] = array_keys( $extraFields[ mb_strtolower( mb_substr( $file, 0, -4 ) ) ] );
|
||||
}
|
||||
$types[ $key ] = 'nexus_server_' . $key;
|
||||
|
||||
$extraFields[ $key ] = $class::extraFormFields( $this );
|
||||
$toggles[ $key ] = array_keys( $extraFields[ $key ] );
|
||||
}
|
||||
|
||||
$form->addHeader( 'server_type' );
|
||||
@@ -185,7 +205,7 @@ class _Server extends \IPS\Node\Model
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'server_queues', explode( ',', $this->queues ), FALSE, array( 'class' => 'IPS\nexus\Hosting\Queue', 'multiple' => TRUE ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'server_max_accounts', $this->id ? $this->max_accounts : 0, FALSE, array( 'unlimited' => 0 ) ) );
|
||||
$nameservers = $this->nameservers ? explode( ',', $this->nameservers ) : array();
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'server_nameservers_default', count( $nameservers ) ? 0 : 1, FALSE, array( 'options' => array( 1 => 'server_nameservers_default_yes', 0 => 'server_nameservers_default_no' ), 'toggles' => array( 0 => array( 'server_nameservers' ) ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'server_nameservers_default', \count( $nameservers ) ? 0 : 1, FALSE, array( 'options' => array( 1 => 'server_nameservers_default_yes', 0 => 'server_nameservers_default_no' ), 'toggles' => array( 0 => array( 'server_nameservers' ) ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'server_nameservers', $nameservers, NULL, array( 'placeholder' => 'ns.example.net' ), NULL, NULL, NULL, 'server_nameservers' ) );
|
||||
$form->addHeader( 'server_reporting' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'server_monitor_on', \IPS\Settings::i()->monitoring_script and $this->monitor, FALSE, array( 'disabled' => !\IPS\Settings::i()->monitoring_script, 'togglesOn' => array( 'server_monitor' ) ) ) );
|
||||
@@ -210,7 +230,7 @@ class _Server extends \IPS\Node\Model
|
||||
{
|
||||
if( isset( $values['server_queues'] ) )
|
||||
{
|
||||
$values['server_queues'] = is_array( $values['server_queues'] ) ? implode( ',', array_keys( $values['server_queues'] ) ) : NULL;
|
||||
$values['server_queues'] = \is_array( $values['server_queues'] ) ? implode( ',', array_keys( $values['server_queues'] ) ) : NULL;
|
||||
}
|
||||
|
||||
if( isset( $values['server_nameservers'] ) )
|
||||
@@ -220,18 +240,16 @@ class _Server extends \IPS\Node\Model
|
||||
|
||||
unset( $values['server_nameservers_default'] );
|
||||
unset( $values['server_monitor_on'] );
|
||||
|
||||
$values = call_user_func( array( 'IPS\nexus\Hosting\\' . mb_ucfirst( $values['server_type'] ) . '\Server', '_formatFormValues' ), $values );
|
||||
|
||||
foreach ( new \DirectoryIterator( \IPS\ROOT_PATH . '/applications/nexus/sources/Hosting' ) as $file )
|
||||
$availableTypes = static::serverTypes();
|
||||
$serverClass = $availableTypes[ mb_ucfirst( $values['server_type'] ) ];
|
||||
$values = $serverClass::_formatFormValues( $values );
|
||||
|
||||
foreach ( static::serverTypes() as $key => $class )
|
||||
{
|
||||
if ( !$file->isDot() and mb_substr( $file, 0, 1 ) !== '.' and $file->isDir() )
|
||||
foreach ( array_keys( $class::extraFormFields( $this ) ) as $k )
|
||||
{
|
||||
$class = 'IPS\nexus\Hosting\\' . mb_ucfirst( $file ) . '\Server';
|
||||
foreach ( array_keys( $class::extraFormFields( $this ) ) as $k )
|
||||
{
|
||||
unset( $values[ $k ] );
|
||||
}
|
||||
unset( $values[ $k ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user