-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
131 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
class Curl | ||
{ | ||
public static function index($url, $params = [], $header = []) | ||
{ | ||
$curl = curl_init(); | ||
|
||
if (strpos($url, 'https') !== false) { | ||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); | ||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); | ||
} | ||
curl_setopt($curl, CURLOPT_URL, $url); | ||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | ||
curl_setopt($curl, CURLOPT_HEADER, false); | ||
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); | ||
curl_setopt($curl, CURLOPT_TIMEOUT, 5); | ||
curl_setopt($curl, CURLOPT_POST, true); | ||
curl_setopt($curl, CURLOPT_POSTFIELDS, $params); | ||
|
||
$data = curl_exec($curl); | ||
|
||
curl_close($curl); | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
use Hleb\Constructor\Handlers\Request; | ||
|
||
class GitHub | ||
{ | ||
public static function callApi($params) | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
use Hleb\Constructor\Handlers\Request; | ||
|
||
class Google | ||
{ | ||
// Captcha v2 | ||
private static function callApi($params) | ||
{ | ||
$api_url = 'https://www.google.com/recaptcha/api/siteverify'; | ||
|
||
if (!function_exists('curl_init')) { | ||
$data = @file_get_contents($api_url . '?' . http_build_query($params)); | ||
} else { | ||
$data = Curl::index($api_url, $params, ['Accept: application/json']); | ||
} | ||
|
||
if (!$data) return false; | ||
|
||
$data = json_decode($data, true); | ||
|
||
return $data['success'] ?? false; | ||
} | ||
|
||
// Проверка в AuthControllerе | ||
public static function checkCaptchaCode() | ||
{ | ||
$response = Request::getPost('g-recaptcha-response'); | ||
|
||
if (!$response) return false; | ||
|
||
return self::callApi(array( | ||
'secret' => config('general.private_key'), | ||
'response' => $response, | ||
'remoteip' => $_SERVER['REMOTE_ADDR'] | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
use Hleb\Constructor\Handlers\Request; | ||
|
||
class Yandex | ||
{ | ||
public static function callApi($params) | ||
{ | ||
$code = Request::getPost('code'); | ||
|
||
if (!empty($code)) { | ||
|
||
$sending_url = 'https://oauth.yandex.ru/token'; // отправка | ||
$receiving_url = 'https://login.yandex.ru/info'; // получение | ||
|
||
$params = [ | ||
'grant_type' => 'authorization_code', | ||
'code' => $code, | ||
'client_id' => 'ID_приложения', | ||
'client_secret' => 'ПАРОЛЬ_приложения', | ||
]; | ||
|
||
$info = Curl::index($sending_url, $params, ['Accept: application/json']); | ||
$data = json_decode($info, true); | ||
|
||
if (!empty($data['access_token'])) { | ||
|
||
$info = Curl::index($receiving_url, ['format' => 'json'], ['Authorization: OAuth ' . $data['access_token']]); | ||
$data = json_decode($info, true); | ||
} | ||
} | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters