This is a simple one:
Create a file with the following content within /template/inc_script/frontend_render (and name it rt_users_online):
<?php /************************************************************************************************************************************ REPTAG CODE: {ONLINE} Developer: Joachim Scholtysik Homepage: http://www.scholtysik.net phpwcms Version: 1.3.9 running with r401 too last modified (RCS): 08.03.2010 08.03.2010 (RCS): Fix for some installations - not all will write into the scripts folder Enhanced output: styling the content 18.06.2008: Fix: Changed order of the variables $zeiten and $ips in the array 23.05.2008: Added phpwcms constants check written by O.G. 22.05.2008: Initial release Description: Shows a status line with users who are online. Installation: Copy this file into the frontend_render directory Create a blank file named "count.txt" and place it also in the frontend_render directory (CHMOD: 777) Place this line into your template or article: {ONLINE} ************************************************************************************************************************************/ // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- if( ! (strpos($content["all"],'{ONLINE}')===false)) { $content["all"] = preg_replace('/\{ONLINE\}/',online(),$content["all"]); } function online() { //$daten = $_SERVER['DOCUMENT_ROOT']."/count.txt"; $daten = PHPWCMS_ROOT."/count.txt"; $time = time(); $ip = getenv("REMOTE_ADDR"); $ablaufzeit = $time - "300"; $pruefung = @file($daten); while (list ($line_num, $line) = @each ($pruefung)) { $zeiten = explode("&&",$line); if($zeiten[1] <= $ablaufzeit) { $fp = fopen( "$daten", "r" ); $contents = fread($fp, filesize($daten)); fclose($fp); $line=quotemeta($line); $string2 = ""; $replace = ereg_replace($line, $string2, $contents); $fh=fopen($daten, "w"); @flock($fp,2); fputs($fh, $replace); @flock($fp,3); fclose($fh); } } $ippruefung = @file($daten); while (list ($line_num, $line) = @each ($ippruefung)) { $ips = explode("&&",$line); if($ips[0] == $ip) { $fp = fopen( "$daten", "r" ); $contents = fread($fp, filesize($daten)); fclose($fp); $line=quotemeta($line); $string2 = ""; $replace = ereg_replace($line, $string2, $contents); $fh=fopen($daten, "w"); @flock($fp,2); fputs($fh, $replace); @flock($fp,3); fclose($fh); } } $fp = fopen("$daten", "a+"); flock($fp,2); fputs ($fp, "$ip&&$time&&\n"); flock($fp,3); fclose ($fp); $anzahldaten = file($daten); $anzahl = count($anzahldaten); $online="<div style='color:RED;text-align:center'><p><b>$anzahl</b> User online</p></div>"; return $online; } ?>
Now create an empty file named “count.txt” and throw it into phpwcms-root (permission 777) and you are done.
Anywhere in your template you can call the script via {ONLINE} or by setting up a CP HTML containig {ONLINE}
You can adjust paths and file name anytime - same goes for styling the output.