1 | <?php |
||||||||||
2 | |||||||||||
3 | namespace Inji; |
||||||||||
4 | /** |
||||||||||
5 | * Recaptcha module |
||||||||||
6 | * |
||||||||||
7 | * @author Alexey Krupskiy <[email protected]> |
||||||||||
8 | * @link http://inji.ru/ |
||||||||||
9 | * @copyright 2015 Alexey Krupskiy |
||||||||||
10 | * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
||||||||||
11 | */ |
||||||||||
12 | class Recaptcha extends Module { |
||||||||||
13 | |||||||||||
14 | public function init() { |
||||||||||
15 | App::$cur->view->customAsset('js', 'https://www.google.com/recaptcha/api.js'); |
||||||||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() The method
customAsset() does not exist on Inji\Module . It seems like you code against a sub-type of Inji\Module such as Inji\Db .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The method
customAsset() does not exist on null .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||||||
16 | } |
||||||||||
17 | |||||||||||
18 | public function show() { |
||||||||||
19 | if (!$this->config['sitekey']) { |
||||||||||
20 | echo 'SiteKey not set for reCAPTCHA'; |
||||||||||
21 | } else { |
||||||||||
22 | echo "<div class='g-recaptcha' data-sitekey='{$this->config['sitekey']}'></div>"; |
||||||||||
23 | } |
||||||||||
24 | } |
||||||||||
25 | |||||||||||
26 | public function check($gResponse) { |
||||||||||
27 | $data = []; |
||||||||||
28 | $data['secret'] = $this->config['secret']; |
||||||||||
29 | $data['response'] = $gResponse; |
||||||||||
30 | $dara['remoteip'] = $_SERVER['REMOTE_ADDR']; |
||||||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||||||
31 | $response = file_get_contents('https://www.google.com/recaptcha/api/siteverify?' . http_build_query($data)); |
||||||||||
32 | if ($response) { |
||||||||||
33 | return json_decode($response); |
||||||||||
34 | } |
||||||||||
35 | return false; |
||||||||||
36 | } |
||||||||||
37 | } |