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