mirror of https://github.com/itflow-org/itflow
Merge pull request #468 from wrongecho/dom-ssl-func
Move domain info logic to functions.php
This commit is contained in:
commit
9b47cd5baf
|
|
@ -352,6 +352,12 @@ function encryptLoginEntry($login_password_cleartext){
|
|||
|
||||
// Get domain expiration date
|
||||
function getDomainExpirationDate($name){
|
||||
|
||||
// Only run if we think the domain is valid
|
||||
if(!filter_var($name, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
|
||||
return '0000-00-00';
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, "https://itflow-whois.herokuapp.com/$name");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
|
||||
|
|
@ -372,6 +378,28 @@ function getDomainExpirationDate($name){
|
|||
return '0000-00-00';
|
||||
}
|
||||
|
||||
// Get domain general info (whois + NS/A/MX records)
|
||||
function getDomainRecords($name){
|
||||
|
||||
$records = array();
|
||||
|
||||
// Only run if we think the domain is valid
|
||||
if(!filter_var($name, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
|
||||
$records['a'] = '';
|
||||
$records['ns'] = '';
|
||||
$records['mx'] = '';
|
||||
$records['whois'] = '';
|
||||
return $records;
|
||||
}
|
||||
|
||||
$domain = escapeshellarg($name);
|
||||
$records['a'] = substr(trim(strip_tags(shell_exec("dig +short $domain"))), 0, 254);
|
||||
$records['ns'] = substr(trim(strip_tags(shell_exec("dig +short NS $domain"))), 0, 254);
|
||||
$records['mx'] = substr(trim(strip_tags(shell_exec("dig +short MX $domain"))), 0, 254);
|
||||
$records['whois'] = substr(trim(strip_tags(shell_exec("whois -H $domain | sed 's/ //g' | head -30"))), 0, 254);
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
function strto_AZaz09($string){
|
||||
$string = ucwords(strtolower($string));
|
||||
|
|
|
|||
57
post.php
57
post.php
|
|
@ -5967,27 +5967,18 @@ if(isset($_POST['add_domain'])){
|
|||
$expire = "0000-00-00";
|
||||
}
|
||||
|
||||
// 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 domain expiry date - if not specified
|
||||
if($expire == '0000-00-00'){
|
||||
$expire = getDomainExpirationDate($name);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
$a = '';
|
||||
$ns = '';
|
||||
$mx = '';
|
||||
$whois = '';
|
||||
// Get domain expiry date - if not specified
|
||||
if($expire == '0000-00-00'){
|
||||
$expire = getDomainExpirationDate($name);
|
||||
}
|
||||
|
||||
// NS, MX, A and WHOIS records/data
|
||||
$records = getDomainRecords($name);
|
||||
$a = mysqli_real_escape_string($mysqli, $records['a']);
|
||||
$ns = mysqli_real_escape_string($mysqli, $records['ns']);
|
||||
$mx = mysqli_real_escape_string($mysqli, $records['mx']);
|
||||
$whois = mysqli_real_escape_string($mysqli, $records['whois']);
|
||||
|
||||
// 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_raw_whois = '$whois', domain_client_id = $client_id, company_id = $session_company_id");
|
||||
|
||||
|
|
@ -6035,24 +6026,18 @@ 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"))));
|
||||
$expire = getDomainExpirationDate($name);
|
||||
}
|
||||
else{
|
||||
$a = '';
|
||||
$ns = '';
|
||||
$mx = '';
|
||||
$whois = '';
|
||||
}
|
||||
// Update domain expiry date
|
||||
$expire = getDomainExpirationDate($name);
|
||||
|
||||
// Update NS, MX, A and WHOIS records/data
|
||||
$records = getDomainRecords($name);
|
||||
$a = mysqli_real_escape_string($mysqli, $records['a']);
|
||||
$ns = mysqli_real_escape_string($mysqli, $records['ns']);
|
||||
$mx = mysqli_real_escape_string($mysqli, $records['mx']);
|
||||
$whois = mysqli_real_escape_string($mysqli, $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_raw_whois = '$whois' WHERE domain_id = $domain_id AND company_id = $session_company_id");
|
||||
|
||||
|
|
@ -6067,7 +6052,7 @@ if(isset($_POST['edit_domain'])){
|
|||
|
||||
if(isset($_GET['delete_domain'])){
|
||||
|
||||
validateAdminRole();
|
||||
validateAdminRole();
|
||||
|
||||
$domain_id = intval($_GET['delete_domain']);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue