diff --git a/app/Controllers/Attributes.php b/app/Controllers/Attributes.php index 07dad9d4d..ea73ae96c 100644 --- a/app/Controllers/Attributes.php +++ b/app/Controllers/Attributes.php @@ -3,7 +3,6 @@ namespace App\Controllers; use App\Models\Attribute; -use Config\Services; require_once('Secure_Controller.php'); @@ -38,7 +37,7 @@ class Attributes extends Secure_Controller */ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); diff --git a/app/Controllers/Cashups.php b/app/Controllers/Cashups.php index 518c8462b..4a77d2629 100644 --- a/app/Controllers/Cashups.php +++ b/app/Controllers/Cashups.php @@ -6,14 +6,13 @@ use App\Models\Cashup; use App\Models\Expense; use App\Models\Reports\Summary_payments; use Config\OSPOS; -use Config\Services; class Cashups extends Secure_Controller { - private Cashup $cashup; - private Expense $expense; - private Summary_payments $summary_payments; - private array $config; + private Cashup $cashup; + private Expense $expense; + private Summary_payments $summary_payments; + private array $config; public function __construct() { @@ -43,7 +42,7 @@ class Cashups extends Secure_Controller */ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); diff --git a/app/Controllers/Customers.php b/app/Controllers/Customers.php index 9ffbce291..7c3b8e723 100644 --- a/app/Controllers/Customers.php +++ b/app/Controllers/Customers.php @@ -125,8 +125,7 @@ class Customers extends Persons */ public function getSuggest(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->customer->get_search_suggestions($search); + $suggestions = $this->customer->get_search_suggestions($this->request->getGet('term'), 25,true); echo json_encode($suggestions); } @@ -136,8 +135,7 @@ class Customers extends Persons */ public function suggest_search(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->customer->get_search_suggestions($search, 25, false); + $suggestions = $this->customer->get_search_suggestions($this->request->getPost('term'), 25, false); echo json_encode($suggestions); } diff --git a/app/Controllers/Employees.php b/app/Controllers/Employees.php index 4b5542ca7..f4d4b5715 100644 --- a/app/Controllers/Employees.php +++ b/app/Controllers/Employees.php @@ -3,7 +3,6 @@ namespace App\Controllers; use App\Models\Module; -use Config\Services; /** * @@ -27,7 +26,7 @@ class Employees extends Persons */ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); @@ -52,8 +51,7 @@ class Employees extends Persons */ public function getSuggest(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->employee->get_search_suggestions($search, 25, true); + $suggestions = $this->employee->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), 25, true); echo json_encode($suggestions); } @@ -63,8 +61,7 @@ class Employees extends Persons */ public function suggest_search(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->employee->get_search_suggestions($search); + $suggestions = $this->employee->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); echo json_encode($suggestions); } diff --git a/app/Controllers/Expenses.php b/app/Controllers/Expenses.php index 7c037123b..cc8f635b1 100644 --- a/app/Controllers/Expenses.php +++ b/app/Controllers/Expenses.php @@ -5,7 +5,6 @@ namespace App\Controllers; use App\Models\Expense; use App\Models\Expense_category; use Config\OSPOS; -use Config\Services; class Expenses extends Secure_Controller { @@ -45,7 +44,7 @@ class Expenses extends Secure_Controller */ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); diff --git a/app/Controllers/Expenses_categories.php b/app/Controllers/Expenses_categories.php index e2a965e30..0ed4f4ed8 100644 --- a/app/Controllers/Expenses_categories.php +++ b/app/Controllers/Expenses_categories.php @@ -3,7 +3,6 @@ namespace App\Controllers; use App\Models\Expense_category; -use Config\Services; class Expenses_categories extends Secure_Controller //TODO: Is this class ever used? { @@ -31,7 +30,7 @@ class Expenses_categories extends Secure_Controller //TODO: Is this class ever u **/ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); diff --git a/app/Controllers/Giftcards.php b/app/Controllers/Giftcards.php index 61dc2a4f4..10c57ab3d 100644 --- a/app/Controllers/Giftcards.php +++ b/app/Controllers/Giftcards.php @@ -4,7 +4,6 @@ namespace App\Controllers; use App\Models\Giftcard; use Config\OSPOS; -use Config\Services; class Giftcards extends Secure_Controller { @@ -32,7 +31,7 @@ class Giftcards extends Secure_Controller */ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); @@ -58,8 +57,7 @@ class Giftcards extends Secure_Controller */ public function getSuggest(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->giftcard->get_search_suggestions($search, true); + $suggestions = $this->giftcard->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), true); echo json_encode($suggestions); } @@ -69,8 +67,7 @@ class Giftcards extends Secure_Controller */ public function suggest_search(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->giftcard->get_search_suggestions($search); + $suggestions = $this->giftcard->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); echo json_encode($suggestions); } diff --git a/app/Controllers/Item_kits.php b/app/Controllers/Item_kits.php index 6628e423a..ce7a62d72 100644 --- a/app/Controllers/Item_kits.php +++ b/app/Controllers/Item_kits.php @@ -7,7 +7,6 @@ use App\Libraries\Barcode_lib; use App\Models\Item; use App\Models\Item_kit; use App\Models\Item_kit_items; -use Config\Services; class Item_kits extends Secure_Controller { @@ -76,7 +75,7 @@ class Item_kits extends Secure_Controller */ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')) ?? ''; + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? ''; $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); @@ -101,8 +100,7 @@ class Item_kits extends Secure_Controller */ public function suggest_search(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->item_kit->get_search_suggestions($search); + $suggestions = $this->item_kit->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); echo json_encode($suggestions); } diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index bd0ae269d..55d40be35 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -94,11 +94,11 @@ class Items extends Secure_Controller **/ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); - $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); - $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); - $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); - $order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS); + $search = $this->request->getGet('search'); + $limit = $this->request->getGet('limit'); + $offset = $this->request->getGet('offset'); + $sort = $this->request->getGet('sort'); + $order = $this->request->getGet('order'); $this->item_lib->set_item_location($this->request->getGet('stock_location')); @@ -182,8 +182,7 @@ class Items extends Secure_Controller 'is_deleted' => $this->request->getPost('is_deleted') !== null ]; - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->item->get_search_suggestions($search, $options); + $suggestions = $this->item->get_search_suggestions($this->request->getPostGet('term'), $options); echo json_encode($suggestions); } @@ -195,8 +194,7 @@ class Items extends Secure_Controller */ public function getSuggest(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->item->get_search_suggestions($search, ['search_custom' => false, 'is_deleted' => false], true); + $suggestions = $this->item->get_search_suggestions($this->request->getGet('term'), ['search_custom' => false, 'is_deleted' => false], true); echo json_encode($suggestions); } diff --git a/app/Controllers/Persons.php b/app/Controllers/Persons.php index f0fb365ad..15f3d2cc8 100644 --- a/app/Controllers/Persons.php +++ b/app/Controllers/Persons.php @@ -3,7 +3,6 @@ namespace App\Controllers; use App\Models\Person; -use Config\Services; use function Tamtamchik\NameCase\str_name_case; abstract class Persons extends Secure_Controller @@ -35,8 +34,7 @@ abstract class Persons extends Secure_Controller */ public function getSuggest(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->person->get_search_suggestions($search); + $suggestions = $this->person->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); echo json_encode($suggestions); } diff --git a/app/Controllers/Receivings.php b/app/Controllers/Receivings.php index e870aec58..f5d64d083 100644 --- a/app/Controllers/Receivings.php +++ b/app/Controllers/Receivings.php @@ -12,7 +12,6 @@ use App\Models\Receiving; use App\Models\Stock_location; use App\Models\Supplier; use Config\OSPOS; -use Config\Services; use ReflectionException; class Receivings extends Secure_Controller @@ -61,9 +60,8 @@ class Receivings extends Secure_Controller */ public function getItemSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('term')); - $suggestions = $this->item->get_search_suggestions($search, ['search_custom' => false, 'is_deleted' => false], true); - $suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($search)); + $suggestions = $this->item->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), ['search_custom' => false, 'is_deleted' => false], true); + $suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS))); echo json_encode($suggestions); } @@ -76,9 +74,8 @@ class Receivings extends Secure_Controller */ public function getStockItemSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('term')); - $suggestions = $this->item->get_stock_search_suggestions($search, ['search_custom' => false, 'is_deleted' => false], true); - $suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($search)); + $suggestions = $this->item->get_stock_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), ['search_custom' => false, 'is_deleted' => false], true); + $suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS))); echo json_encode($suggestions); } diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index 94591f393..a663fb973 100644 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -20,7 +20,7 @@ use App\Models\Stock_location; use App\Models\Tokens\Token_invoice_count; use App\Models\Tokens\Token_customer; use App\Models\Tokens\Token_invoice_sequence; -use Config\Services; +use CodeIgniter\Config\Services; use Config\OSPOS; use ReflectionException; use stdClass; @@ -185,9 +185,7 @@ class Sales extends Secure_Controller public function getItemSearch(): void { $suggestions = []; - $receipt = $search = $this->request->getGet('term') != '' - ? Services::htmlPurifier()->purify($this->request->getGet('term')) - : null; + $receipt = $search = $this->request->getGet('term') != '' ? $this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS) : null; if($this->sale_lib->get_mode() == 'return' && $this->sale->is_valid_receipt($receipt)) { @@ -205,9 +203,7 @@ class Sales extends Secure_Controller */ public function suggest_search(): void { - $search = $this->request->getPost('term') != '' - ? Services::htmlPurifier()->purify($this->request->getPost('term')) - : null; + $search = $this->request->getPost('term') != '' ? $this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS) : null; $suggestions = $this->sale->get_search_suggestions($search); diff --git a/app/Controllers/Suppliers.php b/app/Controllers/Suppliers.php index d436b5c17..82c6ac9fa 100644 --- a/app/Controllers/Suppliers.php +++ b/app/Controllers/Suppliers.php @@ -3,7 +3,6 @@ namespace App\Controllers; use App\Models\Supplier; -use Config\Services; class Suppliers extends Persons { @@ -45,7 +44,7 @@ class Suppliers extends Persons **/ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); @@ -71,8 +70,7 @@ class Suppliers extends Persons **/ public function getSuggest(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('term')); - $suggestions = $this->supplier->get_search_suggestions($search, true); + $suggestions = $this->supplier->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), true); echo json_encode($suggestions); } @@ -82,8 +80,7 @@ class Suppliers extends Persons */ public function suggest_search(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->supplier->get_search_suggestions($search, false); + $suggestions = $this->supplier->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), false); echo json_encode($suggestions); } diff --git a/app/Controllers/Tax_categories.php b/app/Controllers/Tax_categories.php index 5b417369b..f8608fc26 100644 --- a/app/Controllers/Tax_categories.php +++ b/app/Controllers/Tax_categories.php @@ -3,7 +3,6 @@ namespace App\Controllers; use App\Models\Tax_category; -use Config\Services; /** * @property tax_category tax_category @@ -36,7 +35,7 @@ class Tax_categories extends Secure_Controller */ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); diff --git a/app/Controllers/Tax_codes.php b/app/Controllers/Tax_codes.php index 24e48ee23..fd7f868d7 100644 --- a/app/Controllers/Tax_codes.php +++ b/app/Controllers/Tax_codes.php @@ -3,7 +3,6 @@ namespace App\Controllers; use App\Models\Tax_code; -use Config\Services; /** * @property tax_code tax_code @@ -46,7 +45,7 @@ class Tax_codes extends Secure_Controller */ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); diff --git a/app/Controllers/Tax_jurisdictions.php b/app/Controllers/Tax_jurisdictions.php index f094b833b..0c1c77fdb 100644 --- a/app/Controllers/Tax_jurisdictions.php +++ b/app/Controllers/Tax_jurisdictions.php @@ -3,7 +3,6 @@ namespace App\Controllers; use App\Models\Tax_jurisdiction; -use Config\Services; /** * @property tax_jurisdiction tax_jurisdiction @@ -39,7 +38,7 @@ class Tax_jurisdictions extends Secure_Controller */ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); diff --git a/app/Controllers/Taxes.php b/app/Controllers/Taxes.php index 0f9b8de7d..219f82daa 100644 --- a/app/Controllers/Taxes.php +++ b/app/Controllers/Taxes.php @@ -9,7 +9,6 @@ use App\Models\Tax_category; use App\Models\Tax_code; use App\Models\Tax_jurisdiction; use Config\OSPOS; -use Config\Services; class Taxes extends Secure_Controller { @@ -83,7 +82,7 @@ class Taxes extends Secure_Controller */ public function getSearch(): void { - $search = Services::htmlPurifier()->purify($this->request->getGet('search')); + $search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); $offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT); $sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS); @@ -107,8 +106,7 @@ class Taxes extends Secure_Controller */ public function suggest_search(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->tax->get_search_suggestions($search); //TODO: There is no get_search_suggestions function in the tax model + $suggestions = $this->tax->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); //TODO: There is no get_search_suggestions function in the tax model echo json_encode($suggestions); } @@ -120,8 +118,7 @@ class Taxes extends Secure_Controller */ public function suggest_tax_categories(): void { - $search = Services::htmlPurifier()->purify($this->request->getPost('term')); - $suggestions = $this->tax_category->get_tax_category_suggestions($search); + $suggestions = $this->tax_category->get_tax_category_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); echo json_encode($suggestions); } @@ -461,8 +458,7 @@ class Taxes extends Secure_Controller */ public function getSuggestTaxCodes(): void { - $search = Services::htmlPurifier()->purify($this->request->getPostGet('term')); - $suggestions = $this->tax_code->get_tax_codes_search_suggestions($search); + $suggestions = $this->tax_code->get_tax_codes_search_suggestions($this->request->getPostGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); echo json_encode($suggestions); }