From 438e7ac8388d48e66e750f14b6be62f839ad4663 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sun, 13 Mar 2022 09:31:28 +0000 Subject: [PATCH 1/7] Add database field for A record, correct other DNS record fields --- db.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db.sql b/db.sql index 81307296..078d3db5 100644 --- a/db.sql +++ b/db.sql @@ -431,9 +431,10 @@ CREATE TABLE `domains` ( `domain_id` int(11) NOT NULL AUTO_INCREMENT, `domain_name` varchar(200) NOT NULL, `domain_expire` date DEFAULT NULL, - `domain_name_servers` VARCHAR(255) NULL DEFAULT NULL, - `domain_mail_servers` VARCHAR(255) NULL DEFAULT NULL, - `domain_raw_whois` TEXT NULL DEFAULT NULL, + `domain_ip` varchar(255) DEFAULT NULL, + `domain_name_servers` varchar(255) DEFAULT NULL, + `domain_mail_servers` varchar(255) DEFAULT NULL, + `domain_raw_whois` text DEFAULT NULL, `domain_created_at` datetime NOT NULL, `domain_updated_at` datetime DEFAULT NULL, `domain_archived_at` datetime DEFAULT NULL, From ead895aad59116e35c6a622b324e239ae38e3f11 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sun, 13 Mar 2022 09:32:08 +0000 Subject: [PATCH 2/7] Fetch A record details for domain when added --- client_domain_edit_modal.php | 10 ++++++++++ client_domains.php | 1 + post.php | 6 ++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/client_domain_edit_modal.php b/client_domain_edit_modal.php index a475154e..027d3c91 100644 --- a/client_domain_edit_modal.php +++ b/client_domain_edit_modal.php @@ -72,6 +72,16 @@
+
+ +
+
+ +
+ +
+
+
diff --git a/client_domains.php b/client_domains.php index 41c2c87c..94b7d38c 100644 --- a/client_domains.php +++ b/client_domains.php @@ -168,6 +168,7 @@ include("client_domain_add_modal.php"); document.getElementById("editDomainId").value = domain_id; document.getElementById("editDomainName").value = domain.domain_name; document.getElementById("editExpire").value = domain.domain_expire; + document.getElementById("editDomainIP").value = domain.domain_ip; document.getElementById("editNameServers").value = domain.domain_name_servers; document.getElementById("editMailServers").value = domain.domain_mail_servers; document.getElementById("editRawWhois").value = domain.domain_raw_whois; diff --git a/post.php b/post.php index b7783370..cd62cb28 100644 --- a/post.php +++ b/post.php @@ -5315,20 +5315,22 @@ if(isset($_POST['edit_domain'])){ $expire = "0000-00-00"; } - // NS, MX and WHOIS data + // A, NS, MX and WHOIS data if(filter_var($name, FILTER_VALIDATE_DOMAIN) && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')){ $domain = escapeshellarg($name); + $a = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short $domain"))); $ns = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short NS $domain"))); $mx = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short MX $domain"))); $whois = trim(strip_tags(mysqli_real_escape_string($mysqli,shell_exec("whois -H $domain | sed 's/ //g' | head -30")))); } else{ + $a = ''; $ns = ''; $mx = ''; $whois = ''; } - mysqli_query($mysqli,"UPDATE domains SET domain_name = '$name', domain_registrar = $registrar, domain_webhost = $webhost, domain_expire = '$expire', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_raw_whois = '$whois', domain_updated_at = NOW() WHERE domain_id = $domain_id AND company_id = $session_company_id"); + mysqli_query($mysqli,"UPDATE domains SET domain_name = '$name', domain_registrar = $registrar, domain_webhost = $webhost, domain_expire = '$expire', domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_raw_whois = '$whois', domain_updated_at = NOW() WHERE domain_id = $domain_id AND company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Domain', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id"); From 3a6b893f4f37b05ca24fa289906489aca8158797 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sun, 13 Mar 2022 10:28:17 +0000 Subject: [PATCH 3/7] Attempt to parse the expiry date for .com/.org/.net domains - hacky --- client_domain_edit_modal.php | 2 +- post.php | 46 +++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/client_domain_edit_modal.php b/client_domain_edit_modal.php index 027d3c91..9a3c0bff 100644 --- a/client_domain_edit_modal.php +++ b/client_domain_edit_modal.php @@ -99,7 +99,7 @@
- +
diff --git a/post.php b/post.php index cd62cb28..e9202ddb 100644 --- a/post.php +++ b/post.php @@ -5283,17 +5283,27 @@ if(isset($_POST['add_domain'])){ // NS, MX and WHOIS data if(filter_var($name, FILTER_VALIDATE_DOMAIN) && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')){ $domain = escapeshellarg($name); + $a = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short $domain"))); $ns = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short NS $domain"))); $mx = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short MX $domain"))); $whois = trim(strip_tags(mysqli_real_escape_string($mysqli,shell_exec("whois -H $domain | sed 's/ //g' | head -30")))); + + // Get expiry date for com/org/net domains - This is very hacky. An API would be better. + if(!empty($whois && $expire == '0000-00-00')){ + if(substr($_POST['name'], -3) == 'com' OR substr($_POST['name'], -3) == 'org' OR substr($_POST['name'], -3) == 'net'){ + $pos = strpos($whois, 'Registry Expiry Date:'); + $expire = substr($whois, $pos+22,10); + } + } } else{ - $ns = ''; - $mx = ''; - $whois = ''; + $a = ''; + $ns = ''; + $mx = ''; + $whois = ''; } - mysqli_query($mysqli,"INSERT INTO domains SET domain_name = '$name', domain_registrar = $registrar, domain_webhost = $webhost, domain_expire = '$expire', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_raw_whois = '$whois', domain_created_at = NOW(), domain_client_id = $client_id, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO domains SET domain_name = '$name', domain_registrar = $registrar, domain_webhost = $webhost, domain_expire = '$expire', domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_raw_whois = '$whois', domain_created_at = NOW(), domain_client_id = $client_id, company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Domain', log_action = 'Created', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id"); @@ -5312,22 +5322,30 @@ if(isset($_POST['edit_domain'])){ $webhost = intval($_POST['webhost']); $expire = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire']))); if(empty($expire)){ - $expire = "0000-00-00"; + $expire = "0000-00-00"; } // A, NS, MX and WHOIS data if(filter_var($name, FILTER_VALIDATE_DOMAIN) && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')){ - $domain = escapeshellarg($name); - $a = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short $domain"))); - $ns = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short NS $domain"))); - $mx = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short MX $domain"))); - $whois = trim(strip_tags(mysqli_real_escape_string($mysqli,shell_exec("whois -H $domain | sed 's/ //g' | head -30")))); + $domain = escapeshellarg($name); + $a = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short $domain"))); + $ns = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short NS $domain"))); + $mx = strip_tags(mysqli_real_escape_string($mysqli,shell_exec("dig +short MX $domain"))); + $whois = trim(strip_tags(mysqli_real_escape_string($mysqli,shell_exec("whois -H $domain | sed 's/ //g' | head -30")))); + + // Get expiry date for com/org/net domains - This is very hacky. An API would be better. + if(!empty($whois)){ + if(substr($_POST['name'], -3) == 'com' OR substr($_POST['name'], -3) == 'org' OR substr($_POST['name'], -3) == 'net'){ + $pos = strpos($whois, 'Registry Expiry Date:'); + $expire = substr($whois, $pos+22,10); + } + } } else{ - $a = ''; - $ns = ''; - $mx = ''; - $whois = ''; + $a = ''; + $ns = ''; + $mx = ''; + $whois = ''; } mysqli_query($mysqli,"UPDATE domains SET domain_name = '$name', domain_registrar = $registrar, domain_webhost = $webhost, domain_expire = '$expire', domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_raw_whois = '$whois', domain_updated_at = NOW() WHERE domain_id = $domain_id AND company_id = $session_company_id"); From 81e67f4ed3c72845b3f900507d1cddd51ce9640d Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sun, 13 Mar 2022 10:54:55 +0000 Subject: [PATCH 4/7] Comment client_name as not returned in sql query. Comment client_id as we already have it --- client_overview.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client_overview.php b/client_overview.php index e0f655f6..6986faf4 100644 --- a/client_overview.php +++ b/client_overview.php @@ -61,8 +61,8 @@ $sql_tickets_stale = mysqli_query($mysqli,"SELECT * FROM tickets $contact_extension = $row['contact_extension']; $contact_mobile = formatPhoneNumber($row['contact_mobile']); $contact_email = $row['contact_email']; - $client_id = $row['client_id']; - $client_name = $row['client_name']; + //$client_id = $row['client_id']; + //$client_name = $row['client_name']; $department_name = $row['department_name']; ?> From bdef68ddf5c8ddfda23f565ae664af53a2d1ed4d Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sun, 13 Mar 2022 11:27:23 +0000 Subject: [PATCH 5/7] Add notes to client overview --- ajax.php | 12 +++ client_overview.php | 257 +++++++++++++++++++++++++------------------- 2 files changed, 156 insertions(+), 113 deletions(-) diff --git a/ajax.php b/ajax.php index 78c7c877..bc052352 100644 --- a/ajax.php +++ b/ajax.php @@ -141,4 +141,16 @@ if(isset($_GET['network_get_json_details'])){ } echo json_encode($response); +} + +if(isset($_POST['client_set_notes'])){ + $client_id = intval($_POST['client_id']); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['notes']))); + + // Update notes + mysqli_query($mysqli, "UPDATE clients SET client_notes = '$notes' WHERE client_id = '$client_id'"); + + // Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Client', log_action = 'Modify', log_description = '$session_name modified client notes', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), log_client_id = $client_id, log_user_id = $session_user_id, company_id = $session_company_id"); + } \ No newline at end of file diff --git a/client_overview.php b/client_overview.php index 6986faf4..98e32b42 100644 --- a/client_overview.php +++ b/client_overview.php @@ -5,7 +5,7 @@ $sql_contacts = mysqli_query($mysqli,"SELECT * FROM contacts LEFT JOIN departmen $sql_vendors = mysqli_query($mysqli,"SELECT * FROM vendors WHERE vendor_client_id = $client_id AND company_id = $session_company_id ORDER BY vendor_updated_at DESC LIMIT 5"); $sql_documents = mysqli_query($mysqli, "SELECT * FROM documents WHERE document_client_id = $client_id AND documents.company_id = $session_company_id ORDER BY document_updated_at DESC LIMIT 5"); - + $sql_tickets = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_client_id = $client_id AND tickets.company_id = $session_company_id ORDER BY ticket_updated_at DESC LIMIT 5"); $sql_logins = mysqli_query($mysqli,"SELECT * FROM logins WHERE login_client_id = $client_id AND company_id = $session_company_id ORDER BY login_updated_at DESC LIMIT 5"); @@ -40,161 +40,192 @@ $sql_tickets_stale = mysqli_query($mysqli,"SELECT * FROM tickets
- 0){ ?> + 0){ ?> + + + +
+ +
+
+
Client Notes
+ +
+
+ +
-
- -
-
-
Recent Contacts
- - - - while($row = mysqli_fetch_array($sql_contacts)){ - $contact_id = $row['contact_id']; - $contact_name = $row['contact_name']; - $contact_title = $row['contact_title']; - $contact_phone = formatPhoneNumber($row['contact_phone']); - $contact_extension = $row['contact_extension']; - $contact_mobile = formatPhoneNumber($row['contact_mobile']); - $contact_email = $row['contact_email']; - //$client_id = $row['client_id']; - //$client_name = $row['client_name']; - $department_name = $row['department_name']; +
+
+
Recent Contacts
+
+ + - - - - - + while($row = mysqli_fetch_array($sql_contacts)){ + $contact_id = $row['contact_id']; + $contact_name = $row['contact_name']; + $contact_title = $row['contact_title']; + $contact_phone = formatPhoneNumber($row['contact_phone']); + $contact_extension = $row['contact_extension']; + $contact_mobile = formatPhoneNumber($row['contact_mobile']); + $contact_email = $row['contact_email']; + //$client_id = $row['client_id']; + //$client_name = $row['client_name']; + $department_name = $row['department_name']; - + ?> + + + + + - -
-
-

+
+

-
+ + + +
+
- + - 0){ ?> + 0){ ?> - +
- -
-
-
Domains Expiring Soon (30d)
- - - +
+
Domains Expiring Soon (30d)
+
+ + - - - - + while($row = mysqli_fetch_array($sql_domains_expiring)){ + $domain_id = $row['domain_id']; + $domain_name = $row['domain_name']; + $domain_expire = $row['domain_expire']; - + ?> + + + + - -
-
+ + + +
+
- + - 0){ ?> + 0){ ?>
- -
-
-
Asset Warranties Expiring Soon (90d)
- - - +
+
Asset Warranties Expiring Soon (90d)
+
+ + - - - - + while($row = mysqli_fetch_array($sql_asset_warranties_expiring)){ + $asset_id = $row['asset_id']; + $asset_name = $row['asset_name']; + $asset_warranty_expire = $row['asset_warranty_expire']; - + ?> + + + + - -
-
+ + + +
+
- + - 0){ ?> + 0){ ?>
- -
-
-
Stale Tickets (14d)
- - - +
+
Stale Tickets (14d)
+
+ + - - - - - + while($row = mysqli_fetch_array($sql_tickets_stale)){ + $ticket_id = $row['ticket_id']; + $ticket_prefix = $row['ticket_prefix']; + $ticket_number = $row['ticket_number']; + $ticket_subject = $row['ticket_subject']; + $ticket_created_at = $row['ticket_created_at']; - + ?> + + + + + - -
-
+ + + +
+
- + - \ No newline at end of file + + + \ No newline at end of file From 8bea883fa60a6f9b4b768d1b64610093af28e57a Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sun, 13 Mar 2022 11:29:21 +0000 Subject: [PATCH 6/7] Change note outline to primary --- client_overview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client_overview.php b/client_overview.php index 98e32b42..9ae36b16 100644 --- a/client_overview.php +++ b/client_overview.php @@ -46,7 +46,7 @@ $sql_tickets_stale = mysqli_query($mysqli,"SELECT * FROM tickets
-
+
Client Notes
From 1d84fade631e06cbea0fde4a30c802e3cd6c3d4c Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sun, 13 Mar 2022 18:35:29 +0000 Subject: [PATCH 7/7] Add basic portal functionality --- portal/check_login.php | 33 ++++++++++++ portal/index.php | 72 +++++++++++++++++++++++++ portal/login.php | 96 +++++++++++++++++++++++++++++++++ portal/ticket.php | 117 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 318 insertions(+) create mode 100644 portal/check_login.php create mode 100644 portal/index.php create mode 100644 portal/login.php create mode 100644 portal/ticket.php diff --git a/portal/check_login.php b/portal/check_login.php new file mode 100644 index 00000000..41667071 --- /dev/null +++ b/portal/check_login.php @@ -0,0 +1,33 @@ + + + + + + + + + <?php echo $config_app_name; ?> | Client Portal + + + + + + + + + + + + + +
+

Logged in as

+ +
+

My open tickets

+ + + + + + + + + + "; + echo ""; + echo ""; + echo ""; + } + ?> + +
SubjectState
$ticket[ticket_subject]$ticket[ticket_status]
+
\ No newline at end of file diff --git a/portal/login.php b/portal/login.php new file mode 100644 index 00000000..95209987 --- /dev/null +++ b/portal/login.php @@ -0,0 +1,96 @@ + + + + + + + <?php echo $config_app_name; ?> | Client Portal Login + + + + + + + + + + + + + +
+
+
+

- Client Portal Login

+ +
+ + + + + +
+ +
+
+ diff --git a/portal/ticket.php b/portal/ticket.php new file mode 100644 index 00000000..f5a60f2f --- /dev/null +++ b/portal/ticket.php @@ -0,0 +1,117 @@ + + + + + + + + <?php echo $config_app_name; ?> | Client Portal - Tickets + + + + + + + + + + + + + +
+ +

Ticket Details -

+

State:

+

Priority:

+ +
+ + + +
+
+

+
+ + " alt="User Avatar" class="img-size-50 mr-3 img-circle"> + + + + + + + +
+ +
+ +
+
+

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