From b36719eb99414fa61abdb9bc9063e56a0c968e5a Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Thu, 9 Feb 2023 11:32:40 +0000 Subject: [PATCH 1/3] General cleanup/tidying --- api/v1/contacts/create.php | 2 +- api/v1/contacts/delete.php | 2 +- api/v1/contacts/update.php | 2 +- api/v1/validate_api_key.php | 2 +- base32static.php | 2 +- client_contact_details.php | 2 +- client_contacts.php | 2 +- client_invoices.php | 279 ++++----- client_side_nav.php | 586 +++++++++---------- functions.php | 6 +- guest_view_invoice.php | 1092 +++++++++++++++++------------------ guest_view_item.php | 2 +- invoices.php | 2 +- login.php | 8 +- pagination.php | 142 ++--- portal/inc_portal.php | 4 +- portal/invoices.php | 9 +- portal/login.php | 2 +- portal/login_microsoft.php | 2 +- post.php | 46 +- rfc6238.php | 255 ++++---- ticket.php | 17 +- 22 files changed, 1222 insertions(+), 1244 deletions(-) diff --git a/api/v1/contacts/create.php b/api/v1/contacts/create.php index 6919b013..d9941433 100644 --- a/api/v1/contacts/create.php +++ b/api/v1/contacts/create.php @@ -7,7 +7,7 @@ require_once('../require_post_method.php'); require_once('contact_model.php'); // Default -$insert_id = FALSE; +$insert_id = false; if (!empty($name) && !empty($email) && !empty($client_id)) { diff --git a/api/v1/contacts/delete.php b/api/v1/contacts/delete.php index 9fd17cba..541efb33 100644 --- a/api/v1/contacts/delete.php +++ b/api/v1/contacts/delete.php @@ -7,7 +7,7 @@ require_once('../require_post_method.php'); $contact_id = intval($_POST['contact_id']); // Default -$delete_count = FALSE; +$delete_count = false; if (!empty($contact_id)) { $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_id = $contact_id AND contact_client_id = $client_id AND company_id = '$company_id' LIMIT 1")); diff --git a/api/v1/contacts/update.php b/api/v1/contacts/update.php index d19d9521..69169021 100644 --- a/api/v1/contacts/update.php +++ b/api/v1/contacts/update.php @@ -7,7 +7,7 @@ require_once('../require_post_method.php'); $contact_id = intval($_POST['contact_id']); // Default -$update_count = FALSE; +$update_count = false; if (!empty($contact_id)) { diff --git a/api/v1/validate_api_key.php b/api/v1/validate_api_key.php index e2f29590..3eeb02c5 100644 --- a/api/v1/validate_api_key.php +++ b/api/v1/validate_api_key.php @@ -7,7 +7,7 @@ */ // Includes -require_once( __DIR__ . '../../../functions.php'); +require_once(__DIR__ . '../../../functions.php'); require_once(__DIR__ . "../../../config.php"); // JSON header diff --git a/base32static.php b/base32static.php index 980a89c4..1bfad4cc 100644 --- a/base32static.php +++ b/base32static.php @@ -87,7 +87,7 @@ class Base32Static { $eightBits = str_split($x, 8); for ($z = 0; $z < count($eightBits); $z++) { - $binaryString .= ( ($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48 ) ? $y:""; + $binaryString .= (($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48) ? $y:""; } } diff --git a/client_contact_details.php b/client_contact_details.php index 475b17b0..d56ba3cc 100644 --- a/client_contact_details.php +++ b/client_contact_details.php @@ -29,7 +29,7 @@ if (isset($_GET['contact_id'])) { if ($contact_id == $primary_contact) { $primary_contact_display = "Primary Contact"; } else { - $primary_contact_display = FALSE; + $primary_contact_display = false; } $contact_location_id = $row['contact_location_id']; $location_name = htmlentities($row['location_name']); diff --git a/client_contacts.php b/client_contacts.php index a2a6bad5..bb5a8985 100644 --- a/client_contacts.php +++ b/client_contacts.php @@ -133,7 +133,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); if ($contact_id == $primary_contact) { $primary_contact_display = "Primary Contact"; } else { - $primary_contact_display = FALSE; + $primary_contact_display = false; } $contact_location_id = $row['contact_location_id']; $location_name = htmlentities($row['location_name']); diff --git a/client_invoices.php b/client_invoices.php index 40b80d40..11a31590 100644 --- a/client_invoices.php +++ b/client_invoices.php @@ -1,167 +1,168 @@ - - $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM invoices - LEFT JOIN categories ON invoice_category_id = category_id - WHERE invoice_client_id = $client_id - AND (CONCAT(invoice_prefix,invoice_number) LIKE '%$q%' OR invoice_scope LIKE '%$q%' OR category_name LIKE '%$q%' OR invoice_status LIKE '%$q%' OR invoice_amount LIKE '%$q%') - ORDER BY $sb $o LIMIT $record_from, $record_to"); +$sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM invoices + LEFT JOIN categories ON invoice_category_id = category_id + WHERE invoice_client_id = $client_id + AND (CONCAT(invoice_prefix,invoice_number) LIKE '%$q%' OR invoice_scope LIKE '%$q%' OR category_name LIKE '%$q%' OR invoice_status LIKE '%$q%' OR invoice_amount LIKE '%$q%') + ORDER BY $sb $o LIMIT $record_from, $record_to"); $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); ?> -
-
-

Invoices

-
- -
-
-
-
- -
- -
-
- -
- +
+
+

Invoices

+
+
-
+
+ + +
-
-
- Export -
-
+
+
+ +
+ +
+
+
-
- -
-
- - "> - - - - - - - - - - - - - +
+ Export +
+ - if (($invoice_status == "Sent" || $invoice_status == "Partial" || $invoice_status == "Viewed") && strtotime($invoice_due) < time() ) { - $overdue_color = "text-danger font-weight-bold"; - }else{ - $overdue_color = ""; - } - - //Set Badge color based off of invoice status - if ($invoice_status == "Sent") { - $invoice_badge_color = "warning"; - }elseif ($invoice_status == "Viewed") { - $invoice_badge_color = "info"; - }elseif ($invoice_status == "Partial") { - $invoice_badge_color = "primary"; - }elseif ($invoice_status == "Paid") { - $invoice_badge_color = "success"; - }elseif ($invoice_status == "Cancelled") { - $invoice_badge_color = "danger"; - }else{ - $invoice_badge_color = "secondary"; - } - - ?> - - - - - - - - - - - + +
+
+
NumberScopeAmountDateDueCategoryStatusAction
- - - - - -
+ "> + + + + + + + + + + + + + + if (($invoice_status == "Sent" || $invoice_status == "Partial" || $invoice_status == "Viewed") && strtotime($invoice_due) < time()) { + $overdue_color = "text-danger font-weight-bold"; + } else { + $overdue_color = ""; + } - -
NumberScopeAmountDateDueCategoryStatusAction
+ //Set Badge color based off of invoice status + if ($invoice_status == "Sent") { + $invoice_badge_color = "warning"; + } elseif ($invoice_status == "Viewed") { + $invoice_badge_color = "info"; + } elseif ($invoice_status == "Partial") { + $invoice_badge_color = "primary"; + } elseif ($invoice_status == "Paid") { + $invoice_badge_color = "success"; + } elseif ($invoice_status == "Cancelled") { + $invoice_badge_color = "danger"; + } else { + $invoice_badge_color = "secondary"; + } + + ?> + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
- -
-
- - - + diff --git a/functions.php b/functions.php index c54b5f19..5c40b7e2 100644 --- a/functions.php +++ b/functions.php @@ -405,7 +405,7 @@ function getDomainRecords($name) { function getSSL($name) { $certificate = array(); - $certificate['success'] = FALSE; + $certificate['success'] = false; // Only run if we think the domain is valid if (!filter_var($name, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) { @@ -417,7 +417,7 @@ function getSSL($name) { // Get SSL/TSL certificate (using verify peer false to allow for self-signed certs) for domain on default port $socket = "ssl://$name:443"; - $get = stream_context_create(array("ssl" => array("capture_peer_cert" => TRUE, "verify_peer" => FALSE,))); + $get = stream_context_create(array("ssl" => array("capture_peer_cert" => true, "verify_peer" => false,))); $read = stream_socket_client($socket, $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $get); // If the socket connected @@ -427,7 +427,7 @@ function getSSL($name) { openssl_x509_export($cert['options']['ssl']['peer_certificate'], $export); if ($cert_public_key_obj) { - $certificate['success'] = TRUE; + $certificate['success'] = true; $certificate['expire'] = date('Y-m-d', $cert_public_key_obj['validTo_time_t']); $certificate['issued_by'] = strip_tags($cert_public_key_obj['issuer']['O']); $certificate['public_key'] = $export; diff --git a/guest_view_invoice.php b/guest_view_invoice.php index 85cf1a6d..08ace319 100644 --- a/guest_view_invoice.php +++ b/guest_view_invoice.php @@ -119,592 +119,592 @@ $sql_invoice_items = mysqli_query($mysqli, "SELECT * FROM invoice_items WHERE it ?> -
- -
-
-
- "> -
-
- -
-
- -
-
+
+ -
-
-
    -
  • -
  • -
  • -
  • -
  • -
- +
+
+
+ "> +
+
+ +
+
+ +
+
+ +

Invoice

+
-
+
+
+
    +
  • +
  • +
  • +
  • +
  • +
-
    -
  • -
  • -
  • -
  • -
  • -
  • -
+
+
+
    +
  • +
  • +
  • +
  • +
  • +
  • +
+ +
-
-
-
+
+
+
+
+ + + + + + + + + +
Date
Due
+
-
- - - - - - - - - -
Date
Due
-
-
- -
-
-
-
- - - - - - - - - - - - - +
+
+
+
+
ProductDescriptionQtyPriceTaxTotal
+ - - - - - - + + + + + + + + + + $total_tax = 0; + $sub_total = 0; - -
ProductDescriptionQtyPriceTaxTotal
+ while ($row = mysqli_fetch_array($sql_invoice_items)) { + $item_id = $row['item_id']; + $item_name = htmlentities($row['item_name']); + $item_description = htmlentities($row['item_description']); + $item_quantity = floatval($row['item_quantity']); + $item_price = floatval($row['item_price']); + $item_tax = floatval($row['item_tax']); + $item_total = floatval($row['item_total']); + $total_tax = $item_tax + $total_tax; + $sub_total = $item_price * $item_quantity + $sub_total; + + ?> + + + +
+ + + + + + + + + + +
-
-
-
- -
-
-
+
+
+ +
+
+
+
-
- -
-
- - - - - - - 0) { ?> - - - - - 0) { ?> + +
+
Subtotal
Tax
+ - - + + - - - - - - -
Paid
Subtotal
Balance
+ 0) { ?> + + Tax + + + + 0) { ?> + +
Paid
+ + + + + Balance + + + + +
+ +
+ +
- -
- -
-
- - - + + + 1) { ?> $invoice_url_key = htmlentities($row['invoice_url_key']); $invoice_tally_total = $invoice_amount + $invoice_tally_total; $difference = time() - strtotime($invoice_due); - $days = floor($difference / (60*60*24) ); + $days = floor($difference / (60*60*24)); ?> @@ -800,7 +800,7 @@ if (mysqli_num_rows($sql) > 1) { ?> $invoice_url_key = htmlentities($row['invoice_url_key']); $invoice_tally_total = $invoice_amount + $invoice_tally_total; $difference = strtotime($invoice_due) - time(); - $days = floor($difference / (60*60*24) ); + $days = floor($difference / (60*60*24)); ?> @@ -885,7 +885,7 @@ if (mysqli_num_rows($sql) > 1) { ?> if (strtotime($payment_date) > strtotime($invoice_due)) { $payment_note = "Late"; $difference = strtotime($payment_date) - strtotime($invoice_due); - $days = floor($difference / (60*60*24) ) . " Days"; + $days = floor($difference / (60*60*24)) . " Days"; } else { $payment_note = ""; $days = ""; diff --git a/guest_view_item.php b/guest_view_item.php index 9f45565c..efd24195 100644 --- a/guest_view_item.php +++ b/guest_view_item.php @@ -1,7 +1,7 @@ diff --git a/invoices.php b/invoices.php index c74f5859..f145d92c 100644 --- a/invoices.php +++ b/invoices.php @@ -293,7 +293,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $now = time(); - if (($invoice_status == "Sent" || $invoice_status == "Partial" || $invoice_status == "Viewed") && strtotime($invoice_due) + 86400 < $now ) { + if (($invoice_status == "Sent" || $invoice_status == "Partial" || $invoice_status == "Viewed") && strtotime($invoice_due) + 86400 < $now) { $overdue_color = "text-danger font-weight-bold"; } else { $overdue_color = ""; diff --git a/login.php b/login.php index 36bb00cc..164801a2 100644 --- a/login.php +++ b/login.php @@ -47,11 +47,11 @@ $config_mail_from_email = $row['config_mail_from_email']; $config_mail_from_name = $row['config_mail_from_name']; // HTTP-Only cookies -ini_set("session.cookie_httponly", True); +ini_set("session.cookie_httponly", true); // Tell client to only send cookie(s) over HTTPS if ($config_https_only) { - ini_set("session.cookie_secure", True); + ini_set("session.cookie_secure", true); } // Handle POST login request @@ -108,7 +108,7 @@ if (isset($_POST['login'])) { // Determine whether 2FA was used (for logs) $extended_log = ''; // Default value - if ($current_code !== 0 ) { + if ($current_code !== 0) { $extended_log = 'with 2FA'; } @@ -120,7 +120,7 @@ if (isset($_POST['login'])) { $_SESSION['user_name'] = $user_name; $_SESSION['user_role'] = $row['user_role']; $_SESSION['csrf_token'] = randomString(156); - $_SESSION['logged'] = TRUE; + $_SESSION['logged'] = true; // Setup encryption session key if (isset($row['user_specific_encryption_ciphertext']) && $row['user_role'] > 1) { diff --git a/pagination.php b/pagination.php index dc20f7d8..0349e89f 100644 --- a/pagination.php +++ b/pagination.php @@ -11,89 +11,89 @@ $total_found_rows = $num_rows[0]; $total_pages = ceil($total_found_rows / $_SESSION['records_per_page']); if ($total_found_rows > 10) { - $i=0; + $i=0; -?> + ?> -
+
-
-
-
- -
-
-
-

-
-
+
+
+
+ +
+
+
+

+
+
-
    +
      - 100)) { - $pages_split = 100; - } - if (($total_pages <= 10000) && ($total_pages > 1000)) { - $pages_split = 1000; - } - if ($p > 1) { - $prev_class = ""; - }else{ - $prev_class = "disabled"; - } - if ($p <> $total_pages) { - $next_class = ""; - }else{ - $next_class = "disabled"; - } - $url_query_strings = http_build_query(array_merge($_GET,array('p' => $i))); - $prev_page = $p - 1; - $next_page = $p + 1; - - if ($p > 1) { - echo "
    • Prev
    • "; - } - - while ($i < $total_pages) { - $i++; - if (($i == 1) || (($p <= 3) && ($i <= 6)) || (($i > $total_pages - 6) && ($p > $total_pages - 3 )) || (is_int($i / $pages_split)) || (($p > 3) && ($i >= $p - 2) && ($i <= $p + 3)) || ($i == $total_pages)) { - if ($p == $i ) { - $page_class = "active"; - }else{ - $page_class = ""; - } - echo "
    • $i
    • "; - } - } + $total_pages) { - echo "
    • Next
    • "; - } + if ($total_pages <= 100) { + $pages_split = 10; + } + if (($total_pages <= 1000) && ($total_pages > 100)) { + $pages_split = 100; + } + if (($total_pages <= 10000) && ($total_pages > 1000)) { + $pages_split = 1000; + } + if ($p > 1) { + $prev_class = ""; + } else { + $prev_class = "disabled"; + } + if ($p <> $total_pages) { + $next_class = ""; + } else { + $next_class = "disabled"; + } + $url_query_strings = http_build_query(array_merge($_GET,array('p' => $i))); + $prev_page = $p - 1; + $next_page = $p + 1; - ?> + if ($p > 1) { + echo "
    • Prev
    • "; + } -
    -
-
+ while ($i < $total_pages) { + $i++; + if (($i == 1) || (($p <= 3) && ($i <= 6)) || (($i > $total_pages - 6) && ($p > $total_pages - 3)) || (is_int($i / $pages_split)) || (($p > 3) && ($i >= $p - 2) && ($i <= $p + 3)) || ($i == $total_pages)) { + if ($p == $i) { + $page_class = "active"; + } else { + $page_class = ""; + } + echo "
  • $i
  • "; + } + } - $total_pages) { + echo "
  • Next
  • "; + } + + ?> + + +
    +
    + +

    No Results

    "; + echo "

    No Results

    "; } ?> diff --git a/portal/inc_portal.php b/portal/inc_portal.php index 36f5f3ee..8b77da7e 100644 --- a/portal/inc_portal.php +++ b/portal/inc_portal.php @@ -11,10 +11,10 @@ require_once('portal_functions.php'); if (!isset($_SESSION)) { // HTTP Only cookies - ini_set("session.cookie_httponly", True); + ini_set("session.cookie_httponly", true); if ($config_https_only) { // Tell client to only send cookie(s) over HTTPS - ini_set("session.cookie_secure", True); + ini_set("session.cookie_secure", true); } session_start(); } diff --git a/portal/invoices.php b/portal/invoices.php index 8ca7bbf6..d509662f 100644 --- a/portal/invoices.php +++ b/portal/invoices.php @@ -18,9 +18,7 @@ $invoices_sql = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_clie
    " alt="..." height="50" width="50" class="img-circle img-responsive"> - - @@ -73,7 +71,7 @@ $invoices_sql = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_clie } $now = time(); - if (($invoice_status == "Sent" || $invoice_status == "Partial" || $invoice_status == "Viewed") && strtotime($invoice_due) + 86400 < $now ) { + if (($invoice_status == "Sent" || $invoice_status == "Partial" || $invoice_status == "Viewed") && strtotime($invoice_due) + 86400 < $now) { $overdue_color = "text-danger font-weight-bold"; } else { $overdue_color = ""; @@ -107,9 +105,8 @@ $invoices_sql = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_clie - + + diff --git a/portal/login.php b/portal/login.php index 0dce1e80..cac9aba4 100644 --- a/portal/login.php +++ b/portal/login.php @@ -46,7 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])) { if ($row['contact_auth_method'] == 'local') { if (password_verify($password, $row['contact_password_hash'])) { - $_SESSION['client_logged_in'] = TRUE; + $_SESSION['client_logged_in'] = true; $_SESSION['client_id'] = $row['contact_client_id']; $_SESSION['contact_id'] = $row['contact_id']; $_SESSION['company_id'] = $row['company_id']; diff --git a/portal/login_microsoft.php b/portal/login_microsoft.php index 629a8529..894f777d 100644 --- a/portal/login_microsoft.php +++ b/portal/login_microsoft.php @@ -95,7 +95,7 @@ if (isset($_POST['code']) && $_POST['state'] == session_id()) { $row = mysqli_fetch_array($sql); if ($row['contact_auth_method'] == 'azure') { - $_SESSION['client_logged_in'] = TRUE; + $_SESSION['client_logged_in'] = true; $_SESSION['client_id'] = $row['contact_client_id']; $_SESSION['contact_id'] = $row['contact_id']; $_SESSION['company_id'] = $row['company_id']; diff --git a/post.php b/post.php index 37a4c11b..485eaf13 100644 --- a/post.php +++ b/post.php @@ -284,7 +284,7 @@ if(isset($_POST['edit_profile'])){ $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); $new_password = trim($_POST['new_password']); $existing_file_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['existing_file_name']))); - $logout = FALSE; + $logout = false; $extended_log_description = ''; // Email notification when password or email is changed @@ -367,7 +367,7 @@ if(isset($_POST['edit_profile'])){ mysqli_query($mysqli,"UPDATE users SET user_password = '$new_password', user_specific_encryption_ciphertext = '$user_specific_encryption_ciphertext' WHERE user_id = $user_id"); $extended_log_description .= ", password changed"; - $logout = TRUE; + $logout = true; } // Enable extension access, only if it isn't already setup (user doesn't have cookie) @@ -377,7 +377,7 @@ if(isset($_POST['edit_profile'])){ mysqli_query($mysqli, "UPDATE users SET user_extension_key = '$extension_key' WHERE user_id = $user_id"); $extended_log_description .= ", extension access enabled"; - $logout = TRUE; + $logout = true; } } @@ -4788,19 +4788,19 @@ if(isset($_POST["import_client_contacts_csv"])){ $client_id = intval($_POST['client_id']); $file_name = $_FILES["file"]["tmp_name"]; - $error = FALSE; + $error = false; //Check file is CSV $file_extension = strtolower(end(explode('.',$_FILES['file']['name']))); $allowed_file_extensions = array('csv'); if(in_array($file_extension,$allowed_file_extensions) === false){ - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad file extension"; } //Check file isn't empty elseif($_FILES["file"]["size"] < 1){ - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad file size (empty?)"; } @@ -4808,7 +4808,7 @@ if(isset($_POST["import_client_contacts_csv"])){ $f = fopen($file_name, "r"); $f_columns = fgetcsv($f, 1000, ","); if(!$error & count($f_columns) != 8) { - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad column count."; } @@ -4818,7 +4818,7 @@ if(isset($_POST["import_client_contacts_csv"])){ fgetcsv($file, 1000, ","); // Skip first line $row_count = 0; $duplicate_count = 0; - while(($column = fgetcsv($file, 1000, ",")) !== FALSE){ + while(($column = fgetcsv($file, 1000, ",")) !== false){ $duplicate_detect = 0; if(isset($column[0])){ $name = trim(strip_tags(mysqli_real_escape_string($mysqli, $column[0]))); @@ -5209,19 +5209,19 @@ if(isset($_POST["import_client_locations_csv"])){ $client_id = intval($_POST['client_id']); $file_name = $_FILES["file"]["tmp_name"]; - $error = FALSE; + $error = false; //Check file is CSV $file_extension = strtolower(end(explode('.',$_FILES['file']['name']))); $allowed_file_extensions = array('csv'); if(in_array($file_extension,$allowed_file_extensions) === false){ - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad file extension"; } //Check file isn't empty elseif($_FILES["file"]["size"] < 1){ - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad file size (empty?)"; } @@ -5229,7 +5229,7 @@ if(isset($_POST["import_client_locations_csv"])){ $f = fopen($file_name, "r"); $f_columns = fgetcsv($f, 1000, ","); if(!$error & count($f_columns) != 7) { - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad column count."; } @@ -5239,7 +5239,7 @@ if(isset($_POST["import_client_locations_csv"])){ fgetcsv($file, 1000, ","); // Skip first line $row_count = 0; $duplicate_count = 0; - while(($column = fgetcsv($file, 1000, ",")) !== FALSE){ + while(($column = fgetcsv($file, 1000, ",")) !== false){ $duplicate_detect = 0; if(isset($column[0])){ $name = trim(strip_tags(mysqli_real_escape_string($mysqli, $column[0]))); @@ -5519,19 +5519,19 @@ if(isset($_POST["import_client_assets_csv"])){ $client_id = intval($_POST['client_id']); $file_name = $_FILES["file"]["tmp_name"]; - $error = FALSE; + $error = false; //Check file is CSV $file_extension = strtolower(end(explode('.',$_FILES['file']['name']))); $allowed_file_extensions = array('csv'); if(in_array($file_extension,$allowed_file_extensions) === false){ - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad file extension"; } //Check file isn't empty elseif($_FILES["file"]["size"] < 1){ - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad file size (empty?)"; } @@ -5539,7 +5539,7 @@ if(isset($_POST["import_client_assets_csv"])){ $f = fopen($file_name, "r"); $f_columns = fgetcsv($f, 1000, ","); if(!$error & count($f_columns) != 8) { - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad column count."; } @@ -5549,7 +5549,7 @@ if(isset($_POST["import_client_assets_csv"])){ fgetcsv($file, 1000, ","); // Skip first line $row_count = 0; $duplicate_count = 0; - while(($column = fgetcsv($file, 1000, ",")) !== FALSE){ + while(($column = fgetcsv($file, 1000, ",")) !== false){ $duplicate_detect = 0; if(isset($column[0])){ $name = trim(strip_tags(mysqli_real_escape_string($mysqli, $column[0]))); @@ -6163,19 +6163,19 @@ if(isset($_POST["import_client_logins_csv"])){ $client_id = intval($_POST['client_id']); $file_name = $_FILES["file"]["tmp_name"]; - $error = FALSE; + $error = false; //Check file is CSV $file_extension = strtolower(end(explode('.',$_FILES['file']['name']))); $allowed_file_extensions = array('csv'); if(in_array($file_extension,$allowed_file_extensions) === false){ - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad file extension"; } //Check file isn't empty elseif($_FILES["file"]["size"] < 1){ - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad file size (empty?)"; } @@ -6183,7 +6183,7 @@ if(isset($_POST["import_client_logins_csv"])){ $f = fopen($file_name, "r"); $f_columns = fgetcsv($f, 1000, ","); if(!$error & count($f_columns) != 4) { - $error = TRUE; + $error = true; $_SESSION['alert_message'] = "Bad column count."; } @@ -6193,7 +6193,7 @@ if(isset($_POST["import_client_logins_csv"])){ fgetcsv($file, 1000, ","); // Skip first line $row_count = 0; $duplicate_count = 0; - while(($column = fgetcsv($file, 1000, ",")) !== FALSE){ + while(($column = fgetcsv($file, 1000, ",")) !== false){ $duplicate_detect = 0; if(isset($column[0])){ $name = trim(strip_tags(mysqli_real_escape_string($mysqli, $column[0]))); diff --git a/rfc6238.php b/rfc6238.php index 0468bde3..c95554db 100644 --- a/rfc6238.php +++ b/rfc6238.php @@ -1,170 +1,151 @@ SecretKey: $secretkey
    "; + $result = ""; + print "
    SecretKey: $secretkey
    "; - $key = base32static::decode($secretkey); - print "Key(base 32 decode): $key
    "; + $key = base32static::decode($secretkey); + print "Key(base 32 decode): $key
    "; - $unixtimestamp = time()/30; - print "UnixTimeStamp (time()/30): $unixtimestamp
    "; - for($i=-($rangein30s); $i<=$rangein30s; $i++) { - $checktime = (int)($unixtimestamp+$i); - print "Calculating oath_hotp from (int)(unixtimestamp +- 30sec offset): $checktime basing on secret key
    "; + $unixtimestamp = time()/30; + print "UnixTimeStamp (time()/30): $unixtimestamp
    "; + for($i=-($rangein30s); $i<=$rangein30s; $i++) { + $checktime = (int)($unixtimestamp+$i); + print "Calculating oath_hotp from (int)(unixtimestamp +- 30sec offset): $checktime basing on secret key
    "; - $thiskey = self::oath_hotp($key, $checktime, true); - print "======================================================
    "; - print "CheckTime: $checktime oath_hotp:".$thiskey."
    "; - $result = $result." # ".self::oath_truncate($thiskey,6,true); - } + $thiskey = self::oath_hotp($key, $checktime, true); + print "======================================================
    "; + print "CheckTime: $checktime oath_hotp:".$thiskey."
    "; + $result = $result." # ".self::oath_truncate($thiskey,6,true); + } - return $result; + return $result; } public static function getBarCodeUrl($username, $domain, $secretkey, $issuer) { - $url = "http://chart.apis.google.com/chart"; - $url = $url."?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/"; - $url = $url.$username . "@" . $domain . "%3Fsecret%3D" . $secretkey . '%26issuer%3D' . rawurlencode($issuer); + $url = "http://chart.apis.google.com/chart"; + $url = $url."?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/"; + $url = $url.$username . "@" . $domain . "%3Fsecret%3D" . $secretkey . '%26issuer%3D' . rawurlencode($issuer); - return $url; - } - public static function generateRandomClue($length = 16) { - $b32 = "234567QWERTYUIOPASDFGHJKLZXCVBNM"; - $s = ""; - for ($i = 0; $i < $length; $i++) - $s .= $b32[rand(0,31)]; - return $s; + return $url; } - private static function hotp_tobytestream($key) { - $result = array(); - $last = strlen($key); - for ($i = 0; $i < $last; $i = $i + 2) { - $x = $key[$i] + $key[$i + 1]; - $x = strtoupper($x); - $x = hexdec($x); - $result = $result.chr($x); - } + private static function oath_hotp ($key, $counter, $debug=false) { + $result = ""; + $orgcounter = $counter; + $cur_counter = array(0,0,0,0,0,0,0,0); - return $result; - } - private static function oath_hotp ($key, $counter, $debug=false) { - $result = ""; - $orgcounter = $counter; - $cur_counter = array(0,0,0,0,0,0,0,0); + if ($debug) { + print "Packing counter $counter (".dechex($counter).")into binary string - pay attention to hex representation of key and binary representation
    "; + } - if ($debug) { - print "Packing counter $counter (".dechex($counter).")into binary string - pay attention to hex representation of key and binary representation
    "; - } + for($i=7;$i>=0;$i--) { // C for unsigned char, * for repeating to the end of the input data + $cur_counter[$i] = pack ('C*', $counter); - for($i=7;$i>=0;$i--) { // C for unsigned char, * for repeating to the end of the input data - $cur_counter[$i] = pack ('C*', $counter); + if ($debug) { + print $cur_counter[$i]."(".dechex(ord($cur_counter[$i])).")"." from $counter
    "; + } + + $counter = $counter >> 8; + } + + if ($debug) { + foreach ($cur_counter as $char) { + print ord($char) . " "; + } + + print "
    "; + } + + $binary = implode($cur_counter); + // Pad to 8 characters + str_pad($binary, 8, chr(0), STR_PAD_LEFT); if ($debug) { - print $cur_counter[$i]."(".dechex(ord($cur_counter[$i])).")"." from $counter
    "; + print "Prior to HMAC calculation pad with zero on the left until 8 characters.
    "; + print "Calculate sha1 HMAC(Hash-based Message Authentication Code https://en.wikipedia.org/wiki/HMAC).
    "; + print "hash_hmac ('sha1', $binary, $key)
    "; + } + $result = hash_hmac ('sha1', $binary, $key); + + if ($debug) { + print "Result: $result
    "; + } + return $result; + } + private static function oath_truncate($hash, $length = 6, $debug=false) { + $result=""; + + // Convert to dec + if ($debug) { + print "converting hex hash into characters
    "; } - $counter = $counter >> 8; - } + $hashcharacters = str_split($hash,2); - if ($debug) { - foreach ($cur_counter as $char) { - print ord($char) . " "; + if ($debug) { + print_r($hashcharacters); + print "
    and convert to decimals:
    "; + } + for ($j=0; $j"; - } + if ($debug) { + print_r($hmac_result); + } + // http://php.net/manual/ru/function.hash-hmac.php + // adopted from brent at thebrent dot net 21-May-2009 08:17 comment + $offset = $hmac_result[19] & 0xf; - $binary = implode($cur_counter); - // Pad to 8 characters - str_pad($binary, 8, chr(0), STR_PAD_LEFT); + if ($debug) { + print "Calculating offset as 19th element of hmac:".$hmac_result[19]."
    "; + print "offset:".$offset; + } - if ($debug) { - print "Prior to HMAC calculation pad with zero on the left until 8 characters.
    "; - print "Calculate sha1 HMAC(Hash-based Message Authentication Code https://en.wikipedia.org/wiki/HMAC).
    "; - print "hash_hmac ('sha1', $binary, $key)
    "; - } - $result = hash_hmac ('sha1', $binary, $key); + $result = ( + (($hmac_result[$offset+0] & 0x7f) << 24) | + (($hmac_result[$offset+1] & 0xff) << 16) | + (($hmac_result[$offset+2] & 0xff) << 8) | + ($hmac_result[$offset+3] & 0xff) + ) % pow(10,$length); + return $result; + } - if ($debug) { - print "Result: $result
    "; - } - return $result; - } - private static function oath_truncate($hash, $length = 6, $debug=false) { - $result=""; - - // Convert to dec - if ($debug) { - print "converting hex hash into characters
    "; - } - - $hashcharacters = str_split($hash,2); - - if ($debug) { - print_r($hashcharacters); - print "
    and convert to decimals:
    "; - } - for ($j=0; $j"; - print "offset:".$offset; - } - - $result = ( - (($hmac_result[$offset+0] & 0x7f) << 24 ) | - (($hmac_result[$offset+1] & 0xff) << 16 ) | - (($hmac_result[$offset+2] & 0xff) << 8 ) | - ($hmac_result[$offset+3] & 0xff) - ) % pow(10,$length); - return $result; - } - - } +} diff --git a/ticket.php b/ticket.php index ec7749a2..5008d57c 100644 --- a/ticket.php +++ b/ticket.php @@ -1,4 +1,5 @@ - 0 ) { ?> + if ($ticket_asset_count > 0) { ?> @@ -617,17 +618,15 @@ if (isset($_GET['ticket_id'])) {
    - - From c219324bb85b01a3e4a57831e30a9540cf31c097 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Thu, 9 Feb 2023 11:42:57 +0000 Subject: [PATCH 2/3] General cleanup/formatting --- login.php | 34 ++++++++++++++++++++++++++-------- portal/login_microsoft.php | 9 ++++++--- portal/login_reset.php | 36 +++++++++++++++++++++++++++--------- 3 files changed, 59 insertions(+), 20 deletions(-) diff --git a/login.php b/login.php index 164801a2..aaaf1c3a 100644 --- a/login.php +++ b/login.php @@ -99,10 +99,19 @@ if (isset($_POST['login'])) { $subject = "$config_app_name new login for $user_name"; $body = "Hi $user_name,

    A recent successful login to your $config_app_name account was considered a little unusual. If this was you, you can safely ignore this email!

    IP Address: $ip
    User Agent: $user_agent

    If you did not perform this login, your credentials may be compromised.

    Thanks,
    ITFlow"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_mail_from_email, $config_mail_from_name, - $user_email, $user_name, - $subject, $body); + $mail = sendSingleEmail( + $config_smtp_host, + $config_smtp_username, + $config_smtp_password, + $config_smtp_encryption, + $config_smtp_port, + $config_mail_from_email, + $config_mail_from_name, + $user_email, + $user_name, + $subject, + $body + ); } @@ -174,10 +183,19 @@ if (isset($_POST['login'])) { $subject = "Important: $config_app_name failed 2FA login attempt for $user_name"; $body = "Hi $user_name,

    A recent login to your $config_app_name account was unsuccessful due to an incorrect 2FA code. If you did not attempt this login, your credentials may be compromised.

    Thanks,
    ITFlow"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_mail_from_email, $config_mail_from_name, - $user_email, $user_name, - $subject, $body); + $mail = sendSingleEmail( + $config_smtp_host, + $config_smtp_username, + $config_smtp_password, + $config_smtp_encryption, + $config_smtp_port, + $config_mail_from_email, + $config_mail_from_name, + $user_email, + $user_name, + $subject, + $body + ); } // HTML feedback for incorrect 2FA code diff --git a/portal/login_microsoft.php b/portal/login_microsoft.php index 894f777d..4ab12928 100644 --- a/portal/login_microsoft.php +++ b/portal/login_microsoft.php @@ -60,9 +60,12 @@ if (isset($_POST['code']) && $_POST['state'] == session_id()) { // Send request via CURL (server side) so user cannot see the client secret $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $token_grant_url); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, - http_build_query($params)); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt( + $ch, + CURLOPT_POSTFIELDS, + http_build_query($params) + ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); #curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // DEBUG ONLY - WAMP diff --git a/portal/login_reset.php b/portal/login_reset.php index 2b179d14..c772df0e 100644 --- a/portal/login_reset.php +++ b/portal/login_reset.php @@ -24,7 +24,7 @@ if (!isset($_SESSION)) { session_start(); } -$ip = strip_tags(mysqli_real_escape_string($mysqli,getIP())); +$ip = strip_tags(mysqli_real_escape_string($mysqli, getIP())); $user_agent = strip_tags(mysqli_real_escape_string($mysqli, $_SERVER['HTTP_USER_AGENT'])); $company_sql = mysqli_query($mysqli, "SELECT company_name FROM companies WHERE company_id = '1'"); @@ -61,10 +61,19 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $subject = "Password reset for $company_name ITFlow Portal"; $body = "Hello, $name

    Someone (probably you) has requested a new password for your account on $company_name's ITFlow Client Portal.

    Please click here to reset your password.

    Alternatively, copy and paste this URL into your browser:
    $url

    If you didn't request this change, you can safely ignore this email.

    ~
    $company_name
    Support Department
    $config_mail_from_email"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_mail_from_email, $config_mail_from_name, - $email, $name, - $subject, $body); + $mail = sendSingleEmail( + $config_smtp_host, + $config_smtp_username, + $config_smtp_password, + $config_smtp_encryption, + $config_smtp_port, + $config_mail_from_email, + $config_mail_from_name, + $email, + $name, + $subject, + $body + ); // Error handling if ($mail !== true) { @@ -112,10 +121,19 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { $body = "Hello, $name

    Your password for your account on $company_name's ITFlow Client Portal was successfully reset. You should be all set!

    If you didn't reset your password, please get in touch ASAP.

    ~
    $company_name
    Support Department
    $config_mail_from_email"; - $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port, - $config_mail_from_email, $config_mail_from_name, - $email, $name, - $subject, $body); + $mail = sendSingleEmail( + $config_smtp_host, + $config_smtp_username, + $config_smtp_password, + $config_smtp_encryption, + $config_smtp_port, + $config_mail_from_email, + $config_mail_from_name, + $email, + $name, + $subject, + $body + ); // Error handling if ($mail !== true) { From 615f317d2b6d7a169214d3b4a311736142f94117 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Thu, 9 Feb 2023 12:29:12 +0000 Subject: [PATCH 3/3] General cleanup/formatting --- accounts.php | 11 +- ajax.php | 10 +- base32static.php | 4 +- calendar_event_add_modal.php | 4 +- calendar_event_edit_modal.php | 4 +- calendar_events.php | 14 +- categories.php | 32 +- client_add_modal.php | 4 +- client_asset_add_modal.php | 8 +- client_asset_copy_modal.php | 8 +- client_asset_edit_modal.php | 10 +- client_asset_interface_add_modal.php | 2 +- client_assets.php | 24 +- client_certificates.php | 16 +- client_contact_add_modal.php | 2 +- client_contact_details.php | 6 +- client_contact_edit_modal.php | 2 +- client_contacts.php | 20 +- client_document_add_from_template_modal.php | 4 +- client_document_add_modal.php | 2 +- client_document_details.php | 2 +- client_document_edit_modal.php | 2 +- client_document_template_details.php | 2 +- client_document_templates.php | 26 +- client_documents.php | 26 +- client_domain_add_modal.php | 4 +- client_domains.php | 10 +- client_edit_modal.php | 4 +- client_events.php | 4 +- client_invoices.php | 9 +- client_location_add_modal.php | 2 +- client_location_edit_modal.php | 2 +- client_locations.php | 12 +- client_login_add_modal.php | 8 +- client_login_edit_modal.php | 8 +- client_logins.php | 17 +- client_logs.php | 39 +- client_network_add_modal.php | 2 +- client_networks.php | 27 +- client_overview.php | 4 +- client_payments.php | 20 +- client_quotes.php | 8 +- client_recurring_invoices.php | 18 +- client_scheduled_tickets.php | 10 +- client_service_edit_modal.php | 14 +- client_services.php | 80 ++-- client_shared_items.php | 217 +++++------ client_software.php | 354 +++++++++--------- client_software_add_from_template_modal.php | 2 +- client_software_add_modal.php | 4 +- client_software_edit_modal.php | 8 +- client_software_templates.php | 37 +- client_tickets.php | 360 +++++++++--------- client_trips.php | 12 +- client_vendor_templates.php | 312 ++++++++-------- client_vendors.php | 12 +- clients.php | 46 +-- companies.php | 8 +- cron.php | 245 +++++++------ cron_ticket_email_parser.php | 19 +- dashboard_financial.php | 14 +- dashboard_technical.php | 28 +- expense_add_modal.php | 14 +- expense_copy_modal.php | 14 +- expense_edit_modal.php | 14 +- expenses.php | 32 +- functions.php | 18 +- get_credential.php | 4 +- get_settings.php | 2 +- global_search.php | 14 +- guest_download_file.php | 8 +- guest_pay_invoice_stripe.php | 16 +- guest_post.php | 16 +- guest_view_item.php | 6 +- guest_view_quote.php | 10 +- inc_all_client.php | 88 +++-- invoice_add_modal.php | 4 +- invoice_edit_modal.php | 2 +- invoice_payment_add_modal.php | 12 +- invoices.php | 24 +- item_edit_modal.php | 2 +- logs.php | 30 +- notifications_dismissed.php | 12 +- pagination.php | 2 +- pagination_head.php | 38 +- payments.php | 319 ++++++++-------- product_add_modal.php | 202 +++++----- product_edit_modal.php | 196 +++++----- products.php | 191 +++++----- quote_add_modal.php | 4 +- quote_edit_modal.php | 2 +- quotes.php | 386 ++++++++++---------- recurring_invoice.php | 7 +- recurring_invoice_add_modal.php | 4 +- recurring_invoice_edit_modal.php | 2 +- recurring_invoices.php | 352 +++++++++--------- report_expense_by_vendor.php | 12 +- report_expense_summary.php | 10 +- report_income_by_client.php | 4 +- report_income_summary.php | 12 +- report_profit_loss.php | 54 +-- report_tax_summary.php | 104 +++--- report_ticket_by_client.php | 4 +- revenue_add_modal.php | 336 ++++++++--------- revenue_edit_modal.php | 336 ++++++++--------- revenues.php | 30 +- rfc6238.php | 12 +- scheduled_ticket_add_modal.php | 6 +- scheduled_tickets.php | 182 ++++----- settings_api.php | 6 +- settings_defaults.php | 14 +- settings_software_templates.php | 193 +++++----- settings_tags.php | 37 +- settings_taxes.php | 29 +- settings_vendor_templates.php | 309 ++++++++-------- side_nav.php | 2 +- ticket.php | 28 +- ticket_add_modal.php | 12 +- ticket_edit_modal.php | 10 +- ticket_invoice_add_modal.php | 6 +- tickets.php | 2 +- top_nav.php | 2 +- transfer_add_modal.php | 20 +- transfer_edit_modal.php | 20 +- transfers.php | 322 ++++++++-------- trip_add_modal.php | 4 +- trip_copy_modal.php | 4 +- trip_edit_modal.php | 4 +- trips.php | 35 +- user_add_modal.php | 2 +- user_companies_modal.php | 93 ++--- user_edit_modal.php | 248 +++++++------ user_invite_modal.php | 127 ++++--- user_profile.php | 2 +- users.php | 10 +- vendor_add_from_template_modal.php | 2 +- vendor_edit_modal.php | 2 +- vendors.php | 343 +++++++++-------- 138 files changed, 3706 insertions(+), 3556 deletions(-) diff --git a/accounts.php b/accounts.php index 6b6413e8..c73e7fe6 100644 --- a/accounts.php +++ b/accounts.php @@ -9,11 +9,14 @@ if (!empty($_GET['sb'])) { } //Rebuild URL -$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o))); +$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o))); -$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM accounts - WHERE account_name LIKE '%$q%' AND company_id = $session_company_id - ORDER BY $sb $o LIMIT $record_from, $record_to"); +$sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM accounts + WHERE account_name LIKE '%$q%' AND company_id = $session_company_id + ORDER BY $sb $o LIMIT $record_from, $record_to" +); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); diff --git a/ajax.php b/ajax.php index 3902a37b..2e8610c0 100644 --- a/ajax.php +++ b/ajax.php @@ -141,7 +141,9 @@ if (isset($_GET['network_get_json_details'])) { } // Lookup all client locations, as networks can be associated with any client location - $locations_sql = mysqli_query($mysqli, "SELECT location_id, location_name FROM locations + $locations_sql = mysqli_query( + $mysqli, + "SELECT location_id, location_name FROM locations WHERE location_client_id = '$client_id' AND company_id = '$session_company_id'" ); while ($row = mysqli_fetch_array($locations_sql)) { @@ -226,11 +228,11 @@ if (isset($_GET['share_generate_link'])) { $item_encrypted_credential = ''; // Default empty $client_id = intval($_GET['client_id']); - $item_type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['type']))); + $item_type = trim(strip_tags(mysqli_real_escape_string($mysqli, $_GET['type']))); $item_id = intval($_GET['id']); - $item_note = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['note']))); + $item_note = trim(strip_tags(mysqli_real_escape_string($mysqli, $_GET['note']))); $item_view_limit = intval($_GET['views']); - $item_expires = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['expires']))); + $item_expires = trim(strip_tags(mysqli_real_escape_string($mysqli, $_GET['expires']))); $item_key = randomString(156); if ($item_type == "Document") { diff --git a/base32static.php b/base32static.php index 1bfad4cc..a59feaff 100644 --- a/base32static.php +++ b/base32static.php @@ -44,7 +44,7 @@ class Base32Static { $i=0; while($i < count($fiveBitBinaryArray)) { - $base32 .= self::$map[base_convert(str_pad($fiveBitBinaryArray[$i], 5,'0'), 2, 10)]; + $base32 .= self::$map[base_convert(str_pad($fiveBitBinaryArray[$i], 5, '0'), 2, 10)]; $i++; } @@ -71,7 +71,7 @@ class Base32Static { substr($input, -($allowedValues[$i])) != str_repeat(self::$map[32], $allowedValues[$i])) return false; } - $input = str_replace('=','', $input); + $input = str_replace('=', '', $input); $input = str_split($input); $binaryString = ""; diff --git a/calendar_event_add_modal.php b/calendar_event_add_modal.php index a3428a52..40a8be28 100644 --- a/calendar_event_add_modal.php +++ b/calendar_event_add_modal.php @@ -48,7 +48,7 @@ - Client - - Client - $sb, 'o' => $o))); +$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM categories - WHERE category_name LIKE '%$q%' - AND category_type = '$category' - AND category_archived_at IS NULL - AND company_id = $session_company_id - ORDER BY $sb $o LIMIT $record_from, $record_to" +$sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM categories + WHERE category_name LIKE '%$q%' + AND category_type = '$category' + AND category_archived_at IS NULL + AND company_id = $session_company_id + ORDER BY $sb $o LIMIT $record_from, $record_to" ); -$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); //Colors Used -$sql_colors_used = mysqli_query($mysqli,"SELECT category_color FROM categories - WHERE category_type = '$category' - AND category_archived_at IS NULL - AND company_id = $session_company_id" +$sql_colors_used = mysqli_query( + $mysqli, + "SELECT category_color FROM categories + WHERE category_type = '$category' + AND category_archived_at IS NULL + AND company_id = $session_company_id" ); while ($color_used_row = mysqli_fetch_array($sql_colors_used)) { diff --git a/client_add_modal.php b/client_add_modal.php index c1db4453..b3515ea7 100644 --- a/client_add_modal.php +++ b/client_add_modal.php @@ -64,7 +64,7 @@ @@ -271,7 +271,7 @@
      - Location - - Contact - - Network - - Vendor - - Location - - Contact - - Network - '$asset_created_at' OR network_archived_at IS NULL) AND network_client_id = $client_id ORDER BY network_name ASC"); + $sql_networks = mysqli_query($mysqli, "SELECT * FROM networks WHERE (network_archived_at > '$asset_created_at' OR network_archived_at IS NULL) AND network_client_id = $client_id ORDER BY network_name ASC"); while ($row = mysqli_fetch_array($sql_networks)) { $network_id_select = $row['network_id']; $network_name_select = htmlentities($row['network_name']); @@ -227,7 +227,7 @@ '$asset_created_at' OR vendor_archived_at IS NULL) AND vendor_client_id = $client_id AND vendor_template = 0 ORDER BY vendor_name ASC"); + $sql_vendors = mysqli_query($mysqli, "SELECT * FROM vendors WHERE (vendor_archived_at > '$asset_created_at' OR vendor_archived_at IS NULL) AND vendor_client_id = $client_id AND vendor_template = 0 ORDER BY vendor_name ASC"); while ($row = mysqli_fetch_array($sql_vendors)) { $vendor_id_select = $row['vendor_id']; $vendor_name_select = htmlentities($row['vendor_name']); diff --git a/client_asset_edit_modal.php b/client_asset_edit_modal.php index a2bc1180..74ab4a28 100644 --- a/client_asset_edit_modal.php +++ b/client_asset_edit_modal.php @@ -121,7 +121,7 @@ - Contact - '$asset_created_at' OR contact_archived_at IS NULL) AND contact_client_id = $client_id ORDER BY contact_name ASC"); + $sql_contacts = mysqli_query($mysqli, "SELECT * FROM contacts WHERE (contact_archived_at > '$asset_created_at' OR contact_archived_at IS NULL) AND contact_client_id = $client_id ORDER BY contact_name ASC"); while ($row = mysqli_fetch_array($sql_contacts)) { $contact_id_select = $row['contact_id']; $contact_name_select = htmlentities($row['contact_name']); ?> @@ -181,7 +181,7 @@ '$asset_created_at' OR network_archived_at IS NULL) AND network_client_id = $client_id ORDER BY network_name ASC"); + $sql_networks = mysqli_query($mysqli, "SELECT * FROM networks WHERE (network_archived_at > '$asset_created_at' OR network_archived_at IS NULL) AND network_client_id = $client_id ORDER BY network_name ASC"); while ($row = mysqli_fetch_array($sql_networks)) { $network_id_select = $row['network_id']; $network_name_select = htmlentities($row['network_name']); @@ -229,7 +229,7 @@ '$asset_created_at' OR vendor_archived_at IS NULL) AND vendor_client_id = $client_id ORDER BY vendor_name ASC"); + $sql_vendors = mysqli_query($mysqli, "SELECT * FROM vendors WHERE (vendor_archived_at > '$asset_created_at' OR vendor_archived_at IS NULL) AND vendor_client_id = $client_id ORDER BY vendor_name ASC"); while ($row = mysqli_fetch_array($sql_vendors)) { $vendor_id_select = $row['vendor_id']; $vendor_name_select = htmlentities($row['vendor_name']); diff --git a/client_asset_interface_add_modal.php b/client_asset_interface_add_modal.php index 48873d5b..6a36cc0b 100644 --- a/client_asset_interface_add_modal.php +++ b/client_asset_interface_add_modal.php @@ -75,7 +75,7 @@ $sb, 'o' => $o))); +$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o))); -$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM assets - LEFT JOIN contacts ON asset_contact_id = contact_id - LEFT JOIN locations ON asset_location_id = location_id - LEFT JOIN logins ON login_asset_id = asset_id - WHERE asset_client_id = $client_id - AND asset_archived_at IS NULL - AND (asset_name LIKE '%$q%' OR asset_type LIKE '%$q%' OR asset_ip LIKE '%$q%' OR asset_make LIKE '%$q%' OR asset_model LIKE '%$q%' OR asset_serial LIKE '%$q%' OR asset_os LIKE '%$q%' OR contact_name LIKE '%$q%' OR location_name LIKE '%$q%') - AND ($type_query) - ORDER BY $sb $o LIMIT $record_from, $record_to" +$sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM assets + LEFT JOIN contacts ON asset_contact_id = contact_id + LEFT JOIN locations ON asset_location_id = location_id + LEFT JOIN logins ON login_asset_id = asset_id + WHERE asset_client_id = $client_id + AND asset_archived_at IS NULL + AND (asset_name LIKE '%$q%' OR asset_type LIKE '%$q%' OR asset_ip LIKE '%$q%' OR asset_make LIKE '%$q%' OR asset_model LIKE '%$q%' OR asset_serial LIKE '%$q%' OR asset_os LIKE '%$q%' OR contact_name LIKE '%$q%' OR location_name LIKE '%$q%') + AND ($type_query) + ORDER BY $sb $o LIMIT $record_from, $record_to" ); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); diff --git a/client_certificates.php b/client_certificates.php index 7a7d6315..852ba6f6 100644 --- a/client_certificates.php +++ b/client_certificates.php @@ -1,21 +1,21 @@ - $sb, 'o' => $o))); +$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM certificates +$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM certificates WHERE certificate_client_id = $client_id AND (certificate_name LIKE '%$q%' OR certificate_domain LIKE '%$q%' OR certificate_issued_by LIKE '%$q%') ORDER BY $sb $o LIMIT $record_from, $record_to"); -$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); ?> @@ -30,7 +30,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
      - +
      @@ -62,7 +62,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); - Location -
      -
      +

      -
      -
      +
      +
      +

      Scheduled Tickets

      -
      - -
      +
      -
      - - "> - - - - - - + +
      -
      - - - - - - - - - - - - - - -
      ClientSubjectPriorityFrequencyNext Run Date
      Action
      )"> -
      + +
      + +
      + +
      + + "> + + + + + + + + + + + + + + + + + + + + + + +
      ClientSubjectPriorityFrequencyNext Run DateAction
      )"> + + +
      +
      + +
      - -
    -
    $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM api_keys +$sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM api_keys LEFT JOIN clients on api_keys.api_key_client_id = clients.client_id WHERE (api_key_name LIKE '%$q%') AND api_keys.company_id = $session_company_id ORDER BY $sb $o LIMIT $record_from, $record_to"); -$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); ?> diff --git a/settings_defaults.php b/settings_defaults.php index 7323d381..4c55e079 100644 --- a/settings_defaults.php +++ b/settings_defaults.php @@ -19,7 +19,7 @@ require_once("inc_all_settings.php"); ?> @@ -40,7 +40,7 @@ require_once("inc_all_settings.php"); ?> @@ -61,7 +61,7 @@ require_once("inc_all_settings.php"); ?> @@ -82,7 +82,7 @@ require_once("inc_all_settings.php"); ?> @@ -103,7 +103,7 @@ require_once("inc_all_settings.php"); ?> @@ -123,7 +123,7 @@ require_once("inc_all_settings.php"); ?> @@ -143,7 +143,7 @@ require_once("inc_all_settings.php"); ?> diff --git a/settings_software_templates.php b/settings_software_templates.php index 4646edef..0d388f86 100644 --- a/settings_software_templates.php +++ b/settings_software_templates.php @@ -1,115 +1,118 @@ - + $sb, 'o' => $o))); +$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM software - LEFT JOIN logins ON login_software_id = software_id - WHERE software_template = 1 - AND (software_name LIKE '%$q%' OR software_type LIKE '%$q%' OR software_key LIKE '%$q%') - ORDER BY $sb $o LIMIT $record_from, $record_to"); +$sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM software + LEFT JOIN logins ON login_software_id = software_id + WHERE software_template = 1 + AND (software_name LIKE '%$q%' OR software_type LIKE '%$q%' OR software_key LIKE '%$q%') + ORDER BY $sb $o LIMIT $record_from, $record_to" +); -$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); ?>
    -
    -

    License Templates

    -
    - +
    +

    License Templates

    +
    + +
    -
    -
    -
    - -
    - -
    -
    - -
    - -
    -
    -
    +
    + + +
    -
    -
    - -
    - -
    -
    - - "> - - - - - - - - - - - - - - - - - - + - include("client_software_template_edit_modal.php"); - } - - ?> + + +
    +
    +
    TemplateTypeLicense TypeSeatsAction
    $software_version"; ?> -
    + "> + + + + + + + + + + -
    TemplateTypeLicense TypeSeatsAction
    + while($row = mysqli_fetch_array($sql)){ + $software_id = $row['software_id']; + $software_name = htmlentities($row['software_name']); + $software_version = htmlentities($row['software_version']); + $software_type = htmlentities($row['software_type']); + $software_license_type = htmlentities($row['software_license_type']); + $software_key = htmlentities($row['software_key']); + $software_seats = htmlentities($row['software_seats']); + $software_purchase = $row['software_purchase']; + $software_expire = $row['software_expire']; + $software_notes = htmlentities($row['software_notes']); + + ?> + + $software_version"; ?> + + + + + + + + + + + + +
    +
    - -
    - - - \ No newline at end of file + $sb, 'o' => $o))); +$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o))); -$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM tags - WHERE tag_name LIKE '%$q%' - AND company_id = $session_company_id - ORDER BY $sb $o LIMIT $record_from, $record_to" +$sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM tags + WHERE tag_name LIKE '%$q%' + AND company_id = $session_company_id + ORDER BY $sb $o LIMIT $record_from, $record_to" ); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); if ($num_rows > 0) { //Colors Used - $sql_colors_used = mysqli_query($mysqli, "SELECT tag_color FROM tags - WHERE tag_archived_at IS NULL - AND company_id = $session_company_id" + $sql_colors_used = mysqli_query( + $mysqli, + "SELECT tag_color FROM tags + WHERE tag_archived_at IS NULL + AND company_id = $session_company_id" ); while ($color_used_row = mysqli_fetch_array($sql_colors_used)) { @@ -102,7 +107,7 @@ if ($num_rows > 0) { 0) {
    - +
    +require_once("settings_tag_add_modal.php"); +require_once("footer.php"); diff --git a/settings_taxes.php b/settings_taxes.php index 33e71072..15ba5a90 100644 --- a/settings_taxes.php +++ b/settings_taxes.php @@ -1,18 +1,21 @@ - $sb, 'o' => $o))); +$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT * FROM taxes - WHERE tax_archived_at IS NULL - AND company_id = $session_company_id - ORDER BY $sb $o" +$sql = mysqli_query( + $mysqli, + "SELECT * FROM taxes + WHERE tax_archived_at IS NULL + AND company_id = $session_company_id + ORDER BY $sb $o" ); $num_rows = mysqli_num_rows($sql); @@ -64,11 +67,11 @@ $num_rows = mysqli_num_rows($sql);

    No Records Here

    "; + echo "

    No Records Here

    "; } ?> @@ -81,9 +84,5 @@ $num_rows = mysqli_num_rows($sql);
    +require_once("settings_tax_add_modal.php"); +require_once("footer.php"); diff --git a/settings_vendor_templates.php b/settings_vendor_templates.php index c1915cba..39817874 100644 --- a/settings_vendor_templates.php +++ b/settings_vendor_templates.php @@ -1,176 +1,173 @@ - - $sb, 'o' => $o))); +$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM vendors - WHERE vendor_template = 1 - AND (vendor_name LIKE '%$q%' OR vendor_description LIKE '%$q%' OR vendor_account_number LIKE '%$q%' OR vendor_website LIKE '%$q%' OR vendor_contact_name LIKE '%$q%' OR vendor_email LIKE '%$q%' OR vendor_phone LIKE '%$phone_query%') ORDER BY $sb $o LIMIT $record_from, $record_to"); +$sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM vendors + WHERE vendor_template = 1 + AND (vendor_name LIKE '%$q%' OR vendor_description LIKE '%$q%' OR vendor_account_number LIKE '%$q%' OR vendor_website LIKE '%$q%' OR vendor_contact_name LIKE '%$q%' OR vendor_email LIKE '%$q%' OR vendor_phone LIKE '%$phone_query%') ORDER BY $sb $o LIMIT $record_from, $record_to" +); -$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); ?> -
    -
    -

    - Vendor Templates -

    -
    - -
    -
    -
    -
    - -
    - -
    -
    - -
    - -
    -
    -
    - -
    -
    -
    -
    - - "> - - - - - - - - - - - - - - - + +
    +
    +
    VendorDescriptionContactAction
    - - - -
    - - -
    - - -
    - - - -
    - - - -
    - -
    - +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
    +
    -
    -
    + "> + + + + + + + + + + while ($row = mysqli_fetch_array($sql)) { + $vendor_id = $row['vendor_id']; + $vendor_name = htmlentities($row['vendor_name']); + $vendor_description = htmlentities($row['vendor_description']); + if (empty($vendor_description)) { + $vendor_description_display = "-"; + } else { + $vendor_description_display = $vendor_description; + } + $vendor_account_number = htmlentities($row['vendor_account_number']); + $vendor_contact_name = htmlentities($row['vendor_contact_name']); + if (empty($vendor_contact_name)) { + $vendor_contact_name_display = "-"; + } else { + $vendor_contact_name_display = $vendor_contact_name; + } + $vendor_phone = formatPhoneNumber($row['vendor_phone']); + $vendor_extension = htmlentities($row['vendor_extension']); + $vendor_email = htmlentities($row['vendor_email']); + $vendor_website = htmlentities($row['vendor_website']); + $vendor_hours = htmlentities($row['vendor_hours']); + $vendor_sla = htmlentities($row['vendor_sla']); + $vendor_code = htmlentities($row['vendor_code']); + $vendor_notes = htmlentities($row['vendor_notes']); + $vendor_template = intval($row['vendor_template']); - -
    VendorDescriptionContactAction
    + ?> + + + + + +
    + + + + + + + +
    + + +
    + + +
    + + + + + + + + + + + + +
    + +
    - -
    -
    - - - \ No newline at end of file +
    - -
    -
    - - -- Client (Optional) - - Client (Optional) - - Client (Optional) - $sb, 'o' => $o))); +$url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM trips +$sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM trips LEFT JOIN clients ON trip_client_id = client_id LEFT JOIN users ON trip_user_id = user_id WHERE (trip_purpose LIKE '%$q%' OR trip_source LIKE '%$q%' OR trip_destination LIKE '%$q%' OR trip_miles LIKE '%$q%' OR client_name LIKE '%$q%' OR user_name LIKE '%$q%') @@ -65,7 +68,7 @@ $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM trips ORDER BY $sb $o LIMIT $record_from, $record_to" ); -$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $total_found_rows = $num_rows[0]; $total_pages = ceil($total_found_rows / 10); diff --git a/user_add_modal.php b/user_add_modal.php index a41a9f0e..fe7a1421 100644 --- a/user_add_modal.php +++ b/user_add_modal.php @@ -57,7 +57,7 @@ " tabindex="-1"> - \ No newline at end of file +
    diff --git a/user_invite_modal.php b/user_invite_modal.php index 09bb4fca..d91597a0 100644 --- a/user_invite_modal.php +++ b/user_invite_modal.php @@ -1,71 +1,70 @@ - - - - \ No newline at end of file +