public function draw_image($y_form) { //-- $y_form = trim((string) $y_form); //-- //-- $out = ''; //-- ob_start(); //-- if ((string) $this->mode == 'hashed') { $captcha_arr = (array) $this->generate_captcha_hashed(); } else { // 'dotted' $captcha_arr = (array) $this->generate_captcha_dotted(); } //end if else //-- $captcha_image = $captcha_arr['rawimage']; $captcha_word = $captcha_arr['word']; $captcha_arr = array(); //-- $err = ob_get_contents(); ob_end_clean(); //-- if ((string) $err != '') { // trigger errors Smart::log_warning('#Captcha / Draw Image [' . $intext . '] Errors/Output: ' . $err); } //end if //-- ob_start(); //- switch (@strtolower($this->format)) { case "png": //header: "Content-type: image/png" imagepng($captcha_image); break; case "gif": //header: "Content-type: image/gif" imagegif($captcha_image); break; case "jpg": case "jpeg": default: //header: "Content-type: image/jpeg" imagejpeg($captcha_image, '', $this->quality); } //end switch //- $out = ob_get_contents(); //- ob_end_clean(); //- @imagedestroy($captcha_image); // free resources //-- //-- @setcookie(SmartCaptchaFormCheck::chkcookiename($y_form), sha1($y_form . SMART_FRAMEWORK_SECURITY_KEY), 0, '/'); //-- if (SmartCaptchaFormCheck::validate_form_name($y_form) === 1) { if ((string) $this->store == 'session') { SmartSession::set(SmartCaptchaFormCheck::cookiename($y_form), SmartCaptchaFormCheck::checksum($captcha_word)); } else { @setcookie(SmartCaptchaFormCheck::cookiename($y_form), SmartCaptchaFormCheck::checksum($captcha_word), 0, '/'); } //end if else } //end if //-- //-- return $out; //-- }
public static function post__answer__by__ajax($tab, $frm) { //-- global $configs; //-- //-- $tmp_data = '<br><br><hr><pre>' . 'GET:' . '<br>' . Smart::escape_html(print_r(SmartFrameworkSecurity::FilterGetPostCookieVars($_GET), 1)) . '<hr>' . 'POST:' . '<br>' . Smart::escape_html(print_r(SmartFrameworkSecurity::FilterGetPostCookieVars($_POST), 1)) . '</pre>'; //-- //-- if (SmartCaptchaFormCheck::verify(self::captcha_form_name(), self::captcha_mode(), false) == 1) { // verify but do not clear yet $captcha_ok = true; } else { $captcha_ok = false; } //end if else //-- //-- if (strlen($frm['date']) > 0) { //-- if ($captcha_ok !== true) { //-- $code = 'ERROR'; $title = 'CAPTCHA verification FAILED ...'; $desc = 'Please enter a valid captcha value:' . $tmp_data; $redir = ''; $div_id = ''; $div_htm = ''; //-- } else { //-- $code = 'OK'; $title = 'Captcha validation OK ... The page or just the Captcha will be refreshed depending if TextArea is filled or not ...'; $desc = 'Form sent successful:' . $tmp_data; //-- if (strlen($frm['text_area_1']) <= 0) { $redir = SMART_FRAMEWORK_TESTUNIT_BASE_URL . 'testunit.main&time=' . time() . '&tab=' . rawurlencode($tab); $div_id = ''; $div_htm = ''; } else { $redir = ''; $div_id = 'answer_ajax'; $div_htm = '<script>$("#smart__CaptchaFrm__img").attr("src", "' . Smart::escape_js(SMART_FRAMEWORK_TESTUNIT_BASE_URL . 'testunit.captcha&time=' . time()) . '");</script><table border="0" bgcolor="#DDEEFF" width="100%"><tr><td><h1>OK, form sent on: ' . date('Y-m-d H:i:s') . '</h1></td></tr><tr><td><div align="center"><img src="lib/core/img/q_completed.png"></div></td></tr><tr><td><hr><b>Here is the content of the text area:</b><br><pre>' . Smart::escape_html($frm['text_area_1']) . '</pre></td></tr></table>'; } //end if else //-- SmartCaptchaFormCheck::clear(self::captcha_form_name(), self::captcha_mode()); // everything OK, so clear captcha //-- } //end if else //-- } else { //-- $code = 'ERROR'; $title = 'CAPTCHA NOT Checked yet ...'; $desc = 'Please fill the Date field ...' . $tmp_data; //-- if (strlen($frm['text_area_1']) > 0) { $redir = SMART_FRAMEWORK_TESTUNIT_BASE_URL . 'testunit.main&time=' . time() . '&tab=' . rawurlencode($tab); } else { $redir = ''; } //end if else //-- $div_id = ''; $div_htm = ''; //-- } //end if else //-- //-- $out = SmartComponents::post_answer_by_ajax($code, $title, $desc, $redir, $div_id, $div_htm); //-- //-- return $out; //-- }