'InputCaptcha', ':html' => "", ':args' => array('value', 'placeholder', 'required'), 'size' => 5, 'autocomplete' => 'off', 'name' => $CaptchaName, 'class' => 'inputbox' )); SDVA($InputTags['captcha1'], $InputTags['captcha']); $InputTags['captcha1'][':fn'] = 'InputCaptcha1'; array_unshift($EditFunctions, 'RequireCaptcha'); SDV($HandleActions['captchaimage'], 'HandleCaptchaImage'); SDV($HandleAuth['captchaimage'], 'read'); if (!function_exists('pm_session_start')) { function pm_session_start() { return @session_start(); } } function RequireCaptcha($pagename, $page, $new) { global $EnablePostCaptchaRequired, $MessagesFmt, $CaptchaRequiredFmt, $EnablePost; if (!IsEnabled($EnablePostCaptchaRequired, 0)) return; if (IsCaptcha()) return; SDV($CaptchaRequiredFmt, "
"); $MessagesFmt[] = $CaptchaRequiredFmt; $EnablePost = 0; } function IsCaptcha() { global $CaptchaPmToken, $IsCaptcha, $CaptchaName, $EnableCaptchaSession; if (isset($IsCaptcha)) return $IsCaptcha; if ($CaptchaPmToken && !pmtoken(1)) return 0; $key = @$_POST['captchakey']; $resp = @$_POST[$CaptchaName]; $sid = session_id(); pm_session_start(); if (!is_null($key) && $resp && isset($_SESSION['captcha-challenges'][$key])) { # response posted if ($_SESSION['captcha-challenges'][$key] == $resp) $IsCaptcha = 1; else # prevent replay unset($_SESSION['captcha-challenges'][$key]); } if (IsEnabled($EnableCaptchaSession, 0)) { $IsCaptcha |= @$_SESSION['iscaptcha']; $_SESSION['iscaptcha'] = $IsCaptcha; } $IsCaptcha = (int)@$IsCaptcha; if (!$sid) session_write_close(); return $IsCaptcha; } function InputCaptcha($pagename, $type, $args) { CaptchaValue(); return Keep(InputToHTML($pagename, $type, $args, $opt)); } function InputCaptcha1($pagename, $type, $args) { if (@$_SESSION['iscaptcha']) return ''; CaptchaValue(); $chall = CaptchaFn($pagename); return Keep($chall.InputToHTML($pagename, $type, $args, $opt)); } function CaptchaValue() { global $CaptchaKey, $CaptchaValue; if ($CaptchaKey > '' && @$_SESSION['captcha-challenges'][$CaptchaKey] == $CaptchaValue) return $CaptchaValue; $sid = session_id(); pm_session_start(); if ($CaptchaKey == '') { if (isset($_SESSION['captcha-challenges'])) $CaptchaKey = max(array_keys($_SESSION['captcha-challenges']))+1; else $CaptchaKey = 0; } $_SESSION['captcha-challenges'][$CaptchaKey] = $CaptchaValue; if (!$sid) session_write_close(); return $CaptchaValue; } function CaptchaFn($pagename) { global $CaptchaChallenge, $EnableCaptchaImage; if (@$CaptchaChallenge) return $CaptchaChallenge; if ($EnableCaptchaImage) return CaptchaImage($pagename); return CaptchaValue(); } function CaptchaImage($pagename) { global $CaptchaImageFmt, $CaptchaImageEmbedFmt, $CaptchaImageCSS, $EnableCaptchaImageDataURI; NoCache(); $value = CaptchaValue(); SDV($CaptchaImageCSS, "border: none; vertical-align:top;"); SDV($CaptchaImageFmt, "