Subversion Repositories ALCASAR

Rev

Rev 1831 | Rev 2191 | Go to most recent revision | Details | Compare with Previous | 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
 
1831 raphael.pi 27
if (!isset($start) && !isset($stop)){
28
//if($start == '' && $stop == ''){
324 richard 29
	$now = time();
1831 raphael.pi 30
	$stop = date($config['sql_date_format'],$now);
324 richard 31
	$now -= 604800;
1831 raphael.pi 32
	$start = date($config['sql_date_format'],$now);
324 richard 33
}
1831 raphael.pi 34
$start = da_sql_escape_string($link,$start);
35
$stop = da_sql_escape_string($link,$stop);
324 richard 36
 
37
 
38
?>
39
 
40
<head>
41
<title>Statistiques utilisateurs</title>
42
<link rel="stylesheet" href="style.css">
43
</head>
44
<body>
45
<center>
46
<table border=0 width=550 cellpadding=0 cellspacing=0>
47
<tr valign=top>
48
<!--<td align=center><img src="images/title2.gif"></td>-->
49
</tr>
50
</table>
51
</table>
52
<br>
53
<tr valign=top>
54
<td width=65%></td>
55
<td bgcolor="black" width=35%>
1956 raphael.pi 56
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
57
	<tr bgcolor="#666666"align=center><td>
58
<table width="100%" border="0" cellspacing="0" cellpadding="0">
324 richard 59
	<font color="white">Statistiques utilisateurs</font>&nbsp;
1956 raphael.pi 60
	<tr><th></th></tr>
61
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
62
</table>
324 richard 63
<?php
1831 raphael.pi 64
if(isset($pagesize))
65
{	
324 richard 66
echo <<<EOM
67
De <b>$start</b> &agrave;  <b>$stop</b>
68
 
69
<p>
70
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
71
	<tr bgcolor="#d0ddb0">
1831 raphael.pi 72
	<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><th>Serveur</th>
324 richard 73
	</tr>
1831 raphael.pi 74
EOM;
324 richard 75
 
1831 raphael.pi 76
$pagesize = ($pagesize) ? $pagesize : 10;
77
 
78
 
79
$selected[5] = "";
80
$selected[10] = "";
81
$selected[15] = "";
82
$selected[20] = "";
83
$selected[40] = "";
84
$selected[80] = "";
85
$selected['all'] = "";
86
$selected['num'] = "";
87
$selected['time'] = "";
88
$selected['asc'] = "";
89
$selected['desc'] = "";
90
 
91
if (!is_numeric($pagesize) && $pagesize != 'all')
92
	$pagezise = 10;
93
if ($pagesize > 100)
94
	$pagesize = 100;
95
$limit = ($pagesize == 'all') ? '100' : "$pagesize";
96
$selected[$pagesize] = 'selected';
97
$order = ($order) ? $order : $config['general_accounting_info_order'];
98
if ($order != 'desc' && $order != 'asc')
99
	$order = 'desc';
100
if ($sortby != '')
101
	$order_attr = ($sortby == 'num') ? 'connnum' : 'conntotduration';
102
else
103
	$order_attr = 'connnum';
104
if ($server != '' && $server != 'all'){
105
	$server = da_sql_escape_string($link,$server);
106
	$server_str = "AND nasipaddress = '$server'";
107
}
108
else
109
{
110
	$server_str = "";
111
}
112
$login_str = ($login) ? "AND username = '$login' " : '';
113
 
114
$selected[$order] = 'selected';
115
$selected[$sortby] = 'selected';
116
 
117
$sql_extra_query = '';
118
if (isset($config['sql_accounting_extra_query'])){
119
	$sql_extra_query = xlat($config['sql_accounting_extra_query'],$login,$config);
120
	$sql_extra_query = da_sql_escape_string($link,$sql_extra_query);
121
}
122
 
123
unset($da_name_cache);
124
if (isset($_SESSION['da_name_cache']))
125
	$da_name_cache = $_SESSION['da_name_cache'];
126
 
127
 
128
 
129
 
324 richard 130
$link = @da_sql_pconnect($config);
131
if ($link){
1831 raphael.pi 132
	$num = 0;
324 richard 133
	$search = @da_sql_query($link,$config,
134
	"SELECT " . da_sql_limit($limit,0,$config) . " * FROM $config[sql_total_accounting_table]
135
	WHERE acctdate >= '$start' AND acctdate <= '$stop' $server_str $login_str $sql_extra_query " . da_sql_limit($limit,1,$config)
136
	. " ORDER BY $order_attr $order " . da_sql_limit($limit,2,$config) . " ;");
137
 
138
	if ($search){
139
		while( $row = @da_sql_fetch_array($search,$config) ){
140
			$num++;
1831 raphael.pi 141
			$acct_login = $row['username'];
324 richard 142
			if ($acct_login == '')
143
				$acct_login = '-';
144
			else{
145
				$Acct_login = urlencode($acct_login);
146
				$acct_login = "<a href=\"user_admin.php?login=$Acct_login\" title=\"Editer l'utilisateur $acct_login\">$acct_login</a>";
147
			}
1831 raphael.pi 148
			$acct_time = $row['conntotduration'];
324 richard 149
			$acct_time = time2str($acct_time);
1831 raphael.pi 150
			$acct_conn_num = $row['connnum'];
151
			$acct_date = $row['acctdate'];
152
			$acct_upload = $row['inputoctets'];
153
			$acct_download = $row['outputoctets'];
324 richard 154
			$acct_upload = bytes2str($acct_upload);
155
			$acct_download = bytes2str($acct_download);
156
			if (!isset($acct_server)){
1831 raphael.pi 157
				$acct_server = @gethostbyaddr($row['nasipaddress']);
158
				if (!isset($da_name_cache) && $config['general_use_session'] == 'yes'){
159
					$da_name_cache[$row['nasipaddress']] = $acct_server;
324 richard 160
					session_register('da_name_cache');
161
				}
162
				else
1831 raphael.pi 163
					$da_name_cache[$row['nasipaddress']] = $acct_server;
324 richard 164
			}
165
			if ($acct_server == '')
166
				$acct_server = '-';
167
			echo <<<EOM
168
			<tr align=center bgcolor="white">
169
				<td>$num</td>
170
				<td>$acct_login</td>
171
				<td>$acct_date</td>
172
				<td>$acct_server</td>
173
				<td>$acct_conn_num</td>
174
				<td>$acct_time</td>
175
				<td>$acct_upload</td>
176
				<td>$acct_download</td>
1831 raphael.pi 177
				<td>$acct_server</td>
178
 
324 richard 179
			</tr>
180
EOM;
181
		}
182
	}
1831 raphael.pi 183
 
324 richard 184
}
185
echo <<<EOM
186
	</table>
187
<tr><td>
188
<hr>
1831 raphael.pi 189
EOM;
190
}
191
else
192
{
193
	//create dummy selected
194
	if(!isset($selected))	
195
	{
196
		$selected = array();
197
		$selected[5] = "";
198
		$selected[10] = "";
199
		$selected[15] = "";
200
		$selected[20] = "";
201
		$selected[40] = "";
202
		$selected[80] = "";
203
		$selected['all'] = "";
204
		$selected['num'] = "";
205
		$selected['time'] = "";
206
		$selected['asc'] = "";
207
		$selected['desc'] = "";
208
	}
209
 
210
 
211
}
212
echo <<<EOM
324 richard 213
<tr><td align="left">
214
	<form action="user_stats.php" method="post" name="master">
215
	<table border=0>
216
		<tr valign="bottom">
217
			<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>
218
	<tr valign="middle"><td>
219
<input type="hidden" name="show" value="0">
220
<input type="text" name="start" size="11" value="$start"></td>
221
<td><input type="text" name="stop" size="11" value="$stop"></td>
222
<td><select name="pagesize">
1831 raphael.pi 223
 
224
<option $selected[5] value="5" >5
324 richard 225
<option $selected[10] value="10">10
226
<option $selected[15] value="15">15
227
<option $selected[20] value="20">20
228
<option $selected[40] value="40">40
229
<option $selected[80] value="80">80
230
<option $selected[all] value="all">tous
231
</select>
232
</td>
233
<td>
234
<select name="sortby">
235
<option $selected[num] value="num">Nombre de connexions
236
<option $selected[time] value="time">Dur&eacute;e des connexions
237
</select>
238
</td>
239
<td><select name="order">
240
<option $selected[asc] value="asc">croissant
241
<option $selected[desc] value="desc">d&eacute;croissant
242
</select>
243
</td>
244
EOM;
1831 raphael.pi 245
 
324 richard 246
?>
247
 
248
<td><input type="submit" class=button value="show"></td></tr>
249
<tr><td>
250
<b>Sur le serveur d'acc&egrave;s :</b>
251
</td>
252
<td><b>Utilisateur</b></td></tr>
253
<tr><td>
254
<select name="server">
255
<?php
256
foreach ($nas_list as $nas){
1831 raphael.pi 257
	$name = $nas['name'];
258
	if ($nas['ip'] == '')
324 richard 259
		continue;
260
	$servers[$name] = $nas[ip];
261
}
262
ksort($servers);
263
foreach ($servers as $name => $ip){
264
	if ($server == $ip)
265
		echo "<option selected value=\"$ip\">$name\n";
266
	else
267
		echo "<option value=\"$ip\">$name\n";
268
}
1831 raphael.pi 269
if (isset($server) && ($server == '' || $server == 'all'))
324 richard 270
	echo "<option selected value=\"all\">tous\n";
271
else
272
	echo "<option value=\"all\">tous\n";
273
?>
274
</select>
275
</td>
1831 raphael.pi 276
<td><input type="text" name="login" size="11" value="<?php if(!isset($login)){echo "";}else{ echo $login;} ?>"></td>
324 richard 277
</tr>
278
</table></td></tr></form>
279
</table>
280
</tr>
281
</table>
282
</body>
283
</html>