@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
| 3 | 3 | |
| 4 | -if(!defined("__XE__")) exit(); |
|
| 4 | +if (!defined("__XE__")) exit(); |
|
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * @file captcha.addon.php |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @brief Captcha for a particular action |
| 10 | 10 | * English alphabets and voice verification added |
| 11 | 11 | * */ |
| 12 | -if(!class_exists('AddonMemberCaptcha', false)) |
|
| 12 | +if (!class_exists('AddonMemberCaptcha', false)) |
|
| 13 | 13 | { |
| 14 | 14 | class AddonMemberCaptcha |
| 15 | 15 | { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | function before_module_init(&$ModuleHandler) |
| 33 | 33 | { |
| 34 | 34 | $logged_info = Context::get('logged_info'); |
| 35 | - if($logged_info->is_admin == 'Y' || $logged_info->is_site_admin) |
|
| 35 | + if ($logged_info->is_admin == 'Y' || $logged_info->is_site_admin) |
|
| 36 | 36 | { |
| 37 | 37 | return false; |
| 38 | 38 | } |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | // { |
| 41 | 41 | // return false; |
| 42 | 42 | // } |
| 43 | - if($_SESSION['XE_VALIDATOR_ERROR'] == -1) |
|
| 43 | + if ($_SESSION['XE_VALIDATOR_ERROR'] == -1) |
|
| 44 | 44 | { |
| 45 | 45 | $_SESSION['member_captcha_authed'] = false; |
| 46 | 46 | } |
| 47 | - if($_SESSION['member_captcha_authed']) |
|
| 47 | + if ($_SESSION['member_captcha_authed']) |
|
| 48 | 48 | { |
| 49 | 49 | return false; |
| 50 | 50 | } |
@@ -52,26 +52,26 @@ discard block |
||
| 52 | 52 | $type = Context::get('captchaType'); |
| 53 | 53 | |
| 54 | 54 | $this->target_acts = array(); |
| 55 | - if($this->addon_info->apply_find_account == 'apply') |
|
| 55 | + if ($this->addon_info->apply_find_account == 'apply') |
|
| 56 | 56 | { |
| 57 | 57 | $this->target_acts[] = 'procMemberFindAccount'; |
| 58 | 58 | } |
| 59 | - if($this->addon_info->apply_resend_auth_mail == 'apply') |
|
| 59 | + if ($this->addon_info->apply_resend_auth_mail == 'apply') |
|
| 60 | 60 | { |
| 61 | 61 | $this->target_acts[] = 'procMemberResendAuthMail'; |
| 62 | 62 | } |
| 63 | - if($this->addon_info->apply_signup == 'apply') |
|
| 63 | + if ($this->addon_info->apply_signup == 'apply') |
|
| 64 | 64 | { |
| 65 | 65 | $this->target_acts[] = 'procMemberInsert'; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if(Context::getRequestMethod() != 'XMLRPC' && Context::getRequestMethod() !== 'JSON') |
|
| 68 | + if (Context::getRequestMethod() != 'XMLRPC' && Context::getRequestMethod() !== 'JSON') |
|
| 69 | 69 | { |
| 70 | - if($type == 'inline') |
|
| 70 | + if ($type == 'inline') |
|
| 71 | 71 | { |
| 72 | - if(!$this->compareCaptcha()) |
|
| 72 | + if (!$this->compareCaptcha()) |
|
| 73 | 73 | { |
| 74 | - Context::loadLang(_XE_PATH_ . 'addons/captcha_member/lang'); |
|
| 74 | + Context::loadLang(_XE_PATH_.'addons/captcha_member/lang'); |
|
| 75 | 75 | $_SESSION['XE_VALIDATOR_ERROR'] = -1; |
| 76 | 76 | $_SESSION['XE_VALIDATOR_MESSAGE'] = Context::getLang('captcha_denied'); |
| 77 | 77 | $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = 'error'; |
@@ -83,16 +83,16 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | Context::addHtmlHeader('<script> |
| 85 | 85 | if(!captchaTargetAct) {var captchaTargetAct = [];} |
| 86 | - captchaTargetAct.push("' . implode('","', $this->target_acts) . '"); |
|
| 86 | + captchaTargetAct.push("' . implode('","', $this->target_acts).'"); |
|
| 87 | 87 | </script>'); |
| 88 | 88 | Context::loadFile(array('./addons/captcha/captcha.min.js', 'body', '', null), true); |
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // compare session when calling actions such as writing a post or a comment on the board/issue tracker module |
| 93 | - if(!$_SESSION['member_captcha_authed'] && in_array(Context::get('act'), $this->target_acts)) |
|
| 93 | + if (!$_SESSION['member_captcha_authed'] && in_array(Context::get('act'), $this->target_acts)) |
|
| 94 | 94 | { |
| 95 | - Context::loadLang(_XE_PATH_ . 'addons/captcha_member/lang'); |
|
| 95 | + Context::loadLang(_XE_PATH_.'addons/captcha_member/lang'); |
|
| 96 | 96 | $ModuleHandler->error = "captcha_denied"; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | function createKeyword() |
| 103 | 103 | { |
| 104 | 104 | $type = Context::get('captchaType'); |
| 105 | - if($type == 'inline' && $_SESSION['captcha_keyword']) |
|
| 105 | + if ($type == 'inline' && $_SESSION['captcha_keyword']) |
|
| 106 | 106 | { |
| 107 | 107 | return; |
| 108 | 108 | } |
@@ -115,19 +115,19 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | function before_module_init_setCaptchaSession() |
| 117 | 117 | { |
| 118 | - if($_SESSION['member_captcha_authed']) |
|
| 118 | + if ($_SESSION['member_captcha_authed']) |
|
| 119 | 119 | { |
| 120 | 120 | return false; |
| 121 | 121 | } |
| 122 | 122 | // Load language files |
| 123 | - Context::loadLang(_XE_PATH_ . 'addons/captcha_member/lang'); |
|
| 123 | + Context::loadLang(_XE_PATH_.'addons/captcha_member/lang'); |
|
| 124 | 124 | // Generate keywords |
| 125 | 125 | $this->createKeyword(); |
| 126 | 126 | |
| 127 | 127 | $target = Context::getLang('target_captcha'); |
| 128 | 128 | header("Content-Type: text/xml; charset=UTF-8"); |
| 129 | 129 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
| 130 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
| 130 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
| 131 | 131 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
| 132 | 132 | header("Cache-Control: post-check=0, pre-check=0", false); |
| 133 | 133 | header("Pragma: no-cache"); |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | function before_module_init_captchaImage() |
| 146 | 146 | { |
| 147 | - if($_SESSION['member_captcha_authed']) |
|
| 147 | + if ($_SESSION['member_captcha_authed']) |
|
| 148 | 148 | { |
| 149 | 149 | return false; |
| 150 | 150 | } |
| 151 | - if(Context::get('renew')) |
|
| 151 | + if (Context::get('renew')) |
|
| 152 | 152 | { |
| 153 | 153 | $this->createKeyword(); |
| 154 | 154 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | function createCaptchaImage($string) |
| 171 | 171 | { |
| 172 | 172 | $arr = array(); |
| 173 | - for($i = 0, $c = strlen($string); $i < $c; $i++) |
|
| 173 | + for ($i = 0, $c = strlen($string); $i < $c; $i++) |
|
| 174 | 174 | { |
| 175 | 175 | $arr[] = $string{$i}; |
| 176 | 176 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | shuffle($deg); |
| 193 | 193 | |
| 194 | 194 | // Create an image for each letter |
| 195 | - foreach($arr as $i => $str) |
|
| 195 | + foreach ($arr as $i => $str) |
|
| 196 | 196 | { |
| 197 | 197 | $im[$i + 1] = @imagecreate($w, $h); |
| 198 | 198 | $background_color = imagecolorallocate($im[$i + 1], 255, 255, 255); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $ran = range(1, 20); |
| 203 | 203 | shuffle($ran); |
| 204 | 204 | |
| 205 | - if(function_exists('imagerotate')) |
|
| 205 | + if (function_exists('imagerotate')) |
|
| 206 | 206 | { |
| 207 | 207 | imagestring($im[$i + 1], (array_pop($ran) % 3) + 3, 2, (array_pop($ran) % 8), $str, $text_color); |
| 208 | 208 | $im[$i + 1] = imagerotate($im[$i + 1], array_pop($deg), 0); |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // Combine images of each character |
| 220 | - for($i = 1; $i < count($im); $i++) |
|
| 220 | + for ($i = 1; $i < count($im); $i++) |
|
| 221 | 221 | { |
| 222 | 222 | imagecopy($im[0], $im[$i], (($w + 2) * ($i - 1)), 0, 0, 0, $w, $h); |
| 223 | 223 | imagedestroy($im[$i]); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | imagecopyresized($big, $im[0], 0, 0, 0, 0, ($w + 2) * $big_count * $c, $h * $big_count, ($w + 2) * $c, $h); |
| 230 | 230 | imagedestroy($im[0]); |
| 231 | 231 | |
| 232 | - if(function_exists('imageantialias')) |
|
| 232 | + if (function_exists('imageantialias')) |
|
| 233 | 233 | { |
| 234 | 234 | imageantialias($big, true); |
| 235 | 235 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $h = $h * $big_count; |
| 242 | 242 | $d = array_pop($deg); |
| 243 | 243 | |
| 244 | - for($i = -abs($d); $i < $h + abs($d); $i = $i + 7) |
|
| 244 | + for ($i = -abs($d); $i < $h + abs($d); $i = $i + 7) |
|
| 245 | 245 | { |
| 246 | 246 | imageline($big, 0, $i + $d, $w, $i, $line_color); |
| 247 | 247 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $x = range(0, ($w - 10)); |
| 250 | 250 | shuffle($x); |
| 251 | 251 | |
| 252 | - for($i = 0; $i < 200; $i++) |
|
| 252 | + for ($i = 0; $i < 200; $i++) |
|
| 253 | 253 | { |
| 254 | 254 | imagesetpixel($big, $x[$i] % $w, $x[$i + 1] % $h, $line_color); |
| 255 | 255 | } |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | function before_module_init_captchaAudio() |
| 261 | 261 | { |
| 262 | - if($_SESSION['member_captcha_authed']) |
|
| 262 | + if ($_SESSION['member_captcha_authed']) |
|
| 263 | 263 | { |
| 264 | 264 | return false; |
| 265 | 265 | } |
@@ -271,8 +271,8 @@ discard block |
||
| 271 | 271 | header("Content-Disposition: attachment; filename=\"captcha_audio.mp3\""); |
| 272 | 272 | header('Cache-Control: no-store, no-cache, must-revalidate'); |
| 273 | 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)); |
|
| 274 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').'GMT'); |
|
| 275 | + header('Content-Length: '.strlen($data)); |
|
| 276 | 276 | |
| 277 | 277 | echo $data; |
| 278 | 278 | Context::close(); |
@@ -283,17 +283,17 @@ discard block |
||
| 283 | 283 | { |
| 284 | 284 | $data = ''; |
| 285 | 285 | $_audio = './addons/captcha/audio/F_%s.mp3'; |
| 286 | - for($i = 0, $c = strlen($string); $i < $c; $i++) |
|
| 286 | + for ($i = 0, $c = strlen($string); $i < $c; $i++) |
|
| 287 | 287 | { |
| 288 | 288 | $_data = FileHandler::readFile(sprintf($_audio, $string{$i})); |
| 289 | 289 | |
| 290 | 290 | $start = rand(5, 68); // Random start in 4-byte header and 64 byte data |
| 291 | 291 | $datalen = strlen($_data) - $start - 256; // Last unchanged 256 bytes |
| 292 | 292 | |
| 293 | - for($j = $start; $j < $datalen; $j+=64) |
|
| 293 | + for ($j = $start; $j < $datalen; $j += 64) |
|
| 294 | 294 | { |
| 295 | 295 | $ch = ord($_data{$j}); |
| 296 | - if($ch < 9 || $ch > 119) |
|
| 296 | + if ($ch < 9 || $ch > 119) |
|
| 297 | 297 | { |
| 298 | 298 | continue; |
| 299 | 299 | } |
@@ -308,14 +308,14 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | function compareCaptcha() |
| 310 | 310 | { |
| 311 | - if(!in_array(Context::get('act'), $this->target_acts)) return true; |
|
| 311 | + if (!in_array(Context::get('act'), $this->target_acts)) return true; |
|
| 312 | 312 | |
| 313 | - if($_SESSION['member_captcha_authed']) |
|
| 313 | + if ($_SESSION['member_captcha_authed']) |
|
| 314 | 314 | { |
| 315 | 315 | return true; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if(strtoupper($_SESSION['captcha_keyword']) == strtoupper(Context::get('secret_text'))) |
|
| 318 | + if (strtoupper($_SESSION['captcha_keyword']) == strtoupper(Context::get('secret_text'))) |
|
| 319 | 319 | { |
| 320 | 320 | $_SESSION['member_captcha_authed'] = true; |
| 321 | 321 | return true; |
@@ -328,14 +328,14 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | function before_module_init_captchaCompare() |
| 330 | 330 | { |
| 331 | - if(!$this->compareCaptcha()) |
|
| 331 | + if (!$this->compareCaptcha()) |
|
| 332 | 332 | { |
| 333 | 333 | return false; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | header("Content-Type: text/xml; charset=UTF-8"); |
| 337 | 337 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
| 338 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
| 338 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
| 339 | 339 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
| 340 | 340 | header("Cache-Control: post-check=0, pre-check=0", false); |
| 341 | 341 | header("Pragma: no-cache"); |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | unset($_SESSION['member_captcha_authed']); |
| 351 | 351 | $this->createKeyword(); |
| 352 | 352 | |
| 353 | - $swfURL = getUrl() . 'addons/captcha/swf/play.swf'; |
|
| 353 | + $swfURL = getUrl().'addons/captcha/swf/play.swf'; |
|
| 354 | 354 | Context::unloadFile('./addons/captcha/captcha.min.js'); |
| 355 | 355 | Context::loadFile(array('./addons/captcha/inline_captcha.js', 'body')); |
| 356 | 356 | |
@@ -388,18 +388,18 @@ discard block |
||
| 388 | 388 | |
| 389 | 389 | $oAddonMemberCaptcha = &$GLOBALS['__AddonMemberCaptcha__']; |
| 390 | 390 | |
| 391 | -if(method_exists($oAddonMemberCaptcha, $called_position)) |
|
| 391 | +if (method_exists($oAddonMemberCaptcha, $called_position)) |
|
| 392 | 392 | { |
| 393 | - if(!call_user_func_array(array(&$oAddonMemberCaptcha, $called_position), array(&$this))) |
|
| 393 | + if (!call_user_func_array(array(&$oAddonMemberCaptcha, $called_position), array(&$this))) |
|
| 394 | 394 | { |
| 395 | 395 | return false; |
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | $addon_act = Context::get('captcha_action'); |
| 400 | -if($addon_act && method_exists($oAddonMemberCaptcha, $called_position . '_' . $addon_act)) |
|
| 400 | +if ($addon_act && method_exists($oAddonMemberCaptcha, $called_position.'_'.$addon_act)) |
|
| 401 | 401 | { |
| 402 | - if(!call_user_func_array(array(&$oAddonMemberCaptcha, $called_position . '_' . $addon_act), array(&$this))) |
|
| 402 | + if (!call_user_func_array(array(&$oAddonMemberCaptcha, $called_position.'_'.$addon_act), array(&$this))) |
|
| 403 | 403 | { |
| 404 | 404 | return false; |
| 405 | 405 | } |