Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+36 -35
View File
@@ -12,7 +12,7 @@
namespace IPS\nexus\Package;
/* 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;
@@ -53,7 +53,7 @@ class _Hosting extends \IPS\nexus\Package
{
$stickyCustomFields = array_filter( parent::getPurchaseNameInfo( $purchase ) );
if ( !count( $stickyCustomFields ) )
if ( !\count( $stickyCustomFields ) )
{
try
{
@@ -120,7 +120,7 @@ class _Hosting extends \IPS\nexus\Package
{
if( isset( $values['p_queue'] ) )
{
$values['p_queue'] = is_object( $values['p_queue'] ) ? $values['p_queue']->id : $values['p_queue'];
$values['p_queue'] = \is_object( $values['p_queue'] ) ? $values['p_queue']->id : $values['p_queue'];
}
return parent::formatFormValues( $values );
@@ -168,7 +168,7 @@ class _Hosting extends \IPS\nexus\Package
if ( isset( $changes[ $k ] ) )
{
/* What is the current value? */
$currentValue = call_user_func( array( $account, $method ) );
$currentValue = $account->$method();
if ( $currentValue === NULL )
{
$currentValue = -1;
@@ -252,7 +252,7 @@ class _Hosting extends \IPS\nexus\Package
$domainTypeOptions = array();
$domainTypeToggles = array();
$domainPrices = NULL;
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 ) )
{
$domainTypeOptions['buy'] = 'ha_domain_buy';
$domainTypeToggles['buy'] = array( 'ha_domain_to_buy' );
@@ -265,17 +265,17 @@ class _Hosting extends \IPS\nexus\Package
if ( \IPS\Settings::i()->nexus_hosting_allow_own_domain )
{
$ownDomainOptions = explode( ',', \IPS\Settings::i()->nexus_hosting_own_domains );
if ( in_array( 'nameservers', $ownDomainOptions ) or in_array( 'aname', $ownDomainOptions ) or ( in_array( 'cname', $ownDomainOptions ) and $canParkDomains ) )
if ( \in_array( 'nameservers', $ownDomainOptions ) or \in_array( 'aname', $ownDomainOptions ) or ( \in_array( 'cname', $ownDomainOptions ) and $canParkDomains ) )
{
$domainTypeOptions['own'] = 'ha_domain_own';
$domainTypeToggles['own'] = array( 'ha_domain_to_use' );
}
}
if ( !count( $domainTypeOptions ) )
if ( !\count( $domainTypeOptions ) )
{
\IPS\Output::i()->error( 'hosting_err_public', '4X245/4', 500, 'hosting_err_no_domains' );
}
if ( count( $domainTypeOptions ) > 1 )
if ( \count( $domainTypeOptions ) > 1 )
{
$form->add( new \IPS\Helpers\Form\Radio( 'ha_domain_type', NULL, TRUE, array( 'options' => $domainTypeOptions, 'toggles' => $domainTypeToggles ) ) );
}
@@ -385,14 +385,14 @@ class _Hosting extends \IPS\nexus\Package
$options = explode( ',', \IPS\Settings::i()->nexus_hosting_own_domains );
if ( $domain->type === \IPS\nexus\DomainLookup::DOMAIN_TYPE_DOMAIN )
{
if ( !in_array( 'nameservers', $options ) )
if ( !\in_array( 'nameservers', $options ) )
{
throw new \DomainException('domain_must_be_subdomain');
}
}
else
{
if ( !in_array( 'aname', $options ) and ( !in_array( 'cname', $options ) or !$this->maxpark ) )
if ( !\in_array( 'aname', $options ) and ( !\in_array( 'cname', $options ) or !$this->maxpark ) )
{
throw new \DomainException('domain_cannot_be_subdomain');
}
@@ -429,7 +429,7 @@ class _Hosting extends \IPS\nexus\Package
if ( $domain->type === \IPS\nexus\DomainLookup::DOMAIN_TYPE_DOMAIN )
{
if ( !in_array( 'nameservers', $options ) )
if ( !\in_array( 'nameservers', $options ) )
{
throw new \DomainException('domain_must_be_subdomain');
}
@@ -458,12 +458,12 @@ class _Hosting extends \IPS\nexus\Package
else
{
$aname = NULL;
if ( in_array( 'aname', $options ) )
if ( \in_array( 'aname', $options ) )
{
$aname = \IPS\nexus\Hosting\Server::load( $values['server'] )->ip;
}
if ( in_array( 'cname', $options ) and $this->maxpark )
if ( \in_array( 'cname', $options ) and $this->maxpark )
{
if ( !$cname )
{
@@ -481,7 +481,7 @@ class _Hosting extends \IPS\nexus\Package
$isValid = FALSE;
$records = @dns_get_record( $values['ha_domain_to_use'], 0 + ( $aname ? DNS_A : 0 ) + ( $cname ? DNS_CNAME : 0 ) );
if ( is_array( $records ) )
if ( \is_array( $records ) )
{
foreach ( $records as $record )
{
@@ -521,7 +521,7 @@ class _Hosting extends \IPS\nexus\Package
try
{
$server = \IPS\nexus\Hosting\Server::load( \IPS\Request::i()->server );
if ( !in_array( $this->queue, explode( ',', $server->queues ) ) )
if ( !\in_array( $this->queue, explode( ',', $server->queues ) ) )
{
throw new \OutOfRangeException;
}
@@ -609,7 +609,7 @@ class _Hosting extends \IPS\nexus\Package
*/
public function generateInvoiceForm( \IPS\Helpers\Form $form, $k )
{
$class = get_class();
$class = \get_class();
$field = new \IPS\Helpers\Form\Text( 'ha_domain_to_use' . $k, NULL, NULL, array(), function( $value ) use ( $class )
{
if ( !$value )
@@ -697,15 +697,15 @@ class _Hosting extends \IPS\nexus\Package
$form->add( new \IPS\Helpers\Form\Text( 'account_username', $account->username, TRUE, array(), NULL, NULL, \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) );
$form->add( new \IPS\Helpers\Form\Text( 'account_password', $account->password, TRUE, array(), NULL, NULL, \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) );
$form->add( new \IPS\Helpers\Form\Text( 'account_domain', $account->domain, TRUE, array(), NULL, NULL, \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_quota', ( $account->diskspaceAllowance() !== NULL ? intval( $account->diskspaceAllowance() ) / 1048576 / 1.024 : -1 ), TRUE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ), NULL, NULL, 'MB' ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_bwlimit', ( $account->monthlyBandwidthAllowance() !== NULL ? intval( $account->monthlyBandwidthAllowance() ) / 1048576 / 1.024 : -1 ), TRUE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ), NULL, NULL, \IPS\Member::loggedIn()->language()->get('mb_per_month') ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxftp', ( $account->maxFtpAccounts() !== NULL ? intval( $account->maxFtpAccounts() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxsql', ( $account->maxDatabases() !== NULL ? intval( $account->maxDatabases() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxpop', ( $account->maxEmailAccounts() !== NULL ? intval( $account->maxEmailAccounts() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxlst', ( $account->maxMailingLists() !== NULL ? intval( $account->maxMailingLists() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxsub', ( $account->maxSubdomains() !== NULL ? intval( $account->maxSubdomains() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxpark', ( $account->maxParkedDomains() !== NULL ? intval( $account->maxParkedDomains() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxaddon', ( $account->maxAddonDomains() !== NULL ? intval( $account->maxAddonDomains() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_quota', ( $account->diskspaceAllowance() !== NULL ? \intval( $account->diskspaceAllowance() ) / 1048576 / 1.024 : -1 ), TRUE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ), NULL, NULL, 'MB' ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_bwlimit', ( $account->monthlyBandwidthAllowance() !== NULL ? \intval( $account->monthlyBandwidthAllowance() ) / 1048576 / 1.024 : -1 ), TRUE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ), NULL, NULL, \IPS\Member::loggedIn()->language()->get('mb_per_month') ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxftp', ( $account->maxFtpAccounts() !== NULL ? \intval( $account->maxFtpAccounts() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxsql', ( $account->maxDatabases() !== NULL ? \intval( $account->maxDatabases() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxpop', ( $account->maxEmailAccounts() !== NULL ? \intval( $account->maxEmailAccounts() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxlst', ( $account->maxMailingLists() !== NULL ? \intval( $account->maxMailingLists() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxsub', ( $account->maxSubdomains() !== NULL ? \intval( $account->maxSubdomains() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxpark', ( $account->maxParkedDomains() !== NULL ? \intval( $account->maxParkedDomains() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_maxaddon', ( $account->maxAddonDomains() !== NULL ? \intval( $account->maxAddonDomains() ) : -1 ), FALSE, array( 'unlimited' => -1, 'endSuffix' => \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_hasshell', $account->hasSSHAccess(), FALSE, array(), NULL, NULL, \IPS\Theme::i()->getTemplate('hosting')->accountEditWarning() ) );
$form->add( new \IPS\Helpers\Form\Custom( 'do_not_update_server', FALSE, FALSE, array(
'rowHtml' => function()
@@ -714,7 +714,7 @@ class _Hosting extends \IPS\nexus\Package
}
) ) );
if ( count( \IPS\Db::i()->select( '*', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_parent=?', 'nexus', 'bandwidth', $purchase->id ) ) ) )
if ( \count( \IPS\Db::i()->select( '*', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_parent=?', 'nexus', 'bandwidth', $purchase->id ) ) ) )
{
\IPS\Member::loggedIn()->language()->words['p_bwlimit_warning'] = \IPS\Member::loggedIn()->language()->addToStack('bandwidth_edit_warn');
}
@@ -938,7 +938,7 @@ class _Hosting extends \IPS\nexus\Package
$account->save();
return;
}
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
case 'bandwidth':
$bandwidthOptions = json_decode( \IPS\Settings::i()->nexus_hosting_bandwidth, TRUE );
@@ -996,7 +996,7 @@ class _Hosting extends \IPS\nexus\Package
return;
}
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
case 'changedomain':
$account = \IPS\nexus\Hosting\Account::load( $purchase->id );
@@ -1092,7 +1092,7 @@ class _Hosting extends \IPS\nexus\Package
try
{
$server = \IPS\nexus\Hosting\Server::load( $purchase->extra['server'] );
if ( !in_array( $this->queue, explode( ',', $server->queues ) ) )
if ( !\in_array( $this->queue, explode( ',', $server->queues ) ) )
{
throw new \OutOfRangeException;
}
@@ -1116,23 +1116,24 @@ class _Hosting extends \IPS\nexus\Package
$username = mb_substr( preg_replace("/[^a-z\s]/", '', mb_strtolower( $purchase->extra['domain'] ) ), 0, 8 );
while ( mb_strlen( $username ) < 8 )
{
$username .= chr( rand( 97, 122 ) );
$username .= \chr( rand( 97, 122 ) );
}
/* If it already exists, change characters until we get one that doesn't */
do
{
$select = \IPS\Db::i()->select( '*', 'nexus_hosting_accounts', array( 'account_username=? AND account_server=?', $username, $server->id ) );
if ( count( $select ) or !$server->checkUsername( $username ) )
if ( \count( $select ) or !$server->checkUsername( $username ) )
{
$charToChange = rand( 0, 8 - 1 );
$username[ $charToChange ] = chr( rand( 97, 122 ) );
$username[ $charToChange ] = \chr( rand( 97, 122 ) );
}
}
while ( count( $select ) or !$server->checkUsername( $username ) );
while ( \count( $select ) or !$server->checkUsername( $username ) );
/* Create the account */
$class = 'IPS\nexus\Hosting\\' . mb_ucfirst( $server->type ) . '\Account';
$availableTypes = \IPS\nexus\Hosting\Account::accountTypes();
$class = $availableTypes[ mb_ucfirst( $server->type ) ];
$account = new $class;
$account->ps_id = $purchase->id;
$account->server = $server;
@@ -1295,7 +1296,7 @@ class _Hosting extends \IPS\nexus\Package
foreach ( array( 'quota' => 'diskspaceAllowance', 'bwlimit' => 'monthlyBandwidthAllowance', 'maxftp' => 'maxFtpAccounts', 'maxsql' => 'maxDatabases', 'maxpop' => 'maxEmailAccounts', 'maxlst' => 'maxMailingLists', 'maxsub' => 'maxSubdomains', 'maxpark' => 'maxParkedDomains', 'maxaddon' => 'maxAddonDomains', 'hasshell' => 'hasSSHAccess' ) as $k => $method )
{
/* What is the current value? */
$currentValue = call_user_func( array( $account, $method ) );
$currentValue = $account->$method();
if ( $currentValue === NULL )
{
$currentValue = -1;