Subversion Repositories ALCASAR

Rev

Rev 324 | Rev 1956 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

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