Subversion Repositories ALCASAR

Rev

Rev 613 | Rev 925 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
324 richard 1
<?php
912 richard 2
//gestion de la langue
3
if (is_file("../lib/langues.php"))
4
	include("../lib/langues.php");
324 richard 5
require('/etc/freeradius-web/config.php');
912 richard 6
if (is_file("../lib/$config[general_lib_type]/user_info.php"))
7
	include("../lib/$config[general_lib_type]/user_info.php");
597 richard 8
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
9
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
10
else{
11
	echo <<<EOM
912 richard 12
<title>Clear opensession</title>
597 richard 13
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
14
<link rel="stylesheet" href="style.css">
15
</head>
16
<body>
17
<center>
18
<b>Could not include SQL library functions. Aborting</b>
19
</body>
20
</html>
21
EOM;
22
        exit();
23
}
24
 
324 richard 25
echo <<<EOM
26
<html>
27
<head>
912 richard 28
<title>Clear opensession</title>
324 richard 29
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
30
<link rel="stylesheet" href="/css/style.css">
31
</head>
32
<body>
33
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
912 richard 34
	<tr><th>$l_users_managment</th></tr>
324 richard 35
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" 
36
height="2"></td></tr>
37
</TABLE>
38
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
39
	<tr bgcolor="#666666"><td>
40
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
41
		<tr><td valign="middle" align="left">
42
<center>
43
<table border=0 width=550 cellpadding=0 cellspacing=0>
44
<tr valign=top>
45
<!--<td align=center><img src="images/title2.gif"></td>-->
46
</tr>
47
</table>
48
 
49
<table border=0 width=400 cellpadding=0 cellspacing=2>
50
EOM;
51
 
52
include("../html/user_toolbar.html.php");
53
 
54
print <<<EOM
55
</table>
56
 
57
<br>
58
<table border=0 width=540 cellpadding=1 cellspacing=1>
59
<tr valign=top>
60
<td width=340></td>
61
<td bgcolor="black" width=200>
62
	<table border=0 width=100% cellpadding=2 cellspacing=0>
63
	<tr bgcolor="#907030" align=right valign=top><th>
912 richard 64
	<font color="white">$l_user : $login ($cn)</font>&nbsp;
324 richard 65
	</th></tr>
66
	</table>
67
</td></tr>
68
<tr bgcolor="black" valign=top><td colspan=2>
69
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
70
	<tr><td>
71
EOM;
597 richard 72
 
324 richard 73
if ($clear_sessions == 1)
74
	{
606 richard 75
# close active sessions
324 richard 76
	exec ("sudo /usr/local/sbin/alcasar-logout.sh $login");
606 richard 77
# delete open accounting sessions
613 richard 78
	$now = time();
79
	$today_now = date("Y-m-d H:i:s",$now);
606 richard 80
	$link = @da_sql_pconnect($config);
81
	if ($link)
597 richard 82
		{
606 richard 83
		$res = @da_sql_query($link,$config,
613 richard 84
		"UPDATE $config[sql_accounting_table] SET acctstoptime = '$today_now', acctterminatecause='Admin-Reset'
606 richard 85
		WHERE username='$login' AND acctstoptime IS NULL;");
86
		if (! $res)
87
			echo "<b>Error deleting open sessions for user" . da_sql_error($link,$config) . "</b><br>\n";
597 richard 88
		}
606 richard 89
	else
90
		echo "<b>Could not connect to SQL database</b><br>\n";
324 richard 91
	}
606 richard 92
# Count of accounting open sessions (in database)
93
$open_accnt_sessions = 0;
597 richard 94
$link = @da_sql_pconnect($config);
95
if ($link){
96
	$search = @da_sql_query($link,$config,
97
	"SELECT COUNT(*) AS counter FROM $config[sql_accounting_table]
606 richard 98
	WHERE username = '$login' AND acctstoptime IS NULL;");
597 richard 99
	if ($search){
100
		if ($row = @da_sql_fetch_array($search,$config))
606 richard 101
			$open_accnt_sessions = $row['counter'];
597 richard 102
	}
103
	else
104
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
105
}
106
else
107
	echo "<b>Could not connect to SQL database</b><br>\n";
606 richard 108
 
109
# Count of chilli open sessions (for coova-chilli)
110
$open_chilli_sessions = 0;
111
exec ("sudo /usr/sbin/chilli_query list|cut -d\" \" -f5,6|grep $login|grep ^1|wc -l" , $open_chilli_sessions);
112
 
324 richard 113
?>
114
   <form method=post>
115
      <input type=hidden name=login value=<?php print $login ?>>
116
      <input type=hidden name=clear_sessions value="0">
117
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
118
<tr>
119
<td align=center>
120
<?
606 richard 121
if (($open_accnt_sessions == 0) && ($open_chilli_sessions[0] == 0))
324 richard 122
	{
912 richard 123
	echo "$l_no_open_session";
324 richard 124
	}
125
else	{
912 richard 126
	echo "<b>$open_chilli_sessions[0]</b> $l_opened_sessions<br><b>$open_accnt_sessions</b> $l_active_accounting<br>";
127
	echo "$l_want_to_close ";
128
	echo "<input type=submit class=button value=\"$l_yes_close\" OnClick=\"this.form.clear_sessions.value=1\">";
324 richard 129
	}
130
?>
131
</form>
132
</td></tr></table>
133
</td></tr></table>
134
</TD></TR></TABLE>
135
</body>
136
</html>