Subversion Repositories ALCASAR

Rev

Rev 324 | Rev 597 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 324 Rev 580
Line 1... Line 1...
1
<?php
1
<?php
2
require('/etc/freeradius-web/config.php');
2
require('/etc/freeradius-web/config.php');
3
require_once('../lib/xlat.php');
-
 
4
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
-
 
5
	include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
-
 
6
else{
-
 
7
	echo <<<EOM
-
 
8
<title>Fermeture des sessions ouvertes pour l'utilisateur $login</title>
-
 
9
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
-
 
10
<link rel="stylesheet" href="style.css">
-
 
11
</head>
-
 
12
<body>
-
 
13
<center>
-
 
14
<b>Could not include SQL library functions. Aborting</b>
-
 
15
</body>
-
 
16
</html>
-
 
17
EOM;
-
 
18
        exit();
-
 
19
}
-
 
20
 
-
 
21
echo <<<EOM
3
echo <<<EOM
22
<html>
4
<html>
23
<head>
5
<head>
24
<title>Fermeture des sessions ouvertes pour l'usager : $login</title>
6
<title>Fermeture des sessions ouvertes pour l'usager : $login</title>
25
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
7
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
Line 45... Line 27...
45
<table border=0 width=400 cellpadding=0 cellspacing=2>
27
<table border=0 width=400 cellpadding=0 cellspacing=2>
46
EOM;
28
EOM;
47
 
29
 
48
include("../html/user_toolbar.html.php");
30
include("../html/user_toolbar.html.php");
49
 
31
 
50
$open_sessions = 0;
-
 
51
 
-
 
52
$sql_extra_query = '';
-
 
53
if ($config[sql_accounting_extra_query] != ''){
-
 
54
	$sql_extra_query = xlat($config[sql_accounting_extra_query],$login,$config);
-
 
55
	$sql_extra_query = da_sql_escape_string($sql_extra_query);
-
 
56
}
-
 
57
 
-
 
58
print <<<EOM
32
print <<<EOM
59
</table>
33
</table>
60
 
34
 
61
<br>
35
<br>
62
<table border=0 width=540 cellpadding=1 cellspacing=1>
36
<table border=0 width=540 cellpadding=1 cellspacing=1>
Line 71... Line 45...
71
</td></tr>
45
</td></tr>
72
<tr bgcolor="black" valign=top><td colspan=2>
46
<tr bgcolor="black" valign=top><td colspan=2>
73
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
47
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
74
	<tr><td>
48
	<tr><td>
75
EOM;
49
EOM;
76
 
-
 
77
if ($drop_conns == 1){
-
 
78
	$method = 'snmp';
-
 
79
	$nastype = 'cisco';
-
 
80
	if ($config[general_sessionclear_method] != '')
-
 
81
		$method = $config[general_sessionclear_method];
-
 
82
	if ($config[general_nas_type] != '')
-
 
83
		$nastype = $config[general_nas_type];
-
 
84
	if ($config[general_ld_library_path] != '')
-
 
85
		putenv("LD_LIBRARY_PATH=$config[general_ld_library_path]");
-
 
86
	$nas_by_ip = array();
-
 
87
	$meth_by_ip = array();
-
 
88
	$nastype_by_ip = array();
-
 
89
	foreach ($nas_list as $nas){
-
 
90
		if ($nas[ip] != ''){
-
 
91
			$ip = $nas[ip];
-
 
92
			$nas_by_ip[$ip] = $nas[community];
-
 
93
			$meth_by_ip[$ip] = $nas[sessionclear_method];
-
 
94
			$nastype_by_ip[$ip] = $nas[nas_type];
-
 
95
		}
-
 
96
	}
-
 
97
 
-
 
98
	$link = @da_sql_pconnect($config);
-
 
99
	if ($link){
-
 
100
		$search = @da_sql_query($link,$config,
-
 
101
		"SELECT nasipaddress,acctsessionid FROM $config[sql_accounting_table]
-
 
102
		WHERE username = '$login' AND acctstoptime IS NULL;");
-
 
103
		if ($search){
-
 
104
			while($row = @da_sql_fetch_array($search,$config)){
-
 
105
				$sessionid = $row[acctsessionid];
-
 
106
				$sessionid = hexdec($sessionid);
-
 
107
				$nas = $row[nasipaddress];
-
 
108
				$port = $row[nasportid];
-
 
109
				$meth = $meth_by_ip[$nas];
-
 
110
				$nastype = ($nastype_by_ip[$nas] != '') ? $nastype_by_ip[$nas] : $nastype;
-
 
111
				$comm = $nas_by_ip[$nas];
-
 
112
				if ($meth == '')
-
 
113
					$meth = $method;
-
 
114
				if ($meth == 'snmp' && $comm != '')
-
 
115
					exec("$config[general_sessionclear_bin] $nas snmp $nastype $login $sessionid $comm");
-
 
116
				if ($meth == 'telnet')
-
 
117
					exec("$config[general_sessionclear_bin] $nas telnet $nastype $login $sessionid $port");
-
 
118
			}
-
 
119
		}
-
 
120
		else
-
 
121
			echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
-
 
122
	}
-
 
123
	else
-
 
124
		echo "<b>Could not connect to SQL database</b><br>\n";
-
 
125
}
-
 
126
if ($clear_sessions == 1)
50
if ($clear_sessions == 1)
127
	{
51
	{
128
	exec ("sudo /usr/local/sbin/alcasar-logout.sh $login");
52
	exec ("sudo /usr/local/sbin/alcasar-logout.sh $login");
129
	$sql_servers = array();
-
 
130
	if ($config[sql_extra_servers] != '')
-
 
131
		$sql_servers = explode(' ',$config[sql_extra_servers]);
-
 
132
	$quer = '= 0';
-
 
133
	if ($config[sql_type] == 'pg')
-
 
134
		$quer = 'IS NULL';
-
 
135
	$sql_servers[] = $config[sql_server];
-
 
136
	foreach ($sql_servers as $server)
-
 
137
		{
-
 
138
		$link = @da_sql_host_connect($server,$config);
-
 
139
		if ($link)
-
 
140
			{
-
 
141
			$res = @da_sql_query($link,$config,
-
 
142
			"DELETE FROM $config[sql_accounting_table]
-
 
143
			WHERE username='$login' AND acctstoptime $quer $sql_extra_query;");
-
 
144
			if ($res)
-
 
145
				echo "<b>La comptabilit&eacute; des sessions pour cet usager a &eacute;t&eacute; arr&eacute;t&eacute;e</b><br>\n";
-
 
146
			else
-
 
147
				echo "<b>Error deleting open sessions for user" . da_sql_error($link,$config) . "</b><br>\n";
-
 
148
			}
-
 
149
		else
-
 
150
			echo "<b>Could not connect to SQL database</b><br>\n";
-
 
151
		}
-
 
152
	}
-
 
153
$link = @da_sql_pconnect($config);
-
 
154
if ($link){
-
 
155
	$search = @da_sql_query($link,$config,
-
 
156
	"SELECT COUNT(*) AS counter FROM $config[sql_accounting_table]
-
 
157
	WHERE username = '$login' AND acctstoptime IS NULL $sql_extra_query;");
-
 
158
	if ($search){
-
 
159
		if ($row = @da_sql_fetch_array($search,$config))
-
 
160
			$open_sessions = $row[counter];
-
 
161
	}
53
	}
162
	else
-
 
163
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
54
exec ("sudo /usr/sbin/chilli_query list|cut -d\" \" -f5,6|grep $login|grep ^1|wc -l" , $open_sessions);
164
}
-
 
165
else
-
 
166
	echo "<b>Could not connect to SQL database</b><br>\n";
-
 
167
?>
55
?>
168
   <form method=post>
56
   <form method=post>
169
      <input type=hidden name=login value=<?php print $login ?>>
57
      <input type=hidden name=login value=<?php print $login ?>>
170
      <input type=hidden name=clear_sessions value="0">
58
      <input type=hidden name=clear_sessions value="0">
171
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
59
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
172
<tr>
60
<tr>
173
<td align=center>
61
<td align=center>
174
<?
62
<?
175
if ($open_sessions == 0)
63
if ($open_sessions[0] == 0)
176
	{
64
	{
177
	echo "L'usager $login n'a pas de session ouverte";
65
	echo "L'usager $login n'a pas de session ouverte";
178
	}
66
	}
179
else	{
67
else	{
180
	echo "L'usager $login a <i>$open_sessions</i> session(s) ouverte(s)<br><br>";
68
	echo "L'usager $login a <i>$open_sessions[0]</i> session(s) ouverte(s)<br><br>";
181
	echo "&Ecirc;tes-vous certain de vouloir ";
69
	echo "&Ecirc;tes-vous certain de vouloir ";
182
	if ($open_sessions == 1) { echo "la"; } else {echo "les"; }
70
	if ($open_sessions == 1) { echo "la"; } else {echo "les"; }
183
	echo " fermer ? ";
71
	echo " fermer ? ";
184
	echo "<input type=submit class=button value=\"Oui, Fermer\" OnClick=\"this.form.clear_sessions.value=1\">";
72
	echo "<input type=submit class=button value=\"Oui, Fermer\" OnClick=\"this.form.clear_sessions.value=1\">";
185
	}
73
	}
186
?>
74
?>
187
</form>
75
</form>
188
</td></tr></table>
76
</td></tr></table>
189
<!--<input type=submit class=button value="Oui, poubelliser les connexions" OnClick="this.form.drop_conns.value=1">-->
-
 
190
</td></tr></table>
77
</td></tr></table>
191
</TD></TR></TABLE>
78
</TD></TR></TABLE>
192
</body>
79
</body>
193
</html>
80
</html>