mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
replace all instances of mysqli_fetch_array with mysqli_fetch_assoc for better performance and memory usage
This commit is contained in:
@@ -38,7 +38,7 @@ if (isset($_GET['delete_api_key'])) {
|
||||
$api_key_id = intval($_GET['delete_api_key']);
|
||||
|
||||
// Get API Key Name
|
||||
$row = mysqli_fetch_array(mysqli_query($mysqli,"SELECT api_key_name, api_key_client_id FROM api_keys WHERE api_key_id = $api_key_id"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT api_key_name, api_key_client_id FROM api_keys WHERE api_key_id = $api_key_id"));
|
||||
$api_key_name = sanitizeInput($row['api_key_name']);
|
||||
$client_id = intval($row['api_key_client_id']);
|
||||
|
||||
@@ -64,9 +64,9 @@ if (isset($_POST['bulk_delete_api_keys'])) {
|
||||
foreach ($_POST['api_key_ids'] as $api_key_id) {
|
||||
|
||||
$api_key_id = intval($api_key_id);
|
||||
|
||||
|
||||
// Get API Key Name
|
||||
$row = mysqli_fetch_array(mysqli_query($mysqli,"SELECT api_key_name, api_key_client_id FROM api_keys WHERE api_key_id = $api_key_id"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT api_key_name, api_key_client_id FROM api_keys WHERE api_key_id = $api_key_id"));
|
||||
$api_key_name = sanitizeInput($row['api_key_name']);
|
||||
$client_id = intval($row['api_key_client_id']);
|
||||
|
||||
|
||||
@@ -307,11 +307,11 @@ if (isset($_POST['backup_master_key'])) {
|
||||
$password = $_POST['password'];
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM users WHERE user_id = $session_user_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
|
||||
if (password_verify($password, $row['user_password'])) {
|
||||
$site_encryption_master_key = decryptUserSpecificKey($row['user_specific_encryption_ciphertext'], $password);
|
||||
|
||||
|
||||
logAction("Master Key", "Download", "$session_name retrieved the master encryption key");
|
||||
|
||||
appNotify("Master Key", "$session_name retrieved the master encryption key");
|
||||
@@ -320,13 +320,12 @@ if (isset($_POST['backup_master_key'])) {
|
||||
echo "<br>Master encryption key:<br>";
|
||||
echo "<b>$site_encryption_master_key</b>";
|
||||
echo "<br>==============================";
|
||||
|
||||
|
||||
} else {
|
||||
logAction("Master Key", "Download", "$session_name attempted to retrieve the master encryption key but failed");
|
||||
|
||||
flash_alert("Incorrect password.", 'error');
|
||||
|
||||
|
||||
redirect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,12 @@ if (isset($_POST['edit_category'])) {
|
||||
}
|
||||
|
||||
if (isset($_GET['archive_category'])) {
|
||||
|
||||
|
||||
$category_id = intval($_GET['archive_category']);
|
||||
|
||||
// Get Category Name and Type for logging
|
||||
$sql = mysqli_query($mysqli,"SELECT category_name, category_type FROM categories WHERE category_id = $category_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$category_name = sanitizeInput($row['category_name']);
|
||||
$category_type = sanitizeInput($row['category_type']);
|
||||
|
||||
@@ -59,12 +59,12 @@ if (isset($_GET['archive_category'])) {
|
||||
}
|
||||
|
||||
if (isset($_GET['unarchive_category'])) {
|
||||
|
||||
|
||||
$category_id = intval($_GET['unarchive_category']);
|
||||
|
||||
// Get Category Name and Type for logging
|
||||
$sql = mysqli_query($mysqli,"SELECT category_name, category_type FROM categories WHERE category_id = $category_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$category_name = sanitizeInput($row['category_name']);
|
||||
$category_type = sanitizeInput($row['category_type']);
|
||||
|
||||
@@ -79,12 +79,12 @@ if (isset($_GET['unarchive_category'])) {
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_category'])) {
|
||||
|
||||
|
||||
$category_id = intval($_GET['delete_category']);
|
||||
|
||||
// Get Category Name and Type for logging
|
||||
$sql = mysqli_query($mysqli,"SELECT category_name, category_type FROM categories WHERE category_id = $category_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$category_name = sanitizeInput($row['category_name']);
|
||||
$category_type = sanitizeInput($row['category_type']);
|
||||
|
||||
|
||||
@@ -48,12 +48,12 @@ if (isset($_POST['edit_custom_link'])) {
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_custom_link'])) {
|
||||
|
||||
|
||||
$custom_link_id = intval($_GET['delete_custom_link']);
|
||||
|
||||
// Get Custom Link name and uri for logging
|
||||
$sql = mysqli_query($mysqli,"SELECT custom_link_name, custom_link_uri FROM custom_links WHERE custom_link_id = $custom_link_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$custom_link_name = sanitizeInput($row['custom_link_name']);
|
||||
$custom_link_uri = sanitizeInput($row['custom_link_uri']);
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
|
||||
|
||||
if (isset($_GET['delete_saved_payment'])) {
|
||||
|
||||
|
||||
validateCSRFToken($_GET['csrf_token']);
|
||||
|
||||
$saved_payment_id = intval($_GET['delete_saved_payment']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "
|
||||
SELECT
|
||||
SELECT
|
||||
client_saved_payment_methods.saved_payment_id,
|
||||
client_saved_payment_methods.saved_payment_client_id,
|
||||
client_saved_payment_methods.saved_payment_provider_id,
|
||||
@@ -27,7 +27,7 @@ if (isset($_GET['delete_saved_payment'])) {
|
||||
WHERE client_saved_payment_methods.saved_payment_id = $saved_payment_id"
|
||||
);
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$client_id = intval($row['saved_payment_client_id']);
|
||||
$provider_id = intval($row['saved_payment_provider_id']);
|
||||
$payment_provider_name = nullable_htmlentities($row['payment_provider_name']);
|
||||
@@ -62,9 +62,9 @@ if (isset($_GET['delete_saved_payment'])) {
|
||||
// SQL Cascade delete will Remove All Associated Auto Payment Methods on recurring invoices in the recurring payments table.
|
||||
|
||||
logAction("Payment Provider", "Update", "$session_name deleted saved payment method $saved_payment_description (PM: $payment_method)", $client_id);
|
||||
|
||||
|
||||
flash_alert("Payment method <strong>$saved_payment_description</strong> removed", 'error');
|
||||
|
||||
|
||||
redirect();
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ if (isset($_POST['edit_company'])) {
|
||||
$tax_id = sanitizeInput($_POST['tax_id']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT company_logo FROM companies WHERE company_id = 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$existing_file_name = sanitizeInput($row['company_logo']);
|
||||
|
||||
// Company logo
|
||||
@@ -55,7 +55,7 @@ if (isset($_POST['edit_company'])) {
|
||||
if (isset($_GET['remove_company_logo'])) {
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT company_logo FROM companies");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$company_logo = $row['company_logo']; // FileSystem Operation Logo is already sanitized
|
||||
|
||||
unlink("../uploads/settings/$company_logo");
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
|
||||
|
||||
if (isset($_GET['stripe_remove_pm'])) {
|
||||
|
||||
|
||||
validateCSRFToken($_GET['csrf_token']);
|
||||
|
||||
if (!$config_stripe_enable) {
|
||||
@@ -34,21 +34,21 @@ if (isset($_GET['stripe_remove_pm'])) {
|
||||
// Remove Auto Pay on recurring invoices that are stripe
|
||||
$sql_recurring_invoices = mysqli_query($mysqli, "SELECT recurring_invoice_id FROM recurring_invoices WHERE recurring_invoice_client_id = $client_id");
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_recurring_invoices)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_recurring_invoices)) {
|
||||
$recurring_invoice_id = intval($row['recurring_invoice_id']);
|
||||
mysqli_query($mysqli, "DELETE FROM recurring_payments WHERE recurring_payment_method = 'Stripe' AND recurring_payment_recurring_invoice_id = $recurring_invoice_id");
|
||||
}
|
||||
|
||||
logAction("Stripe", "Update", "$session_name deleted saved Stripe payment method (PM: $payment_method)", $client_id);
|
||||
|
||||
|
||||
flash_alert("Payment method removed", 'error');
|
||||
|
||||
|
||||
redirect();
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['stripe_reset_customer'])) {
|
||||
|
||||
|
||||
validateCSRFToken($_GET['csrf_token']);
|
||||
|
||||
$client_id = intval($_GET['client_id']);
|
||||
@@ -59,7 +59,7 @@ if (isset($_GET['stripe_reset_customer'])) {
|
||||
// Remove Auto Pay on recurring invoices that are stripe
|
||||
$sql_recurring_invoices = mysqli_query($mysqli, "SELECT recurring_invoice_id FROM recurring_invoices WHERE recurring_invoice_client_id = $client_id");
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_recurring_invoices)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_recurring_invoices)) {
|
||||
$recurring_invoice_id = intval($row['recurring_invoice_id']);
|
||||
mysqli_query($mysqli, "DELETE FROM recurring_payments WHERE recurring_payment_method = 'Stripe' AND recurring_payment_recurring_invoice_id = $recurring_invoice_id");
|
||||
}
|
||||
@@ -67,7 +67,7 @@ if (isset($_GET['stripe_reset_customer'])) {
|
||||
logAction("Stripe", "Delete", "$session_name reset Stripe settings for client", $client_id);
|
||||
|
||||
flash_alert("Reset client Stripe settings", 'error');
|
||||
|
||||
|
||||
redirect();
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ if (isset($_GET['delete_software_template'])) {
|
||||
|
||||
// Get Software Template Name for logging and alert message
|
||||
$sql = mysqli_query($mysqli,"SELECT software_template_name FROM software_templates WHERE software_template_id = $software_template_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$software_template_name = sanitizeInput($row['software_template_name']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM software_templates WHERE software_template_id = $software_template_id");
|
||||
|
||||
@@ -21,7 +21,7 @@ if (isset($_GET['update'])) {
|
||||
if ($config_telemetry > 0 OR $config_telemetry = 2) {
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM companies WHERE company_id = 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
|
||||
$company_name = sanitizeInput($row['company_name']);
|
||||
$website = sanitizeInput($row['company_website']);
|
||||
|
||||
@@ -53,7 +53,7 @@ if (isset($_POST['add_user'])) {
|
||||
mysqli_query($mysqli, "INSERT INTO user_settings SET user_id = $user_id, user_config_force_mfa = $force_mfa");
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM companies WHERE company_id = 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$company_name = sanitizeInput($row['company_name']);
|
||||
|
||||
// Sanitize Config vars from load_global_settings.php
|
||||
@@ -118,7 +118,7 @@ if (isset($_POST['edit_user'])) {
|
||||
|
||||
// Get current Avatar
|
||||
$sql = mysqli_query($mysqli, "SELECT user_avatar FROM users WHERE user_id = $user_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$existing_file_name = sanitizeInput($row['user_avatar']);
|
||||
|
||||
$extended_log_description = '';
|
||||
@@ -148,7 +148,7 @@ if (isset($_POST['edit_user'])) {
|
||||
// Set Avatar
|
||||
mysqli_query($mysqli, "UPDATE users SET user_avatar = '$new_file_name' WHERE user_id = $user_id");
|
||||
$extended_alert_description = '. File successfully uploaded.';
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,8 +353,8 @@ if (isset($_POST['ir_reset_user_password'])) {
|
||||
// Confirm logged-in user password, for security
|
||||
$admin_password = $_POST['admin_password'];
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM users WHERE user_id = $session_user_id");
|
||||
$userRow = mysqli_fetch_array($sql);
|
||||
|
||||
$userRow = mysqli_fetch_assoc($sql);
|
||||
|
||||
if (!password_verify($admin_password, $userRow['user_password'])) {
|
||||
flash_alert("Incorrect password.", 'error');
|
||||
redirect();
|
||||
@@ -364,7 +364,7 @@ if (isset($_POST['ir_reset_user_password'])) {
|
||||
$sql_users = mysqli_query($mysqli, "SELECT * FROM users WHERE (user_archived_at IS NULL AND user_id != $session_user_id)");
|
||||
|
||||
// Reset passwords
|
||||
while ($row = mysqli_fetch_array($sql_users)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_users)) {
|
||||
$user_id = intval($row['user_id']);
|
||||
$user_email = sanitizeInput($row['user_email']);
|
||||
$new_password = randomString();
|
||||
|
||||
Reference in New Issue
Block a user