Subversion Repositories ALCASAR

Rev

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

Rev 580 Rev 597
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
 
3
echo <<<EOM
21
echo <<<EOM
4
<html>
22
<html>
5
<head>
23
<head>
6
<title>Fermeture des sessions ouvertes pour l'usager : $login</title>
24
<title>Fermeture des sessions ouvertes pour l'usager : $login</title>
7
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
25
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
Line 27... Line 45...
27
<table border=0 width=400 cellpadding=0 cellspacing=2>
45
<table border=0 width=400 cellpadding=0 cellspacing=2>
28
EOM;
46
EOM;
29
 
47
 
30
include("../html/user_toolbar.html.php");
48
include("../html/user_toolbar.html.php");
31
 
49
 
-
 
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
 
32
print <<<EOM
58
print <<<EOM
33
</table>
59
</table>
34
 
60
 
35
<br>
61
<br>
36
<table border=0 width=540 cellpadding=1 cellspacing=1>
62
<table border=0 width=540 cellpadding=1 cellspacing=1>
Line 45... Line 71...
45
</td></tr>
71
</td></tr>
46
<tr bgcolor="black" valign=top><td colspan=2>
72
<tr bgcolor="black" valign=top><td colspan=2>
47
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
73
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
48
	<tr><td>
74
	<tr><td>
49
EOM;
75
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
}
50
if ($clear_sessions == 1)
126
if ($clear_sessions == 1)
51
	{
127
	{
52
	exec ("sudo /usr/local/sbin/alcasar-logout.sh $login");
128
	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];
53
	}
161
	}
-
 
162
	else
54
exec ("sudo /usr/sbin/chilli_query list|cut -d\" \" -f5,6|grep $login|grep ^1|wc -l" , $open_sessions);
163
		echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
-
 
164
}
-
 
165
else
-
 
166
	echo "<b>Could not connect to SQL database</b><br>\n";
55
?>
167
?>
56
   <form method=post>
168
   <form method=post>
57
      <input type=hidden name=login value=<?php print $login ?>>
169
      <input type=hidden name=login value=<?php print $login ?>>
58
      <input type=hidden name=clear_sessions value="0">
170
      <input type=hidden name=clear_sessions value="0">
59
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
171
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
60
<tr>
172
<tr>
61
<td align=center>
173
<td align=center>
62
<?
174
<?
63
if ($open_sessions[0] == 0)
175
if ($open_sessions == 0)
64
	{
176
	{
65
	echo "L'usager $login n'a pas de session ouverte";
177
	echo "L'usager $login n'a pas de session ouverte";
66
	}
178
	}
67
else	{
179
else	{
68
	echo "L'usager $login a <i>$open_sessions[0]</i> session(s) ouverte(s)<br><br>";
180
	echo "L'usager $login a <i>$open_sessions</i> session(s) ouverte(s)<br><br>";
69
	echo "&Ecirc;tes-vous certain de vouloir ";
181
	echo "&Ecirc;tes-vous certain de vouloir ";
70
	if ($open_sessions == 1) { echo "la"; } else {echo "les"; }
182
	if ($open_sessions == 1) { echo "la"; } else {echo "les"; }
71
	echo " fermer ? ";
183
	echo " fermer ? ";
72
	echo "<input type=submit class=button value=\"Oui, Fermer\" OnClick=\"this.form.clear_sessions.value=1\">";
184
	echo "<input type=submit class=button value=\"Oui, Fermer\" OnClick=\"this.form.clear_sessions.value=1\">";
73
	}
185
	}
74
?>
186
?>
75
</form>
187
</form>
76
</td></tr></table>
188
</td></tr></table>
-
 
189
<!--<input type=submit class=button value="Oui, poubelliser les connexions" OnClick="this.form.drop_conns.value=1">-->
77
</td></tr></table>
190
</td></tr></table>
78
</TD></TR></TABLE>
191
</TD></TR></TABLE>
79
</body>
192
</body>
80
</html>
193
</html>