<?php
if(!defined('INDEX')) { header('Location: ../'); exit; }
$pagea = 'vip';
$titre = 'Vérification IP';

$timelimit = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d"), date("Y"))); //2008-06-17 18:15:00
$chapeau->connexion();
$page = gpc('v');
if (empty($page) || !is_numeric($page)) $page = 0;

$act = gpc('act');
if ($act == 'multiok') $chapeau->query("UPDATE $table_user SET multi = '1' WHERE id = ".$_GET['util'].";");

if (isset($_GET['ip'])) $req = mysql_query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE ip = '".$_GET['ip']."' ORDER BY ip ASC;");
elseif (isset($_GET['util']) && isset($_GET['comp'])) $req = mysql_query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE id_util = ".$_GET['util']." OR id_util = ".$_GET['comp']." ORDER BY ip ASC;");
elseif (isset($_GET['util'])) $req = mysql_query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE id_util = '".$_GET['util']."' ORDER BY ip ASC;");
elseif (isset($_GET['tri'])) $req = mysql_query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id ORDER BY ".$_GET['tri']." ASC;");
else $req = mysql_query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE R.time > '$timelimit 00:00:00' ORDER BY R.ip ASC LIMIT ".($page*75).",75;");
//SELECT last_ip,COUNT(*) FROM user GROUP BY last_ip HAVING COUNT(*)>1
$nbpage = $chapeau->unique_query("SELECT COUNT(id) AS nb FROM $table_registre_identification WHERE time > '$timelimit 00:00:00';");
$chapeau->deconnexion();

$anc = array('ip' => 0, 'id_util' => 0);
$tableau = array();
while($resultat = mysql_fetch_array($req)) {
	if ($resultat['mv'] == 3) $color = 'DFBF00';
	elseif ($resultat['multi'] == 1 && $anc['ip'] == $resultat['ip'] && $anc['id_util'] != $resultat['id_util']) $color = 'EE66EE';
	elseif ($anc['ip'] == $resultat['ip'] && $anc['id_util'] != $resultat['id_util']) $color = 'FF0000';
	else $color = false;
	$tableau[] = array($resultat['ip'], gethostbyaddr($resultat['ip']), $resultat['id_util'], $resultat['pseudo'], $resultat['time'], $resultat['mv'], $color);
	$anc = $resultat;
}
$template->assign('ips', $tableau);
$template->assign('numpage', $page);
$template->assign('nbpage', floor($nbpage['nb']/75));
?>