Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -93,14 +93,14 @@ class spam extends Controller
|
||||
/* Work out output */
|
||||
$methodFunction = '_manage' . IPS::mb_ucfirst( $this->activeTab );
|
||||
$activeTabContents = $this->$methodFunction();
|
||||
|
||||
|
||||
/* If this is an AJAX request, just return it */
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
Output::i()->output = $activeTabContents;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Build tab list */
|
||||
$tabs = array();
|
||||
$tabs['captcha'] = 'spamprevention_captcha';
|
||||
@@ -136,7 +136,7 @@ class spam extends Controller
|
||||
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=whitelist' ),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'membertools_delete' ) )
|
||||
{
|
||||
Output::i()->sidebar['actions']['delete_guest_content'] = array(
|
||||
@@ -146,7 +146,7 @@ class spam extends Controller
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('member_delete_guest_content') )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* Display */
|
||||
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" ) );
|
||||
@@ -158,24 +158,44 @@ class spam extends Controller
|
||||
* @param string $type 'options' for the select options, 'toggles' for the toggles
|
||||
* @return array
|
||||
*/
|
||||
protected function getCaptchaOptions( string $type='options' ) : array
|
||||
protected static function getCaptchaOptions( string $type='options' ) : array
|
||||
{
|
||||
switch( $type )
|
||||
{
|
||||
case 'options':
|
||||
return array( 'none' => 'captcha_type_none', 'invisible' => 'captcha_type_invisible', 'recaptcha2' => 'captcha_type_recaptcha2', 'keycaptcha' => 'captcha_type_keycaptcha', 'hcaptcha' => 'captcha_type_hcaptcha' );
|
||||
$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( Settings::i()->bot_antispam_type != 'keycaptcha' )
|
||||
{
|
||||
unset( $options['keycaptcha'] );
|
||||
}
|
||||
return $options;
|
||||
|
||||
case 'toggles':
|
||||
return array(
|
||||
'none' => array( 'bot_antispam_type_warning' ),
|
||||
'recaptcha2' => array( 'recaptcha2_public_key', 'recaptcha2_private_key' ),
|
||||
'invisible' => array( 'recaptcha2_public_key', 'recaptcha2_private_key' ),
|
||||
'keycaptcha' => array( 'keycaptcha_privatekey' ),
|
||||
'hcaptcha' => array( 'hcaptcha_sitekey', 'hcaptcha_secret')
|
||||
);
|
||||
$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( Settings::i()->bot_antispam_type != 'keycaptcha' )
|
||||
{
|
||||
unset( $toggles['keycaptcha'] );
|
||||
}
|
||||
|
||||
return $toggles;
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,15 +207,7 @@ class spam extends Controller
|
||||
{
|
||||
/* Build 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' ) );
|
||||
static::captchaForm( $form );
|
||||
|
||||
/* Save values */
|
||||
if ( $form->values() )
|
||||
@@ -208,6 +220,32 @@ class spam extends Controller
|
||||
return $form;
|
||||
}
|
||||
|
||||
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( Settings::i()->bot_antispam_type == 'keycaptcha' )
|
||||
{
|
||||
$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' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show spammer flagging settings
|
||||
*
|
||||
@@ -220,7 +258,7 @@ class spam extends Controller
|
||||
$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' ),
|
||||
) ) );
|
||||
|
||||
|
||||
/* Save values */
|
||||
if ( $form->values() )
|
||||
{
|
||||
@@ -239,7 +277,7 @@ class spam extends Controller
|
||||
protected function _manageService() : string
|
||||
{
|
||||
$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( Settings::i()->spam_service_days, TRUE );
|
||||
@@ -253,12 +291,14 @@ class spam extends Controller
|
||||
$disabled = TRUE;
|
||||
if( !Settings::i()->ipb_reg_number )
|
||||
{
|
||||
Member::loggedIn()->language()->words['spam_service_enabled_desc'] = Member::loggedIn()->language()->addToStack( '__ipbmafia__nulling_null_alert' ); //Changing error message to custom'
|
||||
}
|
||||
else
|
||||
{
|
||||
Member::loggedIn()->language()->words['spam_service_enabled_desc'] = Member::loggedIn()->language()->addToStack( '__ipbmafia__nulling_null_alert' ); //Changing error message to custom'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$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' ) );
|
||||
@@ -287,7 +327,7 @@ class spam extends Controller
|
||||
|
||||
unset( $values['spam_service_' . $num . '_num' ] );
|
||||
}
|
||||
|
||||
|
||||
$values['spam_service_days'] = json_encode( $values['spam_service_days'] );
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
@@ -322,7 +362,7 @@ class spam extends Controller
|
||||
$table->sortBy = $table->sortBy ?: 'qa_question';
|
||||
$table->quickSearch = array( 'word_custom', 'qa_question' );
|
||||
$table->sortDirection = $table->sortDirection ?: 'asc';
|
||||
|
||||
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_add' ) )
|
||||
{
|
||||
$table->rootButtons = array(
|
||||
@@ -337,7 +377,7 @@ class spam extends Controller
|
||||
$table->rowButtons = function( $row )
|
||||
{
|
||||
$return = array();
|
||||
|
||||
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_edit' ) )
|
||||
{
|
||||
$return['edit'] = array(
|
||||
@@ -346,7 +386,7 @@ class spam extends Controller
|
||||
'link' => Url::internal( 'app=core&module=moderation&controller=spam&do=question&id=' ) . $row['qa_id'],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_delete' ) )
|
||||
{
|
||||
$return['delete'] = array(
|
||||
@@ -356,7 +396,7 @@ class spam extends Controller
|
||||
'data' => array( 'delete' => '' ),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return $return;
|
||||
};
|
||||
|
||||
@@ -400,7 +440,7 @@ class spam extends Controller
|
||||
$save = array(
|
||||
'qa_answers' => json_encode( $values['qa_answers'] ),
|
||||
);
|
||||
|
||||
|
||||
if ( $id )
|
||||
{
|
||||
Db::i()->update( 'core_question_and_answer', $save, array( 'qa_id=?', $question['qa_id'] ) );
|
||||
@@ -412,7 +452,7 @@ class spam extends Controller
|
||||
$id = Db::i()->insert( 'core_question_and_answer', $save );
|
||||
Session::i()->log( 'acplogs__question_added' );
|
||||
}
|
||||
|
||||
|
||||
Lang::saveCustom( 'core', "core_question_and_answer_{$id}", $values['qa_question'] );
|
||||
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=moderation&controller=spam&tab=qanda' ), 'saved' );
|
||||
@@ -439,13 +479,13 @@ class spam extends Controller
|
||||
|
||||
Db::i()->delete( 'core_question_and_answer', array( 'qa_id=?', $id ) );
|
||||
Session::i()->log( 'acplogs__question_deleted' );
|
||||
|
||||
|
||||
Lang::deleteCustom( 'core', "core_question_and_answer_{$id}" );
|
||||
|
||||
/* And redirect */
|
||||
Output::i()->redirect( Url::internal( "app=core&module=moderation&controller=spam&tab=qanda" ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Spam Service Log
|
||||
*
|
||||
@@ -454,18 +494,18 @@ class spam extends Controller
|
||||
protected function serviceLogs() : void
|
||||
{
|
||||
Dispatcher::i()->checkAcpPermission( 'spam_service_log' );
|
||||
|
||||
|
||||
/* Create the table */
|
||||
$table = new TableDb( 'core_spam_service_log', Url::internal( 'app=core&module=moderation&controller=spam&do=serviceLogs' ) );
|
||||
|
||||
|
||||
$table->langPrefix = 'spamlogs_';
|
||||
|
||||
|
||||
/* Columns we need */
|
||||
$table->include = array( 'log_date', 'log_code', 'email_address', 'ip_address' );
|
||||
|
||||
|
||||
$table->sortBy = $table->sortBy ?: 'log_date';
|
||||
$table->sortDirection = $table->sortDirection ?: 'DESC';
|
||||
|
||||
|
||||
/* Search */
|
||||
$table->advancedSearch = array(
|
||||
'email_address' => SEARCH_CONTAINS_TEXT,
|
||||
@@ -474,7 +514,7 @@ class spam extends Controller
|
||||
);
|
||||
|
||||
$table->quickSearch = 'email_address';
|
||||
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'log_date' => function( $val )
|
||||
@@ -482,7 +522,7 @@ class spam extends Controller
|
||||
return DateTime::ts( $val )->localeDate();
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
/* Add a button for settings */
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'settings' => array(
|
||||
@@ -492,12 +532,12 @@ class spam extends Controller
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('prunesettings') )
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/* Display */
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('spamlogs');
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prune Settings
|
||||
*
|
||||
@@ -506,18 +546,18 @@ class spam extends Controller
|
||||
protected function serviceLogSettings() : void
|
||||
{
|
||||
Dispatcher::i()->checkAcpPermission( 'spam_service_log' );
|
||||
|
||||
|
||||
$form = new Form;
|
||||
|
||||
|
||||
$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();
|
||||
Session::i()->log( 'acplog__spamlog_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=moderation&controller=spam&do=serviceLogs' ), 'saved' );
|
||||
}
|
||||
|
||||
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('spamlogssettings');
|
||||
Output::i()->output = Theme::i()->getTemplate('global')->block( 'spamlogssettings', $form, FALSE );
|
||||
}
|
||||
@@ -730,9 +770,11 @@ class spam extends Controller
|
||||
{
|
||||
if( !Settings::i()->ipb_reg_number )
|
||||
{
|
||||
Member::loggedIn()->language()->words['spam_service_enabled_desc'] = Member::loggedIn()->language()->addToStack( '__ipbmafia__nulling_null_alert' ); //Changing error message to custom'
|
||||
}
|
||||
else
|
||||
{
|
||||
Member::loggedIn()->language()->words['spam_service_enabled_desc'] = Member::loggedIn()->language()->addToStack( '__ipbmafia__nulling_null_alert' ); //Changing error message to custom'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user