2 require('../conf/config.php3');
7 require('../lib/functions.php3');
8 require('../lib/defaults.php3');
9 $date = strftime('%A, %e %B %Y, %T %Z');
11 if (is_file("../lib/$config[general_lib_type]/user_info.php3")){
12 include("../lib/$config[general_lib_type]/user_info.php3");
13 if ($user_exists == 'no'){
15 <title>user information page</title>
16 <meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
17 <link rel="stylesheet" href="style.css">
21 <form action="user_admin.php3" method=get>
22 <b>User Name </b>
23 <input type="text" size=10 name="login" value="$login">
24 <b> does not exist</b><br>
25 <input type=submit class=button value="Show User">
33 if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
34 include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
37 <title>user information page</title>
38 <meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
39 <link rel="stylesheet" href="style.css">
43 <b>Could not include SQL library functions. Aborting</b>
50 $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];
52 $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];
54 $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];
56 $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';
58 $remaining = 'unlimited time';
62 $week = $now - 604800;
63 $now_str = date("$config[sql_date_format]",$now + 86400);
64 $week_str = date("$config[sql_date_format]",$week);
66 $week_start = date($config[sql_date_format],$now - ($day)*86400);
67 $month_start = date($config[sql_date_format],$now - date('j')*86400);
70 for ($i = $day; $i >-1; $i--){
71 $days[$i] = date($config[sql_date_format],$now_tmp);
75 //$now -= ($day * 86400);
78 for ($i = $day; $i <= 6; $i++){
79 $days[$i] = date($config[sql_date_format],$now);
84 $daily_used = $weekly_used = $monthly_used = $lastlog_session_time = '-';
86 $used = array('-','-','-','-','-','-','-');
88 $link = @da_sql_pconnect($config);
90 $search = @da_sql_query($link,$config,
91 "SELECT sum(acctsessiontime) AS sum_sess_time,
92 sum(acctinputoctets) AS sum_in_octets,
93 sum(acctoutputoctets) AS sum_out_octets,
94 avg(acctsessiontime) AS avg_sess_time,
95 avg(acctinputoctets) AS avg_in_octets,
96 avg(acctoutputoctets) AS avg_out_octets,
97 COUNT(*) as counter FROM
98 $config[sql_accounting_table] WHERE username = '$login'
99 AND acctstarttime >= '$week_str' AND acctstarttime <= '$now_str';");
101 $row = @da_sql_fetch_array($search,$config);
102 $tot_time = time2str($row[sum_sess_time]);
103 $tot_input = bytes2str($row[sum_in_octets]);
104 $tot_output = bytes2str($row[sum_out_octets]);
105 $avg_time = time2str($row[avg_sess_time]);
106 $avg_input = bytes2str($row[avg_in_octets]);
107 $avg_output = bytes2str($row[avg_out_octets]);
108 $tot_conns = $row[counter];
111 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
112 $search = @da_sql_query($link,$config,
113 "SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE username = '$login'
114 AND acctstarttime >= '$week_start' AND acctstarttime <= '$now_str';");
116 $row = @da_sql_fetch_array($search,$config);
117 $weekly_used = $row[sum_sess_time];
120 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
121 if ($monthly_limit != 'none' || $config[counter_monthly_calculate_usage] == 'true'){
122 $search = @da_sql_query($link,$config,
123 "SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE username = '$login'
124 AND acctstarttime >= '$month_start' AND acctstarttime <= '$now_str';");
126 $row = @da_sql_fetch_array($search,$config);
127 $monthly_used = $row[sum_sess_time];
130 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
132 $search = @da_sql_query($link,$config,
133 "SELECT COUNT(*) AS counter FROM $config[sql_accounting_table] WHERE username = '$login'
134 AND acctstoptime >= '$week_str' AND acctstoptime <= '$now_str'
135 AND (acctterminatecause LIKE 'Login-Incorrect%' OR
136 acctterminatecause LIKE 'Invalid-User%' OR
137 acctterminatecause LIKE 'Multiple-Logins%');");
139 $row = @da_sql_fetch_array($search,$config);
140 $tot_badlogins = $row[counter];
143 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
144 for($i = 0; $i <=6; $i++){
147 $search = @da_sql_query($link,$config,
148 "SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE
149 username = '$login' AND acctstoptime >= '$days[$i] 00:00:00'
150 AND acctstoptime <= '$days[$i] 23:59:59';");
152 $row = @da_sql_fetch_array($search,$config);
153 $used[$i] = $row[sum_sess_time];
154 if ($daily_limit != 'none' && $used[$i] > $daily_limit)
155 $used[$i] = "<font color=red>" . time2str($used[$i]) . "</font>";
157 $used[$i] = time2str($used[$i]);
159 $daily_used = $row[sum_sess_time];
160 if ($daily_limit != 'none'){
161 $remaining = $daily_limit - $daily_used;
164 $log_color = ($remaining) ? 'green' : 'red';
166 $extra_msg = '(Out of daily quota)';
168 $daily_used = time2str($daily_used);
169 if ($daily_limit != 'none' && !$remaining)
170 $daily_used = "<font color=red>$daily_used</font>";
174 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
176 if ($weekly_limit != 'none'){
177 $tmp = $weekly_limit - $weekly_used;
180 $extra_msg .= '(Out of weekly quota)';
182 if (!is_numeric($remaining))
184 if ($remaining > $tmp)
186 $log_color = ($remaining) ? 'green' : 'red';
188 $weekly_used = time2str($weekly_used);
189 if ($weekly_limit != 'none' && !$tmp)
190 $weekly_used = "<font color=red>$weekly_used</font>";
192 if ($monthly_limit != 'none'){
193 $tmp = $monthly_limit - $monthly_used;
196 $extra_msg .= '(Out of monthly quota)';
198 if (!is_numeric($remaining))
200 if ($remaining > $tmp)
202 $log_color = ($remaining) ? 'green' : 'red';
204 if ($monthly_limit != 'none' || $config[counter_monthly_calculate_usage] == 'true'){
205 $monthly_used = time2str($monthly_used);
206 if ($monthly_limit != 'none' && !$tmp)
207 $monthly_used = "<font color=red>$monthly_used</font>";
209 if ($session_limit != 'none'){
210 if (!is_numeric($remaining))
211 $remaining = $session_limit;
212 if ($remaining > $session_limit)
213 $remaining = $session_limit;
216 $search = @da_sql_query($link,$config,
217 "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) . "
219 ORDER BY acctstarttime DESC " . da_sql_limit(1,2,$config). " ;");
221 if (@da_sql_num_rows($search,$config)){
223 $row = @da_sql_fetch_array($search,$config);
224 $lastlog_time = $row['acctstarttime'];
225 $lastlog_server_ip = $row['nasipaddress'];
226 $lastlog_server_port = $row['nasportid'];
227 $lastlog_session_time = date2timediv($lastlog_time,0);
228 if ($daily_limit != 'none'){
229 $remaining = $remaining - $lastlog_session_time;
232 $log_color = ($remaining) ? 'green' : 'red';
234 $lastlog_session_time_jvs = 1000 * $lastlog_session_time;
235 $lastlog_session_time = time2strclock($lastlog_session_time);
236 $lastlog_client_ip = $row['framedipaddress'];
237 $lastlog_server_name = @gethostbyaddr($lastlog_server_ip);
238 $lastlog_client_name = @gethostbyaddr($lastlog_client_ip);
239 $lastlog_callerid = $row['callingstationid'];
240 if ($lastlog_callerid == '')
241 $lastlog_callerid = 'not available';
242 $lastlog_input = $row['acctinputoctets'];
244 $lastlog_input = bytes2str($lastlog_input);
246 $lastlog_input = 'not available';
247 $lastlog_output = $row['acctoutputoctets'];
249 $lastlog_output = bytes2str($lastlog_output);
251 $lastlog_output = 'not available';
255 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
257 $search = @da_sql_query($link,$config,
258 "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) . "
260 ORDER BY acctstoptime DESC " . da_sql_limit(1,2,$config). " ;");
262 if (@da_sql_num_rows($search,$config)){
263 $row = @da_sql_fetch_array($search,$config);
264 $lastlog_time = $row['acctstarttime'];
265 $lastlog_server_ip = $row['nasipaddress'];
266 $lastlog_server_port = $row['nasportid'];
267 $lastlog_session_time = time2str($row['acctsessiontime']);
268 $lastlog_client_ip = $row['framedipaddress'];
269 $lastlog_server_name = ($lastlog_server_ip != '') ? @gethostbyaddr($lastlog_server_ip) : '-';
270 $lastlog_client_name = ($lastlog_client_ip != '') ? @gethostbyaddr($lastlog_client_ip) : '-';
271 $lastlog_callerid = $row['callingstationid'];
272 if ($lastlog_callerid == '')
273 $lastlog_callerid = 'not available';
274 $lastlog_input = $row['acctinputoctets'];
275 $lastlog_input = bytes2str($lastlog_input);
276 $lastlog_output = $row['acctoutputoctets'];
277 $lastlog_output = bytes2str($lastlog_output);
283 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
287 echo "<b>Could not connect to SQL database</b><br>\n";
289 $monthly_limit = (is_numeric($monthly_limit)) ? time2str($monthly_limit) : $monthly_limit;
290 $weekly_limit = (is_numeric($weekly_limit)) ? time2str($weekly_limit) : $weekly_limit;
291 $daily_limit = (is_numeric($daily_limit)) ? time2str($daily_limit) : $daily_limit;
292 $session_limit = (is_numeric($session_limit)) ? time2str($session_limit) : $session_limit;
293 $remaining = (is_numeric($remaining)) ? time2str($remaining) : $remaining;
295 if ($item_vals['Dialup-Access'][0] == 'FALSE' || (!isset($item_vals['Dialup-Access'][0]) && $attrmap['Dialup-Access'] != '' && $attrmap['Dialup-Access'] != 'none'))
297 <font color=red><b> The user account is locked </b></font>
301 user can login for <font color="$log_color"> <b>$remaining $extra_msg</font>
303 $lock_msg = $item_vals['Dialup-Lock-Msg'][0];
306 <font color=red><b>$lock_msg </b</font>
311 $expiration = $default_vals['Expiration'][0];
312 if ($item_vals['Expiration'][0] != '')
313 $expiration = $item_vals['Expiration'][0];
314 if ($expiration != ''){
315 $expiration = strtotime($expiration);
316 if ($expiration != -1 && $expiration < time())
318 <font color=red><b>User Account has expired</b></font>
322 require('../html/user_admin.html.php3');