|
77 | 77 | // Set/check/lookup expiry date |
78 | 78 | if (strtotime($expire) && (new DateTime($expire)) > (new DateTime())) { |
79 | 79 | $expire = "'" . $expire . "'"; |
80 | | - } |
81 | | - else { |
| 80 | + |
| 81 | + } else { |
82 | 82 | $expire = getDomainExpirationDate($name); |
83 | 83 | if (strtotime($expire)) { |
84 | 84 | $expire = "'" . $expire . "'"; |
|
97 | 97 | $txt = sanitizeInput($records['txt']); |
98 | 98 | $whois = sanitizeInput($records['whois']); |
99 | 99 |
|
| 100 | + // Current domain info |
| 101 | + $original_domain_info = mysqli_fetch_assoc(mysqli_query($mysqli," |
| 102 | + SELECT |
| 103 | + domains.*, |
| 104 | + registrar.vendor_name AS registrar_name, |
| 105 | + dnshost.vendor_name AS dnshost_name, |
| 106 | + mailhost.vendor_name AS mailhost_name, |
| 107 | + webhost.vendor_name AS webhost_name |
| 108 | + FROM domains |
| 109 | + LEFT JOIN vendors AS registrar ON domains.domain_registrar = registrar.vendor_id |
| 110 | + LEFT JOIN vendors AS dnshost ON domains.domain_dnshost = dnshost.vendor_id |
| 111 | + LEFT JOIN vendors AS mailhost ON domains.domain_mailhost = mailhost.vendor_id |
| 112 | + LEFT JOIN vendors AS webhost ON domains.domain_webhost = webhost.vendor_id |
| 113 | + WHERE domain_id = $domain_id |
| 114 | + ")); |
| 115 | + |
| 116 | + // Update domain |
100 | 117 | 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"); |
101 | 118 |
|
| 119 | + // Fetch updated info |
| 120 | + $new_domain_info = mysqli_fetch_assoc(mysqli_query($mysqli," |
| 121 | + SELECT |
| 122 | + domains.*, |
| 123 | + registrar.vendor_name AS registrar_name, |
| 124 | + dnshost.vendor_name AS dnshost_name, |
| 125 | + mailhost.vendor_name AS mailhost_name, |
| 126 | + webhost.vendor_name AS webhost_name |
| 127 | + FROM domains |
| 128 | + LEFT JOIN vendors AS registrar ON domains.domain_registrar = registrar.vendor_id |
| 129 | + LEFT JOIN vendors AS dnshost ON domains.domain_dnshost = dnshost.vendor_id |
| 130 | + LEFT JOIN vendors AS mailhost ON domains.domain_mailhost = mailhost.vendor_id |
| 131 | + LEFT JOIN vendors AS webhost ON domains.domain_webhost = webhost.vendor_id |
| 132 | + WHERE domain_id = $domain_id |
| 133 | + ")); |
| 134 | + |
| 135 | + // Compare/log changes |
| 136 | + $ignored_columns = ["domain_updated_at", "domain_accessed_at", "domain_registrar", "domain_webhost", "domain_dnshost", "domain_mailhost"]; |
| 137 | + foreach ($original_domain_info as $column => $old_value) { |
| 138 | + $new_value = $new_domain_info[$column]; |
| 139 | + if ($old_value != $new_value && !in_array($column, $ignored_columns)) { |
| 140 | + $column = sanitizeInput($column); |
| 141 | + $old_value = sanitizeInput($old_value); |
| 142 | + $new_value = sanitizeInput($new_value); |
| 143 | + mysqli_query($mysqli,"INSERT INTO domain_history SET domain_history_column = '$column', domain_history_old_value = '$old_value', domain_history_new_value = '$new_value', domain_history_domain_id = $domain_id"); |
| 144 | + } |
| 145 | + } |
| 146 | + |
102 | 147 | // Logging |
103 | 148 | logAction("Domain", "Edit", "$session_name edited domain $name", $client_id, $domain_id); |
104 | 149 |
|
|
167 | 212 |
|
168 | 213 | mysqli_query($mysqli,"DELETE FROM domains WHERE domain_id = $domain_id"); |
169 | 214 |
|
| 215 | + mysqli_query($mysqli, "DELETE FROM domain_history WHERE domain_history_domain_id = $domain_id");# |
| 216 | + |
170 | 217 | // Logging |
171 | 218 | logAction("Domain", "Delete", "$session_name deleted domain $domain_name", $client_id); |
172 | 219 |
|
|
0 commit comments