Hi i need the last field in the $csv_output in the function exportresults(results) to post available or unavailable
I am unsure how to get this to work please help and explain why it wont work THANKS
<?php
"<h1 style=text-align:center;>Whois lookup Results</h1>".
$srcharray = array(
"available",
"no match",
"not found",
"no found",
"nothing found",
"no domain",
"no data found",
"no data was found",
"no entries found",
"status: free",
"status: available",
"is free",
"does not exist",
"no information",
"we do not have",
"not registered",
"nomatch",
"no such domain",
"no live registration",
"not in whois database",
"not yet been delegated",
"not yet been registered",
"not delegated",
"no records matching",
"no records found",
"- available",
"220 available",
"no existe",
"domain status: avail",
"dominio no registrado",
"has not yet been registered",
"has not yet been delegated",
"nije registrirana",
"domain name not known",
"not in the uanic",
"not a domain controlled by",
"object_not_found",
);
function getDomains($domain_string) {
$domain_array = explode("\n", $domain_string);
return $domain_array;
}
function dig($domain) {
return shell_exec('dig ' . $domain);
}
// function ($availability) {
// if (preg_match("/$term_list/i" , $result)) {
// $dig_result['availability'] = true;
// } else
// {
// $dig_result['availability'] = false;
// }
// return $dig_result['availability'];
// }
function whois($domain) {
global $srcharray;
$domain = trim($domain);
$domain = trim($domain, "www.");
$result = shell_exec('whois ' . $domain);
$whois_result = array();
$whois_result['whois'] = $result;
$whois_result['domain'] = $domain;
$whois_result['dig'] = dig($domain);
$term_list = implode("|", $srcharray);
if (preg_match("/$term_list/i" , $result)) {
$whois_result['availability'] = true;
} else
{
$whois_result['availability'] = false;
}
return $whois_result;
}
function exportResults($results) {
// attempt 1 get an if statement to return a value
// global $srcharray;
// $result2 = shell_exec('whois ' . $domain);
// if (preg_match("/$term_list/i" , $result2)) {
// $return == unavailable;
// }else
// {
// $return == available
//
$csv_output = "Domain\tWhois\tdig\tavailability\t\n";
$filename = "multi_whois.xls";
foreach ($results as $result){
$whois = str_replace('"', "'", $result['whois']);
$return = str_replace("1", "UNAVAILABLE", $result['availability']).
// $return = $availability
$csv_output .= $result['domain'] . "\t" . '"'. $whois .'"'. "\t" . '"' . $result['dig'] . '"' . "\t" . $return . '"' ."\n";
}
header('Pragma: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Content-Transfer-Encoding: none');
header("Content-type: application/vnd.ms-excel;");
header("Content-Disposition: attachment; filename=$filename; size=".strlen($csv_output));
print ($csv_output);
exit();
}
function displayResults($results) {
$html = "";
foreach ($results as $result) {
$html .= "<br>".
"<center>".
"<table border= '2' >".
"<tr>".
"<td align=center width=800>".
"<h2 text-align=center>".
$result['domain'].
"</h2>".
"</td>".
"</tr>".
"<tr>".
"<td align=center width=800>".
str_replace("1","<h2 style=color:red;><blink>UNAVAILABLE</blink></h2>", $result['availability']).
str_replace("0","<h2 style=color:green;><blink>AVAILABLE</blink></h2>", $result['availability']).
// returning a 1 ???
"</td>".
"</tr>".
"<tr>".
"<td align=center width=800>".
str_replace("\n", "<br>", $result['whois']).
"</td>".
"</tr>".
"<tr>".
"<td align=center width=800>".
"<h2 style=text-align:center;>Dig results</h2></center>".
"</td>".
"</tr>".
"<tr>".
"<td align=center width=800>".
str_replace("\n", "<br>", $result['dig']).
"</td>".
"</tr>".
"</table>".
"</center>";
}
return $html;
}
$domain_array = getDomains($_POST["Domainname"]);
$results = array();
foreach ($domain_array as $domain) {
$results[] = whois($domain);
}
if (isset($_POST['export'])) {
exportResults($results);
} else if (isset($_POST['display'])) {
$html = displayResults($results);
$delay_time= $_POST["delaytime"];
sleep($delay_time);
echo '<html>'.
'<body>'.
"<h1 style=text-align:center;>Whois lookup Results</h1>".
'<style= text-align: center;>'.
$html.
'</style>'.
'</body>'.
'</html>';
}
exit();
?>
trying to get a csv field to post available or unavailable
Moderator: General Moderators