示例#1
0
initVars('name', 'desc', 'password', 'domain', 'shell', 'package');
switch ($task) {
    case 'add':
        isadmin() || setmsg(t('Permission Dennied.'));
        header('Cache-Control: private');
        $token = token();
        $packages = ZPackage::getPackages();
        if (checktoken()) {
            $username = $_REQUEST['name'];
            $password = $_REQUEST['password'];
            $domain = $_REQUEST['domain'];
            $package = intval($_REQUEST['package']);
            $shell = $_REQUEST['shell'];
            $break = false;
            // check username
            if (true !== ($res = ZUser::chkUsername($username))) {
                $err['name'] = $res == 'invalid' ? t('Username Invalid. No uppercase, not starting with number, less than 7 chars.') : t('Username Occupied.');
                $break = true;
            }
            // check password
            if (true !== ($res = ZUser::chkPassword($password))) {
                $err['password'] = t('Password can not be empty.');
                $break = true;
            }
            // check domain
            if (true !== ($res = ZVhosts::chkDomain($domain))) {
                $err['domain'] = t('Domain Invalid.');
                if ($res == 'occupied') {
                    $err['domain'] = t('Domain Occupied.');
                }
                $break = true;
function chkUsername($username, $lenlimit = '{1,10}')
{
    return ZUser::chkUsername($username, $lenlimit);
}