Version 4.7.13
This commit is contained in:
1 parent
fd22d99e69
commit
7124a02564
954 files changed
+29277
-59308
No files matched your search
@@ -36,21 +36,17 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_view' );
|
||||
|
||||
if ( \IPS\Request::i()->do !== 'findHostingAccount' )
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->purchase = \IPS\nexus\Purchase::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X195/2', 404, '' );
|
||||
}
|
||||
|
||||
|
||||
\IPS\Output::i()->title = $this->purchase->name . " (#{$this->purchase->id})";
|
||||
$this->purchase = \IPS\nexus\Purchase::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X195/2', 404, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = $this->purchase->name . " (#{$this->purchase->id})";
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'purchases.css', 'nexus', 'admin' ) );
|
||||
parent::execute();
|
||||
@@ -608,21 +604,4 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
|
||||
\IPS\Output::i()->redirect( $this->purchase->acpUrl() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Hosting Account
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function findHostingAccount()
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\nexus\Purchase::load( \IPS\Db::i()->select( 'ps_id', 'nexus_hosting_accounts', array( 'account_username=?', \IPS\Request::i()->username ) )->first() )->acpUrl() );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X195/B', 404, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -660,7 +660,7 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $this->auth and \in_array( $this->status, array( static::STATUS_HELD, static::STATUS_REVIEW ) ) )
|
||||
if ( $transaction->auth and \in_array( $transaction->status, array( $transaction::STATUS_HELD, $transaction::STATUS_REVIEW ) ) )
|
||||
{
|
||||
$transaction->void();
|
||||
}
|
||||
|
||||
@@ -1,231 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Hosting Server Errors
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 12 Aug 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\hosting;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hosting Server Errors
|
||||
*/
|
||||
class _errors extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'errors_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Table
|
||||
*
|
||||
* @param \IPS\Http\Url $url The URL the table will be shown on
|
||||
* @return void
|
||||
*/
|
||||
public static function table( $url )
|
||||
{
|
||||
/* Create the table */
|
||||
$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' ) );
|
||||
$table->mainColumn = 'e_account';
|
||||
if ( !$table->sortBy )
|
||||
{
|
||||
$table->sortBy = 'e_time';
|
||||
$table->sortDirection = 'asc';
|
||||
}
|
||||
|
||||
/* Parsers */
|
||||
$table->parsers = array(
|
||||
'e_time' => function( $val )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val );
|
||||
},
|
||||
'e_server' => function( $val )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Hosting\Server::load( $val )->hostname;
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'e_function' => function ( $val, $row )
|
||||
{
|
||||
$details = json_decode( $row['e_extra'], TRUE );
|
||||
if ( isset( $details['function'] ) )
|
||||
{
|
||||
return $details['function'];
|
||||
}
|
||||
return '';
|
||||
},
|
||||
'e_account' => function ( $val, $row )
|
||||
{
|
||||
$details = json_decode( $row['e_extra'], TRUE );
|
||||
$username = NULL;
|
||||
if ( isset( $details['params']['user'] ) )
|
||||
{
|
||||
$username = $details['params']['user'];
|
||||
}
|
||||
if ( isset( $details['params']['username'] ) )
|
||||
{
|
||||
$username = $details['params']['username'];
|
||||
}
|
||||
if ( $username )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('hosting', 'nexus')->accountLink( $username );
|
||||
}
|
||||
return '';
|
||||
},
|
||||
'e_message' => function( $val )
|
||||
{
|
||||
if ( \IPS\Member::loggedIn()->language()->checkKeyExists( 'hosting_ex_' . $val ) )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'hosting_ex_' . $val );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $val;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/* Buttons */
|
||||
$table->rowButtons = function( $row )
|
||||
{
|
||||
return array(
|
||||
'view' => array(
|
||||
'icon' => 'search',
|
||||
'title' => 'view',
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=errors&do=view&id=' . $row['e_id'] ),
|
||||
'data' => array( 'ipsDialog' => '' )
|
||||
),
|
||||
'retry' => array(
|
||||
'icon' => 'refresh',
|
||||
'title' => 'retry',
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=errors&do=retry&id=' . $row['e_id'] )->csrf()
|
||||
),
|
||||
'delete'=> array(
|
||||
'icon' => 'times-circle',
|
||||
'title' => 'delete',
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=errors&do=delete&id=' . $row['e_id'] ),
|
||||
'data' => array( 'delete' => '' )
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
/* 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) static::table( \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=errors' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* View
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function view()
|
||||
{
|
||||
try
|
||||
{
|
||||
$log = \IPS\Db::i()->select( '*', 'nexus_hosting_errors', array( 'e_id=?', \IPS\Request::i()->id ) )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X244/2', 404, '' );
|
||||
}
|
||||
|
||||
$details = json_decode( $log['e_extra'], TRUE );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->definitionTable( $details['params'], NULL, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retry
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function retry()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$log = \IPS\Db::i()->select( '*', 'nexus_hosting_errors', array( 'e_id=?', \IPS\Request::i()->id ) )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X244/3', 404, '' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\nexus\Hosting\Server::load( $log['e_server'] )->retryError( json_decode( $log['e_extra'], TRUE ) );
|
||||
\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'), 'hosrting_error_retry_done' );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( $e->getMessage(), '3X244/4', 500, '' );
|
||||
}
|
||||
catch ( \IPS\nexus\Hosting\Exception $e )
|
||||
{
|
||||
$message = $e->getMessage();
|
||||
if ( \IPS\Member::loggedIn()->language()->checkKeyExists( 'hosting_ex_' . $message ) )
|
||||
{
|
||||
$message = \IPS\Member::loggedIn()->language()->addToStack( 'hosting_ex_' . $message );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->error( $message, '1X244/1', 503, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
|
||||
\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' );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -1,149 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Monitoring Settings
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 07 Aug 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\hosting;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitoring Settings
|
||||
*/
|
||||
class _monitoring extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\nexus\Hosting\EOM';
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Init Tabs */
|
||||
$tabs = array();
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'hosting', 'monitoring_settings' ) )
|
||||
{
|
||||
$tabs['settings'] = 'settings';
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'hosting', 'monitoring_eom_view' ) )
|
||||
{
|
||||
$tabs['eom'] = 'expected_output_monitoring';
|
||||
}
|
||||
$keys = array_keys( $tabs );
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : array_shift( $keys );
|
||||
|
||||
/* Work out contents */
|
||||
$activeTabContents = NULL;
|
||||
switch ( $activeTab )
|
||||
{
|
||||
/* Settings */
|
||||
case 'settings':
|
||||
|
||||
/* Build Form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->addHeader('monitoring_header');
|
||||
$form->addMessage('monitoring_blurb');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'monitoring_on', \IPS\Settings::i()->monitoring_script, FALSE, array( 'togglesOn' => array( 'monitoring_script', 'monitoring_alert', 'monitoring_from', 'monitoring_backup', 'monitoring_allowed_fails', 'monitoring_panic', 'form_header_network_status_header', 'network_status' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'monitoring_script', \IPS\Settings::i()->monitoring_script, NULL, array( 'placeholder' => 'http://www.example.com/monitor_master.php' ), NULL, NULL, NULL, 'monitoring_script' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'monitoring_backup', \IPS\Settings::i()->monitoring_backup, FALSE, array( 'placeholder' => 'http://backup.example.com/monitor_master.php' ), NULL, NULL, NULL, 'monitoring_backup' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'monitoring_alert', explode( ',', \IPS\Settings::i()->monitoring_alert ), NULL, array(), NULL, NULL, NULL, 'monitoring_alert' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'monitoring_from', \IPS\Settings::i()->monitoring_from ?: \IPS\Settings::i()->email_out, NULL, array(), NULL, NULL, NULL, 'monitoring_from' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'monitoring_allowed_fails', \IPS\Settings::i()->monitoring_allowed_fails, FALSE, array(), NULL, NULL, NULL, 'monitoring_allowed_fails' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'monitoring_panic', \IPS\Settings::i()->monitoring_panic, FALSE, array(), NULL, NULL, NULL, 'monitoring_panic' ) );
|
||||
$form->addHeader('network_status_header');
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'network_status', \IPS\Settings::i()->network_status, FALSE, array( 'options' => array( 2 => 'network_status_2', 1 => 'network_status_1', 0 => 'network_status_0' ), 'toggles' => array( 2 => array( 'network_status_text' ), 1 => array( 'network_status_text' ) ) ), NULL, NULL, NULL, 'network_status' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'network_status_text', NULL, FALSE, array( 'app' => 'nexus', 'key' => 'network_status_text_val', 'editor' => array( 'app' => 'nexus', 'key' => 'Admin', 'autoSaveKey' => 'network_status_text', 'attachIds' => array( NULL, NULL, 'network_status_text' ) ) ), NULL, NULL, NULL, 'network_status_text' ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if ( !$values['monitoring_on'] )
|
||||
{
|
||||
$values['monitoring_script'] = '';
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), "`key`='monitor'" );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), "`key`='monitor'" );
|
||||
}
|
||||
unset( $values['monitoring_on'] );
|
||||
|
||||
$values['monitoring_alert'] = implode( ',', $values['monitoring_alert'] );
|
||||
|
||||
\IPS\Lang::saveCustom( 'nexus', 'network_status_text_val', $values['network_status_text'] );
|
||||
unset( $values['network_status_text'] );
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__host_mon_settings' );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=monitoring&tab=settings' ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
$activeTabContents = (string) $form;
|
||||
break;
|
||||
|
||||
/* EOM */
|
||||
case 'eom':
|
||||
parent::manage();
|
||||
$activeTabContents = \IPS\Theme::i()->getTemplate('forms', 'core')->blurb( 'eom_blurb', TRUE, TRUE ) . \IPS\Output::i()->output;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Display */
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_hosting_monitoring');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=nexus&module=hosting&controller=monitoring" ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download Master Monitoring Script
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function downloadMaster()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'monitoring_settings' );
|
||||
\IPS\Output::i()->sendOutput( file_get_contents( \IPS\ROOT_PATH . '/applications/nexus/data/monitoring/master.txt' ), 200, 'text/plain', array( 'Content-Disposition' => 'attachment; filename=monitor_master.php' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Download Remote Monitoring Script
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function downloadRemote()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'monitoring_settings' );
|
||||
\IPS\Output::i()->sendOutput( file_get_contents( \IPS\ROOT_PATH . '/applications/nexus/data/monitoring/remote.txt' ), 200, 'text/plain', array( 'Content-Disposition' => 'attachment; filename=monitor_remote.php' ) );
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Hosting Queues
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 06 Aug 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\hosting;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hosting Queues
|
||||
*/
|
||||
class _queues extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\nexus\Hosting\Queue';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'queues_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'hosting_queues_blurb' );
|
||||
return parent::manage();
|
||||
}
|
||||
}
|
||||
@@ -1,483 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Hosting Servers
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 06 Aug 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\hosting;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hosting Servers
|
||||
*/
|
||||
class _servers extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\nexus\Hosting\Server';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'servers_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
/* Initiate the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'nexus_hosting_servers', \IPS\Http\Url::internal('app=nexus&module=hosting&controller=servers') );
|
||||
if ( \IPS\Settings::i()->monitoring_script )
|
||||
{
|
||||
$table->include = array( 'server_monitor_icon', 'server_hostname', 'server_ip', 'server_num_accounts', 'server_cost', 'server_income' );
|
||||
$table->widths = array( 'server_monitor_icon' => 5 );
|
||||
$table->noSort = array( 'server_monitor_icon' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->include = array( 'server_hostname', 'server_ip', 'server_num_accounts', 'server_cost', 'server_income' );
|
||||
}
|
||||
$table->sortBy = $table->sortBy ?: 'server_hostname';
|
||||
$table->quickSearch = 'server_hostname';
|
||||
|
||||
/* Buttons */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'hosting', 'servers_add' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['add'] = array(
|
||||
'primary' => true,
|
||||
'title' => 'add',
|
||||
'icon' => 'plus',
|
||||
'link' => \IPS\Http\Url::internal('app=nexus&module=hosting&controller=servers&do=form')
|
||||
);
|
||||
}
|
||||
$table->rowButtons = function( $row )
|
||||
{
|
||||
$return = array();
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'hosting', 'servers_audit' ) )
|
||||
{
|
||||
$return['list'] = array(
|
||||
'title' => 'view_accounts',
|
||||
'icon' => 'search',
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=servers&do=view&id=' . $row['server_id'] )
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'hosting', 'servers_edit' ) )
|
||||
{
|
||||
$return['edit'] = array(
|
||||
'title' => 'edit',
|
||||
'icon' => 'pencil',
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=servers&do=form&id=' . $row['server_id'] )
|
||||
);
|
||||
}
|
||||
|
||||
if ( !$row['server_dedicated'] and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'hosting', 'servers_reboot' ) )
|
||||
{
|
||||
$return['reboot'] = array(
|
||||
'title' => 'reboot',
|
||||
'icon' => 'refresh',
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=servers&do=reboot&id=' . $row['server_id'] )->csrf()
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'hosting', 'servers_delete' ) )
|
||||
{
|
||||
$return['delete'] = array(
|
||||
'title' => 'delete',
|
||||
'icon' => 'times-circle',
|
||||
'link' => \IPS\Http\Url::internal( 'app=nexus&module=hosting&controller=servers&do=delete&id=' . $row['server_id'] ),
|
||||
'data' => array( 'delete' => '' )
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
};
|
||||
|
||||
/* Work out the monthly income for each server */
|
||||
$serverIncomes = array();
|
||||
foreach ( array(
|
||||
'd' => ( 365 / 12 ),
|
||||
'w' => ( 365 / 12 / 7 ),
|
||||
'm' => 1,
|
||||
'y' => ( 1 / 12 ),
|
||||
) as $key => $multiplier )
|
||||
{
|
||||
foreach (
|
||||
\IPS\Db::i()->select(
|
||||
'account_server, ps_renewal_currency, SUM( ps_renewal_price / ps_renewals ) * ' . $multiplier . ' AS amount',
|
||||
'nexus_hosting_accounts',
|
||||
array( 'account_exists=1 AND ps_renewal_unit=?', $key ),
|
||||
NULL,
|
||||
NULL,
|
||||
array( 'account_server', 'ps_renewal_currency' )
|
||||
)->join( 'nexus_purchases', 'nexus_hosting_accounts.ps_id=nexus_purchases.ps_id' )
|
||||
as $row
|
||||
)
|
||||
{
|
||||
if ( !isset( $serverIncomes[ $row['account_server'] ][ $row['ps_renewal_currency'] ] ) )
|
||||
{
|
||||
$serverIncomes[ $row['account_server'] ][ $row['ps_renewal_currency'] ] = 0;
|
||||
}
|
||||
|
||||
$serverIncomes[ $row['account_server'] ][ $row['ps_renewal_currency'] ] += $row['amount'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse the columns */
|
||||
$currencies = \IPS\nexus\Money::currencies();
|
||||
$costCurrency = array_shift( $currencies );
|
||||
$table->parsers = array(
|
||||
'server_monitor_icon' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('hosting')->serverStatus( $row );
|
||||
},
|
||||
'server_num_accounts' => function( $val, $row )
|
||||
{
|
||||
if ( $row['server_dedicated'] )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('purchases')->link( \IPS\nexus\Purchase::load( $row['server_dedicated'] ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_hosting_accounts', array( 'account_server=? AND account_exists=1', $row['server_id'] ) )->first() . ( $row['server_max_accounts'] ? ( ' / ' . $row['server_max_accounts'] ) : '' );
|
||||
}
|
||||
},
|
||||
'server_cost' => function ( $val ) use ( $costCurrency )
|
||||
{
|
||||
return new \IPS\nexus\Money( $val, $costCurrency );
|
||||
},
|
||||
'server_income' => function( $val, $row ) use ( $serverIncomes, $costCurrency )
|
||||
{
|
||||
if ( $row['server_dedicated'] )
|
||||
{
|
||||
try
|
||||
{
|
||||
$purchase = \IPS\nexus\Purchase::load( $row['server_dedicated'] );
|
||||
|
||||
$months = 0;
|
||||
$months += ( $purchase->renewals->interval->y / 12 );
|
||||
$months += ( $purchase->renewals->interval->m );
|
||||
$months += ( $purchase->renewals->interval->d * ( 365 / 12 ) );
|
||||
|
||||
return new \IPS\nexus\Money( $purchase->renewals->cost->amount->multiply( new \IPS\Math\Number("{$months}" ) ), $purchase->renewals->cost->currency );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = array();
|
||||
if ( isset( $serverIncomes[ $row['server_id'] ] ) )
|
||||
{
|
||||
foreach ( $serverIncomes[ $row['server_id'] ] as $currency => $amount )
|
||||
{
|
||||
$return[] = new \IPS\nexus\Money( $amount, $currency );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new \IPS\nexus\Money( 0, $costCurrency );
|
||||
}
|
||||
return implode( '<br>', $return );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/* Add filters for the queues */
|
||||
foreach ( \IPS\nexus\Hosting\Queue::queues() as $queue )
|
||||
{
|
||||
$table->filters[ $queue->name ] = \IPS\Db::i()->findInSet( 'server_queues', array( $queue->id ) );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->sidebar['actions'][] = array(
|
||||
'icon' => 'check-circle',
|
||||
'title' => 'hserv_audit',
|
||||
'link' => \IPS\Http\Url::internal( "app=nexus&module=hosting&controller=servers&do=audit" ),
|
||||
);
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* View accounts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function view()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'servers_audit' );
|
||||
|
||||
try
|
||||
{
|
||||
$server = \IPS\nexus\Hosting\Server::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X243/3', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = $server->hostname;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'hosting' )->viewAccounts( ...$this->_audit( $server ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reboot a server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function reboot()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'servers_reboot' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\nexus\Hosting\Server::load( \IPS\Request::i()->id )->reboot();
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X243/1', 404, '' );
|
||||
}
|
||||
catch ( \IPS\nexus\Hosting\Exception $e )
|
||||
{
|
||||
$message = $e->getMessage();
|
||||
if ( \IPS\Member::loggedIn()->language()->checkKeyExists( 'hosting_ex_' . $message ) )
|
||||
{
|
||||
$message = \IPS\Member::loggedIn()->language()->addToStack( 'hosting_ex_' . $message );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->error( $message, '3X243/2', 500, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__server_reboot', array( $server->hostname => FALSE ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=hosting&controller=servers'), 'rebooting' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Audit all servers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function audit()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'servers_audit' );
|
||||
|
||||
$self = $this;
|
||||
|
||||
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect(
|
||||
\IPS\Http\Url::internal('app=nexus&module=hosting&controller=servers&do=audit'),
|
||||
function( $data ) use ( $self )
|
||||
{
|
||||
if ( !\is_array( $data ) )
|
||||
{
|
||||
$_SESSION['serverAudit'] = array();
|
||||
$data = array( 'offset' => 0, 'bad' => array() );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$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 );
|
||||
foreach ( array( 1, 2, 3, 6, 7, 8 ) as $i )
|
||||
{
|
||||
if ( !empty( $results[ $i ] ) )
|
||||
{
|
||||
$data['bad'][ $server->id ] = $server->hostname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$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 )
|
||||
{
|
||||
$_SESSION['serverAudit'] = $data['bad'];
|
||||
return NULL;
|
||||
}
|
||||
},
|
||||
function()
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=hosting&controller=servers&do=auditResults') );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Audit all servers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function auditResults()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'servers_audit' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'hosting' )->audit( $_SESSION['serverAudit'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Audit a server
|
||||
*
|
||||
* @param \IPS\nexus\Hosting\Server $server
|
||||
* @return array
|
||||
*/
|
||||
protected function _audit( \IPS\nexus\Hosting\Server $server )
|
||||
{
|
||||
/* Get accounts from server */
|
||||
try
|
||||
{
|
||||
$serverAccounts = $server->listAccounts();
|
||||
}
|
||||
catch ( \IPS\nexus\Hosting\Exception $e )
|
||||
{
|
||||
$message = $e->getMessage();
|
||||
if ( \IPS\Member::loggedIn()->language()->checkKeyExists( 'hosting_ex_' . $message ) )
|
||||
{
|
||||
$message = \IPS\Member::loggedIn()->language()->addToStack( 'hosting_ex_' . $message );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->error( $message, '3X243/4', 403, '' );
|
||||
}
|
||||
|
||||
/* Init */
|
||||
$notPresentOnServer = array();
|
||||
$notPresentInDb = array();
|
||||
$domainsDontMatch = array();
|
||||
$expiredButnotSuspended = array();
|
||||
$diskSpaceAllocated = 0;
|
||||
$diskSpaceInUse = 0;
|
||||
$accounts = array();
|
||||
$suspendedButNotExpired = array();
|
||||
$doesNotResolveCorrectly= array();
|
||||
|
||||
/* Get accounts in the database */
|
||||
foreach ( \IPS\Db::i()->select( 'nexus_hosting_accounts.*, nexus_purchases.ps_active', 'nexus_hosting_accounts', array( 'account_server=?', $server->id ), 'account_username' )->join( 'nexus_purchases', 'nexus_hosting_accounts.ps_id=nexus_purchases.ps_id' ) as $row )
|
||||
{
|
||||
/* If we don't think it exists, check if it does */
|
||||
if ( !$row['account_exists'] )
|
||||
{
|
||||
if ( isset( $serverAccounts[ $row['account_username'] ] ) )
|
||||
{
|
||||
$row['account_exists'] = 1;
|
||||
\IPS\Db::i()->update( 'nexus_hosting_accounts', array( 'account_exists' => 1 ), "ps_id={$row['ps_id']}" );
|
||||
}
|
||||
}
|
||||
|
||||
// Now check it
|
||||
if ( $row['account_exists'] )
|
||||
{
|
||||
// Is it in there?
|
||||
if ( isset( $serverAccounts[ $row['account_username'] ] ) )
|
||||
{
|
||||
$accounts[] = array_merge( $row, $serverAccounts[ $row['account_username'] ] );
|
||||
|
||||
// Does the domain match?
|
||||
if ( $serverAccounts[ $row['account_username'] ]['domain'] != $row['account_domain'] )
|
||||
{
|
||||
$row['domain'] = $serverAccounts[ $row['account_username'] ]['domain'];
|
||||
$domainsDontMatch[] = $row;
|
||||
}
|
||||
|
||||
// Does the status match?
|
||||
if ( $row['ps_active'] and !$serverAccounts[ $row['account_username'] ]['active'] )
|
||||
{
|
||||
$suspendedButNotExpired[] = $row;
|
||||
}
|
||||
elseif ( !$row['ps_active'] and $serverAccounts[ $row['account_username'] ]['active'] )
|
||||
{
|
||||
$expiredButnotSuspended[] = $row;
|
||||
}
|
||||
|
||||
// Does it resolve correctly? */
|
||||
if ( gethostbyname( $row['account_domain'] ) !== $server->ip )
|
||||
{
|
||||
$doesNotResolveCorrectly[] = $row;
|
||||
}
|
||||
|
||||
// Get disk use
|
||||
if( $diskSpaceAllocated == -1 or $serverAccounts[ $row['account_username'] ]['disklimit'] == 'unlimited' )
|
||||
{
|
||||
$diskSpaceAllocated = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$diskSpaceAllocated += $serverAccounts[ $row['account_username'] ]['disklimit'];
|
||||
}
|
||||
$diskSpaceInUse += $serverAccounts[ $row['account_username'] ]['diskused'];
|
||||
|
||||
// Note that we have it
|
||||
unset( $serverAccounts[ $row['account_username'] ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !$row['ps_active'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_hosting_accounts', array( 'account_exists' => 0 ), "ps_id={$row['ps_id']}" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$notPresentOnServer[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$notPresentInDb = $serverAccounts;
|
||||
|
||||
/* Return */
|
||||
return array( $server, $notPresentOnServer, $notPresentInDb, $domainsDontMatch, $diskSpaceAllocated, $diskSpaceInUse, $expiredButnotSuspended, $suspendedButNotExpired, $doesNotResolveCorrectly, $accounts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add/Edit Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$availableTypes = \IPS\nexus\Hosting\Server::serverTypes();
|
||||
if( isset( \IPS\Request::i()->server_type ) and \array_key_exists( \IPS\Request::i()->server_type, $availableTypes ) )
|
||||
{
|
||||
$this->nodeClass = $availableTypes[ mb_ucfirst( \IPS\Request::i()->server_type ) ];
|
||||
}
|
||||
|
||||
parent::form();
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Hosting Settings
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 08 Aug 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\hosting;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hosting Settings
|
||||
*/
|
||||
class _settings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Init */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
|
||||
/* Account Management */
|
||||
$form->addTab('hosting_account_management');
|
||||
$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');
|
||||
$form->addHeader('domain_options');
|
||||
$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 ) )
|
||||
{
|
||||
$optionsVal[] = 'enom';
|
||||
}
|
||||
if ( \IPS\Settings::i()->nexus_hosting_subdomains )
|
||||
{
|
||||
$optionsVal[] = 'sub';
|
||||
}
|
||||
if ( \IPS\Settings::i()->nexus_hosting_allow_own_domain )
|
||||
{
|
||||
$optionsVal[] = 'own';
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'domain_options', $optionsVal, FALSE, array(
|
||||
'options' => array(
|
||||
'enom' => 'domain_options_enom',
|
||||
'sub' =>'domain_options_sub',
|
||||
'own' => 'domain_options_own'
|
||||
),
|
||||
'toggles' => array(
|
||||
'enom' => array( 'form_header_nexus_domain_prices', 'nexus_domain_prices', 'nexus_domain_tax' ),
|
||||
'sub' => array( 'form_header_nexus_hosting_sub', 'nexus_hosting_subdomains' ),
|
||||
'own' => array( 'nexus_hosting_own_domains' )
|
||||
),
|
||||
'disabled' => \IPS\Settings::i()->nexus_enom_un ? array() : array( 'enom' )
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'nexus_hosting_nameservers', explode( ',', \IPS\Settings::i()->nexus_hosting_nameservers ), FALSE, array(), function( $val ) {
|
||||
if ( empty( $val ) and ( array_key_exists( 'enom', \IPS\Request::i()->domain_options ) or ( array_key_exists( 'own', \IPS\Request::i()->domain_options ) and array_key_exists( 'nameservers', \IPS\Request::i()->nexus_hosting_own_domains ) ) ) )
|
||||
{
|
||||
throw new \DomainException('nexus_hosting_nameservers_err');
|
||||
}
|
||||
}, NULL, NULL, 'nexus_hosting_nameservers' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'nexus_hosting_subdomains', explode( ',', \IPS\Settings::i()->nexus_hosting_subdomains ), FALSE, array(), NULL, NULL, NULL, 'nexus_hosting_subdomains' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'nexus_hosting_own_domains', explode( ',', \IPS\Settings::i()->nexus_hosting_own_domains ), FALSE, array(
|
||||
'options' => array(
|
||||
'nameservers' => 'nexus_hosting_own_domains_nameservers',
|
||||
'aname' => 'nexus_hosting_own_domains_aname',
|
||||
'cname' => 'nexus_hosting_own_domains_cname',
|
||||
),
|
||||
'toggles' => array(
|
||||
'cname' => array( 'nexus_hosting_own_domain_sub' )
|
||||
)
|
||||
), NULL, NULL, NULL, 'nexus_hosting_own_domains' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'nexus_hosting_own_domain_sub', \IPS\Settings::i()->nexus_hosting_own_domain_sub, FALSE, array(), function( $val ) {
|
||||
if ( !$val and array_key_exists( 'own', \IPS\Request::i()->domain_options ) and array_key_exists( 'cname', \IPS\Request::i()->nexus_hosting_own_domains ) )
|
||||
{
|
||||
throw new \DomainException('nexus_hosting_own_domain_sub_err');
|
||||
}
|
||||
}, NULL, NULL, 'nexus_hosting_own_domain_sub' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_hosting_allow_change_domain', \IPS\Settings::i()->nexus_hosting_allow_change_domain, FALSE, array(), NULL, NULL, NULL ) );
|
||||
$form->addHeader('nexus_domain_prices');
|
||||
$matrix = new \IPS\Helpers\Form\Matrix( 'prices' );
|
||||
$matrix->squashFields = FALSE;
|
||||
$matrix->columns = array(
|
||||
'domain_tld' => array( 'Text' ),
|
||||
'domain_price' => function( $key, $value, $data )
|
||||
{
|
||||
return new \IPS\nexus\Form\Money( $key, $value, FALSE, array() );
|
||||
},
|
||||
);
|
||||
if ( \count( $domainPrices ) )
|
||||
{
|
||||
foreach ( $domainPrices as $tld => $prices )
|
||||
{
|
||||
$matrix->rows[] = array( 'domain_tld' => $tld, 'domain_price' => $prices );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$matrix->rows = array( array( 'domain_tld' => 'com', 'domain_price' => NULL ) );
|
||||
}
|
||||
$form->addMatrix( 'nexus_domain_prices', $matrix );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'nexus_domain_tax', \IPS\Settings::i()->nexus_domain_tax, FALSE, array( 'class' => 'IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ), NULL, NULL, NULL, 'nexus_domain_tax' ) );
|
||||
|
||||
/* Bandwidth */
|
||||
$form->addTab('nexus_hosting_bandwidth');
|
||||
$form->addMessage( 'nexus_hosting_bandwidth_blurb' );
|
||||
$bandwidthMatrix = new \IPS\Helpers\Form\Matrix( 'bandwidth' );
|
||||
$bandwidthMatrix->squashFields = FALSE;
|
||||
$bandwidthMatrix->columns = array(
|
||||
'bandwidth_amount' => array( 'Number' ),
|
||||
'bandwidth_price' => function( $key, $value, $data )
|
||||
{
|
||||
return new \IPS\nexus\Form\Money( $key, $value, FALSE, array() );
|
||||
},
|
||||
);
|
||||
$bandwidthPrices = json_decode( \IPS\Settings::i()->nexus_hosting_bandwidth, TRUE );
|
||||
if ( \count( $bandwidthPrices ) )
|
||||
{
|
||||
foreach ( $bandwidthPrices as $amount => $prices )
|
||||
{
|
||||
$bandwidthMatrix->rows[] = array( 'bandwidth_amount' => $amount, 'bandwidth_price' => $prices );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bandwidthMatrix->rows = array();
|
||||
}
|
||||
$form->addMatrix( 'nexus_hosting_bandwidth', $bandwidthMatrix );
|
||||
|
||||
/* Handle Submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$domainPrices = array();
|
||||
if ( \in_array( 'enom', $values['domain_options'] ) )
|
||||
{
|
||||
foreach ( $values['nexus_domain_prices'] as $option )
|
||||
{
|
||||
if ( $option['domain_tld'] )
|
||||
{
|
||||
$domainPrices[ $option['domain_tld'] ] = $option['domain_price'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$values['nexus_domain_prices'] = json_encode( $domainPrices );
|
||||
$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'] ) : '';
|
||||
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => (bool) $values['nexus_hosting_terminate'] ), "`key`='terminateHosting'" );
|
||||
|
||||
$bandwidthPrices = array();
|
||||
|
||||
foreach ( $values['nexus_hosting_bandwidth'] as $key => $option )
|
||||
{
|
||||
if ( $option['bandwidth_amount'] )
|
||||
{
|
||||
$bandwidthPrices[ $option['bandwidth_amount'] ] = $option['bandwidth_price'];
|
||||
}
|
||||
}
|
||||
$values['nexus_hosting_bandwidth'] = json_encode( $bandwidthPrices );
|
||||
|
||||
unset( $values['domain_options'] );
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__hosting_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=nexus&module=hosting&controller=settings" ) );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
if ( !\IPS\Settings::i()->nexus_enom_un )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['domain_options_enom_desc'] = \IPS\Member::loggedIn()->language()->get( 'domain_options_enom_dis' );
|
||||
}
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('hosting_settings');
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -56,10 +56,6 @@ class _checkoutsettings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$requireBillingOptions['donation'] = 'nexus_require_billing_donation';
|
||||
}
|
||||
if ( \IPS\Settings::i()->nexus_enom_un and $domainPrices = json_decode( \IPS\Settings::i()->nexus_domain_prices, TRUE ) and \count( $domainPrices ) )
|
||||
{
|
||||
$requireBillingOptions['domain'] = 'nexus_require_billing_domain';
|
||||
}
|
||||
|
||||
if ( \IPS\Settings::i()->nexus_subs_enabled and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_member_subscription_packages' )->first() )
|
||||
{
|
||||
|
||||
@@ -89,8 +89,8 @@ class _gateways extends \IPS\Node\Controller
|
||||
$options = array();
|
||||
foreach ( \IPS\nexus\Gateway::gateways() as $key => $class )
|
||||
{
|
||||
/* Deprecate Authorize.net, don't allow it to be used for new gateways */
|
||||
if( $key === 'AuthorizeNet' )
|
||||
/* Deprecate Authorize.net, Braintree and 2Checkout don't allow them to be used for new gateways */
|
||||
if( \in_array( $key, array( 'AuthorizeNet', 'TwoCheckout', 'Braintree' ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ class _invoices extends \IPS\Dispatcher\Controller
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
$table = \IPS\nexus\Invoice::table( $where, $url, 't' );
|
||||
|
||||
$table->advancedSearch = array(
|
||||
'i_id' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'i_title' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
@@ -249,7 +250,7 @@ class _invoices extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global', 'core')->decision( 'invoice_paid_trans', array(
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global', 'core', 'global')->decision( 'invoice_paid_trans', array(
|
||||
'invoice_paid_trans_view' => $transUrl,
|
||||
'invoice_paid_trans_ovrd' => $invoice->acpUrl()->setQueryString( array( 'do' => 'paid', 'override' => 1 ) )->csrf()
|
||||
) );
|
||||
@@ -910,7 +911,7 @@ class _invoices extends \IPS\Dispatcher\Controller
|
||||
$invoice->delete();
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=payments&controller=invoices') );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=payments&controller=invoices')->getSafeUrlFromFilters() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -141,14 +141,24 @@ class _payouts extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Output::i()->error( $e->getMessage(), '1X200/1', 500, '' );
|
||||
}
|
||||
|
||||
$payout->status = $payout::STATUS_COMPLETE;
|
||||
|
||||
$payout->processed_by = \IPS\Member::loggedIn();
|
||||
$payout->save();
|
||||
\IPS\Session::i()->log( 'acplogs__payout_processed', array( $payout->id => FALSE ) );
|
||||
$payout->member->log( 'payout', array( 'type' => 'processed', 'amount' => $payout->amount->amount, 'currency' => $payout->amount->currency, 'payout_id' => $payout->id ) );
|
||||
|
||||
\IPS\Email::buildFromTemplate( 'nexus', 'payoutComplete', array( $payout ), \IPS\Email::TYPE_TRANSACTIONAL )->send( $payout->member );
|
||||
|
||||
/* If the payout was actually completed, notify the user */
|
||||
if( $payout->status == \IPS\nexus\Payout::STATUS_COMPLETE )
|
||||
{
|
||||
$payout->markCompleted();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Use task if the payout is pending */
|
||||
$task = \IPS\Task::load( 'payoutPending', 'key', [ 'app=?', 'nexus' ] );
|
||||
$task->enabled = TRUE;
|
||||
$task->save();
|
||||
}
|
||||
|
||||
$this->_redirect( $payout );
|
||||
}
|
||||
@@ -179,17 +189,31 @@ class _payouts extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Output::i()->error( $e->getMessage(), '1X200/9', 403, '' );
|
||||
}
|
||||
|
||||
|
||||
$pending = 0;
|
||||
foreach ( $payouts as $payout )
|
||||
{
|
||||
$payout->status = $payout::STATUS_COMPLETE;
|
||||
$payout->completed = new \IPS\DateTime;
|
||||
$payout->processed_by = \IPS\Member::loggedIn();
|
||||
$payout->save();
|
||||
\IPS\Session::i()->log( 'acplogs__payout_processed', array( $payout->id => FALSE ) );
|
||||
$payout->member->log( 'payout', array( 'type' => 'processed', 'amount' => $payout->amount->amount, 'currency' => $payout->amount->currency, 'payout_id' => $payout->id ) );
|
||||
|
||||
\IPS\Email::buildFromTemplate( 'nexus', 'payoutComplete', array( $payout ), \IPS\Email::TYPE_TRANSACTIONAL )->send( $payout->member );
|
||||
|
||||
/* Only do this if the payout is actually complete! */
|
||||
if( $payout->status == \IPS\nexus\Payout::STATUS_COMPLETE )
|
||||
{
|
||||
$payout->markCompleted();
|
||||
continue;
|
||||
}
|
||||
|
||||
$pending++;
|
||||
}
|
||||
|
||||
/* Use task if there are incomplete payouts */
|
||||
if( $pending )
|
||||
{
|
||||
$task = \IPS\Task::load( 'payoutPending', 'key', [ 'app=?', 'nexus' ] );
|
||||
$task->enabled = TRUE;
|
||||
$task->save();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=payments&controller=payouts') );
|
||||
@@ -374,6 +398,12 @@ class _payouts extends \IPS\Dispatcher\Controller
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
\IPS\Session::i()->log( 'acplogs__payout_settings' );
|
||||
|
||||
/* Remove any ACP notifications related to Payout Settings */
|
||||
foreach( \IPS\nexus\Gateway::payoutGateways() as $key => $class )
|
||||
{
|
||||
\IPS\core\AdminNotification::remove( 'nexus', 'ConfigurationError', "po{$key}" );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=payments&controller=payouts'), 'saved' );
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class _shippingrates extends \IPS\Node\Controller
|
||||
*/
|
||||
protected function warning()
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'ship_rates_' . \IPS\Request::i()->type, array(
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->decision( 'ship_rates_' . \IPS\Request::i()->type, array(
|
||||
'ship_rates_go_back' => \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=shippingrates&do=form&id=' . \IPS\Request::i()->id ),
|
||||
'ship_rates_save_anyway' => $this->url,
|
||||
) );
|
||||
|
||||
@@ -72,109 +72,12 @@ class _income extends \IPS\Dispatcher\Controller
|
||||
$tabs[ $currency ] = \IPS\Member::loggedIn()->language()->addToStack( 'nexus_report_income_by_method', FALSE, array( 'sprintf' => array( $currency ) ) );
|
||||
}
|
||||
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'totals';
|
||||
\IPS\Request::i()->tab ??= 'totals';
|
||||
$activeTab = ( array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'totals';
|
||||
|
||||
$chart = new \IPS\Helpers\Chart\Database(
|
||||
\IPS\Http\Url::internal( 'app=nexus&module=reports&controller=income&tab=' . $activeTab ),
|
||||
'nexus_transactions',
|
||||
't_date',
|
||||
'',
|
||||
array(
|
||||
'backgroundColor' => '#ffffff',
|
||||
'colors' => array( '#10967e', '#ea7963', '#de6470', '#6b9dde', '#b09be4', '#eec766', '#9fc973', '#e291bf', '#55c1a6', '#5fb9da' ),
|
||||
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
),
|
||||
( \IPS\Request::i()->tab == 'members' ) ? 'PieChart' : 'AreaChart',
|
||||
'monthly',
|
||||
array( 'start' => 0, 'end' => 0 ),
|
||||
array(),
|
||||
$activeTab
|
||||
);
|
||||
$chart->where[] = array( '( t_status=? OR t_status=? ) AND t_method>0', \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED );
|
||||
|
||||
if ( $activeTab === 'totals' )
|
||||
{
|
||||
$chart->groupBy = 't_currency';
|
||||
|
||||
foreach ( $currencies as $currency )
|
||||
{
|
||||
$chart->addSeries( $currency, 'number', 'SUM(t_amount)-SUM(t_partial_refund)', TRUE, $currency );
|
||||
}
|
||||
}
|
||||
elseif( mb_strpos( $activeTab, 'members' ) === 0 )
|
||||
{
|
||||
$chart->groupBy = 't_member';
|
||||
|
||||
if( \count( $currencies ) === 1 )
|
||||
{
|
||||
$chart->format = array_pop( $currencies );
|
||||
}
|
||||
else
|
||||
{
|
||||
$chart->format = mb_substr( $activeTab, 8 );
|
||||
$chart->where[] = array( 't_currency=?', $chart->format );
|
||||
}
|
||||
|
||||
foreach ( \IPS\Db::i()->select( 't_member, SUM(t_amount)-SUM(t_partial_refund) as _amount', 'nexus_transactions', $chart->where, '_amount DESC', array( 0, 20 ), 't_member' ) as $member )
|
||||
{
|
||||
$chart->addSeries( \IPS\Member::load( $member['t_member'] )->name, 'number', 'SUM(t_amount)-SUM(t_partial_refund)', TRUE, $member['t_member'] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$chart->where[] = array( 't_currency=?', $activeTab );
|
||||
$chart->groupBy = 't_method';
|
||||
$chart->format = $activeTab;
|
||||
|
||||
foreach ( \IPS\nexus\Gateway::roots() as $gateway )
|
||||
{
|
||||
$chart->addSeries( $gateway->_title, 'number', 'SUM(t_amount)-SUM(t_partial_refund)', TRUE, $gateway->id );
|
||||
}
|
||||
}
|
||||
|
||||
$chart->tableInclude = array( 't_id', 't_member', 't_invoice', 't_method', 't_amount', 't_date' );
|
||||
$chart->tableParsers = array(
|
||||
't_member' => function( $val ) {
|
||||
return \IPS\Theme::i()->getTemplate('global', 'nexus')->userLink( \IPS\Member::load( $val ) );
|
||||
},
|
||||
't_method' => function( $val ) {
|
||||
if ( $val )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Gateway::load( $val )->_title;
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('account_credit');
|
||||
}
|
||||
},
|
||||
't_amount' => function( $val, $row )
|
||||
{
|
||||
return (string) new \IPS\nexus\Money( $val, $row['t_currency'] );
|
||||
},
|
||||
't_invoice' => function( $val )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('invoices', 'nexus')->link( \IPS\nexus\Invoice::load( $val ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
},
|
||||
't_date' => function( $val ) {
|
||||
return \IPS\DateTime::ts( $val );
|
||||
}
|
||||
);
|
||||
$extension = \IPS\core\Statistics\Chart::loadFromExtension( 'nexus', 'Income' );
|
||||
$chart = $extension->getChart( \IPS\Http\Url::internal( 'app=nexus&module=reports&controller=income&tab=' . $activeTab ) );
|
||||
$extension->setExtra( $chart, $activeTab );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
|
||||
@@ -57,45 +57,20 @@ class _markets extends \IPS\Dispatcher\Controller
|
||||
$tabs[ $currency ] = \IPS\Member::loggedIn()->language()->addToStack( 'nexus_report_income', FALSE, array( 'sprintf' => array( $currency ) ) );
|
||||
}
|
||||
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'count';
|
||||
|
||||
$chart = new \IPS\Helpers\Chart\Database(
|
||||
\IPS\Http\Url::internal( 'app=nexus&module=reports&controller=markets&tab=' . $activeTab ),
|
||||
'nexus_invoices',
|
||||
'i_paid',
|
||||
'',
|
||||
array(
|
||||
'backgroundColor' => '#ffffff',
|
||||
'colors' => array( '#c9e2de', '#10967e' ),
|
||||
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
),
|
||||
'GeoChart',
|
||||
'monthly',
|
||||
array( 'start' => 0, 'end' => 0 ),
|
||||
array(),
|
||||
$activeTab
|
||||
);
|
||||
$chart->availableTypes[] = 'GeoChart';
|
||||
$chart->where[] = array( 'i_status=? AND i_billcountry IS NOT NULL', \IPS\nexus\Invoice::STATUS_PAID );
|
||||
\IPS\Request::i()->tab ??= 'count';
|
||||
$activeTab = ( array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'count';
|
||||
$extension = \IPS\core\Statistics\Chart::loadFromExtension( 'nexus', 'Market' );
|
||||
$chart = $extension->getChart( \IPS\Http\Url::internal( "app=nexus&module=reports&controller=markets&tab={$activeTab}" ) );
|
||||
|
||||
if ( $activeTab !== 'count' )
|
||||
{
|
||||
$chart->where[] = array( 'i_currency=?', $activeTab );
|
||||
$chart->format = $activeTab;
|
||||
}
|
||||
$chart->groupBy = 'i_billcountry';
|
||||
|
||||
foreach ( \IPS\GeoLocation::$countries as $countryCode )
|
||||
{
|
||||
$chart->addSeries( [ 'value' => \IPS\Member::loggedIn()->language()->get( 'country-' . $countryCode ), 'key' => $countryCode ], 'number', $activeTab === 'count' ? 'COUNT(*)' : 'SUM(i_total)', TRUE, $countryCode );
|
||||
try
|
||||
{
|
||||
$extension->setCurrency( $chart, $activeTab );
|
||||
}
|
||||
catch( \InvalidArgumentException ) {}
|
||||
}
|
||||
|
||||
if ( $chart->type === 'GeoChart' )
|
||||
{
|
||||
$chart->options['height'] = 750;
|
||||
$chart->options['keepAspectRatio'] = true;
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
|
||||
@@ -51,46 +51,7 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart\Database(
|
||||
\IPS\Http\Url::internal('app=nexus&module=reports&controller=purchases'),
|
||||
'nexus_purchases',
|
||||
'ps_start',
|
||||
'',
|
||||
array(
|
||||
'backgroundColor' => '#ffffff',
|
||||
'colors' => array( '#10967e', '#ea7963', '#de6470', '#6b9dde', '#b09be4', '#eec766', '#9fc973', '#e291bf', '#55c1a6', '#5fb9da' ),
|
||||
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
)
|
||||
);
|
||||
$chart->where[] = array( 'ps_app=? AND ps_type=?', 'nexus', 'package' );
|
||||
$chart->groupBy = 'ps_item_id';
|
||||
$chart->tableInclude = array( 'ps_id', 'ps_member', 'ps_name', 'ps_start', 'ps_expire' );
|
||||
$chart->tableParsers = array(
|
||||
'ps_member' => function( $val ) {
|
||||
return \IPS\Theme::i()->getTemplate('global', 'nexus')->userLink( \IPS\Member::load( $val ) );
|
||||
},
|
||||
'ps_start' => function( $val ) {
|
||||
return \IPS\DateTime::ts( $val );
|
||||
},
|
||||
'ps_expire' => function( $val ) {
|
||||
return $val ? \IPS\DateTime::ts( $val ) : '';
|
||||
}
|
||||
);
|
||||
|
||||
$packages = array();
|
||||
foreach ( \IPS\Db::i()->select( 'p_id', 'nexus_packages' ) as $packageId )
|
||||
{
|
||||
$packages[ $packageId ] = \IPS\Member::loggedIn()->language()->get( 'nexus_package_' . $packageId );
|
||||
}
|
||||
|
||||
asort( $packages );
|
||||
foreach ( $packages as $id => $name )
|
||||
{
|
||||
$chart->addSeries( $name, 'number', 'COUNT(*)', TRUE, $id );
|
||||
}
|
||||
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'nexus', 'Sales' )->getChart( \IPS\Http\Url::internal( 'app=nexus&module=reports&controller=purchases' ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_reports_purchases');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class _packages extends \IPS\Node\Controller
|
||||
existing purchases unnecessarily */
|
||||
if ( !empty( $changes ) AND $purchases )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'product_change_blurb', array(
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->decision( 'product_change_blurb', array(
|
||||
'product_change_blurb_existing' => \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=updateExisting&id={$new->_id}" )->setQueryString( 'changes', json_encode( $changes ) )->csrf(),
|
||||
'product_change_blurb_new' => $this->url->setQueryString( array( 'root' => ( $new->parent() ? $new->parent()->_id : '' ) ) ),
|
||||
) );
|
||||
@@ -423,7 +423,7 @@ class _packages extends \IPS\Node\Controller
|
||||
) )->csrf();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'change_renew_ba_blurb', $options );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->decision( 'change_renew_ba_blurb', $options );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ class _subscriptions extends \IPS\Node\Controller
|
||||
}
|
||||
$options['cancel'] = \IPS\Http\Url::internal( "app=nexus&module=subscriptions&controller=subscriptions" );
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'subscription_delete_blurb', $options );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->decision( 'subscription_delete_blurb', $options );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ class _subscriptions extends \IPS\Node\Controller
|
||||
existing purchases unnecessarily */
|
||||
if ( !empty( $changes ) AND $purchases )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'product_change_blurb', array(
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->decision( 'product_change_blurb', array(
|
||||
'product_change_blurb_existing' => \IPS\Http\Url::internal( "app=nexus&module=subscriptions&controller=subscriptions&do=updateExisting&id={$new->_id}" )->setQueryString( 'changes', json_encode( $changes ) )->csrf(),
|
||||
'product_change_blurb_new' => $this->url->setQueryString( array( 'root' => ( $new->parent() ? $new->parent()->_id : '' ) ) ),
|
||||
) );
|
||||
@@ -633,7 +633,7 @@ class _subscriptions extends \IPS\Node\Controller
|
||||
) )->csrf();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'change_renew_ba_blurb', $options );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->decision( 'change_renew_ba_blurb', $options );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,44 +45,8 @@ class _volume extends \IPS\Dispatcher\Controller
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( 'app=nexus&module=support&controller=volume' ), 'nexus_support_requests', 'r_started', '',
|
||||
array(
|
||||
'vAxis' => array( 'title' => \IPS\Member::loggedIn()->language()->addToStack('support_requests_created') ),
|
||||
'backgroundColor' => '#ffffff',
|
||||
'colors' => array( '#10967e', '#ea7963', '#de6470', '#6b9dde', '#b09be4', '#eec766', '#9fc973', '#e291bf', '#55c1a6', '#5fb9da' ),
|
||||
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
),
|
||||
'AreaChart'
|
||||
);
|
||||
$chart->groupBy = 'r_department';
|
||||
foreach( \IPS\nexus\Support\Department::roots() as $department )
|
||||
{
|
||||
$chart->addSeries( $department->_title, 'number', 'COUNT(*)', TRUE, $department->id );
|
||||
}
|
||||
|
||||
$chart->tableInclude = array( 'r_id', 'r_title', 'r_member', 'r_department', 'r_status', 'r_started', 'r_last_reply', 'r_replies' );
|
||||
$chart->tableParsers = array(
|
||||
'r_member' => function( $val ) {
|
||||
return \IPS\Theme::i()->getTemplate('global', 'nexus')->userLink( \IPS\Member::load( $val ) );
|
||||
},
|
||||
'r_department' => function( $val ) {
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'nexus_department_' . $val );
|
||||
},
|
||||
'r_status' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'nexus_status_' . $val . '_admin' );
|
||||
},
|
||||
'r_started' => function( $val ) {
|
||||
return \IPS\DateTime::ts( $val );
|
||||
},
|
||||
'r_last_reply' => function( $val ) {
|
||||
return \IPS\DateTime::ts( $val );
|
||||
}
|
||||
);
|
||||
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'nexus', 'Support' )->getChart( \IPS\Http\Url::internal( "app=nexus&module=support&controller=volume" ) );
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_support_volume');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user