
02/07/2009, 20:30
|
 | | | Fecha de Ingreso: julio-2008 Ubicación: localhost/colombia/sevillaValle.php
Mensajes: 1.123
Antigüedad: 16 años, 6 meses Puntos: 32 | |
Respuesta: no me va usuarios activos con txt Ui que raro pegalo asi
<?php
class Activos
{
//creado por acoevil
private $nombre;
private $modo;
private $ip;
private $inactivo=300;
private $hora;
private $activos=0;
function Activos($nombre)
{
$this->nombre=$nombre;
$this->modo="r";
$this->ip=$_SERVER['REMOTE_ADDR'];
$this->hora=$tiempo=date("h:i:s");
################################
$apuntador=$this->abrir();
$usuarios=$this->leer($apuntador);
$this->escribimos($usuarios);
echo "Usuarios en linea: ".$this->activos;
}
function abrir()
{
$apuntador=fopen($this->nombre,$this->modo);
return $apuntador;
}
function leer($apuntador)
{
while(!feof($apuntador))
{
$linea=fgets($apuntador);
list($ip,$tiempo_t)=split(" ",$linea);
if($ip==$this->ip)
{
$mi_ip=$this->ip." ".$this->hora;
$this->activos++;
}
else
{
if(strtotime($this->hora)>strtotime($tiempo_t)){
$diferencia=strtotime($this->hora)-strtotime($tiempo_t);
}else{
$diferencia=strtotime($tiempo_t)-strtotime($this->hora);
}
if($diferencia<$this->inactivo)
{
$tx=$tx.$ip." ".$tiempo_t."\n";
$this->activos++;
}
}
}
if($mi_ip=="")
{
$mi_ip=$this->ip." ".$this->hora;
$this->activos++;
}
fclose($apuntador);
return $introduce=$tx.$mi_ip;
}
function escribimos($usuarios)
{
$fp=fopen($this->nombre,"w");
fwrite($fp,$usuarios);
fclose($fp);
}
}
$usuarios=new Activos("usuarios.txt");
?> |