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'])) {
    - -