Subversion Repositories ALCASAR

Rev

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

Rev 925 Rev 1805
Line 1... Line 1...
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
 
-
 
6
if(!isset($selected['5'])) $selected['5'] = '';
-
 
7
if(!isset($selected['10'])) $selected['10'] = '';
-
 
8
if(!isset($selected['15'])) $selected['15'] = '';
-
 
9
if(!isset($selected['20'])) $selected['20'] = '';
-
 
10
if(!isset($selected['40'])) $selected['40'] = '';
-
 
11
if(!isset($selected['80'])) $selected['80'] = '';
-
 
12
if(!isset($selected['all'])) $selected['all'] = '';
-
 
13
if(!isset($selected['asc'])) $selected['asc'] = '';
-
 
14
if(!isset($selected['desc'])) $selected['desc'] = '';
-
 
15
 
5
require('/etc/freeradius-web/config.php');
16
require('/etc/freeradius-web/config.php');
6
require('../lib/functions.php');
17
require('../lib/functions.php');
7
require('../lib/sql/functions.php');
18
require('../lib/sql/functions.php');
8
require('../lib/attrshow.php');
19
require('../lib/attrshow.php');
9
if (is_file("../lib/$config[general_lib_type]/user_info.php"))
20
if (is_file("../lib/$config[general_lib_type]/user_info.php"))
Line 27... Line 38...
27
EOM;
38
EOM;
28
	exit();
39
	exit();
29
}
40
}
30
 
41
 
31
$now = time();
42
$now = time();
32
$now_str = ($now_str != '') ? "$now_str" : date($config[sql_date_format],$now + 86400);
43
$now_str = (isset($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 );
44
$prev_str = (isset($prev_str) && $prev_str != '') ? "$prev_str" : date($config['sql_date_format'], $now - 604800 );
34
$num = 0;
45
$num = 0;
35
$pagesize = ($pagesize) ? $pagesize : 10;
46
$pagesize = (isset($pagesize) && $pagesize) ? $pagesize : 10;
36
if (!is_numeric($pagesize) && $pagesize != 'all')
47
if (!is_numeric($pagesize) && $pagesize != 'all')
37
	$pagesize = 10;
48
	$pagesize = 10;
38
$limit = ($pagesize == 'all') ? '' : "$pagesize";
49
$limit = ($pagesize == 'all') ? '' : "$pagesize";
39
$selected[$pagesize] = 'selected';
50
$selected[$pagesize] = 'selected';
40
$order = ($order != '') ? $order : $config[general_accounting_info_order];
51
$order = (isset($order) && $order != '') ? $order : $config['general_accounting_info_order'];
41
if ($order != 'desc' && $order != 'asc')
52
if ($order != 'desc' && $order != 'asc')
42
	$order = 'desc';
53
	$order = 'desc';
43
$selected[$order] = 'selected';
54
$selected[$order] = 'selected';
-
 
55
 
-
 
56
$link = da_sql_pconnect($config);
44
$now_str = mysql_escape_string($now_str);
57
$now_str = da_sql_escape_string($link, $now_str);
45
$prev_str = mysql_escape_string($prev_str);
58
$prev_str = da_sql_escape_string($link, $prev_str);
46
//$now_str = da_sql_escape_string($now_str);
59
//$now_str = da_sql_escape_string($now_str);
47
//$prev_str = da_sql_escape_string($prev_str);
60
//$prev_str = da_sql_escape_string($prev_str);
48
 
61
 
49
unset($da_name_cache);
62
unset($da_name_cache);
50
if (isset($_SESSION['da_name_cache']))
63
if (isset($_SESSION['da_name_cache']))
Line 59... Line 72...
59
<link rel="stylesheet" href="/css/style.css">
72
<link rel="stylesheet" href="/css/style.css">
60
</head>
73
</head>
61
<body>
74
<body>
62
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
75
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
63
<tr><th>$l_users_managment</th></tr>
76
<tr><th>$l_users_managment</th></tr>
64
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" 
77
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1"
65
height="2"></td></tr>
78
height="2"></td></tr>
66
</TABLE>
79
</TABLE>
67
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
80
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
68
<tr bgcolor="#666666"><td>
81
<tr bgcolor="#666666"><td>
69
<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
82
<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
Line 97... Line 110...
97
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
110
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
98
	<tr bgcolor="#d0ddb0">
111
	<tr bgcolor="#d0ddb0">
99
	<td><b>#</b></td>
112
	<td><b>#</b></td>
100
<?php
113
<?php
101
for($i=1;$i<=9;$i++){
114
for($i=1;$i<=9;$i++){
102
	if (($acct_attrs['ua']["$i"] != '') && ($acct_attrs['ua']["$i"] != 'server') && ($acct_attrs['ua']["$i"] != 'callerid'))
115
	if (isset($acct_attrs['ua']["$i"]) && ($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";
116
		echo "<td><b>" . $acct_attrs['ua']["$i"] . "</b></td>\n";
104
}
117
}
105
$sql_extra_query = '';
118
$sql_extra_query = '';
106
if ($config[sql_accounting_extra_query] != '')
119
if (isset($config['sql_accounting_extra_query']) && $config['sql_accounting_extra_query'] != '')
107
	$sql_extra_query = xlat($config[sql_accounting_extra_query],$login,$config);
120
	$sql_extra_query = xlat($config['sql_accounting_extra_query'],$login,$config);
108
?>
121
?>
109
	</tr>
122
	</tr>
110
 
123
 
111
<?php
124
<?php
112
$link = @da_sql_pconnect($config);
-
 
113
if ($link){
125
if ($link){
114
	$search = @da_sql_query($link,$config,
126
	$search = da_sql_query($link,$config,
115
	"SELECT " . da_sql_limit($limit,0,$config) . " * FROM $config[sql_accounting_table]
127
	"SELECT " . da_sql_limit($limit,0,$config) . " * FROM $config[sql_accounting_table]
116
	WHERE username = '$login' AND acctstarttime <= '$now_str'
128
	WHERE username = '$login' AND acctstarttime <= '$now_str'
117
	AND acctstarttime >= '$prev_str' $sql_extra_query " . da_sql_limit($limit,1,$config) .
129
	AND acctstarttime >= '$prev_str' $sql_extra_query " . da_sql_limit($limit,1,$config) .
118
	" ORDER BY acctstarttime $order " . da_sql_limit($limit,2,$config). " ;");
130
	" ORDER BY acctstarttime $order " . da_sql_limit($limit,2,$config). " ;");
119
	if ($search){
131
	if ($search){
-
 
132
		$acct_sessiontime_sum = 0;
-
 
133
		$acct_upload_sum = 0;
-
 
134
		$acct_download_sum = 0;
120
		while( $row = @da_sql_fetch_array($search,$config) ){
135
		while( $row = da_sql_fetch_array($search,$config) ){
121
			$num++;
136
			$num++;
122
			$acct_type = "$row[framedprotocol]/$row[nasporttype]";
137
			$acct_type = "$row[framedprotocol]/$row[nasporttype]";
123
			if ($acct_type == '')
138
			if ($acct_type == '')
124
				$acct_type = '-';
139
				$acct_type = '-';
125
			$acct_logedin = $row[acctstarttime];
140
			$acct_logedin = $row['acctstarttime'];
126
			$acct_sessiontime = $row[acctsessiontime];
141
			$acct_sessiontime = $row['acctsessiontime'];
127
			$acct_sessiontime_sum += $acct_sessiontime;
142
			$acct_sessiontime_sum += $acct_sessiontime;
128
			$acct_sessiontime = time2str($acct_sessiontime);
143
			$acct_sessiontime = time2str($acct_sessiontime);
129
			$acct_ip = $row[framedipaddress];
144
			$acct_ip = $row['framedipaddress'];
130
			if ($acct_ip == '')
145
			if ($acct_ip == '')
131
				$acct_ip = '-';
146
				$acct_ip = '-';
132
			$acct_upload = $row[acctinputoctets];
147
			$acct_upload = $row['acctinputoctets'];
133
			$acct_upload_sum += $acct_upload;
148
			$acct_upload_sum += $acct_upload;
134
			$acct_upload = bytes2str($acct_upload);
149
			$acct_upload = bytes2str($acct_upload);
135
			$acct_download = $row[acctoutputoctets];
150
			$acct_download = $row['acctoutputoctets'];
136
			$acct_download_sum += $acct_download;
151
			$acct_download_sum += $acct_download;
137
			$acct_download = bytes2str($acct_download);
152
			$acct_download = bytes2str($acct_download);
138
			$acct_server = $row[nasipaddress];
153
			$acct_server = $row['nasipaddress'];
139
			if ($acct_server != ''){
154
			if ($acct_server != ''){
140
				$acct_server = $da_name_cache[$row[nasipaddress]];
155
				$acct_server = (isset($da_name_cache)) ? $da_name_cache[$row['nasipaddress']] : null;
141
				if (!isset($acct_server)){
156
				if (!isset($acct_server)){
142
					$acct_server = @gethostbyaddr($row[nasipaddress]);
157
					$acct_server = gethostbyaddr($row['nasipaddress']);
143
					if (!isset($da_name_cache) && $config[general_use_session] == 'yes'){
158
					if (!isset($da_name_cache) && $config['general_use_session'] == 'yes'){
144
						$da_name_cache[$row[nasipaddress]] = $acct_server;
159
						$da_name_cache[$row['nasipaddress']] = $acct_server;
145
						session_register('da_name_cache');
160
						session_register('da_name_cache');
146
					}
161
					}
147
					else
162
					else
148
						$da_name_cache[$row[nasipaddress]] = $acct_server;
163
						$da_name_cache[$row['nasipaddress']] = $acct_server;
149
				}
164
				}
150
			}
165
			}
151
			else
166
			else
152
				$acct_server = '-';
167
				$acct_server = '-';
153
			$acct_server = "$acct_server:$row[nasportid]";
168
			$acct_server = "$acct_server:$row[nasportid]";
154
			$acct_terminate_cause = "$row[acctterminatecause]";
169
			$acct_terminate_cause = "$row[acctterminatecause]";
155
			if ($acct_terminate_cause == '')
170
			if ($acct_terminate_cause == '')
156
				$acct_terminate_cause = '-';
171
				$acct_terminate_cause = '-';
157
			if (ereg('Login-Incorrect',$acct_terminate_cause) ||
172
			if (preg_match('/Login-Incorrect/',$acct_terminate_cause) ||
158
				ereg('Multiple-Logins', $acct_terminate_cause) || ereg('Invalid-User',$acct_terminate_cause))
173
				preg_match('/Multiple-Logins/', $acct_terminate_cause) || preg_match('/Invalid-User/',$acct_terminate_cause))
159
			$acct_callerid = "$row[callingstationid]";
174
			$acct_callerid = "$row[callingstationid]";
160
			if ($acct_callerid == '')
175
			if (!isset($acct_callerid) || $acct_callerid == '')
161
				$acct_callerid = '-';
176
				$acct_callerid = '-';
162
			echo <<<EOM
177
			echo <<<EOM
163
			<tr align=center>
178
			<tr align=center>
164
				<td>$num</td>
179
				<td>$num</td>
165
EOM;
180
EOM;
166
				if ($acct_attrs[ua][1] != '') echo "<td>$acct_type</td>\n";
181
				if (isset($acct_attrs['ua'][1]) && $acct_attrs['ua'][1] != '') echo "<td>$acct_type</td>\n";
167
				if ($acct_attrs[ua][2] != '') echo "<td>$acct_logedin</td>\n";
182
				if (isset($acct_attrs['ua'][2]) && $acct_attrs['ua'][2] != '') echo "<td>$acct_logedin</td>\n";
168
				if ($acct_attrs[ua][3] != '') echo "<td>$acct_sessiontime</td>\n";
183
				if (isset($acct_attrs['ua'][3]) && $acct_attrs['ua'][3] != '') echo "<td>$acct_sessiontime</td>\n";
169
				if ($acct_attrs[ua][4] != '') echo "<td>$acct_ip</td>\n";
184
				if (isset($acct_attrs['ua'][4]) && $acct_attrs['ua'][4] != '') echo "<td>$acct_ip</td>\n";
170
				if ($acct_attrs[ua][5] != '') echo "<td>$acct_upload</td>\n";
185
				if (isset($acct_attrs['ua'][5]) && $acct_attrs['ua'][5] != '') echo "<td>$acct_upload</td>\n";
171
				if ($acct_attrs[ua][6] != '') echo "<td>$acct_download</td>\n";
186
				if (isset($acct_attrs['ua'][6]) && $acct_attrs['ua'][6] != '') echo "<td>$acct_download</td>\n";
172
//				if ($acct_attrs[ua][7] != '') echo "<td>$acct_server</td>\n";
187
//				if (isset($acct_attrs['ua'][7]) && $acct_attrs[ua][7] != '') echo "<td>$acct_server</td>\n";
173
				if ($acct_attrs[ua][8] != '') echo "<td>$acct_terminate_cause</td>\n";
188
				if (isset($acct_attrs['ua'][8]) && $acct_attrs['ua'][8] != '') echo "<td>$acct_terminate_cause</td>\n";
174
//				if ($acct_attrs[ua][9] != '') echo "<td>$acct_callerid</td>\n";
189
//				if (isset($acct_attrs['ua'][9]) && $acct_attrs[ua][9] != '') echo "<td>$acct_callerid</td>\n";
175
			echo "</tr>\n";
190
			echo "</tr>\n";
176
		}
191
		}
177
		$acct_sessiontime_sum = time2str($acct_sessiontime_sum);
192
		$acct_sessiontime_sum = (isset($acct_sessiontime_sum)) ? time2str($acct_sessiontime_sum) : "0 seconds";
178
		$acct_upload_sum = bytes2str($acct_upload_sum);
193
		$acct_upload_sum = (isset($acct_upload_sum)) ? bytes2str($acct_upload_sum) : "0.00 KBs";
179
		$acct_download_sum = bytes2str($acct_download_sum);
194
		$acct_download_sum = (isset($acct_download_sum)) ? bytes2str($acct_download_sum) : "0.00 KBs";
180
	}
195
	}
181
	else
196
	else
182
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
197
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
183
}
198
}
184
else
199
else
185
	echo "<b>Could not connect to SQL database</b><br>\n";
200
	echo "<b>Could not connect to SQL database</b><br>\n";
186
$colspan = 3;
201
$colspan = 3;
187
if ($acct_attrs[ua][1] == '')
202
if (!isset($acct_attrs['ua'][1]) || $acct_attrs['ua'][1] == ''){
188
	$colspan--;
203
	$colspan--;}
189
if ($acct_attrs[ua][2] == '')
204
if (!isset($acct_attrs['ua'][2]) || $acct_attrs['ua'][2] == ''){
190
	$colspan--;
205
	$colspan--;}
191
echo <<<EOM
206
echo <<<EOM
192
			<tr bgcolor="lightyellow" align="center">
207
			<tr bgcolor="lightyellow" align="center">
193
			<td colspan=$colspan><b>Total</b></td>
208
			<td colspan=$colspan><b>Total</b></td>
194
EOM;
209
EOM;
195
				if ($acct_attrs[ua][3] != '') echo "<td><b>$acct_sessiontime_sum</b></td>\n";
210
				if (isset($acct_attrs['ua'][3]) && $acct_attrs['ua'][3] != '') echo "<td><b>$acct_sessiontime_sum</b></td>\n";
196
				if ($acct_attrs[ua][4] != '') echo "<td>&nbsp;</td>\n";
211
				if (isset($acct_attrs['ua'][4]) && $acct_attrs['ua'][4] != '') echo "<td>&nbsp;</td>\n";
197
				if ($acct_attrs[ua][5] != '') echo "<td><b>$acct_upload_sum</b></td>\n";
212
				if (isset($acct_attrs['ua'][5]) && $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";
213
				if (isset($acct_attrs['ua'][6]) && $acct_attrs['ua'][6] != '') echo "<td><b>$acct_download_sum</b></td>\n";
199
//				if ($acct_attrs[ua][7] != '') echo "<td>&nbsp;</td>\n";
214
//				if (isset($acct_attrs['ua'][7]) && $acct_attrs['ua'][7] != '') echo "<td>&nbsp;</td>\n";
200
				if ($acct_attrs[ua][8] != '') echo "<td>&nbsp;</td>\n";
215
				if (isset($acct_attrs['ua'][8]) && $acct_attrs['ua'][8] != '') echo "<td>&nbsp;</td>\n";
201
//				if ($acct_attrs[ua][9] != '') echo "<td>&nbsp;</td>\n";
216
//				if (isset($acct_attrs['ua'][9]) && $acct_attrs['ua'][9] != '') echo "<td>&nbsp;</td>\n";
202
?>
217
?>
203
				</tr>
218
				</tr>
204
	</table>
219
	</table>
205
<tr><td>
220
<tr><td>
206
<hr>
221
<hr>