【发布时间】:2010-11-12 07:45:29
【问题描述】:
为什么下面的 PHP 代码会删除一些 CAPTCHA 图像并允许其他几个图像保留在服务器上?
伪代码
//process_form.php
PHP
session_start()
$radiobutton = '';
$captcha_set = false;
IF POST SUBMIT
IF empty text1 && empty text2
echo error msg, include HTML FORM
ELSE IF empty radiobtn
echo error msg, include HTML FORM
ELSE IF
isset POST[phrase] isstring POST[phrase] isset SESSION[phrase]
strlen POST[phrase] > 0 strlen SESSION[phrase] > 0
POST[phrase] == SESSION[phrase]
$captcha_set = true;
if ($captcha_set)
{
unset($_SESSION['phrase']);
unlink(sha1(session_id()) . '.png');
}
SQL INSERT
ELSE
echo error msg, include HTML FORM
ELSE
include HTML FORM
/PHP
HTML 表单
PHP
Require Once Text/Captcha.php
PEAR Capthca Options
/PHP
HTML
FORM
PHP
echo '<img src="' . sha1(session_id()) . '.png?' . time() . '" />';
/PHP
/FORM /HTML
【问题讨论】: