Subversion Repositories ALCASAR

Rev

Rev 912 | Rev 1805 | 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>
925 richard 43
<table border=0 width=640 cellpadding=0 cellspacing=2>
324 richard 44
EOM;
45
 
46
include("../html/user_toolbar.html.php");
47
 
48
print <<<EOM
49
</table>
50
 
51
<br>
925 richard 52
<table border=0 width=620 cellpadding=1 cellspacing=1>
324 richard 53
<tr valign=top>
925 richard 54
<td width=400></td>
55
<td bgcolor="black">
324 richard 56
	<table border=0 width=100% cellpadding=2 cellspacing=0>
57
	<tr bgcolor="#907030" align=right valign=top><th>
912 richard 58
	<font color="white">$l_user : $login ($cn)</font>&nbsp;
324 richard 59
	</th></tr>
60
	</table>
61
</td></tr>
62
<tr bgcolor="black" valign=top><td colspan=2>
63
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
64
	<tr><td>
65
EOM;
597 richard 66
 
324 richard 67
if ($clear_sessions == 1)
68
	{
606 richard 69
# close active sessions
324 richard 70
	exec ("sudo /usr/local/sbin/alcasar-logout.sh $login");
606 richard 71
# delete open accounting sessions
613 richard 72
	$now = time();
73
	$today_now = date("Y-m-d H:i:s",$now);
606 richard 74
	$link = @da_sql_pconnect($config);
75
	if ($link)
597 richard 76
		{
606 richard 77
		$res = @da_sql_query($link,$config,
613 richard 78
		"UPDATE $config[sql_accounting_table] SET acctstoptime = '$today_now', acctterminatecause='Admin-Reset'
606 richard 79
		WHERE username='$login' AND acctstoptime IS NULL;");
80
		if (! $res)
81
			echo "<b>Error deleting open sessions for user" . da_sql_error($link,$config) . "</b><br>\n";
597 richard 82
		}
606 richard 83
	else
84
		echo "<b>Could not connect to SQL database</b><br>\n";
324 richard 85
	}
606 richard 86
# Count of accounting open sessions (in database)
87
$open_accnt_sessions = 0;
597 richard 88
$link = @da_sql_pconnect($config);
89
if ($link){
90
	$search = @da_sql_query($link,$config,
91
	"SELECT COUNT(*) AS counter FROM $config[sql_accounting_table]
606 richard 92
	WHERE username = '$login' AND acctstoptime IS NULL;");
597 richard 93
	if ($search){
94
		if ($row = @da_sql_fetch_array($search,$config))
606 richard 95
			$open_accnt_sessions = $row['counter'];
597 richard 96
	}
97
	else
98
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
99
}
100
else
101
	echo "<b>Could not connect to SQL database</b><br>\n";
606 richard 102
 
103
# Count of chilli open sessions (for coova-chilli)
104
$open_chilli_sessions = 0;
105
exec ("sudo /usr/sbin/chilli_query list|cut -d\" \" -f5,6|grep $login|grep ^1|wc -l" , $open_chilli_sessions);
106
 
324 richard 107
?>
108
   <form method=post>
109
      <input type=hidden name=login value=<?php print $login ?>>
110
      <input type=hidden name=clear_sessions value="0">
111
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
112
<tr>
113
<td align=center>
114
<?
606 richard 115
if (($open_accnt_sessions == 0) && ($open_chilli_sessions[0] == 0))
324 richard 116
	{
912 richard 117
	echo "$l_no_open_session";
324 richard 118
	}
119
else	{
912 richard 120
	echo "<b>$open_chilli_sessions[0]</b> $l_opened_sessions<br><b>$open_accnt_sessions</b> $l_active_accounting<br>";
121
	echo "$l_want_to_close ";
122
	echo "<input type=submit class=button value=\"$l_yes_close\" OnClick=\"this.form.clear_sessions.value=1\">";
324 richard 123
	}
124
?>
125
</form>
126
</td></tr></table>
127
</td></tr></table>
128
</TD></TR></TABLE>
129
</body>
130
</html>