Foros del Web » Programando para Internet » PHP »

Comprobar fecha

Estas en el tema de Comprobar fecha en el foro de PHP en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 11/07/2003, 12:38
Avatar de nuevo  
Fecha de Ingreso: mayo-2003
Ubicación: Spain
Mensajes: 2.009
Antigüedad: 20 años, 11 meses
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
  #2 (permalink)  
Antiguo 11/07/2003, 12:40
Avatar de nuevo  
Fecha de Ingreso: mayo-2003
Ubicación: Spain
Mensajes: 2.009
Antigüedad: 20 años, 11 meses
Puntos: 2
y de paso corregir un poco el codigo... esq aun no se mucho y soy bastante guarro... ya lo se
__________________
3w.valenciadjs.com
3w.laislatv.com
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:04.