<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////
// BotBanish 9.0.02
// Randem Systems: https://randemsystems.support
// BotBanish Pre-Defines
// Date: 07/16/2026
//
///////////////////////////////////////////////////////////////////////////////////////////////////////

	global $BotBanishSettings, $BotBanishMemoryUsage;

//	BotBanishCheckMemoryUsage('Define Start');

//================================================================
// Setup IPv4 or IPv6 format for .htaccess
// Apache versions below 2.4.00 cannot use IPv6
//================================================================

	BotBanishDefineGlobals('BOTBANISH_APACHE_VERSION', intval(2400));

//================================================================
// .htaccess file error handling setup
//================================================================

	$curdir = str_ireplace('\\', '/', getcwd());
	chdir($_SERVER['DOCUMENT_ROOT']);
	$root = str_ireplace('\\', '/', getcwd());
	chdir($curdir);

	if (defined('ABSPATH')) {

		$repl = get_option( 'siteurl' );
		$rootfolder = BOTBANISH_PLUGIN_DIR;

	} else {

		$repl = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_NAME'];

		if (isset($boarddir))

			$rootfolder = isset($boarddir) ? $boarddir . '/' : '/';
		else
			$rootfolder = str_replace('\\', '/', realpath(getcwd() . '../../../../../')) . '/';
	}

	$char = '*';
	$start = str_repeat($char . ' ', 5);
	$end = str_repeat(' ' . $char, 5);
	$section = '# %s%s%s';


	BotBanishDefineGlobals('BOTBANISH_PAGE_HEADER', '
		<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="Expires" content="0" />
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.3.0/jspdf.umd.min.js"></script>
		<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
		<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
		<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
		<link rel="stylesheet" href="' . $BotBanishSettings['BOTBANISH_INSTALL_URL'] . 'css/stylesheet.css">
		');

	BotBanishDefineGlobals('BOTBANISH_CENTER_HEAD','
		<div>
			<table width="100%" align="center">
				<tr>
					<td width="25%"></td>
					<td width="50%">');

	BotBanishDefineGlobals('BOTBANISH_CENTER_FOOTER','
					</td>
					<td width="25%"></td>
				</tr>
			</table>
		</div>');

	BotBanishDefineGlobals('BOTBANISH_ROOT_FOLDER', $rootfolder);
	BotBanishDefineGlobals('BOTBANISH_APIKEY', 'Free');
	BotBanishDefineGlobals('BOTBANISH_GEO_APIKEY', 'Free');
	BotBanishDefineGlobals('BOTBANISH_LANGUAGE_DATABASE', 1);
	BotBanishDefineGlobals('BOTBANISH_HTACCESS_RECORD_IP', 1);
	BotBanishDefineGlobals('BOTBANISH_HTACCESS_RECORD_BOT', 1);
	BotBanishDefineGlobals('BOTBANISH_LOG_FILES', 10);

	BotBanishDefineGlobals('BOTBANISH_LOG_TYPES', 'Error, Activity, Access, Info, Contact, Reject, Block, Email, Message, SQLStatements, FormID, Trace, Message, Parsed');

	BotBanishDefineGlobals('BOTBANISH_CODE_START', '# * * * * * BotBanish CODE Start * * * * *');
	BotBanishDefineGlobals('BOTBANISH_CODE_END', '# * * * * * BotBanish CODE End * * * * *');
	BotBanishDefineGlobals('BOTBANISH_RULE_START', '# * * * * * BotBanish RULES Start * * * * *');
	BotBanishDefineGlobals('BOTBANISH_RULE_END', '# * * * * * BotBanish RULES End * * * * *');

	BotBanishDefineGlobals('BOTBANISH_XMLRPC_START', '# * * * * * BotBanish XMLRPC Start * * * * *');
	BotBanishDefineGlobals('BOTBANISH_XMLRPC_END', '# * * * * * BotBanish XMLRPC End * * * * *');
	BotBanishDefineGlobals('BOTBANISH_HTACCESS_START', '# * * * * * BotBanish HTACCESS Start * * * * *');
	BotBanishDefineGlobals('BOTBANISH_HTACCESS_END', '# * * * * * BotBanish HTACCESS End * * * * *');
	BotBanishDefineGlobals('BOTBANISH_WPCONFIG_START', '# * * * * * BotBanish WPCONFIG Start * * * * *');
	BotBanishDefineGlobals('BOTBANISH_WPCONFIG_END', '# * * * * * BotBanish WPCONFIG End * * * * *');

	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_REWRITE_BLACKLIST_START', sprintf($section, $start, 'BotBanish BOT Blacklist Start (REWRITECOND)', $end));
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_REWRITE_BLACKLIST_END', sprintf($section, $start, 'BotBanish BOT Blacklist End (REWRITECOND)', $end));
	
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_REWRITE_WHITELIST_START', sprintf($section, $start, 'BotBanish BOT Whitelist Start (REWRITECOND)', $end));
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_REWRITE_WHITELIST_END', sprintf($section, $start, 'BotBanish BOT Whitelist End (REWRITECOND)', $end));


	BotBanishDefineGlobals('BOTBANISH_HTACCESS_HEADER', PHP_EOL . PHP_EOL . '# Deny bandwidth, Spam, data and login attacks (BotBanish - ' . $BotBanishSettings['BOTBANISH_USER_HOST'] . ')' . PHP_EOL . PHP_EOL);
	BotBanishDefineGlobals('BOTBANISH_REPLACE', '//	* * * * * BotBanish * * * * *');

	// .htaccess section headers and footers

	BotBanishDefineGlobals('BOTBANISH_IP_HEADER_START', PHP_EOL . '<Limit GET POST>' . PHP_EOL . 'order allow,deny' . PHP_EOL . 'allow from all' . PHP_EOL . '</Limit>' . PHP_EOL);
	BotBanishDefineGlobals('BOTBANISH_BOT_HEADER_END', PHP_EOL . '<Limit GET POST HEAD>' . PHP_EOL . 'Order Allow,Deny' . PHP_EOL . 'Allow from all' . PHP_EOL . 'Deny from env=bad_bot' . PHP_EOL . '</Limit>' . PHP_EOL);
	BotBanishDefineGlobals('BOTBANISH_REQUIREALL_START_ORG', PHP_EOL . '<RequireAll>' . PHP_EOL . 'Require all granted' . PHP_EOL);
	BotBanishDefineGlobals('BOTBANISH_REQUIREALL_END_ORG', PHP_EOL . '</RequireAll>' . PHP_EOL);
	BotBanishDefineGlobals('BOTBANISH_REQUIREALL_START', PHP_EOL . '<Files *>' . PHP_EOL . '<RequireAll>' . PHP_EOL . 'Require all granted' . PHP_EOL);
	BotBanishDefineGlobals('BOTBANISH_REQUIREALL_END', PHP_EOL . '</RequireAll>' . PHP_EOL . '</Files>' . PHP_EOL);
	BotBanishDefineGlobals('BOTBANISH_EMPTY_REQUIRE', PHP_EOL . '<RequireAll>' . PHP_EOL . 'Require all granted' . PHP_EOL . '</RequireAll>' . PHP_EOL);
	BotBanishDefineGlobals('BOTBANISH_EMPTY_FILES', PHP_EOL . '<Files *>' . PHP_EOL . '</Files>' . PHP_EOL);
	
	// BotBanish .htaccess tags

	// IP Blacklist
	
	BotBanishDefineGlobals('BOTBANISH_TAG_IP_BLACKLIST_START', '# * * * * * BotBanish IP Blacklist Start * * * * *');
	BotBanishDefineGlobals('BOTBANISH_TAG_IP_BLACKLIST_END', '# * * * * * BotBanish IP Blacklist End * * * * *');
	
	BotBanishDefineGlobals('BOTBANISH_REWRITECOND_BLACKLIST_START', PHP_EOL . 'RewriteCond %{HTTP_USER_AGENT}' . PHP_EOL);
	BotBanishDefineGlobals('BOTBANISH_REWRITECOND_BLACKLIST_END', PHP_EOL . 'RewriteRule .* - [G,L,F]' . PHP_EOL);
		
	BotBanishDefineGlobals('BOTBANISH_TAG_IP_BLACKLIST_START_2_4', $BotBanishSettings['BOTBANISH_TAG_IP_BLACKLIST_START']);
	BotBanishDefineGlobals('BOTBANISH_TAG_IP_BLACKLIST_END_2_4', $BotBanishSettings['BOTBANISH_TAG_IP_BLACKLIST_END']);
	
	// IP Whitelist
	
	BotBanishDefineGlobals('BOTBANISH_TAG_IP_WHITELIST_START', '# * * * * * BotBanish IP Whitelist Start * * * * *');
	BotBanishDefineGlobals('BOTBANISH_TAG_IP_WHITELIST_END', '# * * * * * BotBanish IP Whitelist End * * * * *');

	BotBanishDefineGlobals('BOTBANISH_REWRITECOND_WHITELIST_START', PHP_EOL . 'RewriteCond %{HTTP_USER_AGENT}' . PHP_EOL);
	BotBanishDefineGlobals('BOTBANISH_REWRITECOND_WHITELIST_END', PHP_EOL . 'RewriteRule .* - [S=1]' . PHP_EOL);

	BotBanishDefineGlobals('BOTBANISH_TAG_IP_WHITELIST_START_2_4', $BotBanishSettings['BOTBANISH_TAG_IP_WHITELIST_START']);
	BotBanishDefineGlobals('BOTBANISH_TAG_IP_WHITELIST_END_2_4', $BotBanishSettings['BOTBANISH_TAG_IP_WHITELIST_END']);
		
	// BOT Blacklist
	
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_BLACKLIST_START', '# * * * * * BotBanish BOT Blacklist Start * * * * *');
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_BLACKLIST_END', '# * * * * * BotBanish BOT Blacklist End * * * * *');

	BotBanishDefineGlobals('BOTBANISH_BOT_REWRITECOND_BLACKLIST_2_4', 'RewriteCond %%{HTTP_USER_AGENT} ');
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_BLACKLIST_START_2_4', $BotBanishSettings['BOTBANISH_TAG_BOT_BLACKLIST_START']);
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_BLACKLIST_END_2_4', $BotBanishSettings['BOTBANISH_TAG_BOT_BLACKLIST_END']);

	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_REWRITECOND_BLACKLIST_START_2_4', sprintf($section, $start, 'BotBanish BOT Blacklist Start (REWRITECOND)', $end));
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_REWRITECOND_BLACKLIST_END_2_4', sprintf($section, $start, 'BotBanish BOT Blacklist End (REWRITECOND)', $end));

	// BOT Whitelist
	
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_WHITELIST_START', '# * * * * * BotBanish BOT Whitelist Start * * * * *');
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_WHITELIST_END', '# * * * * * BotBanish BOT Whitelist End * * * * *');

	BotBanishDefineGlobals('BOTBANISH_BOT_REWRITECOND_WHITELIST_2_4', 'RewriteCond %%{HTTP_USER_AGENT} ');
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_WHITELIST_START_2_4', $BotBanishSettings['BOTBANISH_TAG_BOT_WHITELIST_START']);
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_WHITELIST_END_2_4', $BotBanishSettings['BOTBANISH_TAG_BOT_WHITELIST_END']);

	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_REWRITECOND_WHITELIST_START_2_4', sprintf($section, $start, 'BotBanish BOT Whitelist Start (REWRITECOND)', $end));
	BotBanishDefineGlobals('BOTBANISH_TAG_BOT_REWRITECOND_WHITELIST_END_2_4', sprintf($section, $start, 'BotBanish BOT Whitelist End (REWRITECOND)', $end));
	


	BotBanishDefineGlobals('BOTBANISH_DATABASE_TABLE_COLLATIONS', array('utf8mb4_0900_ai_ci',
																		'utf8mb4_unicode_520_ci',
																		'utf8mb4_unicode_ci',
																		'utf8mb4_general_ci',
																		'utf8mb3_0900_ai_ci',
																		'utf8mb3_unicode_520_ci',
																		'utf8mb3_unicode_ci',
																		'utf8mb3_general_ci',
																		'utf8_general_ci')
																		);

	$collate = false;
	BotBanishDefineGlobals('BOTBANISH_DATABASE_TABLE_COLLATION_DEFAULT', 'utf8mb4_0900_ai_ci');
	BotBanishDefineGlobals('BOTBANISH_DATABASE_TABLE_CHARSET_DEFAULT', 'utf8mb4');

	global $mbname;
	$contact_formName = defined('SMF') ? $mbname : 'Contact';

	$colors = array(
		'Red' => '#FF0000',
		'Cyan' => '#00FFFF',
		'Blue' => '#0000FF',
		'DarkBlue' => '#00008B',
		'LightBlue' => '#ADD8E6',		
		'BrightBlue' => '#0099cc',
		'Purple' => '#800080',	
		'Yellow' => '#FFFF00',
		'Lime' => '#00FF00',
		'Magenta' => '#FF00FF',
		'Pink' => '#FFC0CB',
		'White' => '#FFFFFF',
		'Silver' => '#C0C0C0',
		'Grey' => '#808080',
		'Gray' => '#808080',
		'Black' => '#000000',
		'Orange' => '#FFA500',
		'Brown' => '#A52A2A',
		'Maroon' => '#800000',
		'Green' => '#008000',
		'Olive' => '#808000',
	);
	
	$lockout_array = array(

		'BOTBANISH_BAD_BOT_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_HITCOUNT_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_HIDDEN_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_EMAIL_USERNAME_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_ABUSE_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_URL_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_UNKNOWN_BOT_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_SPOOF_BOT_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_BAD_DOMAIN_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_INVALID_REQUEST_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_EMPTY_USERAGENT_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_IP_RANGE_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_GEO_ACTIVE' => 1,
		'BOTBANISH_COUNTRY_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_CONTACT_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_USER_LOCKOUT_ACTIVE' => 1,
		'BOTBANISH_TRUNCATE_ACTIVE' => 1,
		'BOTBANISH_RETAIN_ACTIVE' => 1,
		'BOTBANISH_REDIRECT_ONLY_ACTIVE' => 1,
		'BOTBANISH_IP_LOCKOUT_ACTIVE' =>1,

		'BOTBANISH_IP_LOCKOUT' => 1,
		'BOTBANISH_BAD_BOT_LOCKOUT' => 2,
		'BOTBANISH_HITCOUNT_LOCKOUT' => 3,
		'BOTBANISH_HIDDEN_LOCKOUT' => 4,
		'BOTBANISH_EMAIL_USERNAME_LOCKOUT' => 5,
		'BOTBANISH_ABUSE_LOCKOUT' => 6,
		'BOTBANISH_URL_LOCKOUT' => 7,
		'BOTBANISH_UNKNOWN_BOT_LOCKOUT' => 8,
		'BOTBANISH_SPOOF_BOT_LOCKOUT' => 9,
		'BOTBANISH_BAD_DOMAIN_LOCKOUT' => 10,
		'BOTBANISH_INVALID_REQUEST_LOCKOUT' => 11,
		'BOTBANISH_EMPTY_USERAGENT_LOCKOUT' => 12,
		'BOTBANISH_IP_RANGE_LOCKOUT' => 13,
		'BOTBANISH_COUNTRY_LOCKOUT' => 14,
		'BOTBANISH_CONTACT_LOCKOUT' => 15,
		'BOTBANISH_USER_LOCKOUT' => 16,

		'BOTBANISH_CONTACT_TRACE' => 0,
//		'BOTBANISH_CONTACT_ACTIVE' => 1,
		'BOTBANISH_CONTACT_LEARNING_ACTIVE' => 0,
		'BOTBANISH_CONTACT_FORM' => $contact_formName,
		'BOTBANISH_CONTACT_REQUIRED' => 'a,e,i,o,u',
		'BOTBANISH_CONTACT_ELIMINATE' => (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME'])) ? $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_NAME'] : substr($_SERVER['PHP_SELF'], 1, strripos($_SERVER['PHP_SELF'], '/')),
		'BOTBANISH_CONTACT_FORBIDDEN' => 'https://, http://, ftp://, sftp://, bit.ly, href=, www., !, $, %, Links to, mailto:, tinyurl, reseller, price, url=, hash=, .com, tiktok, facebook, instagram, free, sale, whatsapp, youtube, linkedin, wechat, telegram, messenger, snapchat, reddit, douyin, twitter, pinterest, qq, quora, qzone, ChatGPT, kuaishou',
		'BOTBANISH_CONTACT_EXCLUDE' => 'BotBanishClient:, BotBanishServer:, UpdraftPlus',
		'BOTBANISH_CONTACT_TAGS' => 'Subject, From, Name, First, Last, Phone, To, Email, IP, Body, Message',

		'BOTBANISH_USER_TRACE' => 0,
//		'BOTBANISH_USER_ACTIVE' => 1,
		'BOTBANISH_USER_REQUIRED' => 'a,e,i,o,u',
		'BOTBANISH_USER_ELIMINATE' => '',
		'BOTBANISH_USER_FORBIDDEN' => 'https://, http://, ftp://, sftp://, bit.ly, href=, www., !, $, %, Links to, mailto:, tinyurl, reseller, price, url=, hash=, .com, tiktok, facebook, instagram, free, sale, whatsapp, youtube, linkedin, wechat, telegram, messenger, snapchat, reddit, douyin, twitter, pinterest, qq, quora, qzone, ChatGPT, kuaishou',
		'BOTBANISH_USER_EXCLUDE' => '',
	);

	$dataarray = array(
//		'BOTBANISH_HTTP_USER_AGENT' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
		'BOTBANISH_HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
		'BOTBANISH_COLOR' => $colors,
		'BOTBANISH_DEBUG_ON' => 0,
		'BOTBANISH_LIMIT_LOG_IP' => 0,
		'BOTBANISH_INSTALL_DATE' => date('Y-m-d H:i:s'),
		'BOTBANISH' => 1,
		'BOTBANISH_SIGNATURE_POST_LIMIT' => 10,
		'BOTBANISH_HACKER' => 'Hacker',
		'BOTBANISH_USER_ID' => 0,
		'BOTBANISH_ANALYTICS_WEBSITE' => 1,
		'BOTBANISH_ANALYTICS_DOWNLOADS' => 1,
		'BOTBANISH_SERVERSIDE_ANALYTICS' => 0,		// Let server log the website and download hits (1 = Server / 0 = Local)
		'BOTBANISH_SEND_EMAIL_ALERTS' => 1,
		'BOTBANISH_CHECK_UPDATES' => 1,
		'BOTBANISH_DOC_ERRORS_MONITOR' => 1,
		'BOTBANISH_LOG_TO_DB' => 1,
		'BOTBANISH_MAX_HIT_COUNT' => 30,
		'BOTBANISH_MAX_HIT_SECONDS' => 30,
		'BOTBANISH_MAX_IP_RANGE_COUNT' => 25,
		'BOTBANISH_MAX_IP_DAY_COUNT' => 365,
		'BOTBANISH_HTACCESS_FLUSH_COUNT' => 20,
		'BOTBANISH_HTACCESS_FLUSH_TIME' => 20,
		'BOTBANISH_TRUNCATE_DAYS' => 90,
		'BOTBANISH_RETAIN_DAYS' => 10,
		'BOTBANISH_TRUNCATE_LAST_DATE' => strtotime(date('Y-m-d H:i:s')),

		'BOTBANISH_HTACCESS_CACHING' => 1,
		'BOTBANISH_DEFINE'=> 1,
		'BOTBANISH_VALUE' => 2,
		'BOTBANISH_STRING' => 3,
		'BOTBANISH_REQUEST_METHOD' => 'POST',
		'BOTBANISH_SESSION_TIMEOUT' => 3600 * 24,	// 24 hours

		// Plugin Status Display

		'BOTBANISH_PLUGIN_AUDIT_ACTIVE' => 1,
		'BOTBANISH_PLUGIN_AUDIT_DISPLAY_DATETIME' => 0,	// 1 = Relative, 0 - Normal
		'BOTBANISH_PLUGIN_AUDIT_DAYS' => 60,

		'BOTBANISH_DEBUG_FORCELOCKOUT' => 0,
		'BOTBANISH_DEBUG_LOG_ERRORS' => 1,
		'BOTBANISH_DEBUG_LOG_INFO' => 0,
		'BOTBANISH_DEBUG_SQL' => 0,
		'BOTBANISH_DEBUG_TRACE_ALL' => 0,
		'BOTBANISH_DEBUG_BACKTRACE' => 0,

		'BOTBANISH_CONTACT_LOCKOUT_HIT_COUNT' => 77777,
		'BOTBANISH_HONEY_POT_LOCKOUT_HIT_COUNT' => 99999,
		'BOTBANISH_SMF_BANNED_IP_IMPORT' => 66666,
		'BOTBANISH_DOWNLOAD_ERROR' => 55555,
		'BOTBANISH_REDIRECTION' => 88888,
		'BOTBANISH_HTACCESS_NAME' => '.htaccess',

		'BOTBANISH_DOC_ERRORS' =>  '401, 402, 403, 404, 405, 406, 410', // 403 (forbidden) is reserved for bot blocking
		'BOTBANISH_DOC_ERRORS_TERMINATE' =>  '400, 401',
		'BOTBANISH_UA_EXCEPTIONS' =>  'http://, https://, @, ?, #, ^, &, ~, $',
		'BOTBANISH_UA_UNKNOWN_BOT' => 'http://, https://, @, ?, #, ^, &, ~, $, bot, .html, .com',
		'BOTBANISH_HTACCESS_LOCK' => 'lock',
		'BOTBANISH_HTACCESS_UNLOCK' => 'unlock',
		'BOTBANISH_HONEYPOT_FILE_HTML' => 'BotBanish_RegisterAccount.html',
		'BOTBANISH_UPDATE_HTML_FOLDER' => $rootfolder,
		'BOTBANISH_UPDATE_HTML' => 0,
		'BOTBANISH_REFERER_DATA' => 1,
		'BOTBANISH_PAGE_DATA' => 1,

		'BOTBANISH_UPDATE_HTML_ACTIVE' => 0,
		'BOTBANISH_XMLRPC_ACTIVE' => 1,
		'BOTBANISH_WPCONFIG_ACTIVE' => 1,
		'BOTBANISH_HTACCESS_ACTIVE' => 1,
		'BOTBANISH_PROTECT_ROOT_ACTIVE' => 0,

		'BOTBANISH_FONT_RED_START' => '<b><font color=red>',
		'BOTBANISH_FONT_RED_END' => '</font></b>',

		'BOTBANISH_HEADER_HTML' => '<div align="center"><img src="' . $BotBanishSettings['BOTBANISH_IMAGES_URL'] . 'banner.png" width="90%" height="100"></div>',

		// Setup our arrays to manipulate the .htaccess file for the proper version
		// New style - Apache 2.4 and greater

		'HTACCESS_ENTRY_IP_BLACKLIST_2_4' => array(
			'tag_start' => $BotBanishSettings['BOTBANISH_TAG_IP_BLACKLIST_START_2_4'],
			'tag_end' => $BotBanishSettings['BOTBANISH_TAG_IP_BLACKLIST_END_2_4'],
			'start' => $BotBanishSettings['BOTBANISH_REQUIREALL_START'],
			'end' 	=> $BotBanishSettings['BOTBANISH_REQUIREALL_END'],
			'str'	=> 'Require not ip %s' . PHP_EOL,
			'type' => 'ip',
			'id' => 1
		),

		'HTACCESS_ENTRY_BOT_BLACKLIST_2_4' => array(
			'tag_start' => $BotBanishSettings['BOTBANISH_TAG_BOT_REWRITECOND_BLACKLIST_START_2_4'],
			'tag_end' => $BotBanishSettings['BOTBANISH_TAG_BOT_REWRITECOND_BLACKLIST_END_2_4'],
			'start'	=> $BotBanishSettings['BOTBANISH_REWRITECOND_BLACKLIST_START'],
			'end'	=> $BotBanishSettings['BOTBANISH_REWRITECOND_BLACKLIST_END'],
			'str'	=> $BotBanishSettings['BOTBANISH_BOT_REWRITECOND_BLACKLIST_2_4'] . '"%s" [OR,NC]' . PHP_EOL,
			'type' => 'bot',
			'id' => 2
		),

		'HTACCESS_ENTRY_BOT_WHITELIST_2_4' => array(
			'tag_start' => $BotBanishSettings['BOTBANISH_TAG_BOT_REWRITECOND_WHITELIST_START_2_4'],
			'tag_end' => $BotBanishSettings['BOTBANISH_TAG_BOT_REWRITECOND_WHITELIST_END_2_4'],
			'start'	=> $BotBanishSettings['BOTBANISH_REWRITECOND_WHITELIST_START'],
			'end'	=> $BotBanishSettings['BOTBANISH_REWRITECOND_WHITELIST_END'],
			'str'	=> $BotBanishSettings['BOTBANISH_BOT_REWRITECOND_WHITELIST_2_4'] . '"%s" [NC]' . PHP_EOL,
//			'str'	=> $BotBanishSettings['BOTBANISH_BOT_REWRITECOND_WHITELIST_2_4'] . '!^.*%s.* [NC]' . PHP_EOL,
			'type' => 'bot',
			'id' => 3
		),
		
		// Bot catcher. Only bots and some toolbars will trigger this link and then we own ya!

		'BOTBANISH_HIDDEN_HONEYPOT_LINK' => '<div name="divBotBanish" style="height: 0px;width: 0px;overflow:hidden;"><a href="' . $BotBanishSettings['BOTBANISH_HONEYPOT_URL'] . '">Register</a></div>',
		// Make sure all our folders etc... are defined

		'BOTBANISH_SCRIPT_DIR' => $BotBanishSettings['BOTBANISH_DIR'] . 'Analytics/',
		'BOTBANISH_CHECK_UPDATES' => 1,

		'BOTBANISH_HONEYPOT_HTML' =>
		'<!doctype html>'. PHP_EOL .
		'<html lang="en">'. PHP_EOL .
		'<head>'. PHP_EOL .
		'<META http-equiv="refresh" content="1;URL=%s">'. PHP_EOL .
		'<title>Register Account</title>'. PHP_EOL .
		'</head>'. PHP_EOL .
		'<body>'. PHP_EOL .
		'</body>'. PHP_EOL .
		'</html>'. PHP_EOL,
		
	'BOTBANISH_XMLRPC_DATA' => '
	# Block WordPress xmlrpc.php requests

	<Files xmlrpc.php>
	Require all denied
	</Files>',

	'BOTBANISH_HTACCESS_DATA' => '
	# Block .htaccess access

	<Files .htaccess>
	Require all denied
	</Files>',

	'BOTBANISH_WPCONFIG_DATA' => '
	# Block WordPress wp-config.php access

	<Files wp-config.php>
	Require all denied
	</Files>',
);
	
	BotBanishDefineGlobals('BOTBANISH_LANGUAGES', array('english'=>'english',
														'french'=>'french',
														'german'=>'german',
														'italian'=>'italian',
														'portuguese'=>'portuguese',
														'spanish'=>'spanish',
														'swedish'=>'swedish')
														);

	// Try to match the language that SMF is currently in to see if we support it

	if (defined('SMF')) {

		global $language;
		$str = explode('_', $language);
		$lang = $str[0];

	} else {

		$lang = 'english';
	}

	$lang = isset($language) && defined('SMF') && array_search($lang, $BotBanishSettings['BOTBANISH_LANGUAGES']) !== false ? strtolower($lang) : 'english';
	BotBanishDefineGlobals('BOTBANISH_LANGUAGE_SELECT', $lang);

	$dataarray = array_merge($dataarray, $lockout_array);

	foreach ($dataarray as $key => $value)
		BotBanishDefineGlobals($key, $value);

//================================================================
// Capture & Tracking Section
//================================================================

	// Webpage and download tracking. Gets placed on each page in the header section.

	BotBanishDefineGlobals('BOTBANISH_ANALYTICS_HTML', '
		<div id="BotBanishObj">

			<iframe id="botbanishanalytics" style="height: 0px;width: 0px;overflow:hidden;" frameborder="0" scrolling="auto" allowtransparency="true" src=""></iframe>

			<script type="text/javascript">

				pagename = document.getElementsByTagName("title")[0].innerHTML;
				document.getElementById("botbanishanalytics").allowTransparency = "true";
				document.getElementById("botbanishanalytics").src = "' . $BotBanishSettings['BOTBANISH_INSTALL_URL'] . 'Analytics/BotBanishAnalyticsLog.php?user_id=0&pagename="+pagename;

			</script>
		</div>
		');


	BotBanishInitLanguage();	// Language Section
	BotBanishDefineGlobals('BOTBANISH_TIMEZONE', BotBanishGetTimeZone());	// Time Zone Section
//	BotBanishCheckMemoryUsage('Define End');

function BotBanishInitLanguage() {

	global $BotBanishSettings;
	$language = defined('BOTBANISH_LANGUAGE_SELECT') ? $BotBanishSettings['BOTBANISH_LANGUAGE_SELECT'] : 'english';

	BotBanishDefineGlobals('BOTBANISH_LANGUAGE_SELECT', $language);

	$filename = 'BotBanishLanguage.' . $language . '.php';

	$txt = array();
	include $BotBanishSettings['BOTBANISH_LANGUAGE_DIR'] . $filename;

	if (!empty($txt))
		$BotBanishText = $txt;

	return $language;
}
?>