Subversion Repositories ALCASAR

Rev

Rev 324 | Rev 910 | 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
?>
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';
820 richard 40
$now_str = mysql_escape_string($now_str);
41
$prev_str = mysql_escape_string($prev_str);
42
//$now_str = da_sql_escape_string($now_str);
43
//$prev_str = da_sql_escape_string($prev_str);
324 richard 44
 
45
unset($da_name_cache);
46
if (isset($_SESSION['da_name_cache']))
47
	$da_name_cache = $_SESSION['da_name_cache'];
48
 
49
 
50
echo <<<EOM
51
<head>
52
<title>Analyse pour $login</title>
53
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
54
<link rel="stylesheet" href="/css/style.css">
55
</head>
56
<body>
57
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
58
<tr><th>Statistique des connexions</th></tr>
59
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" 
60
height="2"></td></tr>
61
</TABLE>
62
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
63
<tr bgcolor="#666666"><td>
64
<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
65
<tr><td valign="middle" align="left">
66
<center>
67
<table border=0 width=550 cellpadding=0 cellspacing=0>
68
<tr valign=top>
69
<!--<td align=center><img src="images/title2.gif"></td>-->
70
</tr>
71
</table>
72
<table border=0 width=400 cellpadding=0 cellspacing=2>
73
EOM;
74
 
75
include("../html/user_toolbar.html.php");
76
 
77
print <<<EOM
78
</table>
79
<br>
80
<table border=0 width=840 cellpadding=1 cellspacing=1>
81
<tr valign=top>
82
<td width=65%></td>
83
<td bgcolor="black" width=35%>
84
	<table border=0 width=100% cellpadding=2 cellspacing=0>
85
	<tr bgcolor="#907030" align=right valign=top><th>
86
	<font color="white">Analyse pour $login</font>&nbsp;
87
	</th></tr>
88
	</table>
89
</td></tr>
90
<tr bgcolor="black" valign=top><td colspan=2>
91
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
92
	<tr><td>
93
Dates du <b>$prev_str</b> au <b>$now_str</b>
94
EOM;
95
?>
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">
100
	<th>#</th>
101
<?php
102
for($i=1;$i<=9;$i++){
103
	if ($acct_attrs['ua']["$i"] != '')
104
		echo "<th>" . $acct_attrs['ua']["$i"] . "</th>\n";
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
			$tr_color='white';
123
			$num++;
124
			$acct_type = "$row[framedprotocol]/$row[nasporttype]";
125
			if ($acct_type == '')
126
				$acct_type = '-';
127
			$acct_logedin = $row[acctstarttime];
128
			$acct_sessiontime = $row[acctsessiontime];
129
			$acct_sessiontime_sum += $acct_sessiontime;
130
			$acct_sessiontime = time2str($acct_sessiontime);
131
			$acct_ip = $row[framedipaddress];
132
			if ($acct_ip == '')
133
				$acct_ip = '-';
134
			$acct_upload = $row[acctinputoctets];
135
			$acct_upload_sum += $acct_upload;
136
			$acct_upload = bytes2str($acct_upload);
137
			$acct_download = $row[acctoutputoctets];
138
			$acct_download_sum += $acct_download;
139
			$acct_download = bytes2str($acct_download);
140
			$acct_server = $row[nasipaddress];
141
			if ($acct_server != ''){
142
				$acct_server = $da_name_cache[$row[nasipaddress]];
143
				if (!isset($acct_server)){
144
					$acct_server = @gethostbyaddr($row[nasipaddress]);
145
					if (!isset($da_name_cache) && $config[general_use_session] == 'yes'){
146
						$da_name_cache[$row[nasipaddress]] = $acct_server;
147
						session_register('da_name_cache');
148
					}
149
					else
150
						$da_name_cache[$row[nasipaddress]] = $acct_server;
151
				}
152
			}
153
			else
154
				$acct_server = '-';
155
			$acct_server = "$acct_server:$row[nasportid]";
156
			$acct_terminate_cause = "$row[acctterminatecause]";
157
			if ($acct_terminate_cause == '')
158
				$acct_terminate_cause = '-';
159
			if (ereg('Login-Incorrect',$acct_terminate_cause) ||
160
				ereg('Multiple-Logins', $acct_terminate_cause) || ereg('Invalid-User',$acct_terminate_cause))
161
				$tr_color='#ffe8e0';
162
			$acct_callerid = "$row[callingstationid]";
163
			if ($acct_callerid == '')
164
				$acct_callerid = '-';
165
			echo <<<EOM
166
			<tr align=center bgcolor="$tr_color">
167
				<td>$num</td>
168
EOM;
169
				if ($acct_attrs[ua][1] != '') echo "<td>$acct_type</td>\n";
170
				if ($acct_attrs[ua][2] != '') echo "<td>$acct_logedin</td>\n";
171
				if ($acct_attrs[ua][3] != '') echo "<td>$acct_sessiontime</td>\n";
172
				if ($acct_attrs[ua][4] != '') echo "<td>$acct_ip</td>\n";
173
				if ($acct_attrs[ua][5] != '') echo "<td>$acct_upload</td>\n";
174
				if ($acct_attrs[ua][6] != '') echo "<td>$acct_download</td>\n";
175
				if ($acct_attrs[ua][7] != '') echo "<td>$acct_server</td>\n";
176
				if ($acct_attrs[ua][8] != '') echo "<td>$acct_terminate_cause</td>\n";
177
				if ($acct_attrs[ua][9] != '') echo "<td>$acct_callerid</td>\n";
178
			echo "</tr>\n";
179
		}
180
		$acct_sessiontime_sum = time2str($acct_sessiontime_sum);
181
		$acct_upload_sum = bytes2str($acct_upload_sum);
182
		$acct_download_sum = bytes2str($acct_download_sum);
183
	}
184
	else
185
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
186
}
187
else
188
	echo "<b>Could not connect to SQL database</b><br>\n";
189
$colspan = 3;
190
if ($acct_attrs[ua][1] == '')
191
	$colspan--;
192
if ($acct_attrs[ua][2] == '')
193
	$colspan--;
194
echo <<<EOM
195
			<tr bgcolor="lightyellow">
196
			<td colspan=$colspan align="right">Total pages</td>
197
EOM;
198
				if ($acct_attrs[ua][3] != '') echo "<td align=\"center\"><b>$acct_sessiontime_sum</td>\n";
199
				if ($acct_attrs[ua][4] != '') echo "<td>&nbsp;</td>\n";
200
				if ($acct_attrs[ua][5] != '') echo "<td align=\"right\" nowrap><b>$acct_upload_sum</td>\n";
201
				if ($acct_attrs[ua][6] != '') echo "<td align=\"right\" nowrap><b>$acct_download_sum</td>\n";
202
				if ($acct_attrs[ua][7] != '') echo "<td>&nbsp;</td>\n";
203
				if ($acct_attrs[ua][8] != '') echo "<td>&nbsp;</td>\n";
204
				if ($acct_attrs[ua][9] != '') echo "<td>&nbsp;</td>\n";
205
?>
206
				</tr>
207
	</table>
208
<tr><td>
209
<hr>
210
<tr><td align="center">
211
	<form action="user_accounting.php" method="get" name="master">
212
	<table border=0>
213
		<tr><td colspan=6></td>
214
		</tr>
215
		<tr valign="bottom">
216
			<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>
217
	<tr valign="middle"><td>
218
<?php
219
	echo <<<EOM
220
<input type="text" name="login" size="11" value="$login"></td>
221
<td><input type="text" name="prev_str" size="11" value="$prev_str"></td>
222
<td><input type="text" name="now_str" size="11" value="$now_str"></td>
223
<td><select name="pagesize">
224
<option $selected[5] value="5" >05
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><select name="order">
234
<option $selected[asc] value="asc">plus ancien en premier
235
<option $selected[desc] value="desc">plus r&eacute;cent en premier
236
</select>
237
</td>
238
EOM;
239
?>
240
 
241
<td><input type="submit" class=button value="show"></td></tr>
242
</table></td></tr></form>
243
</table>
244
</tr>
245
</table>
246
</TD></TR>
247
</TABLE>
248
</td></tr>
249
</TABLE>
250
</body>
251
</html>