From 13a14ec31094f686cc80fa5678b288cf1e413abe Mon Sep 17 00:00:00 2001 From: Steve Ireland Date: Wed, 1 Mar 2023 08:10:14 -0500 Subject: [PATCH] Remove grunt045 from zipped opensourcepos file. Also fix the call to array_walker since the parameters (even if not used) are validated in PHP 8. --- Gruntfile.js | 2 +- app/Controllers/Config.php | 21 +++++++++++++++++++-- app/Controllers/Customers.php | 11 ++++++++++- app/Controllers/Home.php | 3 ++- app/Helpers/locale_helper.php | 4 ++-- app/Libraries/Email_lib.php | 8 +++++++- app/Libraries/Mailchimp_lib.php | 11 ++++++++--- app/Libraries/Sms_lib.php | 8 +++++++- app/Models/Employee.php | 4 +--- 9 files changed, 57 insertions(+), 15 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index dfc23ddb2..26129f641 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,7 +7,7 @@ module.exports = function(grunt) { 'vendor/**', 'app/**', '!/tests', - '!/grunt045', + '!grunt045**', '!/public/images/menubar/png/', '!/public/dist/bootswatch/', '/public/dist/bootswatch/*/*.css', diff --git a/app/Controllers/Config.php b/app/Controllers/Config.php index 13e8d407b..5fdaa99c5 100644 --- a/app/Controllers/Config.php +++ b/app/Controllers/Config.php @@ -283,8 +283,25 @@ class Config extends Secure_Controller { $encrypter = Services::encrypter(); - $data['mailchimp']['api_key'] = $encrypter->decrypt($this->config['mailchimp_api_key'] ?? ''); - $data['mailchimp']['list_id'] = $encrypter->decrypt($this->config['mailchimp_list_id'] ?? ''); + $mailchimp_api_key = $this->config['mailchimp_api_key']; + if(!empty($mailchimp_api_key)) + { + $data['mailchimp']['api_key'] = $encrypter->decrypt($mailchimp_api_key); + } + else + { + $data['mailchimp']['api_key'] = ''; + } + + $mailchimp_list_id = $this->config['mailchimp_list_id']; + if(!empty($mailchimp_list_id)) + { + $data['mailchimp']['list_id'] = $encrypter->decrypt($mailchimp_list_id); + } + else + { + $data['mailchimp']['list_id'] = ''; + } } else { diff --git a/app/Controllers/Customers.php b/app/Controllers/Customers.php index b23712897..c5ad9dc05 100644 --- a/app/Controllers/Customers.php +++ b/app/Controllers/Customers.php @@ -42,7 +42,16 @@ class Customers extends Persons $encrypter = Services::encrypter(); - $this->_list_id = $encrypter->decrypt($this->config['mailchimp_list_id']); + $mailchimp_list_id = $this->config['mailchimp_list_id']; + + if(!empty($mailchimp_list_id)) + { + $this->_list_id = $encrypter->decrypt($this->config['mailchimp_list_id']); + } + else + { + $this->_list_id = ""; + } } public function getIndex(): void diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 2f11069dd..b27cf89d9 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -15,9 +15,10 @@ class Home extends Secure_Controller echo view('home/home'); } - public function getLogout(): void + public function getLogout(): \CodeIgniter\HTTP\RedirectResponse { $this->employee->logout(); + return redirect()->to('login'); } /** diff --git a/app/Helpers/locale_helper.php b/app/Helpers/locale_helper.php index 5e87b8106..7ee794811 100644 --- a/app/Helpers/locale_helper.php +++ b/app/Helpers/locale_helper.php @@ -593,14 +593,14 @@ function valid_decimal(string $decimal): bool //TODO: need a better name for $de function encode_array(array $data): array { - array_walk($data, function(&$value, &$key) { $value = rawurlencode($value);}); + array_walk($data, function(&$value, $key) { $value = rawurlencode($value);}); return $data; } function decode_array(array $data): array { - array_walk($data, function(&$value, &$key) { $value = rawurldecode($value);}); + array_walk($data, function(&$value, $key) { $value = rawurldecode($value);}); return $data; } diff --git a/app/Libraries/Email_lib.php b/app/Libraries/Email_lib.php index 2abece36b..5ef0f6d21 100644 --- a/app/Libraries/Email_lib.php +++ b/app/Libraries/Email_lib.php @@ -25,8 +25,14 @@ class Email_lib { $this->email = new Email(); $this->config = config('OSPOS')->settings; + $encrypter = Services::encrypter(); + $smtp_pass = $this->config['smtp_pass']; + if(!empty($smtp_pass)) + { + $smtp_pass = $encrypter->decrypt($smtp_pass); + } $email_config = [ 'mailtype' => 'html', @@ -36,7 +42,7 @@ class Email_lib 'mailpath' => $this->config['mailpath'], 'smtp_host' => $this->config['smtp_host'], 'smtp_user' => $this->config['smtp_user'], - 'smtp_pass' => $encrypter->decrypt($this->config['smtp_pass']), + 'smtp_pass' => $smtp_pass, 'smtp_port' => $this->config['smtp_port'], 'smtp_timeout' => $this->config['smtp_timeout'], 'smtp_crypto' => $this->config['smtp_crypto'] diff --git a/app/Libraries/Mailchimp_lib.php b/app/Libraries/Mailchimp_lib.php index a36efe0df..cfd3c666d 100644 --- a/app/Libraries/Mailchimp_lib.php +++ b/app/Libraries/Mailchimp_lib.php @@ -41,9 +41,14 @@ class MailchimpConnector $encrypter = Services::encrypter(); - $this->_api_key = empty($api_key) - ? $encrypter->decrypt($config['mailchimp_api_key']) //TODO: Hungarian notation - : $api_key; //TODO: Hungarian notation + $mailchimp_api_key = $config['mailchimp_api_key']; + + if(!empty($mailchimp_api_key)) + { + $this->_api_key = empty($api_key) + ? $encrypter->decrypt($mailchimp_api_key) //TODO: Hungarian notation + : $api_key; //TODO: Hungarian notation + } if(!empty($this->_api_key)) //TODO: Hungarian notation { diff --git a/app/Libraries/Sms_lib.php b/app/Libraries/Sms_lib.php index adfabc6ab..01503d3c8 100644 --- a/app/Libraries/Sms_lib.php +++ b/app/Libraries/Sms_lib.php @@ -26,10 +26,16 @@ class Sms_lib public function sendSMS(int $phone, string $message): bool { $config = config('OSPOS')->settings; + $encrypter = Services::encrypter(); + $password = $config['msg_pwd']; + if(!empty($password)) + { + $password = $encrypter->decrypt($password); + } + $username = $config['msg_uid']; - $password = $encrypter->decrypt($config['msg_pwd']); $originator = $config['msg_src']; $response = FALSE; diff --git a/app/Models/Employee.php b/app/Models/Employee.php index 0ee5df93b..07bfaee34 100644 --- a/app/Models/Employee.php +++ b/app/Models/Employee.php @@ -408,11 +408,9 @@ class Employee extends Person /** * Logs out a user by destroying all session data and redirect to log in */ - public function logout(): RedirectResponse + public function logout() { session()->destroy(); - - return redirect()->to('login'); } /**