<?php
session_start();
header("content-type:text/html;charset=utf-8");
error_reporting(0);
date_default_timezone_set("PRC");
require_once "../sql.php";
if(isset($_POST['username'])){$username_login=$_POST['username'];}else{exit;}
if(isset($_POST['psd'])){$psd=$_POST['psd'];}else{exit;}
$yzsql="select * from admin where admin='{$username_login}'";
if($yzrst=mysql_query($yzsql)){
   if(mysql_num_rows($yzrst)>0){
    while($yzrow=@mysql_fetch_assoc($yzrst)){
        if($yzrow['admin']==$username_login && $yzrow['password']==$psd && $yzrow['time']==0){
            header("location:../index.php");
            $_SESSION['admin_name']=$username_login;
        }else{
        $yzcs=$yzrow['cishu']+1;
        $yzupdate="update admin set cishu=".$yzcs." where admin='{$username_login}'";
        mysql_query($yzupdate);
            if($yzrow['cishu']>=3){
              echo "error3";
              if($yzrow['cishu']==3){
              $time=time()+10;
              $errsql="update admin set time=".$time." where admin='{$username_login}'"; 
              mysql_query($errsql); 
              }
            }else{
                echo "error";
            }           
       if($yzrow['time']!=0 && $yzrow['time']<time()){
       $qingchu="update admin set cishu=0,time=0 where admin='{$username_login}'";
       mysql_query($qingchu);
       }    
     }
    }
  }else{
    echo "error2";
    }
}  
?>