Nachfolgendes Addon ermöglicht es den Traffic deines GTChats extern auszugeben,
dabei werden immer 30 Tage berücksichtigt.
Zum Eintrag in der Datenbank
dabei werden immer 30 Tage berücksichtigt.
PHP-Quellcode
- <?php
- // GTChat Traffic Zähler
- // Version 0.5b
- // Original by TobiTaba
- // Erweitert mit Monats und Trafficzähler 07/08/2007 durch Sven Schmidt "condor" (info@gtchat-developer.de)
- // Alle Rechte unterliegen www.gtchat-developer.de & TobiTaba
- ob_start();
- ?>
- <html>
- <head>
- <title>Chat - Traffic Übersicht</title>
- </head>
- <center>
- <table style="width:100%; border:0px;" cellspacing="0" cellpadding="2">
- <tr>
- <td style="width:50%;" valign="top"><span style="font-weight:bold;">Datum</span></td>
- <td style="width:50%;" valign="top"><span style="font-weight:bold;">Traffic</span></td>
- </tr>
- <?
- $file = 'cgi-bin/Variables/traffic.log';
- $byte = 'Byte';
- $month = 0; // Monatszähler
- $traffic = 0; // Trafficzähler
- if(is_file($file)){
- $hash = fopen($file,'r');
- while(!feof($hash)) {
- $zeile = fgets($hash);
- $array = explode('|',$zeile);
- $datum = date("d.m.Y", + $array[0]);
- if($array[1] > 1024) {
- $array[1] = round ($array[1] / 1024 / 1024,2);
- $byte = 'MB';
- $month ++;
- $traffic = $traffic + $array[1];
- }
- // Datum darf nicht Unix Zeit entsprechen, der Monat darf noch nicht vorbei sein.
- if($datum != "01.01.1970" && $month <= 31){
- ?>
- <tr>
- <td style="width:50%;" valign="top"><?=$datum;?></td>
- <td style="width:50%;" valign="top"><?=$array[1];?> <?=$byte;?></td>
- </tr>
- <?
- }
- }
- // Nach einem Monat, Gesamtverbrauch anzeigen.
- if($month == 31){
- echo '<tr>';
- echo '<td valign="top" style="text-align:center;" colspan="2">Sie haben diesen Monat '. $traffic .' '. $byte .' Traffic verbraucht.</td>';
- echo '</tr>';
- }
- fclose($hash);
- ?>
- </table>
- </center>
- <div style="text-align:center;"><input type="submit" onClick="print();" value="Drucken" /></div>
- <? } ?>
- </body>
- </html>
- <? ob_end_flush(); ?>
Zum Eintrag in der Datenbank