Subversion Repositories ALCASAR

Rev

Rev 606 | Rev 912 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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