Просмотр файла ip/ipconvert.php

Размер файла: 2.19Kb
<?php
require 'config.php';
require 'header.php';

require_once "../includes/start.php";
require_once "../includes/functions.php";
require_once "../includes/header.php";
include_once "../themes/".$config['themes']."/index.php";

$act = $_GET['act'];
if($act != 'ip'){
$act = 'domain';
}

$domain = trim($_GET['domain']);
$ip = trim($_GET['ip']);

print '<div class="input">';

switch ($act)
{
case 'ip':
print '<form action="ipconvert.php" method="get">
<div>
<input name="ip" type="text" title="IP" maxlength="15"/><br/>
<input type="hidden" name="url" value="'.$url.'"/>
<input type="hidden" name="act" value="ip"/>
<input type="submit" value="Смотреть"/>
</div>
</form>';

if(!$ip){
print '<div class="red">Введите IP</div>';
}
else{
if(!preg_match("/^\d{0,3}+\.\d{0,3}+\.\d{0,3}+\.\d{0,3}+$/i", $ip)){
print '<div class="red">Error!</div>';
}
else{
$domain = gethostbyaddr($ip);
print '<span class="red">'.$domain.'<br/></span>';
}
}

print '</div>
<div class="border">
<a href="ipconvert.php?act=domain&amp;url='.$url.'">Host&#187;IP</a><br/>
</div>
<div class="border">
<a href="ipconvert.php?act=ip&amp;url='.$url.'">IP&#187;Host</a><br/>
</div>';
break;

case 'domain':
print '<form action="ipconvert.php" method="get"><div>
<input name="domain" type="text" title="Domain"/><br/>
<input type="hidden" name="url" value="'.$url.'"/>
<input type="hidden" name="act" value="domain"/>
<input type="submit" value="Смотреть"/>
</div>
</form>';

if(!$domain){
print '<div class="red">Введите домен</div>';
}
else
{
$domain = str_replace('http://','',$domain);
$domain = htmlspecialchars(trim($domain));
$ip = gethostbynamel($domain);

foreach ($ip as $index => $val){
print '<span class="red">'.$val.'<br/></span>';
}
}

print '</div>
<div class="border">
<a href="ipconvert.php?act=ip&amp;url='.$url.'">IP&#187;Host</a><br/>
</div>
<div class="border">
<a href="ipconvert.php?act=domain&amp;url='.$url.'">Host&#187;IP</a><br/>
</div>';
break;

default:
print '<div class="red">Error!</div>';
break;
}

echo '<br /><img src="'.BASEDIR.'../images/img/act_home.gif" alt="image" /> <a href="'.BASEDIR.'../index.php?'.SID.'">На главную</a>';

include_once "../themes/".$config['themes']."/foot.php";
?>