<?php

///////////////////////////////////////////////////////////////////////////////////////////////////////
// BotBanish 7.1.00
// Randem Systems: https://randemsystems.support
// BotBanish Black and White IP List Templates for SMF
// Date: 01/28/2026
// Usage: 
//
// Function: Shows Black / White IP Lists
///////////////////////////////////////////////////////////////////////////////////////////////////////

function template_search_blackwhitelist()
{
	global $context, $scripturl, $BotBanishText, $BotBanishSettings;

	$type = stripos($_REQUEST['area'], 'whitelist') === false ? 'blacklist' : 'whitelist';
	$rtn = 'searchdata' . $type . 'ip';
	
	echo $BotBanishSettings['BOTBANISH_HEADER_HTML'];

	echo '
	<div id="admincenter">
		<form action="', $scripturl, '?action=botbanish;area=' . $rtn . '" method="post" accept-charset="', $context['character_set'], '">
			<div class="cat_bar">
				<h3 class="catbg">
					<span class="floatleft">', $BotBanishText['search_for'] . ' ' . $context['BotBanishBlackWhiteListType'], '</span>
					<span class="smalltext floatright">', $BotBanishText['wild_cards_allowed'], '</span>
				</h3>
			</div>
			<input type="hidden" name="sa" value="query" />
			<div class="windowbg">
				<span class="topslice"><span></span></span>
				<div class="content">
					<div class="flow_hidden">
						<div class="msearch_details">
							<dl class="settings right">
								<dt class="righttext">
									<strong>', $BotBanishText['ip_id'], ':</strong>
									<select name="types[spiderid]">
										<option value="--">&lt;</option>
										<option value="-">&lt;=</option>
										<option value="=" selected="selected">=</option>
										<option value="+">&gt;=</option>
										<option value="++">&gt;</option>
									</select>
								</dt>
								<dd>
									<input type="text" name="ipid" value="" size="10" class="input_text" />
								</dd>
								<dt class="righttext">
									<strong>', $BotBanishText['ip_addr'], ':</strong>
									<select name="types[spidername]">
										<option value="--">&lt;</option>
										<option value="-">&lt;=</option>
										<option value="=" selected="selected">=</option>
										<option value="+">&gt;=</option>
										<option value="++">&gt;</option>
									</select>
								</dt>
								<dd>
									<input type="text" name="ip" value="" size="15" class="input_text" />
								</dd>';
								
	if ($context['BotBanishBlackWhiteType'] == 'whitelistip') {
		
		echo '					<dt class="righttext">
									<strong>', $BotBanishText['ip_name'], ':</strong>
									<select name="types[useragentpart]">
										<option value="--">&lt;</option>
										<option value="-">&lt;=</option>
										<option value="=" selected="selected">=</option>
										<option value="+">&gt;=</option>
										<option value="++">&gt;</option>
									</select>
								</dt>
								<dd>
									<input type="text" name="ipname" value="" size="30" class="input_text" />
								</dd>';
	}
	
		echo '				</dl>
						</div>
					</div>
				</div>
				<span class="botslice clear_right"><span></span></span>
			</div>
			<br />
			</div><br />
			<div class="righttext">
				<input type="submit" value="', $BotBanishText['blackwhitelist_search'] . ' ' . $context['BotBanishBlackWhiteListType'], '" class="button_submit" />
			</div>
		</form>
	</div>
	<br class="clear" />';
}

function template_add_blackwhitelist()
{
	global $context, $scripturl, $BotBanishText, $BotBanishSettings;

	$type = stripos($_REQUEST['area'], 'whitelist') === false ? 'blacklist' : 'whitelist';
	$rtn = 'adddata' . $type . 'ip';
	
	echo $BotBanishSettings['BOTBANISH_HEADER_HTML'];

	echo '
	<div id="admincenter">
		<form action="', $scripturl, '?action=botbanish;area=' . $rtn . '" method="post" accept-charset="', $context['character_set'], '">
			<div class="cat_bar">
				<h3 class="catbg">
					<span class="floatleft">', $BotBanishText['blackwhitelist_add'] . ' ' . $context['BotBanishBlackWhiteListType'], '</span>
					<span class="smalltext floatright">', $BotBanishText['wild_cards_not_allowed'], '</span>
				</h3>
			</div>
			<input type="hidden" name="sa" value="add" />
			<div class="windowbg">
				<span class="topslice"><span></span></span>
				<div class="content">
					<div class="flow_hidden">
						<div class="msearch_details">
							<dl class="settings right">
								<dt class="righttext">
									<strong>', $BotBanishText['ip_addr'], ':</strong>
								</dt>
								<dd>
									<input type="text" name="ip" value="" size="15" class="input_text" />
								</dd>';

	if ($context['BotBanishBlackWhiteType'] == 'whitelistips') {
		
		echo '					<dt class="righttext">
									<strong>', $BotBanishText['ip_name'], ':</strong>
								</dt>
								<dd>
									<input type="text" name="ipname" value="" size="30" class="input_text" />
								</dd>';
	}
								
	echo '					</dl>
						</div>
					</div>
				</div>
				<span class="botslice clear_right"><span></span></span>
			</div>
			<br />
			</div><br />
			<div class="righttext">
				<input type="submit" value="', $BotBanishText['blackwhitelist_add'] . ' ' . $context['BotBanishBlackWhiteListType'], '" class="button_submit" />
			</div>
		</form>
	</div>
	<br class="clear" />';
}
?>