Subversion Repositories ALCASAR

Rev

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

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