| Conditions | 5 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | public static function validate($data = null) |
||
| 39 | { |
||
| 40 | // check if test suite is enabled and test going on |
||
| 41 | if (App::$Properties->get('testSuite') === true && App::$Request->getClientIp() === '127.0.0.1') { |
||
| 42 | // captcha value should be equal to config file md5 sum :) |
||
| 43 | return $data === File::getMd5('/Private/Config/Default.php'); |
||
| 44 | } |
||
| 45 | // allow to validate captcha by codeception tests |
||
| 46 | $captchaValue = App::$Session->get('captcha'); |
||
| 47 | // unset session value to prevent duplication. Security fix. |
||
| 48 | App::$Session->remove('captcha'); |
||
| 49 | // check if session has value |
||
| 50 | if ($captchaValue === null || Str::length($captchaValue) < 1) { |
||
| 51 | return false; |
||
| 52 | } |
||
| 53 | |||
| 54 | return $data === $captchaValue; |
||
| 55 | } |
||
| 57 |