<?php

if (IS_POST)
{
    $arr2 = array();
    $arr2['team'] = intval($_POST['team']);
    str_is_int($_POST['username']) && yun_error('用户名不能全为数字');
    strlen($_POST['username']) < 3 && yun_error('用户名不能少于3位',
        'yun_onfocus("username");');
    $result = $db->query("select * from " . PF . "user where name='" . addslashes($_POST['username']) .
        '\'');
    $db->num_rows($result) && yun_error('用户已存在', 'yun_onfocus("username");');
    $arr2['name'] = $_POST['username'];
    strlen($_POST['pass']) < 5 && yun_error('密码不能少于5位', 'yun_onfocus("pass");');
    $arr2['pass'] = md5(md5($_POST['pass']));
    ereg("^[-a-zA-Z0-9_\.]+\@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$", $_POST['email']) or
        yun_error('邮箱格式不正确', 'yun_onfocus("email");');
    $result = $db->query("select * from " . PF . "user where email='" . addslashes($_POST['email']) .
        "'");
    $db->num_rows($result) && yun_error('邮箱已存在', 'yun_onfocus("email");');
    $arr2['email'] = $_POST['email'];
    $arr2['posts'] = abs(intval($_POST['posts']));
    $arr2['sex'] = $_POST['sex'] ? 1 : 0;
    $arr2['reg_time'] = TIME;
    foreach ($arr2 as $k => $v)
    {
        $arr2[$k] = '\'' . addslashes($v) . '\'';
    }
    $karr = array_keys($arr2);
    $karrs = implode(',', $karr);
    $varrs = implode(',', $arr2);
    if ($db->query("insert into " . PF . "user ($karrs) values($varrs)"))
    {
        yun_succeed('创建成功', url(RPGM . 'user/'), true);
    } else
    {
        yun_error('创建失败');
    }
}
$arr = array();
arg($arr, $id);

?>