Aby pod statystykami były transfery poszczególnych userów musisz mieć zainstalowanego, poprawnie skonfigurowanego i odpalonego niceshaper'a a w pliku index.php (plik statystyk) musisz dokonać drobnych zmian:
1/ wpis $handle = fopen("nsstats.txt", 'rb'); <--- tutaj ścieżka do pliku statystyki niceshaper'a)
2/ zahaszować linie #main_text_close();
3/ w tej lini #include("themes/$themes/index.php"); jest błąd, w pliku oryginalnym theme jest bez "s" w obydwu wyrazach)
i to chyba tyle, poniżej mój plik index.php
<?
/*
* (C) Copyright 2003 Krzysztof Gibas <sdas (at) gibas org>
* - current maintainer
* 2001 Gonthar <gonthar (at) moon net pl>
* - developed scr_ipfm-0.1
*
* scr_ipfm generates graphical statistics from ipfm logs.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: index.php,v 1.116 2003/11/04 19:56:17 gibas Exp $
*/
include("conf.php");
include("functions.php");
//0.0.0.0 - access from any network.
if ($hosts_allow != "0.0.0.0") {
$keywords = preg_split ("/([\s]+|[\s]*[\,][\s]*|[\s]*[;][\s]*)/", "$hosts_allow", -1, PREG_SPLIT_NO_EMPTY);
for ($counter = 0; $counter < count($keywords); $counter++) {
$hosts_allow = $keywords[$counter];
$raddr = split("\.", $_SERVER['REMOTE_ADDR']);
$hallow = split("\.", $hosts_allow);
$access = 0;
//check first four numbers of $hosts_allow
for ($i = 0; $i <= 3; $i++) {
if ($raddr[$i] == $hallow[$i]) {
$access++;
}
//if adress is network address i.e. 192.168.1.0
if ($i == 2 && $hallow[3] == "0") {
$access++;
}
}
//if $access == 4 access is granted.
if ($access == 4) {
$deny = 1;
}
}
if (!$deny) {
echo "Sorry, You don't have permission to access on this server.";
exit();
}
}
if (isset($_GET['host']) == 1 ) {
include "host.php";
}
elseif (isset($_GET['daily']) == 1) {
include "daily.php";
}
elseif (isset($_GET['dailygraph']) == 1) {
include "daily-graph.php";
}
elseif (isset($_GET['dayinmonth']) == 1) {
include "dayinmonth.php";
}
elseif (isset($_GET['dayinmonthgraph']) == 1) {
include "dayinmonth-graph.php";
}
elseif (isset($_GET['monthly']) == 1) {
include "monthly.php";
}
elseif (isset($_GET['monthlygraph']) == 1) {
include "monthly-graph.php";
}
elseif (isset($_GET['monthinyear']) == 1) {
include "monthinyear.php";
}
elseif (isset($_GET['monthinyeargraph']) ==1) {
include "monthinyear-graph.php";
}
elseif (isset($_GET['yearly']) == 1) {
include "yearly.php";
}
elseif (isset($_GET['yearlygraph']) == 1) {
include "yearly-graph.php";
}
elseif (isset($_GET['yearinglobal']) == 1) {
include "yearinglobal.php";
}
elseif (isset($_GET['yearinglobalgraph']) == 1) {
include "yearinglobal-graph.php";
}
elseif (isset($_GET['global']) == 1) {
include "global.php";
}
elseif (isset($_GET['globalgraph']) == 1) {
include "global-graph.php";
}
//default stats
else {
//Is it secure? I think so.
$default_stats = addslashes($default_stats);
if (isset($default_stats) && file_exists("./$default_stats" . ".php")) {
include("$default_stats" . ".php");
}
else {
include("daily.php");
}
}
html_make_footer();
$chunksize = 1*(1024*1024); // how many bytes per chunk
$handle = fopen("nsstats.txt", 'rb');
if ($handle === false) {
return false;
}
echo '<table align="center" width="80%" border="0" cellspacing="2" cellpadding="2">
<tr align="center" style="padding-bottom: 10px;"><td class="title"> </td><td class="title"><strong>Komputer</s
trong></td><td class="title" align="center"><strong>Download</strong></td><td class="title" align="center"><strong>Upload</st
rong></td></tr>';
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
$buffer3=explode("\n", $buffer);
$zlicz=1;
$down=0;
$up=0;
for ($i=2;$i<count($buffer3);$i++) {
$buffer3[$i] = preg_replace('/\s+/', ' ', $buffer3[$i]);
$buffer2=explode(" ", $buffer3[$i]);
if ($buffer2[0] !='') {
echo '<tr><td align="right">'.($zlicz).'.</td><td style="padding-le
ft: 10px;">'.$buffer2[0].'</td>
<td align="right" style="padding-right: 30px;">'.substr
($buffer2[4],0,-4).' kB/s</td>
<td align="right" style="padding-right: 30p
x;">'.substr($buffer2[9],0,-4).' kB/s</td>
</tr>';
$down=$down+substr($buffe
r2[4],0,-4);
$up=$up+substr($b
uffer2[9],0,-4);
$zlicz=$z
licz+1;
}
}
echo '<tr style="padding-top: 10px;"><td> </td><td align="center"><strong>razem</strong></td><td align="right" style="pa
dding-right: 30px;"><strong>'.$down;
if (substr($down,-2,1)!='.') echo '.0';
echo '</strong> kB/s</td><td align="right" style="padding-right: 30px;"><strong>'.$up;
if (substr($up,-2,1)!='.') echo '.0';
-echo '</strong> kB/s</td></tr></table>';
}
fclose($handle);
#main_text_close();
#=====================================================#
$site_title = 'Shaper';
$meta_info = '<META HTTP-EQUIV="Refresh" CONTENT="60; URL=shaper.php">';
#include("themes/$themes/index.php");
?>
|