Subversion Repositories ALCASAR

Rev

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

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