<?php

require dirname(__FILE__) . "/global.php";
if (isset($_POST['nickname'])) {
    $nickname = strAddslashes(trim($_POST['nickname']));
    if (!empty($nickname)) {
        $checkname = usernameCheck($nickname);
        if (!empty($checkname)) {
            echo "1 " . $checkname;
        } else {
            $DB->connect($mysql_host, $mysql_user, $mysql_pass, $mysql_dbname);
            $N = $DB->fetch_one("SELECT COUNT(`uid`) FROM `" . $table_member . "` WHERE lower(`name`)='" . strtolower($nickname) . "'");
            $DB->close();
            if ($N > 0) {
                echo "1 昵称“" . $nickname . "”已被注册,换一个吧 ^_^";
            } else {
                setcookie("TouristName", Xxtea::encrypt($nickname, $cookie_key_login), time() + 63072000, $cookie_path, $cookie_domain);
                echo "0 成功";
            }
        }
    } else {
        setcookie("TouristName", '', time() - 3600, $cookie_path, $cookie_domain);
        echo "1";
    }
} else {
    $tmp = template("anonymity.html");
    $tmp->assign('loginArr', $loginArr);
    $tmp->output();
}
ob_end_flush();
Exemple #2
0
    if (is_array($array)) {
        foreach ($array as $key => $value) {
            if (!is_array($value)) {
                $array[$key] = addslashes($value);
            } else {
                Add_S($array[$key]);
            }
        }
    }
}
//设置游客cookie
$anonymous = get_cookie('anonymous');
if (empty($anonymous)) {
    $xxtea = new Xxtea();
    $auth = real_ip() . "\t" . $timestamp;
    $strcode = $xxtea->encrypt($auth, "zzqss");
    set_cookie('anonymous', $strcode, $timestamp + 3600 * 24 * 7);
    //cookie有效期一周
    $anonymous = $strcode;
}
checkauth();
//检查用户登录
checkkey();
//统计购物车物品数量
if (!empty($_USERS['uname'])) {
    $wherestrcart = "uname ='" . $_USERS['uname'] . "'";
} else {
    $wherestrcart = "anonymous ='" . $anonymous . "'";
}
$_CARTCOUNT = DB::result_first("Select count(gid) From " . DB::table('cart') . " where " . $wherestrcart);
//购物车物品数量
Exemple #3
0
function adminCookie()
{
    global $cookie_path, $cookie_domain, $cookie_key_admin;
    $Secure = Xxtea::encrypt($_COOKIE['userName'] . "|" . $_COOKIE['userId'], $cookie_key_admin);
    setcookie("adminSecure", $Secure, time() + 86400, $cookie_path, $cookie_domain);
}