Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions app/app/Http/Controllers/Admin/CustomizationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ public function save(Request $request)
}
$update_params['customer_satisfaction_survey_enabled'] = $customer_satisfaction_survey_enabled;

$recaptcha_enabled = false;
if ( $update_params['recaptcha_enabled'] =='yes') {
$recaptcha_enabled = true;
}
$update_params['recaptcha_enabled'] = $recaptcha_enabled;

$enable_google_signin = false;

if ( !empty( $update_params['enable_google_signin'] ) ) {
Expand Down Expand Up @@ -298,21 +304,6 @@ public function save(Request $request)
$update_params['allow_app_feedback'] = $allow_app_feedback;




$recaptcha_enabled = false;

if ( !empty( $update_params['recaptcha_enabled'] ) ) {
$recaptcha_enabled = true;
}
$update_params['recaptcha_enabled'] = $recaptcha_enabled;


if ( !empty( $update_params['recaptcha_enabled'] ) ) {
$recaptcha_enabled = true;
}
$update_params['recaptcha_enabled'] = $recaptcha_enabled;

if ( !empty( $update_params['disqus_enabled'] ) ) {
$disqus_enabled = true;
}
Expand Down
5 changes: 5 additions & 0 deletions app/app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ public function contactSubmit(Request $request)
$request->session()->flash('status', 'Invalid captcha validation. Please try again.');
return view('pages.contact', $vars);
}
} else {
// Call validation using string format standard in 5.1
$this->validate($request, [
'cf-turnstile-response' => 'required|turnstile',
]);
}
if (empty($data['first_name'])) {
$request->session()->flash('status', 'Please fill in first name..');
Expand Down
28 changes: 28 additions & 0 deletions app/app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use App\ApiCredentialKVStore;
use Validator;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -19,6 +21,32 @@ public function boot()
if ( $ssl ) {
\URL::forceSchema('https');
}
Validator::extend('turnstile', function ($attribute, $value, $parameters, $validator) {
$creds = ApiCredentialKVStore::getRecord();
$secret = $creds['cloudflare_secret_key'];
$ip = request()->ip();

// Native cURL payload request for Laravel 5.1
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://challenges.cloudflare.com/turnstile/v0/siteverify');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'secret' => $secret,
'response' => $value,
'remoteip' => $ip
]);

$response = curl_exec($ch);
curl_close($ch);

if ($response) {
$responseData = json_decode($response, true);
return isset($responseData['success']) && $responseData['success'] === true;
}

return false;
});
}

/**
Expand Down
3 changes: 3 additions & 0 deletions app/resources/lang/en/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
'attribute-name' => [
'rule-name' => 'custom-message',
],
'cf-turnstile-response' => [
'turnstile' => 'The anti-bot verification failed. Please try again.',
],
],

/*
Expand Down
21 changes: 20 additions & 1 deletion app/resources/views/admin/customizations/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@
</div>
</div>

<div class="row form-group">

<div class="row form-group">
<label for="billing_flow">Billing flow</label>
<div class="controls">
<select name="billing_flow" class="form-control" id="billing_flow">
Expand All @@ -422,6 +423,24 @@
</div>
</div>

<div class="row form-group">
<label for="upgrade_flow">Upgrade flow</label>
<div class="controls">
<select name="upgrade_flow" class="form-control" id="upgrade_flow">
@if ( $record->upgrade_flow == 'IMMEDIATE')
<option value="IMMEDIATE" selected>Immediate</option>
<option value="SCHEDULED">Scheduled</option>
@elseif ( $record->upgrade_flow == 'SCHEDULED')
<option value="IMMEDIATE">Immediate</option>
<option value="SCHEDULED" selected>Scheduled</option>
@else
<option value="IMMEDIATE">Immediate</option>
<option value="SCHEDULED">Scheduled</option>
@endif
</select>
</div>
</div>

<div class="row form-group">
<label for="invoice_due_in_days">Invoice due in days</label>
<div class="controls">
Expand Down
7 changes: 7 additions & 0 deletions app/resources/views/pages/contact.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Contact
@endsection
@section('content')

@if (Session::has('status'))
<div class="blue-grey darken-1 thankyou">
<center>
Expand Down Expand Up @@ -35,6 +36,10 @@
<div class="col-12 col-lg-6 contact-form column">
<p>Have queries regarding our offerings? Feel free to contact us.</p>
<form method="POST" action="/contact" id="contactFrm">

@if ($errors->has('cf-turnstile-response'))
<p style="color: red;">{{ $errors->first('cf-turnstile-response') }}</p>
@endif
<div class="row">
<div class="col-12 col-md-6">
<div class="wrapper">
Expand Down Expand Up @@ -78,6 +83,8 @@
data-callback='onSubmit'
data-action='submit'>Send message</button>
@else
<div class="cf-turnstile" data-sitekey="{{ $creds['cloudflare_site_key'] }}"></div>
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
<button class="btn button" type="submit">Send message</button>
@endif
</div>
Expand Down
Loading