<?php
namespace EADPlataforma\Controller\Website;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController as Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use EADPlataforma\Services\GeneralService;
use EADPlataforma\Entity\ConfigurationIp;
use EADPlataforma\Entity\User;
use EADPlataforma\Enum\UserEnum;
use EADPlataforma\Enum\ClientEnum;
use EADPlataforma\Enum\ConfigurationIpEnum;
use EADPlataforma\Enum\ServicesEnum;
use EADPlataforma\Enum\ErrorEnum;
abstract class AbstractWebsiteController extends Controller {
/**
* @var GeneralService
*/
protected $generalService;
/**
* @var \MemcacheService
*/
protected $memcacheService;
/**
* @var SchoolEntityManager
*/
protected $em;
/**
* @var SchoolEntityManagerRead
*/
protected $emRead;
/**
* @var EadminEntityManager
*/
protected $emEadmin;
/**
* @var User $user
*/
protected $user;
/**
* @var FileService $fileService
*/
protected $fileService;
/**
* @var LogService $userLogService
*/
protected $userLogService;
/**
* @var ConfigurationService
*/
protected $configuration;
/**
* @var SessionInterface
*/
protected $sessionSym;
/**
* @var EntityUtil $entityUtil
*/
protected $entityUtil;
/**
* @var StringUtil $stringUtil
*/
protected $stringUtil;
/**
* @var UserPermissionUtil $userPermissionUtil
*/
protected $userPermissionUtil;
/**
* @var RequestUtil $requestUtil
*/
protected $requestUtil;
/**
* @var \Client
*/
protected $client;
/**
* @var \ClientConfiguration
*/
protected $clientConfig;
/**
* @var string
*/
protected $domain;
/**
* @var string
*/
protected $eadDomain;
/**
* @var array
*/
protected $data = [];
/**
* @var string
*/
public $adminLink;
/**
* Constructor
*
* @param GeneralService $generalService
* @param RequestStack $requestStack
*/
public function __construct(GeneralService $generalService, RequestStack $requestStack){
$this->generalService = $generalService;
$this->em = $this->generalService->getService('SchoolEntityManager');
$this->emRead = $this->generalService->getService('SchoolEntityManagerRead');
$this->emEadmin = $this->generalService->getService('EadminEntityManager');
$this->fileService = $this->generalService->getService('FileService');
$this->userLogService = $this->generalService->getService('LogService');
$this->memcacheService = $this->generalService->getService('MemcacheService');
$this->userPermissionUtil = $this->generalService->getUtil('UserPermissionUtil');
$databaseManagerService = $this->generalService->getService('DatabaseManagerService');
$databaseManagerService->executeMigrations();
$request = $requestStack->getCurrentRequest();
$this->user = $this->generalService->getService('UserSessionService')->getUser();
$this->configuration = $this->generalService->getService('ConfigurationService');
$this->sessionSym = $this->configuration->getSessionSym();
$this->entityUtil = $this->generalService->getUtil('EntityUtil');
$this->stringUtil = $this->generalService->getUtil('StringUtil');
$this->requestUtil = $this->generalService->getUtil('RequestUtil');
$this->client = $this->configuration->getClient();
$this->clientConfig = $this->configuration->getClientConfiguration();
if($this->client){
$this->domain = $this->configuration->getActiveDomain(true);
$this->eadDomain = $this->client->getDomainPrimary();
$this->adminLink = $this->configuration->getAdminLink();
}
if(!$this->generalService->isSandbox()){
//$this->executeCron($request);
}
if($this->configuration->checkModuleIsAbleOnPlan('ipFunction')){
$this->checkConfigurationIp($request);
}
$this->checkPlatformStatus($request);
$this->checkRedirectDomain($request);
if($this->isPlatformActive()){
$this->checkIsRestricted($request);
$this->checkUserIsComplete($request);
}
}
public function executeCron(Request $request)
{
return;
/*$platformStatus = $this->clientConfig->getPlatformStatus();
$suspended = ClientEnum::PLATFORM_STATUS_SUSPENDED;
$canceled = ClientEnum::PLATFORM_STATUS_CANCELED;
if($platformStatus == $suspended || $platformStatus == $canceled){
return;
}
if(
stristr($request->getPathInfo(), '/general/')
){
return;
}
$today = date('Y-m-d H:i:s');
$lastExecutionDay = $this->configuration->get('cron_date');
$cronUrl = "https://{$this->eadDomain}/general/{$this->clientConfig->getToken()}";
if(!empty($lastExecutionDay)){
$todaySeconds = strtotime($today);
$lastExecutionSeconds = strtotime($lastExecutionDay);
$diff = $todaySeconds - $lastExecutionSeconds;
$diffHours = round($diff / 60 / 60);
if($diffHours >= 24){
$sqsService = $this->generalService->getService('Aws\\AwsSqs');
$sqsService->sendMessageCron($cronUrl);
sleep(5);
}
}else{
$hour = rand(7,9);
$min = rand(10,59);
$date = date('Y-m-d');
$this->configuration->set('cron_date', "{$date} 0{$hour}:{$min}:00", false);
}*/
}
public function checkConfigurationIp(Request $request)
{
$info = $this->generalService->getServiceAccess(ServicesEnum::LOGIN);
if(!in_array($request->getClientIp(), $info->validIps)){
$configuration = $this->generalService->getService('ConfigurationService');
$configurationIpRepository = $this->em->getRepository(ConfigurationIp::class);
$configurationIp = $configurationIpRepository->findOneBy([
"ip" => $request->getClientIp(),
"deleted" => ConfigurationIpEnum::ITEM_NO_DELETED
]);
$countWhitelist = $configurationIpRepository->count([
"type" => ConfigurationIpEnum::WHITE_LIST,
"deleted" => ConfigurationIpEnum::ITEM_NO_DELETED
]);
if($configurationIp){
if($configurationIp->getType() == ConfigurationIpEnum::BLACK_LIST){
$response = new Response('', Response::HTTP_UNAUTHORIZED);
$response->send();
exit;
}
}elseif(!empty($countWhitelist)){
$response = new Response('', Response::HTTP_UNAUTHORIZED);
$response->send();
exit;
}
}
}
public function checkRedirectDomain(Request $request)
{
$info = $this->generalService->getServiceAccess(ServicesEnum::LOGIN);
if(in_array($request->getClientIp(), $info->validIps)){
return;
}
if($this->configuration->isLocal()){
return;
}
$ignoreRoutes = [
"genereateAdminSSO",
"loginEadminSSO",
"sendCron",
"manifest",
"updateLive",
"meetRecordRegister",
"sitemap",
"cronGeneral",
"callbackVimeo",
"getTokenAccessRd",
"executeCalculateAnticipation",
"getEADCheckoutFee",
"deleteNfeEADCheckout",
"executeCronListEmail",
"executeCronUserSubscription",
"sendWebhookQueue",
"deleteTrashAll",
"processDataEadCheckout",
"processDataEadCheckoutBar",
"processDataPagSeguro",
"processDataPagSeguroBar",
"processDataHotmart",
"processDataHotmartBar",
"processDataPayPal",
"processDataPayPalBar",
"processDataEduzz",
"processDataEduzzBar",
"processDataProvi",
"processDataProviBar",
"processDataBraip",
"processDataBraipBar",
"processDataMonetizze",
"processDataMonetizzeBar",
"processDataKiwify",
"processDataKiwifyBar",
"processDataDigitalManagerGuru",
"processDataDigitalManagerGuruBar",
"processDataAppMax",
"processDataAppMaxBar",
"processDataDoppus",
"processDataDoppusBar",
"processDataTicto",
"processDataTictoBar",
"processDataMercadoPago",
"processDataMercadoPagoBar",
"processDataAbmex",
"processDataAbmexBar",
"processDataPerfectPay",
"processDataPerfectPayBar",
"processDataEvermart",
"processDataEvermartBar",
"processDataHeroSpark",
"processDataHeroSparkBar",
"processDataYampi",
"processDataYampiBar",
"processDataCartPanda",
"processDataCartPandaBar",
"processDataKirvano",
"processDataKirvanoBar",
"callbackRdStation",
"callbackRdStationBar",
"callbackBling",
"callbackBlingBar",
"callbackDinamize",
"callbackDinamizeBar",
"cartCheckoutCharge",
"getRoutesToFileImport",
"getRoutesToExport",
"exportCertificate",
"exportTestimonial",
"exportEnrollment",
"exportExamUser",
"exportExamUserReport",
"exportLessonLog",
"exportNewsLetter",
"exportProductCharge",
"exportTransaction",
"exportTransactionItem",
"exportUser",
"exportUserSubscription",
"exportWhishList",
"exportLessonPresence",
"exportQuestions",
"exportProductOpportunity",
"fileGetUpload",
"exportLessonSupport",
"getClientInfo",
"downgradeToFree",
"upgradeReceivers",
"removeClientCustomDomain",
"getInfo",
"getInfoCourse",
"sendAuthenticationEmail"
];
if(in_array($request->get('_route'), $ignoreRoutes)){
return;
}
$gKeyV3 = $this->configuration->get('recaptcha_key_v3');
$gSecretV3 = $this->configuration->get('recaptcha_secret_v3');
$domainPrimary = $this->client->getDomainPrimary();
$domainSecondary = $this->client->getDomainSecondary();
if(
empty($gKeyV3) ||
empty($gSecretV3) ||
!$this->configuration->checkModuleIsAbleOnPlan('domainFunction')
){
if($request->getHost() == $domainSecondary && !empty($domainSecondary)){
$url = "https://{$domainPrimary}{$request->getPathInfo()}";
$redirectResponse = new RedirectResponse($url, 302);
$redirectResponse->send();
exit;
}
}
if($this->clientConfig->getRedirect() == ClientEnum::YES){
if(empty($gKeyV3) || empty($gSecretV3)){
return;
}
if($request->getHost() == $this->client->getDomainPrimary()){
if(!empty($domainSecondary)){
$url = "https://{$domainSecondary}{$request->getPathInfo()}";
$redirectResponse = new RedirectResponse($url, 301);
$redirectResponse->send();
exit;
}
}
}
}
public function checkIsRestricted(Request $request)
{
if(!$this->user){
$ignoreRoutes = [
"genereateAdminSSO",
"loginEadminSSO",
"sendCron",
"updateLive",
"meetRecordRegister",
"notFound",
"manifest",
"sitemap",
"authLogin",
"authMFA",
"sendEmailAuthentication",
"updateUserNotification",
"sendEmailRecoverPassword",
"resetPassword",
"login",
"loginPost",
"loginFast",
"loginApi",
"loginConfirm",
"loginAuthentication",
"recoverPassword",
"changePasswordPost",
"resetPasswordPost",
"userLogoff",
"logoff ",
"getChargePage",
"cartCheckoutCharge",
"cronGeneral",
"callbackVimeo",
"getTokenAccessRd",
"executeCalculateAnticipation",
"getEADCheckoutFee",
"deleteNfeEADCheckout",
"executeCronListEmail",
"executeCronUserSubscription",
"sendWebhookQueue",
"deleteTrashAll",
"processDataEadCheckout",
"processDataEadCheckoutBar",
"processDataPagSeguro",
"processDataPagSeguroBar",
"processDataHotmart",
"processDataHotmartBar",
"processDataPayPal",
"processDataPayPalBar",
"processDataEduzz",
"processDataEduzzBar",
"processDataProvi",
"processDataProviBar",
"processDataBraip",
"processDataBraipBar",
"processDataMonetizze",
"processDataMonetizzeBar",
"processDataKiwify",
"processDataKiwifyBar",
"processDataDigitalManagerGuru",
"processDataDigitalManagerGuruBar",
"processDataAppMax",
"processDataAppMaxBar",
"processDataDoppus",
"processDataDoppusBar",
"processDataTicto",
"processDataTictoBar",
"processDataMercadoPago",
"processDataMercadoPagoBar",
"processDataAbmex",
"processDataAbmexBar",
"processDataPerfectPay",
"processDataPerfectPayBar",
"processDataEvermart",
"processDataEvermartBar",
"processDataHeroSpark",
"processDataHeroSparkBar",
"processDataYampi",
"processDataYampiBar",
"processDataCartPanda",
"processDataCartPandaBar",
"processDataKirvano",
"processDataKirvanoBar",
"callbackRdStation",
"callbackRdStationBar",
"callbackBling",
"callbackBlingBar",
"callbackDinamize",
"callbackDinamizeBar",
"certificateSearchPage",
"certificatePage",
"stopNotification",
"updateUserNotification",
"fileGetUpload",
"getClientInfo",
"downgradeToFree",
"upgradeReceivers",
"removeClientCustomDomain",
"downloadCertificate",
"viewCertificate",
"getInfo",
"getInfoCourse",
"sendAuthenticationEmail"
];
$platformType = $this->client->getPlatformType();
if($platformType == ClientEnum::PLATFORM_TYPE_RESTRICTED){
if(in_array($request->get('_route'), $ignoreRoutes)){
return;
}
$this->checkUserSession($request);
return;
}
}
return;
}
public function isPlatformActive()
{
$platformStatus = $this->clientConfig->getPlatformStatus();
if($platformStatus == ClientEnum::PLATFORM_STATUS_FREEZED && $this->user){
return $this->userPermissionUtil->canAccessAdm();
}
return ($platformStatus == ClientEnum::PLATFORM_STATUS_ACTIVED);
}
public function checkPlatformStatus(Request $request){
if($this->isPlatformActive()){
return;
}
$platformStatus = $this->clientConfig->getPlatformStatus();
$ignoreRoutes = [
"genereateAdminSSO",
"loginEadminSSO",
"sendCron",
"updateLive",
"meetRecordRegister",
"home",
"getClientInfo",
"downgradeToFree",
"upgradeReceivers",
"removeClientCustomDomain",
"fileGetUpload",
"getInfo",
"getInfoCourse"
];
if($platformStatus == ClientEnum::PLATFORM_STATUS_FREEZED){
if($this->user){
return;
}
$ignoreRoutes[] = "authLogin";
$ignoreRoutes[] = "authMFA";
$ignoreRoutes[] = "sendEmailAuthentication";
$ignoreRoutes[] = "updateUserNotification";
$ignoreRoutes[] = "sendEmailRecoverPassword";
$ignoreRoutes[] = "resetPassword";
$ignoreRoutes[] = "login";
$ignoreRoutes[] = "loginPost";
$ignoreRoutes[] = "loginFast";
$ignoreRoutes[] = "loginApi";
$ignoreRoutes[] = "loginConfirm";
$ignoreRoutes[] = "loginAuthentication";
$ignoreRoutes[] = "recoverPassword";
$ignoreRoutes[] = "changePasswordPost";
$ignoreRoutes[] = "resetPasswordPost";
$ignoreRoutes[] = "userLogoff";
$ignoreRoutes[] = "logoff";
$ignoreRoutes[] = "cronGeneral";
$ignoreRoutes[] = "callbackVimeo";
$ignoreRoutes[] = "getTokenAccessRd";
$ignoreRoutes[] = "executeCalculateAnticipation";
$ignoreRoutes[] = "getEADCheckoutFee";
$ignoreRoutes[] = "deleteNfeEADCheckout";
$ignoreRoutes[] = "executeCronListEmail";
$ignoreRoutes[] = "executeCronUserSubscription";
$ignoreRoutes[] = "sendWebhookQueue";
$ignoreRoutes[] = "deleteTrashAll";
$ignoreRoutes[] = "processDataEadCheckout";
$ignoreRoutes[] = "processDataEadCheckoutBar";
$ignoreRoutes[] = "processDataPagSeguro";
$ignoreRoutes[] = "processDataPagSeguroBar";
$ignoreRoutes[] = "processDataHotmart";
$ignoreRoutes[] = "processDataHotmartBar";
$ignoreRoutes[] = "processDataPayPal";
$ignoreRoutes[] = "processDataPayPalBar";
$ignoreRoutes[] = "processDataEduzz";
$ignoreRoutes[] = "processDataEduzzBar";
$ignoreRoutes[] = "processDataProvi";
$ignoreRoutes[] = "processDataProviBar";
$ignoreRoutes[] = "processDataBraip";
$ignoreRoutes[] = "processDataBraipBar";
$ignoreRoutes[] = "processDataMonetizze";
$ignoreRoutes[] = "processDataMonetizzeBar";
$ignoreRoutes[] = "processDataKiwify";
$ignoreRoutes[] = "processDataKiwifyBar";
$ignoreRoutes[] = "processDataDigitalManagerGuru";
$ignoreRoutes[] = "processDataDigitalManagerGuruBar";
$ignoreRoutes[] = "processDataAppMax";
$ignoreRoutes[] = "processDataAppMaxBar";
$ignoreRoutes[] = "processDataDoppus";
$ignoreRoutes[] = "processDataDoppusBar";
$ignoreRoutes[] = "processDataTicto";
$ignoreRoutes[] = "processDataTictoBar";
$ignoreRoutes[] = "processDataMercadoPago";
$ignoreRoutes[] = "processDataMercadoPagoBar";
$ignoreRoutes[] = "processDataAbmex";
$ignoreRoutes[] = "processDataAbmexBar";
$ignoreRoutes[] = "processDataPerfectPay";
$ignoreRoutes[] = "processDataPerfectPayBar";
$ignoreRoutes[] = "processDataEvermart";
$ignoreRoutes[] = "processDataEvermartBar";
$ignoreRoutes[] = "processDataHeroSpark";
$ignoreRoutes[] = "processDataHeroSparkBar";
$ignoreRoutes[] = "processDataYampi";
$ignoreRoutes[] = "processDataYampiBar";
$ignoreRoutes[] = "processDataCartPanda";
$ignoreRoutes[] = "processDataCartPandaBar";
$ignoreRoutes[] = "processDataKirvano";
$ignoreRoutes[] = "processDataKirvanoBar";
$ignoreRoutes[] = "callbackRdStation";
$ignoreRoutes[] = "callbackRdStationBar";
$ignoreRoutes[] = "callbackBling";
$ignoreRoutes[] = "callbackBlingBar";
$ignoreRoutes[] = "callbackDinamize";
$ignoreRoutes[] = "callbackDinamizeBar";
$ignoreRoutes[] = "certificateSearchPage";
$ignoreRoutes[] = "certificatePage";
$ignoreRoutes[] = "stopNotification";
$ignoreRoutes[] = "updateUserNotification";
$ignoreRoutes[] = "sendAuthenticationEmail";
}
if(in_array($request->get('_route'), $ignoreRoutes)){
return;
}
$url = $this->generalService->generateUrl('home');
$redirectResponse = new RedirectResponse($url);
$redirectResponse->headers->set('Content-Type', 'text/html');
$redirectResponse->send();
exit;
}
public function checkUserIsComplete(Request $request)
{
if($this->user){
$userRepository = $this->em->getRepository(User::class);
if(!$userRepository->checkUserIsComplete($this->user)){
$ignoreRoutes = [
"genereateAdminSSO",
"loginEadminSSO",
"sendCron",
"userProfile",
"updateLive",
"meetRecordRegister",
"logoff",
"userLogoff",
"getChargePage",
"getCartItemsMenu",
"cartInitiateCheckout",
"checkoutOldCart",
"checkoutNewCart",
"checkoutCartWithCoupon",
"checkoutClean",
"cartIndividual",
"cartAdd",
"cartAddSuggestion",
"cartCreateEnroll",
"cartCheckoutPlanTrial",
"addProductWhishlist",
"applyCartCoupon",
"cart",
"getUserValidCarts",
"cartChangeStatus",
"cartCheckoutPaypal",
"cartCheckoutPagseguro",
"cartCheckoutMercadopago",
"cartCheckoutCharge",
"cartCheckoutDefault",
"cartCheckoutCustom",
"cartOneClickBuy",
"cartCheckoutNewTry",
"cartConclusion",
"cartConclusionCheckStatus",
"cartCouponRemove",
"cartDelete",
"countProductCouponByProductOffers",
"listCouponByProductOffers",
"testGeoSelectCep",
"loginConfirm",
"stopNotification",
"updateUserNotification",
"fileGetUpload",
"getClientInfo",
"downgradeToFree",
"upgradeReceivers",
"removeClientCustomDomain",
"getInfo",
"getInfoCourse"
];
if(!in_array($request->get('_route'), $ignoreRoutes)){
$url = $this->generalService->generateUrl('userProfile');
$redirectResponse = new RedirectResponse($url);
$redirectResponse->headers->set('Content-Type', 'text/html');
$redirectResponse->send();
exit;
}
}
}
}
public function checkUserSession(Request $request)
{
if(!$this->user){
$hash = base64_encode($request->getUri());
$url = $this->generalService->generateUrl('login', [ "hash" => $hash ]);
$redirectResponse = new RedirectResponse($url);
$redirectResponse->headers->set('Content-Type', 'text/html');
$redirectResponse->send();
exit;
}
}
public function jsonSerializer($arraySerilize) {
$encoders = [new JsonEncoder()];
$normalizers = [new ObjectNormalizer()];
$serializer = new Serializer($normalizers, $encoders);
return $serializer->serialize($arraySerilize, 'json', [
'circular_reference_handler' => function ($object) {
return $object->getId();
}
]);
}
public function renderEAD($templateName, $module = "website")
{
//$this->data = $this->stringUtil->convertToUtf8($this->data);
$pixelService = $this->generalService->getService('Marketing\\PixelService');
$pixelService->sendConversion('PageView');
$this->data['nonceHash'] = bin2hex(random_bytes(16));
$allowSrc = [
"https://fonts.googleapis.com",
"https://cdnjs.cloudflare.com",
"https://cdn.eadplataforma.app",
"https://kit.fontawesome.com",
"https://www.googletagmanager.com",
"https://cdn.tailwindcss.com",
"https://player.sambatech.com.br",
"http://player.sambatech.com.br",
"https://player.pandavideo.com.br",
"https://fonts.gstatic.com",
"https://static.hotjar.com",
"https://player.vdocipher.com",
"https://www.google.com",
"http://testeeadpublic.s3.us-east-2.amazonaws.com",
"wss://metrics.eadplataforma.app",
"https://metrics.eadplataforma.app",
"https://www.google-analytics.com",
"https://analytics.google.com",
"http://livestream.com",
"'nonce-{$this->data['nonceHash']}'"
];
$allowSrc = implode(' ', $allowSrc);
$optionsSrc = [
"default-src 'self'",
"script-src 'self' {$allowSrc}",
"object-src 'none'",
"style-src 'self' {$allowSrc}",
"font-src 'self' {$allowSrc}",
"img-src 'self' data: {$allowSrc}",
"connect-src 'self' {$allowSrc}",
"media-src 'self' {$allowSrc}",
"frame-src 'self' {$allowSrc}",
"report-uri /report/csp",
];
$optionsSrc = implode('; ', $optionsSrc);
$response = $this->render("{$module}/{$templateName}", $this->data);
//$response->headers->set("Content-Security-Policy", $optionsSrc);
return $response;
}
public function eadResponse($data, ?int $errorCode = ErrorEnum::SUCCESS,
?bool $serializer = true, ?bool $useHttpStatus = false){
$response = [ "data" => $data, "error" => !empty($errorCode) ? $errorCode : false ];
//$response = $this->stringUtil->convertToUtf8($response);
if($serializer){
$response = $this->jsonSerializer($response);
}else{
$response = json_encode($response);
}
$httpStatus = 200;
if($useHttpStatus && $errorCode && isset(ErrorEnum::HTTP_STATUS[$errorCode])){
$httpStatus = ErrorEnum::HTTP_STATUS[$errorCode];
}
return new JsonResponse($response, $httpStatus, [], true);
}
public function validateEntity($entityObj, $groups = []){
return $this->entityUtil->setEntity($entityObj)->validateEntity($groups);
}
public function createCaptchaKey(Request $request)
{
$preKey = md5("captcha");
$value = md5($this->client->getDomainPrimary().date('Y-m-d H:i:s').$request->getClientIp());
$key = "{$preKey}_{$value}";
$data = $this->stringUtil->randomText(6);
$this->memcacheService->saveData($key, $data, 60 * 60 * 24);
return $key;
}
public function isValidCaptcha(Request $request)
{
$this->requestUtil->setRequest($request)->setData();
$gRecaptchaResponse = $this->requestUtil->getField('g-recaptcha-response');
$eCaptchaPost = $this->requestUtil->getField('e-captcha');
$keyCaptcha = $this->requestUtil->getField('keyCaptcha');
$gSecretKey = $this->configuration->get('recaptcha_secret_v2');
$gSecretKeyV3 = $this->configuration->get('recaptcha_secret_v3');
$configDefault = $this->configuration->getDefaultRecaptcha();
$host = $request->getHost();
if(
!empty($gSecretKey) ||
!empty($gSecretKeyV3) ||
stristr($host, ".eadplataforma.app")
){
if(!empty($gRecaptchaResponse)){
$ip = $request->getClientIp();
$secret = $configDefault->defaultRecaptchaSecretV3;
if(!stristr($host, ".eadplataforma.app")){
if(!empty($gSecretKeyV3)){
$secret = $gSecretKeyV3;
}else if(!empty($gSecretKey)){
$secret = $gSecretKey;
}
}
$dataUrl = [
"secret" => $secret,
"response" => $gRecaptchaResponse,
"remoteip" => $ip,
];
$dataUrl = http_build_query($dataUrl);
$url = "https://www.google.com/recaptcha/api/siteverify?{$dataUrl}";
$return = file_get_contents($url);
$return = json_decode($return);
if(!$return->success){
return false;
}
if(isset($return->score)){
if($return->score <= 0.7){
return false;
}
return true;
}
return false;
}
return false;
}
return true;
if(!empty($this->memcacheService->getData($keyCaptcha))){
return ($eCaptchaPost == $this->memcacheService->getData($keyCaptcha));
}else{
$this->memcacheService->deleteData($keyCaptcha);
}
return false;
}
}