• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Users online on www

klekSu

Stroke my ego.
Joined
Nov 4, 2008
Messages
1,285
Reaction score
18
Hi there, so i haven't seen it anywhere before that's why i give it here, for you. The script is usefull for people who wants to know how many people there is online on his www at the moment.

Screen:
online.png


Create a file online.txt in the main www directory and save it empty. If linux, give it chmod 666. Now in layouts/NameOfLay/layout.php or index.php depends what you got, add this wherever you want, and ofcourse edit it for your needs.

PHP:
<?
         $plik = "online.txt";
             $czas = 60;
                 $t = time();
             $ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];    
         $u = explode("\n", str_replace("\r", "", @join("", @file($plik))));
         foreach($u as $i => $v) {
             $e = explode("|", $v);
             if($e[0] == $ip || $e[1] < $t) unset($u[$i]);
         }
         $u[] = $ip . "|" . ($t + $czas);
         $fp = fopen($plik, "w");
             flock($fp, 2);
                 fputs($fp, join("\n", $u));
             flock($fp, 3);
         fclose($fp);
         echo 'Now online: '.count($u);
    ?>

In line 3 $czas = 60; it's the time of deleting offline users-refreshing the status, you can edit it, but it should stay as 60 seconds. I hope the script is usefull for you, cheers.
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
Np and thanks for comments :)
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
Back
Top