<?php 
    function transforme($time) {
    if ($time>=86400){
    $jour = floor($time/86400);
    $reste = $time%86400;
    $heure = floor($reste/3600);
    $reste = $reste%3600;
    $minute = floor($reste/60);
    $seconde = $reste%60;
    $result = $jour.'j '.$heure.'h '.$minute.'min '.$seconde.'s'; }
    elseif ($time < 86400 AND $time>=3600) {
    $heure = floor($time/3600);
    $reste = $time%3600;
    $minute = floor($reste/60);
    $seconde = $reste%60;
    $result = $heure.'h '.$minute.'min '.$seconde.' s'; }
    elseif ($time<3600 AND $time>=60) {
    $minute = floor($time/60);
    $seconde = $time%60;
    $result = $minute.'min '.$seconde.'s';
    }
    elseif ($time < 60) {
    $result = $time.'s'; }
    return $result; }
	
// include "includes/core.php";

$result = mysql_query("SELECT * FROM users WHERE name='".$user->name."'");
// $result = mysql_query("SELECT * FROM users WHERE name='S3t0x'");
while($row=mysql_fetch_assoc($result))
{
	// echo $row['lastvisit']."<br>";
	
	$regex = '#(.+)\-(.+)\-(.+) (.+)\:(.+)\:(.+)#';
	$texte = $row['lastvisit'];
	$jour = preg_replace($regex, '$1', $texte);
	$mois = preg_replace($regex, '$2', $texte);
	$annee = preg_replace($regex, '$3', $texte);
	$heure = preg_replace($regex, '$4', $texte);
	$min = preg_replace($regex, '$5', $texte);
	$sec = preg_replace($regex, '$6', $texte);
	
	$avant = mktime(0,0,0,$mois,$jour,$annee);
	$maintenant = time();
	
	$difference = $maintenant - $avant;
	
	$restant = $row['vipday']-$difference;
	if ($restant >= 0){
		echo transforme($restant);
	}
	else {
	echo "Adh&eacute;rer au Club";
	}

}
?>
