Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Eu consegui um script que informa quanto users estão on-line no meu site.
São três arquivos:
useronline.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[http://www.w3.org/TR/html4/loose.dtd">http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Untitled Document</title></head><body><span class="style1"> usuários on line: </span><?phpinclude ("./config.php3");if (!$datei) $datei = dirname(__FILE__)."/$filename";$time = @time();$ip = $REMOTE_ADDR;$string = "$ip|$time\n";$a = fopen("$filename", "a+");fputs($a, $string);fclose($a);$timeout = time()-(60*$timer);$all = "";$i = 0;$datei = file($filename);for ($num = 0; $num < count($datei); $num++) { $pieces = explode("|",$datei[$num]); if ($pieces[1] > $timeout) { $all .= $pieces[0]; $all .= ","; } $i++;}$all = substr($all,0,strlen($all)-1);$arraypieces = explode(",",$all);$useronline = count(array_flip(array_flip($arraypieces)));// display how many people where activ within $timeoutecho $useronline;// Delete$dell = "";for ($numm = 0; $numm < count($datei); $numm++) { $tiles = explode("|",$datei[$numm]); if ($tiles[1] > $timeout) { $dell .= "$tiles[0]|$tiles[1]"; }}if (!$datei) $datei = dirname(__FILE__)."/$filename";$time = @time();$ip = $REMOTE_ADDR;$string = "$dell";$a = fopen("$filename", "w+");fputs($a, $string);fclose($a);?></html>
config.php3
<?php// Timeout - After this time the users will // be deleted (in minutes)$timer = 30;// Name of the file where all the data, about// the user's activity will be saved$filename = "$DOCUMENT_ROOT/useronline/log.txt";?>
e log.txt
O problema é que quando eu hospedo no servidor aparece desse jeito:
>
usuários on line:
Warning: fopen(): open_basedir restriction in effect. File(/home/webcindario/useronline/log.txt) is not within the allowed path(s): (/home/webcindario/gta-street) in /home/webcindario/gta-street/useronline.php on line 56
Warning: fopen(/home/webcindario/useronline/log.txt): failed to open stream: Operation not permitted in /home/webcindario/gta-street/useronline.php on line 56
Warning: fputs(): supplied argument is not a valid stream resource in /home/webcindario/gta-street/useronline.php on line 57
Warning: fclose(): supplied argument is not a valid stream resource in /home/webcindario/gta-street/useronline.php on line 58
Warning: file(): open_basedir restriction in effect. File(/home/webcindario/useronline/log.txt) is not within the allowed path(s): (/home/webcindario/gta-street) in /home/webcindario/gta-street/useronline.php on line 64
Warning: file(/home/webcindario/useronline/log.txt): failed to open stream: Operation not permitted in /home/webcindario/gta-street/useronline.php on line 64
1
Warning: fopen(): open_basedir restriction in effect. File(/home/webcindario/useronline/log.txt) is not within the allowed path(s): (/home/webcindario/gta-street) in /home/webcindario/gta-street/useronline.php on line 95
Warning: fopen(/home/webcindario/useronline/log.txt): failed to open stream: Operation not permitted in /home/webcindario/gta-street/useronline.php on line 95
Warning: fputs(): supplied argument is not a valid stream resource in /home/webcindario/gta-street/useronline.php on line 96
Warning: fclose(): supplied argument is not a valid stream resource in /home/webcindario/gta-street/useronline.php on line 97
Já tentei de tudo. Eu testo o código aqui no localhost e funciona direitinho.
Onde tá o erro.???
Alguém me ajude aê, por favor!
Valeu
Carregando comentários...