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\modules\admin\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,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _errors extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
@@ -35,14 +40,15 @@ class _errors extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
* Table
|
||||
*
|
||||
* @param \IPS\Http\Url $url The URL the table will be shown on
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
public static function table( $url )
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'nexus_hosting_errors', \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=errors' ) );
|
||||
$table = new \IPS\Helpers\Table\Db( 'nexus_hosting_errors', $url );
|
||||
$table->include = array( 'e_time', 'e_server', 'e_account', 'e_function', 'e_message' );
|
||||
$table->langPrefix = 'hosting_';
|
||||
$table->rowClasses = array( 'e_message' => array( 'ipsTable_wrap' ) );
|
||||
@@ -93,7 +99,7 @@ class _errors extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
if ( $username )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('hosting')->accountLink( $username );
|
||||
return \IPS\Theme::i()->getTemplate('hosting', 'nexus')->accountLink( $username );
|
||||
}
|
||||
return '';
|
||||
},
|
||||
@@ -123,7 +129,7 @@ class _errors extends \IPS\Dispatcher\Controller
|
||||
'retry' => array(
|
||||
'icon' => 'refresh',
|
||||
'title' => 'retry',
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=errors&do=retry&id=' . $row['e_id'] )
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=errors&do=retry&id=' . $row['e_id'] )->csrf()
|
||||
),
|
||||
'delete'=> array(
|
||||
'icon' => 'times-circle',
|
||||
@@ -134,15 +140,19 @@ class _errors extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
};
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->sidebar['actions'][] = array(
|
||||
'icon' => 'envelope',
|
||||
'title' => 'notifications',
|
||||
'link' => \IPS\Http\Url::internal( "app=nexus&module=hosting&controller=errors&do=settings" ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('notifications') )
|
||||
);
|
||||
/* Return */
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_hosting_errors');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'hosting_errors_blurb' ) . (string) $table;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'hosting_errors_blurb' ) . (string) static::table( \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=errors' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,6 +182,8 @@ class _errors extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function retry()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$log = \IPS\Db::i()->select( '*', 'nexus_hosting_errors', array( 'e_id=?', \IPS\Request::i()->id ) )->first();
|
||||
@@ -216,24 +228,4 @@ class _errors extends \IPS\Dispatcher\Controller
|
||||
\IPS\Db::i()->delete( 'nexus_hosting_errors', array( 'e_id=?', \IPS\Request::i()->id ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=hosting&controller=errors'), 'deleted' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function settings()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'nexus_hosting_error_emails', explode( ',', \IPS\Settings::i()->nexus_hosting_error_emails ), FALSE, array( 'stackFieldType' => 'Email' ) ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$values['nexus_hosting_error_emails'] = implode( ',', $values['nexus_hosting_error_emails'] );
|
||||
$form->saveAsSettings( $values );
|
||||
\IPS\Session::i()->log( 'acplogs__host_err_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=hosting&controller=errors'), 'saved' );
|
||||
}
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_hosting_errors');
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\modules\admin\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,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _monitoring extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\modules\admin\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,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _queues extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\modules\admin\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,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _servers extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
@@ -98,7 +103,7 @@ class _servers extends \IPS\Node\Controller
|
||||
$return['reboot'] = array(
|
||||
'title' => 'reboot',
|
||||
'icon' => 'refresh',
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=servers&do=reboot&id=' . $row['server_id'] )
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=servers&do=reboot&id=' . $row['server_id'] )->csrf()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -248,7 +253,7 @@ class _servers extends \IPS\Node\Controller
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = $server->hostname;
|
||||
\IPS\Output::i()->output = call_user_func_array( array( \IPS\Theme::i()->getTemplate( 'hosting' ), 'viewAccounts' ), $this->_audit( $server ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'hosting' )->viewAccounts( ...$this->_audit( $server ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,6 +264,7 @@ class _servers extends \IPS\Node\Controller
|
||||
protected function reboot()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'servers_reboot' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -299,7 +305,7 @@ class _servers extends \IPS\Node\Controller
|
||||
\IPS\Http\Url::internal('app=nexus&module=hosting&controller=servers&do=audit'),
|
||||
function( $data ) use ( $self )
|
||||
{
|
||||
if ( !is_array( $data ) )
|
||||
if ( !\is_array( $data ) )
|
||||
{
|
||||
$_SESSION['serverAudit'] = array();
|
||||
$data = array( 'offset' => 0, 'bad' => array() );
|
||||
@@ -307,7 +313,7 @@ class _servers extends \IPS\Node\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$select = \IPS\Db::i()->select( '*', 'nexus_hosting_servers', array(), 'server_hostname', array( $data['offset'], 1 ), NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS );
|
||||
$select = \IPS\Db::i()->select( '*', 'nexus_hosting_servers', array(), 'server_hostname', array( $data['offset'], 1 ) );
|
||||
$server = \IPS\nexus\Hosting\Server::constructFromData( $select->first() );
|
||||
|
||||
$results = $self->_audit( $server );
|
||||
@@ -321,7 +327,7 @@ class _servers extends \IPS\Node\Controller
|
||||
}
|
||||
|
||||
$data['offset']++;
|
||||
return array( $data, \IPS\Member::loggedIn()->language()->get('hserv_audit_running'), 100 / $select->count(TRUE) * $data['offset'] );
|
||||
return array( $data, \IPS\Member::loggedIn()->language()->get('hserv_audit_running'), 100 / \IPS\Db::i()->select( '*', 'nexus_hosting_servers' )->first() * $data['offset'] );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
@@ -466,19 +472,10 @@ class _servers extends \IPS\Node\Controller
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$availableTypes = array();
|
||||
|
||||
foreach ( new \DirectoryIterator( \IPS\ROOT_PATH . '/applications/nexus/sources/Hosting' ) as $file )
|
||||
$availableTypes = \IPS\nexus\Hosting\Server::serverTypes();
|
||||
if( isset( \IPS\Request::i()->server_type ) and \array_key_exists( \IPS\Request::i()->server_type, $availableTypes ) )
|
||||
{
|
||||
if (!$file->isDot() and mb_substr($file, 0, 1) !== '.' and $file->isDir())
|
||||
{
|
||||
$availableTypes[] = (string) $file;
|
||||
}
|
||||
}
|
||||
|
||||
if( isset( \IPS\Request::i()->server_type ) and in_array( \IPS\Request::i()->server_type, $availableTypes ) )
|
||||
{
|
||||
$this->nodeClass = "IPS\\nexus\\Hosting\\" . mb_ucfirst( \IPS\Request::i()->server_type ) . "\\Server";
|
||||
$this->nodeClass = $availableTypes[ mb_ucfirst( \IPS\Request::i()->server_type ) ];
|
||||
}
|
||||
|
||||
parent::form();
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\modules\admin\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,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _settings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
@@ -46,7 +51,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Account Management */
|
||||
$form->addTab('hosting_account_management');
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'nexus_hosting_terminate', \IPS\Settings::i()->nexus_hosting_terminate, TRUE, array( 'unlimited' => -1, 'unlimitedLang' => 'forever' ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days') ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'nexus_hosting_terminate', \IPS\Settings::i()->nexus_hosting_terminate, TRUE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => -1, 'unlimitedLang' => 'forever' ), NULL, NULL, NULL ) );
|
||||
|
||||
/* Domains */
|
||||
$form->addTab('hosting_settings_domains');
|
||||
@@ -54,7 +59,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
$optionsVal = array();
|
||||
$domainPrices = array();
|
||||
|
||||
if ( \IPS\Settings::i()->nexus_enom_un and $domainPrices = json_decode( \IPS\Settings::i()->nexus_domain_prices, TRUE ) and count( $domainPrices ) )
|
||||
if ( \IPS\Settings::i()->nexus_enom_un and $domainPrices = json_decode( \IPS\Settings::i()->nexus_domain_prices, TRUE ) and \count( $domainPrices ) )
|
||||
{
|
||||
$optionsVal[] = 'enom';
|
||||
}
|
||||
@@ -113,7 +118,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
return new \IPS\nexus\Form\Money( $key, $value, FALSE, array() );
|
||||
},
|
||||
);
|
||||
if ( count( $domainPrices ) )
|
||||
if ( \count( $domainPrices ) )
|
||||
{
|
||||
foreach ( $domainPrices as $tld => $prices )
|
||||
{
|
||||
@@ -140,7 +145,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
},
|
||||
);
|
||||
$bandwidthPrices = json_decode( \IPS\Settings::i()->nexus_hosting_bandwidth, TRUE );
|
||||
if ( count( $bandwidthPrices ) )
|
||||
if ( \count( $bandwidthPrices ) )
|
||||
{
|
||||
foreach ( $bandwidthPrices as $amount => $prices )
|
||||
{
|
||||
@@ -157,7 +162,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$domainPrices = array();
|
||||
if ( in_array( 'enom', $values['domain_options'] ) )
|
||||
if ( \in_array( 'enom', $values['domain_options'] ) )
|
||||
{
|
||||
foreach ( $values['nexus_domain_prices'] as $option )
|
||||
{
|
||||
@@ -168,11 +173,11 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
$values['nexus_domain_prices'] = json_encode( $domainPrices );
|
||||
$values['nexus_hosting_allow_own_domain'] = in_array( 'own', $values['domain_options'] );
|
||||
$values['nexus_hosting_allow_own_domain'] = \in_array( 'own', $values['domain_options'] );
|
||||
|
||||
$values['nexus_hosting_nameservers'] = implode( ',', $values['nexus_hosting_nameservers'] );
|
||||
$values['nexus_hosting_subdomains'] = in_array( 'sub', $values['domain_options'] ) ? implode( ',', $values['nexus_hosting_subdomains'] ) : '';
|
||||
$values['nexus_hosting_own_domains'] = in_array( 'own', $values['domain_options'] ) ? implode( ',', $values['nexus_hosting_own_domains'] ) : '';
|
||||
$values['nexus_hosting_subdomains'] = \in_array( 'sub', $values['domain_options'] ) ? implode( ',', $values['nexus_hosting_subdomains'] ) : '';
|
||||
$values['nexus_hosting_own_domains'] = \in_array( 'own', $values['domain_options'] ) ? implode( ',', $values['nexus_hosting_own_domains'] ) : '';
|
||||
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => (bool) $values['nexus_hosting_terminate'] ), "`key`='terminateHosting'" );
|
||||
|
||||
|
||||
Reference in new issue
Block a user