mirror of https://github.com/itflow-org/itflow
Reworked Client Domains, added mail host and dns host, made all the host columns sortable by reworking the logic and optimized the code further
This commit is contained in:
parent
7ca4163552
commit
88a96e3044
|
|
@ -89,6 +89,48 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>DNS Host</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-server"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="dnshost">
|
||||
<option value="">- Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
?>
|
||||
<option value="<?php echo $vendor_id; ?>"><?php echo $vendor_name; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Mail Host</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="mailhost">
|
||||
<option value="">- Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
?>
|
||||
<option value="<?php echo $vendor_id; ?>"><?php echo $vendor_name; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Expire Date</label>
|
||||
<div class="input-group">
|
||||
|
|
|
|||
|
|
@ -72,6 +72,28 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>DNS Host</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-server"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" id="editDomainDNShostId" name="dnshost">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Mail Host</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" id="editDomainMailhostId" name="mailhost">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Expire Date</label>
|
||||
<div class="input-group">
|
||||
|
|
|
|||
|
|
@ -10,11 +10,19 @@ require_once "inc_all_client.php";
|
|||
//Rebuild URL
|
||||
$url_query_strings_sort = http_build_query($get_copy);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM domains
|
||||
LEFT JOIN vendors ON domain_registrar = vendor_id
|
||||
WHERE domain_client_id = $client_id
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS domains.*,
|
||||
registrar.vendor_name AS registrar_name,
|
||||
dnshost.vendor_name AS dnshost_name,
|
||||
mailhost.vendor_name AS mailhost_name,
|
||||
webhost.vendor_name AS webhost_name
|
||||
FROM domains
|
||||
LEFT JOIN vendors AS registrar ON domains.domain_registrar = registrar.vendor_id
|
||||
LEFT JOIN vendors AS dnshost ON domains.domain_dnshost = dnshost.vendor_id
|
||||
LEFT JOIN vendors AS mailhost ON domains.domain_mailhost = mailhost.vendor_id
|
||||
LEFT JOIN vendors AS webhost ON domains.domain_webhost = webhost.vendor_id
|
||||
WHERE domain_client_id = $client_id
|
||||
AND domain_archived_at IS NULL
|
||||
AND (domain_name LIKE '%$q%' OR vendor_name LIKE '%$q%')
|
||||
AND (domains.domain_name LIKE '%$q%' OR domains.domain_description LIKE '%$q%' OR registrar.vendor_name LIKE '%$q%' OR dnshost.vendor_name LIKE '%$q%' OR mailhost.vendor_name LIKE '%$q%' OR webhost.vendor_name LIKE '%$q%')
|
||||
ORDER BY $sort $order LIMIT $record_from, $record_to");
|
||||
|
||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
|
|
@ -83,8 +91,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
</div>
|
||||
</td>
|
||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=domain_name&order=<?php echo $disp; ?>">Domain</a></th>
|
||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=vendor_name&order=<?php echo $disp; ?>">Registrar</a></th>
|
||||
<th>Web Host</th>
|
||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=registrar_name&order=<?php echo $disp; ?>">Registrar</a></th>
|
||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=webhost_name&order=<?php echo $disp; ?>">Web Host</a></th>
|
||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=dnshost_name&order=<?php echo $disp; ?>">DNS Host</a></th>
|
||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=mailhost_name&order=<?php echo $disp; ?>">Mail Host</a></th>
|
||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=domain_expire&order=<?php echo $disp; ?>">Expires</a></th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
|
|
@ -96,21 +106,22 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
$domain_id = intval($row['domain_id']);
|
||||
$domain_name = nullable_htmlentities($row['domain_name']);
|
||||
$domain_description = nullable_htmlentities($row['domain_description']);
|
||||
$domain_registrar = intval($row['domain_registrar']);
|
||||
$domain_webhost = intval($row['domain_webhost']);
|
||||
$domain_expire = nullable_htmlentities($row['domain_expire']);
|
||||
$domain_registrar_name = nullable_htmlentities($row['vendor_name']);
|
||||
$domain_registrar_name = nullable_htmlentities($row['registrar_name']);
|
||||
if($domain_registrar_name) {
|
||||
$domain_registrar_name_display = $domain_registrar_name;
|
||||
} else {
|
||||
$domain_registrar_name_display = "-";
|
||||
}
|
||||
$domain_webhost_name = nullable_htmlentities($row['webhost_name']);
|
||||
$domain_dnshost_name = nullable_htmlentities($row['dnshost_name']);
|
||||
$domain_mailhost_name = nullable_htmlentities($row['mailhost_name']);
|
||||
$domain_created_at = nullable_htmlentities($row['domain_created_at']);
|
||||
if (empty($domain_registrar_name)) {
|
||||
$domain_registrar_name = "-";
|
||||
}
|
||||
|
||||
$sql_domain_webhost = mysqli_query($mysqli, "SELECT vendor_name FROM vendors WHERE vendor_id = $domain_webhost");
|
||||
$row = mysqli_fetch_array($sql_domain_webhost);
|
||||
$domain_webhost_name = "-";
|
||||
if ($row) {
|
||||
$domain_webhost_name = nullable_htmlentities($row['vendor_name']);
|
||||
}
|
||||
// Add - if empty on the table
|
||||
$domain_registrar_name_display = $domain_registrar_name ? $domain_registrar_name : "-";
|
||||
$domain_webhost_name_display = $domain_webhost_name ? $domain_webhost_name : "-";
|
||||
$domain_dnshost_name_display = $domain_dnshost_name ? $domain_dnshost_name : "-";
|
||||
$domain_mailhost_name_display = $domain_mailhost_name ? $domain_mailhost_name : "-";
|
||||
|
||||
?>
|
||||
<tr>
|
||||
|
|
@ -131,8 +142,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
</div>
|
||||
</a>
|
||||
</td>
|
||||
<td><?php echo $domain_registrar_name; ?></td>
|
||||
<td><?php echo $domain_webhost_name; ?></td>
|
||||
<td><?php echo $domain_registrar_name_display; ?></td>
|
||||
<td><?php echo $domain_webhost_name_display; ?></td>
|
||||
<td><?php echo $domain_dnshost_name_display; ?></td>
|
||||
<td><?php echo $domain_mailhost_name_display; ?></td>
|
||||
<td><?php echo $domain_expire; ?></td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
|
|
|
|||
|
|
@ -1867,10 +1867,17 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
|||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.2.6'");
|
||||
}
|
||||
|
||||
// if (CURRENT_DATABASE_VERSION == '1.2.6') {
|
||||
// // Insert queries here required to update to DB version 1.2.7
|
||||
if (CURRENT_DATABASE_VERSION == '1.2.6') {
|
||||
|
||||
mysqli_query($mysqli, "ALTER TABLE `domains` ADD `domain_dnshost` INT(11) NOT NULL DEFAULT 0 AFTER `domain_webhost`");
|
||||
mysqli_query($mysqli, "ALTER TABLE `domains` ADD `domain_mailhost` INT(11) NOT NULL DEFAULT 0 AFTER `domain_dnshost`");
|
||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.2.7'");
|
||||
}
|
||||
|
||||
// if (CURRENT_DATABASE_VERSION == '1.2.7') {
|
||||
// // Insert queries here required to update to DB version 1.2.8
|
||||
// // Then, update the database to the next sequential version
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.2.7");
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.2.8");
|
||||
// }
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@
|
|||
* It is used in conjunction with database_updates.php
|
||||
*/
|
||||
|
||||
DEFINE("LATEST_DATABASE_VERSION", "1.2.6");
|
||||
DEFINE("LATEST_DATABASE_VERSION", "1.2.7");
|
||||
|
|
|
|||
4
db.sql
4
db.sql
|
|
@ -504,6 +504,8 @@ CREATE TABLE `domains` (
|
|||
`domain_accessed_at` datetime DEFAULT NULL,
|
||||
`domain_registrar` int(11) NOT NULL DEFAULT 0,
|
||||
`domain_webhost` int(11) NOT NULL DEFAULT 0,
|
||||
`domain_dnshost` int(11) NOT NULL DEFAULT 0,
|
||||
`domain_mailhost` int(11) NOT NULL DEFAULT 0,
|
||||
`domain_client_id` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`domain_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
|
@ -1899,4 +1901,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2024-04-08 16:47:46
|
||||
-- Dump completed on 2024-04-10 13:20:42
|
||||
|
|
|
|||
|
|
@ -70,6 +70,47 @@ function populateDomainEditModal(client_id, domain_id) {
|
|||
}
|
||||
});
|
||||
|
||||
// DNS Host dropdown
|
||||
var dnshostDropdown = document.getElementById("editDomainDNShostId");
|
||||
|
||||
// Clear registrar dropdown
|
||||
var i, L = dnshostDropdown.options.length -1;
|
||||
for(i = L; i >= 0; i--) {
|
||||
dnshostDropdown.remove(i);
|
||||
}
|
||||
dnshostDropdown[dnshostDropdown.length] = new Option('- Vendor -', '0');
|
||||
|
||||
// Populate dropdown
|
||||
vendors.forEach(vendor => {
|
||||
if (parseInt(vendor.vendor_id) == parseInt(domain.domain_dnshost)) {
|
||||
// Selected domain
|
||||
dnshostDropdown[dnshostDropdown.length] = new Option(vendor.vendor_name, vendor.vendor_id, true, true);
|
||||
}
|
||||
else{
|
||||
dnshostDropdown[dnshostDropdown.length] = new Option(vendor.vendor_name, vendor.vendor_id);
|
||||
}
|
||||
});
|
||||
|
||||
// Mail Host dropdown
|
||||
var mailhostDropdown = document.getElementById("editDomainMailhostId");
|
||||
|
||||
// Clear mailhost dropdown
|
||||
var i, L = mailhostDropdown.options.length -1;
|
||||
for(i = L; i >= 0; i--) {
|
||||
mailhostDropdown.remove(i);
|
||||
}
|
||||
mailhostDropdown[mailhostDropdown.length] = new Option('- Vendor -', '0');
|
||||
|
||||
// Populate dropdown
|
||||
vendors.forEach(vendor => {
|
||||
if (parseInt(vendor.vendor_id) == parseInt(domain.domain_mailhost)) {
|
||||
// Selected domain
|
||||
mailhostDropdown[mailhostDropdown.length] = new Option(vendor.vendor_name, vendor.vendor_id, true, true);
|
||||
}
|
||||
else{
|
||||
mailhostDropdown[mailhostDropdown.length] = new Option(vendor.vendor_name, vendor.vendor_id);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ if (isset($_POST['add_domain'])) {
|
|||
$name = preg_replace("(^https?://)", "", sanitizeInput($_POST['name']));
|
||||
$description = sanitizeInput($_POST['description']);
|
||||
$registrar = intval($_POST['registrar']);
|
||||
$dnshost = intval($_POST['dnshost']);
|
||||
$webhost = intval($_POST['webhost']);
|
||||
$mailhost = intval($_POST['mailhost']);
|
||||
$extended_log_description = '';
|
||||
$expire = sanitizeInput($_POST['expire']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
|
@ -39,7 +41,7 @@ if (isset($_POST['add_domain'])) {
|
|||
$whois = sanitizeInput($records['whois']);
|
||||
|
||||
// Add domain record
|
||||
mysqli_query($mysqli,"INSERT INTO domains SET domain_name = '$name', domain_description = '$description', domain_registrar = $registrar, domain_webhost = $webhost, domain_expire = $expire, domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_txt = '$txt', domain_raw_whois = '$whois', domain_notes = '$notes', domain_client_id = $client_id");
|
||||
mysqli_query($mysqli,"INSERT INTO domains SET domain_name = '$name', domain_description = '$description', domain_registrar = $registrar, domain_webhost = $webhost, domain_dnshost = $dnshost, domain_mailhost = $mailhost, domain_expire = $expire, domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_txt = '$txt', domain_raw_whois = '$whois', domain_notes = '$notes', domain_client_id = $client_id");
|
||||
|
||||
// Get inserted ID (for linking certificate, if exists)
|
||||
$domain_id = mysqli_insert_id($mysqli);
|
||||
|
|
@ -72,7 +74,9 @@ if (isset($_POST['edit_domain'])) {
|
|||
$name = preg_replace("(^https?://)", "", sanitizeInput($_POST['name']));
|
||||
$description = sanitizeInput($_POST['description']);
|
||||
$registrar = intval($_POST['registrar']);
|
||||
$dnshost = intval($_POST['dnshost']);
|
||||
$webhost = intval($_POST['webhost']);
|
||||
$mailhost = intval($_POST['mailhost']);
|
||||
$expire = sanitizeInput($_POST['expire']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
||||
|
|
@ -104,7 +108,7 @@ if (isset($_POST['edit_domain'])) {
|
|||
$txt = sanitizeInput($records['txt']);
|
||||
$whois = sanitizeInput($records['whois']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE domains SET domain_name = '$name', domain_description = '$description', domain_registrar = $registrar, domain_webhost = $webhost, domain_expire = $expire, domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_txt = '$txt', domain_raw_whois = '$whois', domain_notes = '$notes' WHERE domain_id = $domain_id");
|
||||
mysqli_query($mysqli,"UPDATE domains SET domain_name = '$name', domain_description = '$description', domain_registrar = $registrar, domain_webhost = $webhost, domain_dnshost = $dnshost, domain_mailhost = $mailhost, domain_expire = $expire, domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_txt = '$txt', domain_raw_whois = '$whois', domain_notes = '$notes' WHERE domain_id = $domain_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Domain', log_action = 'Modify', log_description = '$session_name modified domain $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $domain_id");
|
||||
|
|
|
|||
Loading…
Reference in New Issue