<?
if (isset($_POST["clear"])){

	$my_query='TRUNCATE TABLE `csf_ac_'.strip_tags(htmlspecialchars($_POST["clear"])).'`';
	mysql_query($my_query);
	echo '<script language="Javascript">alert("Таблица '.strip_tags(htmlspecialchars($_POST["clear"])).' успешно очищена")</script>';
}

if (isset($_POST["onpage"])){

	$g_onpage = strip_tags(htmlspecialchars($_POST["onpage"]));
	$g_newup =  (strip_tags(htmlspecialchars($_POST["newup"]))) ? "1" : "0";
	$g_protect =  strip_tags(htmlspecialchars($_POST["protect"]));

	$m_speedhack  = (strip_tags(htmlspecialchars($_POST["speedhack_chk"]))) ? "1" : "0";
	$m_spinhack  =(strip_tags(htmlspecialchars($_POST["spinhack_chk"]))) ? "1" : "0";
	$m_fastfire  = (strip_tags(htmlspecialchars($_POST["fastfire_chk"]))) ? "1" : "0";
	$m_cdhack  = (strip_tags(htmlspecialchars($_POST["cdhack_chk"]))) ? "1" : "0";
	$m_fighterfx  = (strip_tags(htmlspecialchars($_POST["fighterfx_chk"]))) ? "1" : "0";
	$m_cheatlist  = (strip_tags(htmlspecialchars($_POST["cheatlist_chk"]))) ? "1" : "0";
	$m_namespam  = (strip_tags(htmlspecialchars($_POST["namespam_chk"]))) ? "1" : "0";
	$m_bunnyhop  = (strip_tags(htmlspecialchars($_POST["bunnyhop_chk"]))) ? "1" : "0";
	$m_zoneguard  = (strip_tags(htmlspecialchars($_POST["zoneguard_chk"]))) ? "1" : "0";
	$m_cmdflood  = (strip_tags(htmlspecialchars($_POST["cmdflood_chk"]))) ? "1" : "0";
	$m_cheatnames  = (strip_tags(htmlspecialchars($_POST["cheatnames_chk"]))) ? "1" : "0";
	$m_cheatkey  = (strip_tags(htmlspecialchars($_POST["cheatkey_chk"]))) ? "1" : "0";
	$m_cheatsay  = (strip_tags(htmlspecialchars($_POST["cheatsay_chk"]))) ? "1" : "0";
	$m_filescheck  = (strip_tags(htmlspecialchars($_POST["filescheck_chk"]))) ? "1" : "0";
	$m_opengl32  = (strip_tags(htmlspecialchars($_POST["opengl32_chk"]))) ? "1" : "0";

	$fp = fopen('csf_ac_logs/config.php','w'); 
	$line = "<? \r\n\r\n	// Колличество записей на страницу";
	$line .= "\r\n	\$onpage = ".$g_onpage.";";
	$line .= "\r\n\r\n	// Отображение новых записей сверху";
	$line .= "\r\n	\$newup = ".$g_newup.";";
	$line .= "\r\n\r\n	// Вход с авторизацией";
	$line .= "\r\n	// 0 - Отключить авторизацию";
	$line .= "\r\n	// 1 - Авторизация на просмотр логов (При авторизации, Админка доступна тоже)";
	$line .= "\r\n	// 2 - Авторизация только при входе в Админ Панель";
	$line .= "\r\n	\$protect = ".$g_protect.";";
	$line .= "\r\n\r\n	// Список отображаемых модулей";
	$line .= "\r\n	\$menu_speedhack = ".$m_speedhack.";";
	$line .= "\r\n	\$menu_spinhack = ".$m_spinhack.";";
	$line .= "\r\n	\$menu_fastfire = ".$m_fastfire.";";
	$line .= "\r\n	\$menu_cdhack = ".$m_cdhack.";";
	$line .= "\r\n	\$menu_fighterfx = ".$m_fighterfx.";";
	$line .= "\r\n	\$menu_cheatlist = ".$m_cheatlist.";";
	$line .= "\r\n	\$menu_namespam = ".$m_namespam.";";
	$line .= "\r\n	\$menu_bunnyhop = ".$m_bunnyhop.";";
	$line .= "\r\n	\$menu_zoneguard = ".$m_zoneguard.";";
	$line .= "\r\n	\$menu_cmdflood = ".$m_cmdflood.";";
	$line .= "\r\n	\$menu_cheatnames = ".$m_cheatnames.";";
	$line .= "\r\n	\$menu_cheatkey = ".$m_cheatkey.";";
	$line .= "\r\n	\$menu_cheatsay = ".$m_cheatsay.";";
	$line .= "\r\n	\$menu_filescheck = ".$m_filescheck.";";
	$line .= "\r\n	\$menu_opengl32 = ".$m_opengl32.";";
	$line .= "\r\n \r\n?>"; 
	fwrite($fp,$line);
	fclose($fp);

	echo '<META HTTP-EQUIV = "Refresh" CONTENT = "0; URL='.$_SERVER["REQUEST_URI"].'">';

}

$newupcheck = ($newup) ? " checked" : "";
$protectcheck0 = ($protect==0) ? " checked" : "";
$protectcheck1 = ($protect==1) ? " checked" : "";
$protectcheck2 = ($protect==2) ? " checked" : "";

echo '
Очищение таблицы:
  <form method="post" action="'.$_SERVER["REQUEST_URI"].'">
   <p><select name="clear">
    <option value="speedhack">SpeedHack</option>
    <option value="spinhack">SpinHack</option>
    <option value="fastfire">FastFire</option>
    <option value="cdhack">CDHack</option>
    <option value="fighterfx">FighterFX</option>
    <option value="cheatlist">CheatList</option>
    <option value="namespam">NameSpam</option>
    <option value="bunnyhop">BunnyHop</option>
    <option value="zoneguard">ZoneGuard</option>
    <option value="cmdflood">CMDFlood</option>
    <option value="cheatnames">CheatNames</option>
    <option value="cheatkey">CheatKey</option>
    <option value="cheatsay">CheatSay</option>
    <option value="filescheck">FilesCheck</option>
    <option value="opengl32">OpenGL32</option>
   </select>
   <input type="submit" value="Очистить" ></p>
  </form> 
<hr/>

 <form method="post" action="'.$_SERVER["REQUEST_URI"].'">
	Колличество записей на страницу:
		<input name="onpage" type="text" size="3" value="'.$onpage.'"></input>
	<br>
		<label for="newup">Отображение новых записей сверху</label> <input type="checkbox" id="newup" name="newup" value="1" '.$newupcheck.'>
	<br><hr/>
	Вход с авторизацией:
		<p><input type="radio" name="protect" id="protect0" value="0" '.$protectcheck0.'> <label for="protect0">Отключить авторизацию</label></input></p>
		<p><input type="radio" name="protect" id="protect1" value="1" '.$protectcheck1.'> <label for="protect1">Авторизация на просмотр логов (При авторизации, Админка доступна тоже)</label></p>
		<p><input type="radio" name="protect" id="protect2" value="2" '.$protectcheck2.'> <label for="protect2">Авторизация только при входе в Админ Панель</label></p>
 <hr/>
	Список отображаемых модулей:
 <br>

		<table border="0" cellpadding="0" width="90%" align="center">
 <br>';
			$menuon = '';
			$selected = ($menu_speedhack) ? " checked" : "";
			$menuon .= '<td><p><label for="speedhack_chk">SpeedHack</label> <input type="checkbox" id="speedhack_chk" name="speedhack_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_spinhack) ? " checked" : "";
			$menuon .= '<p><label for="spinhack_chk">SpinHack</label> <input type="checkbox" id="spinhack_chk" name="spinhack_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_fastfire) ? " checked" : "";
			$menuon .= '<p><label for="fastfire_chk">FastFire</label> <input type="checkbox" id="fastfire_chk" name="fastfire_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_cdhack) ? " checked" : "";
			$menuon .= '<p><label for="cdhack_chk">CDHack</label> <input type="checkbox" id="cdhack_chk" name="cdhack_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_fighterfx) ? " checked" : "";
			$menuon .= '<p><label for="fighterfx_chk">FighterFX</label> <input type="checkbox" id="fighterfx_chk" name="fighterfx_chk" value="1" '.$selected.'></p></td>';

			$selected = ($menu_opengl32) ? " checked" : "";
			$menuon .= '<td><p><label for="opengl32_chk">OpenGL32</label> <input type="checkbox" id="opengl32_chk" name="opengl32_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_cheatlist) ? " checked" : "";
			$menuon .= '<p><label for="cheatlist_chk">CheatList</label> <input type="checkbox" id="cheatlist_chk" name="cheatlist_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_namespam) ? " checked" : "";
			$menuon .= '<p><label for="namespam_chk">NameSpam</label> <input type="checkbox" id="namespam_chk" name="namespam_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_bunnyhop) ? " checked" : "";
			$menuon .= '<p><label for="bunnyhop_chk">BunnyHop</label> <input type="checkbox" id="bunnyhop_chk" name="bunnyhop_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_zoneguard) ? " checked" : "";
			$menuon .= '<p><label for="zoneguard_chk">ZoneGuard</label> <input type="checkbox" id="zoneguard_chk" name="zoneguard_chk" value="1" '.$selected.'></p></td>';
			
			$selected = ($menu_cmdflood) ? " checked" : "";
			$menuon .= '<td><p><label for="cmdflood_chk">CMDFlood</label> <input type="checkbox" id="cmdflood_chk" name="cmdflood_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_cheatnames) ? " checked" : "";
			$menuon .= '<p><label for="cheatnames_chk">CheatNames</label> <input type="checkbox" id="cheatnames_chk" name="cheatnames_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_cheatkey) ? " checked" : "";
			$menuon .= '<p><label for="cheatkey_chk">CheatKey</label> <input type="checkbox" id="cheatkey_chk" name="cheatkey_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_cheatsay) ? " checked" : "";
			$menuon .= '<p><label for="cheatsay_chk">CheatSay</label> <input type="checkbox" id="cheatsay_chk" name="cheatsay_chk" value="1" '.$selected.'></p>';
			$selected = ($menu_filescheck) ? " checked" : "";
			$menuon .= '<p><label for="filescheck_chk">FilesCheck</label> <input type="checkbox" id="filescheck_chk" name="filescheck_chk" value="1" '.$selected.'></p></td>';


			echo $menuon;

echo '</td></tr></table>
 <hr/>
<div align="right"><input type="submit" value="Сохранить" ></div>
</form> 
';

?>