1<?
2/*
3 * (C) Copyright 2003 Krzysztof Gibas <sdas (at) gibas org>
4 *                      - current maintainer
5 *               2001 Gonthar <gonthar (at) moon net pl>
6 *                      - developed scr_ipfm-0.1
7 *
8 * scr_ipfm generates graphical statistics from ipfm logs.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This  program is  distributed in the  hope  that  it will be useful,
16 * but  WITHOUT  ANY  WARRANTY;  without even  the  implied warranty of
17 * MERCHANTABILITY  or  FITNESS  FOR  A  PARTICULAR  PURPOSE.  See  the
18 * GNU General Public License for more details.
19 *
20 * You  should  have  received a copy of the GNU General Public License
21 * along  with  this  program;  if  not,  write  to  the  Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
23 * USA.
24 *
25 * $Id: index.php,v 1.116 2003/11/04 19:56:17 gibas Exp $
26*/
27
28include("conf.php");
29include("functions.php");
30
31//0.0.0.0 - access from any network.
32if ($hosts_allow != "0.0.0.0") {
33    $keywords = preg_split ("/([\s]+|[\s]*[\,][\s]*|[\s]*[;][\s]*)/", "$hosts_allow", -1, PREG_SPLIT_NO_EMPTY);
34
35    for ($counter = 0; $counter < count($keywords); $counter++) {
36        $hosts_allow = $keywords[$counter];
37
38        $raddr = split("\.", $_SERVER['REMOTE_ADDR']);
39        $hallow = split("\.", $hosts_allow);
40
41        $access = 0;
42        //check first four numbers of $hosts_allow
43        for ($i = 0; $i <= 3; $i++) {
44            if ($raddr[$i] == $hallow[$i]) {
45                $access++;
46            }
47            //if adress is network address i.e. 192.168.1.0
48            if ($i == 2 && $hallow[3] == "0") {
49                $access++;
50            }
51        }
52	//if $access == 4 access is granted.
53        if ($access == 4) {
54            $deny = 1;
55        }
56    }
57    if (!$deny) {
58        echo "Sorry, You don't have permission to access on this server.";
59        exit();
60    }
61}
62
63if (isset($_GET['host']) == 1 ) {
64    include "host.php";
65}
66elseif (isset($_GET['daily']) == 1) {
67    include "daily.php";
68}
69elseif (isset($_GET['dailygraph']) == 1) {
70    include "daily-graph.php";
71}
72elseif (isset($_GET['dayinmonth']) == 1) {
73    include "dayinmonth.php";
74}
75elseif (isset($_GET['dayinmonthgraph']) == 1) {
76    include "dayinmonth-graph.php";
77}
78elseif (isset($_GET['monthly']) == 1) {
79    include "monthly.php";
80}
81elseif (isset($_GET['monthlygraph']) == 1) {
82    include "monthly-graph.php";
83}
84elseif (isset($_GET['monthinyear']) == 1) {
85    include "monthinyear.php";
86}
87elseif (isset($_GET['monthinyeargraph']) ==1) {
88    include "monthinyear-graph.php";
89}
90elseif (isset($_GET['yearly']) == 1) {
91    include "yearly.php";
92}
93elseif (isset($_GET['yearlygraph']) == 1) {
94    include "yearly-graph.php";
95}
96elseif (isset($_GET['yearinglobal']) == 1) {
97    include "yearinglobal.php";
98}
99elseif (isset($_GET['yearinglobalgraph']) == 1) {
100    include "yearinglobal-graph.php";
101}
102elseif (isset($_GET['global']) == 1) {
103    include "global.php";
104}
105elseif (isset($_GET['globalgraph']) == 1) {
106    include "global-graph.php";
107}
108//default stats
109else {
110    //Is it secure? I think so.
111    $default_stats = addslashes($default_stats);
112
113    if (isset($default_stats) && file_exists("./$default_stats" . ".php")) {
114	include("$default_stats" . ".php");
115    }
116    else {
117	include("daily.php");
118    }
119}
120
121html_make_footer();
122
123?>
124