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">
19 <body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
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">
41 <body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
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),sum(AcctInputOctets),sum(AcctOutputOctets),
92 avg(AcctSessionTime),avg(AcctInputOctets),avg(AcctOutputOctets),COUNT(*) FROM
93 $config[sql_accounting_table] WHERE UserName = '$login'
94 AND AcctStartTime >= '$week_str' AND AcctStartTime <= '$now_str';");
96 $row = @da_sql_fetch_array($search,$config);
97 $tot_time = time2str($row['sum(AcctSessionTime)']);
98 $tot_input = bytes2str($row['sum(AcctInputOctets)']);
99 $tot_output = bytes2str($row['sum(AcctOutputOctets)']);
100 $avg_time = time2str($row['avg(AcctSessionTime)']);
101 $avg_input = bytes2str($row['avg(AcctInputOctets)']);
102 $avg_output = bytes2str($row['avg(AcctOutputOctets)']);
103 $tot_conns = $row['COUNT(*)'];
106 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
107 $search = @da_sql_query($link,$config,
108 "SELECT sum(AcctSessionTime) FROM $config[sql_accounting_table] WHERE UserName = '$login'
109 AND AcctStartTime >= '$week_start' AND AcctStartTime <= '$now_str';");
111 $row = @da_sql_fetch_array($search,$config);
112 $weekly_used = $row['sum(AcctSessionTime)'];
115 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
116 if ($monthly_limit != 'none' || $config[counter_monthly_calculate_usage] == 'true'){
117 $search = @da_sql_query($link,$config,
118 "SELECT sum(AcctSessionTime) FROM $config[sql_accounting_table] WHERE UserName = '$login'
119 AND AcctStartTime >= '$month_start' AND AcctStartTime <= '$now_str';");
121 $row = @da_sql_fetch_array($search,$config);
122 $monthly_used = $row['sum(AcctSessionTime)'];
125 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
127 $search = @da_sql_query($link,$config,
128 "SELECT COUNT(*) FROM $config[sql_accounting_table] WHERE UserName = '$login'
129 AND AcctStopTime >= '$week_str' AND AcctStopTime <= '$now_str'
130 AND (AcctTerminateCause LIKE 'Login-Incorrect%' OR
131 AcctTerminateCause LIKE 'Invalid-User%' OR
132 AcctTerminateCause LIKE 'Multiple-Logins%');");
134 $row = @da_sql_fetch_array($search,$config);
135 $tot_badlogins = $row['COUNT(*)'];
138 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
139 for($i = 0; $i <=6; $i++){
142 $search = @da_sql_query($link,$config,
143 "SELECT sum(AcctSessionTime) FROM $config[sql_accounting_table] WHERE
144 UserName = '$login' AND AcctStopTime >= '$days[$i] 00:00:00'
145 AND AcctStopTime <= '$days[$i] 23:59:59';");
147 $row = @da_sql_fetch_array($search,$config);
148 $used[$i] = $row['sum(AcctSessionTime)'];
149 if ($daily_limit != 'none' && $used[$i] > $daily_limit)
150 $used[$i] = "<font color=red>" . time2str($used[$i]) . "</font>";
152 $used[$i] = time2str($used[$i]);
154 $daily_used = $row['sum(AcctSessionTime)'];
155 if ($daily_limit != 'none'){
156 $remaining = $daily_limit - $daily_used;
159 $log_color = ($remaining) ? 'green' : 'red';
161 $extra_msg = '(Out of daily quota)';
163 $daily_used = time2str($daily_used);
164 if ($daily_limit != 'none' && !$remaining)
165 $daily_used = "<font color=red>$daily_used</font>";
169 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
171 if ($weekly_limit != 'none'){
172 $tmp = $weekly_limit - $weekly_used;
175 $extra_msg .= '(Out of weekly quota)';
177 if (!is_numeric($remaining))
179 if ($remaining > $tmp)
181 $log_color = ($remaining) ? 'green' : 'red';
183 $weekly_used = time2str($weekly_used);
184 if ($weekly_limit != 'none' && !$tmp)
185 $weekly_used = "<font color=red>$weekly_used</font>";
187 if ($monthly_limit != 'none'){
188 $tmp = $monthly_limit - $monthly_used;
191 $extra_msg .= '(Out of monthly quota)';
193 if (!is_numeric($remaining))
195 if ($remaining > $tmp)
197 $log_color = ($remaining) ? 'green' : 'red';
199 if ($monthly_limit != 'none' || $config[counter_monthly_calculate_usage] == 'true'){
200 $monthly_used = time2str($monthly_used);
201 if ($monthly_limit != 'none' && !$tmp)
202 $monthly_used = "<font color=red>$monthly_used</font>";
204 if ($session_limit != 'none'){
205 if (!is_numeric($remaining))
206 $remaining = $session_limit;
207 if ($remaining > $session_limit)
208 $remaining = $session_limit;
211 $search = @da_sql_query($link,$config,
212 "SELECT * FROM $config[sql_accounting_table]
213 WHERE UserName = '$login' AND AcctStopTime IS NULL
214 ORDER BY AcctStartTime DESC LIMIT 1;");
216 if (@da_sql_num_rows($search,$config)){
218 $row = @da_sql_fetch_array($search,$config);
219 $lastlog_time = $row['AcctStartTime'];
220 $lastlog_server_ip = $row['NASIPAddress'];
221 $lastlog_server_port = $row['NASPortId'];
222 $lastlog_session_time = date2timediv($lastlog_time,0);
223 if ($daily_limit != 'none'){
224 $remaining = $remaining - $lastlog_session_time;
227 $log_color = ($remaining) ? 'green' : 'red';
229 $lastlog_session_time_jvs = 1000 * $lastlog_session_time;
230 $lastlog_session_time = time2strclock($lastlog_session_time);
231 $lastlog_client_ip = $row['FramedIPAddress'];
232 $lastlog_server_name = @gethostbyaddr($lastlog_server_ip);
233 $lastlog_client_name = @gethostbyaddr($lastlog_client_ip);
234 $lastlog_callerid = $row['CallingStationId'];
235 if ($lastlog_callerid == '')
236 $lastlog_callerid = 'not available';
237 $lastlog_input = $row['AcctInputOctets'];
239 $lastlog_input = bytes2str($lastlog_input);
241 $lastlog_input = 'not available';
242 $lastlog_output = $row['AcctOutputOctets'];
244 $lastlog_input = bytes2str($lastlog_output);
246 $lastlog_output = 'not available';
250 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
252 $search = @da_sql_query($link,$config,
253 "SELECT * FROM $config[sql_accounting_table]
254 WHERE UserName = '$login' AND AcctSessionTime != '0'
255 ORDER BY AcctStopTime DESC LIMIT 1;");
257 if (@da_sql_num_rows($search,$config)){
258 $row = @da_sql_fetch_array($search,$config);
259 $lastlog_time = $row['AcctStartTime'];
260 $lastlog_server_ip = $row['NASIPAddress'];
261 $lastlog_server_port = $row['NASPortId'];
262 $lastlog_session_time = time2str($row['AcctSessionTime']);
263 $lastlog_client_ip = $row['FramedIPAddress'];
264 $lastlog_server_name = ($lastlog_server_ip != '') ? @gethostbyaddr($lastlog_server_ip) : '-';
265 $lastlog_client_name = ($lastlog_client_ip != '') ? @gethostbyaddr($lastlog_client_ip) : '-';
266 $lastlog_callerid = $row['CallingStationId'];
267 if ($lastlog_callerid == '')
268 $lastlog_callerid = 'not available';
269 $lastlog_input = $row['AcctInputOctets'];
270 $lastlog_input = bytes2str($lastlog_input);
271 $lastlog_output = $row['AcctOutputOctets'];
272 $lastlog_output = bytes2str($lastlog_output);
278 echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
282 echo "<b>Could not connect to SQL database</b><br>\n";
284 $monthly_limit = (is_numeric($monthly_limit)) ? time2str($monthly_limit) : $monthly_limit;
285 $weekly_limit = (is_numeric($weekly_limit)) ? time2str($weekly_limit) : $weekly_limit;
286 $daily_limit = (is_numeric($daily_limit)) ? time2str($daily_limit) : $daily_limit;
287 $session_limit = (is_numeric($session_limit)) ? time2str($session_limit) : $session_limit;
288 $remaining = (is_numeric($remaining)) ? time2str($remaining) : $remaining;
290 if ($item_vals['Dialup-Access'][0] == 'FALSE' || (!isset($item_vals['Dialup-Access'][0]) && $attrmap['Dialup-Access'] != '' && $attrmap['Dialup-Access'] != 'none'))
292 <font color=red><b> The user account is locked </b></font>
296 user can login for <font color="$log_color"> <b>$remaining $extra_msg</font>
298 $lock_msg = $item_vals['Dialup-Lock-Msg'][0];
301 <font color=red><b>$lock_msg </b</font>
306 $expiration = $default_vals['Expiration'][0];
307 if ($item_vals['Expiration'][0] != '')
308 $expiration = $item_vals['Expiration'][0];
309 if ($expiration != ''){
310 $expiration = strtotime($expiration);
311 if ($expiration != -1 && $expiration < time())
313 <font color=red><b>User Account has expired</b></font>
317 require('../html/user_admin.html.php3');