Subversion Repositories ALCASAR

Rev

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

Rev 324 Rev 907
1
<?php
1
<?php
-
 
2
//gestion de la langue
-
 
3
$origine='user_new';
-
 
4
if (is_file("../lib/langues.php"))
-
 
5
	include("../lib/langues.php");
2
require('/etc/freeradius-web/config.php');
6
require('/etc/freeradius-web/config.php');
3
?>
7
?>
4
<html>
8
<html>
5
<head>
9
<head>
6
<?php
10
<?php
7
require('../lib/functions.php');
11
require('../lib/functions.php');
8
require('../lib/defaults.php');
12
require('../lib/defaults.php');
9
$date = strftime('%A, %e %B %Y, %T %Z');
13
$date = strftime('%A, %e %B %Y, %T %Z');
10
 
14
 
11
if (is_file("../lib/$config[general_lib_type]/user_info.php")){
15
if (is_file("../lib/$config[general_lib_type]/user_info.php")){
12
	include("../lib/$config[general_lib_type]/user_info.php");
16
	include("../lib/$config[general_lib_type]/user_info.php");
13
	if ($user_exists == 'no'){
17
	if ($user_exists == 'no'){
14
		echo <<<EOM
18
		echo <<<EOM
15
<title>Page d'information d'utilisateur</title>
19
<title>User information page</title>
16
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
20
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
17
<link rel="stylesheet" href="/css/style.css">
21
<link rel="stylesheet" href="/css/style.css">
18
</head>
22
</head>
19
<body>
23
<body>
20
<center>
24
<center>
21
<form action="user_admin.php" method=get>
25
<form action="user_admin.php" method=get>
22
<b>User Name&nbsp;&nbsp;</b>
26
<b>User Name&nbsp;&nbsp;</b>
23
<input type="text" size=10 name="login" value="$login">
27
<input type="text" size=10 name="login" value="$login">
24
<b>&nbsp;&nbsp;does not exist</b><br>
28
<b>&nbsp;&nbsp;does not exist</b><br>
25
<input type=submit class=button value="Show User">
29
<input type=submit class=button value="Show User">
26
</body>
30
</body>
27
</html>
31
</html>
28
EOM;
32
EOM;
29
		exit();
33
		exit();
30
	}
34
	}
31
}
35
}
32
 
36
 
33
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
37
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
34
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
38
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
35
else{
39
else{
36
	echo <<<EOM
40
	echo <<<EOM
37
<title>Page d'information d'utilisateur</title>
41
<title>User information page</title>
38
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
42
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
39
<link rel="stylesheet" href="style.css">
43
<link rel="stylesheet" href="style.css">
40
</head>
44
</head>
41
<body>
45
<body>
42
<center>
46
<center>
43
<b>Could not include SQL library functions. Aborting</b>
47
<b>Could not include SQL library functions. Aborting</b>
44
</body>
48
</body>
45
</html>
49
</html>
46
EOM;
50
EOM;
47
	exit();
51
	exit();
48
}
52
}
49
 
53
 
50
$monthly_limit = ($item_vals['Max-Monthly-Session'][0] != '') ? $item_vals['Max-Monthly-Session'][0] : $default_vals['Max-Monthly-Session'][0];
54
$monthly_limit = ($item_vals['Max-Monthly-Session'][0] != '') ? $item_vals['Max-Monthly-Session'][0] : $default_vals['Max-Monthly-Session'][0];
51
$monthly_limit = ($monthly_limit) ? $monthly_limit : $config[counter_default_monthly];
55
$monthly_limit = ($monthly_limit) ? $monthly_limit : $config[counter_default_monthly];
52
$weekly_limit = ($item_vals['Max-Weekly-Session'][0] != '') ? $item_vals['Max-Weekly-Session'][0] : $default_vals['Max-Weekly-Session'][0];
56
$weekly_limit = ($item_vals['Max-Weekly-Session'][0] != '') ? $item_vals['Max-Weekly-Session'][0] : $default_vals['Max-Weekly-Session'][0];
53
$weekly_limit = ($weekly_limit) ? $weekly_limit : $config[counter_default_weekly];
57
$weekly_limit = ($weekly_limit) ? $weekly_limit : $config[counter_default_weekly];
54
$daily_limit = ($item_vals['Max-Daily-Session'][0] != '') ? $item_vals['Max-Daily-Session'][0] : $default_vals['Max-Daily-Session'][0];
58
$daily_limit = ($item_vals['Max-Daily-Session'][0] != '') ? $item_vals['Max-Daily-Session'][0] : $default_vals['Max-Daily-Session'][0];
55
$daily_limit = ($daily_limit) ? $daily_limit : $config[counter_default_daily];
59
$daily_limit = ($daily_limit) ? $daily_limit : $config[counter_default_daily];
56
$session_limit = ($item_vals['Session-Timeout'][0] != '') ? $item_vals['Session-Timeout'][0] : $default_vals['Session-Timeout'][0];
60
$session_limit = ($item_vals['Session-Timeout'][0] != '') ? $item_vals['Session-Timeout'][0] : $default_vals['Session-Timeout'][0];
57
$session_limit = ($session_limit) ? $session_limit : 'none';
61
$session_limit = ($session_limit) ? $session_limit : 'none';
-
 
62
$total_limit = ($item_vals['Max-All-Session'][0] != '') ? $item_vals['Max-All-Session'][0] : $default_vals['Max-All-Session'][0];
-
 
63
$total_limit = ($total_limit) ? $total_limit : 'none';
58
$remaining = 'unlimited time';
64
$remaining = 'unlimited time';
59
$log_color = 'green';
65
$log_color = 'green';
60
 
66
 
61
$now = time();
67
$now = time();
62
$week = $now - 604800;
68
$week = $now - 604800;
63
$now_str = date("$config[sql_date_format]",$now + 86400);
69
$now_str = date("$config[sql_date_format]",$now + 86400);
64
$week_str = date("$config[sql_date_format]",$week);
70
$week_str = date("$config[sql_date_format]",$week);
65
$day = date('w');
71
$day = date('w');
66
$week_start = date($config[sql_date_format],$now - ($day)*86400);
72
$week_start = date($config[sql_date_format],$now - ($day)*86400);
67
$month_start = date($config[sql_date_format],$now - date('j')*86400);
73
$month_start = date($config[sql_date_format],$now - date('j')*86400);
68
$today = $day;
74
$today = $day;
69
$now_tmp = $now;
75
$now_tmp = $now;
70
for ($i = $day; $i >-1; $i--){
76
for ($i = $day; $i >-1; $i--){
71
	$days[$i] = date($config[sql_date_format],$now_tmp);
77
	$days[$i] = date($config[sql_date_format],$now_tmp);
72
	$now_tmp -= 86400;
78
	$now_tmp -= 86400;
73
}
79
}
74
$day++;
80
$day++;
75
//$now -= ($day * 86400);
81
//$now -= ($day * 86400);
76
$now -= 604800;
82
$now -= 604800;
77
$now += 86400;
83
$now += 86400;
78
for ($i = $day; $i <= 6; $i++){
84
for ($i = $day; $i <= 6; $i++){
79
	$days[$i] = date($config[sql_date_format],$now);
85
	$days[$i] = date($config[sql_date_format],$now);
80
//	$now -= 86400;
86
//	$now -= 86400;
81
	$now += 86400;
87
	$now += 86400;
82
}
88
}
83
 
89
 
84
$daily_used = $weekly_used = $monthly_used = $lastlog_session_time = '-';
90
$daily_used = $weekly_used = $monthly_used = $lastlog_session_time = '-';
85
$extra_msg = '';
91
$extra_msg = '';
86
$used = array('-','-','-','-','-','-','-');
92
$used = array('-','-','-','-','-','-','-');
87
 
93
 
88
$link = @da_sql_pconnect($config);
94
$link = @da_sql_pconnect($config);
89
if ($link){
95
if ($link){
90
	$search = @da_sql_query($link,$config,
96
	$search = @da_sql_query($link,$config,
91
	"SELECT sum(acctsessiontime) AS sum_sess_time,
97
	"SELECT sum(acctsessiontime) AS sum_sess_time,
92
	sum(acctinputoctets) AS sum_in_octets,
98
	sum(acctinputoctets) AS sum_in_octets,
93
	sum(acctoutputoctets) AS sum_out_octets,
99
	sum(acctoutputoctets) AS sum_out_octets,
94
	avg(acctsessiontime) AS avg_sess_time,
100
	avg(acctsessiontime) AS avg_sess_time,
95
	avg(acctinputoctets) AS avg_in_octets,
101
	avg(acctinputoctets) AS avg_in_octets,
96
	avg(acctoutputoctets) AS avg_out_octets,
102
	avg(acctoutputoctets) AS avg_out_octets,
97
	COUNT(*) as counter FROM
103
	COUNT(*) as counter FROM
98
	$config[sql_accounting_table] WHERE username = '$login'
104
	$config[sql_accounting_table] WHERE username = '$login'
99
	AND acctstarttime >= '$week_str' AND acctstarttime <= '$now_str';");
105
	AND acctstarttime >= '$week_str' AND acctstarttime <= '$now_str';");
100
	if ($search){
106
	if ($search){
101
		$row = @da_sql_fetch_array($search,$config);
107
		$row = @da_sql_fetch_array($search,$config);
102
		$tot_time = time2str($row[sum_sess_time]);
108
		$tot_time = time2str($row[sum_sess_time]);
103
		$tot_input = bytes2str($row[sum_in_octets]);
109
		$tot_input = bytes2str($row[sum_in_octets]);
104
		$tot_output = bytes2str($row[sum_out_octets]);
110
		$tot_output = bytes2str($row[sum_out_octets]);
105
		$avg_time = time2str($row[avg_sess_time]);
111
		$avg_time = time2str($row[avg_sess_time]);
106
		$avg_input = bytes2str($row[avg_in_octets]);
112
		$avg_input = bytes2str($row[avg_in_octets]);
107
		$avg_output = bytes2str($row[avg_out_octets]);
113
		$avg_output = bytes2str($row[avg_out_octets]);
108
		$tot_conns = $row[counter];
114
		$tot_conns = $row[counter];
109
	}
115
	}
110
	else
116
	else
111
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
117
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
112
	$search = @da_sql_query($link,$config,
118
	$search = @da_sql_query($link,$config,
113
	"SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE username = '$login'
119
	"SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE username = '$login'
114
	AND acctstarttime >= '$week_start' AND acctstarttime <= '$now_str';");
120
	AND acctstarttime >= '$week_start' AND acctstarttime <= '$now_str';");
115
	if ($search){
121
	if ($search){
116
		$row = @da_sql_fetch_array($search,$config);
122
		$row = @da_sql_fetch_array($search,$config);
117
		$weekly_used = $row[sum_sess_time];
123
		$weekly_used = $row[sum_sess_time];
118
	}
124
	}
119
	else
125
	else
120
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
126
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
121
	if ($monthly_limit != 'none' || $config[counter_monthly_calculate_usage] == 'true'){
127
	if ($monthly_limit != 'none' || $config[counter_monthly_calculate_usage] == 'true'){
122
		$search = @da_sql_query($link,$config,
128
		$search = @da_sql_query($link,$config,
123
		"SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE username = '$login'
129
		"SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE username = '$login'
124
		AND acctstarttime >= '$month_start' AND acctstarttime <= '$now_str';");
130
		AND acctstarttime >= '$month_start' AND acctstarttime <= '$now_str';");
125
		if ($search){
131
		if ($search){
126
			$row = @da_sql_fetch_array($search,$config);
132
			$row = @da_sql_fetch_array($search,$config);
127
			$monthly_used = $row[sum_sess_time];
133
			$monthly_used = $row[sum_sess_time];
128
		}
134
		}
129
		else
135
		else
130
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
136
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
131
	}
137
	}
132
	$search = @da_sql_query($link,$config,
138
	$search = @da_sql_query($link,$config,
133
	"SELECT COUNT(*) AS counter FROM $config[sql_accounting_table] WHERE username = '$login'
139
	"SELECT COUNT(*) AS counter FROM $config[sql_accounting_table] WHERE username = '$login'
134
	AND acctstoptime >= '$week_str' AND acctstoptime <= '$now_str'
140
	AND acctstoptime >= '$week_str' AND acctstoptime <= '$now_str'
135
	AND (acctterminatecause LIKE 'Login-Incorrect%' OR
141
	AND (acctterminatecause LIKE 'Login-Incorrect%' OR
136
	acctterminatecause LIKE 'Invalid-User%' OR
142
	acctterminatecause LIKE 'Invalid-User%' OR
137
	acctterminatecause LIKE 'Multiple-Logins%');");
143
	acctterminatecause LIKE 'Multiple-Logins%');");
138
	if ($search){
144
	if ($search){
139
		$row = @da_sql_fetch_array($search,$config);
145
		$row = @da_sql_fetch_array($search,$config);
140
		$tot_badlogins = $row[counter];
146
		$tot_badlogins = $row[counter];
141
	}
147
	}
142
	else
148
	else
143
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
149
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
144
	for($i = 0; $i <=6; $i++){
150
	for($i = 0; $i <=6; $i++){
145
		if ($days[$i] == '')
151
		if ($days[$i] == '')
146
			continue;
152
			continue;
147
		$search = @da_sql_query($link,$config,
153
		$search = @da_sql_query($link,$config,
148
		"SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE
154
		"SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE
149
		username = '$login' AND acctstoptime >= '$days[$i] 00:00:00'
155
		username = '$login' AND acctstoptime >= '$days[$i] 00:00:00'
150
		AND acctstoptime <= '$days[$i] 23:59:59';");
156
		AND acctstoptime <= '$days[$i] 23:59:59';");
151
		if ($search){
157
		if ($search){
152
			$row = @da_sql_fetch_array($search,$config);
158
			$row = @da_sql_fetch_array($search,$config);
153
			$used[$i] = $row[sum_sess_time];
159
			$used[$i] = $row[sum_sess_time];
154
			if ($daily_limit != 'none' && $used[$i] > $daily_limit)
160
			if ($daily_limit != 'none' && $used[$i] > $daily_limit)
155
				$used[$i] = "<font color=red>" . time2str($used[$i]) . "</font>";
161
				$used[$i] = "<font color=red>" . time2str($used[$i]) . "</font>";
156
			else
162
			else
157
				$used[$i] = time2str($used[$i]);
163
				$used[$i] = time2str($used[$i]);
158
			if ($today == $i){
164
			if ($today == $i){
159
				$daily_used = $row[sum_sess_time];
165
				$daily_used = $row[sum_sess_time];
160
				if ($daily_limit != 'none'){
166
				if ($daily_limit != 'none'){
161
					$remaining = $daily_limit - $daily_used;
167
					$remaining = $daily_limit - $daily_used;
162
					if ($remaining <=0)
168
					if ($remaining <=0)
163
						$remaining = 0;
169
						$remaining = 0;
164
					$log_color = ($remaining) ? 'green' : 'red';
170
					$log_color = ($remaining) ? 'green' : 'red';
165
					if (!$remaining)
171
					if (!$remaining)
166
						$extra_msg = '(Out of daily quota)';
172
						$extra_msg = '(Out of daily quota)';
167
				}
173
				}
168
				$daily_used = time2str($daily_used);
174
				$daily_used = time2str($daily_used);
169
				if ($daily_limit != 'none' && !$remaining)
175
				if ($daily_limit != 'none' && !$remaining)
170
					$daily_used = "<font color=red>$daily_used</font>";
176
					$daily_used = "<font color=red>$daily_used</font>";
171
			}
177
			}
172
		}
178
		}
173
		else
179
		else
174
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
180
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
175
	}
181
	}
176
	if ($weekly_limit != 'none'){
182
	if ($weekly_limit != 'none'){
177
		$tmp = $weekly_limit - $weekly_used;
183
		$tmp = $weekly_limit - $weekly_used;
178
		if ($tmp <=0){
184
		if ($tmp <=0){
179
			$tmp = 0;
185
			$tmp = 0;
180
			$extra_msg .= '(Out of weekly quota)';
186
			$extra_msg .= '(Out of weekly quota)';
181
		}
187
		}
182
		if (!is_numeric($remaining))
188
		if (!is_numeric($remaining))
183
			$remaining = $tmp;
189
			$remaining = $tmp;
184
		if ($remaining > $tmp)
190
		if ($remaining > $tmp)
185
			$remaining = $tmp;
191
			$remaining = $tmp;
186
		$log_color = ($remaining) ? 'green' : 'red';
192
		$log_color = ($remaining) ? 'green' : 'red';
187
	}
193
	}
188
	$weekly_used = time2str($weekly_used);
194
	$weekly_used = time2str($weekly_used);
189
	if ($weekly_limit != 'none' && !$tmp)
195
	if ($weekly_limit != 'none' && !$tmp)
190
		$weekly_used = "<font color=red>$weekly_used</font>";
196
		$weekly_used = "<font color=red>$weekly_used</font>";
191
 
197
 
192
	if ($monthly_limit != 'none'){
198
	if ($monthly_limit != 'none'){
193
		$tmp = $monthly_limit - $monthly_used;
199
		$tmp = $monthly_limit - $monthly_used;
194
		if ($tmp <=0){
200
		if ($tmp <=0){
195
			$tmp = 0;
201
			$tmp = 0;
196
			$extra_msg .= '(Out of monthly quota)';
202
			$extra_msg .= '(Out of monthly quota)';
197
		}
203
		}
198
		if (!is_numeric($remaining))
204
		if (!is_numeric($remaining))
199
			$remaining = $tmp;
205
			$remaining = $tmp;
200
		if ($remaining > $tmp)
206
		if ($remaining > $tmp)
201
			$remaining = $tmp;
207
			$remaining = $tmp;
202
		$log_color = ($remaining) ? 'green' : 'red';
208
		$log_color = ($remaining) ? 'green' : 'red';
203
	}
209
	}
204
	if ($monthly_limit != 'none' || $config[counter_monthly_calculate_usage] == 'true'){
210
	if ($monthly_limit != 'none' || $config[counter_monthly_calculate_usage] == 'true'){
205
		$monthly_used = time2str($monthly_used);
211
		$monthly_used = time2str($monthly_used);
206
		if ($monthly_limit != 'none' && !$tmp)
212
		if ($monthly_limit != 'none' && !$tmp)
207
			$monthly_used = "<font color=red>$monthly_used</font>";
213
			$monthly_used = "<font color=red>$monthly_used</font>";
208
	}
214
	}
209
	if ($session_limit != 'none'){
215
	if ($session_limit != 'none'){
210
		if (!is_numeric($remaining))
216
		if (!is_numeric($remaining))
211
			$remaining = $session_limit;
217
			$remaining = $session_limit;
212
		if ($remaining > $session_limit)
218
		if ($remaining > $session_limit)
213
			$remaining = $session_limit;
219
			$remaining = $session_limit;
214
	}
220
	}
215
 
221
 
216
	$search = @da_sql_query($link,$config,
222
	$search = @da_sql_query($link,$config,
217
	"SELECT " . da_sql_limit(1,0,$config) . " * FROM $config[sql_accounting_table]
223
	"SELECT " . da_sql_limit(1,0,$config) . " * FROM $config[sql_accounting_table]
218
	WHERE username = '$login' AND acctstoptime IS NULL " . da_sql_limit(1,1,$config) . "
224
	WHERE username = '$login' AND acctstoptime IS NULL " . da_sql_limit(1,1,$config) . "
219
	 ORDER BY acctstarttime DESC " . da_sql_limit(1,2,$config). " ;");
225
	 ORDER BY acctstarttime DESC " . da_sql_limit(1,2,$config). " ;");
220
	if ($search){
226
	if ($search){
221
		if (@da_sql_num_rows($search,$config)){
227
		if (@da_sql_num_rows($search,$config)){
222
			$logged_now = 1;
228
			$logged_now = 1;
223
			$row = @da_sql_fetch_array($search,$config);
229
			$row = @da_sql_fetch_array($search,$config);
224
			$lastlog_time = $row['acctstarttime'];
230
			$lastlog_time = $row['acctstarttime'];
225
			$lastlog_server_ip = $row['nasipaddress'];
231
			$lastlog_server_ip = $row['nasipaddress'];
226
			$lastlog_server_port = $row['nasportid'];
232
			$lastlog_server_port = $row['nasportid'];
227
			$lastlog_session_time = date2timediv($lastlog_time,0);
233
			$lastlog_session_time = date2timediv($lastlog_time,0);
228
			if ($daily_limit != 'none'){
234
			if ($daily_limit != 'none'){
229
				$remaining = $remaining - $lastlog_session_time;
235
				$remaining = $remaining - $lastlog_session_time;
230
				if ($remaining < 0)
236
				if ($remaining < 0)
231
					$remaining = 0;
237
					$remaining = 0;
232
				$log_color = ($remaining) ? 'green' : 'red'; 
238
				$log_color = ($remaining) ? 'green' : 'red'; 
233
			}
239
			}
234
			$lastlog_session_time_jvs = 1000 * $lastlog_session_time;
240
			$lastlog_session_time_jvs = 1000 * $lastlog_session_time;
235
			$lastlog_session_time = time2strclock($lastlog_session_time);
241
			$lastlog_session_time = time2strclock($lastlog_session_time);
236
			$lastlog_client_ip = $row['framedipaddress'];	
242
			$lastlog_client_ip = $row['framedipaddress'];	
237
			$lastlog_server_name = @gethostbyaddr($lastlog_server_ip);
243
			$lastlog_server_name = @gethostbyaddr($lastlog_server_ip);
238
			$lastlog_client_name = @gethostbyaddr($lastlog_client_ip);
244
			$lastlog_client_name = @gethostbyaddr($lastlog_client_ip);
239
			$lastlog_callerid = $row['callingstationid'];
245
			$lastlog_callerid = $row['callingstationid'];
240
			if ($lastlog_callerid == '')
246
			if ($lastlog_callerid == '')
241
				$lastlog_callerid = 'not available';
247
				$lastlog_callerid = 'not available';
242
			$lastlog_input = $row['acctinputoctets'];
248
			$lastlog_input = $row['acctinputoctets'];
243
			if ($lastlog_input)
249
			if ($lastlog_input)
244
				$lastlog_input = bytes2str($lastlog_input);
250
				$lastlog_input = bytes2str($lastlog_input);
245
			else
251
			else
246
				$lastlog_input = 'not available';
252
				$lastlog_input = 'not available';
247
			$lastlog_output = $row['acctoutputoctets'];
253
			$lastlog_output = $row['acctoutputoctets'];
248
			if ($lastlog_output)
254
			if ($lastlog_output)
249
				$lastlog_output = bytes2str($lastlog_output);
255
				$lastlog_output = bytes2str($lastlog_output);
250
			else
256
			else
251
				$lastlog_output = 'not available';
257
				$lastlog_output = 'not available';
252
		}
258
		}
253
	}
259
	}
254
	else
260
	else
255
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
261
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
256
	if (! $logged_now){
262
	if (! $logged_now){
257
		$search = @da_sql_query($link,$config,
263
		$search = @da_sql_query($link,$config,
258
		"SELECT " . da_sql_limit(1,0,$config) . " * FROM $config[sql_accounting_table]
264
		"SELECT " . da_sql_limit(1,0,$config) . " * FROM $config[sql_accounting_table]
259
		WHERE username = '$login' AND acctsessiontime != '0' " . da_sql_limit(1,1,$config) . "
265
		WHERE username = '$login' AND acctsessiontime != '0' " . da_sql_limit(1,1,$config) . "
260
		 ORDER BY acctstoptime DESC " . da_sql_limit(1,2,$config). " ;");
266
		 ORDER BY acctstoptime DESC " . da_sql_limit(1,2,$config). " ;");
261
		if ($search){
267
		if ($search){
262
			if (@da_sql_num_rows($search,$config)){
268
			if (@da_sql_num_rows($search,$config)){
263
				$row = @da_sql_fetch_array($search,$config);
269
				$row = @da_sql_fetch_array($search,$config);
264
				$lastlog_time = $row['acctstarttime'];
270
				$lastlog_time = $row['acctstarttime'];
265
				$lastlog_server_ip = $row['nasipaddress'];
271
				$lastlog_server_ip = $row['nasipaddress'];
266
				$lastlog_server_port = $row['nasportid'];
272
				$lastlog_server_port = $row['nasportid'];
267
				$lastlog_session_time = time2str($row['acctsessiontime']);
273
				$lastlog_session_time = time2str($row['acctsessiontime']);
268
				$lastlog_client_ip = $row['framedipaddress'];	
274
				$lastlog_client_ip = $row['framedipaddress'];	
269
		$lastlog_server_name = ($lastlog_server_ip != '') ? @gethostbyaddr($lastlog_server_ip) : '-';
275
		$lastlog_server_name = ($lastlog_server_ip != '') ? @gethostbyaddr($lastlog_server_ip) : '-';
270
		$lastlog_client_name = ($lastlog_client_ip != '') ? @gethostbyaddr($lastlog_client_ip) : '-';
276
		$lastlog_client_name = ($lastlog_client_ip != '') ? @gethostbyaddr($lastlog_client_ip) : '-';
271
				$lastlog_callerid = $row['callingstationid'];
277
				$lastlog_callerid = $row['callingstationid'];
272
				if ($lastlog_callerid == '')
278
				if ($lastlog_callerid == '')
273
					$lastlog_callerid = 'not available';
279
					$lastlog_callerid = 'not available';
274
				$lastlog_input = $row['acctinputoctets'];
280
				$lastlog_input = $row['acctinputoctets'];
275
				$lastlog_input = bytes2str($lastlog_input);
281
				$lastlog_input = bytes2str($lastlog_input);
276
				$lastlog_output = $row['acctoutputoctets'];
282
				$lastlog_output = $row['acctoutputoctets'];
277
				$lastlog_output = bytes2str($lastlog_output);
283
				$lastlog_output = bytes2str($lastlog_output);
278
			}
284
			}
279
			else
285
			else
280
				$not_known = 1;
286
				$not_known = 1;
281
		}
287
		}
282
		else
288
		else
283
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
289
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
284
	}
290
	}
285
}
291
}
286
else
292
else
287
	echo "<b>Could not connect to SQL database</b><br>\n";
293
	echo "<b>Could not connect to SQL database</b><br>\n";
288
 
294
 
289
$monthly_limit = (is_numeric($monthly_limit)) ? time2str($monthly_limit) : $monthly_limit;
295
$monthly_limit = (is_numeric($monthly_limit)) ? time2str($monthly_limit) : $monthly_limit;
290
$weekly_limit = (is_numeric($weekly_limit)) ? time2str($weekly_limit) : $weekly_limit;
296
$weekly_limit = (is_numeric($weekly_limit)) ? time2str($weekly_limit) : $weekly_limit;
291
$daily_limit = (is_numeric($daily_limit)) ? time2str($daily_limit) : $daily_limit;
297
$daily_limit = (is_numeric($daily_limit)) ? time2str($daily_limit) : $daily_limit;
292
$session_limit = (is_numeric($session_limit)) ? time2str($session_limit) : $session_limit;
298
$session_limit = (is_numeric($session_limit)) ? time2str($session_limit) : $session_limit;
-
 
299
$total_limit = (is_numeric($total_limit)) ? time2str($total_limit) : $total_limit;
293
$remaining = (is_numeric($remaining)) ? time2str($remaining) : $remaining;
300
$remaining = (is_numeric($remaining)) ? time2str($remaining) : $remaining;
294
 
301
 
295
if ($item_vals['Dialup-Access'][0] == 'FALSE' || (!isset($item_vals['Dialup-Access'][0]) && $attrmap['Dialup-Access'] != '' && $attrmap['Dialup-Access'] != 'none'))
302
if ($item_vals['Dialup-Access'][0] == 'FALSE' || (!isset($item_vals['Dialup-Access'][0]) && $attrmap['Dialup-Access'] != '' && $attrmap['Dialup-Access'] != 'none'))
296
	$msg =<<<EON
303
	$msg =<<<EON
297
<font color=red><b> Le compte de l'utilisateur est verrouill&eacute; </b></font>
304
<font color=red><b> $l_locked_user </b></font>
298
EON;
305
EON;
299
else
306
else
300
	$msg =<<<EON
307
	$msg =<<<EON
301
L'utilisateur peut s'identifier pendant <font color="$log_color"> <b>$remaining $extra_msg</font>
308
$l_user_remain_login<font color="$log_color"> <b>$remaining $extra_msg</b></font>
302
EON;
309
EON;
303
$lock_msg = $item_vals['Dialup-Lock-Msg'][0];
310
$lock_msg = $item_vals['Dialup-Lock-Msg'][0];
304
if ($lock_msg != '')
311
if ($lock_msg != '')
305
	$descr =<<<EON
312
	$descr =<<<EON
306
<font color=red><b>$lock_msg </b</font>
313
<font color=red><b>$lock_msg </b</font>
307
EON;
314
EON;
308
else
315
else
309
	$descr = '-';
316
	$descr = '-';
310
 
317
 
311
$expiration = $default_vals['Expiration'][0];
318
$expiration = $default_vals['Expiration'][0];
312
if ($item_vals['Expiration'][0] != '')
319
if ($item_vals['Expiration'][0] != '')
313
	$expiration = $item_vals['Expiration'][0];
320
	$expiration = $item_vals['Expiration'][0];
314
if ($expiration != ''){
321
if ($expiration != ''){
315
	$expiration = strtotime($expiration);
322
	$expiration = strtotime($expiration);
316
	if ($expiration != -1 && $expiration < time())
323
	if ($expiration != -1 && $expiration < time())
317
		$descr = <<<EOM
324
		$descr = <<<EOM
318
<font color=red><b>Le compte de l'utilisateur a expir&eacute</b></font>
325
<font color=red><b>$l_user_expired</b></font>
319
EOM;
326
EOM;
320
}
327
}
321
 
328
 
322
require('../html/user_admin.html.php');
329
require('../html/user_admin.html.php');
323
?>
330
?>
324
 
331