Subversion Repositories ALCASAR

Rev

Rev 820 | 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
?>
4
<html>
5
<?php
6
require('../lib/functions.php');
7
require('../lib/sql/functions.php');
8
require('../lib/attrshow.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>Analyse pour $login</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
$now = time();
28
$now_str = ($now_str != '') ? "$now_str" : date($config[sql_date_format],$now + 86400);
29
$prev_str = ($prev_str != '') ? "$prev_str" : date($config[sql_date_format], $now - 604800 );
30
$num = 0;
31
$pagesize = ($pagesize) ? $pagesize : 10;
32
if (!is_numeric($pagesize) && $pagesize != 'all')
33
	$pagesize = 10;
34
$limit = ($pagesize == 'all') ? '' : "$pagesize";
35
$selected[$pagesize] = 'selected';
36
$order = ($order != '') ? $order : $config[general_accounting_info_order];
37
if ($order != 'desc' && $order != 'asc')
38
	$order = 'desc';
39
$selected[$order] = 'selected';
40
$now_str = da_sql_escape_string($now_str);
41
$prev_str = da_sql_escape_string($prev_str);
42
 
43
unset($da_name_cache);
44
if (isset($_SESSION['da_name_cache']))
45
	$da_name_cache = $_SESSION['da_name_cache'];
46
 
47
 
48
echo <<<EOM
49
<head>
50
<title>Analyse pour $login</title>
51
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
52
<link rel="stylesheet" href="/css/style.css">
53
</head>
54
<body>
55
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
56
<tr><th>Statistique des connexions</th></tr>
57
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" 
58
height="2"></td></tr>
59
</TABLE>
60
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
61
<tr bgcolor="#666666"><td>
62
<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
63
<tr><td valign="middle" align="left">
64
<center>
65
<table border=0 width=550 cellpadding=0 cellspacing=0>
66
<tr valign=top>
67
<!--<td align=center><img src="images/title2.gif"></td>-->
68
</tr>
69
</table>
70
<table border=0 width=400 cellpadding=0 cellspacing=2>
71
EOM;
72
 
73
include("../html/user_toolbar.html.php");
74
 
75
print <<<EOM
76
</table>
77
<br>
78
<table border=0 width=840 cellpadding=1 cellspacing=1>
79
<tr valign=top>
80
<td width=65%></td>
81
<td bgcolor="black" width=35%>
82
	<table border=0 width=100% cellpadding=2 cellspacing=0>
83
	<tr bgcolor="#907030" align=right valign=top><th>
84
	<font color="white">Analyse pour $login</font>&nbsp;
85
	</th></tr>
86
	</table>
87
</td></tr>
88
<tr bgcolor="black" valign=top><td colspan=2>
89
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
90
	<tr><td>
91
Dates du <b>$prev_str</b> au <b>$now_str</b>
92
EOM;
93
?>
94
 
95
<p>
96
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
97
	<tr bgcolor="#d0ddb0">
98
	<th>#</th>
99
<?php
100
for($i=1;$i<=9;$i++){
101
	if ($acct_attrs['ua']["$i"] != '')
102
		echo "<th>" . $acct_attrs['ua']["$i"] . "</th>\n";
103
}
104
$sql_extra_query = '';
105
if ($config[sql_accounting_extra_query] != '')
106
	$sql_extra_query = xlat($config[sql_accounting_extra_query],$login,$config);
107
?>
108
	</tr>
109
 
110
<?php
111
$link = @da_sql_pconnect($config);
112
if ($link){
113
	$search = @da_sql_query($link,$config,
114
	"SELECT " . da_sql_limit($limit,0,$config) . " * FROM $config[sql_accounting_table]
115
	WHERE username = '$login' AND acctstarttime <= '$now_str'
116
	AND acctstarttime >= '$prev_str' $sql_extra_query " . da_sql_limit($limit,1,$config) .
117
	" ORDER BY acctstarttime $order " . da_sql_limit($limit,2,$config). " ;");
118
	if ($search){
119
		while( $row = @da_sql_fetch_array($search,$config) ){
120
			$tr_color='white';
121
			$num++;
122
			$acct_type = "$row[framedprotocol]/$row[nasporttype]";
123
			if ($acct_type == '')
124
				$acct_type = '-';
125
			$acct_logedin = $row[acctstarttime];
126
			$acct_sessiontime = $row[acctsessiontime];
127
			$acct_sessiontime_sum += $acct_sessiontime;
128
			$acct_sessiontime = time2str($acct_sessiontime);
129
			$acct_ip = $row[framedipaddress];
130
			if ($acct_ip == '')
131
				$acct_ip = '-';
132
			$acct_upload = $row[acctinputoctets];
133
			$acct_upload_sum += $acct_upload;
134
			$acct_upload = bytes2str($acct_upload);
135
			$acct_download = $row[acctoutputoctets];
136
			$acct_download_sum += $acct_download;
137
			$acct_download = bytes2str($acct_download);
138
			$acct_server = $row[nasipaddress];
139
			if ($acct_server != ''){
140
				$acct_server = $da_name_cache[$row[nasipaddress]];
141
				if (!isset($acct_server)){
142
					$acct_server = @gethostbyaddr($row[nasipaddress]);
143
					if (!isset($da_name_cache) && $config[general_use_session] == 'yes'){
144
						$da_name_cache[$row[nasipaddress]] = $acct_server;
145
						session_register('da_name_cache');
146
					}
147
					else
148
						$da_name_cache[$row[nasipaddress]] = $acct_server;
149
				}
150
			}
151
			else
152
				$acct_server = '-';
153
			$acct_server = "$acct_server:$row[nasportid]";
154
			$acct_terminate_cause = "$row[acctterminatecause]";
155
			if ($acct_terminate_cause == '')
156
				$acct_terminate_cause = '-';
157
			if (ereg('Login-Incorrect',$acct_terminate_cause) ||
158
				ereg('Multiple-Logins', $acct_terminate_cause) || ereg('Invalid-User',$acct_terminate_cause))
159
				$tr_color='#ffe8e0';
160
			$acct_callerid = "$row[callingstationid]";
161
			if ($acct_callerid == '')
162
				$acct_callerid = '-';
163
			echo <<<EOM
164
			<tr align=center bgcolor="$tr_color">
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";
173
				if ($acct_attrs[ua][7] != '') echo "<td>$acct_server</td>\n";
174
				if ($acct_attrs[ua][8] != '') echo "<td>$acct_terminate_cause</td>\n";
175
				if ($acct_attrs[ua][9] != '') echo "<td>$acct_callerid</td>\n";
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
193
			<tr bgcolor="lightyellow">
194
			<td colspan=$colspan align="right">Total pages</td>
195
EOM;
196
				if ($acct_attrs[ua][3] != '') echo "<td align=\"center\"><b>$acct_sessiontime_sum</td>\n";
197
				if ($acct_attrs[ua][4] != '') echo "<td>&nbsp;</td>\n";
198
				if ($acct_attrs[ua][5] != '') echo "<td align=\"right\" nowrap><b>$acct_upload_sum</td>\n";
199
				if ($acct_attrs[ua][6] != '') echo "<td align=\"right\" nowrap><b>$acct_download_sum</td>\n";
200
				if ($acct_attrs[ua][7] != '') echo "<td>&nbsp;</td>\n";
201
				if ($acct_attrs[ua][8] != '') echo "<td>&nbsp;</td>\n";
202
				if ($acct_attrs[ua][9] != '') echo "<td>&nbsp;</td>\n";
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">
214
			<td><small><b>Utilisateur</td><td><small><b>d&eacute;but date</td><td><small><b>fin date</td><td><small><b>nbr./page</td><td><b>class&eacute; le</td>
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">
232
<option $selected[asc] value="asc">plus ancien en premier
233
<option $selected[desc] value="desc">plus r&eacute;cent en premier
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>