<?php
error_reporting(0);
isset($_GET['username'])?$username = $_GET['username'] :$username = null;
require_once("config.php");
if($username!=null){
$sql = "select username from dunling_user where username='$username'";
$ery = mysql_query($sql,$config);
$num = mysql_num_rows($ery);
if($num >= "1"){
    echo "no";
}else{
    echo "ok";
}
mysql_close();
exit;
}
isset($_POST['shenfen'])?$shenfen = $_POST['shenfen'] :$shenfen = null;
isset($_POST['username'])?$username = $_POST['username'] :$username = null;
isset($_POST['userpass'])?$userpass = $_POST['userpass'] :$userpass = null;
isset($_POST['qq'])?$qq = $_POST['qq'] :$qq = null;
if($username!=null and $userpass!=null){
$systemsql = "select regjinbi from dunling_config where id='1'";
$sysery = mysql_query($systemsql,$config);
$syscon = mysql_fetch_array($sysery);
$regjinbi = $syscon['regjinbi'];


    $sql = "select username from dunling_user where username='$username'";
    $ery = mysql_query($sql,$config);
    $num = mysql_num_rows($ery);
    if($num >= "1"){
    echo "no";
    exit;
    }

    $rand = rand(100000,999999);
    $newpass = sha1($userpass.$rand);
    ini_set("date.timezone","PRC");
    $time = date("Y-m-d H:i:s");
    $insql = "insert into dunling_user (username,userpass,qq,regtime,logintime,rand,shenfen,jinbi) values ('$username','$newpass','$qq','$time','$time','$rand','$shenfen','$regjinbi')";
    $inery = mysql_query($insql,$config);
    if($inery){
        setcookie("user",$username,time()+3600*72);
        setcookie("pass",$newpass,time()+3600*72);
        echo $shenfen;
    }else{
        echo "no";
    }
mysql_close();
exit;
    
}

?>