summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-03-07 23:12:41 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-03-07 23:12:41 +0000
commit9699028a571f1df9bd54799a8df0b97d03f6901b (patch)
tree44b7a6d30f21088895656ad7f0e9395c6f606f3a /usr
parent90b7aa76dae8c8436f968d2cb47f25a1c52ef989 (diff)
downloadpfsense-9699028a571f1df9bd54799a8df0b97d03f6901b.zip
pfsense-9699028a571f1df9bd54799a8df0b97d03f6901b.tar.gz
Add local user manager code imported from Pascal Suter's m0n0wall developers group message.
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/captiveportal/index.php126
-rwxr-xr-xusr/local/www/datetimepicker.js483
-rwxr-xr-xusr/local/www/services_captiveportal.php163
-rwxr-xr-xusr/local/www/services_usermanager.php191
4 files changed, 870 insertions, 93 deletions
diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php
index dcff86f..c51c073 100755
--- a/usr/local/captiveportal/index.php
+++ b/usr/local/captiveportal/index.php
@@ -27,6 +27,10 @@
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
+
+ This version of index.php has been modified by Rob Parker
+ <rob.parker@keycom.co.uk>. Changes made are in relation to Per-User Bandwidth
+ Management based on returned RADIUS attributes, and are (c) 2004 Keycom PLC.
*/
require("globals.inc");
@@ -44,7 +48,6 @@ $orig_host = $_ENV['HTTP_HOST'];
$orig_request = $_ENV['CAPTIVE_REQPATH'];
$lockfile = "{$g['varrun_path']}/captiveportal.lock";
$clientip = $_ENV['REMOTE_ADDR'];
-$portalip = $_ENV['SERVER_ADDR'];
if (!$clientip) {
/* not good - bail out */
@@ -58,44 +61,43 @@ if (!$clientmac && !isset($config['captiveportal']['nomacfilter'])) {
exit;
}
-/* find MAC address for portal */
-$iflist = get_interface_list();
-$portalmac = $iflist[ $config['interfaces'][$config['captiveportal']['interface']]['if'] ]['mac'];
-
if ($clientmac && portal_mac_fixed($clientmac)) {
/* punch hole in ipfw for pass thru mac addresses */
- portal_allow($clientip, $clientmac, "unauthenticated");
+ // KEYCOM: passthru mac bandwidth control]
+ if (isset($config['captiveportal']['peruserbw'])) {
+ portal_allow($clientip, $clientmac, "unauthenticated",$config['captiveportal']['bwauthmacup'],$config['captiveportal']['bwauthmacdn']);
+ } else {
+ portal_allow($clientip, $clientmac, "unauthenticated",0,0);
+ }
} else if ($_POST['accept'] && file_exists("{$g['vardb_path']}/captiveportal_radius.db")) {
/* authenticate against radius server */
$radiusservers = captiveportal_get_radius_servers();
- /* determine port type */
- $port_type = 15; // default to ethernet
- if ($config['interfaces'][ $config['captiveportal']['interface'] ]['wireless']) {
- $port_type = 19; // wireless
- }
-
if ($_POST['auth_user'] && $_POST['auth_pass']) {
$auth_val = RADIUS_AUTHENTICATION($_POST['auth_user'],
$_POST['auth_pass'],
- $port_type,
$radiusservers[0]['ipaddr'],
$radiusservers[0]['port'],
$radiusservers[0]['key']);
+ $auth_returns = explode("/", $auth_val);
+ $auth_val = $auth_returns[0];
+ $bw_up = $auth_returns[1];
+ $bw_down = $auth_returns[2];
if ($auth_val == 2) {
- $sessionid = portal_allow($clientip, $clientmac, $_POST['auth_user']);
+ if (isset($config['captiveportal']['peruserbw'])) {
+ $sessionid = portal_allow($clientip, $clientmac, $_POST['auth_user'],$bw_up,$bw_down);
+ } else {
+ $sessionid = portal_allow($clientip, $clientmac, $_POST['auth_user'],0,0);
+ }
if (isset($config['captiveportal']['radacct_enable']) && isset($radiusservers[0])) {
$auth_val = RADIUS_ACCOUNTING_START($_POST['auth_user'],
$sessionid,
- $port_type,
- $clientmac,
- $clientip,
- $portalmac,
$radiusservers[0]['ipaddr'],
$radiusservers[0]['acctport'],
- $radiusservers[0]['key']);
+ $radiusservers[0]['key'],
+ $clientip);
}
} else {
readfile("{$g['varetc_path']}/captiveportal-error.html");
@@ -104,8 +106,34 @@ if ($clientmac && portal_mac_fixed($clientmac)) {
readfile("{$g['varetc_path']}/captiveportal-error.html");
}
+} else if ($_POST['accept'] && $config['captiveportal']['auth_method']=="local") {
+ //check against local usermanager
+
+ //erase expired accounts
+ if(trim($config['users'][$_POST['auth_user']]['expirationdate'])!="" && strtotime("-1 day")>strtotime($config['users'][$_POST['auth_user']]['expirationdate'])){
+ unset($config['users'][$_POST['auth_user']]);
+ write_config();
+ }
+ if($config['users'][$_POST['auth_user']]['password']==md5($_POST['auth_pass'])){
+ portal_allow($clientip, $clientmac,$_POST['auth_user'],0,0);
+ } else {
+ readfile("{$g['varetc_path']}/captiveportal-error.html");
+ }
} else if ($_POST['accept'] && $clientip) {
- portal_allow($clientip, $clientmac, "unauthenticated");
+ //KEYCOM: authorised up and down bandwidth defaults (set from webgui). If not set, use 128/128
+ if (isset($config['captiveportal']['peruserbw'])) {
+ $bw_up=$config['captiveportal']['bwauthipup'];
+ $bw_down=$config['captiveportal']['bwauthipdn'];
+ if(!isset($bw_up)) {
+ $bw_up=128;
+ }
+ if(!isset($bw_down)) {
+ $bw_down=128;
+ }
+ portal_allow($clientip, $clientmac, "unauthenticated",$bw_up,$bw_down);
+ } else {
+ portal_allow($clientip, $clientmac, "unauthenticated",0,0);
+ }
} else if ($_POST['logout_id']) {
disconnect_client($_POST['logout_id']);
echo <<<EOD
@@ -135,7 +163,7 @@ EOD;
if (isset($config['captiveportal']['httpslogin']))
$htmltext = str_replace("\$PORTAL_ACTION\$", "https://{$config['captiveportal']['httpsname']}:8001/", $htmltext);
else
- $htmltext = str_replace("\$PORTAL_ACTION\$", "http://{$config['interfaces'][$config['captiveportal']['interface']]['ipaddr']}:8000/", $htmltext);
+ $htmltext = str_replace("\$PORTAL_ACTION\$", "", $htmltext);
if (preg_match("/redirurl=(.*)/", $orig_request, $matches))
$redirurl = urldecode($matches[1]);
@@ -169,7 +197,7 @@ function portal_mac_fixed($clientmac) {
return FALSE ;
}
-function portal_allow($clientip,$clientmac,$clientuser) {
+function portal_allow($clientip,$clientmac,$clientuser,$bw_up,$bw_down) {
global $orig_host, $orig_request, $g, $config;
@@ -191,6 +219,26 @@ function portal_allow($clientip,$clientmac,$clientuser) {
/* add ipfw rules for layer 3 */
exec("/sbin/ipfw add $ruleno set 2 skipto 50000 ip from $clientip to any in");
exec("/sbin/ipfw add $ruleno set 2 skipto 50000 ip from any to $clientip out");
+
+ /* KEYCOM: add ipfw rules for dummynet based on bw_up and bw_down */
+ //we're just copying them by adding on some and hoping no collision will occur
+ //2000 users would be expecting a bit much from a WAP ;)
+
+ //we're using fixed rule numbers which are 'a step above' the m0n0 ones
+ //this makes sure we always know where our rules are, and taht they are deleted when m0n0's are
+ //they're set so they shouldn't hit anything important, and also so they are in roughly the right position in the fw.
+
+ //of course, we only need to do this if it's enabled in the config
+ if (isset($config['captiveportal']['peruserbw'])) {
+ $up_rule_number = $ruleno + 40500;
+ $down_rule_number = $ruleno + 45500;
+ $lanif = $config['interfaces']['lan']['if'];
+ exec("/sbin/ipfw add $up_rule_number set 4 pipe $up_rule_number ip from $clientip to any via $lanif");
+ exec("/sbin/ipfw add $down_rule_number set 4 pipe $down_rule_number ip from any to $clientip via $lanif");
+ exec("/sbin/ipfw pipe $up_rule_number config bw " . trim($bw_up) . "Kbit/s queue 10");
+ exec("/sbin/ipfw pipe $down_rule_number config bw " . trim($bw_down) . "Kbit/s queue 10");
+ }
+ /* done */
/* add ipfw rules for layer 2 */
if (!isset($config['captiveportal']['nomacfilter'])) {
@@ -219,21 +267,23 @@ function portal_allow($clientip,$clientmac,$clientuser) {
for ($i = 0; $i < count($cpdb); $i++) {
if(!strcasecmp($cpdb[$i][2],$clientip)) {
if(isset($config['captiveportal']['radacct_enable']) && isset($radiusservers[0])) {
- $port_type = 15; // default to ethernet
- if (isset($config['interfaces'][ $config['captiveportal']['interface'] ]['wireless'])) {
- $port_type = 19; // wireless
- }
-
RADIUS_ACCOUNTING_STOP($cpdb[$i][1], // ruleno
$cpdb[$i][4], // username
$cpdb[$i][5], // sessionid
$cpdb[$i][0], // start time
- $port_type,
$radiusservers[0]['ipaddr'],
$radiusservers[0]['acctport'],
- $radiusservers[0]['key']);
+ $radiusservers[0]['key'],
+ $clientip);
+ }
+ //KEYCOM: we need to delete +40500 and +45500 as well...
+ //these are the rule numbers we use to control traffic shaping for each logged in user via captive portal
+ mwexec("/sbin/ipfw delete " . $cpdb[$i][1]);
+ //we only need to remove our rules if peruserbw is turned on.
+ if(isset($config['captiveportal']['peruserbw'])) {
+ mwexec("/sbin/ipfw delete " . ($cpdb[$i][1]+40500));
+ mwexec("/sbin/ipfw delete " . ($cpdb[$i][1]+45500));
}
- mwexec("/sbin/ipfw delete " . $cpdb[$i][1] . " " . ($cpdb[$i][1]+10000));
unset($cpdb[$i]);
break;
}
@@ -401,23 +451,21 @@ function disconnect_client($sessionid) {
if ($cpdb[$i][5] == $sessionid) {
/* this client needs to be deleted - remove ipfw rules */
if(isset($config['captiveportal']['radacct_enable']) && isset($radiusservers[0])) {
-
- /* determine port type */
- $port_type = 15; // default to ethernet
- if ($config['interfaces'][ $config['captiveportal']['interface'] ]['wireless']) {
- $port_type = 19; // wireless
- }
-
RADIUS_ACCOUNTING_STOP($cpdb[$i][1], // ruleno
$cpdb[$i][4], // username
$cpdb[$i][5], // sessionid
$cpdb[$i][0], // start time
- $port_type,
$radiusservers[0]['ipaddr'],
$radiusservers[0]['acctport'],
- $radiusservers[0]['key']);
+ $radiusservers[0]['key'],
+ $clientip);
}
+ //again we need to remve +40500 and +45500 as well, if they exist
mwexec("/sbin/ipfw delete " . $cpdb[$i][1] . " " . ($cpdb[$i][1]+10000));
+ if(isset($config['captiveportal']['peruserbw'])) {
+ mwexec("/sbin/ipfw delete " . ($cpdb[$i][1]+40500));
+ mwexec("/sbin/ipfw delete " . ($cpdb[$i][1]+45500));
+ }
unset($cpdb[$i]);
break;
}
diff --git a/usr/local/www/datetimepicker.js b/usr/local/www/datetimepicker.js
new file mode 100755
index 0000000..a0f5a9c
--- /dev/null
+++ b/usr/local/www/datetimepicker.js
@@ -0,0 +1,483 @@
+//Javascript name: My Date Time Picker
+//Date created: 16-Nov-2003 23:19
+//Scripter: TengYong Ng
+//Website: http://www.rainforestnet.com
+//Copyright (c) 2003 TengYong Ng
+//FileName: DateTimePicker.js
+//Version: 0.8
+//Contact: contact@rainforestnet.com
+// Note: Permission given to use this script in ANY kind of applications if
+// header lines are left unchanged.
+
+//Global variables
+var winCal;
+var dtToday=new Date();
+var Cal;
+var docCal;
+var MonthName=["January", "February", "March", "April", "May", "June","July",
+ "August", "September", "October", "November", "December"];
+var WeekDayName=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
+var exDateTime;//Existing Date and Time
+
+//Configurable parameters
+var cnTop="200";//top coordinate of calendar window.
+var cnLeft="500";//left coordinate of calendar window
+var WindowTitle ="DateTime Picker";//Date Time Picker title.
+var WeekChar=2;//number of character for week day. if 2 then Mo,Tu,We. if 3 then Mon,Tue,Wed.
+var CellWidth=20;//Width of day cell.
+var DateSeparator="/";//Date Separator, you can change it to "/" if you want.
+var TimeMode=24;//default TimeMode value. 12 or 24
+
+var ShowLongMonth=true;//Show long month name in Calendar header. example: "January".
+var ShowMonthYear=true;//Show Month and Year in Calendar header.
+var MonthYearColor="#cc0033";//Font Color of Month and Year in Calendar header.
+var WeekHeadColor="#0099CC";//Background Color in Week header.
+var SundayColor="#6699FF";//Background color of Sunday.
+var SaturdayColor="#CCCCFF";//Background color of Saturday.
+var WeekDayColor="white";//Background color of weekdays.
+var FontColor="blue";//color of font in Calendar day cell.
+var TodayColor="#FFFF33";//Background color of today.
+var SelDateColor="#FFFF99";//Backgrond color of selected date in textbox.
+var YrSelColor="#cc0033";//color of font of Year selector.
+var ThemeBg="";//Background image of Calendar window.
+//end Configurable parameters
+//end Global variable
+
+function NewCal(pCtrl,pFormat,pShowTime,pTimeMode)
+{
+ Cal=new Calendar(dtToday);
+ if ((pShowTime!=null) && (pShowTime))
+ {
+ Cal.ShowTime=true;
+ if ((pTimeMode!=null) &&((pTimeMode=='12')||(pTimeMode=='24')))
+ {
+ TimeMode=pTimeMode;
+ }
+ }
+ if (pCtrl!=null)
+ Cal.Ctrl=pCtrl;
+ if (pFormat!=null)
+ Cal.Format=pFormat.toUpperCase();
+
+ exDateTime=document.getElementById(pCtrl).value;
+ if (exDateTime!="")//Parse Date String
+ {
+ var Sp1;//Index of Date Separator 1
+ var Sp2;//Index of Date Separator 2
+ var tSp1;//Index of Time Separator 1
+ var tSp1;//Index of Time Separator 2
+ var strMonth;
+ var strDate;
+ var strYear;
+ var intMonth;
+ var YearPattern;
+ var strHour;
+ var strMinute;
+ var strSecond;
+ //parse month
+ Sp1=exDateTime.indexOf(DateSeparator,0)
+ Sp2=exDateTime.indexOf(DateSeparator,(parseInt(Sp1)+1));
+
+ if ((Cal.Format.toUpperCase()=="DDMMYYYY") || (Cal.Format.toUpperCase()=="DDMMMYYYY"))
+ {
+ strMonth=exDateTime.substring(Sp1+1,Sp2);
+ strDate=exDateTime.substring(0,Sp1);
+ }
+ else if ((Cal.Format.toUpperCase()=="MMDDYYYY") || (Cal.Format.toUpperCase()=="MMMDDYYYY"))
+ {
+ strMonth=exDateTime.substring(0,Sp1);
+ strDate=exDateTime.substring(Sp1+1,Sp2);
+ }
+ if (isNaN(strMonth))
+ intMonth=Cal.GetMonthIndex(strMonth);
+ else
+ intMonth=parseInt(strMonth,10)-1;
+ if ((parseInt(intMonth,10)>=0) && (parseInt(intMonth,10)<12))
+ Cal.Month=intMonth;
+ //end parse month
+ //parse Date
+ if ((parseInt(strDate,10)<=Cal.GetMonDays()) && (parseInt(strDate,10)>=1))
+ Cal.Date=strDate;
+ //end parse Date
+ //parse year
+ strYear=exDateTime.substring(Sp2+1,Sp2+5);
+ YearPattern=/^\d{4}$/;
+ if (YearPattern.test(strYear))
+ Cal.Year=parseInt(strYear,10);
+ //end parse year
+ //parse time
+ if (Cal.ShowTime==true)
+ {
+ tSp1=exDateTime.indexOf(":",0)
+ tSp2=exDateTime.indexOf(":",(parseInt(tSp1)+1));
+ strHour=exDateTime.substring(tSp1,(tSp1)-2);
+ Cal.SetHour(strHour);
+ strMinute=exDateTime.substring(tSp1+1,tSp2);
+ Cal.SetMinute(strMinute);
+ strSecond=exDateTime.substring(tSp2+1,tSp2+3);
+ Cal.SetSecond(strSecond);
+ }
+ }
+ winCal=window.open("","DateTimePicker","toolbar=0,status=0,menubar=0,fullscreen=no,width=195,height=245,resizable=0,top="+cnTop+",left="+cnLeft);
+ docCal=winCal.document;
+ RenderCal();
+}
+
+function RenderCal()
+{
+ var vCalHeader;
+ var vCalData;
+ var vCalTime;
+ var i;
+ var j;
+ var SelectStr;
+ var vDayCount=0;
+ var vFirstDay;
+
+ docCal.open();
+ docCal.writeln("<html><head><title>"+WindowTitle+"</title>");
+ docCal.writeln("<script>var winMain=window.opener;</script>");
+ docCal.writeln("</head><body background='"+ThemeBg+"' link="+FontColor+" vlink="+FontColor+"><form name='Calendar'>");
+
+ vCalHeader="<table border=1 cellpadding=1 cellspacing=1 width='100%' align=\"center\" valign=\"top\">\n";
+ //Month Selector
+ vCalHeader+="<tr>\n<td colspan='7'><table border=0 width='100%' cellpadding=0 cellspacing=0><tr><td align='left'>\n";
+ vCalHeader+="<select name=\"MonthSelector\" onChange=\"javascript:winMain.Cal.SwitchMth(this.selectedIndex);winMain.RenderCal();\">\n";
+ for (i=0;i<12;i++)
+ {
+ if (i==Cal.Month)
+ SelectStr="Selected";
+ else
+ SelectStr="";
+ vCalHeader+="<option "+SelectStr+" value >"+MonthName[i]+"\n";
+ }
+ vCalHeader+="</select></td>";
+ //Year selector
+ vCalHeader+="\n<td align='right'><a href=\"javascript:winMain.Cal.DecYear();winMain.RenderCal()\"><b><font color=\""+YrSelColor+"\"><</font></b></a><font face=\"Verdana\" color=\""+YrSelColor+"\" size=2><b> "+Cal.Year+" </b></font><a href=\"javascript:winMain.Cal.IncYear();winMain.RenderCal()\"><b><font color=\""+YrSelColor+"\">></font></b></a></td></tr></table></td>\n";
+ vCalHeader+="</tr>";
+ //Calendar header shows Month and Year
+ if (ShowMonthYear)
+ vCalHeader+="<tr><td colspan='7'><font face='Verdana' size='2' align='center' color='"+MonthYearColor+"'><b>"+Cal.GetMonthName(ShowLongMonth)+" "+Cal.Year+"</b></font></td></tr>\n";
+ //Week day header
+ vCalHeader+="<tr bgcolor="+WeekHeadColor+">";
+ for (i=0;i<7;i++)
+ {
+ vCalHeader+="<td align='center'><font face='Verdana' size='2'>"+WeekDayName[i].substr(0,WeekChar)+"</font></td>";
+ }
+ vCalHeader+="</tr>";
+ docCal.write(vCalHeader);
+
+ //Calendar detail
+ CalDate=new Date(Cal.Year,Cal.Month);
+ CalDate.setDate(1);
+ vFirstDay=CalDate.getDay();
+ vCalData="<tr>";
+ for (i=0;i<vFirstDay;i++)
+ {
+ vCalData=vCalData+GenCell();
+ vDayCount=vDayCount+1;
+ }
+ for (j=1;j<=Cal.GetMonDays();j++)
+ {
+ var strCell;
+ vDayCount=vDayCount+1;
+ if ((j==dtToday.getDate())&&(Cal.Month==dtToday.getMonth())&&(Cal.Year==dtToday.getFullYear()))
+ strCell=GenCell(j,true,TodayColor);//Highlight today's date
+ else
+ {
+ if (j==Cal.Date)
+ {
+ strCell=GenCell(j,true,SelDateColor);
+ }
+ else
+ {
+ if (vDayCount%7==0)
+ strCell=GenCell(j,false,SaturdayColor);
+ else if ((vDayCount+6)%7==0)
+ strCell=GenCell(j,false,SundayColor);
+ else
+ strCell=GenCell(j,null,WeekDayColor);
+ }
+ }
+ vCalData=vCalData+strCell;
+
+ if((vDayCount%7==0)&&(j<Cal.GetMonDays()))
+ {
+ vCalData=vCalData+"</tr>\n<tr>";
+ }
+ }
+ docCal.writeln(vCalData);
+ //Time picker
+ if (Cal.ShowTime)
+ {
+ var showHour;
+ showHour=Cal.getShowHour();
+ vCalTime="<tr>\n<td colspan='7' align='center'>";
+ vCalTime+="<input type='text' name='hour' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+showHour+" onchange=\"javascript:winMain.Cal.SetHour(this.value)\">";
+ vCalTime+=" : ";
+ vCalTime+="<input type='text' name='minute' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+Cal.Minutes+" onchange=\"javascript:winMain.Cal.SetMinute(this.value)\">";
+ vCalTime+=" : ";
+ vCalTime+="<input type='text' name='second' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+Cal.Seconds+" onchange=\"javascript:winMain.Cal.SetSecond(this.value)\">";
+ if (TimeMode==12)
+ {
+ var SelectAm =(parseInt(Cal.Hours,10)<12)? "Selected":"";
+ var SelectPm =(parseInt(Cal.Hours,10)>=12)? "Selected":"";
+
+ vCalTime+="<select name=\"ampm\" onchange=\"javascript:winMain.Cal.SetAmPm(this.options[this.selectedIndex].value);\">";
+ vCalTime+="<option "+SelectAm+" value=\"AM\">AM</option>";
+ vCalTime+="<option "+SelectPm+" value=\"PM\">PM<option>";
+ vCalTime+="</select>";
+ }
+ vCalTime+="\n</td>\n</tr>";
+ docCal.write(vCalTime);
+ }
+ //end time picker
+ docCal.writeln("\n</table>");
+ docCal.writeln("</form></body></html>");
+ docCal.close();
+}
+
+function GenCell(pValue,pHighLight,pColor)//Generate table cell with value
+{
+ var PValue;
+ var PCellStr;
+ var vColor;
+ var vHLstr1;//HighLight string
+ var vHlstr2;
+ var vTimeStr;
+
+ if (pValue==null)
+ PValue="";
+ else
+ PValue=pValue;
+
+ if (pColor!=null)
+ vColor="bgcolor=\""+pColor+"\"";
+ else
+ vColor="";
+ if ((pHighLight!=null)&&(pHighLight))
+ {vHLstr1="color='red'><b>";vHLstr2="</b>";}
+ else
+ {vHLstr1=">";vHLstr2="";}
+
+ if (Cal.ShowTime)
+ {
+ vTimeStr="winMain.document.getElementById('"+Cal.Ctrl+"').value+=' '+"+"winMain.Cal.getShowHour()"+"+':'+"+"winMain.Cal.Minutes"+"+':'+"+"winMain.Cal.Seconds";
+ if (TimeMode==12)
+ vTimeStr+="+' '+winMain.Cal.AMorPM";
+ }
+ else
+ vTimeStr="";
+ PCellStr="<td "+vColor+" width="+CellWidth+" align='center'><font face='verdana' size='2'"+vHLstr1+"<a href=\"javascript:winMain.document.getElementById('"+Cal.Ctrl+"').value='"+Cal.FormatDate(PValue)+"';"+vTimeStr+";window.close();\">"+PValue+"</a>"+vHLstr2+"</font></td>";
+ return PCellStr;
+}
+
+function Calendar(pDate,pCtrl)
+{
+ //Properties
+ this.Date=pDate.getDate();//selected date
+ this.Month=pDate.getMonth();//selected month number
+ this.Year=pDate.getFullYear();//selected year in 4 digits
+ this.Hours=pDate.getHours();
+
+ if (pDate.getMinutes()<10)
+ this.Minutes="0"+pDate.getMinutes();
+ else
+ this.Minutes=pDate.getMinutes();
+
+ if (pDate.getSeconds()<10)
+ this.Seconds="0"+pDate.getSeconds();
+ else
+ this.Seconds=pDate.getSeconds();
+
+ this.MyWindow=winCal;
+ this.Ctrl=pCtrl;
+ this.Format="ddMMyyyy";
+ this.Separator=DateSeparator;
+ this.ShowTime=false;
+ if (pDate.getHours()<12)
+ this.AMorPM="AM";
+ else
+ this.AMorPM="PM";
+}
+
+function GetMonthIndex(shortMonthName)
+{
+ for (i=0;i<12;i++)
+ {
+ if (MonthName[i].substring(0,3).toUpperCase()==shortMonthName.toUpperCase())
+ { return i;}
+ }
+}
+Calendar.prototype.GetMonthIndex=GetMonthIndex;
+
+function IncYear()
+{ Cal.Year++;}
+Calendar.prototype.IncYear=IncYear;
+
+function DecYear()
+{ Cal.Year--;}
+Calendar.prototype.DecYear=DecYear;
+
+function SwitchMth(intMth)
+{ Cal.Month=intMth;}
+Calendar.prototype.SwitchMth=SwitchMth;
+
+function SetHour(intHour)
+{
+ var MaxHour;
+ var MinHour;
+ if (TimeMode==24)
+ { MaxHour=23;MinHour=0}
+ else if (TimeMode==12)
+ { MaxHour=12;MinHour=1}
+ else
+ alert("TimeMode can only be 12 or 24");
+ var HourExp=new RegExp("^\\d\\d$");
+ if (HourExp.test(intHour) && (parseInt(intHour,10)<=MaxHour) && (parseInt(intHour,10)>=MinHour))
+ {
+ if ((TimeMode==12) && (Cal.AMorPM=="PM"))
+ {
+ if (parseInt(intHour,10)==12)
+ Cal.Hours=12;
+ else
+ Cal.Hours=parseInt(intHour,10)+12;
+ }
+ else if ((TimeMode==12) && (Cal.AMorPM=="AM"))
+ {
+ if (intHour==12)
+ intHour-=12;
+ Cal.Hours=parseInt(intHour,10);
+ }
+ else if (TimeMode==24)
+ Cal.Hours=parseInt(intHour,10);
+ }
+}
+Calendar.prototype.SetHour=SetHour;
+
+function SetMinute(intMin)
+{
+ var MinExp=new RegExp("^\\d\\d$");
+ if (MinExp.test(intMin) && (intMin<60))
+ Cal.Minutes=intMin;
+}
+Calendar.prototype.SetMinute=SetMinute;
+
+function SetSecond(intSec)
+{
+ var SecExp=new RegExp("^\\d\\d$");
+ if (SecExp.test(intSec) && (intSec<60))
+ Cal.Seconds=intSec;
+}
+Calendar.prototype.SetSecond=SetSecond;
+
+function SetAmPm(pvalue)
+{
+ this.AMorPM=pvalue;
+ if (pvalue=="PM")
+ {
+ this.Hours=(parseInt(this.Hours,10))+12;
+ if (this.Hours==24)
+ this.Hours=12;
+ }
+ else if (pvalue=="AM")
+ this.Hours-=12;
+}
+Calendar.prototype.SetAmPm=SetAmPm;
+
+function getShowHour()
+{
+ var finalHour;
+ if (TimeMode==12)
+ {
+ if (parseInt(this.Hours,10)==0)
+ {
+ this.AMorPM="AM";
+ finalHour=parseInt(this.Hours,10)+12;
+ }
+ else if (parseInt(this.Hours,10)==12)
+ {
+ this.AMorPM="PM";
+ finalHour=12;
+ }
+ else if (this.Hours>12)
+ {
+ this.AMorPM="PM";
+ if ((this.Hours-12)<10)
+ finalHour="0"+((parseInt(this.Hours,10))-12);
+ else
+ finalHour=parseInt(this.Hours,10)-12;
+ }
+ else
+ {
+ this.AMorPM="AM";
+ if (this.Hours<10)
+ finalHour="0"+parseInt(this.Hours,10);
+ else
+ finalHour=this.Hours;
+ }
+ }
+ else if (TimeMode==24)
+ {
+ if (this.Hours<10)
+ finalHour="0"+parseInt(this.Hours,10);
+ else
+ finalHour=this.Hours;
+ }
+ return finalHour;
+}
+Calendar.prototype.getShowHour=getShowHour;
+
+function GetMonthName(IsLong)
+{
+ var Month=MonthName[this.Month];
+ if (IsLong)
+ return Month;
+ else
+ return Month.substr(0,3);
+}
+Calendar.prototype.GetMonthName=GetMonthName;
+
+function GetMonDays()//Get number of days in a month
+{
+ var DaysInMonth=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
+ if (this.IsLeapYear())
+ {
+ DaysInMonth[1]=29;
+ }
+ return DaysInMonth[this.Month];
+}
+Calendar.prototype.GetMonDays=GetMonDays;
+
+function IsLeapYear()
+{
+ if ((this.Year%4)==0)
+ {
+ if ((this.Year%100==0) && (this.Year%400)!=0)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+}
+Calendar.prototype.IsLeapYear=IsLeapYear;
+
+function FormatDate(pDate)
+{
+ if (this.Format.toUpperCase()=="DDMMYYYY")
+ return (pDate+DateSeparator+(this.Month+1)+DateSeparator+this.Year);
+ else if (this.Format.toUpperCase()=="DDMMMYYYY")
+ return (pDate+DateSeparator+this.GetMonthName(false)+DateSeparator+this.Year);
+ else if (this.Format.toUpperCase()=="MMDDYYYY")
+ return ((this.Month+1)+DateSeparator+pDate+DateSeparator+this.Year);
+ else if (this.Format.toUpperCase()=="MMMDDYYYY")
+ return (this.GetMonthName(false)+DateSeparator+pDate+DateSeparator+this.Year);
+}
+Calendar.prototype.FormatDate=FormatDate; \ No newline at end of file
diff --git a/usr/local/www/services_captiveportal.php b/usr/local/www/services_captiveportal.php
index 5b94e11..8265a6d 100755
--- a/usr/local/www/services_captiveportal.php
+++ b/usr/local/www/services_captiveportal.php
@@ -1,22 +1,22 @@
#!/usr/local/bin/php
-<?php
+<?php
/*
services_captiveportal.php
part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+
+ Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -29,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+$pgtitle = array("Services", "Captive portal");
require("guiconfig.inc");
if (!is_array($config['captiveportal'])) {
@@ -49,6 +50,7 @@ $pconfig['cinterface'] = $config['captiveportal']['interface'];
$pconfig['timeout'] = $config['captiveportal']['timeout'];
$pconfig['idletimeout'] = $config['captiveportal']['idletimeout'];
$pconfig['enable'] = isset($config['captiveportal']['enable']);
+$pconfig['auth_method'] = $config['captiveportal']['auth_method'];
$pconfig['radacct_enable'] = isset($config['captiveportal']['radacct_enable']);
$pconfig['httpslogin_enable'] = isset($config['captiveportal']['httpslogin']);
$pconfig['httpsname'] = $config['captiveportal']['httpsname'];
@@ -56,6 +58,13 @@ $pconfig['cert'] = base64_decode($config['captiveportal']['certificate']);
$pconfig['key'] = base64_decode($config['captiveportal']['private-key']);
$pconfig['logoutwin_enable'] = isset($config['captiveportal']['logoutwin_enable']);
$pconfig['nomacfilter'] = isset($config['captiveportal']['nomacfilter']);
+$pconfig['peruserbw'] = isset($config['captiveportal']['peruserbw']);
+$pconfig['bwauthmacup'] = $config['captiveportal']['bwauthmacup'];
+$pconfig['bwauthmacdn'] = $config['captiveportal']['bwauthmacdn'];
+$pconfig['bwauthipup'] = $config['captiveportal']['bwauthipup'];
+$pconfig['bwauthipdn'] = $config['captiveportal']['bwauthipdn'];
+$pconfig['bwdefaultup'] = $config['captiveportal']['bwdefaultup'];
+$pconfig['bwdefaultdn'] = $config['captiveportal']['bwdefaultdn'];
$pconfig['redirurl'] = $config['captiveportal']['redirurl'];
$pconfig['radiusip'] = $config['captiveportal']['radiusip'];
$pconfig['radiusport'] = $config['captiveportal']['radiusport'];
@@ -71,9 +80,9 @@ if ($_POST) {
if ($_POST['enable']) {
$reqdfields = explode(" ", "cinterface");
$reqdfieldsn = explode(",", "Interface");
-
+
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
+
/* make sure no interfaces are bridged */
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
$coptif = &$config['interfaces']['opt' . $i];
@@ -82,7 +91,7 @@ if ($_POST) {
break;
}
}
-
+
if ($_POST['httpslogin_enable']) {
if (!$_POST['cert'] || !$_POST['key']) {
$input_errors[] = "Certificate and key must be specified for HTTPS login.";
@@ -92,13 +101,13 @@ if ($_POST) {
if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
$input_errors[] = "This key does not appear to be valid.";
}
-
+
if (!$_POST['httpsname'] || !is_domain($_POST['httpsname'])) {
$input_errors[] = "The HTTPS server name must be specified for HTTPS login.";
}
}
}
-
+
if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) {
$input_errors[] = "The timeout must be at least 1 minute.";
}
@@ -120,27 +129,35 @@ if ($_POST) {
$config['captiveportal']['timeout'] = $_POST['timeout'];
$config['captiveportal']['idletimeout'] = $_POST['idletimeout'];
$config['captiveportal']['enable'] = $_POST['enable'] ? true : false;
+ $config['captiveportal']['auth_method'] = $_POST['auth_method'];
$config['captiveportal']['radacct_enable'] = $_POST['radacct_enable'] ? true : false;
$config['captiveportal']['httpslogin'] = $_POST['httpslogin_enable'] ? true : false;
$config['captiveportal']['httpsname'] = $_POST['httpsname'];
$config['captiveportal']['certificate'] = base64_encode($_POST['cert']);
$config['captiveportal']['private-key'] = base64_encode($_POST['key']);
$config['captiveportal']['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false;
+ $config['captiveportal']['peruserbw'] = $_POST['peruserbw'] ? true : false;
+ $config['captiveportal']['bwauthmacup'] = $_POST['bwauthmacup'];
+ $config['captiveportal']['bwauthmacdn'] = $_POST['bwauthmacdn'];
+ $config['captiveportal']['bwauthipup'] = $_POST['bwauthipup'];
+ $config['captiveportal']['bwauthipdn'] = $_POST['bwauthipdn'];
+ $config['captiveportal']['bwdefaultup'] = $_POST['bwdefaultup'];
+ $config['captiveportal']['bwdefaultdn'] = $_POST['bwdefaultdn'];
$config['captiveportal']['nomacfilter'] = $_POST['nomacfilter'] ? true : false;
$config['captiveportal']['redirurl'] = $_POST['redirurl'];
$config['captiveportal']['radiusip'] = $_POST['radiusip'];
$config['captiveportal']['radiusport'] = $_POST['radiusport'];
$config['captiveportal']['radiusacctport'] = $_POST['radiusacctport'];
$config['captiveportal']['radiuskey'] = $_POST['radiuskey'];
-
+
/* file upload? */
if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
$config['captiveportal']['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
if (is_uploaded_file($_FILES['errfile']['tmp_name']))
$config['captiveportal']['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
-
+
write_config();
-
+
$retval = 0;
if (!file_exists($d_sysrebootreqd_path)) {
config_lock();
@@ -151,24 +168,26 @@ if ($_POST) {
}
}
?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<title><?=gentitle("Services: Captive portal");?></title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link href="gui.css" rel="stylesheet" type="text/css">
+<?php include("fbegin.inc"); ?>
<script language="JavaScript">
<!--
-function radacct_change() {
- if (document.iform.radacct_enable.checked) {
+function auth_method_change() {
+ if (document.iform.auth_method[0].checked == false) {
document.iform.logoutwin_enable.checked = 1;
+ } else {
+ document.iform.logoutwin_enable.checked = 0;
}
}
+function radacct_change() {
+ if (document.iform.radacct_enable.checked) {
+ auth_method_change();
+ }
+}
function enable_change(enable_change) {
var endis;
endis = !(document.iform.enable.checked || enable_change);
- document.iform.radiusacctport.disabled = endis;
+
document.iform.cinterface.disabled = endis;
document.iform.idletimeout.disabled = endis;
document.iform.timeout.disabled = endis;
@@ -177,6 +196,9 @@ function enable_change(enable_change) {
document.iform.radiusport.disabled = endis;
document.iform.radiuskey.disabled = endis;
document.iform.radacct_enable.disabled = endis;
+ document.iform.auth_method[0].disabled = endis;
+ document.iform.auth_method[1].disabled = endis;
+ document.iform.auth_method[2].disabled = endis;
document.iform.httpslogin_enable.disabled = endis;
document.iform.httpsname.disabled = endis;
document.iform.cert.disabled = endis;
@@ -185,23 +207,21 @@ function enable_change(enable_change) {
document.iform.nomacfilter.disabled = endis;
document.iform.htmlfile.disabled = endis;
document.iform.errfile.disabled = endis;
-
+
if (enable_change && document.iform.radacct_enable.checked) {
document.iform.logoutwin_enable.checked = 1;
}
+ if (enable_change && document.iform.auth_method[0].checked == false) {
+ document.iform.logoutwin_enable.checked = 1;
+ }
}
//-->
</script>
-</head>
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<?php include("fbegin.inc"); ?>
-<p class="pgtitle">Services: Captive portal</p>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
<form action="services_captiveportal.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td>
+ <tr><td class="tabnavtbl">
<ul id="tabnav">
<li class="tabact">Captive portal</li>
<li class="tabinact"><a href="services_captiveportal_mac.php">Pass-through MAC</a></li>
@@ -211,13 +231,13 @@ function enable_change(enable_change) {
<tr>
<td class="tabcont">
<table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
+ <tr>
<td width="22%" valign="top" class="vtable">&nbsp;</td>
<td width="78%" class="vtable">
<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
<strong>Enable captive portal </strong></td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top" class="vncellreq">Interface</td>
<td width="78%" class="vtable">
<select name="cinterface" class="formfld" id="cinterface">
@@ -227,7 +247,7 @@ function enable_change(enable_change) {
$interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
}
foreach ($interfaces as $iface => $ifacename): ?>
- <option value="<?=$iface;?>" <?php if ($iface == $pconfig['cinterface']) echo "selected"; ?>>
+ <option value="<?=$iface;?>" <?php if ($iface == $pconfig['cinterface']) echo "selected"; ?>>
<?=htmlspecialchars($ifacename);?>
</option>
<?php endforeach; ?>
@@ -241,16 +261,16 @@ function enable_change(enable_change) {
minutes<br>
Clients will be disconnected after this amount of inactivity. They may log in again immediately, though. Leave this field blank for no idle timeout.</td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top" class="vncell">Hard timeout</td>
- <td width="78%" class="vtable">
- <input name="timeout" type="text" class="formfld" id="timeout" size="6" value="<?=htmlspecialchars($pconfig['timeout']);?>">
+ <td width="78%" class="vtable">
+ <input name="timeout" type="text" class="formfld" id="timeout" size="6" value="<?=htmlspecialchars($pconfig['timeout']);?>">
minutes<br>
Clients will be disconnected after this amount of time, regardless of activity. They may log in again immediately, though. Leave this field blank for no hard timeout (not recommended unless an idle timeout is set).</td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top" class="vncell">Logout popup window</td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<input name="logoutwin_enable" type="checkbox" class="formfld" id="logoutwin_enable" value="yes" <?php if($pconfig['logoutwin_enable']) echo "checked"; ?>>
<strong>Enable logout popup window</strong><br>
If enabled, a popup window will appear when clients are allowed through the captive portal. This allows clients to explicitly disconnect themselves before the idle or hard timeout occurs. When RADIUS accounting is enabled, this option is implied.</td>
@@ -268,12 +288,49 @@ to access after they've authenticated.</td>
<td class="vtable">
<input name="nomacfilter" type="checkbox" class="formfld" id="nomacfilter" value="yes" <?php if ($pconfig['nomacfilter']) echo "checked"; ?>>
<strong>Disable MAC filtering</strong><br>
- If this option is set, no attempts will be made to ensure that the MAC address of clients stays the same while they're logged in. This is required when the MAC address of cannot be determined (usually because there are routers between m0n0wall and the clients).</td>
+ If this option is set, no attempts will be made to ensure that the MAC address of clients stays the same while they're logged in. This is required when the MAC address cannot be determined (usually because there are routers between m0n0wall and the clients).</td>
</tr>
- <tr>
+ <tr>
+ <td valign="top" class="vncell">Per-user bandwidth restriction</td>
+ <td class="vtable">
+ <input name="peruserbw" type="checkbox" class="formfld" id="peruserbw" value="yes" <?php if ($pconfig['peruserbw']) echo "checked"; ?>>
+ <strong>Enable per-user bandwidth restriction </strong><br><br>
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td>Pass-through MAC download&nbsp;&nbsp;</td>
+ <td><input type="text" class="formfld" id="bwauthmacdn" size="5" value="<?=htmlspecialchars($pconfig['bwauthmacdn']);?>"> Kbit/s</td>
+ </tr><tr>
+ <td>Pass-through MAC upload</td>
+ <td><input type="text" class="formfld" id="bwauthmacdn" size="5" value="<?=htmlspecialchars($pconfig['bwauthmacup']);?>"> Kbit/s</td>
+ </tr><tr>
+ <td>Pass-through IP download</td>
+ <td><input type="text" class="formfld" id="bwauthipdn" size="5" value="<?=htmlspecialchars($pconfig['bwauthipdn']);?>"> Kbit/s</td>
+ </tr><tr>
+ <td>Pass-through IP upload</td>
+ <td><input type="text" class="formfld" id="bwauthipup" size="5" value="<?=htmlspecialchars($pconfig['bwauthipup']);?>"> Kbit/s</td>
+ </tr><tr>
+ <td>Default download</td>
+ <td><input type="text" class="formfld" id="bwdefaultdn" size="5" value="<?=htmlspecialchars($pconfig['bwdefaultdn']);?>"> Kbit/s</td>
+ </tr><tr>
+ <td>Default upload</td>
+ <td><input type="text" class="formfld" id="bwdefaultup" size="5" value="<?=htmlspecialchars($pconfig['bwdefaultup']);?>"> Kbit/s</td>
+ </tr></table>
+ <br>
+ If this option is set, the captive portal will restrict each user who logs in to a specific bandwidth as set in RADIUS. Your RADIUS server must return the attributes Nomadix-Bw-Up and Nomadix-Bw-Down (1 and 2 VSAs from Vendor 3309, Nomadix) along with Access-Accept for this to work. Bandwidth is set in Kbit/s. You can control pass-through and default bandwidths above.</td>
+ </tr>
+ <tr>
<td width="22%" valign="top" class="vncell">RADIUS server</td>
- <td width="78%" class="vtable">
+ <td width="78%" class="vtable">
<table cellpadding="0" cellspacing="0">
+ <td>No Authentication:&nbsp;&nbsp;</td>
+ <td><input name="auth_method" type="radio" id="auth_method" value="none" <?php if($pconfig['auth_method']!="local" || $pconfig['auth_method']!="radius") echo "checked"; ?> onClick="auth_method_change()"></td>
+ </tr>
+ <td>Local <a href="services_usermanager.php">Usermanager</a>:&nbsp;&nbsp;</td>
+ <td><input name="auth_method" type="radio" id="auth_method" value="local" <?php if($pconfig['auth_method']=="local") echo "checked"; ?> onClick="auth_method_change()"></td>
+ </tr>
+ <td>RADIUS Authentication:&nbsp;&nbsp;</td>
+ <td><input name="auth_method" type="radio" id="auth_method" value="radius" <?php if($pconfig['auth_method']=="radius") echo "checked"; ?> onClick="auth_method_change()"></td>
+ </tr>
<tr>
<td>IP address:</td>
<td><input name="radiusip" type="text" class="formfld" id="radiusip" size="20" value="<?=htmlspecialchars($pconfig['radiusip']);?>"></td>
@@ -313,7 +370,7 @@ to access after they've authenticated.</td>
<td class="vtable">
<textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
<br>
- Paste a signed certificate in X.509 PEM format here. <A target="_new" HREF='system_advanced_create_certs.php'>Create</a> certificates automatically.</td>
+ Paste a signed certificate in X.509 PEM format here.</td>
</tr>
<tr>
<td valign="top" class="vncell">HTTPS private key</td>
@@ -322,12 +379,12 @@ to access after they've authenticated.</td>
<br>
Paste an RSA private key in PEM format here.</td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top" class="vncellreq">Portal page contents</td>
- <td width="78%" class="vtable">
- <input type="file" name="htmlfile" class="formfld" id="htmlfile"><br>
+ <td width="78%" class="vtable">
+ <?=$mandfldhtml;?><input type="file" name="htmlfile" class="formfld" id="htmlfile"><br>
<?php if ($config['captiveportal']['page']['htmltext']): ?>
- <a href="?act=viewhtml" target="_blank">View current page</a>
+ <a href="?act=viewhtml" target="_blank">View current page</a>
<br>
<br>
<?php endif; ?>
@@ -348,19 +405,19 @@ with a submit button (name=&quot;accept&quot;) and a hidden field with name=&quo
<td class="vtable">
<input name="errfile" type="file" class="formfld" id="errfile"><br>
<?php if ($config['captiveportal']['page']['errtext']): ?>
- <a href="?act=viewerrhtml" target="_blank">View current page</a>
+ <a href="?act=viewerrhtml" target="_blank">View current page</a>
<br>
<br>
<?php endif; ?>
The contents of the HTML file that you upload here are displayed when a RADIUS authentication error occurs.</td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
+ <td width="78%">
+ <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
</td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
</strong></span>Changing any settings on this page will disconnect all clients! Don't forget to enable the DHCP server on your captive portal interface! Make sure that the default/maximum DHCP lease time is higher than the timeout entered on this page. Also, the DNS forwarder needs to be enabled for DNS lookups by unauthenticated clients to work. </span></td>
@@ -376,5 +433,3 @@ enable_change(false);
//-->
</script>
<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/usr/local/www/services_usermanager.php b/usr/local/www/services_usermanager.php
new file mode 100755
index 0000000..fb7071a
--- /dev/null
+++ b/usr/local/www/services_usermanager.php
@@ -0,0 +1,191 @@
+#!/usr/local/bin/php
+<?php
+/*
+ services_usermanager.php
+ part of m0n0wall (http://m0n0.ch/wall)
+
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+ Copyright (C) 2005 Pascal Suter <monodev@psuter.ch>.
+ All rights reserved.
+ (files was created by Pascal based on the source code of services_captiveportal.php from Manuel)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+$pgtitle = array("Services", "Usermanager");
+require("guiconfig.inc");
+if(isset($_POST['save'])){
+ $_POST['username']=trim($_POST['username']);
+ if($_POST['old_username']!="" && $_POST['old_username']!=$_POST['username']){
+ $config['users'][$_POST['username']]=$config['users'][$_POST['old_username']];
+ unset($config['users'][$_POST['old_username']]);
+ }
+ foreach(Array('fullname','expirationdate') as $field){
+ $config['users'][$_POST['username']][$field]=trim($_POST[$field]);
+ }
+ if(trim($_POST['password1'])!="********" && trim($_POST['password1'])!=""){
+ if(trim($_POST['password1'])==trim($_POST['password2'])){
+ $config['users'][$_POST['username']]['password']=md5(trim($_POST['password1']));
+ } else {
+ $input_errors[]="passwords did not match --> password was not changed!";
+ }
+ }
+ if($_POST['username']=="" || trim($_POST['password1'])==""){
+ $input_errors[] = "username and password must not be empty!";
+ $_GET['act']="new";
+ } else {
+ write_config();
+ $savemsg=$_POST['username']." successfully saved<br>";
+ }
+} else if ($_GET['act']=="delete" && isset($_GET['username'])){
+ unset($config['users'][$_GET['username']]);
+ write_config();
+ $savemsg=$_GET['username']." successfully deleted<br>";
+}
+//erase expired accounts
+$changed=false;
+if(is_array($config['users'])){
+ foreach($config['users'] as $username => $user){
+ if(trim($user['expirationdate'])!="" && strtotime("-1 day")>strtotime($user['expirationdate'])){
+ unset($config['users'][$username]);
+ $changed=true;
+ $savemsg.="$username has expired --> $username was deleted<br>";
+ }
+ }
+ if($changed){
+ write_config();
+ }
+}
+
+?>
+<?php include("fbegin.inc"); ?>
+<script language="javascript" type="text/javascript" src="datetimepicker.js">
+//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
+//Script featured on JavaScript Kit (http://www.javascriptkit.com)
+//For this script, visit http://www.javascriptkit.com
+</script>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+ <ul id="tabnav">
+ <li class="tabact">User Manager</li>
+ </ul>
+ </td></tr>
+ <tr>
+ <td class="tabcont">
+<?php
+if($_GET['act']=="new" || $_GET['act']=="edit"){
+ if($_GET['act']=="edit" && isset($_GET['username'])){
+ $user=$config['users'][$_GET['username']];
+ }
+?>
+ <form action="services_usermanager.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Username</td>
+ <td width="78%" class="vtable">
+ <input name="username" type="text" class="formfld" id="username" size="20" value="<? echo $_GET['username']; ?>">
+ <br>
+ <span class="vexpl">Username to be used</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Password</td>
+ <td width="78%" class="vtable">
+ <input name="password1" type="password" class="formfld" id="password1" size="20" value="<?php echo ($_GET['act']=='edit' ? "********" : "" ); ?>">
+ <br>
+ <span class="vexpl">Password for the user</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">confirm Password</td>
+ <td width="78%" class="vtable">
+ <input name="password2" type="password" class="formfld" id="password2" size="20" value="<?php echo ($_GET['act']=='edit' ? "********" : "" ); ?>">
+ <br>
+ <span class="vexpl">Confirm the above Password</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Full Name</td>
+ <td width="78%" class="vtable">
+ <input name="fullname" type="text" class="formfld" id="fullname" size="20" value="<? echo $user['fullname']; ?>">
+ <br>
+ Full Name of current user, for your own information only</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Expiration Date</td>
+ <td width="78%" class="vtable">
+ <input name="expirationdate" type="text" class="formfld" id="expirationdate" size="10" value="<? echo $user['expirationdate']; ?>">
+ <a href="javascript:NewCal('expirationdate','mmddyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
+ <br> <span class="vexpl">enter nothing if account doesnt expire, otherwhise enter the expiration date in us-format: mm/dd/yyyy</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="save" type="submit" class="formbtn" value="Save">
+ <input name="old_username" type="hidden" value="<? echo $_GET['username'];?>">
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php
+} else {
+ echo <<<END
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="35%" class="listhdrr">Username</td>
+ <td width="20%" class="listhdrr">Full Name</td>
+ <td width="35%" class="listhdr">Expires</td>
+ <td width="10%" class="list"></td>
+ </tr>
+END;
+ if(is_array($config['users'])){
+ foreach($config['users'] as $username => $user){
+?>
+ <tr>
+ <td class="listlr">
+ <?php echo $username; ?>&nbsp;
+ </td>
+ <td class="listr">
+ <?php echo $user['fullname']; ?>&nbsp;
+ </td>
+ <td class="listbg">
+ <?php echo $user['expirationdate']; ?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list"> <a href="services_usermanager.php?act=edit&username=<?php echo $username; ?>"><img src="e.gif" width="17" height="17" border="0"></a>
+ &nbsp;<a href="services_usermanager.php?act=delete&username=<?php echo $username; ?>" onclick="return confirm('Do you really want to delete this User?')"><img src="x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+<?php
+ }
+ }
+ echo <<<END
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list"> <a href="services_usermanager.php?act=new"><img src="plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+END;
+}
+?>
+
+ </td>
+ </tr>
+ </table>
+<?php include("fend.inc"); ?>
OpenPOWER on IntegriCloud