From 4760bdada4360adda015d4c10fd3d3a69f2a82df Mon Sep 17 00:00:00 2001 From: Khurshid Alam Date: Tue, 1 Nov 2022 21:55:53 +0600 Subject: [PATCH] Security Update --- core/functions.php | 83 ++++++++++++------- module/accounts/ajax.php | 6 +- module/expenses/ajax.php | 4 +- module/incomes/ajax.php | 2 +- module/ledgers/ajax.php | 36 ++++---- module/loan-management/ajax.php | 2 +- module/my-shop/ajax.php | 8 +- module/peoples/ajax.php | 12 +-- module/production/ajax.php | 83 +++++++++++++++++-- module/production/link-raw-materials.php | 2 +- module/products/ajax.php | 14 ++-- module/products/attach-sub-product.php | 2 +- module/products/edit-product.php | 4 +- module/reports/ajax.php | 54 +++++------- module/reports/ajax_back.php | 6 +- .../customer-report-single.php | 2 +- .../product-report/product-report-single.php | 2 +- module/sales/ajax.php | 4 +- module/sales/edit-sale.php | 2 +- module/settings/ajax.php | 8 +- module/stock-management/ajax.php | 12 +-- module/stock-management/edit-purchase.php | 2 +- 22 files changed, 213 insertions(+), 137 deletions(-) diff --git a/core/functions.php b/core/functions.php index 31f892c..ed5de85 100644 --- a/core/functions.php +++ b/core/functions.php @@ -18,6 +18,16 @@ function safe_input($data, $encoding = true) { return $data; } +/** + * Convert all applicable characters to HTML entities + * + * From PHP 8.1.0 the default flag is ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 + * So, we make this for all version + */ +function safe_entities($data) { + return htmlentities($data, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401); +} + /** * Determine the http or https and append with the domain. * @@ -2374,10 +2384,11 @@ function send_sms($number, $msg) { global $table_prefeix; - $url = "http://example.com/api.php"; + //$url = "http://66.45.237.70/maskingapi.php"; + $url = "http://66.45.237.70/api.php"; $data= array( - 'username'=>"username", - 'password'=>"password", + 'username'=>"Royal", + 'password'=>"CZXAPHK8", //'senderid'=> "The Royal", 'number'=>$number, 'message'=>$msg @@ -2777,40 +2788,48 @@ function near_unit_qty($product_id, $qty, $unit) { ) )); + + if($getData !== false) { + + $totalBaseQty = $qty; + $remainQty = 0; + $finalUnitName = ""; + $finalQtyBasedOnUnit = 0; + + // Generate the base qty based on unit + foreach($getData["data"] as $pKey => $pVal ) { + + if( $pVal["product_unit"] === $unit) { + + $totalBaseQty *= $pVal["base_qnt"]; + break; + + } - $totalBaseQty = $qty; - $remainQty = 0; - $finalUnitName = ""; - $finalQtyBasedOnUnit = 0; - - // Generate the base qty based on unit - foreach($getData["data"] as $pKey => $pVal ) { - - if( $pVal["product_unit"] === $unit) { - - $totalBaseQty *= $pVal["base_qnt"]; - break; - } - - } - - // Now get the unit which base_qnt is grater then or equal to unitDevider - foreach($getData["data"] as $pKey => $pVal ) { - - if( $pVal["base_qnt"] <= $totalBaseQty) { - - $finalUnitName = $pVal["product_unit"]; - $remainQty = ($totalBaseQty % $pVal["base_qnt"]); - $finalQtyBasedOnUnit = ($totalBaseQty - $remainQty) / $pVal["base_qnt"]; - break; - + + // Now get the unit which base_qnt is grater then or equal to unitDevider + foreach($getData["data"] as $pKey => $pVal ) { + + if( $pVal["base_qnt"] <= $totalBaseQty) { + + $finalUnitName = $pVal["product_unit"]; + $remainQty = ($totalBaseQty % $pVal["base_qnt"]); + $finalQtyBasedOnUnit = ($totalBaseQty - $remainQty) / $pVal["base_qnt"]; + break; + + } + } - - } - return $finalQtyBasedOnUnit . " " . $finalUnitName . ( $remainQty > 0 ? ", " . near_unit_qty($product_id, $remainQty, $unit) : ""); + return $finalQtyBasedOnUnit . " " . $finalUnitName . ( $remainQty > 0 ? ", " . near_unit_qty($product_id, $remainQty, $unit) : ""); + + } else { + + return $qty . " " . $unit; + + } } diff --git a/module/accounts/ajax.php b/module/accounts/ajax.php index 7f6e674..055d760 100644 --- a/module/accounts/ajax.php +++ b/module/accounts/ajax.php @@ -333,7 +333,7 @@ - + @@ -692,7 +692,7 @@ - "> + "> @@ -1242,7 +1242,7 @@ " class="form-control datePicker" required> - "> + "> diff --git a/module/expenses/ajax.php b/module/expenses/ajax.php index 2bc975d..623f344 100644 --- a/module/expenses/ajax.php +++ b/module/expenses/ajax.php @@ -232,7 +232,7 @@
" class="form-control"> - "> + ">
@@ -1867,7 +1867,7 @@ function (data, status) {
- "> + "> ">
diff --git a/module/incomes/ajax.php b/module/incomes/ajax.php index 75413d6..be4d549 100644 --- a/module/incomes/ajax.php +++ b/module/incomes/ajax.php @@ -1464,7 +1464,7 @@ function(data, status) { - "> + "> diff --git a/module/ledgers/ajax.php b/module/ledgers/ajax.php index 6550cda..fdcb221 100644 --- a/module/ledgers/ajax.php +++ b/module/ledgers/ajax.php @@ -44,7 +44,7 @@ sum(payment_items_amount) as total_salary_paid_before_filtered_date from {$table_prefeix}payment_items where is_trash = 0 and payment_items_type != 'Bill' and payment_items_date < '{$dateRange[0]}' group by payment_items_employee ) as payments on payment_items_employee = emp_id - where emp_id = {$emp_id} + where emp_id = '{$emp_id}' "); @@ -53,7 +53,7 @@ ( select 1 as sortby, - {$emp_id} as empl_id, + '{$emp_id}' as empl_id, '' as ledger_date, 'Opening/Previous Balance' as description, 0 as debit, @@ -89,7 +89,7 @@ from {$table_prefeix}payment_items where is_trash = 0 and payment_items_type != 'Bill' and payment_items_date between '{$dateRange[0]}' and '{$dateRange[1]}' group by payment_items_id ) as get_data - where empl_id = {$emp_id} + where empl_id = '{$emp_id}' order by ledger_date, sortby "); @@ -253,7 +253,7 @@ WHERE is_trash = 0 and capital_received_date < '{$dateRange[0]}' group by capital_accounts ) as capital on capital.capital_accounts = accounts.accounts_id - where accounts_id = {$account_id} + where accounts_id = '{$account_id}' "); @@ -261,7 +261,7 @@ SELECT account_id, ledger_date_time, sql_join_id, sql_join_id_two, description, debit, credit, @balance := ( @balance + debit ) - credit as balance from ( SELECT - {$account_id} as account_id, + '{$account_id}' as account_id, '' as ledger_date_time, '' as sql_join_id, '' as sql_join_id_two, @@ -429,7 +429,7 @@ from {$table_prefeix}capital as capital where capital.is_trash = 0 and capital_received_date between '{$dateRange[0]}' and '{$dateRange[1]}' ) as getData - where account_id = {$account_id} + where account_id = '{$account_id}' order by ledger_date_time ASC "); @@ -508,7 +508,7 @@ sum(journal_records_payment_amount) as journal_records_incoming_payment_amount_before_filtered_date from {$table_prefeix}journal_records where is_trash = 0 and journal_records_payments_type = 'Incoming' and date(journal_records_datetime) < '{$dateRange[0]}' group by journal_records_journal_id ) as journal_records_Incoming on journal_records_Incoming.journal_records_journal_id = journals_id - where journals_id = {$journal_id} + where journals_id = '{$journal_id}' "); @@ -517,7 +517,7 @@ ( select 1 as sortby, - {$journal_id} as journals_id, + '{$journal_id}' as journals_id, '' as ledger_date, 'Opening/Previous Balance' as description, 0 as debit, @@ -543,7 +543,7 @@ from {$table_prefeix}journal_records as journal_records_outgoing where journal_records_outgoing.is_trash = 0 and journal_records_outgoing.journal_records_payments_type = 'Outgoing' and date(journal_records_outgoing.journal_records_datetime) between '{$dateRange[0]}' and '{$dateRange[1]}' group by journal_records_outgoing.journal_records_id ) as get_data - where journals_id = {$journal_id} + where journals_id = '{$journal_id}' order by ledger_date, sortby "); @@ -631,7 +631,7 @@ sum(payments_return_amount) as total_payment_return_before_filtered_date from {$table_prefeix}payments_return where is_trash = 0 and payments_return_type = 'Outgoing' and date(payments_return_date) < '{$dateRange[0]}' group by payments_return_customer_id ) as payment_return on payments_return_customer_id = customer_id - where customer_id = {$customer_id} + where customer_id = '{$customer_id}' "); $getData = easySelectD(" @@ -639,7 +639,7 @@ ( select 1 as sortby, - {$customer_id} as customer_id, + '{$customer_id}' as customer_id, '' as ledger_date, 'Opening/Previous Balance' as description, 0 as debit, @@ -713,7 +713,7 @@ incomes_amount as credit from {$table_prefeix}incomes where is_trash = 0 and incomes_date between '{$dateRange[0]}' and '{$dateRange[1]}' group by incomes_id ) as get_data - where customer_id = {$customer_id} + where customer_id = '{$customer_id}' order by ledger_date, sortby "); @@ -803,7 +803,7 @@ sum(payments_return_amount) as total_payment_return_before_filtered_date from {$table_prefeix}payments_return where is_trash = 0 and payments_return_type = 'Incoming' and date(payments_return_date) < '{$dateRange[0]}' group by payments_return_company_id ) as payment_return on payments_return_company_id = company_id - where company_id = {$company_id} + where company_id = '{$company_id}' "); //var_dump($previous_balance); @@ -813,7 +813,7 @@ ( select 1 as sortby, - {$company_id} as company_id, + '{$company_id}' as company_id, '' as ledger_date, 'Opening/Previous Balance' as description, 0 as debit, @@ -901,7 +901,7 @@ payments_return_amount as credit from {$table_prefeix}payments_return where is_trash = 0 and payments_return_type = 'Incoming' and date(payments_return_date) between '{$dateRange[0]}' and '{$dateRange[1]}' group by company_id ) as get_data - where company_id = {$company_id} + where company_id = '{$company_id}' order by ledger_date, sortby "); @@ -982,7 +982,7 @@ sum(payments_return_amount) as total_return_before_filtered_date from {$table_prefeix}payments_return where is_trash = 0 and date(payments_return_date) < '{$dateRange[0]}' group by payments_return_emp_id ) as payment_return on payments_return_emp_id = emp_id - where emp_id = {$emp_id} + where emp_id = '{$emp_id}' "); @@ -991,7 +991,7 @@ ( select 1 as sortby, - {$emp_id} as empl_id, + '{$emp_id}' as empl_id, '' as ledger_date, 'Opening/Previous Balance' as description, 0 as debit, @@ -1036,7 +1036,7 @@ from {$table_prefeix}payments_return where is_trash = 0 and date(payments_return_date) between '{$dateRange[0]}' and '{$dateRange[1]}' group by payments_return_id ) as get_data - where empl_id = {$emp_id} + where empl_id = '{$emp_id}' order by ledger_date, sortby "); diff --git a/module/loan-management/ajax.php b/module/loan-management/ajax.php index 2610e2b..a78cd7b 100644 --- a/module/loan-management/ajax.php +++ b/module/loan-management/ajax.php @@ -300,7 +300,7 @@ - "> + ">
diff --git a/module/my-shop/ajax.php b/module/my-shop/ajax.php index c900167..9f8c77d 100644 --- a/module/my-shop/ajax.php +++ b/module/my-shop/ajax.php @@ -301,8 +301,8 @@ - "> - "> + "> + ">
@@ -1210,7 +1210,7 @@ " class="form-control"> - "> + ">
@@ -2193,7 +2193,7 @@ function(data, status) { - "> + ">
diff --git a/module/peoples/ajax.php b/module/peoples/ajax.php index 6330302..a4e15b5 100644 --- a/module/peoples/ajax.php +++ b/module/peoples/ajax.php @@ -485,7 +485,7 @@ - +
- +