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

@@ -12,7 +12,7 @@
namespace IPS\nexus\modules\admin\payments;
/* 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 _payouts extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -64,13 +69,13 @@ class _payouts extends \IPS\Dispatcher\Controller
foreach ( \IPS\Db::i()->select( 'po_gateway', 'nexus_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ), NULL, NULL, 'po_gateway' ) as $gateway )
{
$classname = 'IPS\nexus\Gateway\\' . $gateway . '\Payout';
$classname = \IPS\nexus\Gateway::payoutGateways()[ $gateway ];
if ( class_exists( $classname ) and method_exists( $classname, 'massProcess' ) )
{
\IPS\Output::i()->sidebar['actions'][] = array(
'icon' => 'check',
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'account_credit_mass_payout', TRUE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'payout__admin_' . $gateway ) ) ) ),
'link' => \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=payouts&do=massprocess&gateway=' . $gateway )
'link' => \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=payouts&do=massprocess&gateway=' . $gateway )->csrf()
);
}
}
@@ -107,6 +112,7 @@ class _payouts extends \IPS\Dispatcher\Controller
protected function process()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'payouts_process' );
\IPS\Session::i()->csrfCheck();
try
{
@@ -150,8 +156,9 @@ class _payouts extends \IPS\Dispatcher\Controller
protected function massprocess()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'payouts_process' );
\IPS\Session::i()->csrfCheck();
$classname = 'IPS\nexus\Gateway\\' . \IPS\Request::i()->gateway . '\Payout';
$classname = \IPS\nexus\Gateway::payoutGateways()[ \IPS\Request::i()->gateway ];
if ( !class_exists( $classname ) or !method_exists( $classname, 'massProcess' ) )
{
\IPS\Output::i()->error( 'generic_error', '2X200/8', 403, '' );
@@ -191,6 +198,7 @@ class _payouts extends \IPS\Dispatcher\Controller
protected function cancel()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'payouts_cancel' );
\IPS\Session::i()->csrfCheck();
try
{
@@ -264,24 +272,20 @@ class _payouts extends \IPS\Dispatcher\Controller
$options = array();
$toggles = array();
$fields = array();
foreach ( new \DirectoryIterator( \IPS\ROOT_PATH . '/applications/nexus/sources/Gateway' ) as $file )
foreach ( \IPS\nexus\Gateway::payoutGateways() as $key => $class )
{
if ( $file->isDir() and !$file->isDot() and $file != 'Stripe' and file_exists( \IPS\ROOT_PATH . '/applications/nexus/sources/Gateway/' . $file . '/Payout.php' ) )
$options[ $key ] = 'payout__admin_' . $key;
$toggles[ $key ] = array( 'form_header_payout_settings' );
foreach ( $class::settings() as $field )
{
$options[ (string) $file ] = 'payout__admin_' . $file;
$toggles[ (string) $file ] = array( 'form_header_payout_settings' );
$class = 'IPS\nexus\Gateway\\' . (string) $file . '\\Payout';
foreach ( $class::settings() as $field )
if ( !$field->htmlId )
{
if ( !$field->htmlId )
{
$field->htmlId = md5(mt_rand());
}
$fields[] = $field;
$toggles[ (string) $file ][] = $field->htmlId;
$field->htmlId = md5(mt_rand());
}
$fields[] = $field;
$toggles[ $key ][] = $field->htmlId;
}
}
@@ -292,7 +296,7 @@ class _payouts extends \IPS\Dispatcher\Controller
}
$settings = \IPS\Settings::i()->nexus_payout ? json_decode( \IPS\Settings::i()->nexus_payout, TRUE ) : array();
$settings = is_array( $settings ) ? array_keys( $settings ) : array();
$settings = \is_array( $settings ) ? array_keys( $settings ) : array();
$form = new \IPS\Helpers\Form;
$form->addMessage('payout_description');
@@ -305,10 +309,10 @@ class _payouts extends \IPS\Dispatcher\Controller
$form->add( $field );
}
$form->addHeader('payout_settings');
$form->add( new \IPS\nexus\Form\Money( 'nexus_payout_min', \IPS\Settings::i()->nexus_payout_min ? json_decode( \IPS\Settings::i()->nexus_payout_min, TRUE ) : '*', FALSE, array( 'unlimitedLang' => 'no_restriction' ), NULL, NULL, NULL, 'nexus_payout_min' ) );
$form->add( new \IPS\nexus\Form\Money( 'nexus_payout_min', ( \IPS\Settings::i()->nexus_payout_min AND \IPS\Settings::i()->nexus_payout_min != '*' ) ? json_decode( \IPS\Settings::i()->nexus_payout_min, TRUE ) : '*', FALSE, array( 'unlimitedLang' => 'no_restriction' ), NULL, NULL, NULL, 'nexus_payout_min' ) );
$form->add( new \IPS\Helpers\Form\Custom( 'nexus_payout_maximum', NULL, FALSE, array( 'getHtml' => function( $element ) {
$amount = new \IPS\nexus\Form\Money( 'nexus_payout_maximum[2]', \IPS\Settings::i()->nexus_payout_max ? json_decode( \IPS\Settings::i()->nexus_payout_max, TRUE ) : '*', FALSE, array( 'unlimitedLang' => 'no_restriction', 'unlimitedTogglesOff' => array( 'payout_max_limited' ) ), NULL, NULL, NULL, 'nexus_payout_max' );
$amount = new \IPS\nexus\Form\Money( 'nexus_payout_maximum[2]', ( \IPS\Settings::i()->nexus_payout_max AND \IPS\Settings::i()->nexus_payout_max != '*' ) ? json_decode( \IPS\Settings::i()->nexus_payout_max, TRUE ) : '*', FALSE, array( 'unlimitedLang' => 'no_restriction', 'unlimitedTogglesOff' => array( 'payout_max_limited' ) ), NULL, NULL, NULL, 'nexus_payout_max' );
$period = \IPS\Settings::i()->nexus_payout_max_period ? json_decode( \IPS\Settings::i()->nexus_payout_max_period, TRUE ) : array( 1, 'day' );
return \IPS\Theme::i()->getTemplate( 'payouts' )->maximumLimits( $amount->html(), (int) $period[0], $period[1] );
@@ -334,12 +338,18 @@ class _payouts extends \IPS\Dispatcher\Controller
}
}
}
/* Clear out gateway fields that aren't real settings */
foreach( $fields as $field )
{
unset( $values[ $field->name ] );
}
$values['nexus_payout'] = json_encode( $payoutSettings );
$values['nexus_payout_min'] = is_array( $values['nexus_payout_min'] ) ? json_encode( $values['nexus_payout_min'] ) : '*';
$values['nexus_payout_max'] = is_array( $values['nexus_payout_maximum'][2] ) ? json_encode( $values['nexus_payout_maximum'][2] ) : '*';
$values['nexus_payout_max_period'] = json_encode( array( $values['nexus_payout_maximum'][0], $values['nexus_payout_maximum'][1] ) );
$values['nexus_payout_min'] = \is_array( $values['nexus_payout_min'] ) ? json_encode( $values['nexus_payout_min'] ) : '*';
$values['nexus_payout_max'] = ( \is_array( $values['nexus_payout_maximum'][2] ) AND ( !isset( $values['nexus_payout_maximum'][2]['__unlimited'] ) OR !$values['nexus_payout_maximum'][2]['__unlimited'] ) ) ? json_encode( $values['nexus_payout_maximum'][2] ) : '*';
$values['nexus_payout_max_period'] = ( $values['nexus_payout_max'] == '*' ) ? NULL : json_encode( array( $values['nexus_payout_maximum'][0], $values['nexus_payout_maximum'][1] ) );
if ( $values['allow_topups'] )
{
$values['nexus_min_topup'] = $values['nexus_min_topup'] == '*' ? '*' : json_encode( $values['nexus_min_topup'] );
@@ -350,10 +360,10 @@ class _payouts extends \IPS\Dispatcher\Controller
$values['nexus_min_topup'] = '';
$values['nexus_max_credit'] = '';
}
unset( $values['allow_topups'] );
unset( $values['allow_topups'], $values['nexus_payout_maximum'] );
$values['nexus_no_commission'] = implode( ',', $values['nexus_no_commission'] );
$form->saveAsSettings( $values );
\IPS\Session::i()->log( 'acplogs__payout_settings' );
@@ -387,7 +397,10 @@ class _payouts extends \IPS\Dispatcher\Controller
case 't':
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=payments&controller=payouts')->setQueryString( 'filter', \IPS\Request::i()->filter ) );
break;
case 'n':
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=overview&controller=notifications') );
break;
}
}