Subversion Repositories ALCASAR

Rev

Rev 1847 | Rev 2373 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

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