Delete trailing whitespace.
[freeradius.git] / dialup_admin / htdocs / user_edit.php3
1 <?php
2 require('../conf/config.php3');
3 require('../lib/attrshow.php3');
4 require('../lib/defaults.php3');
5 $extra_text = '';
6 if ($user_type != 'group'){
7         if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
8                 include("../lib/$config[general_lib_type]/user_info.php3");
9         if ($config[general_lib_type] == 'sql' && $config[sql_show_all_groups] == 'true'){
10                 $extra_text = "<br><font size=-2><i>(The groups that the user is a member of are highlated)</i></font>";
11                 $saved_login = $login;
12                 $login = '';
13                 if (is_file("../lib/sql/group_info.php3"))
14                         include("../lib/sql/group_info.php3");
15                 $login = $saved_login;
16         }
17 }
18 else{
19         if (is_file("../lib/$config[general_lib_type]/group_info.php3"))
20                 include("../lib/$config[general_lib_type]/group_info.php3");
21 }
22 if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
23         $colspan=2;
24         $show_ops = 1;
25         include("../lib/operators.php3");
26 }
27 else{
28         $show_ops = 0;
29         $colspan=1;
30 }
31
32
33 echo <<<EOM
34 <html>
35 <head>
36 EOM;
37
38 if ($user_type != 'group')
39         echo " <title>subscription configuration for $login ($cn)</title>\n";
40 else
41         echo " <title>subscription configuration for $login</title>\n";
42 ?>
43
44 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $config[general_charset]?>">
45 <link rel="stylesheet" href="style.css">
46 </head>
47 <body>
48 <center>
49 <table border=0 width=550 cellpadding=0 cellspacing=0>
50 <tr valign=top>
51 <td align=center><img src="images/title2.gif"></td>
52 </tr>
53 </table>
54 <table border=0 width=400 cellpadding=0 cellspacing=2>
55
56 <?php
57 if ($user_type != 'group')
58         include("../html/user_toolbar.html.php3");
59 else
60         include("../html/group_toolbar.html.php3");
61
62 print <<<EOM
63 </table>
64
65 <br>
66 <table border=0 width=540 cellpadding=1 cellspacing=1>
67 <tr valign=top>
68 <td width=75%>&nbsp;</td>
69 <td bgcolor="black" width=25% align=right>
70         <table border=0 width="200" cellpadding=2 cellspacing=0>
71         <tr bgcolor="#907030" align=center valign=top><th>
72         <font color="white">User Preferences for $login ($cn)</font>&nbsp;
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;
80
81 if ($change == 1){
82         if (is_file("../lib/$config[general_lib_type]/change_attrs.php3"))
83                 include("../lib/$config[general_lib_type]/change_attrs.php3");
84         if ($user_type != 'group'){
85                 if ($config[general_show_user_password] != 'no' && $passwd != ''
86                         && is_file("../lib/$config[general_lib_type]/change_passwd.php3"))
87                         include("../lib/$config[general_lib_type]/change_passwd.php3");
88                 if (is_file("../lib/$config[general_lib_type]/user_info.php3"))
89                         include("../lib/$config[general_lib_type]/user_info.php3");
90                 if ($group_change && $config[general_lib_type] == 'sql' && $config[sql_show_all_groups] == 'true'){
91                         include("../lib/sql/group_change.php3");
92                         include("../lib/defaults.php3");
93                 }
94         }
95         else{
96                 if (is_file("../lib/$config[general_lib_type]/group_info.php3"))
97                         include("../lib/$config[general_lib_type]/group_info.php3");
98         }
99 }
100 else if ($badusers == 1){
101         if (is_file("../lib/add_badusers.php3"))
102                 include("../lib/add_badusers.php3");
103 }
104
105 ?>
106    <form name="edituser" method=post>
107       <input type=hidden name=login value=<?php print $login ?>>
108       <input type=hidden name=user_type value=<?php print $user_type ?>>
109       <input type=hidden name=change value="0">
110       <input type=hidden name=add value="0">
111       <input type=hidden name=badusers value="0">
112       <input type=hidden name=group_change value="0">
113         <table border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
114 <?php
115 if ($user_type == 'group')
116         echo <<<EOM
117 Note: The attributes contained in the groups the user belongs to<br>
118 are extracted after the attributes in the radcheck/radreply tables.<br>
119 Please take that into consideration when adding attributes in the group<br>
120 and selecting operators.
121 <br>
122 EOM;
123 if ($user_type != 'group' && $config[general_show_user_password] != 'no'){
124         echo <<<EOM
125 <tr>
126 <td align=right colspan=$colspan bgcolor="#d0ddb0">
127 User Password (changes only)<br>
128 EOM;
129 if ($user_password_exists == 'yes')
130         echo "<font size=-2>User password <font color=\"green\"><b>exists</b></font></font>\n";
131 else
132         echo "<font size=-2>User password <font color=\"red\"><b>does not exist</b></font></font>\n";
133         echo <<<EOM
134 </td>
135 <td>
136 <input type=password name=passwd value="" size=40>
137 </td>
138 </tr>
139 EOM;
140 }
141         foreach($show_attrs as $key => $desc){
142                 $name = $attrmap["$key"];
143                 $generic = $attrmap[generic]["$key"];
144                 if ($name == 'none')
145                         continue;
146                 unset($vals);
147                 unset($selected);
148                 unset($ops);
149                 $def_added = 0;
150                 if ($item_vals["$key"][count]){
151                         for($i=0;$i<$item_vals["$key"][count];$i++){
152                                 $vals[] = $item_vals["$key"][$i];
153                                 $ops[] = $item_vals["$key"][operator][$i];
154                         }
155                 }
156                 else{
157                         if ($default_vals["$key"][count]){
158                                 for($i=0;$i<$default_vals["$key"][count];$i++){
159                                         $vals[] = $default_vals["$key"][$i];
160                                         $ops[] = $default_vals["$key"][operator][$i];
161                                 }
162                         }
163                         else{
164                                 $vals[] = '';
165                                 $ops[] = '=';
166                         }
167                         $def_added = 1;
168                 }
169                 if ($generic == 'generic' && $def_added == 0){
170                         for($i=0;$i<$default_vals["$key"][count];$i++){
171                                 $vals[] = $default_vals["$key"][$i];
172                                 $ops[] = $default_vals["$key"][operator][$i];
173                         }
174                 }
175                 if ($add && $name == $add_attr){
176                         $vals[] = $default_vals["$key"][0];
177                         $ops[] = ($default_vals["$key"][operator][0] != '') ? $default_vals["$key"][operator][0] : '=';
178                 }
179
180                 $i = 0;
181                 foreach($vals as $val){
182                         $name1 = $name . $i;
183                         $val = ereg_replace('"','&quot;',$val);
184                         $oper_name = $name1 . '_op';
185                         $oper = $ops[$i];
186                         $selected[$oper] = 'selected';
187                         $i++;
188                         print <<<EOM
189 <tr>
190 <td align=right bgcolor="#d0ddb0">
191 EOM;
192                         $desc = addslashes($desc);
193                         eval("\$desc = \"$desc\";");
194                         $desc = stripslashes($desc);
195                         if ($i == 1)
196                                 echo "$desc\n";
197                         else
198                                 echo "$desc ($i)\n";
199                         print <<<EOM
200 </td>
201 EOM;
202                         if ($show_ops)
203                                 print <<<EOM
204 <td>
205 <select name=$oper_name>
206 <option $selected[$op_eq] value="=">=
207 <option $selected[$op_set] value=":=">:=
208 <option $selected[$op_add] value="+=">+=
209 <option $selected[$op_eq2] value="==">==
210 <option $selected[$op_ne] value="!=">!=
211 <option $selected[$op_gt] value=">">&gt;
212 <option $selected[$op_ge] value=">=">&gt;=
213 <option $selected[$op_lt] value="<">&lt;
214 <option $selected[$op_le] value="<=">&lt;=
215 <option $selected[$op_regeq] value="=~">=~
216 <option $selected[$op_regne] value="!~">!~
217 <option $selected[$op_exst] value="=*">=*
218 <option $selected[$op_nexst] value="!*">!*
219 </select>
220 </td>
221 EOM;
222
223                         print <<<EOM
224 <td>
225 <input type=text name="$name1" value="$val" size=40>
226 </td>
227 </tr>
228 EOM;
229                 }
230         }
231 ?>
232 <tr>
233 <td align=right colspan=<?php print $colspan ?> bgcolor="#d0ddb0">
234 Add Attribute
235 </td>
236 <td>
237 <select name="add_attr" OnChange="this.form.add.value=1;this.form.submit()">
238 <?php
239 foreach ($show_attrs as $key => $desc){
240         $name = $attrmap["$key"];
241         print <<<EOM
242 <option value="$name">$desc
243 EOM;
244 }
245 ?>
246 </select>
247 </td>
248 </tr>
249
250 <?php
251 if (isset($member_groups)){
252         echo <<<EOM
253 <tr>
254 <td align=right colspan=$colspan bgcolor="#d0ddb0">
255 Member of $extra_text
256 </td>
257 <td>
258 <select size=2 name="edited_groups[]" multiple OnChange="this.form.group_change.value=1">
259 EOM;
260         if ($config[sql_show_all_groups] == 'true'){
261                 foreach ($existing_groups as $group => $count){
262                         if ($member_groups[$group] == $group)
263                                 echo "<option selected value=\"$group\">$group\n";
264                         else
265                                 echo "<option value=\"$group\">$group\n";
266                 }
267         }else{
268                 foreach ($member_groups as $group)
269                         echo "<option value=\"$group\">$group\n";
270         }
271         echo <<<EOM
272 </select>
273 </td>
274 </tr>
275 EOM;
276 }
277 ?>
278         </table>
279 <br>
280 <input type=submit class=button value=Change OnClick="this.form.change.value=1">
281 <?php
282 if ($user_type != 'group'){
283         echo <<<EOM
284 <br><br>
285 <input type=submit class=button value="Add to Badusers" OnClick="this.form.badusers.value=1">
286 <a href="help/badusers_help.html" target=bu_help onclick=window.open("help/badusers_help.html","bu_help","width=600,height=210,toolbar=no,scrollbars=no,resizable=yes") title="BADUSERS Help Page"><font color="blue">&lt;--Help</font></a>
287 EOM;
288 }
289 ?>
290 </form>
291         </td></tr>
292 </table>
293 </tr>
294 </table>
295 </body>
296 </html>