<?php require_once "header.php";?>
<h1>Find Subdo</h1>
<form method="GET" action="" class="form-inline my-2 my-lg-0">
	Domain : <input type="text" class="form-control mr-sm-2" name="domain" placeholder="<?php echo $_GET['domain'] ?>"> 
	<input type="submit" class="btn btn-primary my-2 my-sm-0" value="Search">
</form>
<?php
// error_reporting(0);
header("X-Frame-Options: DENY");
header("Content-Security-Policy: frame-ancestors 'none'", false);
$domain = $_GET['domain'];
if (isset($_GET['domain'])) {
	$domain = $_GET['domain'];
	function http_request($url){
	    $ch = curl_init();
	    curl_setopt($ch, CURLOPT_URL, $url);
	    curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	    $output = curl_exec($ch); 
	    curl_close($ch);      
	    return $output;
	}

	$reverse = http_request("http://api.hackertarget.com/hostsearch/?q=".$domain);
	$reverse = json_encode($reverse);
	$reverse = str_replace('"', '', explode('\n', $reverse));
	echo 'Total: '.count($reverse).' Domain<br>
		<div style="color:#dbd9d9;"><table border="1" class="table">
		<tr>
			<th width=5><span style="color:black;">No</span></th>
            <th><span style="color:black;">Nama</span></th>
            <th><span style="color:black;">IP</span></th>
		</tr></div>';
	$nomor = 1;
	foreach ($reverse as $key => $d) {
        $d = explode(',', $d);
		echo "<tr style='color:#dbd9d9;'>
				<td><span style='color:black;'>".$nomor++."</span></td>
                <td><a href='http://".$d[0]."' target='_blank'>".$d[0]."</a></td>
                <td><a href='http://".end($d)."' target='_blank'>".end($d)."</a></td>
				</tr>";
	}
}
?>