mirror of
https://github.com/itflow-org/itflow
synced 2026-03-02 11:54:52 +00:00
Merge pull request #888 from wrongecho/dns-expiry-null-fix
Domain expiration dates
This commit is contained in:
2
cron.php
2
cron.php
@@ -138,7 +138,7 @@ if($config_enable_alert_domain_expire == 1){
|
|||||||
$mysqli,
|
$mysqli,
|
||||||
"SELECT * FROM domains
|
"SELECT * FROM domains
|
||||||
LEFT JOIN clients ON domain_client_id = client_id
|
LEFT JOIN clients ON domain_client_id = client_id
|
||||||
WHERE domain_expire = CURDATE() + INTERVAL $day DAY"
|
WHERE domain_expire IS NOT NULL AND domain_expire = CURDATE() + INTERVAL $day DAY"
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($row = mysqli_fetch_array($sql)) {
|
while ($row = mysqli_fetch_array($sql)) {
|
||||||
|
|||||||
@@ -41,12 +41,19 @@ if ( $argv[1] !== $config_cron_key ) {
|
|||||||
// END ERROR
|
// END ERROR
|
||||||
// REFRESH DOMAIN WHOIS DATA (1 a day)
|
// REFRESH DOMAIN WHOIS DATA (1 a day)
|
||||||
// Get the oldest updated domain (MariaDB shows NULLs first when ordering by default)
|
// Get the oldest updated domain (MariaDB shows NULLs first when ordering by default)
|
||||||
$row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT domain_id, domain_name FROM `domains` ORDER BY domain_updated_at LIMIT 1"));
|
$row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT domain_id, domain_name, domain_expire FROM `domains` ORDER BY domain_updated_at LIMIT 1"));
|
||||||
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
|
|
||||||
|
// Get current data in database
|
||||||
$domain_id = intval($row['domain_id']);
|
$domain_id = intval($row['domain_id']);
|
||||||
$domain_name = sanitizeInput($row['domain_name']);
|
$domain_name = sanitizeInput($row['domain_name']);
|
||||||
|
$current_expire = sanitizeInput($row['domain_expire']);
|
||||||
|
|
||||||
|
// Touch the record we're refreshing to ensure we don't loop
|
||||||
|
mysqli_query($mysqli, "UPDATE domains SET domain_updated_at = NOW() WHERE domain_id = $domain_id");
|
||||||
|
|
||||||
|
// Lookup fresh info
|
||||||
$expire = getDomainExpirationDate($domain_name);
|
$expire = getDomainExpirationDate($domain_name);
|
||||||
$records = getDomainRecords($domain_name);
|
$records = getDomainRecords($domain_name);
|
||||||
$a = sanitizeInput($records['a']);
|
$a = sanitizeInput($records['a']);
|
||||||
@@ -55,16 +62,18 @@ if ($row) {
|
|||||||
$txt = sanitizeInput($records['txt']);
|
$txt = sanitizeInput($records['txt']);
|
||||||
$whois = sanitizeInput($records['whois']);
|
$whois = sanitizeInput($records['whois']);
|
||||||
|
|
||||||
if (
|
// Handle expiry date
|
||||||
$expire === 'NULL'
|
if (strtotime($expire)) {
|
||||||
&& $row['domain_expire'] !== null
|
$expire = "'" . $expire . "'"; // Valid
|
||||||
&& (new DateTime($row['domain_expire'])) >= (new DateTime())
|
} elseif (!strtotime($expire) && strtotime($current_expire)) {
|
||||||
) {
|
// New expiry date is invalid, but old one is OK - reverting back
|
||||||
$expire = $row['domain_expire'];
|
$expire = "'" . $current_expire . "'";
|
||||||
|
} else {
|
||||||
|
// Neither are valid, setting expiry to NULL
|
||||||
|
$expire = 'NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the domain
|
|
||||||
mysqli_query($mysqli, "UPDATE domains SET domain_name = '$domain_name', domain_expire = '$expire', domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_txt = '$txt', domain_raw_whois = '$whois' WHERE domain_id = $domain_id");
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Re-add the cert refresher
|
// Update the domain
|
||||||
|
mysqli_query($mysqli, "UPDATE domains SET domain_name = '$domain_name', domain_expire = $expire, domain_ip = '$a', domain_name_servers = '$ns', domain_mail_servers = '$mx', domain_txt = '$txt', domain_raw_whois = '$whois' WHERE domain_id = $domain_id");
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,16 +16,17 @@ if (isset($_POST['add_domain'])) {
|
|||||||
$expire = sanitizeInput($_POST['expire']);
|
$expire = sanitizeInput($_POST['expire']);
|
||||||
$notes = sanitizeInput($_POST['notes']);
|
$notes = sanitizeInput($_POST['notes']);
|
||||||
|
|
||||||
if (empty($expire)) {
|
// Set/check/lookup expiry date
|
||||||
$expire = "NULL";
|
if (strtotime($expire)) {
|
||||||
} else {
|
|
||||||
$expire = "'" . $expire . "'";
|
$expire = "'" . $expire . "'";
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
// Get domain expiry date - if not specified
|
|
||||||
if ($expire == 'NULL') {
|
|
||||||
$expire = getDomainExpirationDate($name);
|
$expire = getDomainExpirationDate($name);
|
||||||
$expire = "'" . $expire . "'";
|
if (strtotime($expire)) {
|
||||||
|
$expire = "'" . $expire . "'";
|
||||||
|
} else {
|
||||||
|
$expire = 'NULL';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NS, MX, A and WHOIS records/data
|
// NS, MX, A and WHOIS records/data
|
||||||
@@ -39,7 +40,6 @@ if (isset($_POST['add_domain'])) {
|
|||||||
// Add domain record
|
// Add domain record
|
||||||
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_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_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");
|
||||||
|
|
||||||
|
|
||||||
// Get inserted ID (for linking certificate, if exists)
|
// Get inserted ID (for linking certificate, if exists)
|
||||||
$domain_id = mysqli_insert_id($mysqli);
|
$domain_id = mysqli_insert_id($mysqli);
|
||||||
|
|
||||||
@@ -74,9 +74,22 @@ if (isset($_POST['edit_domain'])) {
|
|||||||
$expire = sanitizeInput($_POST['expire']);
|
$expire = sanitizeInput($_POST['expire']);
|
||||||
$notes = sanitizeInput($_POST['notes']);
|
$notes = sanitizeInput($_POST['notes']);
|
||||||
|
|
||||||
if (empty($expire) || (new DateTime($expire)) < (new DateTime())) {
|
// if (empty($expire) || (new DateTime($expire)) < (new DateTime())) {
|
||||||
// Update domain expiry date
|
// // Update domain expiry date
|
||||||
|
// $expire = getDomainExpirationDate($name);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Set/check/lookup expiry date
|
||||||
|
if (strtotime($expire) && (new DateTime($expire)) > (new DateTime())) {
|
||||||
|
$expire = "'" . $expire . "'";
|
||||||
|
}
|
||||||
|
else {
|
||||||
$expire = getDomainExpirationDate($name);
|
$expire = getDomainExpirationDate($name);
|
||||||
|
if (strtotime($expire)) {
|
||||||
|
$expire = "'" . $expire . "'";
|
||||||
|
} else {
|
||||||
|
$expire = 'NULL';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$client_id = intval($_POST['client_id']);
|
$client_id = intval($_POST['client_id']);
|
||||||
@@ -89,7 +102,7 @@ if (isset($_POST['edit_domain'])) {
|
|||||||
$txt = sanitizeInput($records['txt']);
|
$txt = sanitizeInput($records['txt']);
|
||||||
$whois = sanitizeInput($records['whois']);
|
$whois = sanitizeInput($records['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_txt = '$txt', domain_raw_whois = '$whois', domain_notes = '$notes' WHERE domain_id = $domain_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_txt = '$txt', domain_raw_whois = '$whois', domain_notes = '$notes' WHERE domain_id = $domain_id");
|
||||||
|
|
||||||
//Logging
|
//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");
|
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");
|
||||||
|
|||||||
Reference in New Issue
Block a user