Location: PHPKode > projects > Phpbbantispam > files/admin/admin_antispam_fields.php
<?php
define('IN_PHPBB', 1);
define('IN_ANTISPAM', true);
/** Antispam admin functions
 * @author	Ramon Fincken, Phpbbinstallers.net, RamonFincken.com, WebsiteFreelancers.nl
 *
 * V 1.3.2  (Make sure you update this file on regular basis) 
 */

if (!empty ($setmodules)) {
   $filename = basename(__FILE__);
   $module['Antispam']['Management'] = $filename . "?mode=generalconfig";
   return;
}
//
// Load default header
//
$no_page_header = FALSE;
$phpbb_root_path = '../';
require ($phpbb_root_path . 'extension.inc');
require ('./pagestart.' . $phpEx);

$file_version = '1.3.2';
include ('./antispam_functions/admin_antispam_functions.' . $phpEx);

// ----------------------- VERSION INFO
write_version($file_version);
// UPDATE
// -------------------------------------------------------------------------------------
if ($mode === 'update' && $action = 'update') {
   // Safety check:
   // Will be obsolete once every file has been updated to 1.2.7 but we'll leave it for the time beeing
   if (intval($HTTP_POST_VARS[mod_spamcheck_main_adminid]) < 2) {
      $url = "admin_antispam_fields.$phpEx";
      $meta = '<meta http-equiv="refresh" content="5;url=' . append_sid($url) . '&mode=generalconfig">';
      message_die(GENERAL_MESSAGE, $meta . 'Admin was set to ALL !<br />Go back and change settings');
   }
   
   // API key ?
   if (intval($HTTP_POST_VARS['mod_spamcheck_api']) == 1 && empty($HTTP_POST_VARS['mod_spamcheck_api_auth'])) {
      $url = "admin_antispam_fields.$phpEx";
      $meta = '<meta http-equiv="refresh" content="5;url=' . append_sid($url) . '&mode=generalconfig">';
      message_die(GENERAL_MESSAGE, $meta . 'If you enable the API you need to enter a key !<br />Go back and change settings');
   }  
   // Length of API key
   if (intval($HTTP_POST_VARS['mod_spamcheck_api']) == 1 && !empty($HTTP_POST_VARS['mod_spamcheck_api_auth']) && strlen($HTTP_POST_VARS[mod_spamcheck_api_auth]) < 5) {
      $url = "admin_antispam_fields.$phpEx";
      $meta = '<meta http-equiv="refresh" content="5;url=' . append_sid($url) . '&mode=generalconfig">';
      message_die(GENERAL_MESSAGE, $meta . 'Please enter a key with a <b>length above 5</b> chars!<br />Go back and change settings');
   }     

   // Bypass //
   // Bypass Group
   antispam_update_conftable(intval($HTTP_POST_VARS['mod_spamcheck_groupbypassid']),'mod_spamcheck_groupbypassid');

   // Bypass User    
   antispam_update_conftable(intval($HTTP_POST_VARS['mod_spamcheck_userposts']),'mod_spamcheck_userposts');
   antispam_update_conftable(intval($HTTP_POST_VARS['mod_spamcheck_userdays']),'mod_spamcheck_userdays');

   // Bypass Admin
   antispam_update_conftable(intval($HTTP_POST_VARS['mod_spamcheck_main_adminid']),'mod_spamcheck_main_adminid');
   // Bypass //

   // Enable //
   antispam_update_conftable($HTTP_POST_VARS['mod_spamcheck_check_pm'],'mod_spamcheck_check_pm');   
   antispam_update_conftable($HTTP_POST_VARS['mod_spamcheck_check_post'],'mod_spamcheck_check_post');
   antispam_update_conftable($HTTP_POST_VARS['mod_spamcheck_check_register'],'mod_spamcheck_check_register');
   // Enable //

   // Sent mail //
   antispam_update_conftable($HTTP_POST_VARS['mod_spamcheck_sentmail'],'mod_spamcheck_sentmail');
   antispam_update_conftable($HTTP_POST_VARS['mod_spamcheck_htmlmail'],'mod_spamcheck_htmlmail');
   antispam_update_conftable($HTTP_POST_VARS['mod_spamcheck_adminmail'],'mod_spamcheck_adminmail');
   // Sent mail //

   // Remote websites
   antispam_update_conftable($HTTP_POST_VARS['mod_spamcheck_checkremote'],'mod_spamcheck_checkremote');   
   
   // FieldFest
   antispam_update_conftable($HTTP_POST_VARS['mod_spamcheck_fieldfest'],'mod_spamcheck_fieldfest');

   // Max Websites
   antispam_update_conftable(intval($HTTP_POST_VARS['mod_spamcheck_maxsites']),'mod_spamcheck_maxsites');
   antispam_update_conftable(intval($HTTP_POST_VARS['mod_spamcheck_maxsitescount']),'mod_spamcheck_maxsitescount');

   // Spamchecklevel
   // Needs to be between 1 and 5
   $spamchecklevel = intval($HTTP_POST_VARS[mod_spamcheck_level]);
   if ($spamchecklevel < 1)
      $spamchecklevel = 1;
   if ($spamchecklevel > 5)
      $spamchecklevel = 5;
      antispam_update_conftable($spamchecklevel,'mod_spamcheck_level');
   // Spamchecklevel   

   // API
	antispam_update_conftable(intval($HTTP_POST_VARS['mod_spamcheck_api']),'mod_spamcheck_api');
	antispam_update_conftable(addslashes($HTTP_POST_VARS['mod_spamcheck_api_auth']),'mod_spamcheck_api_auth');

   // DB
   antispam_update_conftable($HTTP_POST_VARS['mod_spamcheck_dbstore'],'mod_spamcheck_dbstore');

   $url = "admin_antispam_fields.$phpEx";
   $meta = '<meta http-equiv="refresh" content="2;url=' . append_sid($url) . '&mode=generalconfig">';
   message_die(GENERAL_MESSAGE, $meta . $lang['Antispam_db_updateok']);
}

// MANAGEMENT
// -------------------------------------------------------------------------------------                                          
if ($mode === 'generalconfig') {
   $template->set_filenames(array (
      "body" => "admin/antispam_generalconfig_body.tpl"
   ));

   // Config //   
   // Bypass group
   write_block('BypassConfigset', '<br/><b/>Bypass this usergroup</b/>', '');
   write_block('BypassConfigset', $lang['Group_name'], show_groups());
   unset ($input);

   // Bypass user
   write_block('BypassConfigset', '<br/><b/>Bypass these users</b/>', '');
   $input = 'At least ';
   $input .= make_input('text', 'mod_spamcheck_userposts', $board_config[mod_spamcheck_userposts], 2);
   $input .= ' posts and are member for at least ';
   $input .= make_input('text', 'mod_spamcheck_userdays', $board_config[mod_spamcheck_userdays], 2);
   $input .= ' days.';
   write_block('BypassConfigset', 'Users who have', $input);
   unset ($input);

   write_block('BypassConfigset', 'Main admin', show_admins());
   unset ($input);

   // Enable
   $input = make_radio(array (
      'mod_spamcheck_check_pm',
      'mod_spamcheck_check_pm'
   ), array (
      '1',
      '0'
   ), array (
      'Yes',
      'No'
   ), $board_config[mod_spamcheck_check_pm]);
   write_block('EnableConfigset', 'Check all PMs?', $input);
   unset ($input);
   $input = make_radio(array (
      'mod_spamcheck_check_post',
      'mod_spamcheck_check_post'
   ), array (
      '1',
      '0'
   ), array (
      'Yes',
      'No'
   ), $board_config[mod_spamcheck_check_post]);
   write_block('EnableConfigset', 'Check all Posts?', $input);
   unset ($input);
   $input = make_radio(array (
      'mod_spamcheck_check_register',
      'mod_spamcheck_check_register'
   ), array (
      '1',
      '0'
   ), array (
      'Yes',
      'No'
   ), $board_config[mod_spamcheck_check_register]);
   write_block('EnableConfigset', 'Check all Registrations?', $input);
   unset ($input);

   // Remote Check
   $input = make_radio(array (
      'mod_spamcheck_checkremote',
      'mod_spamcheck_checkremote'
   ), array (
      '1',
      '0'
   ), array (
      'Yes',
      'No'
   ), $board_config[mod_spamcheck_checkremote]);
   write_block('OptionalConfigset', 'Visit remote websites and check for forbidden words?', $input);
   unset ($input);
   // FieldFest
   $input = make_radio(array (
      'mod_spamcheck_fieldfest',
      'mod_spamcheck_fieldfest'
   ), array (
      '1',
      '0'
   ), array (
      'Yes',
      'No'
   ), $board_config[mod_spamcheck_fieldfest]);
   write_block('OptionalConfigset', 'Enable FieldFest? (Recommended)', $input);
   unset ($input);
   // Max websites per post
   $input = make_radio(array (
      'mod_spamcheck_maxsites',
      'mod_spamcheck_maxsites'
   ), array (
      '1',
      '0'
   ), array (
      'Yes',
      'No'
   ), $board_config[mod_spamcheck_maxsites]);
   $input .= ' :: Max. websites: ' . make_input('text', 'mod_spamcheck_maxsitescount', $board_config[mod_spamcheck_maxsitescount], 2);
   write_block('OptionalConfigset', 'Max websites per post (Recommended)', $input);
   unset ($input);
   // Spamchecklevel
   $input = make_input('text', 'mod_spamcheck_level', $board_config[mod_spamcheck_level], 2);
   write_block('OptionalConfigset', 'Spamcheck level<br /> ( 1,2,3,4,5  1 = normal, 5 = aggressive )', $input);
   unset ($input);

   // API
   // Enable/disable
   $input = make_radio(array (
      'mod_spamcheck_api',
      'mod_spamcheck_api'
   ), array (
      '1',
      '0'
   ), array (
      'Enable',
      'Disable'
   ), $board_config[mod_spamcheck_api]);
   $input .= ' :: API key: ' . make_input('text', 'mod_spamcheck_api_auth', stripslashes($board_config[mod_spamcheck_api_auth]), 5);
   write_block('OptionalConfigset', 'API ( Optional for programmers )', $input);
   unset ($input);   

   // Sent mail
   $input = make_radio(array (
      'mod_spamcheck_sentmail',
      'mod_spamcheck_sentmail'
   ), array (
      '1',
      '0'
   ), array (
      'Yes',
      'No'
   ), $board_config[mod_spamcheck_sentmail]);
   write_block('SentMailConfigset', 'Sent mail on spam attempt', $input);
   unset ($input);

   $input = make_radio(array (
      'mod_spamcheck_htmlmail',
      'mod_spamcheck_htmlmail'
   ), array (
      '1',
      '0'
   ), array (
      'Yes',
      'No'
   ), $board_config[mod_spamcheck_htmlmail]);
   write_block('SentMailConfigset', 'Sent mail on spam attempt  in HTML format', $input);
   unset ($input);

   $input = make_input('text', 'mod_spamcheck_adminmail', $board_config[mod_spamcheck_adminmail], 30);
   write_block('SentMailConfigset', 'Sent mail on spam attempt to', $input);
   unset ($input);
   // Sent mail

   // DB storage  
   $input = make_radio(array (
      'mod_spamcheck_dbstore',
      'mod_spamcheck_dbstore'
   ), array (
      '1',
      '0'
   ), array (
      'Yes',
      'No'
   ), $board_config[mod_spamcheck_dbstore]);
   write_block('DatabaseConfigset', 'Store spam attemts in database', $input);
   unset ($input);

   // General //  
   $template->assign_vars(array (
      "MODE" => ucfirst($HTTP_GET_VARS['mode']
   ), "SID" => $SID, "ALPHA" => '<br />' . $lang['Antispam_alphafunction']));

}
// -------------------------------------------------------------------------------------                              
// MANAGEMENT

$template->pparse("body");

include ('./page_footer_admin.' . $phpEx);
?>
Return current item: Phpbbantispam