Check to see if arrays are set before executing for each loops to prevent php errors

This commit is contained in:
johnnyq 2024-11-14 19:13:56 -05:00
parent e9f023f0c7
commit ed92592aa6
14 changed files with 74 additions and 64 deletions

View File

@ -273,7 +273,7 @@ if (isset($_POST['bulk_assign_asset_location'])) {
$client_id = intval($row['location_client_id']);
// Assign Location to Selected Contacts
if ($_POST['asset_ids']) {
if (isset($_POST['asset_ids'])) {
// Get Selected Contacts Count
$asset_count = count($_POST['asset_ids']);
@ -318,7 +318,7 @@ if (isset($_POST['bulk_assign_asset_contact'])) {
$client_id = intval($row['contact_client_id']);
// Assign Contact to Selected Assets
if ($_POST['asset_ids']) {
if (isset($_POST['asset_ids'])) {
// Get Selected Contacts Count
$asset_count = count($_POST['asset_ids']);
@ -357,7 +357,7 @@ if (isset($_POST['bulk_edit_asset_status'])) {
$status = sanitizeInput($_POST['bulk_status']);
// Assign Status to Selected Assets
if ($_POST['asset_ids']) {
if (isset($_POST['asset_ids'])) {
// Get Count
$asset_count = count($_POST['asset_ids']);
@ -394,7 +394,7 @@ if (isset($_POST['bulk_archive_assets'])) {
validateCSRFToken($_POST['csrf_token']);
if ($_POST['asset_ids']) {
if (isset($_POST['asset_ids'])) {
// Get Count
$count = count($_POST['asset_ids']);
@ -433,7 +433,7 @@ if (isset($_POST['bulk_unarchive_assets'])) {
validateCSRFToken($_POST['csrf_token']);
if ($_POST['asset_ids']) {
if (isset($_POST['asset_ids'])) {
// Get Count
$count = count($_POST['asset_ids']);

View File

@ -125,7 +125,7 @@ if (isset($_POST['bulk_delete_certificates'])) {
enforceUserPermission('module_support', 3);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['certificate_ids']) {
if (isset($_POST['certificate_ids'])) {
// Get selected count
$count = count($_POST['certificate_ids']);

View File

@ -62,7 +62,7 @@ if (isset($_POST['add_client'])) {
}
// Add Tags
if ($_POST['tags']) {
if (isset($_POST['tags'])) {
foreach ($_POST['tags'] as $tag) {
$tag = intval($tag);
mysqli_query($mysqli, "INSERT INTO client_tags SET client_id = $client_id, tag_id = $tag");
@ -139,9 +139,11 @@ if (isset($_POST['edit_client'])) {
mysqli_query($mysqli, "DELETE FROM client_tags WHERE client_id = $client_id");
// Add new tags
foreach($_POST['tags'] as $tag) {
$tag = intval($tag);
mysqli_query($mysqli, "INSERT INTO client_tags SET client_id = $client_id, tag_id = $tag");
if(isset($_POST['tags'])) {
foreach($_POST['tags'] as $tag) {
$tag = intval($tag);
mysqli_query($mysqli, "INSERT INTO client_tags SET client_id = $client_id, tag_id = $tag");
}
}
// Logging

View File

@ -32,7 +32,7 @@ if (isset($_POST['add_contact'])) {
$contact_id = mysqli_insert_id($mysqli);
// Add Tags
if ($_POST['tags']) {
if (isset($_POST['tags'])) {
foreach($_POST['tags'] as $tag) {
$tag = intval($tag);
mysqli_query($mysqli, "INSERT INTO contact_tags SET contact_id = $contact_id, tag_id = $tag");
@ -144,9 +144,11 @@ if (isset($_POST['edit_contact'])) {
mysqli_query($mysqli, "DELETE FROM contact_tags WHERE contact_id = $contact_id");
// Add new tags
foreach($_POST['tags'] as $tag) {
$tag = intval($tag);
mysqli_query($mysqli, "INSERT INTO contact_tags SET contact_id = $contact_id, tag_id = $tag");
if (isset($_POST['tags'])) {
foreach($_POST['tags'] as $tag) {
$tag = intval($tag);
mysqli_query($mysqli, "INSERT INTO contact_tags SET contact_id = $contact_id, tag_id = $tag");
}
}
// Update Primary contact in clients if primary contact is checked
@ -225,7 +227,7 @@ if (isset($_POST['bulk_assign_contact_location'])) {
$client_id = intval($row['location_client_id']);
// Assign Location to Selected Contacts
if ($_POST['contact_ids']) {
if (isset($_POST['contact_ids'])) {
// Get Selected Contacts Count
$contact_count = count($_POST['contact_ids']);
@ -262,7 +264,7 @@ if (isset($_POST['bulk_edit_contact_phone'])) {
$phone = preg_replace("/[^0-9]/", '', $_POST['bulk_phone']);
// Assign Location to Selected Contacts
if ($_POST['contact_ids']) {
if (isset($_POST['contact_ids'])) {
// Get Selected Contacts Count
$contact_count = count($_POST['contact_ids']);
@ -299,7 +301,7 @@ if (isset($_POST['bulk_edit_contact_department'])) {
$department = sanitizeInput($_POST['bulk_department']);
// Assign Location to Selected Contacts
if ($_POST['contact_ids']) {
if (isset($_POST['contact_ids'])) {
// Get Selected Contacts Count
$contact_count = count($_POST['contact_ids']);
@ -339,7 +341,7 @@ if (isset($_POST['bulk_edit_contact_role'])) {
$contact_technical = intval($_POST['bulk_contact_technical']);
// Assign Location to Selected Contacts
if ($_POST['contact_ids']) {
if (isset($_POST['contact_ids'])) {
// Get Selected Contacts Count
$contact_count = count($_POST['contact_ids']);
@ -377,7 +379,7 @@ if (isset($_POST['bulk_assign_contact_tags'])) {
enforceUserPermission('module_client', 2);
// Assign Location to Selected Contacts
if ($_POST['contact_ids']) {
if (isset($_POST['contact_ids'])) {
// Get Selected Contacts Count
$count = count($_POST['contact_ids']);
@ -397,12 +399,14 @@ if (isset($_POST['bulk_assign_contact_tags'])) {
}
// Add new tags
foreach($_POST['bulk_tags'] as $tag) {
$tag = intval($tag);
if (isset($_POST['bulk_tags'])) {
foreach($_POST['bulk_tags'] as $tag) {
$tag = intval($tag);
$sql = mysqli_query($mysqli,"SELECT * FROM contact_tags WHERE contact_id = $contact_id AND tag_id = $tag");
if (mysqli_num_rows($sql) == 0) {
mysqli_query($mysqli, "INSERT INTO contact_tags SET contact_id = $contact_id, tag_id = $tag");
$sql = mysqli_query($mysqli,"SELECT * FROM contact_tags WHERE contact_id = $contact_id AND tag_id = $tag");
if (mysqli_num_rows($sql) == 0) {
mysqli_query($mysqli, "INSERT INTO contact_tags SET contact_id = $contact_id, tag_id = $tag");
}
}
}
@ -427,7 +431,7 @@ if (isset($_POST['bulk_archive_contacts'])) {
//validateCSRFToken($_POST['csrf_token']);
if ($_POST['contact_ids']) {
if (isset($_POST['contact_ids'])) {
$count = 0; // Default 0
@ -477,7 +481,7 @@ if (isset($_POST['bulk_unarchive_contacts'])) {
enforceUserPermission('module_client', 2);
//validateCSRFToken($_POST['csrf_token']);
if ($_POST['contact_ids']) {
if (isset($_POST['contact_ids'])) {
// Get Selected Contacts Count
$count = count($_POST['contact_ids']);
@ -521,7 +525,7 @@ if (isset($_POST['bulk_delete_contacts'])) {
enforceUserPermission('module_client', 3);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['contact_ids']) {
if (isset($_POST['contact_ids'])) {
// Get Selected Contacts Count
$count = count($_POST['contact_ids']);

View File

@ -153,7 +153,7 @@ if (isset($_POST['bulk_assign_login_tags'])) {
enforceUserPermission('module_credential', 2);
// Assign tags to Selected Credentials
if ($_POST['login_ids']) {
if (isset($_POST['login_ids'])) {
// Get Selected Credential Count
$count = count($_POST['login_ids']);
@ -173,7 +173,7 @@ if (isset($_POST['bulk_assign_login_tags'])) {
}
// Add new tags
if(isset($_POST['bulk_tags'])) {
if (isset($_POST['bulk_tags'])) {
foreach($_POST['bulk_tags'] as $tag) {
$tag = intval($tag);
@ -204,7 +204,7 @@ if (isset($_POST['bulk_archive_logins'])) {
enforceUserPermission('module_credential', 2);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['login_ids']) {
if (isset($_POST['login_ids'])) {
// Get Selected Credential Count
$count = count($_POST['login_ids']);
@ -243,7 +243,7 @@ if (isset($_POST['bulk_unarchive_logins'])) {
validateCSRFToken($_POST['csrf_token']);
if ($_POST['login_ids']) {
if (isset($_POST['login_ids'])) {
// Get Selected Credential Count
$count = count($_POST['login_ids']);
@ -282,7 +282,7 @@ if (isset($_POST['bulk_delete_logins'])) {
validateCSRFToken($_POST['csrf_token']);
if ($_POST['login_ids']) {
if (isset($_POST['login_ids'])) {
// Get Selected Credential Count
$count = count($_POST['login_ids']);

View File

@ -180,7 +180,7 @@ if (isset($_POST['bulk_move_document'])) {
$client_id = intval($row['folder_client_id']);
// Move Documents to Folder Loop
if ($_POST['document_ids']) {
if (isset($_POST['document_ids'])) {
// Get Selected Count
$count = count($_POST['document_ids']);
@ -701,7 +701,7 @@ if (isset($_POST['bulk_delete_documents'])) {
validateCSRFToken($_POST['csrf_token']);
if ($_POST['document_ids']) {
if (isset($_POST['document_ids'])) {
// Get selected document count
$count = count($_POST['document_ids']);

View File

@ -179,7 +179,7 @@ if (isset($_POST['bulk_archive_domains'])) {
enforceUserPermission('module_support', 3);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['domain_ids']) {
if (isset($_POST['domain_ids'])) {
// Get Selected Count
$count = count($_POST['domain_ids']);
@ -216,7 +216,7 @@ if (isset($_POST['bulk_unarchive_domains'])) {
enforceUserPermission('module_support', 3);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['domain_ids']) {
if (isset($_POST['domain_ids'])) {
// Get Selected Count
$count = count($_POST['domain_ids']);
@ -253,7 +253,7 @@ if (isset($_POST['bulk_delete_domains'])) {
enforceUserPermission('module_support', 3);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['domain_ids']) {
if (isset($_POST['domain_ids'])) {
// Get Selected Count
$count = count($_POST['domain_ids']);

View File

@ -119,7 +119,7 @@ if (isset($_POST['bulk_edit_expense_category'])) {
$category_name = sanitizeInput($row['category_name']);
// Assign category to Selected Expenses
if ($_POST['expense_ids']) {
if (isset($_POST['expense_ids'])) {
// Get Selected Count
$count = count($_POST['expense_ids']);
@ -159,7 +159,7 @@ if (isset($_POST['bulk_edit_expense_account'])) {
$account_name = sanitizeInput($row['account_name']);
// Assign account to Selected Expenses
if ($_POST['expense_ids']) {
if (isset($_POST['expense_ids'])) {
// Get Selected Contacts Count
$count = count($_POST['expense_ids']);
@ -199,7 +199,7 @@ if (isset($_POST['bulk_edit_expense_client'])) {
$client_name = sanitizeInput($row['client_name']);
// Assign Client to Selected Expenses
if ($_POST['expense_ids']) {
if (isset($_POST['expense_ids'])) {
// Get Selected Count
$count = count($_POST['expense_ids']);
@ -229,7 +229,7 @@ if (isset($_POST['bulk_delete_expenses'])) {
validateAdminRole();
validateCSRFToken($_POST['csrf_token']);
if ($_POST['expense_ids']) {
if (isset($_POST['expense_ids'])) {
// Get Selected Count
$count = count($_POST['expense_ids']);

View File

@ -176,7 +176,7 @@ if (isset($_POST['bulk_delete_files'])) {
validateCSRFToken($_POST['csrf_token']);
// Delete file loop
if ($_POST['file_ids']) {
if (isset($_POST['file_ids'])) {
// Get selected file Count
$file_count = count($_POST['file_ids']);
@ -224,7 +224,7 @@ if (isset($_POST['bulk_move_files'])) {
$client_id = intval($row['folder_client_id']);
// Check array for data
if ($_POST['file_ids']) {
if (isset($_POST['file_ids'])) {
// Get Selected file Count
$file_count = count($_POST['file_ids']);

View File

@ -95,9 +95,11 @@ if(isset($_POST['edit_location'])){
mysqli_query($mysqli, "DELETE FROM location_tags WHERE location_id = $location_id");
// Add new tags
foreach($_POST['tags'] as $tag) {
$tag = intval($tag);
mysqli_query($mysqli, "INSERT INTO location_tags SET location_id = $location_id, tag_id = $tag");
if (isset($_POST['tags'])) {
foreach($_POST['tags'] as $tag) {
$tag = intval($tag);
mysqli_query($mysqli, "INSERT INTO location_tags SET location_id = $location_id, tag_id = $tag");
}
}
//Check to see if a file is attached
@ -214,7 +216,7 @@ if (isset($_POST['bulk_assign_location_tags'])) {
enforceUserPermission('module_client', 2);
// Assign Tags to Selected
if ($_POST['location_ids']) {
if (isset($_POST['location_ids'])) {
// Get Selected Count
$count = count($_POST['location_ids']);
@ -234,12 +236,14 @@ if (isset($_POST['bulk_assign_location_tags'])) {
}
// Add new tags
foreach($_POST['bulk_tags'] as $tag) {
$tag = intval($tag);
if (isset($_POST['bulk_tags'])) {
foreach($_POST['bulk_tags'] as $tag) {
$tag = intval($tag);
$sql = mysqli_query($mysqli,"SELECT * FROM location_tags WHERE location_id = $location_id AND tag_id = $tag");
if (mysqli_num_rows($sql) == 0) {
mysqli_query($mysqli, "INSERT INTO location_tags SET location_id = $location_id, tag_id = $tag");
$sql = mysqli_query($mysqli,"SELECT * FROM location_tags WHERE location_id = $location_id AND tag_id = $tag");
if (mysqli_num_rows($sql) == 0) {
mysqli_query($mysqli, "INSERT INTO location_tags SET location_id = $location_id, tag_id = $tag");
}
}
}
@ -262,7 +266,7 @@ if (isset($_POST['bulk_archive_locations'])) {
enforceUserPermission('module_client', 2);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['location_ids']) {
if (isset($_POST['location_ids'])) {
$count = 0; // Default 0
@ -304,7 +308,7 @@ if (isset($_POST['bulk_unarchive_locations'])) {
enforceUserPermission('module_client', 2);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['location_ids']) {
if (isset($_POST['location_ids'])) {
// Get Selected Count
$count = count($_POST['location_ids']);
@ -341,7 +345,7 @@ if (isset($_POST['bulk_delete_locations'])) {
enforceUserPermission('module_client', 3);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['location_ids']) {
if (isset($_POST['location_ids'])) {
// Get Selected Count
$count = count($_POST['location_ids']);

View File

@ -92,7 +92,7 @@ if (isset($_POST['bulk_delete_networks'])) {
enforceUserPermission('module_support', 3);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['network_ids']) {
if (isset($_POST['network_ids'])) {
// Get Selected Count
$count = count($_POST['network_ids']);

View File

@ -123,7 +123,7 @@ if (isset($_POST['bulk_edit_product_category'])) {
$category_name = sanitizeInput($row['category_name']);
// Assign category to Selected Products
if ($_POST['product_ids']) {
if (isset($_POST['product_ids'])) {
// Get Count
$count = count($_POST['product_ids']);
@ -158,7 +158,7 @@ if (isset($_POST['bulk_archive_products'])) {
validateCSRFToken($_POST['csrf_token']);
if ($_POST['product_ids']) {
if (isset($_POST['product_ids'])) {
$count = count($_POST['product_ids']);
@ -193,7 +193,7 @@ if (isset($_POST['bulk_unarchive_products'])) {
enforceUserPermission('module_sales', 2);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['product_ids']) {
if (isset($_POST['product_ids'])) {
$count = count($_POST['product_ids']);
@ -228,7 +228,7 @@ if (isset($_POST['bulk_delete_products'])) {
enforceUserPermission('module_sales', 3);
validateCSRFToken($_POST['csrf_token']);
if ($_POST['product_ids']) {
if (isset($_POST['product_ids'])) {
$count = count($_POST['product_ids']);

View File

@ -199,7 +199,7 @@ if (isset($_POST['add_project_ticket'])) {
$project_name = sanitizeInput($row['project_name']);
// Add Tickets
if ($_POST['tickets']) {
if (isset($_POST['tickets'])) {
// Get Selected Count
$count = count($_POST['tickets']);

View File

@ -163,7 +163,7 @@ if (isset($_POST['bulk_archive_vendors'])) {
validateAdminRole();
validateCSRFToken($_POST['csrf_token']);
if (isset($vendor_ids)) {
if (isset($_POST['vendor_ids'])) {
// Get Selected Count
$count = count($_POST['vendor_ids']);
@ -200,7 +200,7 @@ if (isset($_POST['bulk_unarchive_vendors'])) {
validateAdminRole();
validateCSRFToken($_POST['csrf_token']);
if (isset($vendor_ids)) {
if (isset($_POST['vendor_ids'])) {
// Get Selected Count
$count = count($_POST['vendor_ids']);
@ -237,7 +237,7 @@ if (isset($_POST['bulk_delete_vendors'])) {
validateAdminRole();
validateCSRFToken($_POST['csrf_token']);
if (isset($vendor_ids)) {
if (isset($_POST['vendor_ids'])) {
// Get Selected Count
$count = count($_POST['vendor_ids']);