Exemplo n.º 1
0
<?php

require '../include/init.inc';
require '../include/util.inc';
$uid = auth('uid');
$error = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = $_POST['username'];
    if (!validate_nickname($username)) {
        $error = "请输入有效的用户名";
    } else {
        if (Radcheck::exists(array('username' => $username))) {
            $error = "该用户名已经存在";
        } else {
            $password = make_random_key();
            $rc = Radcheck::create(array('username' => $username, 'value' => $password, 'attribute' => 'Cleartext-Password', 'op' => ':='));
            UserRadacct::create(array('uid' => $uid, 'radacctid' => $rc->id));
        }
    }
} else {
    if (isset($_REQUEST['a']) && $_REQUEST['a'] == 'delete') {
        $id = $_REQUEST['id'];
        $ura = UserRadacct::find_by_pk($id, array());
        if ($ura) {
            Radcheck::delete_all(array('conditions' => array('id' => $ura->radacctid)));
            $ura->delete();
        }
        header('Location: accounts.php');
    }
}
$radcheck = UserRadacct::find_by_uid($uid);
Exemplo n.º 2
0
            alert(s("该Email已被占用", 'This email is aleady taken'), 'error');
        }
    }
    if (!validate_nickname($nickname)) {
        alert(s("请输入有效的昵称", 'Please input valid nick name'), 'error');
    } else {
        if (User::check_nickname($nickname)) {
            alert(s("该昵称已被占用", 'This nick name is aleady taken'), 'error');
        }
    }
    if (!validate_password($password)) {
        alert(s("请输入有效的密码", 'Please input valid password'), 'error');
    }
    if (count($alerts) <= 0) {
        $hashed_password = md5($password . $config['salt']);
        $verify_hash = make_random_key();
        $user = User::create(array('email' => $email, 'nickname' => $nickname, 'password' => $hashed_password, 'verify_hash' => $verify_hash, 'is_locked' => 1));
        Radcheck::create(array('username' => $email, 'value' => $password, 'attribute' => 'Cleartext-Password', 'op' => ''));
        // send active mail
        $r = Mailer::send_account_active($user->id);
        if ($r) {
            $_SESSION['email'] = $user->email;
            header('Location: /register_next.php');
        } else {
            alert(s("注册失败,请稍后重试", 'Register failed, please try again later'), 'error');
        }
    }
}
?>
<!DOCTYPE html>
<html>