Subversion Repositories ALCASAR

Rev

Rev 1831 | Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
324 richard 1
<?php
2
require('/etc/freeradius-web/config.php');
3
require('../lib/functions.php');
4
require('../lib/sql/nas_list.php');
5
require_once('../lib/xlat.php');
6
?>
7
<html>
8
<?php
9
 
10
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
11
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
12
else{
13
	echo <<<EOM
14
<title>Statistiques utilisateurs</title>
15
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
16
<link rel="stylesheet" href="style.css">
17
</head>
18
<body>
19
<center>
20
<b>Could not include SQL library functions. Aborting</b>
21
</body>
22
</html>
23
EOM;
24
	exit();
25
}
26
 
27
if ($start == '' && $stop == ''){
28
	$now = time();
29
	$stop = date($config[sql_date_format],$now);
30
	$now -= 604800;
31
	$start = date($config[sql_date_format],$now);
32
}
33
$start = da_sql_escape_string($start);
34
$stop = da_sql_escape_string($stop);
35
$pagesize = ($pagesize) ? $pagesize : 10;
36
if (!is_numeric($pagesize) && $pagesize != 'all')
37
	$pagezise = 10;
38
if ($pagesize > 100)
39
	$pagesize = 100;
40
$limit = ($pagesize == 'all') ? '100' : "$pagesize";
41
$selected[$pagesize] = 'selected';
42
$order = ($order) ? $order : $config[general_accounting_info_order];
43
if ($order != 'desc' && $order != 'asc')
44
	$order = 'desc';
45
if ($sortby != '')
46
	$order_attr = ($sortby == 'num') ? 'connnum' : 'conntotduration';
47
else
48
	$order_attr = 'connnum';
49
if ($server != '' && $server != 'all'){
50
	$server = da_sql_escape_string($server);
51
	$server_str = "AND nasipaddress = '$server'";
52
}
53
$login_str = ($login) ? "AND username = '$login' " : '';
54
 
55
$selected[$order] = 'selected';
56
$selected[$sortby] = 'selected';
57
 
58
$sql_extra_query = '';
59
if ($config[sql_accounting_extra_query] != ''){
60
	$sql_extra_query = xlat($config[sql_accounting_extra_query],$login,$config);
61
	$sql_extra_query = da_sql_escape_string($sql_extra_query);
62
}
63
 
64
unset($da_name_cache);
65
if (isset($_SESSION['da_name_cache']))
66
	$da_name_cache = $_SESSION['da_name_cache'];
67
 
68
?>
69
 
70
<head>
71
<title>Statistiques utilisateurs</title>
72
<link rel="stylesheet" href="style.css">
73
</head>
74
<body>
75
<center>
76
<table border=0 width=550 cellpadding=0 cellspacing=0>
77
<tr valign=top>
78
<!--<td align=center><img src="images/title2.gif"></td>-->
79
</tr>
80
</table>
81
<table border=0 width=400 cellpadding=0 cellspacing=2>
82
</table>
83
<br>
84
<table border=0 width=840 cellpadding=1 cellspacing=1>
85
<tr valign=top>
86
<td width=65%></td>
87
<td bgcolor="black" width=35%>
88
	<table border=0 width=100% cellpadding=2 cellspacing=0>
89
	<tr bgcolor="#907030" align=right valign=top><th>
90
	<font color="white">Statistiques utilisateurs</font>&nbsp;
91
	</th></tr>
92
	</table>
93
</td></tr>
94
<tr bgcolor="black" valign=top><td colspan=2>
95
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
96
	<tr><td>
97
<?php
98
echo <<<EOM
99
De <b>$start</b> &agrave;  <b>$stop</b>
100
EOM;
101
?>
102
 
103
<p>
104
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
105
	<tr bgcolor="#d0ddb0">
106
	<th>#</th><th>Identifiant</th><th>Date</th><th>Serveur</th><th>Nombres de connections</th><th>Dur&eacute;e des connections</th><th>Upload</th><th>Download</th>
107
	</tr>
108
 
109
<?php
110
$link = @da_sql_pconnect($config);
111
if ($link){
112
	$search = @da_sql_query($link,$config,
113
	"SELECT " . da_sql_limit($limit,0,$config) . " * FROM $config[sql_total_accounting_table]
114
	WHERE acctdate >= '$start' AND acctdate <= '$stop' $server_str $login_str $sql_extra_query " . da_sql_limit($limit,1,$config)
115
	. " ORDER BY $order_attr $order " . da_sql_limit($limit,2,$config) . " ;");
116
 
117
	if ($search){
118
		while( $row = @da_sql_fetch_array($search,$config) ){
119
			$num++;
120
			$acct_login = $row[username];
121
			if ($acct_login == '')
122
				$acct_login = '-';
123
			else{
124
				$Acct_login = urlencode($acct_login);
125
				$acct_login = "<a href=\"user_admin.php?login=$Acct_login\" title=\"Editer l'utilisateur $acct_login\">$acct_login</a>";
126
			}
127
			$acct_time = $row[conntotduration];
128
			$acct_time = time2str($acct_time);
129
			$acct_conn_num = $row[connnum];
130
			$acct_date = $row[acctdate];
131
			$acct_upload = $row[inputoctets];
132
			$acct_download = $row[outputoctets];
133
			$acct_upload = bytes2str($acct_upload);
134
			$acct_download = bytes2str($acct_download);
135
			$acct_server = $da_name_cache[$row[nasipaddress]];
136
			if (!isset($acct_server)){
137
				$acct_server = @gethostbyaddr($row[nasipaddress]);
138
				if (!isset($da_name_cache) && $config[general_use_session] == 'yes'){
139
					$da_name_cache[$row[nasipaddress]] = $acct_server;
140
					session_register('da_name_cache');
141
				}
142
				else
143
					$da_name_cache[$row[nasipaddress]] = $acct_server;
144
			}
145
			if ($acct_server == '')
146
				$acct_server = '-';
147
			echo <<<EOM
148
			<tr align=center bgcolor="white">
149
				<td>$num</td>
150
				<td>$acct_login</td>
151
				<td>$acct_date</td>
152
				<td>$acct_server</td>
153
				<td>$acct_conn_num</td>
154
				<td>$acct_time</td>
155
				<td>$acct_upload</td>
156
				<td>$acct_download</td>
157
			</tr>
158
EOM;
159
		}
160
	}
161
}
162
echo <<<EOM
163
	</table>
164
<tr><td>
165
<hr>
166
<tr><td align="left">
167
	<form action="user_stats.php" method="post" name="master">
168
	<table border=0>
169
		<tr valign="bottom">
170
			<td><small><b>date d&eacute;but</td><td><small><b>date fin</td><td><small><b>nbr./page</td><td><small><b>tri&eacute; par</td><td><small><b>class&eacute; par ordre </td>
171
	<tr valign="middle"><td>
172
<input type="hidden" name="show" value="0">
173
<input type="text" name="start" size="11" value="$start"></td>
174
<td><input type="text" name="stop" size="11" value="$stop"></td>
175
<td><select name="pagesize">
176
<option $selected[5] value="5" >05
177
<option $selected[10] value="10">10
178
<option $selected[15] value="15">15
179
<option $selected[20] value="20">20
180
<option $selected[40] value="40">40
181
<option $selected[80] value="80">80
182
<option $selected[all] value="all">tous
183
</select>
184
</td>
185
<td>
186
<select name="sortby">
187
<option $selected[num] value="num">Nombre de connexions
188
<option $selected[time] value="time">Dur&eacute;e des connexions
189
</select>
190
</td>
191
<td><select name="order">
192
<option $selected[asc] value="asc">croissant
193
<option $selected[desc] value="desc">d&eacute;croissant
194
</select>
195
</td>
196
EOM;
197
?>
198
 
199
<td><input type="submit" class=button value="show"></td></tr>
200
<tr><td>
201
<b>Sur le serveur d'acc&egrave;s :</b>
202
</td>
203
<td><b>Utilisateur</b></td></tr>
204
<tr><td>
205
<select name="server">
206
<?php
207
foreach ($nas_list as $nas){
208
	$name = $nas[name];
209
	if ($nas[ip] == '')
210
		continue;
211
	$servers[$name] = $nas[ip];
212
}
213
ksort($servers);
214
foreach ($servers as $name => $ip){
215
	if ($server == $ip)
216
		echo "<option selected value=\"$ip\">$name\n";
217
	else
218
		echo "<option value=\"$ip\">$name\n";
219
}
220
if ($server == '' || $server == 'all')
221
	echo "<option selected value=\"all\">tous\n";
222
else
223
	echo "<option value=\"all\">tous\n";
224
?>
225
</select>
226
</td>
227
<td><input type="text" name="login" size="11" value="<?php echo $login ?>"></td>
228
</tr>
229
</table></td></tr></form>
230
</table>
231
</tr>
232
</table>
233
</body>
234
</html>