Completed
Push — master ( 67c338...c7b167 )
by Wanderson
04:24
created

ReCaptcha::isValid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Win\Widget;
4
5
/**
6
 * Validador do ReCaptcha do google
7
 * @author WebCorpore
8
 */
9
class ReCaptcha {
10
11
	public static $siteKey = '';
12
	public static $secretKey = '';
13
14
	/**
15
	 * Retorna TRUE se usuário marcou "Não sou um robô"
16
	 * @return boolean
17
	 */
18
	public static function isValid() {
19
		$captcha = $_POST['g-recaptcha-response'];
20
		$response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . static::$secretKey . "&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']), TRUE);
21
		return (boolean) $response['success'];
22
	}
23
24
}
25