Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/07/2003, 12:38
Avatar de nuevo
nuevo
 
Fecha de Ingreso: mayo-2003
Ubicación: Spain
Mensajes: 2.009
Antigüedad: 21 años
Puntos: 2
Comprobar fecha

miren... uso este codigo para comprobar si una fecha en la BD es menor del tiempo estipulado... si es asi actualiza un contador... lo hace mediante tiempo y la ip, guardando los datos en la BD, pero hay un problema... cuando el usuario se conecta por 2º vez y el tiempo no ha caducado, y el codigo actualiza la BD y pone el tiempo a 0, entonces... si yo le pongo 12 horas para que no sume+1, cuando el user entra a las 3 horas el encuentra la IP y pone el contador a 0 sin sumar... es un error de que no compruebo si existe la ip o no y si existe que compruebe el tiempo... y si ha pasado el limite que sume+1...

alguien me puede ayudar a corregir este error... gracias

Código PHP:
<?php
if ($_GET['accion']=="votar"){
mysql_select_db("b");
$ip getenv(REMOTE_ADDR);
$tid date("Y-m-d H:i:s", (time()-10));
mysql_query("DELETE FROM online WHERE tid < '$tid'");
$tjek mysql_query("SELECT * FROM online WHERE ip='$ip'");
if(
mysql_num_rows($tjek) == 0) {
    
mysql_query("INSERT INTO online (tid, ip) VALUES (now(),'$ip')");
$id_mod_nivel$_GET['id'];
require (
"aut_config.inc.php");
$usuario_consulta mysql_query("SELECT $selecttbl FROM $sql_tabla WHERE id=$id_mod_nivel") or die("$error6");
while(
$resultados mysql_fetch_array($usuario_consulta)) {
$contador "$resultados[visitas]";
$nweb=$_GET['id'];
$infowebvotos"$resultados[votos]";
$infowebvisitas"$resultados[visitas]";
$infowebvisitas ++;
}
$contador ++;
mysql_query("UPDATE $sql_tabla SET visitas='$contador' WHERE id='$id'") or die(mysql_error());
echo <<< HTML
<html>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr valign="center" align="center">
<td>
<table width=97 border=0 cellspacing=0 cellpadding=0><a href="cuenta.voto.php?accion=votar&id=$nweb" target=_blank>
    <tr height=76>
        <td align=center valign="bottom" bgcolor=#1e1e43 width=97 height=76 background="images/icono.votar.jpg"><font size=1 color=white face=Verdana><b>SHADOW TOP<br>
            <br><br><br><br>Dame Tu Voto</b></font></td>
    </tr>
    <tr height=16>
        <td align=center valign="middle" bgcolor=#1e1e43 width=97 height=16><font size=1 color=White face=Verdana><b>VISITAS: $infowebvisitas</b></td>
    </tr>
    <tr height=3>
        <td bgcolor=white width=97 height=1></td>
    </tr>
</table>
</td></tr></table></body></html>
HTML;
mysql_close();
mysql_free_result($usuario_consulta);
} else {
    
mysql_query("UPDATE online SET tid=now() WHERE ip='$ip'");
}
$online mysql_query("SELECT COUNT(*) AS antal FROM online");
//
define("MAX_IDLE_TIME"2);
function 
getOnlineUsers() {
    if (
$directory_handle opendir(session_save_path())) {
    
$count 0;
    while (
false !== ($file readdir($directory_handle))) {
        if (
$file != '.' && $file != '..') {
            if (
time() - fileatime(session_save_path() . '\\' $file) < MAX_IDLE_TIME 60) {
                
$count++;
                }
            }
        }
        
closedir($directory_handle);
        return (
$count);
    } else {
    return 
false;
}
}
mysql_close();
$id_mod_nivel$_GET['id'];
require (
"aut_config.inc.php");
$usuario_consulta mysql_query("SELECT $selecttbl FROM $sql_tabla WHERE id=$id_mod_nivel") or die("$error6");
while(
$resultados mysql_fetch_array($usuario_consulta)) {
$contador "$resultados[visitas]";
echo <<< HTML
<html>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr valign="center" align="center">
<td>
<table width=97 border=0 cellspacing=0 cellpadding=0><a href="cuenta.voto.php?accion=votar&id=$nweb" target=_blank>
    <tr height=76>
        <td align=center valign="bottom" bgcolor=#1e1e43 width=97 height=76 background="images/icono.votar.jpg"><font size=1 color=white face=Verdana><b>SHADOW TOP<br>
            <br><br><br><br>Dame Tu Voto</b></font></td>
    </tr>
    <tr height=16>
        <td align=center valign="middle" bgcolor=#1e1e43 width=97 height=16><font size=1 color=White face=Verdana><b>VISITAS: $contador</b></td>
    </tr>
    <tr height=3>
        <td bgcolor=white width=97 height=1></td>
    </tr>
</table>
</td></tr></table></body></html>
HTML;
}
}
?>
__________________
3w.valenciadjs.com
3w.laislatv.com