<?php
error_reporting(0);
ini_set("date.timezone","PRC");
require_once("config.php");
isset($_POST['username'])?$username=$_POST['username']:$username=null;
isset($_POST['userpass'])?$userpass=$_POST['userpass']:$userpass=null;
$userpass = sha1($userpass."www.dunling.com");
$sql = "select * from dunling_menber where username='$username' and userpass='$userpass'";
$ery = mysql_query($sql,$config)or die("mysql error");
$num = mysql_num_rows($ery);
$u = mysql_fetch_array($ery);
$uid = $u['id'];
$username = $u['username'];
$locks = $u['locks'];
if($num == "0"){
    echo '1';
    exit;
}else{
    if($locks=="1"){
        echo "2";
        exit;
    }else{
    setcookie("uid",$uid,time()+3600*24,'/');
    setcookie("username",$username,time()+3600*24,'/');
    $time = time();
    $uplogintime = "update dunling_menber set logintime = '$time' where username = '$username'";
    mysql_query($uplogintime,$config);
    mysql_close();
    echo 'ok';
    exit;
    }
}
mysql_close();
?>