<?

/*
if( !isset($_GET['login']) ) {
	//exit;
	$_GET['login'] = "Spaz";
}
*/

function get_ip() {
    if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    elseif(isset($_SERVER['HTTP_CLIENT_IP'])) {
        $ip  = $_SERVER['HTTP_CLIENT_IP'];
    }
    else {
        $ip = $_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}

$login = "Spaz";

include('config.php');

$sql = "SELECT login, ip FROM matgraph_verifip WHERE login = '".addslashes($login)."'";
$req = db_mysql_Query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
if( $row = mysql_fetch_array($req) ) {
	$sql_2 = "UPDATE matgraph_verifip SET ip = '".get_ip()."' WHERE login = '".addslashes($login)."'";
	$req_2 = db_mysql_Query($sql_2) or die('Erreur SQL !<br>'.$sql_2.'<br>'.mysql_error());
} else {
	$sql_2 = "INSERT INTO matgraph_verifip (ip, login)
				VALUES ('".get_ip()."','".addslashes($login)."')";
	$req_2 = db_mysql_Query($sql_2) or die('Erreur SQL !<br>'.$sql_2.'<br>'.mysql_error());
}


?>