]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
* Do an eval on the attribute description strings in the user_edit page. That will...
authorkkalev <kkalev>
Sat, 1 Feb 2003 16:06:05 +0000 (16:06 +0000)
committerkkalev <kkalev>
Sat, 1 Feb 2003 16:06:05 +0000 (16:06 +0000)
  page to work properly.
* Add a login-time creation page which will allow the administrator to create the login-time string through a gui
  instead of writing it directly in UUCP format.

Changelog
conf/user_edit.attrs
htdocs/login_time_create.php3 [new file with mode: 0644]
htdocs/user_edit.php3

index a89d1083ea7efd27bc7f11d94d744be62e1883ef..1cb60ce9b4e8540d593d4f7a22325f7f48ec63c8 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,8 @@
+Ver 1.63:
+* Do an eval on the attribute description strings in the user_edit page. That will allow the login-time creation
+  page to work properly.
+* Add a login-time creation page which will allow the administrator to create the login-time string through a gui
+  instead of writing it directly in UUCP format.
 Ver 1.62:
 * Remove one sql query from user_admin which was not needed.
 * Instead of a query like "LIKE 'YYYY-MM-DD%'" use "AcctStopTime >= 'YYYY-MM-DD 00:00:00 AND AcctStopTime
index e5e564827f56bb88e73692d4e594c8c5ec48a929..ff5193e2e6a6b70f5480262324678bcd86d37f71 100644 (file)
@@ -37,7 +37,7 @@ Dialup-Lock-Msg                       <a href="help/lock_message_help.html" target=lm_help onclick=w
 #Reply-Message                 Reply Message
 #Max-Daily-Session             Daily Limit (secs)
 #Max-Weekly-Session            Weekly Limit (secs)
-#Login-Time                    User Login Period <a href="help/login_time_help.html" target=lt_help onclick=window.open("help/login_time_help.html","lt_help","width=600,height=370,toolbar=no,scrollbars=no,resizable=yes") title="Login-Time Help Page"><font color="blue">(UUCP Format)</font></a>
+#Login-Time                    <a href="login_time_create.php3?val=$name1&first=yes" target=lt_create onclick=window.open("login_time_create.php3?val=$name1&first=yes","lt_create","width=600,height=490,toolbar=no,scrollbars=yes,resizable=yes") title="Login-Time Creation Page"><font color="blue">User Login Period </font></a>(<a href="help/login_time_help.html" target=lt_help onclick=window.open("help/login_time_help.html","lt_help","width=600,height=370,toolbar=no,scrollbars=no,resizable=yes") title="Login-Time Help Page"><font color="blue">UUCP </font></a>Format)
 #Expiration                    <a href="help/expiration_help.html" target=lt_help onclick=window.open("help/expiration_help.html","lt_help","width=600,height=180,toolbar=no,scrollbars=no,resizable=yes") title="Expiration Help Page"><font color="blue">User Expiration Date</font></a>
 #
 # Uncomment this if you are using ldap and you are using user regular profiles.
diff --git a/htdocs/login_time_create.php3 b/htdocs/login_time_create.php3
new file mode 100644 (file)
index 0000000..cc28aa8
--- /dev/null
@@ -0,0 +1,280 @@
+<html>
+<head>
+<title>Login-Time Creation Page</title>
+<link rel="stylesheet" href="style.css">
+</head>
+<body bgcolor="#80a040" background="images/greenlines1.gif" link="black" alink="black">
+<?php
+
+function check_day($day){
+       switch($day){
+               case 'Mo':
+               case 'Tu':
+               case 'We':
+               case 'Th':
+               case 'Th':
+               case 'Fr':
+               case 'Sa':
+               case 'Su':
+               case 'Al':
+               case 'Any':
+               case 'Wk':
+                       return 1;
+                       break;
+               default:
+                       return 0;
+                       break;
+       }
+}
+
+$mapping = array(
+       'Mo' => 'Monday',
+       'Tu' => 'Tusday',
+       'We' => 'Wednesday',
+       'Th' => 'Thursday',
+       'Fr' => 'Friday',
+       'Sa' => 'Saturday',
+       'Su' => 'Sunday',
+       'Al' => 'All Days',
+       'Any' => 'All Days',
+       'Wk' => 'Weekdays');
+
+$rules = array();
+
+if ($add == 1){
+       if ($use == 'double' && $start_day != $stop_day){
+               $new = $start_day;
+               if ($stop_day != '')
+                       $new .= "-$stop_day";
+               if ($Dstart_time != '' && $Dstop_time != '')
+                       $new .= "$Dstart_time-$Dstop_time";
+       }
+       else if ($use == 'one'){
+               $new = $day;
+               if ($Mstart_time != '' && $Mstop_time != '')
+                       $new .= "$Mstart_time-$Mstop_time";
+       }
+       if ($new != ''){
+               if ($rulestr == '')
+                       $rulestr = $new;
+               else
+                       $rulestr .= ",$new";
+       }
+}
+$Mstart_time = $Mstop_time = $Dstart_time = $Dstop_time = '';
+
+
+if ($rulestr != '')
+       $rules1 = preg_split('/[,|]/',$rulestr);
+
+if ($rules1){
+       foreach ($rules1 as $rule){
+               if ($delete1 == 1 && $sel_rule == $rule)
+                       continue;
+               $matches = array();
+               if (preg_match('/^\w{2,3}$/',$rule)){
+                       if (!check_day($rule)){
+                               $err_msg .= "<b>Rule '$rule' is invalid</b><br>\n";
+                               continue;
+                       }
+                       if ($sel_rule == $rule || $sel_rule == ''){
+                               $checked[one] = 'checked';
+                               $selected_more[$rule] = 'selected';
+                       }
+                       $msg = $mapping[$rule];
+               }
+               else if (preg_match('/^(\w{2,3})(\d{4})-(\d{4})$/',$rule,$matches)){
+                       if (!check_day($matches[1])){
+                               $err_msg .= "<b>Rule '$rule' is invalid</b><br>\n";
+                               continue;
+                       }
+                       if ($sel_rule == $rule || $sel_rule == ''){
+                               $checked[one] = 'checked';
+                               $selected_more[$matches[1]] = 'selected';
+                               $Mstart_time = $matches[2];
+                               $Mstop_time = $matches[3];
+                       }
+                       $msg = $mapping[$matches[1]] . " $matches[2] - $matches[3]";
+               }
+               else if (preg_match('/^(\w{2,3})-(\w{2,3})$/',$rule,$matches)){
+                       if (!check_day($matches[1]) || !check_day($matches[2])){
+                               $err_msg .= "<b>Rule '$rule' is invalid</b><br>\n";
+                               continue;
+                       }
+                       if ($sel_rule == $rule || $sel_rule == ''){
+                               $checked[double] = 'checked';
+                               $selected_start[$matches[1]] = 'selected';
+                               $selected_stop[$matches[2]] = 'selected';
+                       }
+                       $msg = $mapping[$matches[1]] . " - " . $mapping[$matches[2]];
+               }
+               else if (preg_match('/^(\w{2,3})-(\w{2,3})(\d{4})-(\d{4})$/',$rule,$matches)){
+                       if (!check_day($matches[1]) || !check_day($matches[2])){
+                               $err_msg .= "<b>Rule '$rule' is invalid</b><br>\n";
+                               continue;
+                       }
+                       if ($sel_rule == $rule || $sel_rule == ''){
+                               $checked[double] = 'checked';
+                               $selected_start[$matches[1]] = 'selected';
+                               $selected_stop[$matches[2]] = 'selected';
+                               $Dstart_time = $matches[3];
+                               $Dstop_time = $matches[4];
+                       }
+                       $msg = $mapping[$matches[1]] . " - " . $mapping[$matches[2]] . " $matches[3] - $matches[4]";
+               }
+               else{
+                       $err_msg .= "<b>Rule $rule is invalid</b><br>\n";
+                       continue;
+               }
+               array_push($rules,$rule);
+               $rule_msgs[$rule] = $msg;
+       }
+}
+if ($sel_rule != '')
+       $selected_rule[$sel_rule] = 'selected';
+else
+       $Mstart_time = $Mstop_time = $Dstart_time = $Dstop_time = '';
+
+$rulestr = '';
+foreach ($rules as $rule){
+       if ($rulestr == '')
+               $rulestr = "$rule";
+       else
+               $rulestr .= ",$rule";
+} 
+if ($update == 1 && $val != '')
+       echo <<<EOM
+<script language="JavaScript1.1" type="text/javascript">
+window.opener.document.edituser.$val.value = "$rulestr";
+window.close();
+</script>
+EOM;
+
+if ($checked[double] == '' && $checked[one] == '')
+       $checked[double] = 'checked';
+
+?>
+<center>
+<table border=0 width=540 cellpadding=1 cellspacing=1>
+<tr valign=top>
+<td width=340></td>
+<td bgcolor="black" width=400>
+       <table border=0 width=100% cellpadding=2 cellspacing=0>
+       <tr bgcolor="#907030" align=right valign=top><th><font color="white">Login-Time Create Page</font>&nbsp;</th></tr>
+       </table>
+</td></tr>
+<form name=ruleform method=post action="login_time_create.php3">
+<input type=hidden name=add value="0">
+<input type=hidden name=delete1 value="0">
+<input type=hidden name=update value="0">
+<input type=hidden name=val value="<?php echo $val?>">
+<tr bgcolor="black" valign=top><td colspan=2>
+       <table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
+       <tr><td align=center>
+<table width=90%>
+<tr>
+<td>&nbsp;</td>
+<td><b>Start Day</b></td>
+<td><b>Stop Day</b></td>
+<td align=center><b>Time (HHMM)</b></td>
+</tr>
+<tr>
+
+<?php
+       echo <<<EOM
+<td><input type=radio name=use value=double $checked[double]>&nbsp;<b>Range</b></td>
+<td><select name=start_day OnClick="this.form.use[0].checked=true;this.form.Mstart_time.value='';this.form.Mstop_time.value=''">
+<option value="Mo" $selected_start[Mo]>Monday
+<option value="Tu" $selected_start[Tu]>Tuesday
+<option value="We" $selected_start[We]>Wednesday
+<option value="Th" $selected_start[Th]>Thursday
+<option value="Fr" $selected_start[Fr]>Friday
+<option value="Sa" $selected_start[Sa]>Saturday
+<option value="Su" $selected_start[Su]>Sunday
+</select></td>
+<td><select name=stop_day OnClick="this.form.use[0].checked=true;this.form.Mstart_time.value='';this.form.Mstop_time.value=''">
+<option value="Mo" $selected_stop[Mo]>Monday
+<option value="Tu" $selected_stop[Tu]>Tuesday
+<option value="We" $selected_stop[We]>Wednesday
+<option value="Th" $selected_stop[Th]>Thursday
+<option value="Fr" $selected_stop[Fr]>Friday
+<option value="Sa" $selected_stop[Sa]>Saturday
+<option value="Su" $selected_stop[Su]>Sunday
+</select></td>
+<td align=right><input type=text name=Dstart_time size=4 value="$Dstart_time" OnClick="this.form.use[0].checked=true;this.form.Mstart_time.value='';this.form.Mstop_time.value=''">
+&nbsp;-&nbsp;
+<input type=text name=Dstop_time size=4 value="$Dstop_time" OnClick="this.form.use[0].checked=true;this.form.Mstart_time.value='';this.form.Mstop_time.value=''"></td>
+</tr>
+<tr>
+<td><input type=radio name=use value=one $checked[one]>&nbsp;<b>Specific</b></td>
+<td><select name=day OnClick="this.form.use[1].checked=true;this.form.Dstart_time.value='';this.form.Dstop_time.value=''">
+<option value="Mo" $selected_more[Mo]>Monday
+<option value="Tu" $selected_more[Tu]>Tuesday
+<option value="We" $selected_more[We]>Wednesday
+<option value="Th" $selected_more[Th]>Thursday
+<option value="Fr" $selected_more[Fr]>Friday
+<option value="Sa" $selected_more[Sa]>Saturday
+<option value="Su" $selected_more[Su]>Sunday
+<option value="Wk" $selected_more[Wk]>Weekdays
+<option value="Al" $selected_more[Al]>All Days
+</select></td>
+<td colspan=2 align=right><input type=text name=Mstart_time size=4 value="$Mstart_time" OnClick="this.form.use[1].checked=true;this.form.Dstart_time.value='';this.form.Dstop_time.value=''">
+&nbsp;-&nbsp;
+<input type=text name=Mstop_time size=4 value="$Mstop_time" OnClick="this.form.use[1].checked=true;this.form.Dstart_time.value='';this.form.Dstop_time.value=''"></td>
+</tr>
+EOM;
+?>
+
+<tr><td>&nbsp;</td></tr>
+<tr><td colspan=5 align=center>
+<input type=submit class=button value=" + " OnClick="this.form.add.value=1">
+&nbsp;&nbsp;&nbsp;
+<input type=submit class=button value=" - " OnClick="this.form.delete1.value=1">
+</td></tr>
+<tr><td colspan=5 align=center>
+<br>
+<b>Rule Set</b>
+</td></tr>
+<tr><td colspan=5 align=center>
+<?php
+if (!empty($rules)){
+       echo "<select name=\"sel_rule\" size=5 multi OnChange=\"this.form.submit()\">\n";
+       foreach ($rules as $rule)
+               echo "<option value=\"$rule\" $selected_rule[$rule]>$rule_msgs[$rule]\n";
+       echo "</select>\n";
+}
+else
+       echo "<i>No rules available</i><br>\n"; 
+?>
+</td></tr>
+<tr><td colspan=5 align=center><?php echo $err_msg ?></td></tr>
+<tr><td>&nbsp;</td></tr>
+<tr><td colspan=5 align=center><b>Rule string (<a href="help/login_time_help.html" target=lt_help onclick=window.open("login_time_help.html","lt_help","width=600,height=370,toolbar=no,scrollbars=no,resizable=yes") title="Login-Time Help Page"><font color="blue">UUCP Format</font></a>)</b></td></tr>
+<tr><td colspan=5 align=center>
+<input type=text name=rulestr value="<?php echo $rulestr ?>" size=40 OnChange="this.form.submit()">
+</td></tr>
+<tr><td>&nbsp;</td></tr>
+<tr><td colspan=5 align=center>
+<input type=submit class=button value="Update Attribute in User Edit page" OnClick="this.form.update.value=1">
+</td></tr>
+</table>
+<?php
+if ($rulestr == '' && $first == 'yes')
+       echo <<<EOM
+<script language="JavaScript1.1" type="text/javascript">
+window.document.ruleform.rulestr.value=window.opener.document.edituser.$val.value;
+window.document.ruleform.submit();
+</script>
+EOM;
+?>
+</form>
+</td></tr>
+<tr><td align=center>
+<a href="javascript:window.close();"><b>Close Window</b></a>
+</td></tr>
+</center>
+</table>
+</tr>
+</table>
+</body>
+</html>
index 1c18c6ae42a857797086c7aa65da9db357b9942f..f4cd8df44fc87eb9de0a577cc982f6e779d45662 100644 (file)
@@ -92,7 +92,7 @@ else if ($badusers == 1){
 }
        
 ?>
-   <form method=post>
+   <form name="edituser" method=post>
       <input type=hidden name=login value=<?php print $login ?>>
       <input type=hidden name=user_type value=<?php print $user_type ?>>
       <input type=hidden name=change value="0">
@@ -177,6 +177,9 @@ EOM;
 <tr>
 <td align=right bgcolor="#d0ddb0">
 EOM;
+                       $desc = addslashes($desc);
+                       eval("\$desc = \"$desc\";");
+                       $desc = stripslashes($desc);
                        if ($i == 1)
                                echo "$desc\n";
                        else