<?php
session_start();
include_once '../../common.php';
include_once '../../conn.php';
if($dailiid == "admin"){echo  $dailiid="";}	
if(!isset($_SESSION['username'])){echo "<script>alert('身份已失效请重新登录!')</script><script>location.href='index.php'</script>";exit;}
$username=ubo($_SESSION['username']);
if($_POST){
$name=ubo(iconv("UTF-8","GB2312",$_POST['name']));
$remarks=ubo(iconv("UTF-8","GB2312",$_POST['remarks']));
$reward=$_POST['reward'];
if($_POST['type']=='reward'){
    if($remarks==null){
        $type=" UPDATE `zhucema` SET `reward`=$reward where `user`='$name'";
        mysql_query($type);
        exit(json_encode(array('zt'=>"1")));
    }else{
        $type=" UPDATE `zhucema` SET `reward`=$reward,`remarks`='$remarks' where `user`='$name' ";
        mysql_query($type);
        exit(json_encode(array('zt'=>"1")));
    }


}

date_default_timezone_set('PRC');
if($name=='admin'){
$msg=iconv("GB2312","UTF-8","这个账户不允许添加");
$json_data = array ('zt'=>"0",'msg'=>$msg);   
echo json_encode($json_data);
}elseif($name==null){
$msg=iconv("GB2312","UTF-8","用户名不能为空");
$json_data = array ('zt'=>"0",'msg'=>$msg);   
echo json_encode($json_data);
}else{

$type="WHERE user='$name'";
$row=queryall(zhucema,$type); 
if($row){
$msg=iconv("GB2312","UTF-8","总代已存在");
$json_data = array ('zt'=>"0",'msg'=>$msg);   
echo json_encode($json_data);
}else{
$type="(`user`, `pass`,`zd`, `ma`, `zdsl`,`reward`,`remarks`) VALUES ('$name','123456','$name', '$name','1',$reward,'$remarks')";
dbinsert(zhucema,$type);
echo json_encode(array('zt'=>"1"));
}
}
}else{
$msg=iconv("GB2312","UTF-8","参数错误");
$json_data = array ('zt'=>"0",'msg'=>$msg);   
echo json_encode($json_data);
}
?>
