有没有办法注销在php中完成的摘要认证.
我试过unset($ _ SERVER ["PHP_AUTH_DIGEST"]); 但它不会要求重新登录.我知道如果我关闭浏览器然后它将工作,这是我的功能.
function login(){
$realm = "Restricted area";
$users = array("jamesm"=>"");
if (empty($_SERVER["PHP_AUTH_DIGEST"])) {
header("HTTP/1.1 401 Unauthorized");
header("WWW-Authenticate: Digest realm=\"{$realm}\",qop=\"auth\",nonce=\"".uniqid()."\",opaque=\"".md5($realm)."\"");
return false;
}
if (!($data = http_digest_parse($_SERVER["PHP_AUTH_DIGEST"])) || !isset($users[$data["username"]]))
return false;
$A1 = md5($data["username"] . ":{$realm}:{$users[$data["username"]]}");
$A2 = md5($_SERVER["REQUEST_METHOD"].":{$data["uri"]}");
$valid_response = md5("{$A1}:{$data["nonce"]}:{$data["nc"]}:{$data["cnonce"]}:{$data["qop"]}:{$A2}");
if ($data["response"] != $valid_response)
return false;
return true;
}
function logout(){
unset($_SERVER["PHP_AUTH_DIGEST"]);
return true;
}
Run Code Online (Sandbox Code Playgroud)
我还需要添加到注销功能以完成此操作.
如果我改变了它的作用,但我不希望它被改变.
php security logout digest-authentication http-status-code-401
在绘制和移动模型时如何使用z轴?
我目前的代码中有以下内容:
var canvas = {
obj: document.querySelector("canvas"),
models: [{
start: [10, 10, 10],
end: [1, 20, 20],
color: "silver",
},{ start: [30, 30, 30],
end: [10, 1, 10],
color: "silver",
},{ start: [60, 60, 60],
end: [10, 10, 10],
color: "silver",
}],
data: {},
draw: (function () {
if (this.obj.getContext) {
this.data.ctx = this.obj.getContext('2d');
this.models.forEach(function () {
canvas.data.ctx.fillStyle = this.color;
canvas.data.ctx.fillRect(this["start"][0], this["start"][1], this["end"][0], this["end"][1]);
}));
}
return this
})
}.draw()
Run Code Online (Sandbox Code Playgroud)
我知道3d可以在2d画布中使用,例如Pre3D库
所以我要做的是拥有一个商品的模型,并能够在3D中平移和环顾四周...我仍然不知道如何移动一切,但现在我要求如何获得z轴那里...然后我会问如何移动画布......
由于我的登录不起作用,我使用PHP和JavaScript这样做.
PHP:
$users = sql("SELECT * FROM USERS WHERE SITE_ID='${CONFIG["ID"]}'");
if($_REQUEST["logindata"]){
$logindata = $_REQUEST["logindata"];
$now = array_shift(explode(" ",microtime()));
if($_REQUEST["time"] < strtotime("+10 sec",$now) && $_REQUEST["time"] > strtotime("-10 sec",$now))
exit(json_encode(array("TYPE"=>"FUNCTION","FUNCTION"=>"(\$login.failed(\"Time out for this request.. (Go away bots)\"))")));
foreach($users as $user){
if(hash_hmac("sha1",$user["LOGIN_SALT"],hash_hmac("sha1",$_SERVER["REMOTE_ADDR"],$_REQUEST["time"])) == $logindata){
$_SESSION = $user;
$_SESSION["ACTIVE_IP"] = $IP;
sql("UPDATE USERS SET ACTIVE_IP='${IP}' WHERE LOGIN_SALT='${user["LOGIN_SALT"]}'",0);
$result = json_encode(array("TYPE"=>"FUNCTION","FUNCTION"=>"(\$login.success())"));
}
}
!$result ? $result = json_encode(array("TYPE"=>"FUNCTION","FUNCTION"=>"(\$login.failed())")) : void;
}
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
login: (function () {
$("#ajax_loading").fadeIn("fast");
$("[type=submit]").fadeOut("fast");
$tmp.time = "" + (new Date()).valueOf();
return …Run Code Online (Sandbox Code Playgroud)