Subversion Repositories ALCASAR

Rev

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

Rev 2654 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($type)) $type = 'user';
6
if (!isset($type)) $type = 'user';
7
if (!isset($user_type)) $user_type = 'user';
7
if (!isset($user_type)) $user_type = 'user';
8
if (!isset($delete_user)) $delete_user = 0;
8
if (!isset($delete_user)) $delete_user = 0;
9
if ($user_type != 'group'){
9
if ($user_type != 'group'){
10
	if (is_file("../lib/$config[general_lib_type]/user_info.php"))
10
	if (is_file("../lib/$config[general_lib_type]/user_info.php"))
11
		include("../lib/$config[general_lib_type]/user_info.php");
11
		include("../lib/$config[general_lib_type]/user_info.php");
12
}
12
}
13
else {
13
else {
14
	if (is_file("../lib/$config[general_lib_type]/group_info.php"))
14
	if (is_file("../lib/$config[general_lib_type]/group_info.php"))
15
		include("../lib/$config[general_lib_type]/group_info.php");
15
		include("../lib/$config[general_lib_type]/group_info.php");
16
}
16
}
17
if (is_file("../lib/langues.php"))
17
if (is_file("../lib/langues.php"))
18
	include("../lib/langues.php");
18
	include("../lib/langues.php");
19
 
19
 
20
echo <<<EOM
20
echo <<<EOM
21
<html>
21
<html>
22
<head>
22
<head>
23
EOM;
23
EOM;
24
 
24
 
25
if ($user_type != 'group') {
25
if ($user_type != 'group') {
26
	$util = $l_user;
26
	$util = $l_user;
27
	$title = $l_users_managment;
27
	$title = $l_users_managment;
28
	$cnName = " ($cn)";
28
	$cnName = " ($cn)";
29
}
29
}
30
else {
30
else {
31
	$util = $l_group;
31
	$util = $l_group;
32
	$title = $l_groups_managment;
32
	$title = $l_groups_managment;
33
	$cnName = '';
33
	$cnName = '';
34
}
34
}
35
 
35
 
36
echo <<<EOM
36
echo <<<EOM
37
<title>delete users and groups</title>
37
<title>delete users and groups</title>
38
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
38
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
39
<link rel="stylesheet" href="/css/style.css">
39
<link rel="stylesheet" href="/css/acc.css">
40
</head>
40
</head>
41
<body>
41
<body>
42
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
42
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
43
	<tr><th>$title</th></tr>
43
	<tr><th>$title</th></tr>
44
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1"
44
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1"
45
height="2"></td></tr>
45
height="2"></td></tr>
46
</TABLE>
46
</TABLE>
47
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
47
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
48
	<tr bgcolor="#666666"><td>
48
	<tr bgcolor="#666666"><td>
49
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
49
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
50
		<tr><td valign="middle" align="left">
50
		<tr><td valign="middle" align="left">
51
<center>
51
<center>
52
<table border=0 width=640 cellpadding=0 cellspacing=2>
52
<table border=0 width=640 cellpadding=0 cellspacing=2>
53
EOM;
53
EOM;
54
 
54
 
55
if ($delete_user != 1) {
55
if ($delete_user != 1) {
56
	if ($user_type != 'group')
56
	if ($user_type != 'group')
57
		include("../html/user_toolbar.html.php");
57
		include("../html/user_toolbar.html.php");
58
	else
58
	else
59
		include("../html/group_toolbar.html.php");
59
		include("../html/group_toolbar.html.php");
60
}
60
}
61
 
61
 
62
print <<<EOM
62
print <<<EOM
63
</table>
63
</table>
64
 
64
 
65
<br>
65
<br>
66
<table border=0 width=620 cellpadding=1 cellspacing=1>
66
<table border=0 width=620 cellpadding=1 cellspacing=1>
67
<tr valign=top>
67
<tr valign=top>
68
<td width=400></td>
68
<td width=400></td>
69
<td bgcolor="black">
69
<td bgcolor="black">
70
	<table border=0 width=100% cellpadding=2 cellspacing=0>
70
	<table border=0 width=100% cellpadding=2 cellspacing=0>
71
	<tr bgcolor="#907030" align=right valign=top><th>
71
	<tr bgcolor="#907030" align=right valign=top><th>
72
	<font color="white">$util : $login$cnName</font>&nbsp;
72
	<font color="white">$util : $login$cnName</font>&nbsp;
73
	</th></tr>
73
	</th></tr>
74
	</table>
74
	</table>
75
</td></tr>
75
</td></tr>
76
<tr bgcolor="black" valign=top><td colspan=2>
76
<tr bgcolor="black" valign=top><td colspan=2>
77
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
77
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
78
	<tr><td>
78
	<tr><td>
79
EOM;
79
EOM;
80
 
80
 
81
if ($delete_user == 1){
81
if ($delete_user == 1){
82
	if ($user_type != 'group'){
82
	if ($user_type != 'group'){
83
		// Disconnecting user
83
		// Disconnecting user
84
		$mac = exec('sudo /usr/sbin/chilli_query list | awk '.escapeshellarg('($5 == 1) && ($6 == "'.$login.'") {print $1}'));
84
		$mac = exec('sudo /usr/sbin/chilli_query list | awk '.escapeshellarg('($5 == 1) && ($6 == "'.$login.'") {print $1}'));
85
		if (!empty($mac)) {
85
		if (!empty($mac)) {
86
			exec('sudo /usr/sbin/chilli_query logout mac '.escapeshellarg($mac));
86
			exec('sudo /usr/sbin/chilli_query logout mac '.escapeshellarg($mac));
87
		}
87
		}
88
 
88
 
89
		if (is_file("../lib/$config[general_lib_type]/delete_user.php"))
89
		if (is_file("../lib/$config[general_lib_type]/delete_user.php"))
90
			include("../lib/$config[general_lib_type]/delete_user.php");
90
			include("../lib/$config[general_lib_type]/delete_user.php");
91
	}
91
	}
92
	else{
92
	else{
93
		$group_macs = [];
93
		$group_macs = [];
94
		// Disconnecting users
94
		// Disconnecting users
95
		foreach ($group_members as $member){
95
		foreach ($group_members as $member){
96
			$mac = exec('sudo /usr/sbin/chilli_query list | awk '.escapeshellarg('($5 == 1) && ($6 == "'.$member.'") {print $1}'));
96
			$mac = exec('sudo /usr/sbin/chilli_query list | awk '.escapeshellarg('($5 == 1) && ($6 == "'.$member.'") {print $1}'));
97
			if (!empty($mac)) {
97
			if (!empty($mac)) {
98
				exec('sudo /usr/sbin/chilli_query logout mac '.escapeshellarg($mac));
98
				exec('sudo /usr/sbin/chilli_query logout mac '.escapeshellarg($mac));
99
				if ($member === $mac) {
99
				if ($member === $mac) {
100
					$group_macs[] = $mac;
100
					$group_macs[] = $mac;
101
				}
101
				}
102
			}
102
			}
103
		}
103
		}
104
		if (isset($delete_users_of_group) && $delete_users_of_group == 1){
104
		if (isset($delete_users_of_group) && $delete_users_of_group == 1){
105
			$tmp_group_name=$login;
105
			$tmp_group_name=$login;
106
			foreach ($group_members as $member){
106
			foreach ($group_members as $member){
107
				$login=$member;
107
				$login=$member;
108
				if (is_file("../lib/$config[general_lib_type]/delete_user.php"))
108
				if (is_file("../lib/$config[general_lib_type]/delete_user.php"))
109
					include("../lib/$config[general_lib_type]/delete_user.php");
109
					include("../lib/$config[general_lib_type]/delete_user.php");
110
			}
110
			}
111
			$login=$tmp_group_name;
111
			$login=$tmp_group_name;
112
		} else {
112
		} else {
113
			// Reconnect allowed MAC from the selected group
113
			// Reconnect allowed MAC from the selected group
114
			foreach ($group_macs as $mac) {
114
			foreach ($group_macs as $mac) {
115
				exec('sudo /usr/sbin/chilli_query login mac '.escapeshellarg($mac).' username '.escapeshellarg($mac)." password 'password'");
115
				exec('sudo /usr/sbin/chilli_query login mac '.escapeshellarg($mac).' username '.escapeshellarg($mac)." password 'password'");
116
			}
116
			}
117
		}
117
		}
118
		if (is_file("../lib/$config[general_lib_type]/delete_group.php"))
118
		if (is_file("../lib/$config[general_lib_type]/delete_group.php"))
119
			include("../lib/$config[general_lib_type]/delete_group.php");
119
			include("../lib/$config[general_lib_type]/delete_group.php");
120
	}
120
	}
121
	echo <<<EOM
121
	echo <<<EOM
122
</td></tr>
122
</td></tr>
123
</table>
123
</table>
124
</tr>
124
</tr>
125
</table>
125
</table>
126
</body>
126
</body>
127
</html>
127
</html>
128
EOM;
128
EOM;
129
	exit();
129
	exit();
130
}
130
}
131
?>
131
?>
132
   <form method=post>
132
   <form method=post>
133
      <input type=hidden name=login value=<?php print $login ?>>
133
      <input type=hidden name=login value=<?php print $login ?>>
134
      <input type=hidden name=delete_user value="0">
134
      <input type=hidden name=delete_user value="0">
135
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
135
	<table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
136
<tr>
136
<tr>
137
<td align=center>
137
<td align=center>
138
<?php
138
<?php
139
if ($user_type == 'group'){
139
if ($user_type == 'group'){
140
  echo "$l_group_members_remove : ";
140
  echo "$l_group_members_remove : ";
141
  echo "<input type=checkbox name=delete_users_of_group value=\"1\">";
141
  echo "<input type=checkbox name=delete_users_of_group value=\"1\">";
142
}
142
}
143
echo "<br>";
143
echo "<br>";
144
echo "$l_are_you_sure <b>$login</b> ? ";
144
echo "$l_are_you_sure <b>$login</b> ? ";
145
?>
145
?>
146
	<input type=submit class=button value="<?php echo"$l_yes_remove";?>" OnClick="this.form.delete_user.value=1">
146
	<input type=submit class=button value="<?php echo"$l_yes_remove";?>" OnClick="this.form.delete_user.value=1">
147
</form>
147
</form>
148
</td></tr></table></td></tr>
148
</td></tr></table></td></tr>
149
</table>
149
</table>
150
</tr>
150
</tr>
151
</table>
151
</table>
152
</TD></TR>
152
</TD></TR>
153
</TABLE>
153
</TABLE>
154
</td></tr>
154
</td></tr>
155
</TABLE>
155
</TABLE>
156
</body>
156
</body>
157
</html>
157
</html>
158
 
158