Subversion Repositories ALCASAR

Rev

Rev 2382 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
324 richard 1
<?php
911 richard 2
//gestion de la langue
3
if (is_file("../lib/langues.php"))
4
	include("../lib/langues.php");
324 richard 5
require('/etc/freeradius-web/config.php');
1805 clement.si 6
if (!isset($type)) $type = 'user';
2654 tom.houday 7
if (!isset($user_type)) $user_type = 'user';
8
if (!isset($delete_user)) $delete_user = 0;
9
if ($user_type != 'group'){
324 richard 10
	if (is_file("../lib/$config[general_lib_type]/user_info.php"))
11
		include("../lib/$config[general_lib_type]/user_info.php");
911 richard 12
}
13
else {
324 richard 14
	if (is_file("../lib/$config[general_lib_type]/group_info.php"))
15
		include("../lib/$config[general_lib_type]/group_info.php");
911 richard 16
}
17
if (is_file("../lib/langues.php"))
18
	include("../lib/langues.php");
324 richard 19
 
20
echo <<<EOM
21
<html>
22
<head>
23
EOM;
24
 
2654 tom.houday 25
if ($user_type != 'group') {
911 richard 26
	$util = $l_user;
2654 tom.houday 27
	$title = $l_users_managment;
28
	$cnName = " ($cn)";
29
}
30
else {
911 richard 31
	$util = $l_group;
2654 tom.houday 32
	$title = $l_groups_managment;
33
	$cnName = '';
34
}
324 richard 35
 
36
echo <<<EOM
911 richard 37
<title>delete users and groups</title>
324 richard 38
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
39
<link rel="stylesheet" href="/css/style.css">
40
</head>
41
<body>
42
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
911 richard 43
	<tr><th>$title</th></tr>
1805 clement.si 44
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1"
324 richard 45
height="2"></td></tr>
46
</TABLE>
47
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
48
	<tr bgcolor="#666666"><td>
49
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
50
		<tr><td valign="middle" align="left">
51
<center>
925 richard 52
<table border=0 width=640 cellpadding=0 cellspacing=2>
324 richard 53
EOM;
54
 
2382 tom.houday 55
if ($delete_user != 1) {
56
	if ($user_type != 'group')
57
		include("../html/user_toolbar.html.php");
58
	else
59
		include("../html/group_toolbar.html.php");
60
}
324 richard 61
 
62
print <<<EOM
63
</table>
64
 
65
<br>
925 richard 66
<table border=0 width=620 cellpadding=1 cellspacing=1>
324 richard 67
<tr valign=top>
925 richard 68
<td width=400></td>
69
<td bgcolor="black">
324 richard 70
	<table border=0 width=100% cellpadding=2 cellspacing=0>
71
	<tr bgcolor="#907030" align=right valign=top><th>
2654 tom.houday 72
	<font color="white">$util : $login$cnName</font>&nbsp;
324 richard 73
	</th></tr>
74
	</table>
75
</td></tr>
76
<tr bgcolor="black" valign=top><td colspan=2>
77
	<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
78
	<tr><td>
79
EOM;
1805 clement.si 80
 
324 richard 81
if ($delete_user == 1){
82
	if ($user_type != 'group'){
2654 tom.houday 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
 
324 richard 89
		if (is_file("../lib/$config[general_lib_type]/delete_user.php"))
90
			include("../lib/$config[general_lib_type]/delete_user.php");
91
	}
92
	else{
2654 tom.houday 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
		}
1805 clement.si 104
		if (isset($delete_users_of_group) && $delete_users_of_group == 1){
324 richard 105
			$tmp_group_name=$login;
106
			foreach ($group_members as $member){
107
				$login=$member;
108
				if (is_file("../lib/$config[general_lib_type]/delete_user.php"))
109
					include("../lib/$config[general_lib_type]/delete_user.php");
110
			}
111
			$login=$tmp_group_name;
2654 tom.houday 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
			}
324 richard 117
		}
118
		if (is_file("../lib/$config[general_lib_type]/delete_group.php"))
119
			include("../lib/$config[general_lib_type]/delete_group.php");
120
	}
121
	echo <<<EOM
122
</td></tr>
123
</table>
124
</tr>
125
</table>
126
</body>
127
</html>
128
EOM;
129
	exit();
130
}
131
?>
132
   <form method=post>
133
      <input type=hidden name=login value=<?php print $login ?>>
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>
136
<tr>
137
<td align=center>
138
<?php
139
if ($user_type == 'group'){
911 richard 140
  echo "$l_group_members_remove : ";
324 richard 141
  echo "<input type=checkbox name=delete_users_of_group value=\"1\">";
142
}
143
echo "<br>";
911 richard 144
echo "$l_are_you_sure <b>$login</b> ? ";
324 richard 145
?>
911 richard 146
	<input type=submit class=button value="<?php echo"$l_yes_remove";?>" OnClick="this.form.delete_user.value=1">
324 richard 147
</form>
148
</td></tr></table></td></tr>
149
</table>
150
</tr>
151
</table>
152
</TD></TR>
153
</TABLE>
154
</td></tr>
155
</TABLE>
156
</body>
157
</html>