diff --git a/add_certificate_modal.php b/add_certificate_modal.php
new file mode 100644
index 00000000..2292710f
--- /dev/null
+++ b/add_certificate_modal.php
@@ -0,0 +1,51 @@
+
\ No newline at end of file
diff --git a/client.php b/client.php
index 122c79b9..a1976a31 100644
--- a/client.php
+++ b/client.php
@@ -78,6 +78,9 @@ if(isset($_GET['client_id'])){
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('domain_id') AS num FROM domains WHERE client_id = $client_id"));
$num_domains = $row['num'];
+
+ $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('certificate_id') AS num FROM certificates WHERE client_id = $client_id"));
+ $num_certificates = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('software_id') AS num FROM software WHERE client_id = $client_id"));
$num_software = $row['num'];
diff --git a/client_certificates.php b/client_certificates.php
new file mode 100644
index 00000000..1ae5e2c2
--- /dev/null
+++ b/client_certificates.php
@@ -0,0 +1,127 @@
+ $sb, 'o' => $o)));
+
+//Paging
+if(isset($_GET['p'])){
+ $p = intval($_GET['p']);
+ $record_from = (($p)-1)*$config_records_per_page;
+ $record_to = $config_records_per_page;
+}else{
+ $record_from = 0;
+ $record_to = $config_records_per_page;
+ $p = 1;
+}
+
+if(isset($_GET['q'])){
+ $q = mysqli_real_escape_string($mysqli,$_GET['q']);
+}else{
+ $q = "";
+}
+
+if(!empty($_GET['sb'])){
+ $sb = mysqli_real_escape_string($mysqli,$_GET['sb']);
+}else{
+ $sb = "certificate_name";
+}
+
+if(isset($_GET['o'])){
+ if($_GET['o'] == 'ASC'){
+ $o = "ASC";
+ $disp = "DESC";
+ }else{
+ $o = "DESC";
+ $disp = "ASC";
+ }
+}else{
+ $o = "ASC";
+ $disp = "DESC";
+}
+
+$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM certificates
+ WHERE client_id = $client_id AND (certificate_name 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()"));
+$total_found_rows = $num_rows[0];
+$total_pages = ceil($total_found_rows / 10);
+
+?>
+
+
+
+
\ No newline at end of file
diff --git a/client_routes.php b/client_routes.php
index e471f021..da921ac9 100644
--- a/client_routes.php
+++ b/client_routes.php
@@ -25,6 +25,9 @@ if(isset($_GET['tab'])){
elseif($_GET['tab'] == "domains"){
include("client_domains.php");
}
+ elseif($_GET['tab'] == "certificates"){
+ include("client_certificates.php");
+ }
elseif($_GET['tab'] == "software"){
include("client_software.php");
}
diff --git a/client_side_nav.php b/client_side_nav.php
index 9847aae9..a5a794ff 100644
--- a/client_side_nav.php
+++ b/client_side_nav.php
@@ -95,6 +95,19 @@
+
+ ">
+
+
+ Certificates
+ 0){ ?>
+
+
+
+
+
+
">
diff --git a/db.sql b/db.sql
index c0eab5f0..9891689a 100644
--- a/db.sql
+++ b/db.sql
@@ -123,6 +123,27 @@ CREATE TABLE `categories` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `certificates`
+--
+
+DROP TABLE IF EXISTS `certificates`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `certificates` (
+ `certificate_id` int(11) NOT NULL AUTO_INCREMENT,
+ `certificate_name` varchar(200) NOT NULL,
+ `certificate_issued_by` varchar(200) NOT NULL,
+ `certificate_expire` date DEFAULT NULL,
+ `certificate_notes` text DEFAULT NULL,
+ `certificate_created_at` datetime NOT NULL,
+ `certificate_updated_at` datetime DEFAULT NULL,
+ `client_id` int(11) NOT NULL,
+ `company_id` int(11) NOT NULL,
+ PRIMARY KEY (`certificate_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `clients`
--
@@ -215,7 +236,7 @@ CREATE TABLE `domains` (
`domain_updated_at` datetime DEFAULT NULL,
`domain_registrar` int(11) DEFAULT NULL,
`domain_webhost` int(11) DEFAULT NULL,
- `client_id` int(11) DEFAULT NULL,
+ `client_id` int(11) NOT NULL,
`company_id` int(11) NOT NULL,
PRIMARY KEY (`domain_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@@ -822,6 +843,22 @@ CREATE TABLE `user_companies` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `user_keys`
+--
+
+DROP TABLE IF EXISTS `user_keys`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `user_keys` (
+ `user_key_id` int(11) NOT NULL AUTO_INCREMENT,
+ `user_key_name` varchar(200) DEFAULT NULL,
+ `user_public_key` varchar(250) NOT NULL,
+ `user_id` int(11) NOT NULL,
+ PRIMARY KEY (`user_key_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `users`
--
@@ -883,4 +920,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2021-01-22 18:05:30
+-- Dump completed on 2021-01-26 16:07:08
diff --git a/edit_certificate_modal.php b/edit_certificate_modal.php
new file mode 100644
index 00000000..7717d5f2
--- /dev/null
+++ b/edit_certificate_modal.php
@@ -0,0 +1,51 @@
+
\ No newline at end of file
diff --git a/post.php b/post.php
index 568bcf1b..3193ab2a 100644
--- a/post.php
+++ b/post.php
@@ -3566,6 +3566,62 @@ if(isset($_GET['delete_domain'])){
}
+if(isset($_POST['add_certificate'])){
+
+ $client_id = intval($_POST['client_id']);
+ $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
+ $issued_by = strip_tags(mysqli_real_escape_string($mysqli,$_POST['issued_by']));
+ $expire = strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire']));
+ if(empty($expire)){
+ $expire = "0000-00-00";
+ }
+
+ mysqli_query($mysqli,"INSERT INTO certificates SET certificate_name = '$name', certificate_issued_by = '$issued_by', certificate_expire = '$expire', certificate_created_at = NOW(), client_id = $client_id, company_id = $session_company_id");
+
+ //Logging
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Certificate', log_action = 'Created', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
+
+ $_SESSION['alert_message'] = "Certificate added";
+
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+
+}
+
+if(isset($_POST['edit_certificate'])){
+
+ $certificate_id = intval($_POST['certificate_id']);
+ $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
+ $issued_by = strip_tags(mysqli_real_escape_string($mysqli,$_POST['issued_by']));
+ $expire = strip_tags(mysqli_real_escape_string($mysqli,$_POST['expire']));
+ if(empty($expire)){
+ $expire = "0000-00-00";
+ }
+
+ mysqli_query($mysqli,"UPDATE certificates SET certificate_name = '$name', certificate_issued_by = '$issued_by', certificate_expire = '$expire', certificate_updated_at = NOW() WHERE certificate_id = $certificate_id AND company_id = $session_company_id");
+
+ //Logging
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Certificate', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
+
+ $_SESSION['alert_message'] = "Certificate updated";
+
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+
+}
+
+if(isset($_GET['delete_certificate'])){
+ $certificate_id = intval($_GET['delete_certificate']);
+
+ mysqli_query($mysqli,"DELETE FROM certificates WHERE certificate_id = $certificate_id AND company_id = $session_company_id");
+
+ //Logging
+ mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Certificate', log_action = 'Deleted', log_description = '$certificate_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
+
+ $_SESSION['alert_message'] = "Certificate deleted";
+
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+
+}
+
if(isset($_POST['add_software'])){
$client_id = intval($_POST['client_id']);