weezer_rocks182
06-17-2003, 07:42 AM
hey. i need a 'users online' script, one that will display the amount of current users on the site. preferably, i would like a php script to do this. but a CGI script will work as well.
|
View Full Version : Users Online Script weezer_rocks182 06-17-2003, 07:42 AM hey. i need a 'users online' script, one that will display the amount of current users on the site. preferably, i would like a php script to do this. but a CGI script will work as well. Lissa 06-17-2003, 01:14 PM This one is pretty easy to use: http://downloads.w3secrets.com/downloads/useronline_v_21.htm weezer_rocks182 06-17-2003, 08:08 PM not working... i've put everything in correctly (i think): the files (config.php3, useronline.php4 and log.txt) are all stored in /useronline of my server. you can see a demo of the (not working) script at http://kwp.scottshriner.net/usersonline.htm --------------------- config.php3: --------------------- <?php // Timeout - After this time the users will_ // be deleted (in minutes) $timer = 900; // Name of the file where all the data, about // the user's activity will be saved $filename = "http://kwp.scottshriner.net/useronline/log.txt"; ?> --------------------- useronline.php4 --------------------- include ("http://kwp.scottshriner.net/useronline/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 $timeout echo $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 for usersonline.htm -------------------------------- (all head/meta tags and stuff up here) <body> <?php include("http://kwp.scottshriner.net/useronline/useronline.php4"); ?> Users Online </body> Dude128 06-17-2003, 08:27 PM check to see what file extension your particular PHP installation uses- make sure the extensions you are using- .php3 and .php4 are available. some installations may only be configured to work with one, or something else like .php or .phtml. in that case, you would have to rename some of the files to use the correct extension. also, you have the example on a .htm page, so the PHP code isn't being parsed. you will have to rename that page to have the appropriate PHP extension. weezer_rocks182 06-17-2003, 09:53 PM the .htm page has the <? php include() ?> coding on it, which (as the readme file says) will display the number of current users, no matter what. weezer_rocks182 06-17-2003, 10:00 PM alright i renamed usersonline.htm to usersonline.php, went to it, and this is what it says: Warning: fputs(): supplied argument is not a valid stream resource in /home/scottshr/public_html/kwp/useronline/useronline.php4 on line 35 Warning: fclose(): supplied argument is not a valid stream resource in /home/scottshr/public_html/kwp/useronline/useronline.php4 on line 36 1 Warning: fputs(): supplied argument is not a valid stream resource in /home/scottshr/public_html/kwp/useronline/useronline.php4 on line 74 Warning: fclose(): supplied argument is not a valid stream resource in /home/scottshr/public_html/kwp/useronline/useronline.php4 on line 75 Users Online bellportal 06-20-2003, 08:54 PM Also try: http://www.fastonlineusers.com/ As long as you only change the parts of the code that you are allowed to, you don't have to download or even host any scripts on your site. It is all processed on their servers. All you have to do is copy and paste and change the URL of your site in the link. Easy as pie! HTH, |