<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Version 0.9.7

Copyright (C) 2006-2007  Sylvain FATOME
This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr

Web : http://smitst.homelinux.com
****************************************************************************************/

session_start(); 
include_once("../inc/config.inc.php");
include_once("../inc/func_log.inc.php");
if (CheckURLLog(FALSE)==FALSE) header("Location: ../index.php");
if (CheckNivLog("9")==FALSE) header("Location: ../index.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_geol.inc.php");
include_once("../inc/func_log.inc.php");
include_once("../inc/geoip.inc.php");
Archivelog(@$_SESSION["code_log"]);

$ip = strip_tags(trim($_GET['ip'])); // Récupération adresse IP

$ip_ok=TRUE;

if ($ip <> "")
{
	$expr = "^[0-9]{1,3}[\.][0-9]{1,3}[\.][0-9]{1,3}[\.][0-9]{1,3}$";
	if (eregi($expr,$ip))
	{
		// Détection de l'OS du serveur
		$os = getenv('OS');
		if (empty($os))
		{ 
			$os = php_uname();
		}
		if(empty($os))
		{
			$os ="-"; $unix=TRUE;
		}
		else
		{
			if (@eregi("^win",$os))
				$unix = FALSE; 
			else
				$unix = TRUE;
		}
	}
	else
		$ip_ok=FALSE;
}
else
	$ip_ok = FALSE;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SMI - ESPACE PRIVE : D&eacute;tail ip log</title>

<!-- Feuille de style pour les affichages courants -->
<link href="../css/smi.css" rel="stylesheet" type="text/css">

<!-- Feuille de style pour les affichages du menu -->


<!-- Scripts Javascript pour fenêtres -->
<script language="JavaScript" src="../jscript/fen.js"></script>

<!-- Scripts Javascript pour vérifications -->
<script language="JavaScript" src="../jscript/verif_field.js"></script>

</head>
<body>
<?PHP
if ($ip_ok == TRUE)
{
?>
	<p align="center" class="titrepage">DETAIL IP LOG</p>
	<p align="center" class="titre_gras">Pur l'adresse IP : <?PHP echo $ip; ?></p>
	<br>
	<!-- bouton de fermeture de la fenêtre -->
	<p align="right">
		<input name="ferm" type="button" class="bton_fmarr_std" id="ferm" value="Quitter" onclick="javascript:; window.self.close('');">
	</p>
	<div align="center">
	<form name="formulaire" action="" method="post">
	<span class="titre_gras">Pays d'origine</span>
	<?PHP
	echo "<pre>";
	echo pays_connect($ip);
	echo "</pre>";
	?>
	<hr align="center" width="400" size="2" style="color:#666666">
	<span class="titre_gras">Traceroute</span>
	<?PHP
	echo "<pre>";
	if ($unix) 
	{
		system ("traceroute ".$ip);
		system("killall -q traceroute");// Destruction de tous les processus Traceroute en cours
	}
	else
	{
		system("tracert ".$ip." 1> /tmp/output.txt 2>&1; cat /tmp/output.txt; rm /tmp/output.txt");
	}
	echo "</pre>";
	?>
	<hr align="center" width="400" size="2" style="color:#666666">
	<span class="titre_gras">Host</span>
	<br><br>
	<?PHP echo gethostbyaddr($ip);?>
	<hr align="center" width="400" size="2" style="color:#666666">
	<span class="titre_gras">NSLookup</span>
	<br>
	<?PHP
	echo "<pre>";
	system ("nslookup ".$ip." -sil 1> /tmp/output.txt 2>&1; cat /tmp/output.txt; rm /tmp/output.txt");
	echo "</pre>";
	?>
	<hr align="center" width="400" size="2" style="color:#666666">
	<span class="titre_gras">Ping</span>
	<br>
	<?PHP
	echo "<pre>";
	if ($unix) 
	{
		system ("ping -c 3 ".$ip." 1> /tmp/output.txt 2>&1; cat /tmp/output.txt; rm /tmp/output.txt");
	}
	else
	{
		system ("ping ".$ip." 1> /tmp/output.txt 2>&1; cat /tmp/output.txt; rm /tmp/output.txt");
	}
	echo "</pre>";
	?>
	<?PHP
	if ($unix) 
	{
	?>
		<hr align="center" width="400" size="2" style="color:#666666">
		<span class="titre_gras">Tracepath</span>
		<br>
		<?PHP
		echo "<pre>";
		system ("tracepath ".$ip." 1> /tmp/output.txt 2>&1; cat /tmp/output.txt; rm /tmp/output.txt");
		echo "</pre>";
		?>
	<?PHP } ?>
	</form>
	</div>

	<!-- bouton de fermeture de la fenêtre -->
	<p align="center">
		<input name="ferm" type="button" class="bton_fmarr_std" id="ferm" value="Quitter" onclick="javascript:; window.self.close('');">
	</p>
<?PHP
}
else
{
?>
	<script type="text/javascript">
	window.self.close('');
	</script>
<?PHP
}
?>
</body>
</html>
