<style>
BODY {
	PADDING-RIGHT: 0px; 
	PADDING-LEFT: 0px; 
	background-position: top;
    scrollbar-base-color: color;
    scrollbar-track-color: color;
    scrollbar-face-color: #3399ff;
    scrollbar-highlight-color: color;
    scrollbar-3dlight-color: color;
    scrollbar-darkshadow-color: color;
    scrollbar-shadow-color: color;
    scrollbar-arrow-color: #FF0000;
	PADDING-BOTTOM: 0px; 
	MARGIN: 0px; 
	PADDING-TOP: 0px; 
	FONT-FAMILY: trebuchet ms, arial, helvetica,sans-serif; 
	BACKGROUND-COLOR: #99CCFF
}
A:link {
	 COLOR: #000CFF;
}
A:visited {
	 COLOR: #000CFF;
}
A:hover {
	COLOR: #FF0000;
}
	input.sb {color:#5B5B5B;font: 12px Arial;height:20px;border:1px #414141 solid;background-image:url(../images/fbg2.gif)}
input.sb2 { margin: 0px;font: 12px Arial; background:#9bc3e6 url(../images/fbg4.gif) repeat-x; color: black; cursor:hand;)}

</style>
<?php
include "config.php";
error_reporting(1);
$cat[1]="Бизнес/Финансы";
$cat[2]="Государство/Право";
$cat[3]="Информация/Справки";
$cat[4]="Компьютеры/Интернет";
$cat[5]="Культура/Искусство";
$cat[6]="Медицина/Здоровье";
$cat[7]="Наука/Образование";
$cat[8]="Новости/СМИ";
$cat[9]="Отдых/Развлечения";
$cat[10]="Страны/Города";
$cat[11]="Товары/Услуги";
$cat[12]="Прочее";
$cat_nums=12;
$count_notes = count($notes);
if (isset($_POST['password']) && $_POST['password'] != PASSWORD)
	echo "<center><b>Пароль <font color=#FF0000>НЕВЕРНЫЙ!";
if (isset($_POST['password']) && $_POST['password'] == PASSWORD) {
	session_register('admin');
	$admin = PASSWORD;
}
if (!isset($admin)) { print_access_form(); exit; }
$action=htmlspecialchars(substr(trim($_POST['action']),0,10));
$cat_id=htmlspecialchars(trim($_POST['cat_id']));
if (isset($_POST['sid'])) {
$sid=eregi_replace("&amp;", "&", htmlspecialchars(substr(trim($_POST['sid']),0,80)));
$GEST_DB="cat".$cat_id.".db";
$notes = file($GEST_DB);
$count_notes = count($notes);
	$n=-1;
    for ($j=0;$j<$count_notes;$j++) {
    	$record = explode("¤", trim($notes[$j]));
		if ($sid==trim($record[4])) { $n=$j; break; }
	}
	if ($action == "delete") $notes[$n]="";
	 elseif ($action == "exclude") {
		 $st=$notes[$n];
		 if ($st[0] != "*") $notes[$n]="*".$st;
	 }
	  else if (($action == "restore") && ($n>-1)) {
		  $st=$record[0];
		  if ($st[0] == "*") $notes[$n] = substr($notes[$n],1);
	  }
	 $fopt = fopen ($GEST_DB, "w"); 
	 chmod($GEST_DB, 0733);
	 if ($fopt) 
		for ($j=0;$j<$count_notes;$j++) 
		   if (!(($action == "delete") && ($n == $j))) $result = fwrite($fopt, $notes[$j]);
	 fclose($fopt);
}
if (isset($_GET['cat_id'])) $id=htmlspecialchars(trim($_GET['cat_id']));
if (isset($_POST['cat_id'])) $id=htmlspecialchars(trim($_POST['cat_id']));
if (!$id) $id = "1";
$GEST_DB="cat".$id.".db";
$notes = file($GEST_DB);
$count_notes = count($notes);
?>
<p>&nbsp;</p><h3><p align=center><b>Панель администратора.</b></p></h3><table align=center background="<?php echo top_bg2; ?>"><tr>
<td align=center class=d4 background="<?php echo top_bg3; ?>"><b>Участники рейтинга<td align=center class=d4 background="<?php echo top_bg3; ?>"><b>Действие<td align=center background="<?php echo top_bg3; ?>">
<tr><td>
<script language="jscript">
function check_action(f) {
	if (f.action.value=='show') {
		document.all.go.href=f.sid.value;
		return false;
	}
	else return true;
}
</script>
<form name="a_form" method="POST" onsubmit="return check_action(this);">
<select name="sid" style="width:420px">
<?php
  for ($j=0;$j<$count_notes;$j++) {
	  $record = explode("¤", trim($notes[$j]));
      $st=substr($record[0],0,1);
	  if ($st[0] == "*") { echo "#"; $start = 1; } else $start = 0;
	  $url = substr($record[0], $start+7, 100);
	  if (strpos($url, "/")>-1) $url = substr($url, 0, strpos($url, "/"));
	  echo "<option value=\"".substr($record[4], 0, 100)."\">";
	  if ($st[0] == "*") echo "#";
	  echo substr($record[1], 0, 40)." [".$url."]</option>";
  }
?>
</select>
 <input type="hidden" name="cat_id" value="<?php echo $id; ?>">
  <td>
  <select name="action">
    <option value="exclude">исключить</option>
    <option value="restore">включить</option>
    <option value="delete">удалить</option>
    <option value="show">проверить</option>
  </select><td>
<input type="hidden" name="password" value="<?php echo $admin; ?>" />
<input class=sb2 type="submit" value="выполнить" style="cursor:hand;width:100px;height:22px">
<tr><td></form>
<form name="frm">
<table align=center background="<?php echo top_bg2; ?>"><tr><td class=d3><b>Email : 
<select name="mail">
<?php
  for ($j=0;$j<$count_notes;$j++) {
	  $record = explode("¤", trim($notes[$j]));
	  echo "<option value=\"".$record[5]."\">  ".substr($record[5],0,30)."</option>";
  }
?>
</select> <td> <input name="email" class=sb type="text" value=""> <td> <input class=sb2 type="button" value="Изьять" onclick="document.frm.email.value=document.frm.mail.value"><td></td></tr></table>
<td align=center><a name="go" target="_blank"><b>Cсылка</b></a><td>
</td></tr></table>
</form>
<?php
function print_access_form() {
?>
<p>&nbsp;</p><p>&nbsp;</p><form method="post" name="admin" id="check">
<table border="0" cellspacing="0" cellpadding="4" align=center>
<tr>
	<td align=center><b>Введите пароль: 
<tr><td><input class=sb type="password" name="password" id="password" size="20" maxlength="20" style="height:20px">
&nbsp;<input class=sb2 type="submit" name="entry" value="Войти"></td>
</tr>
</table>
</form>
<?php } ?>
<center><form method=POST action="admin.php">
<select name="cat_id">
<?php
for ($j=1;$j<=$cat_nums;$j++)  {
	echo "<option value=\"".$j."\"";
    if ($j == $id) echo " selected";
    echo ">".$cat[$j]."</option>";
}
?>
</select>&nbsp;<input class=sb2 type="submit" value=">>>" />
<input type="hidden" name="password" value="<?php echo $admin ?>" /></form> 
<p>&nbsp;</p>