NAVIGATION
This shows you the differences between two versions of the page.
|
deutsch:ersetzer_rts:frontend_render:benutzer_online [2010/03/08 14:04] Claus created |
deutsch:ersetzer_rts:frontend_render:benutzer_online [2018/06/03 18:09] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Anzahl der Benutzer, die gerade online sind ===== | ===== Anzahl der Benutzer, die gerade online sind ===== | ||
| + | Das ist ganz einfach: \\ | ||
| + | Lege eine Datei mit folgendem Inhalt an (nenne sie rt_users_online und speichere sie in /template/inc_script/frontend_render): | ||
| + | <code php> | ||
| + | <?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; | ||
| + | } | ||
| + | ?> | ||
| + | </code> | ||
| + | Jetzt noch eine leere Datei "count.txt" ins phpwcms-root (Dateitechte 777) und fertig. \\ | ||
| + | In Deiner Vorlage schreibe {ONLINE} - oder erstelle einen CP HTML mit dem Inhalt {ONLINE} \\ | ||
| + | Pfade und Dateiname sowie output-Aussehen können angepasst werden. | ||