Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('conn.php');
- $time = 5 ;
- $date = time() ;
- $ip = $_SERVER['REMOTE_ADDR'];
- $limite = $date-$time*60 ;
- mysql_query("delete from online where date < $limite") ;
- $resp = mysql_query("select * from online where ip='$ip'") ;
- if(mysql_num_rows($resp) != 0) {
- mysql_query("update online set date='$date' where ip='$ip'") ;
- }
- else {
- mysql_query("insert into online (date,ip) values ('$date','$ip')") ;
- }
- $query = "SELECT * FROM online";
- $resp = @mysql_query($query) or die(mysql_error());
- $usuarios = mysql_num_rows($resp);
- if($usuarios > 1 || $usuarios == 0){
- echo("Hay ");
- }else{
- echo("Hay ");
- }if($usuarios == 0){
- echo("no ");
- }else{
- echo($usuarios." ");
- }if($usuarios > 1 || $usuarios == 0){
- echo("Usuarios en línea.");
- }else{echo("usuario en línea.");
- }?>
- <?php
- include('conn.php');
- $ip = $_SERVER['REMOTE_ADDR'];
- $sql="select ip, TIMEDIFF(NOW(), fecha), fecha, num_visitas from visitas where ip='$ip'";
- $rs=mysql_query($sql) or die("Problemas al ejecutar select SQL ".mysql_error());
- $fila=mysql_fetch_array($rs);
- $tiempo=$fila[1];
- $num_visitas=$fila[3];
- $horas_t=substr($tiempo,0,2);
- $tiemRes = 5;
- if (mysql_num_rows($rs)==0)
- {
- $sql="insert into visitas(ip, num_visitas, fecha) values('$ip', 1, NOW())";
- mysql_query($sql) or die("Problemas al ejecutar la insert SQL ".mysql_error());
- }
- elseif (mysql_num_rows($rs) > 0 && $horas_t > $tiemRes)
- {
- $sql="update visitas set fecha=NOW(), num_visitas='$num_visitas'+1 where ip='$ip'";
- mysql_query($sql) or die("Problemas al ejecutar update SQL ".mysql_error());
- }
- $sql="select SUM(num_visitas) from visitas";
- $rs=mysql_query($sql) or die("Problemas al ejecutar select SQL ".mysql_error());
- $fila=mysql_fetch_array($rs);
- $num_visitas=$fila[0];
- mysql_close($conection); ?>
Add Comment
Please, Sign In to add comment