Subversion Repositories ALCASAR

Rev

Rev 2299 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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