Al usar este script me da un error:
Cita:
No entiendo ;/ si solo estoy usando 1 bytes porque dice eso?Fatal error: Allowed memory size of 104857600 bytes exhausted (tried to allocate 1 bytes) in /home/a1923435/public_html/test.php on line 22
Probe augmentandole el memory_limit pero sigue tirando lo mismo
Código PHP:
<?php
ini_set("memory_limit","100M");
$dataFile = "online.txt";
$sessionTime = "5" ; //time in **minutes** to consider someone online before removing them
#####################################################
# No editing needed below
#####################################################
error_reporting(E_ERROR | E_PARSE);
if(!file_exists($dataFile)) {
$fp = fopen($dataFile, "w+");
fclose($fp);
}
$ip = $_SERVER['REMOTE_ADDR'];
$users = array();
$onusers = array();
$timeuser = time();
//get users part
$fp = fopen($dataFile, "r");
flock($fp, LOCK_SH);
while(!feof($fp)) {
$users[] = rtrim(fgets($fp));
}
flock($fp, LOCK_UN);
fclose($fp);
// pagina actual
if($id == ""){ $paginactual = "principal";} else {
if(file_exists("$id.php")) { $paginactual = $id ;}
if(!file_exists("$id.php")) { $paginactual = "principal" ;}
}
// refer
$refer=$_SERVER['HTTP_REFERER'];
if($refer==""){
$refer="Su PC";
}
// usuario
if($ucnnick == ""){$nameuser = "!$paginactual";} else { $nameuser = "|$ucnnick|$paginactual|$refer"; }
//cleanup part
$x = 0;
$alreadyIn = FALSE;
foreach($users as $key => $data) {
list( , $lastvisit) = explode("|", $data);
if(time() - $lastvisit >= $sessionTime * 60) {
$users[$x] = "";
} else {
if(strpos($data, $ip) !== FALSE) {
$alreadyIn = TRUE;
$users[$x] = "$ip|$timeuser$nameuser"; //update record
}
}
$x++;
}
if($alreadyIn == FALSE) {
$users[] = "$ip|$timeuser$nameuser";
}
//write file
$fp = fopen($dataFile, "w+");
flock($fp, LOCK_EX);
$totaluser = 0;
foreach($users as $single) {
if($single != "") {
fwrite($fp, $single . "\r\n");
$totaluser++;
}
}
flock($fp, LOCK_UN);
fclose($fp);
if($uo_keepquiet != TRUE) {
echo $totaluser;
}
?>
<br>
Anonimos :
<?
$fd_anonimo = fopen($dataFile, "r");
$contenido_anonimo = fread($fd_anonimo, filesize($dataFile));
fclose($fd_anonimo);
$fichero_anonimo = explode("!", $contenido_anonimo);
$fichero_anonimo = array_slice($fichero_anonimo, 0, -1);
$fichero_anonimo = array_reverse($fichero_anonimo);
$anonimos = count($fichero_anonimo);
echo $anonimos ;
?>
<br>
Registrados:
<?
$registrados = $totaluser-$anonimos;
echo $registrados ;
?>