diff options
-rw-r--r-- | etc/inc/interfaces.inc | 31 | ||||
-rw-r--r-- | etc/inc/upgrade_config.inc | 2 | ||||
-rwxr-xr-x | usr/local/www/interfaces.php | 35 |
3 files changed, 41 insertions, 27 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 331b101..a985ff8 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -62,7 +62,7 @@ function get_interface_arr($flush = false) { /* If the cache doesn't exist, build it */ if (!isset($interface_arr_cache) or $flush) - $interface_arr_cache = explode(" ", `/sbin/ifconfig -l`); + $interface_arr_cache = explode(" ", trim(`/sbin/ifconfig -l`)); return $interface_arr_cache; } @@ -72,16 +72,16 @@ function get_interface_arr($flush = false) { * detected. */ function does_interface_exist($interface) { - global $config; - - if(!$interface) - return false; + global $config; + + if(!$interface) + return false; - $ints = get_interface_arr(); + $ints = get_interface_arr(); if (in_array($interface, $ints)) - return true; - else - return false; + return true; + else + return false; } function interfaces_loopback_configure() { @@ -861,7 +861,7 @@ function interface_bring_down($interface = "wan", $destroy = false) { } /* This function can configure PPPoE, MLPPP (PPPoE), PPtP. -* It writes the mpd config file to /var/etc every time the interfaces is brought up. +* It writes the mpd config file to /var/etc every time the link is opened. */ function interface_ppps_configure($interface) { @@ -887,7 +887,10 @@ function interface_ppps_configure($interface) { log_error("Can't find PPP config with ptpid {$ifcfg['ptpid']} in interface_ppps_configure()."); return 0; } - + if (!isset($ifcfg['enable'])) { + log_error("{$interface} is not enabled."); + return 0; + } $pppif = $ifcfg['if']; if ($ppp['type'] == "ppp") $type = "modem"; @@ -3114,7 +3117,7 @@ function find_interface_ip($interface, $flush = false) $interface = str_replace("\n", "", $interface); - if (does_interface_exist($interface) == false) + if (!does_interface_exist($interface)) return; /* Setup IP cache */ @@ -3157,8 +3160,8 @@ function get_interface_ip($interface = "wan") $curip = find_interface_ip($realif); if ($curip && is_ipaddr($curip) && ($curip != "0.0.0.0")) return $curip; - - return null; + else + return null; } function get_interface_subnet($interface = "wan") diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc index d732fed..f9a0482 100644 --- a/etc/inc/upgrade_config.inc +++ b/etc/inc/upgrade_config.inc @@ -1985,7 +1985,7 @@ function upgrade_063_to_064() { if (!isset($ppp['ptpid'])){ $config['ppps']['ppp'][$pppid]['ptpid'] = uniqid('', true); } - if (isset($ppp['defaultgw'])){ + if (isset($ppp['defaultgw'])) unset($config['ppps']['ppp'][$pppid]['defaultgw']); } } diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php index f35ae64..4d6c4c4 100755 --- a/usr/local/www/interfaces.php +++ b/usr/local/www/interfaces.php @@ -94,14 +94,12 @@ $a_gateways = &$config['gateways']['gateway_item']; $wancfg = &$config['interfaces'][$if]; -if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { - foreach ($a_ppps as $pppid => $ppp) { - if ($wancfg['ptpid'] == $ppp['ptpid']) - break; - } +foreach ($a_ppps as $pppid => $ppp) { + if ($wancfg['ptpid'] == $ppp['ptpid']) + break; } -if ($wancfg['ptpid'] == $a_ppps[$pppid]['ptpid']) { +if (isset($wancfg['ptpid']) && $wancfg['ptpid'] == $a_ppps[$pppid]['ptpid']) { $pconfig['pppid'] = $pppid; if ($a_ppps[$pppid]['type'] == "ppp"){ @@ -171,6 +169,9 @@ if ($wancfg['ptpid'] == $a_ppps[$pppid]['ptpid']) { $pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']); $pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout']; } +} else { + $new_ptpid=uniqid('', true); + $pppid = count($a_ppps); } $pconfig['dhcphostname'] = $wancfg['dhcphostname']; $pconfig['alias-address'] = $wancfg['alias-address']; @@ -499,12 +500,17 @@ if ($_POST) { unset($wancfg['provider']); unset($wancfg['ondemand']); unset($wancfg['timeout']); - if ($wancfg['pppoe']['pppoe-reset-type']) - unset($wancfg['pppoe']['pppoe-reset-type']); + unset($wancfg['pppoe']['pppoe-reset-type']); unset($wancfg['local']); unset($wancfg['subnet']); unset($wancfg['remote']); - + unset($a_ppps[$pppid]['apn']); + unset($a_ppps[$pppid]['phone']); + unset($a_ppps[$pppid]['localip']); + unset($a_ppps[$pppid]['subnet']); + unset($a_ppps[$pppid]['gateway']); + unset($a_ppps[$pppid]['pppoe-reset-type']); + $wancfg['descr'] = remove_bad_chars($_POST['descr']); $wancfg['enable'] = $_POST['enable'] == "yes" ? true : false; @@ -568,7 +574,13 @@ if ($_POST) { $a_ppps[$pppid]['ports'] = $_POST['port']; $a_ppps[$pppid]['username'] = $_POST['username']; $a_ppps[$pppid]['password'] = base64_encode($_POST['password']); + $a_ppps[$pppid]['phone'] = $_POST['phone']; $a_ppps[$pppid]['apn'] = $_POST['apn']; + $wancfg['if'] = $_POST['type'] . $if_num; + $wancfg['ptpid'] = $_POST['ptpid']; + $wancfg['ipaddr'] = $_POST['type']; + unset($a_ppps[$pppid]['ondemand']); + unset($a_ppps[$pppid]['idletimeout']); break; case "pppoe": @@ -1962,12 +1974,11 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "ppp" = <input id="save" name="Submit" type="submit" class="formbtn" value="Save"> <input id="cancel" type="button" class="formbtn" value="Cancel" onclick="history.back()"> <input name="if" type="hidden" id="if" value="<?=$if;?>"> - <?php if ($wancfg['ptpid'] == $a_ppps[$pppid]['ptpid']) : ?> - <input name="pppid" type="hidden" value="<?=$pppid;?>"> + <?php if (isset ($wancfg['ptpid']) && $wancfg['ptpid'] == $a_ppps[$pppid]['ptpid']) : ?> <input name="ppp_port" type="hidden" value="<?=$a_ppps[$pppid]['ports'];?>"> <input name="ptpid" type="hidden" value="<?=$a_ppps[$pppid]['ptpid'];?>"> <?php else: ?> - <input name="ptpid" type="hidden" value="<?=uniqid('', true);?>"> + <input name="ptpid" type="hidden" value="<?=$new_ptpid;?>"> <?php endif; ?> </td> </tr> |