View file top/inc/admin.php

File size: 5.02Kb
<?php
error_reporting(0);
function login($currentPassword)
{
  global $password; 
  session_register("password");	
  $password = $currentPassword;
  if($password == PASSWORD) return true;
    else	
	{ 
	  session_unregister("password"); 
	  @sleep(1); 
	  return false; 
	}
}
function checkPermissions($currentPassword)
{
	if($currentPassword != PASSWORD) 
	{ 
	  session_destroy(); 
	  exit; 
	}
}
session_start();
if (!isset($password)) $password = "";
$loginUser = login($password);
if(!$loginUser)
{
	print_access_form(); 
	exit;
}
$action=htmlspecialchars(substr(trim($_POST['action']),0,10));
if ($action == 'nul')
{
	 $fod=getcwd();
     $fold=$fod."/inc/members";
     chdir($fold);
     $fo=opendir($fold);
     while ($read=readdir($fo))
     { 
       if(($read != ".") && ($read != "..")) 
       { 
    	 $fnt = file("$read");
	     $record = explode("¤", trim($fnt[0]));
	     $sd = trim($record[4]);
		 $IO_data = "../data/io_".$sd.".dat";
		 $io = fopen($IO_data, "w");
		 $result = fwrite($io, "0¤0");
		 fclose($IO_data);
	     rsort($note);
       } 
     }
     chdir("../../");
     closedir($fo);		
}
if (isset($_POST['sid'])) {
	$sid=htmlspecialchars(substr(trim($_POST['sid']),0,5));
	if ($action == "delete") 
	{
		@unlink("./inc/members/sid".$sid.".db");
		@unlink("./inc/data/io_".$sid.".dat");
		@unlink("./inc/data/date_of_".$sid.".dat");
		@unlink("./inc/data/daylog_of_".$sid.".dat");
		@unlink("./inc/data/hit_of_".$sid.".dat");
	}
	 elseif ($action == "exclude") {
      $not = file("./inc/members/sid".$sid.".db");
	  $st=$not[0];
	  if ($st[0] != "*") $st = "*".$st;
	  $fo = fopen("./inc/members/sid".$sid.".db", "w");
	  fwrite($fo, $st);
	 }
	  else if ($action == "restore") {
        $not = file("./inc/members/sid".$sid.".db");
	    $st=$not[0];
	    if ($st[0] == "*") $st = substr($st,1);
	    $fo = fopen("./inc/members/sid".$sid.".db", "w");
	    fwrite($fo, $st);
	  }
}
 $fod=getcwd();
 $fold=$fod."/inc/members";
 chdir($fold);
 $fo=opendir($fold);
 while ($read=readdir($fo))
 { 
   if(($read != ".") && ($read != "..")) 
   { 
	 $note[]=$read; 
	 $fnt = file("$read");
	 $notes[] = $fnt[0];
	 rsort($note);
   } 
 }
 chdir("../../");
 closedir($fo);		
 $count_notes = count($notes);
?>
<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') {
		w_open=window.open(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;
	  echo "<option value=\"".trim($record[4])."\">";
	  if ($st[0] == "*") echo "#";
	  echo "[".$record[4]."] ".substr($record[0], $start, 80)."</option>";
  }
?>
</select>
  <td>
  <select name="action">
    <option value="exclude">исключить</option>
    <option value="restore">включить</option>
    <option value="delete">удалить</option>
  </select><td>
<input class=sb2 type="submit" value="выполнить" style="cursor:hand;width:100px;height:22px">
<input type="hidden" name="password" value="<?php echo $password; ?>" />
<tr>
</td></tr></table>
</form><br>
<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[3]."\">[".$record[4]."]  ".substr($record[3],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"><input type="hidden" name="password" value="<?php echo $password; ?>" /></td></tr></table></form>
<p align=center class=d4><form method="POST"><input type="hidden" name="action" value="nul">
<input class=sb2 type="submit" value="Обнулить рейтинг" style="width:180;height:24px"></form></p> 
<p align=center class=d4><form action="index.php" target="_blank"><input class=sb2 type="submit" value="  Просмотреть рейтинг" style="width:180;height:24px" /></b></a></p></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" size="20" maxlength="20" style="height:20px">
&nbsp;<input class=sb2 type="submit" value="Войти"></td>
</tr>
</table>
</form>
<?php }?>