Viewing file: conta_user.php (1.71 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include ("conex.php");
$db = mysql_connect("$bd_host", "$bd_usuario", "$bd_password") or die("No hay conexión.");
if(!$db)
die("no db");
if(!mysql_select_db($bd_base,$db))
die("No se seleccionó la base de datos.");
$server_time=date("U");
$client_ip=$_SERVER['REMOTE_ADDR'];
$arr = getdate();
$dia_actual = $arr["mday"];
$hora_actual = $arr["hours"];
$minuto_actual = $arr["minutes"];
$visita = mysql_query("SELECT * FROM visitas");
while($row = mysql_fetch_array($visita)) {
extract($row);
$dia = $row["dia"];
$totales = $row["totales"];
$today = $row["hoy"];
if ($dia_actual != $dia) {
$today = 1;
}else{
$today++;
}
$totales++;
}
$actualiza="UPDATE visitas SET dia='$dia_actual', totales='$totales', hoy='$today'";
mysql_query($actualiza);
$p4 = mysql_query("SELECT * FROM current_users WHERE ip='$client_ip'");
$pa4 = mysql_fetch_array($p4);
if($pa4) {
$update="UPDATE current_users set time='$server_time' where ip='$pa4[ip]'";
mysql_query($update) or die("No es posible actualizar: " . mysql_error());
} else {
$query=("INSERT INTO `current_users` (`ip`, `time`) VALUES ('$client_ip', '$server_time')");
$result = mysql_query($query) or die("No se puede insertar: " . mysql_error());
}
$time2=$server_time-1800;
$remove="DELETE from current_users WHERE time<'$time2'";
mysql_query($remove) or die("Unable to delete: " . mysql_error());
$result6 = mysql_query("SELECT ip FROM current_users" );
$current_visitors = mysql_num_rows($result6);
/*echo "
<b>Visitas desde 23/02/2005:</b> <font color=red>$totales</font> | <b>Visitas hoy:</b> <font color=blue>$today</font> | <b>Online:</b> <font color=red>$current_visitors</font> <b>visitantes</b>";*/
mysql_close ($db);
?>
|