4 if(!defined(
"__XE__")) exit();
12 if(!class_exists(
'AddonCaptcha',
false))
18 var $target_acts = NULL;
20 function setInfo(&$addon_info)
22 $this->addon_info = $addon_info;
25 function before_module_proc()
27 if($this->addon_info->act_type ==
'everytime' && $_SESSION[
'captcha_authed'])
29 unset($_SESSION[
'captcha_authed']);
33 function before_module_init(&$ModuleHandler)
40 if($this->addon_info->target !=
'all' &&
Context::get(
'is_logged'))
44 if($_SESSION[
'XE_VALIDATOR_ERROR'] == -1)
46 $_SESSION[
'captcha_authed'] =
false;
48 if($_SESSION[
'captcha_authed'])
55 $this->target_acts = array(
'procBoardInsertDocument',
'procBoardInsertComment',
'procIssuetrackerInsertIssue',
'procIssuetrackerInsertHistory',
'procTextyleInsertComment');
61 if(!$this->compareCaptcha())
64 $_SESSION[
'XE_VALIDATOR_ERROR'] = -1;
66 $_SESSION[
'XE_VALIDATOR_MESSAGE_TYPE'] =
'error';
67 $_SESSION[
'XE_VALIDATOR_RETURN_URL'] =
Context::get(
'error_return_url');
68 $ModuleHandler->_setInputValueToSession();
74 if(!captchaTargetAct) {var captchaTargetAct = [];}
75 captchaTargetAct.push("' . implode(
'","', $this->target_acts) .
'");
77 Context::loadFile(array(
'./addons/captcha/captcha.min.js',
'body',
'', null),
true);
82 if(!$_SESSION[
'captcha_authed'] && in_array(
Context::get(
'act'), $this->target_acts))
85 $ModuleHandler->error =
"captcha_denied";
91 function createKeyword()
94 if($type ==
'inline' && $_SESSION[
'captcha_keyword'])
99 $arr = range(
'A',
'Y');
101 $arr = array_slice($arr, 0, 6);
102 $_SESSION[
'captcha_keyword'] = join(
'', $arr);
105 function before_module_init_setCaptchaSession()
107 if($_SESSION[
'captcha_authed'])
114 $this->createKeyword();
117 header(
"Content-Type: text/xml; charset=UTF-8");
118 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
119 header(
"Last-Modified: " . gmdate(
"D, d M Y H:i:s") .
" GMT");
120 header(
"Cache-Control: no-store, no-cache, must-revalidate");
121 header(
"Cache-Control: post-check=0, pre-check=0",
false);
122 header(
"Pragma: no-cache");
123 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>"
134 function before_module_init_captchaImage()
136 if($_SESSION[
'captcha_authed'])
142 $this->createKeyword();
145 $keyword = $_SESSION[
'captcha_keyword'];
146 $im = $this->createCaptchaImage($keyword);
148 header(
"Cache-Control: ");
150 header(
"Content-Type: image/png");
159 function createCaptchaImage($string)
162 for($i = 0, $c = strlen($string); $i < $c; $i++)
164 $arr[] = $string{$i};
178 $im[] = imagecreate(($w + 2) * count($arr), $h);
180 $deg = range(-30, 30);
184 foreach($arr as $i => $str)
186 $im[$i + 1] = @imagecreate($w, $h);
187 $background_color = imagecolorallocate($im[$i + 1], 255, 255, 255);
188 $text_color = imagecolorallocate($im[$i + 1], 0, 0, 0);
194 if(function_exists(
'imagerotate'))
196 imagestring($im[$i + 1], (array_pop($ran) % 3) + 3, 2, (array_pop($ran) % 8), $str, $text_color);
197 $im[$i + 1] = imagerotate($im[$i + 1], array_pop($deg), 0);
199 $background_color = imagecolorallocate($im[$i + 1], 255, 255, 255);
200 imagecolortransparent($im[$i + 1], $background_color);
204 imagestring($im[$i + 1], (array_pop($ran) % 3) + 3, 2, (array_pop($ran) % 4), $str, $text_color);
209 for($i = 1, $c = count($im); $i<$c; $i++)
211 imagecopy($im[0], $im[$i], (($w + 2) * ($i - 1)), 0, 0, 0, $w, $h);
212 imagedestroy($im[$i]);
217 $big = imagecreatetruecolor(($w + 2) * $big_count * $c, $h * $big_count);
218 imagecopyresized($big, $im[0], 0, 0, 0, 0, ($w + 2) * $big_count * $c, $h * $big_count, ($w + 2) * $c, $h);
219 imagedestroy($im[0]);
221 if(function_exists(
'imageantialias'))
223 imageantialias($big,
true);
227 $line_color = imagecolorallocate($big, 0, 0, 0);
229 $w = ($w + 2) * $big_count * $c;
230 $h = $h * $big_count;
231 $d = array_pop($deg);
233 for($i = -abs($d); $i < $h + abs($d); $i = $i + 7)
235 imageline($big, 0, $i + $d, $w, $i, $line_color);
238 $x = range(0, ($w - 10));
241 for($i = 0; $i < 200; $i++)
243 imagesetpixel($big, $x[$i] % $w, $x[$i + 1] % $h, $line_color);
249 function before_module_init_captchaAudio()
251 if($_SESSION[
'captcha_authed'])
256 $keyword = strtoupper($_SESSION[
'captcha_keyword']);
257 $data = $this->createCaptchaAudio($keyword);
259 header(
'Content-type: audio/mpeg');
260 header(
"Content-Disposition: attachment; filename=\"captcha_audio.mp3\"");
261 header(
'Cache-Control: no-store, no-cache, must-revalidate');
262 header(
'Expires: Sun, 1 Jan 2000 12:00:00 GMT');
263 header(
'Last-Modified: ' . gmdate(
'D, d M Y H:i:s') .
'GMT');
264 header(
'Content-Length: ' . strlen($data));
271 function createCaptchaAudio($string)
274 $_audio =
'./addons/captcha/audio/F_%s.mp3';
275 for($i = 0, $c = strlen($string); $i < $c; $i++)
279 $start = rand(5, 68);
280 $datalen = strlen($_data) - $start - 256;
282 for($j = $start; $j < $datalen; $j+=64)
284 $ch = ord($_data{$j});
285 if($ch < 9 || $ch > 119)
289 $_data{$j} = chr($ch + rand(-8, 8));
298 function compareCaptcha()
300 if(!in_array(
Context::get(
'act'), $this->target_acts))
return true;
302 if($_SESSION[
'captcha_authed'])
307 if(strtoupper($_SESSION[
'captcha_keyword']) == strtoupper(
Context::get(
'secret_text')))
309 $_SESSION[
'captcha_authed'] =
true;
313 unset($_SESSION[
'captcha_authed']);
318 function before_module_init_captchaCompare()
320 if(!$this->compareCaptcha())
325 header(
"Content-Type: text/xml; charset=UTF-8");
326 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
327 header(
"Last-Modified: " . gmdate(
"D, d M Y H:i:s") .
" GMT");
328 header(
"Cache-Control: no-store, no-cache, must-revalidate");
329 header(
"Cache-Control: post-check=0, pre-check=0",
false);
330 header(
"Pragma: no-cache");
331 print(
"<response>\r\n<error>0</error>\r\n<message>success</message>\r\n</response>");
337 function inlineDisplay()
339 unset($_SESSION[
'captcha_authed']);
340 $this->createKeyword();
342 $swfURL =
getUrl() .
'addons/captcha/swf/play.swf';
349 <img src=
"%s" id=
"captcha_image" alt=
"CAPTCHA" width=
"240" height=
"50" style=
"width:240px; height:50px; border:1px solid #b0b0b0" />
350 <
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">
351 <param name=
"allowScriptAccess" value=
"always" />
352 <param name=
"quality" value=
"high" />
353 <param name=
"movie" value=
"%s" />
354 <param name=
"wmode" value=
"window" />
355 <param name=
"allowFullScreen" value=
"false">
356 <param name=
"bgcolor" value=
"#fffff" />
357 <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" />
359 <button type=
"button" class=
"captchaReload text">%s</button>
360 <button type=
"button" class=
"captchaPlay text">%s</button><br />
361 <input type=
"hidden" name=
"captchaType" value=
"inline" />
362 <input name=
"secret_text" type=
"text" id=
"secret_text" />
364 $tags = sprintf($tags,
getUrl(
'captcha_action',
'captchaImage',
'rand', mt_rand(10000, 99999))
373 $GLOBALS[
'__AddonCaptcha__'] =
new AddonCaptcha;
374 $GLOBALS[
'__AddonCaptcha__']->setInfo($addon_info);
382 if(!call_user_func_array(array(&
$oAddonCaptcha, $called_position), array(&$this)))
391 if(!call_user_func_array(array(&
$oAddonCaptcha, $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('AddonCaptcha', false)) $oAddonCaptcha
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang