Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -12,38 +12,74 @@ namespace IPS\core\modules\admin\moderation;
/* To prevent PHP errors (extending class does not exist) revealing path */
use DomainException;
use IPS\DateTime;
use IPS\Db;
use IPS\Dispatcher;
use IPS\Dispatcher\Controller;
use IPS\GeoLocation;
use IPS\Helpers\Form;
use IPS\Helpers\Form\CheckboxSet;
use IPS\Helpers\Form\Interval;
use IPS\Helpers\Form\Matrix;
use IPS\Helpers\Form\Number;
use IPS\Helpers\Form\Radio;
use IPS\Helpers\Form\Select;
use IPS\Helpers\Form\Stack;
use IPS\Helpers\Form\Text;
use IPS\Helpers\Form\Translatable;
use IPS\Helpers\Form\YesNo;
use IPS\Helpers\Table\Db as TableDb;
use IPS\Http\Url;
use IPS\IPS;
use IPS\Lang;
use IPS\Login;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Settings;
use IPS\Theme;
use UnderflowException;
use function defined;
use function in_array;
use function intval;
use const IPS\Helpers\Table\SEARCH_CONTAINS_TEXT;
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
use const IPS\Helpers\Table\SEARCH_NUMERIC;
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' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Spam Prevention Settings
*/
class _spam extends \IPS\Dispatcher\Controller
class spam extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* @brief The current tab
*/
protected mixed $activeTab;
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
/* Get tab content */
$this->activeTab = \IPS\Request::i()->tab ?: 'captcha';
$this->activeTab = Request::i()->tab ?: 'captcha';
\IPS\Dispatcher::i()->checkAcpPermission( 'spam_manage' );
Dispatcher::i()->checkAcpPermission( 'spam_manage' );
parent::execute();
}
@@ -52,16 +88,16 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
/* Work out output */
$methodFunction = '_manage' . mb_ucfirst( $this->activeTab );
$methodFunction = '_manage' . IPS::mb_ucfirst( $this->activeTab );
$activeTabContents = $this->$methodFunction();
/* If this is an AJAX request, just return it */
if( \IPS\Request::i()->isAjax() )
if( Request::i()->isAjax() )
{
\IPS\Output::i()->output = $activeTabContents;
Output::i()->output = $activeTabContents;
return;
}
@@ -71,49 +107,49 @@ class _spam extends \IPS\Dispatcher\Controller
$tabs['flagging'] = 'spamprevention_flagging';
$tabs['service'] = 'enhancements__core_SpamMonitoring';
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_manage' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_manage' ) and in_array( Login::registrationType(), array( 'normal', 'full' ) ) )
{
$tabs['qanda'] = 'qanda_settings';
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'geolocation' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'geolocation' ) and in_array( Login::registrationType(), array( 'normal', 'full' ) ) AND Settings::i()->ipsgeoip )
{
$tabs['geolocation'] = 'geolocation_settings';
}
/* Add a button for logs */
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_service_log' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_service_log' ) )
{
\IPS\Output::i()->sidebar['actions']['errorLog'] = array(
Output::i()->sidebar['actions']['errorLog'] = array(
'title' => 'spamlogs',
'icon' => 'exclamation-triangle',
'link' => \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=serviceLogs' ),
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=serviceLogs' ),
);
}
/* Add a button for whitelist */
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_whitelist_manage' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_whitelist_manage' ) )
{
\IPS\Output::i()->sidebar['actions']['whitelist'] = array(
Output::i()->sidebar['actions']['whitelist'] = array(
'title' => 'spam_whitelist',
'icon' => 'shield',
'link' => \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=whitelist' ),
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=whitelist' ),
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'membertools_delete' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'membertools_delete' ) )
{
\IPS\Output::i()->sidebar['actions']['delete_guest_content'] = array(
Output::i()->sidebar['actions']['delete_guest_content'] = array(
'title' => 'member_delete_guest_content',
'icon' => 'trash-o',
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=deleteGuestContent' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('member_delete_guest_content') )
'icon' => 'trash',
'link' => Url::internal( 'app=core&module=members&controller=members&do=deleteGuestContent' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('member_delete_guest_content') )
);
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_moderation_spam');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( $tabs, $this->activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=core&module=moderation&controller=spam" ) );
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_moderation_spam');
Output::i()->output = Theme::i()->getTemplate( 'global' )->tabs( $tabs, $this->activeTab, $activeTabContents, Url::internal( "app=core&module=moderation&controller=spam" ) );
}
/**
@@ -122,45 +158,24 @@ class _spam extends \IPS\Dispatcher\Controller
* @param string $type 'options' for the select options, 'toggles' for the toggles
* @return array
*/
protected static function getCaptchaOptions( string $type='options' ) : array
protected function getCaptchaOptions( string $type='options' ) : array
{
switch( $type )
{
case 'options':
$options = [
'none' => 'captcha_type_none',
'turnstile' => 'captcha_type_turnstile',
'invisible' => 'captcha_type_invisible',
'recaptcha2' => 'captcha_type_recaptcha2',
'keycaptcha' => 'captcha_type_keycaptcha',
'hcaptcha' => 'captcha_type_hcaptcha'
];
if( \IPS\Settings::i()->bot_antispam_type != 'keycaptcha' )
{
unset( $options['keycaptcha'] );
}
return $options;
return array( 'none' => 'captcha_type_none', 'invisible' => 'captcha_type_invisible', 'recaptcha2' => 'captcha_type_recaptcha2', 'keycaptcha' => 'captcha_type_keycaptcha', 'hcaptcha' => 'captcha_type_hcaptcha' );
case 'toggles':
$toggles = [
'none' => [ 'bot_antispam_type_warning' ],
'turnstile' => [ 'turnstile_site_key', 'turnstile_secret_key' ],
'recaptcha2' => [ 'recaptcha2_public_key', 'recaptcha2_private_key' ],
'invisible' => [ 'recaptcha2_public_key', 'recaptcha2_private_key' ],
'keycaptcha' => [ 'keycaptcha_privatekey' ],
'hcaptcha' => [ 'hcaptcha_sitekey', 'hcaptcha_secret' ]
];
if( \IPS\Settings::i()->bot_antispam_type != 'keycaptcha' )
{
unset( $toggles['keycaptcha'] );
}
return $toggles;
return array(
'none' => array( 'bot_antispam_type_warning' ),
'recaptcha2' => array( 'guest_captcha', 'recaptcha2_public_key', 'recaptcha2_private_key' ),
'invisible' => array( 'guest_captcha', 'recaptcha2_public_key', 'recaptcha2_private_key' ),
'keycaptcha' => array( 'guest_captcha', 'keycaptcha_privatekey' ),
'hcaptcha' => array( 'guest_captcha', 'hcaptcha_sitekey', 'hcaptcha_secret')
);
}
return [];
return array();
}
/**
@@ -168,65 +183,42 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return string HTML to display
*/
protected function _manageCaptcha()
protected function _manageCaptcha() : string
{
/* Build Form */
$form = new \IPS\Helpers\Form;
static::captchaForm( $form );
$form = new Form;
$form->add( new Radio( 'bot_antispam_type', Settings::i()->bot_antispam_type, TRUE, array(
'options' => $this->getCaptchaOptions( 'options' ),
'toggles' => $this->getCaptchaOptions( 'toggles' ),
), NULL, NULL, NULL, 'bot_antispam_type' ) );
$form->add( new Text( 'recaptcha2_public_key', Settings::i()->recaptcha2_public_key, FALSE, array(), NULL, NULL, NULL, 'recaptcha2_public_key' ) );
$form->add( new Text( 'recaptcha2_private_key', Settings::i()->recaptcha2_private_key, FALSE, array(), NULL, NULL, NULL, 'recaptcha2_private_key' ) );
$form->add( new Text( 'keycaptcha_privatekey', Settings::i()->keycaptcha_privatekey, FALSE, array(), NULL, NULL, NULL, 'keycaptcha_privatekey' ) );
$form->add( new Text( 'hcaptcha_sitekey', Settings::i()->hcaptcha_sitekey, FALSE, array(), NULL, NULL, NULL, 'hcaptcha_sitekey' ) );
$form->add( new Text( 'hcaptcha_secret', Settings::i()->hcaptcha_secret, FALSE, array(), NULL, NULL, NULL, 'hcaptcha_secret' ) );
$form->add( new YesNo( 'guest_captcha', Settings::i()->guest_captcha, FALSE, array(), NULL, NULL, NULL, 'guest_captcha' ) );
/* Save values */
if ( $form->values() )
{
$form->saveAsSettings();
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
\IPS\Session::i()->log( 'acplogs__spamprev_settings' );
Session::i()->log( 'acplogs__spamprev_settings' );
}
return $form;
}
/**
* @param \IPS\Helpers\Form $form
* @return void
*/
public static function captchaForm( Form $form ): void
{
$form->add( new Radio( 'bot_antispam_type', Settings::i()->bot_antispam_type, TRUE, array(
'options' => static::getCaptchaOptions( 'options' ),
'toggles' => static::getCaptchaOptions( 'toggles' ),
), NULL, NULL, NULL, 'bot_antispam_type' ) );
$form->add( new Text( 'turnstile_site_key', Settings::i()->turnstile_site_key, id: 'turnstile_site_key' ) );
$form->add( new Text( 'turnstile_secret_key', Settings::i()->turnstile_secret_key, id: 'turnstile_secret_key' ) );
if( \IPS\CIC )
{
\IPS\Member::loggedIn()->language()->words['turnstile_secret_key_desc'] = \IPS\Member::loggedIn()->language()->addToStack('turnstile_secret_key_cloud_desc');
}
$form->add( new Text( 'recaptcha2_public_key', Settings::i()->recaptcha2_public_key, FALSE, array(), NULL, NULL, NULL, 'recaptcha2_public_key' ) );
$form->add( new Text( 'recaptcha2_private_key', Settings::i()->recaptcha2_private_key, FALSE, array(), NULL, NULL, NULL, 'recaptcha2_private_key' ) );
if( \IPS\Settings::i()->bot_antispam_type == 'keycaptcha' )
{
$form->add( new Text( 'keycaptcha_privatekey', Settings::i()->keycaptcha_privatekey, FALSE, [], NULL, NULL, NULL, 'keycaptcha_privatekey' ) );
}
$form->add( new Text( 'hcaptcha_sitekey', Settings::i()->hcaptcha_sitekey, FALSE, array(), NULL, NULL, NULL, 'hcaptcha_sitekey' ) );
$form->add( new Text( 'hcaptcha_secret', Settings::i()->hcaptcha_secret, FALSE, array(), NULL, NULL, NULL, 'hcaptcha_secret' ) );
}
/**
* Show spammer flagging settings
*
* @return string HTML to display
*/
protected function _manageFlagging()
protected function _manageFlagging() : string
{
/* Build Form */
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'spm_option', explode( ',', \IPS\Settings::i()->spm_option ), FALSE, array(
$form = new Form;
$form->add( new CheckboxSet( 'spm_option', explode( ',', Settings::i()->spm_option ), FALSE, array(
'options' => array( 'disable' => 'spm_option_disable', 'unapprove' => 'spm_option_unapprove', 'delete' => 'spm_option_delete', 'ban' => 'spm_option_ban' ),
) ) );
@@ -234,7 +226,7 @@ class _spam extends \IPS\Dispatcher\Controller
if ( $form->values() )
{
$form->saveAsSettings();
\IPS\Session::i()->log( 'acplogs__spamprev_settings' );
Session::i()->log( 'acplogs__spamprev_settings' );
}
return $form;
@@ -245,46 +237,46 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return string HTML to display
*/
protected function _manageService()
protected function _manageService() : string
{
$licenseData = \IPS\IPS::licenseKey();
$licenseData = IPS::licenseKey();
/* Build Form */
$actions = array( 1 => 'spam_service_act_1', 5 => 'spam_service_act_5', 2 => 'spam_service_act_2', 3 => 'spam_service_act_3', 4 => 'spam_service_act_4' );
$days = json_decode( \IPS\Settings::i()->spam_service_days, TRUE );
$days = json_decode( Settings::i()->spam_service_days, TRUE );
$form = new \IPS\Helpers\Form;
$form = new Form;
$form->addHeader( 'enhancements__core_SpamMonitoring' );
$disabled = FALSE;
if( !$licenseData or !isset( $licenseData['products']['spam'] ) or !$licenseData['products']['spam'] or ( !$licenseData['cloud'] AND strtotime( $licenseData['expires'] ) < time() ) )
{
$disabled = TRUE;
if( !\IPS\Settings::i()->ipb_reg_number )
if( !Settings::i()->ipb_reg_number )
{
\IPS\Member::loggedIn()->language()->words['spam_service_enabled_desc'] = \IPS\Member::loggedIn()->language()->addToStack( '__ipbmafia__nulling_null_alert' ); //Changing error message to custom
Member::loggedIn()->language()->words['spam_service_enabled_desc'] = Member::loggedIn()->language()->addToStack( 'spam_service_nokey', FALSE, array( 'sprintf' => array( Url::internal( 'app=core&module=settings&controller=licensekey' ) ) ) );
}
else
{
\IPS\Member::loggedIn()->language()->words['spam_service_enabled_desc'] = \IPS\Member::loggedIn()->language()->addToStack( '__ipbmafia__nulling_null_alert' ); //Changing error message to custom
Member::loggedIn()->language()->words['spam_service_enabled_desc'] = Member::loggedIn()->language()->addToStack( 'spam_service_noservice' );
}
}
$form->add( new \IPS\Helpers\Form\YesNo( 'spam_service_enabled', \IPS\Settings::i()->spam_service_enabled, FALSE, array( 'disabled' => $disabled, 'togglesOn' => array( 'spam_service_send_to_ips', 'spam_service_action_0', 'spam_service_action_1', 'spam_service_action_2', 'spam_service_action_3', 'spam_service_action_4', 'spam_service_disposable' ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'spam_service_send_to_ips', \IPS\Settings::i()->spam_service_send_to_ips, FALSE, array( 'disabled' => $disabled ), NULL, NULL, NULL, 'spam_service_send_to_ips' ) );
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_1', \IPS\Settings::i()->spam_service_action_1, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_action_1_num' ) ) ), NULL, NULL, NULL, 'spam_service_action_1' ) );
$form->add( new \IPS\Helpers\Form\Number( 'spam_service_action_1_num', ( isset( $days[1] ) ? $days[1] : -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_1_num' ) );
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_2', \IPS\Settings::i()->spam_service_action_2, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_action_2_num' ) ) ), NULL, NULL, NULL, 'spam_service_action_2' ) );
$form->add( new \IPS\Helpers\Form\Number( 'spam_service_action_2_num', ( isset( $days[2] ) ? $days[2] : -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_2_num' ) );
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_3', \IPS\Settings::i()->spam_service_action_3, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_action_3_num' ) ) ), NULL, NULL, NULL, 'spam_service_action_3' ) );
$form->add( new \IPS\Helpers\Form\Number( 'spam_service_action_3_num', ( isset( $days[3] ) ? $days[3] : -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_3_num' ) );
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_4', \IPS\Settings::i()->spam_service_action_4, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_action_4_num' ) ) ), NULL, NULL, NULL, 'spam_service_action_4' ) );
$form->add( new \IPS\Helpers\Form\Number( 'spam_service_action_4_num', ( isset( $days[4] ) ? $days[4] : -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_4_num' ) );
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_disposable', \IPS\Settings::i()->spam_service_disposable, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_disposable_num' ) ) ), NULL, NULL, NULL, 'spam_service_disposable' ) );
$form->add( new \IPS\Helpers\Form\Number( 'spam_service_disposable_num', ( isset( $days['disposable'] ) ? $days['disposable'] : -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'spam_service_disposable_num' ) );
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_0', \IPS\Settings::i()->spam_service_action_0, FALSE, array( 'disabled' => $disabled, 'options' => $actions ), NULL, NULL, NULL, 'spam_service_action_0' ) );
$form->add( new YesNo( 'spam_service_enabled', Settings::i()->spam_service_enabled, FALSE, array( 'disabled' => $disabled, 'togglesOn' => array( 'spam_service_send_to_ips', 'spam_service_action_0', 'spam_service_action_1', 'spam_service_action_2', 'spam_service_action_3', 'spam_service_action_4', 'spam_service_disposable' ) ) ) );
$form->add( new YesNo( 'spam_service_send_to_ips', Settings::i()->spam_service_send_to_ips, FALSE, array( 'disabled' => $disabled ), NULL, NULL, NULL, 'spam_service_send_to_ips' ) );
$form->add( new Select( 'spam_service_action_1', Settings::i()->spam_service_action_1, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_action_1_num' ) ) ), NULL, NULL, NULL, 'spam_service_action_1' ) );
$form->add( new Number( 'spam_service_action_1_num', ( $days[1] ?? -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_1_num' ) );
$form->add( new Select( 'spam_service_action_2', Settings::i()->spam_service_action_2, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_action_2_num' ) ) ), NULL, NULL, NULL, 'spam_service_action_2' ) );
$form->add( new Number( 'spam_service_action_2_num', ( $days[2] ?? -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_2_num' ) );
$form->add( new Select( 'spam_service_action_3', Settings::i()->spam_service_action_3, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_action_3_num' ) ) ), NULL, NULL, NULL, 'spam_service_action_3' ) );
$form->add( new Number( 'spam_service_action_3_num', ( $days[3] ?? -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_3_num' ) );
$form->add( new Select( 'spam_service_action_4', Settings::i()->spam_service_action_4, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_action_4_num' ) ) ), NULL, NULL, NULL, 'spam_service_action_4' ) );
$form->add( new Number( 'spam_service_action_4_num', ( $days[4] ?? -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_4_num' ) );
$form->add( new Select( 'spam_service_disposable', Settings::i()->spam_service_disposable, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_disposable_num' ) ) ), NULL, NULL, NULL, 'spam_service_disposable' ) );
$form->add( new Number( 'spam_service_disposable_num', ( $days['disposable'] ?? -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, Member::loggedIn()->language()->addToStack('days'), 'spam_service_disposable_num' ) );
$form->add( new Select( 'spam_service_action_0', Settings::i()->spam_service_action_0, FALSE, array( 'disabled' => $disabled, 'options' => $actions ), NULL, NULL, NULL, 'spam_service_action_0' ) );
if ( $values = $form->values() )
{
@@ -302,7 +294,7 @@ class _spam extends \IPS\Dispatcher\Controller
$values['spam_service_days'] = json_encode( $values['spam_service_days'] );
$form->saveAsSettings( $values );
\IPS\Session::i()->log( 'acplog__enhancements_edited', array( 'enhancements__core_SpamMonitoring' => TRUE ) );
Session::i()->log( 'acplog__enhancements_edited', array( 'enhancements__core_SpamMonitoring' => TRUE ) );
}
return $form;
@@ -313,20 +305,20 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return string HTML to display
*/
protected function _manageQanda()
protected function _manageQanda() : string
{
\IPS\Dispatcher::i()->checkAcpPermission( 'qanda_manage' );
Dispatcher::i()->checkAcpPermission( 'qanda_manage' );
/* Create the table */
$table = new \IPS\Helpers\Table\Db( 'core_question_and_answer', \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&tab=qanda' ) );
$table = new TableDb( 'core_question_and_answer', Url::internal( 'app=core&module=moderation&controller=spam&tab=qanda' ) );
$table->include = array( 'qa_question' );
$table->joins = array(
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'core_question_and_answer_', core_question_and_answer.qa_id ) AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'core_question_and_answer_', core_question_and_answer.qa_id ) AND w.lang_id=" . Member::loggedIn()->language()->id )
);
$table->parsers = array(
'qa_question' => function( $val, $row )
{
return ( $row['word_custom'] ? $row['word_custom'] : $row['qa_question'] );
return ( $row['word_custom'] ?: $row['qa_question'] );
}
);
$table->mainColumn = 'qa_question';
@@ -334,13 +326,13 @@ class _spam extends \IPS\Dispatcher\Controller
$table->quickSearch = array( 'word_custom', 'qa_question' );
$table->sortDirection = $table->sortDirection ?: 'asc';
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_add' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_add' ) )
{
$table->rootButtons = array(
'add' => array(
'icon' => 'plus',
'title' => 'qanda_add_question',
'link' => \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=question' ),
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=question' ),
)
);
}
@@ -349,21 +341,21 @@ class _spam extends \IPS\Dispatcher\Controller
{
$return = array();
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_edit' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_edit' ) )
{
$return['edit'] = array(
'icon' => 'pencil',
'title' => 'edit',
'link' => \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=question&id=' ) . $row['qa_id'],
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=question&id=' ) . $row['qa_id'],
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_delete' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_delete' ) )
{
$return['delete'] = array(
'icon' => 'times-circle',
'title' => 'delete',
'link' => \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=delete&id=' ) . $row['qa_id'],
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=delete&id=' ) . $row['qa_id'],
'data' => array( 'delete' => '' ),
);
}
@@ -371,7 +363,7 @@ class _spam extends \IPS\Dispatcher\Controller
return $return;
};
return \IPS\Theme::i()->getTemplate( 'spam' )->spamQandASettings( $table );
return Theme::i()->getTemplate( 'spam' )->spamQandASettings( $table );
}
/**
@@ -379,31 +371,31 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function question()
protected function question() : void
{
/* Init */
$id = 0;
$question = array();
/* Start the form */
$form = new \IPS\Helpers\Form;
$form = new Form;
/* Load question */
try
{
$id = \intval( \IPS\Request::i()->id );
$id = intval( Request::i()->id );
$form->hiddenValues['id'] = $id;
$question = \IPS\Db::i()->select( '*', 'core_question_and_answer', array( 'qa_id=?', $id ) )->first();
$question = Db::i()->select( '*', 'core_question_and_answer', array( 'qa_id=?', $id ) )->first();
\IPS\Dispatcher::i()->checkAcpPermission( 'qanda_edit' );
Dispatcher::i()->checkAcpPermission( 'qanda_edit' );
}
catch ( \UnderflowException $e )
catch ( UnderflowException $e )
{
\IPS\Dispatcher::i()->checkAcpPermission( 'qanda_add' );
Dispatcher::i()->checkAcpPermission( 'qanda_add' );
}
$form->add( new \IPS\Helpers\Form\Translatable( 'qa_question', NULL, TRUE, array( 'app' => 'core', 'key' => ( $id ? "core_question_and_answer_{$id}" : NULL ) ) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'qa_answers', $id ? json_decode( $question['qa_answers'], TRUE ) : array(), TRUE ) );
$form->add( new Translatable( 'qa_question', NULL, TRUE, array( 'app' => 'core', 'key' => ( $id ? "core_question_and_answer_{$id}" : NULL ) ) ) );
$form->add( new Stack( 'qa_answers', $id ? json_decode( $question['qa_answers'], TRUE ) : array(), TRUE ) );
/* Handle submissions */
if ( $values = $form->values() )
@@ -414,25 +406,25 @@ class _spam extends \IPS\Dispatcher\Controller
if ( $id )
{
\IPS\Db::i()->update( 'core_question_and_answer', $save, array( 'qa_id=?', $question['qa_id'] ) );
Db::i()->update( 'core_question_and_answer', $save, array( 'qa_id=?', $question['qa_id'] ) );
\IPS\Session::i()->log( 'acplogs__question_edited' );
Session::i()->log( 'acplogs__question_edited' );
}
else
{
$id = \IPS\Db::i()->insert( 'core_question_and_answer', $save );
\IPS\Session::i()->log( 'acplogs__question_added' );
$id = Db::i()->insert( 'core_question_and_answer', $save );
Session::i()->log( 'acplogs__question_added' );
}
\IPS\Lang::saveCustom( 'core', "core_question_and_answer_{$id}", $values['qa_question'] );
Lang::saveCustom( 'core', "core_question_and_answer_{$id}", $values['qa_question'] );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&tab=qanda' ), 'saved' );
Output::i()->redirect( Url::internal( 'app=core&module=moderation&controller=spam&tab=qanda' ), 'saved' );
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('qanda_settings');
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Output::i()->title );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( \IPS\Output::i()->title, $form );
Output::i()->title = Member::loggedIn()->language()->addToStack('qanda_settings');
Output::i()->breadcrumb[] = array( NULL, Output::i()->title );
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( Output::i()->title, $form );
}
/**
@@ -440,21 +432,21 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function delete()
protected function delete() : void
{
$id = \intval( \IPS\Request::i()->id );
\IPS\Dispatcher::i()->checkAcpPermission( 'qanda_delete' );
$id = intval( Request::i()->id );
Dispatcher::i()->checkAcpPermission( 'qanda_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
Request::i()->confirmedDelete();
\IPS\Db::i()->delete( 'core_question_and_answer', array( 'qa_id=?', $id ) );
\IPS\Session::i()->log( 'acplogs__question_deleted' );
Db::i()->delete( 'core_question_and_answer', array( 'qa_id=?', $id ) );
Session::i()->log( 'acplogs__question_deleted' );
\IPS\Lang::deleteCustom( 'core', "core_question_and_answer_{$id}" );
Lang::deleteCustom( 'core', "core_question_and_answer_{$id}" );
/* And redirect */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=moderation&controller=spam&tab=qanda" ) );
Output::i()->redirect( Url::internal( "app=core&module=moderation&controller=spam&tab=qanda" ) );
}
/**
@@ -462,12 +454,12 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function serviceLogs()
protected function serviceLogs() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'spam_service_log' );
Dispatcher::i()->checkAcpPermission( 'spam_service_log' );
/* Create the table */
$table = new \IPS\Helpers\Table\Db( 'core_spam_service_log', \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=serviceLogs' ) );
$table = new TableDb( 'core_spam_service_log', Url::internal( 'app=core&module=moderation&controller=spam&do=serviceLogs' ) );
$table->langPrefix = 'spamlogs_';
@@ -479,34 +471,34 @@ class _spam extends \IPS\Dispatcher\Controller
/* Search */
$table->advancedSearch = array(
'email_address' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
'ip_address' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
'log_code' => \IPS\Helpers\Table\SEARCH_NUMERIC,
'email_address' => SEARCH_CONTAINS_TEXT,
'ip_address' => SEARCH_CONTAINS_TEXT,
'log_code' => SEARCH_NUMERIC,
);
$table->quickSearch = 'email_address';
/* Custom parsers */
$table->parsers = array(
'log_date' => function( $val, $row )
'log_date' => function( $val )
{
return \IPS\DateTime::ts( $val )->localeDate();
return DateTime::ts( $val )->localeDate();
},
);
/* Add a button for settings */
\IPS\Output::i()->sidebar['actions'] = array(
Output::i()->sidebar['actions'] = array(
'settings' => array(
'title' => 'prunesettings',
'icon' => 'cog',
'link' => \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=serviceLogSettings' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('prunesettings') )
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=serviceLogSettings' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('prunesettings') )
),
);
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('spamlogs');
\IPS\Output::i()->output = (string) $table;
Output::i()->title = Member::loggedIn()->language()->addToStack('spamlogs');
Output::i()->output = (string) $table;
}
/**
@@ -514,23 +506,23 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function serviceLogSettings()
protected function serviceLogSettings() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'spam_service_log' );
Dispatcher::i()->checkAcpPermission( 'spam_service_log' );
$form = new \IPS\Helpers\Form;
$form = new Form;
$form->add( new \IPS\Helpers\Form\Interval( 'prune_log_spam', \IPS\Settings::i()->prune_log_spam, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_log_spam' ) );
$form->add( new Interval( 'prune_log_spam', Settings::i()->prune_log_spam, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_log_spam' ) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
\IPS\Session::i()->log( 'acplog__spamlog_settings' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=serviceLogs' ), 'saved' );
Session::i()->log( 'acplog__spamlog_settings' );
Output::i()->redirect( Url::internal( 'app=core&module=moderation&controller=spam&do=serviceLogs' ), 'saved' );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('spamlogssettings');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'spamlogssettings', $form, FALSE );
Output::i()->title = Member::loggedIn()->language()->addToStack('spamlogssettings');
Output::i()->output = Theme::i()->getTemplate('global')->block( 'spamlogssettings', $form, FALSE );
}
/**
@@ -538,10 +530,10 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function whitelist()
protected function whitelist() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'spam_whitelist_manage' );
$table = new \IPS\Helpers\Table\Db( 'core_spam_whitelist', \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=whitelist' ) );
Dispatcher::i()->checkAcpPermission( 'spam_whitelist_manage' );
$table = new TableDb( 'core_spam_whitelist', Url::internal( 'app=core&module=moderation&controller=spam&do=whitelist' ) );
$table->filters = array(
'spam_whitelist_ip' => 'whitelist_type=\'ip\'',
@@ -556,27 +548,27 @@ class _spam extends \IPS\Dispatcher\Controller
$table->sortDirection = $table->sortDirection ?: 'asc';
$table->quickSearch = 'whitelist_content';
$table->advancedSearch = array(
'whitelist_reason' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
'whitelist_date' => \IPS\Helpers\Table\SEARCH_DATE_RANGE
'whitelist_reason' => SEARCH_CONTAINS_TEXT,
'whitelist_date' => SEARCH_DATE_RANGE
);
/* Custom parsers */
$table->parsers = array(
'whitelist_date' => function( $val, $row )
'whitelist_date' => function( $val )
{
return \IPS\DateTime::ts( $val )->localeDate();
return DateTime::ts( $val )->localeDate();
},
'whitelist_type' => function( $val, $row )
'whitelist_type' => function( $val )
{
switch( $val )
{
default:
case 'ip':
return \IPS\Member::loggedIn()->language()->addToStack('spam_whitelist_ip_select');
break;
return Member::loggedIn()->language()->addToStack('spam_whitelist_ip_select');
case 'domain':
return \IPS\Member::loggedIn()->language()->addToStack('spam_whitelist_domain_select');
break;
return Member::loggedIn()->language()->addToStack('spam_whitelist_domain_select');
}
}
);
@@ -586,22 +578,22 @@ class _spam extends \IPS\Dispatcher\Controller
{
$return = array();
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_whitelist_edit' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_whitelist_edit' ) )
{
$return['edit'] = array(
'icon' => 'pencil',
'title' => 'edit',
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('edit') ),
'link' => \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=whitelistForm&id=' ) . $row['whitelist_id'],
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('edit') ),
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=whitelistForm&id=' ) . $row['whitelist_id'],
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_whitelist_delete' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_whitelist_delete' ) )
{
$return['delete'] = array(
'icon' => 'times-circle',
'title' => 'delete',
'link' => \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=whitelistDelete&id=' ) . $row['whitelist_id'],
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=whitelistDelete&id=' ) . $row['whitelist_id'],
'data' => array( 'delete' => '' ),
);
}
@@ -610,22 +602,22 @@ class _spam extends \IPS\Dispatcher\Controller
};
/* Add an add button for whitelist */
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_whitelist_add' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_whitelist_add' ) )
{
\IPS\Output::i()->sidebar['actions'] = array(
Output::i()->sidebar['actions'] = array(
'add' => array(
'primary' => TRUE,
'icon' => 'plus',
'title' => 'spam_whitelist_add',
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('spam_whitelist_add') ),
'link' => \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=whitelistForm' )
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('spam_whitelist_add') ),
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=whitelistForm' )
)
);
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('spam_whitelist');
\IPS\Output::i()->output = (string) $table;
Output::i()->title = Member::loggedIn()->language()->addToStack('spam_whitelist');
Output::i()->output = (string) $table;
}
/**
@@ -633,23 +625,23 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function whitelistForm()
protected function whitelistForm() : void
{
$current = NULL;
if ( \IPS\Request::i()->id )
if ( Request::i()->id )
{
$current = \IPS\Db::i()->select( '*', 'core_spam_whitelist', array( 'whitelist_id=?', \IPS\Request::i()->id ) )->first();
$current = Db::i()->select( '*', 'core_spam_whitelist', array( 'whitelist_id=?', Request::i()->id ) )->first();
\IPS\Dispatcher::i()->checkAcpPermission( 'spam_whitelist_edit' );
Dispatcher::i()->checkAcpPermission( 'spam_whitelist_edit' );
}
else
{
\IPS\Dispatcher::i()->checkAcpPermission( 'spam_whitelist_add' );
Dispatcher::i()->checkAcpPermission( 'spam_whitelist_add' );
}
/* Build form */
$form = new \IPS\Helpers\Form();
$form->add( new \IPS\Helpers\Form\Select( 'whitelist_type', $current ? $current['whitelist_type'] : NULL, TRUE,
$form = new Form();
$form->add( new Select( 'whitelist_type', $current ? $current['whitelist_type'] : NULL, TRUE,
array(
'options' => array(
'ip' => 'spam_whitelist_ip_select',
@@ -661,14 +653,14 @@ class _spam extends \IPS\Dispatcher\Controller
)
) ) );
$form->add( new \IPS\Helpers\Form\Text( 'whitelist_ip_content', $current ? $current['whitelist_content'] : NULL, TRUE, array(), NULL, NULL, NULL, 'whitelist_ip_content' ) );
$form->add( new \IPS\Helpers\Form\Text( 'whitelist_domain_content', $current ? $current['whitelist_content'] : NULL, TRUE, array( 'placeholder' => 'mycompany.com' ), function( $value ) {
$form->add( new Text( 'whitelist_ip_content', $current ? $current['whitelist_content'] : NULL, TRUE, array(), NULL, NULL, NULL, 'whitelist_ip_content' ) );
$form->add( new Text( 'whitelist_domain_content', $current ? $current['whitelist_content'] : NULL, TRUE, array( 'placeholder' => 'mycompany.com' ), function( $value ) {
if( isset( $value ) AND mb_stripos( $value, '@' ) )
{
throw new \DomainException( 'whitelist_domain_email_detected' );
throw new DomainException( 'whitelist_domain_email_detected' );
}
}, NULL, NULL, 'whitelist_domain_content' ) );
$form->add( new \IPS\Helpers\Form\Text( 'whitelist_reason', $current ? $current['whitelist_reason'] : NULL ) );
$form->add( new Text( 'whitelist_reason', $current ? $current['whitelist_reason'] : NULL ) );
/* Handle submissions */
if ( $values = $form->values() )
@@ -684,20 +676,20 @@ class _spam extends \IPS\Dispatcher\Controller
if ( $current )
{
unset( $save['whitelist_date'] );
\IPS\Db::i()->update( 'core_spam_whitelist', $save, array( 'whitelist_id=?', $current['whitelist_id'] ) );
\IPS\Session::i()->log( 'acplog__spam_whitelist_edited', array( 'spam_whitelist_' . $save['whitelist_type'] . '_select' => TRUE, $save['whitelist_content'] => FALSE ) );
Db::i()->update( 'core_spam_whitelist', $save, array( 'whitelist_id=?', $current['whitelist_id'] ) );
Session::i()->log( 'acplog__spam_whitelist_edited', array( 'spam_whitelist_' . $save['whitelist_type'] . '_select' => TRUE, $save['whitelist_content'] => FALSE ) );
}
else
{
\IPS\Db::i()->insert( 'core_spam_whitelist', $save );
\IPS\Session::i()->log( 'acplog__spam_whitelist_created', array( 'spam_whitelist_' . $save['whitelist_type'] . '_select' => TRUE, $save['whitelist_content'] => FALSE ) );
Db::i()->insert( 'core_spam_whitelist', $save );
Session::i()->log( 'acplog__spam_whitelist_created', array( 'spam_whitelist_' . $save['whitelist_type'] . '_select' => TRUE, $save['whitelist_content'] => FALSE ) );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=whitelist' ), 'saved' );
Output::i()->redirect( Url::internal( 'app=core&module=moderation&controller=spam&do=whitelist' ), 'saved' );
}
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( $current ? $current['whitelist_content'] : 'add', $form, FALSE );
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( $current ? $current['whitelist_content'] : 'add', $form, FALSE );
}
/**
@@ -705,65 +697,64 @@ class _spam extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function whitelistDelete()
protected function whitelistDelete() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'spam_whitelist_delete' );
Dispatcher::i()->checkAcpPermission( 'spam_whitelist_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
Request::i()->confirmedDelete();
try
{
$current = \IPS\Db::i()->select( '*', 'core_spam_whitelist', array( 'whitelist_id=?', \IPS\Request::i()->id ) )->first();
\IPS\Session::i()->log( 'acplog__spam_whitelist_deleted', array( 'whitelist_filter_' . $current['whitelist_type'] . '_select' => TRUE, $current['whitelist_content'] => FALSE ) );
\IPS\Db::i()->delete( 'core_spam_whitelist', array( 'whitelist_id=?', \IPS\Request::i()->id ) );
$current = Db::i()->select( '*', 'core_spam_whitelist', array( 'whitelist_id=?', Request::i()->id ) )->first();
Session::i()->log( 'acplog__spam_whitelist_deleted', array( 'whitelist_filter_' . $current['whitelist_type'] . '_select' => TRUE, $current['whitelist_content'] => FALSE ) );
Db::i()->delete( 'core_spam_whitelist', array( 'whitelist_id=?', Request::i()->id ) );
}
catch ( \UnderflowException $e ) { }
catch ( UnderflowException $e ) { }
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=whitelist' ) );
Output::i()->redirect( Url::internal( 'app=core&module=moderation&controller=spam&do=whitelist' ) );
}
/**
* Show GeoLocation settings
*
* @return string HTML to display
*/
protected function _manageGeolocation()
protected function _manageGeolocation() : string
{
$licenseData = \IPS\IPS::licenseKey();
/* Build Form */
$settings = \IPS\Settings::i()->spam_geo_settings ? json_decode( \IPS\Settings::i()->spam_geo_settings, true ) : array();
$licenseData = IPS::licenseKey();
$form = new \IPS\Helpers\Form;
$matrix = new \IPS\Helpers\Form\Matrix;
/* Build Form */
$settings = Settings::i()->spam_geo_settings ? json_decode( Settings::i()->spam_geo_settings, true ) : array();
$matrix = new Matrix;
if( !$licenseData or !isset( $licenseData['products']['spam'] ) or !$licenseData['products']['spam'] or ( !$licenseData['cloud'] AND strtotime( $licenseData['expires'] ) < time() ) )
{
if( !\IPS\Settings::i()->ipb_reg_number )
if( !Settings::i()->ipb_reg_number )
{
\IPS\Member::loggedIn()->language()->words['spam_service_enabled_desc'] = \IPS\Member::loggedIn()->language()->addToStack( '__ipbmafia__nulling_null_alert' ); //Changing error message to custom
Member::loggedIn()->language()->words['spam_service_enabled_desc'] = Member::loggedIn()->language()->addToStack( 'spam_service_nokey', FALSE, array( 'sprintf' => array( Url::internal( 'app=core&module=settings&controller=licensekey' ) ) ) );
}
else
{
\IPS\Member::loggedIn()->language()->words['spam_service_enabled_desc'] = \IPS\Member::loggedIn()->language()->addToStack( '__ipbmafia__nulling_null_alert' ); //Changing error message to custom
Member::loggedIn()->language()->words['spam_service_enabled_desc'] = Member::loggedIn()->language()->addToStack( 'spam_service_noservice' );
}
}
$matrix->columns = array(
'country' => function( $key, $value, $data ) {
$options = array();
foreach( \IPS\GeoLocation::$countries AS $country )
foreach( GeoLocation::$countries AS $country )
{
$options[ $country ] = \IPS\Member::loggedIn()->language()->addToStack( 'country-' . $country );
$options[ $country ] = Member::loggedIn()->language()->addToStack( 'country-' . $country );
}
return new \IPS\Helpers\Form\Select( $key, $value, TRUE, array( 'options' => $options ) );
return new Select( $key, $value, TRUE, array( 'options' => $options ) );
},
'action' => function( $key, $value, $data ) {
return new \IPS\Helpers\Form\Select( $key, $value, TRUE, array( 'options' => array( 'moderate' => 'spam_service_act_2', 'block' => 'spam_service_act_4' ) ) );
return new Select( $key, $value, TRUE, array( 'options' => array( 'moderate' => 'spam_service_act_2', 'block' => 'spam_service_act_4' ) ) );
}
);
$matrix->rows = array();
foreach( $settings AS $country => $action )
{
@@ -772,19 +763,19 @@ class _spam extends \IPS\Dispatcher\Controller
'action' => $action
);
}
$form->addMatrix( 'geolocation', $matrix );
if ( $values = $form->values() )
if ( $values = $matrix->values() )
{
$save = array();
foreach( $values['geolocation'] AS $key => $value )
foreach( $values AS $key => $value )
{
$save[ $value['country'] ] = $value['action'];
}
\IPS\Settings::i()->changeValues( array( 'spam_geo_settings' => json_encode( $save ) ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=moderation&controller=spam&tab=geolocation" ), 'saved' );
Settings::i()->changeValues( array( 'spam_geo_settings' => json_encode( $save ) ) );
Output::i()->redirect( Url::internal( "app=core&module=moderation&controller=spam&tab=geolocation" ), 'saved' );
}
return \IPS\Theme::i()->getTemplate( 'spam' )->spamGeoSettings( $form );
return Theme::i()->getTemplate( 'spam' )->spamGeoSettings( $matrix );
}
}