0
我有一個非常簡單的驗證碼,這樣的事情:防止查詢驗證碼發生器從YSlow的
<?php
session_start();
function randomText($length) {
$pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
for($i=0;$i<$length;$i++) {
$key .= $pattern{rand(0,35)};
}
return $key;
}
$textCaptcha=randomText(8);
$_SESSION['tmptxt'] = $textCaptcha;
$captcha = imagecreatefromgif("bgcaptcha.gif");
$colText = imagecolorallocate($captcha, 0, 0, 0);
imagestring($captcha, 5, 16, 7, $textCaptcha, $colText);
header("Content-type: image/gif");
imagegif($captcha);
?>
的問題是,如果用戶已經安裝了YSlow的,圖像查詢2倍,因此,驗證碼被重新生成並且不會與用戶插入的相匹配。
我看到只是第二次查詢,如果我將內容類型標頭作爲gif傳遞,如果我將它打印爲普通的php,則不會發生。
有人對此有任何線索?我可以如何防止它或識別第二個查詢是由YSlow做出的,不要再次生成驗證碼。
Regards, 影子。