21 require_once dirname(dirname(dirname(__FILE__))).
'/include/init.inc';
33 function sendAccessibleCaptchaEmail($to_email_address, $key)
35 require_once
'Mail.php';
36 require_once
'Mail/mime.php';
39 $to_email_address = trim($to_email_address);
42 $from_address =
'"Accessible CAPTCHA Form"';
43 if (SQ_CONF_SYSTEM_NAME !=
'') {
44 $from_system_name =
'from the '.SQ_CONF_SYSTEM_NAME.
' website ';
45 $from_address = SQ_CONF_SYSTEM_NAME;
49 $from_address =
'"'.$from_address.
'"';
51 $current_url = current_url();
52 $body =
'This email has been generated '.$from_system_name.
"as part of a form submission which includes an Accessible CAPTCHA field.\n\n".
53 "Please visit the following page to validate your submission before submitting the form\n\n".
54 $current_url.
'?key='.$key;
56 $mime =
new Mail_mime(
"\n");
57 $mime->setTXTBody($body);
59 $from_address .=
' <'.SQ_CONF_DEFAULT_EMAIL.
'>';
62 'From' => $from_address,
63 'Subject' =>
'Accessible CAPTCHA Form Verification',
67 'head_charset' => SQ_CONF_DEFAULT_CHARACTER_SET,
68 'text_charset' => SQ_CONF_DEFAULT_CHARACTER_SET,
69 'html_charset' => SQ_CONF_DEFAULT_CHARACTER_SET,
71 $body = @$mime->get($param);
72 $headers = @$mime->headers($headers);
73 $mail =& Mail::factory(
'mail');
74 $status = @$mail->send($to_email_address, $headers, $body);
88 function validateAccessibleCaptcha($key)
90 $verified_captcha = FALSE;
92 if ((isset($_SESSION[
'SQ_ACCESSIBLE_CAPTCHA_KEY'])) && ($_SESSION[
'SQ_ACCESSIBLE_CAPTCHA_KEY'] === $key)) {
94 $verified_captcha = TRUE;
95 $_SESSION[
'SQ_ACCESSIBLE_CAPTCHA_PASSED'] = 1;
98 unset($_SESSION[
'SQ_ACCESSIBLE_CAPTCHA_KEY']);
99 unset($_SESSION[
'SQ_ACCESSIBLE_CAPTCHA_GENERATED']);
102 if ($verified_captcha) {
104 <p>Thank you
for verifying the Accessible CAPTCHA input.<br />
105 Please proceed to submit your form.</p>
109 <p>This Accessible CAPTCHA key has expired
for this session.<br />
110 Please
return to the form to generate a
new key.</p>
127 if (!isset($_SESSION[
'SQ_ACCESSIBLE_CAPTCHA_GENERATED'])) exit;
130 if (isset($_GET[
'email'])) {
132 $user_email = addslashes($_GET[
'email']);
135 if ((strpos($user_email,
',') === FALSE) || (strpos($user_email,
';') === FALSE)) {
138 $local_megadice = rand(1, 1000000);
140 $submission_time = time();
141 $key = md5($user_email.$submission_time.$local_megadice);
144 $_SESSION[
'SQ_ACCESSIBLE_CAPTCHA_KEY'] = $key;
145 sendAccessibleCaptchaEmail($user_email, $key);
148 }
else if (isset($_GET[
'key'])) {
151 $key = addslashes($_GET[
'key']);
152 validateAccessibleCaptcha($key);