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