Commit a3c87cf4 by Francisco Salazar

Registros antispam

parent 9461ae98
...@@ -10,11 +10,13 @@ composer require jenssegers/agent ...@@ -10,11 +10,13 @@ composer require jenssegers/agent
``` ```
- Add the service provider in config/app.php: - Add the service provider in config/app.php:
```php ```php
Jenssegers\Agent\AgentServiceProvider::class, Jenssegers\Agent\AgentServiceProvider::class,
``` ```
- And add the Agent alias to config/app.php: - And add the Agent alias to config/app.php:
```php ```php
'Agent' => Jenssegers\Agent\Facades\Agent::class, 'Agent' => Jenssegers\Agent\Facades\Agent::class,
``` ```
......
...@@ -23,7 +23,7 @@ class CrmFormsController extends Controller ...@@ -23,7 +23,7 @@ class CrmFormsController extends Controller
public function store(RequestInterested $request) public function store(RequestInterested $request)
{ {
$request; error_log("$request");
$agent = new Agent(); $agent = new Agent();
$agent->setUserAgent($request->header('User-Agent')); $agent->setUserAgent($request->header('User-Agent'));
$browser = $agent->browser(); $browser = $agent->browser();
...@@ -46,75 +46,65 @@ class CrmFormsController extends Controller ...@@ -46,75 +46,65 @@ class CrmFormsController extends Controller
$agent->isTablet(); $agent->isTablet();
$user = User::find(1); $user = User::find(1);
if (config('crmforms.validate_email')) { //Se activa la opcion de validar emails por API
if($request->desc2 == "" && $request->email2 == "[email protected]" && strpos($request->email, "@mail.ru") === false){
$url = "https://apps.emaillistverify.com/api/verifyEmail?secret=".env('KEY_VERIFY')."&email=".$request->email; if (config('crmforms.validate_email')) { //Se activa la opcion de validar emails por API
$url = "https://apps.emaillistverify.com/api/verifyEmail?secret=".env('KEY_VERIFY')."&email=".$request->email;
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', $url);
$respuesta = $res->getBody();
$client = new \GuzzleHttp\Client(); if ( $respuesta == 'ok') { //Si el correo es valido
$res = $client->request('GET', $url); $interested = Interested::create($request->all());
$respuesta = $res->getBody(); $interested->notify(new WelcomeInterested());
$user->notify(new NewInterestd($interested));
if ( $respuesta == 'ok') { //Si el correo es valido $interested_details = InterestedDetail::firstOrNew(['interested_id' => $interested->id]);
$interested_details->browser = $browser;
$interested_details->browser_version = $browser_version;
$interested_details->devise = $devise;
$interested_details->platform = $platform;
$interested_details->platform_version = $platform_version;
$interested_details->session_time = $session_time;
$interested_details->devise_type = $devise_type;
$interested_details->save();
} else { // Si el correo no es valido
$user->notify(new EmailInvalid($request->all()));
return redirect()
->back()
->withInput()
->with('fail', 'fail');
}
} else { // No se valida el correo por api, va directo a la bd
$interested = Interested::create($request->all()); $interested = Interested::create($request->all());
$interested->notify(new WelcomeInterested()); $interested->notify(new WelcomeInterested());
$user->notify(new NewInterestd($interested)); $user->notify(new NewInterestd($interested));
$interested_details = InterestedDetail::firstOrNew(['interested_id' => $interested->id]); $interested_details = InterestedDetail::firstOrNew(['interested_id' => $interested->id]);
$interested_details->browser = $browser; $interested_details->browser = $browser;
$interested_details->browser_version = $browser_version; $interested_details->browser_version = $browser_version;
$interested_details->devise = $devise; $interested_details->devise = $devise;
$interested_details->platform = $platform; $interested_details->plataform = $platform;
$interested_details->platform_version = $platform_version; $interested_details->plataform_version = $platform_version;
$interested_details->session_time = $session_time; $interested_details->session_time = $session_time;
$interested_details->devise_type = $devise_type; $interested_details->devise_type = $devise_type;
$interested_details->save(); $interested_details->save();
}
} else { // Si el correo no es valido
$user->notify(new EmailInvalid($request->all()));
return redirect()
->back()
->withInput()
->with('fail', 'fail');
}
} else { // No se valida el correo por api, va directo a la bd
$interested = Interested::create($request->all());
$interested->notify(new WelcomeInterested());
$user->notify(new NewInterestd($interested));
$interested_details = InterestedDetail::firstOrNew(['interested_id' => $interested->id]);
$interested_details->browser = $browser; return redirect()
$interested_details->browser_version = $browser_version;
$interested_details->devise = $devise;
$interested_details->plataform = $platform;
$interested_details->plataform_version = $platform_version;
$interested_details->session_time = $session_time;
$interested_details->devise_type = $devise_type;
$interested_details->save();
}
return redirect()
->route('crmforms.redirect', $request->landing) ->route('crmforms.redirect', $request->landing)
->with('registrado', 'registrado') ->with('registrado', 'registrado')
->with('message_success', 'Hemos recibido tu solicitud, en breve nos comunicaremos contigo'); ->with('message_success', 'Hemos recibido tu solicitud, en breve nos comunicaremos contigo');
}else{
return redirect()->back();
}
} }
public function redirect($landing) public function redirect($landing)
......
{{-- Mensajes de error y mensajes de avisos --}} {{-- Mensajes de error y mensajes de avisos --}}
@include('partials.messages_partial') @include('partials.messages_partial')
<style>
.ocultar{display:none;}
</style>
{{-- No remover --}} {{-- No remover --}}
{!! Form::open(['route'=> ['crmforms.store'],"method"=>"POST", "id"=>"landing_form"]) !!} {!! Form::open(['route'=> ['crmforms.store'],"method"=>"POST", "id"=>"landing_form"]) !!}
...@@ -34,6 +37,13 @@ dsasd ...@@ -34,6 +37,13 @@ dsasd
</div> </div>
</div> </div>
<div class="ocultar">
<label>Descripcion extra</label>
<input name="desc2" id="desc2" type="text">
<label>email 2</label>
<input name="email2" id="email2" type="text" value="hola@onestartup.mx">
</div>
<div class="row"> <div class="row">
{!! Form::submit('Enviar información', ['class'=>'btn btn-primary']) !!} {!! Form::submit('Enviar información', ['class'=>'btn btn-primary']) !!}
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment