From 55f8ba652aa1f1d8e9fb6ee71e8b5992d366eca3 Mon Sep 17 00:00:00 2001 From: "AFTECH.RO" <38830718+aftechro@users.noreply.github.com> Date: Sat, 26 Feb 2022 02:08:38 +0000 Subject: [PATCH 1/8] Update ticket.php - Display IP on Asset section so would be handy for the technician when troubleshooting - Implement Asset warranty so the technician can take better decision regarding the asset fixing option (parts replacement under manufacturer warranty or in house parts replacement) --- ticket.php | 62 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 15 deletions(-) diff --git a/ticket.php b/ticket.php index f17abfed..9504190e 100644 --- a/ticket.php +++ b/ticket.php @@ -70,12 +70,14 @@ if(isset($_GET['ticket_id'])){ $contact_mobile = formatPhoneNumber($row['contact_mobile']); $asset_id = $row['asset_id']; + $asset_ip = htmlentities($row['asset_ip']); $asset_name = htmlentities($row['asset_name']); $asset_type = htmlentities($row['asset_type']); $asset_make = htmlentities($row['asset_make']); $asset_model = htmlentities($row['asset_model']); $asset_serial = htmlentities($row['asset_serial']); $asset_os = htmlentities($row['asset_os']); + $asset_warranty_expire = $row['asset_warranty_expire']; $location_name = $row['location_name']; $location_address = $row['location_address']; @@ -145,6 +147,18 @@ if(isset($_GET['ticket_id'])){ $client_tag_name_display_array[] = " $client_tag_name"; } $client_tags_display = implode(' ', $client_tag_name_display_array); + + // Get the asset warranty expiry + $date = date('Y-m-d H:i:s'); + $dt_value = $asset_warranty_expire; //sample date + $warranty_check = date('m/d/Y',strtotime('-8 hours')); + + if($dt_value <= $date){ + $dt_value = "Expired on $asset_warranty_expire"; $color ='red'; + }else{ + $color = 'green'; + } + ?> @@ -392,20 +406,7 @@ if(isset($_GET['ticket_id'])){

Asset

- -
- - -
- - - + Asset name:
- + OS: +
+ + IP: +
+ + + Model: +
+ + + + Service Tag: +
+ + + + Warranty expire:
Date: Sat, 26 Feb 2022 11:16:53 +0000 Subject: [PATCH 2/8] Move ajax logic to ajax.php --- ajax.php | 122 ++++++++++++++++++++++++++++++++++++++++ client_certificates.php | 8 +-- client_networks.php | 2 +- post.php | 99 -------------------------------- ticket_merge_modal.php | 2 +- 5 files changed, 128 insertions(+), 105 deletions(-) create mode 100644 ajax.php diff --git a/ajax.php b/ajax.php new file mode 100644 index 00000000..c4dbfa57 --- /dev/null +++ b/ajax.php @@ -0,0 +1,122 @@ + array("capture_peer_cert" => TRUE, "verify_peer" => FALSE,))); + $read = stream_socket_client($socket, $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $get); + $cert = stream_context_get_params($read); + $cert_public_key_obj = openssl_x509_parse($cert['options']['ssl']['peer_certificate']); + openssl_x509_export($cert['options']['ssl']['peer_certificate'], $export); + + // Process data + if($cert_public_key_obj){ + $response['success'] = "TRUE"; + $response['expire'] = date('Y-m-d', $cert_public_key_obj['validTo_time_t']); + $response['issued_by'] = strip_tags($cert_public_key_obj['issuer']['O']); + $response['public_key'] = $export; //nl2br + } + else{ + $response['success'] = "FALSE"; + } + + echo json_encode($response); + +} + +/* + * Looks up info for a given certificate ID from the database, used to dynamically populate modal fields + */ +if(isset($_GET['certificate_get_json_details'])){ + $certificate_id = intval($_GET['certificate_id']); + $client_id = intval($_GET['client_id']); + + // Individual certificate lookup + $cert_sql = mysqli_query($mysqli,"SELECT * FROM certificates WHERE certificate_id = $certificate_id AND certificate_client_id = $client_id"); + while($row = mysqli_fetch_array($cert_sql)){ + $response['certificate'][] = $row; + } + + // Get all domains for this client that could be linked to this certificate + $domains_sql = mysqli_query($mysqli, "SELECT domain_id, domain_name FROM domains WHERE domain_client_id = '$client_id' AND company_id = '$session_company_id'"); + while($row = mysqli_fetch_array($domains_sql)){ + $response['domains'][] = $row; + } + + echo json_encode($response); +} + +/* + * Looks up info on the ticket number provided, used to populate the ticket merge modal + */ +if(isset($_GET['merge_ticket_get_json_details'])){ + $merge_into_ticket_number = intval($_GET['merge_into_ticket_number']); + + $sql = mysqli_query($mysqli,"SELECT * FROM tickets + LEFT JOIN clients ON ticket_client_id = client_id + LEFT JOIN contacts ON ticket_contact_id = contact_id + WHERE ticket_number = '$merge_into_ticket_number' AND tickets.company_id = '$session_company_id'"); + + if(mysqli_num_rows($sql) == 0){ + //Do nothing. + } + else { + //Return ticket, client and contact details for the given ticket number + $response = mysqli_fetch_array($sql); + echo json_encode($response); + } +} + +/* + * Looks up info for a given network ID from the database, used to dynamically populate modal fields + */ +if(isset($_GET['network_get_json_details'])){ + $network_id = intval($_GET['network_id']); + $client_id = intval($_GET['client_id']); + + // Individual network lookup + $network_sql = mysqli_query($mysqli,"SELECT * FROM networks WHERE network_id = $network_id AND network_client_id = $client_id"); + while($row = mysqli_fetch_array($network_sql)){ + $response['network'][] = $row; + } + + // 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 + WHERE location_client_id = '$client_id' AND company_id = '$session_company_id'" + ); + while($row = mysqli_fetch_array($locations_sql)){ + $response['locations'][] = $row; + } + + echo json_encode($response); +} \ No newline at end of file diff --git a/client_certificates.php b/client_certificates.php index 08d689b8..df820aa0 100644 --- a/client_certificates.php +++ b/client_certificates.php @@ -140,7 +140,7 @@ include("client_certificate_add_modal.php"); // Send a GET request to post.php as post.php?certificate_get_json_details=true&client_id=NUM&certificate_id=NUM jQuery.get( - "post.php", + "ajax.php", {certificate_get_json_details: 'true', client_id: client_id, certificate_id: certificate_id}, function(data){ @@ -203,10 +203,10 @@ include("client_certificate_add_modal.php"); var publicKey = document.getElementById("editPublicKey"); } - //Send a GET request to post.php as post.php?fetch_certificate=TRUE&domain=DOMAIN + //Send a GET request to post.php as post.php?certificate_fetch_parse_json_details=TRUE&domain=DOMAIN jQuery.get( - "post.php", - {fetch_certificate: 'TRUE', domain: domain}, + "ajax.php", + {certificate_fetch_parse_json_details: 'TRUE', domain: domain}, function(data){ //If we get a response from post.php, parse it as JSON const ssl_data = JSON.parse(data); diff --git a/client_networks.php b/client_networks.php index bf2b1e6c..dbf9218a 100644 --- a/client_networks.php +++ b/client_networks.php @@ -170,7 +170,7 @@ function populateNetworkEditModal(client_id, network_id) { // Send a GET request to post.php as post.php?network_get_json_details=true&client_id=NUM&network_id=NUM jQuery.get( - "post.php", + "ajax.php", {network_get_json_details: 'true', client_id: client_id, network_id: network_id}, function(data){ diff --git a/post.php b/post.php index ef99c70d..ff794d38 100644 --- a/post.php +++ b/post.php @@ -5073,25 +5073,6 @@ if(isset($_POST['edit_network'])){ } -if(isset($_GET['network_get_json_details'])){ - $network_id = intval($_GET['network_id']); - $client_id = intval($_GET['client_id']); - - $network_sql = mysqli_query($mysqli,"SELECT * FROM networks WHERE network_id = $network_id AND network_client_id = $client_id"); - while($row = mysqli_fetch_array($network_sql)){ - $response['network'][] = $row; - } - - $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)){ - $response['locations'][] = $row; - } - - echo json_encode($response); -} - if(isset($_GET['delete_network'])){ $network_id = intval($_GET['delete_network']); @@ -5219,68 +5200,6 @@ if(isset($_POST['edit_certificate'])){ } -if(isset($_GET['certificate_get_json_details'])){ - $certificate_id = intval($_GET['certificate_id']); - $client_id = intval($_GET['client_id']); - - $cert_sql = mysqli_query($mysqli,"SELECT * FROM certificates WHERE certificate_id = $certificate_id AND certificate_client_id = $client_id"); - while($row = mysqli_fetch_array($cert_sql)){ - $response['certificate'][] = $row; - } - - $domains_sql = mysqli_query($mysqli, "SELECT domain_id, domain_name FROM domains - WHERE domain_client_id = '$client_id' AND company_id = '$session_company_id'" - ); - while($row = mysqli_fetch_array($domains_sql)){ - $response['domains'][] = $row; - } - - echo json_encode($response); -} - -if(isset($_GET['fetch_certificate'])){ - // PHP doesn't appreciate attempting SSL sockets to non-existent domains - if(empty($_GET['domain'])){ - exit(); - } - $domain = $_GET['domain']; - - // FQDNs in database shouldn't have a URL scheme, adding one - $domain = "https://".$domain; - - // Parse host and port - $url = parse_url($domain, PHP_URL_HOST); - $port = parse_url($domain, PHP_URL_PORT); - // Default port - if(!$port){ - $port = "443"; - } - - // Get certificate - // Using verify peer false to allow for self-signed / internal CA certs - $socket = "ssl://$url:$port"; - $get = stream_context_create(array("ssl" => array("capture_peer_cert" => TRUE, "verify_peer" => FALSE,))); - $read = stream_socket_client($socket, $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $get); - $cert = stream_context_get_params($read); - $cert_public_key_obj = openssl_x509_parse($cert['options']['ssl']['peer_certificate']); - openssl_x509_export($cert['options']['ssl']['peer_certificate'], $export); - - // Process data - if($cert_public_key_obj){ - $cert_data['success'] = "TRUE"; - $cert_data['expire'] = date('Y-m-d', $cert_public_key_obj['validTo_time_t']); - $cert_data['issued_by'] = strip_tags($cert_public_key_obj['issuer']['O']); - $cert_data['public_key'] = $export; //nl2br - } - else{ - $cert_data['success'] = "FALSE"; - } - - // Return as JSON - echo json_encode($cert_data); - -} - if(isset($_GET['delete_certificate'])){ $certificate_id = intval($_GET['delete_certificate']); @@ -5728,24 +5647,6 @@ if(isset($_GET['archive_ticket_reply'])){ } -if(isset($_GET['merge_ticket_get_json_details'])){ - $merge_into_ticket_number = intval($_GET['merge_into_ticket_number']); - - $sql = mysqli_query($mysqli,"SELECT * FROM tickets - LEFT JOIN clients ON ticket_client_id = client_id - LEFT JOIN contacts ON ticket_contact_id = contact_id - WHERE ticket_number = '$merge_into_ticket_number' AND tickets.company_id = '$session_company_id'"); - - if(mysqli_num_rows($sql) == 0){ - //Do nothing. - } - else { - //Return ticket, client and contact details for the given ticket number - $row = mysqli_fetch_array($sql); - echo json_encode($row); - } -} - if(isset($_POST['merge_ticket'])){ $ticket_id = intval($_POST['ticket_id']); $merge_into_ticket_number = intval($_POST['merge_into_ticket_number']); diff --git a/ticket_merge_modal.php b/ticket_merge_modal.php index 8521733b..80d578c2 100644 --- a/ticket_merge_modal.php +++ b/ticket_merge_modal.php @@ -74,7 +74,7 @@ //Send a GET request to post.php as post.php?merge_ticket_get_json_details=true&merge_into_ticket_number=NUMBER jQuery.get( - "post.php", + "ajax.php", {merge_ticket_get_json_details: 'true', merge_into_ticket_number: merge_into_ticket_number}, function(data){ //If we get a response from post.php, parse it as JSON From 3f65bc59936d204be95290e3fd882f97913cabb1 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sat, 26 Feb 2022 11:18:33 +0000 Subject: [PATCH 3/8] Text --- ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ajax.php b/ajax.php index c4dbfa57..07a56ad8 100644 --- a/ajax.php +++ b/ajax.php @@ -11,7 +11,7 @@ include("functions.php"); include("check_login.php"); /* - * Fetches SSL certificates from remote hosts & returns the relevant info (host, issuer, expiry) + * Fetches SSL certificates from remote hosts & returns the relevant info (issuer, expiry, public key) */ if(isset($_GET['certificate_fetch_parse_json_details'])){ // PHP doesn't appreciate attempting SSL sockets to non-existent domains From 80d5f332536c09ed4fa2bcd5c1a0428593e53896 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sat, 26 Feb 2022 11:22:27 +0000 Subject: [PATCH 4/8] Update price placeholder to use $invoice_currency_code --- invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/invoice.php b/invoice.php index ee5fbba4..5dd6f7cd 100644 --- a/invoice.php +++ b/invoice.php @@ -299,7 +299,7 @@ if(isset($_GET['invoice_id'])){ - + - + -
-
- -
- -
-
- -
- -
- -
-
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - - - - - - - -
-
-

Create your first user

-
-
- -
-
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
- -
-
-
- -
- - -
- -
- - -
-
-
- - - -
-
-

Company Details

-
-
- - Database config invalid, or users already exist in the database. - -
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
- -
- - - -
- -
-
- - - - -
-
-

Telemetry

-
-
-
-
Would you like to share some data with us?
- -
- -
- - -
- -
- -
- - -
- -
- - - -
-
-
- - - -
-
-

Welcome to ITFlow Setup

-
-
-

A database must be created before proceeding, then click on the Setup button to to get started,

-
-

Post installation, additional steps are required for tasks such as sending out recurring invoices, late payment reminders, scheduled tickets, alerts, etc.

- -
-

An API is present to allow integration with other third pary apps. An API Key will be auto generated and can be changed in settings after setup. The API will give you the following capabilities:

- -
-

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.

- Warning: config.php is not writable. Ensure the webserver user has write access.
"; - }else{ - // Else, able to write. Tidy up - unlink("config.php"); - } + -
Setup
-
- +
+ + +
+ + - +
+
+
Setup Checks
+
+
+ +
Install
+
+
- - - + + + + +
+
+

Connect your Database

+
+
+ + Database already configured. Any further changes should be made by editing the config.php file, + or deleting it and refreshing this page. + +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ + + +
+
+

Create your first user

+
+
+ +
+
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ + +
+ +
+ + +
+
+
+ + + +
+
+

Company Details

+
+
+ + Database config invalid, or users already exist in the database. + +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ + +
+ +
+ + + +
+ +
+
+ + + + +
+
+

Telemetry

+
+
+
+
Would you like to share some data with us?
+ +
+ +
+ + +
+ +
+ +
+ + +
+ +
+ +

Post installation, a few additional steps are required:

+ + +
+ + + +
+ +
+
+ + + +
+
+

Welcome to ITFlow Setup

+
+
+

Thank you for choosing to try ITFlow! Feel free to reach out on the forums if you have any questions.

+

A database must be created before proceeding - click on the button below to get started!

+
+

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.

+ Warning: config.php is not writable. Ensure the webserver process has write access. Check the docs for info.
"; + }else{ + // Else, able to write. Tidy up + unlink("config.php"); + } + ?> +
+
Begin Setup
+
+ + + + + + + - - + + - + - - - - - - - - - + + + + + + + + + - - + + From 839804c592fc9875aa6206ce80760f605506664e Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sat, 26 Feb 2022 12:50:44 +0000 Subject: [PATCH 8/8] Show API key section in new admin side navbar --- admin_side_nav.php | 8 ++++++++ api_keys.php => settings-api.php | 0 2 files changed, 8 insertions(+) rename api_keys.php => settings-api.php (100%) diff --git a/admin_side_nav.php b/admin_side_nav.php index 8a93b86c..22293061 100644 --- a/admin_side_nav.php +++ b/admin_side_nav.php @@ -112,6 +112,14 @@ + +