Subversion Repositories ALCASAR

Rev

Rev 911 | Rev 1805 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

Rev 911 Rev 925
1
<?php
1
<?php
2
//gestion de la langue
2
//gestion de la langue
3
if (is_file("../lib/langues.php"))
3
if (is_file("../lib/langues.php"))
4
	include("../lib/langues.php");
4
	include("../lib/langues.php");
5
require('/etc/freeradius-web/config.php');
5
require('/etc/freeradius-web/config.php');
6
require('../lib/functions.php');
6
require('../lib/functions.php');
7
require('../lib/sql/functions.php');
7
require('../lib/sql/functions.php');
8
require('../lib/attrshow.php');
8
require('../lib/attrshow.php');
9
if (is_file("../lib/$config[general_lib_type]/user_info.php"))
9
if (is_file("../lib/$config[general_lib_type]/user_info.php"))
10
	include("../lib/$config[general_lib_type]/user_info.php");
10
	include("../lib/$config[general_lib_type]/user_info.php");
11
 
11
 
12
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
12
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
13
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
13
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
14
else{
14
else{
15
	echo <<<EOM
15
	echo <<<EOM
16
<html>
16
<html>
17
<head>
17
<head>
18
<title>User accounting</title>
18
<title>User accounting</title>
19
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
19
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
20
<link rel="stylesheet" href="/css/style.css">
20
<link rel="stylesheet" href="/css/style.css">
21
</head>
21
</head>
22
<body>
22
<body>
23
<center>
23
<center>
24
<b>Could not include SQL library functions. Aborting</b>
24
<b>Could not include SQL library functions. Aborting</b>
25
</body>
25
</body>
26
</html>
26
</html>
27
EOM;
27
EOM;
28
	exit();
28
	exit();
29
}
29
}
30
 
30
 
31
$now = time();
31
$now = time();
32
$now_str = ($now_str != '') ? "$now_str" : date($config[sql_date_format],$now + 86400);
32
$now_str = ($now_str != '') ? "$now_str" : date($config[sql_date_format],$now + 86400);
33
$prev_str = ($prev_str != '') ? "$prev_str" : date($config[sql_date_format], $now - 604800 );
33
$prev_str = ($prev_str != '') ? "$prev_str" : date($config[sql_date_format], $now - 604800 );
34
$num = 0;
34
$num = 0;
35
$pagesize = ($pagesize) ? $pagesize : 10;
35
$pagesize = ($pagesize) ? $pagesize : 10;
36
if (!is_numeric($pagesize) && $pagesize != 'all')
36
if (!is_numeric($pagesize) && $pagesize != 'all')
37
	$pagesize = 10;
37
	$pagesize = 10;
38
$limit = ($pagesize == 'all') ? '' : "$pagesize";
38
$limit = ($pagesize == 'all') ? '' : "$pagesize";
39
$selected[$pagesize] = 'selected';
39
$selected[$pagesize] = 'selected';
40
$order = ($order != '') ? $order : $config[general_accounting_info_order];
40
$order = ($order != '') ? $order : $config[general_accounting_info_order];
41
if ($order != 'desc' && $order != 'asc')
41
if ($order != 'desc' && $order != 'asc')
42
	$order = 'desc';
42
	$order = 'desc';
43
$selected[$order] = 'selected';
43
$selected[$order] = 'selected';
44
$now_str = mysql_escape_string($now_str);
44
$now_str = mysql_escape_string($now_str);
45
$prev_str = mysql_escape_string($prev_str);
45
$prev_str = mysql_escape_string($prev_str);
46
//$now_str = da_sql_escape_string($now_str);
46
//$now_str = da_sql_escape_string($now_str);
47
//$prev_str = da_sql_escape_string($prev_str);
47
//$prev_str = da_sql_escape_string($prev_str);
48
 
48
 
49
unset($da_name_cache);
49
unset($da_name_cache);
50
if (isset($_SESSION['da_name_cache']))
50
if (isset($_SESSION['da_name_cache']))
51
	$da_name_cache = $_SESSION['da_name_cache'];
51
	$da_name_cache = $_SESSION['da_name_cache'];
52
 
52
 
53
 
53
 
54
echo <<<EOM
54
echo <<<EOM
55
<html>
55
<html>
56
<head>
56
<head>
57
<title>iUser accounting</title>
57
<title>User accounting</title>
58
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
58
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
59
<link rel="stylesheet" href="/css/style.css">
59
<link rel="stylesheet" href="/css/style.css">
60
</head>
60
</head>
61
<body>
61
<body>
62
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
62
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
63
<tr><th>$l_users_managment</th></tr>
63
<tr><th>$l_users_managment</th></tr>
64
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" 
64
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" 
65
height="2"></td></tr>
65
height="2"></td></tr>
66
</TABLE>
66
</TABLE>
67
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
67
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
68
<tr bgcolor="#666666"><td>
68
<tr bgcolor="#666666"><td>
69
<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
69
<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
70
<tr><td valign="middle" align="left">
70
<tr><td valign="middle" align="left">
71
<center>
71
<center>
72
<table border=0 width=400 cellpadding=0 cellspacing=2>
72
<table border=0 width=640 cellpadding=0 cellspacing=2>
73
EOM;
73
EOM;
74
 
74
 
75
include("../html/user_toolbar.html.php");
75
include("../html/user_toolbar.html.php");
76
 
76
 
77
print <<<EOM
77
print <<<EOM
78
</table>
78
</table>
79
<br>
79
<br>
80
<table border=0 width=840 cellpadding=1 cellspacing=1>
80
<table border=0 width=720 cellpadding=1 cellspacing=1>
81
<tr valign=top>
81
<tr valign=top>
82
<td width=65%></td>
82
<td width=400></td>
83
<td bgcolor="black" width=35%>
83
<td bgcolor="black">
84
	<table border=0 width=100% cellpadding=2 cellspacing=0>
84
	<table border=0 width=100% cellpadding=2 cellspacing=0>
85
	<tr bgcolor="#907030" align=right valign=top><th>
85
	<tr bgcolor="#907030" align=right valign=top><th>
86
	<font color="white">$l_user : $login ($cn)</font>
86
	<font color="white">$l_user : $login ($cn)</font>
87
	</th></tr>
87
	</th></tr>
88
	</table>
88
	</table>
89
</td></tr>
89
</td></tr>
90
<tr bgcolor="black" valign=top><td colspan=2>
90
<tr bgcolor="black" valign=top><td colspan=2>
91
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
91
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
92
	<tr><td>
92
	<tr><td>
93
Dates : <b>$prev_str</b> to <b>$now_str</b>
93
Dates : <b>$prev_str</b> to <b>$now_str</b>
94
EOM;
94
EOM;
95
?>
95
?>
96
<p>
96
<p>
97
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
97
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
98
	<tr bgcolor="#d0ddb0">
98
	<tr bgcolor="#d0ddb0">
99
	<td><b>#</b></td>
99
	<td><b>#</b></td>
100
<?php
100
<?php
101
for($i=1;$i<=9;$i++){
101
for($i=1;$i<=9;$i++){
102
	if (($acct_attrs['ua']["$i"] != '') && ($acct_attrs['ua']["$i"] != 'server') && ($acct_attrs['ua']["$i"] != 'callerid'))
102
	if (($acct_attrs['ua']["$i"] != '') && ($acct_attrs['ua']["$i"] != 'server') && ($acct_attrs['ua']["$i"] != 'callerid'))
103
		echo "<td><b>" . $acct_attrs['ua']["$i"] . "</b></td>\n";
103
		echo "<td><b>" . $acct_attrs['ua']["$i"] . "</b></td>\n";
104
}
104
}
105
$sql_extra_query = '';
105
$sql_extra_query = '';
106
if ($config[sql_accounting_extra_query] != '')
106
if ($config[sql_accounting_extra_query] != '')
107
	$sql_extra_query = xlat($config[sql_accounting_extra_query],$login,$config);
107
	$sql_extra_query = xlat($config[sql_accounting_extra_query],$login,$config);
108
?>
108
?>
109
	</tr>
109
	</tr>
110
 
110
 
111
<?php
111
<?php
112
$link = @da_sql_pconnect($config);
112
$link = @da_sql_pconnect($config);
113
if ($link){
113
if ($link){
114
	$search = @da_sql_query($link,$config,
114
	$search = @da_sql_query($link,$config,
115
	"SELECT " . da_sql_limit($limit,0,$config) . " * FROM $config[sql_accounting_table]
115
	"SELECT " . da_sql_limit($limit,0,$config) . " * FROM $config[sql_accounting_table]
116
	WHERE username = '$login' AND acctstarttime <= '$now_str'
116
	WHERE username = '$login' AND acctstarttime <= '$now_str'
117
	AND acctstarttime >= '$prev_str' $sql_extra_query " . da_sql_limit($limit,1,$config) .
117
	AND acctstarttime >= '$prev_str' $sql_extra_query " . da_sql_limit($limit,1,$config) .
118
	" ORDER BY acctstarttime $order " . da_sql_limit($limit,2,$config). " ;");
118
	" ORDER BY acctstarttime $order " . da_sql_limit($limit,2,$config). " ;");
119
	if ($search){
119
	if ($search){
120
		while( $row = @da_sql_fetch_array($search,$config) ){
120
		while( $row = @da_sql_fetch_array($search,$config) ){
121
			$num++;
121
			$num++;
122
			$acct_type = "$row[framedprotocol]/$row[nasporttype]";
122
			$acct_type = "$row[framedprotocol]/$row[nasporttype]";
123
			if ($acct_type == '')
123
			if ($acct_type == '')
124
				$acct_type = '-';
124
				$acct_type = '-';
125
			$acct_logedin = $row[acctstarttime];
125
			$acct_logedin = $row[acctstarttime];
126
			$acct_sessiontime = $row[acctsessiontime];
126
			$acct_sessiontime = $row[acctsessiontime];
127
			$acct_sessiontime_sum += $acct_sessiontime;
127
			$acct_sessiontime_sum += $acct_sessiontime;
128
			$acct_sessiontime = time2str($acct_sessiontime);
128
			$acct_sessiontime = time2str($acct_sessiontime);
129
			$acct_ip = $row[framedipaddress];
129
			$acct_ip = $row[framedipaddress];
130
			if ($acct_ip == '')
130
			if ($acct_ip == '')
131
				$acct_ip = '-';
131
				$acct_ip = '-';
132
			$acct_upload = $row[acctinputoctets];
132
			$acct_upload = $row[acctinputoctets];
133
			$acct_upload_sum += $acct_upload;
133
			$acct_upload_sum += $acct_upload;
134
			$acct_upload = bytes2str($acct_upload);
134
			$acct_upload = bytes2str($acct_upload);
135
			$acct_download = $row[acctoutputoctets];
135
			$acct_download = $row[acctoutputoctets];
136
			$acct_download_sum += $acct_download;
136
			$acct_download_sum += $acct_download;
137
			$acct_download = bytes2str($acct_download);
137
			$acct_download = bytes2str($acct_download);
138
			$acct_server = $row[nasipaddress];
138
			$acct_server = $row[nasipaddress];
139
			if ($acct_server != ''){
139
			if ($acct_server != ''){
140
				$acct_server = $da_name_cache[$row[nasipaddress]];
140
				$acct_server = $da_name_cache[$row[nasipaddress]];
141
				if (!isset($acct_server)){
141
				if (!isset($acct_server)){
142
					$acct_server = @gethostbyaddr($row[nasipaddress]);
142
					$acct_server = @gethostbyaddr($row[nasipaddress]);
143
					if (!isset($da_name_cache) && $config[general_use_session] == 'yes'){
143
					if (!isset($da_name_cache) && $config[general_use_session] == 'yes'){
144
						$da_name_cache[$row[nasipaddress]] = $acct_server;
144
						$da_name_cache[$row[nasipaddress]] = $acct_server;
145
						session_register('da_name_cache');
145
						session_register('da_name_cache');
146
					}
146
					}
147
					else
147
					else
148
						$da_name_cache[$row[nasipaddress]] = $acct_server;
148
						$da_name_cache[$row[nasipaddress]] = $acct_server;
149
				}
149
				}
150
			}
150
			}
151
			else
151
			else
152
				$acct_server = '-';
152
				$acct_server = '-';
153
			$acct_server = "$acct_server:$row[nasportid]";
153
			$acct_server = "$acct_server:$row[nasportid]";
154
			$acct_terminate_cause = "$row[acctterminatecause]";
154
			$acct_terminate_cause = "$row[acctterminatecause]";
155
			if ($acct_terminate_cause == '')
155
			if ($acct_terminate_cause == '')
156
				$acct_terminate_cause = '-';
156
				$acct_terminate_cause = '-';
157
			if (ereg('Login-Incorrect',$acct_terminate_cause) ||
157
			if (ereg('Login-Incorrect',$acct_terminate_cause) ||
158
				ereg('Multiple-Logins', $acct_terminate_cause) || ereg('Invalid-User',$acct_terminate_cause))
158
				ereg('Multiple-Logins', $acct_terminate_cause) || ereg('Invalid-User',$acct_terminate_cause))
159
			$acct_callerid = "$row[callingstationid]";
159
			$acct_callerid = "$row[callingstationid]";
160
			if ($acct_callerid == '')
160
			if ($acct_callerid == '')
161
				$acct_callerid = '-';
161
				$acct_callerid = '-';
162
			echo <<<EOM
162
			echo <<<EOM
163
			<tr align=center>
163
			<tr align=center>
164
				<td>$num</td>
164
				<td>$num</td>
165
EOM;
165
EOM;
166
				if ($acct_attrs[ua][1] != '') echo "<td>$acct_type</td>\n";
166
				if ($acct_attrs[ua][1] != '') echo "<td>$acct_type</td>\n";
167
				if ($acct_attrs[ua][2] != '') echo "<td>$acct_logedin</td>\n";
167
				if ($acct_attrs[ua][2] != '') echo "<td>$acct_logedin</td>\n";
168
				if ($acct_attrs[ua][3] != '') echo "<td>$acct_sessiontime</td>\n";
168
				if ($acct_attrs[ua][3] != '') echo "<td>$acct_sessiontime</td>\n";
169
				if ($acct_attrs[ua][4] != '') echo "<td>$acct_ip</td>\n";
169
				if ($acct_attrs[ua][4] != '') echo "<td>$acct_ip</td>\n";
170
				if ($acct_attrs[ua][5] != '') echo "<td>$acct_upload</td>\n";
170
				if ($acct_attrs[ua][5] != '') echo "<td>$acct_upload</td>\n";
171
				if ($acct_attrs[ua][6] != '') echo "<td>$acct_download</td>\n";
171
				if ($acct_attrs[ua][6] != '') echo "<td>$acct_download</td>\n";
172
//				if ($acct_attrs[ua][7] != '') echo "<td>$acct_server</td>\n";
172
//				if ($acct_attrs[ua][7] != '') echo "<td>$acct_server</td>\n";
173
				if ($acct_attrs[ua][8] != '') echo "<td>$acct_terminate_cause</td>\n";
173
				if ($acct_attrs[ua][8] != '') echo "<td>$acct_terminate_cause</td>\n";
174
//				if ($acct_attrs[ua][9] != '') echo "<td>$acct_callerid</td>\n";
174
//				if ($acct_attrs[ua][9] != '') echo "<td>$acct_callerid</td>\n";
175
			echo "</tr>\n";
175
			echo "</tr>\n";
176
		}
176
		}
177
		$acct_sessiontime_sum = time2str($acct_sessiontime_sum);
177
		$acct_sessiontime_sum = time2str($acct_sessiontime_sum);
178
		$acct_upload_sum = bytes2str($acct_upload_sum);
178
		$acct_upload_sum = bytes2str($acct_upload_sum);
179
		$acct_download_sum = bytes2str($acct_download_sum);
179
		$acct_download_sum = bytes2str($acct_download_sum);
180
	}
180
	}
181
	else
181
	else
182
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
182
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
183
}
183
}
184
else
184
else
185
	echo "<b>Could not connect to SQL database</b><br>\n";
185
	echo "<b>Could not connect to SQL database</b><br>\n";
186
$colspan = 3;
186
$colspan = 3;
187
if ($acct_attrs[ua][1] == '')
187
if ($acct_attrs[ua][1] == '')
188
	$colspan--;
188
	$colspan--;
189
if ($acct_attrs[ua][2] == '')
189
if ($acct_attrs[ua][2] == '')
190
	$colspan--;
190
	$colspan--;
191
echo <<<EOM
191
echo <<<EOM
192
			<tr bgcolor="lightyellow" align="center">
192
			<tr bgcolor="lightyellow" align="center">
193
			<td colspan=$colspan><b>Total</b></td>
193
			<td colspan=$colspan><b>Total</b></td>
194
EOM;
194
EOM;
195
				if ($acct_attrs[ua][3] != '') echo "<td><b>$acct_sessiontime_sum</b></td>\n";
195
				if ($acct_attrs[ua][3] != '') echo "<td><b>$acct_sessiontime_sum</b></td>\n";
196
				if ($acct_attrs[ua][4] != '') echo "<td>&nbsp;</td>\n";
196
				if ($acct_attrs[ua][4] != '') echo "<td>&nbsp;</td>\n";
197
				if ($acct_attrs[ua][5] != '') echo "<td><b>$acct_upload_sum</b></td>\n";
197
				if ($acct_attrs[ua][5] != '') echo "<td><b>$acct_upload_sum</b></td>\n";
198
				if ($acct_attrs[ua][6] != '') echo "<td><b>$acct_download_sum</b></td>\n";
198
				if ($acct_attrs[ua][6] != '') echo "<td><b>$acct_download_sum</b></td>\n";
199
//				if ($acct_attrs[ua][7] != '') echo "<td>&nbsp;</td>\n";
199
//				if ($acct_attrs[ua][7] != '') echo "<td>&nbsp;</td>\n";
200
				if ($acct_attrs[ua][8] != '') echo "<td>&nbsp;</td>\n";
200
				if ($acct_attrs[ua][8] != '') echo "<td>&nbsp;</td>\n";
201
//				if ($acct_attrs[ua][9] != '') echo "<td>&nbsp;</td>\n";
201
//				if ($acct_attrs[ua][9] != '') echo "<td>&nbsp;</td>\n";
202
?>
202
?>
203
				</tr>
203
				</tr>
204
	</table>
204
	</table>
205
<tr><td>
205
<tr><td>
206
<hr>
206
<hr>
207
<tr><td align="center">
207
<tr><td align="center">
208
	<form action="user_accounting.php" method="get" name="master">
208
	<form action="user_accounting.php" method="get" name="master">
209
	<table border=0>
209
	<table border=0>
210
		<tr><td colspan=6></td>
210
		<tr><td colspan=6></td>
211
		</tr>
211
		</tr>
212
		<tr valign="bottom">
212
		<tr valign="bottom">
213
	<td><?php echo "$l_user";?></td><td>from</td><td>to</td><td>nbr./page</td><td>order</td>
213
	<td><?php echo "$l_user";?></td><td>from</td><td>to</td><td>nbr./page</td><td>order</td>
214
	<tr valign="middle"><td>
214
	<tr valign="middle"><td>
215
<?php
215
<?php
216
	echo <<<EOM
216
	echo <<<EOM
217
<input type="text" name="login" size="11" value="$login"></td>
217
<input type="text" name="login" size="11" value="$login"></td>
218
<td><input type="text" name="prev_str" size="11" value="$prev_str"></td>
218
<td><input type="text" name="prev_str" size="11" value="$prev_str"></td>
219
<td><input type="text" name="now_str" size="11" value="$now_str"></td>
219
<td><input type="text" name="now_str" size="11" value="$now_str"></td>
220
<td><select name="pagesize">
220
<td><select name="pagesize">
221
<option $selected[5] value="5" >05
221
<option $selected[5] value="5" >05
222
<option $selected[10] value="10">10
222
<option $selected[10] value="10">10
223
<option $selected[15] value="15">15
223
<option $selected[15] value="15">15
224
<option $selected[20] value="20">20
224
<option $selected[20] value="20">20
225
<option $selected[40] value="40">40
225
<option $selected[40] value="40">40
226
<option $selected[80] value="80">80
226
<option $selected[80] value="80">80
227
<option $selected[all] value="all">tous
227
<option $selected[all] value="all">tous
228
</select>
228
</select>
229
</td>
229
</td>
230
<td><select name="order">
230
<td><select name="order">
231
<option $selected[asc] value="asc">older first
231
<option $selected[asc] value="asc">older first
232
<option $selected[desc] value="desc">recent first
232
<option $selected[desc] value="desc">recent first
233
</select>
233
</select>
234
</td>
234
</td>
235
EOM;
235
EOM;
236
?>
236
?>
237
 
237
 
238
<td><input type="submit" class=button value="show"></td></tr>
238
<td><input type="submit" class=button value="show"></td></tr>
239
</table></td></tr></form>
239
</table></td></tr></form>
240
</table>
240
</table>
241
</tr>
241
</tr>
242
</table>
242
</table>
243
</TD></TR>
243
</TD></TR>
244
</TABLE>
244
</TABLE>
245
</td></tr>
245
</td></tr>
246
</TABLE>
246
</TABLE>
247
</body>
247
</body>
248
</html>
248
</html>
249
 
249