diff --git a/application/controllers/Config.php b/application/controllers/Config.php
index 639ecc794..b73bc80c0 100644
--- a/application/controllers/Config.php
+++ b/application/controllers/Config.php
@@ -286,11 +286,16 @@ class Config extends Secure_Controller
{
$batch_save_data = array(
'theme' => $this->input->post('theme'),
+ 'default_sales_discount' => $this->input->post('default_sales_discount'),
'receiving_calculate_average_price' => $this->input->post('receiving_calculate_average_price') != NULL,
'lines_per_page' => $this->input->post('lines_per_page'),
- 'default_sales_discount' => $this->input->post('default_sales_discount'),
'notify_horizontal_position' => $this->input->post('notify_horizontal_position'),
'notify_vertical_position' => $this->input->post('notify_vertical_position'),
+ 'gcaptcha_enable' => $this->input->post('gcaptcha_enable') != NULL,
+ 'gcaptcha_secret_key' => $this->input->post('gcaptcha_secret_key'),
+ 'gcaptcha_site_key' => $this->input->post('gcaptcha_site_key'),
+ 'giftcard_number' => $this->input->post('giftcard_number'),
+ 'statistics' => $this->input->post('statistics') != NULL,
'custom1_name' => $this->input->post('custom1_name'),
'custom2_name' => $this->input->post('custom2_name'),
'custom3_name' => $this->input->post('custom3_name'),
@@ -300,9 +305,7 @@ class Config extends Secure_Controller
'custom7_name' => $this->input->post('custom7_name'),
'custom8_name' => $this->input->post('custom8_name'),
'custom9_name' => $this->input->post('custom9_name'),
- 'custom10_name' => $this->input->post('custom10_name'),
- 'statistics' => $this->input->post('statistics') != NULL,
- 'giftcard_number' => $this->input->post('giftcard_number'),
+ 'custom10_name' => $this->input->post('custom10_name')
);
$result = $this->Appconfig->batch_save($batch_save_data);
diff --git a/application/controllers/Login.php b/application/controllers/Login.php
index cb883b4e2..6617167eb 100644
--- a/application/controllers/Login.php
+++ b/application/controllers/Login.php
@@ -1,6 +1,6 @@
form_validation->set_rules('username', 'lang:login_undername', 'callback_login_check');
$this->form_validation->set_error_delimiters('
', '
');
-
+
+ $this->form_validation->set_rules('username', 'lang:login_username', 'required|callback_login_check');
+
+ if($this->config->item('gcaptcha_enable'))
+ {
+ $this->form_validation->set_rules('g-recaptcha-response', 'lang:login_gcaptcha', 'required|callback_gcaptcha_check');
+ }
+
if($this->form_validation->run() == FALSE)
{
$this->load->view('login');
@@ -22,9 +28,9 @@ class Login extends CI_Controller
if($this->config->item('statistics'))
{
$this->load->library('tracking_lib');
-
+
$this->tracking_lib->track_page('login', 'login');
-
+
$this->tracking_lib->track_event('Stats', 'Theme', $this->config->item('theme'));
$this->tracking_lib->track_event('Stats', 'Language', $this->config->item('language'));
$this->tracking_lib->track_event('Stats', 'Timezone', $this->config->item('timezone'));
@@ -48,9 +54,9 @@ class Login extends CI_Controller
{
$password = $this->input->post('password');
- if($this->_security_check($username, $password))
+ if($this->_security_check())
{
- $this->form_validation->set_message('login_check', 'Security check failure');
+ $this->form_validation->set_message('login_check', $this->lang->line('login_invalid_security'));
return FALSE;
}
@@ -62,10 +68,33 @@ class Login extends CI_Controller
return FALSE;
}
- return TRUE;
+ return TRUE;
}
-
- private function _security_check($username, $password)
+
+ public function gcaptcha_check($recaptchaResponse)
+ {
+ $url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . $this->config->item('gcaptcha_secret_key') . '&response=' . $recaptchaResponse . '&remoteip=' . $this->input->ip_address();
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ch, CURLOPT_URL, $url);
+ $result = curl_exec($ch);
+ curl_close($ch);
+
+ $status = json_decode($result, TRUE);
+
+ if(empty($status['success']))
+ {
+ $this->form_validation->set_message('gcaptcha_check', $this->lang->line('login_invalid_gcaptcha'));
+
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+ private function _security_check()
{
return preg_match('~\b(Copyright|(c)|©|All rights reserved|Developed|Crafted|Implemented|Made|Powered|Code|Design|unblockUI|blockUI|blockOverlay|hide|opacity)\b~i', file_get_contents(APPPATH . 'views/partial/footer.php'));
}
diff --git a/application/language/en/config_lang.php b/application/language/en/config_lang.php
index 4059131d3..a9561accf 100644
--- a/application/language/en/config_lang.php
+++ b/application/language/en/config_lang.php
@@ -118,6 +118,12 @@ $lang["config_financial_year_may"] = "1st of May";
$lang["config_financial_year_nov"] = "1st of November";
$lang["config_financial_year_oct"] = "1st of October";
$lang["config_financial_year_sep"] = "1st of September";
+$lang["config_gcaptcha_enable"] = "Login Page reCAPTCHA";
+$lang["config_gcaptcha_secret_key"] = "reCAPTCHA Secret Key";
+$lang["config_gcaptcha_secret_key_required"] = "reCAPTCHA Secret Key is a required field";
+$lang["config_gcaptcha_site_key"] = "reCAPTCHA Site Key";
+$lang["config_gcaptcha_site_key_required"] = "reCAPTCHA Site Key is a required field";
+$lang["config_gcaptcha_tooltip"] = "Protect the Login page with Google reCAPTCHA";
$lang["config_general"] = "General";
$lang["config_general_configuration"] = "General Configuration";
$lang["config_giftcard_number"] = "Gift Card Number";
diff --git a/application/language/en/login_lang.php b/application/language/en/login_lang.php
index 570437f41..e20309954 100644
--- a/application/language/en/login_lang.php
+++ b/application/language/en/login_lang.php
@@ -1,7 +1,10 @@
'default_sales_discount',
'class' => 'form-control input-sm required',
'type' => 'number',
- 'min'=>0,
- 'max'=>100,
- 'value'=>$this->config->item('default_sales_discount'))); ?>
+ 'min' => 0,
+ 'max' => 100,
+ 'value' => $this->config->item('default_sales_discount'))); ?>
%
-
+
+
+
+
+
+
-