Subversion Repositories ALCASAR

Rev

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

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