4 if(!defined(
"__XE__")) exit();
12 if(!class_exists(
'AddonMemberCaptcha',
false))
14 class AddonMemberCaptcha
17 var $target_acts = NULL;
19 function setInfo(&$addon_info)
21 $this->addon_info = $addon_info;
24 function before_module_proc()
28 unset($_SESSION[
'member_captcha_authed']);
32 function before_module_init(&$ModuleHandler)
43 if($_SESSION[
'XE_VALIDATOR_ERROR'] == -1)
45 $_SESSION[
'member_captcha_authed'] =
false;
47 if($_SESSION[
'member_captcha_authed'])
54 $this->target_acts = array();
55 if($this->addon_info->apply_find_account ==
'apply')
57 $this->target_acts[] =
'procMemberFindAccount';
59 if($this->addon_info->apply_resend_auth_mail ==
'apply')
61 $this->target_acts[] =
'procMemberResendAuthMail';
63 if($this->addon_info->apply_signup ==
'apply')
65 $this->target_acts[] =
'procMemberInsert';
72 if(!$this->compareCaptcha())
75 $_SESSION[
'XE_VALIDATOR_ERROR'] = -1;
77 $_SESSION[
'XE_VALIDATOR_MESSAGE_TYPE'] =
'error';
78 $_SESSION[
'XE_VALIDATOR_RETURN_URL'] =
Context::get(
'error_return_url');
79 $ModuleHandler->_setInputValueToSession();
85 if(!captchaTargetAct) {var captchaTargetAct = [];}
86 captchaTargetAct.push("' . implode(
'","', $this->target_acts) .
'");
88 Context::loadFile(array(
'./addons/captcha/captcha.min.js',
'body',
'', null),
true);
93 if(!$_SESSION[
'member_captcha_authed'] && in_array(
Context::get(
'act'), $this->target_acts))
96 $ModuleHandler->error =
"captcha_denied";
102 function createKeyword()
105 if($type ==
'inline' && $_SESSION[
'captcha_keyword'])
110 $arr = range(
'A',
'Y');
112 $arr = array_slice($arr, 0, 6);
113 $_SESSION[
'captcha_keyword'] = join(
'', $arr);
116 function before_module_init_setCaptchaSession()
118 if($_SESSION[
'member_captcha_authed'])
125 $this->createKeyword();
128 header(
"Content-Type: text/xml; charset=UTF-8");
129 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
130 header(
"Last-Modified: " . gmdate(
"D, d M Y H:i:s") .
" GMT");
131 header(
"Cache-Control: no-store, no-cache, must-revalidate");
132 header(
"Cache-Control: post-check=0, pre-check=0",
false);
133 header(
"Pragma: no-cache");
134 printf(
"<response>\r\n <error>0</error>\r\n <message>success</message>\r\n <about_captcha><![CDATA[%s]]></about_captcha>\r\n <captcha_reload><![CDATA[%s]]></captcha_reload>\r\n <captcha_play><![CDATA[%s]]></captcha_play>\r\n <cmd_input><![CDATA[%s]]></cmd_input>\r\n <cmd_cancel><![CDATA[%s]]></cmd_cancel>\r\n </response>"
145 function before_module_init_captchaImage()
147 if($_SESSION[
'member_captcha_authed'])
153 $this->createKeyword();
156 $keyword = $_SESSION[
'captcha_keyword'];
157 $im = $this->createCaptchaImage($keyword);
159 header(
"Cache-Control: ");
161 header(
"Content-Type: image/png");
170 function createCaptchaImage($string)
173 for($i = 0, $c = strlen($string); $i < $c; $i++)
175 $arr[] = $string{$i};
189 $im[] = imagecreate(($w + 2) * count($arr), $h);
191 $deg = range(-30, 30);
195 foreach($arr as $i => $str)
197 $im[$i + 1] = @imagecreate($w, $h);
198 $background_color = imagecolorallocate($im[$i + 1], 255, 255, 255);
199 $text_color = imagecolorallocate($im[$i + 1], 0, 0, 0);
205 if(function_exists(
'imagerotate'))
207 imagestring($im[$i + 1], (array_pop($ran) % 3) + 3, 2, (array_pop($ran) % 8), $str, $text_color);
208 $im[$i + 1] = imagerotate($im[$i + 1], array_pop($deg), 0);
210 $background_color = imagecolorallocate($im[$i + 1], 255, 255, 255);
211 imagecolortransparent($im[$i + 1], $background_color);
215 imagestring($im[$i + 1], (array_pop($ran) % 3) + 3, 2, (array_pop($ran) % 4), $str, $text_color);
220 for($i = 1; $i < count($im); $i++)
222 imagecopy($im[0], $im[$i], (($w + 2) * ($i - 1)), 0, 0, 0, $w, $h);
223 imagedestroy($im[$i]);
228 $big = imagecreatetruecolor(($w + 2) * $big_count * $c, $h * $big_count);
229 imagecopyresized($big, $im[0], 0, 0, 0, 0, ($w + 2) * $big_count * $c, $h * $big_count, ($w + 2) * $c, $h);
230 imagedestroy($im[0]);
232 if(function_exists(
'imageantialias'))
234 imageantialias($big,
true);
238 $line_color = imagecolorallocate($big, 0, 0, 0);
240 $w = ($w + 2) * $big_count * $c;
241 $h = $h * $big_count;
242 $d = array_pop($deg);
244 for($i = -abs($d); $i < $h + abs($d); $i = $i + 7)
246 imageline($big, 0, $i + $d, $w, $i, $line_color);
249 $x = range(0, ($w - 10));
252 for($i = 0; $i < 200; $i++)
254 imagesetpixel($big, $x[$i] % $w, $x[$i + 1] % $h, $line_color);
260 function before_module_init_captchaAudio()
262 if($_SESSION[
'member_captcha_authed'])
267 $keyword = strtoupper($_SESSION[
'captcha_keyword']);
268 $data = $this->createCaptchaAudio($keyword);
270 header(
'Content-type: audio/mpeg');
271 header(
"Content-Disposition: attachment; filename=\"captcha_audio.mp3\"");
272 header(
'Cache-Control: no-store, no-cache, must-revalidate');
273 header(
'Expires: Sun, 1 Jan 2000 12:00:00 GMT');
274 header(
'Last-Modified: ' . gmdate(
'D, d M Y H:i:s') .
'GMT');
275 header(
'Content-Length: ' . strlen($data));
282 function createCaptchaAudio($string)
285 $_audio =
'./addons/captcha/audio/F_%s.mp3';
286 for($i = 0, $c = strlen($string); $i < $c; $i++)
290 $start = rand(5, 68);
291 $datalen = strlen($_data) - $start - 256;
293 for($j = $start; $j < $datalen; $j+=64)
295 $ch = ord($_data{$j});
296 if($ch < 9 || $ch > 119)
300 $_data{$j} = chr($ch + rand(-8, 8));
309 function compareCaptcha()
311 if(!in_array(
Context::get(
'act'), $this->target_acts))
return true;
313 if($_SESSION[
'member_captcha_authed'])
318 if(strtoupper($_SESSION[
'captcha_keyword']) == strtoupper(
Context::get(
'secret_text')))
320 $_SESSION[
'member_captcha_authed'] =
true;
324 unset($_SESSION[
'member_captcha_authed']);
329 function before_module_init_captchaCompare()
331 if(!$this->compareCaptcha())
336 header(
"Content-Type: text/xml; charset=UTF-8");
337 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
338 header(
"Last-Modified: " . gmdate(
"D, d M Y H:i:s") .
" GMT");
339 header(
"Cache-Control: no-store, no-cache, must-revalidate");
340 header(
"Cache-Control: post-check=0, pre-check=0",
false);
341 header(
"Pragma: no-cache");
342 print(
"<response>\r\n<error>0</error>\r\n<message>success</message>\r\n</response>");
348 function inlineDisplay()
350 unset($_SESSION[
'member_captcha_authed']);
351 $this->createKeyword();
353 $swfURL =
getUrl() .
'addons/captcha/swf/play.swf';
360 <img src=
"%s" id=
"captcha_image" alt=
"CAPTCHA" width=
"240" height=
"50" style=
"width:240px; height:50px; border:1px solid #b0b0b0" />
361 <
object classid=
"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=
"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width=
"0" height=
"0" id=
"captcha_audio" align=
"middle">
362 <param name=
"allowScriptAccess" value=
"always" />
363 <param name=
"quality" value=
"high" />
364 <param name=
"movie" value=
"%s" />
365 <param name=
"wmode" value=
"window" />
366 <param name=
"allowFullScreen" value=
"false">
367 <param name=
"bgcolor" value=
"#fffff" />
368 <embed src=
"%s" quality=
"high" wmode=
"window" allowFullScreen=
"false" bgcolor=
"#ffffff" width=
"0" height=
"0" name=
"captcha_audio" align=
"middle" allowScriptAccess=
"always" type=
"application/x-shockwave-flash" pluginspage=
"http://www.macromedia.com/go/getflashplayer" />
370 <button type=
"button" class=
"captchaReload text">%s</button>
371 <button type=
"button" class=
"captchaPlay text">%s</button><br />
372 <input type=
"hidden" name=
"captchaType" value=
"inline" />
373 <input name=
"secret_text" type=
"text" id=
"secret_text" />
375 $tags = sprintf($tags,
getUrl(
'captcha_action',
'captchaImage',
'rand', mt_rand(10000, 99999))
384 $GLOBALS[
'__AddonMemberCaptcha__'] =
new AddonMemberCaptcha;
385 $GLOBALS[
'__AddonMemberCaptcha__']->setInfo($addon_info);
402 if(!call_user_func_array(array(&
$oAddonMemberCaptcha, $called_position .
'_' . $addon_act), array(&$this)))
unloadFile($file, $targetIe= '', $media= 'all')
if(file_exists(_XE_PATH_. 'config/config.user.inc.php')) if(!defined('__DEBUG__')) if(!defined('__DEBUG_OUTPUT__')) if(!defined('__DEBUG_PROTECT__')) if(!defined('__DEBUG_PROTECT_IP__')) if(!defined('__DEBUG_DB_OUTPUT__')) if(!defined('__LOG_SLOW_QUERY__')) if(!defined('__LOG_SLOW_TRIGGER__')) if(!defined('__LOG_SLOW_ADDON__')) if(!defined('__LOG_SLOW_WIDGET__')) if(!defined('__DEBUG_QUERY__')) if(!defined('__OB_GZHANDLER_ENABLE__')) if(!defined('__ENABLE_PHPUNIT_TEST__')) if(!defined('__PROXY_SERVER__')) if(!defined('__ERROR_LOG__')) if(!defined('__DISABLE_DEFAULT_CSS__')) if(!defined('__AUTO_OPCACHE_INVALIDATE__')) if((__DEBUG_OUTPUT__==2)&&version_compare(PHP_VERSION, '6.0.0')===-1) if(version_compare(PHP_VERSION, '5.3.0') >=0) $GLOBALS['__xe_autoload_file_map']
set($key, $val, $set_to_get_vars=0)
if(method_exists($oAddonCaptcha, $called_position)) $addon_act
if(!class_exists('AddonMemberCaptcha', false)) $oAddonMemberCaptcha
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang