Commit d5654b79 authored by Franco Fichtner's avatar Franco Fichtner

interfaces: remove pppoe reset cron handling... #911

... Ad already annotated a few spots, the whole thing is beyond
repair and I dread extending it to PPP and others which has been
asked for a few times now.  We will have to find another way.

To paraphrase Star Trek: He's dead, Jim.

The upside is that the cron config items are flushed by default
now, later we can remove this as we don't care what is in that
unused config section anyway.
parent 8d10efac
...@@ -1408,108 +1408,6 @@ function interfaces_ptpid_next() ...@@ -1408,108 +1408,6 @@ function interfaces_ptpid_next()
return $ptpid; return $ptpid;
} }
function getMPDCRONSettings($pppif)
{
global $config;
$cron_cmd_file = "/var/etc/pppoe_restart_{$pppif}";
if (isset($config['cron']['item'])) {
foreach ($config['cron']['item'] as $i => $item) {
if (stripos($item['command'], $cron_cmd_file) !== false) {
return array("ID" => $i, "ITEM" => $item);
}
}
}
return null;
}
function handle_pppoe_reset($post_array)
{
global $config;
$pppif = "{$post_array['type']}{$post_array['ptpid']}";
$cron_cmd_file = "/var/etc/pppoe_restart_{$pppif}";
if (!isset($config['cron']['item']) || !is_array($config['cron']['item'])) {
$config['cron']['item'] = array();
}
$itemhash = getMPDCRONSettings($pppif);
// reset cron items if necessary and return
if (empty($post_array['pppoe-reset-type'])) {
if (isset($itemhash)) {
unset($config['cron']['item'][$itemhash['ID']]);
}
killbypid('/var/run/cron.pid', 'HUP');
return;
}
if (empty($itemhash)) {
$itemhash = array();
}
$item = array();
if (isset($post_array['pppoe-reset-type']) && $post_array['pppoe-reset-type'] == "custom") {
$item['minute'] = $post_array['pppoe_resetminute'];
$item['hour'] = $post_array['pppoe_resethour'];
if (isset($post_array['pppoe_resetdate']) && $post_array['pppoe_resetdate'] <> "") {
$date = explode("/", $post_array['pppoe_resetdate']);
$item['mday'] = $date[1];
$item['month'] = $date[0];
} else {
$item['mday'] = "*";
$item['month'] = "*";
}
$item['wday'] = "*";
$item['who'] = "root";
$item['command'] = $cron_cmd_file;
} elseif (isset($post_array['pppoe-reset-type']) && $post_array['pppoe-reset-type'] == "preset") {
switch ($post_array['pppoe_pr_preset_val']) {
case "monthly":
$item['minute'] = "0";
$item['hour'] = "0";
$item['mday'] = "1";
$item['month'] = "*";
$item['wday'] = "*";
break;
case "weekly":
$item['minute'] = "0";
$item['hour'] = "0";
$item['mday'] = "*";
$item['month'] = "*";
$item['wday'] = "0";
break;
case "daily":
$item['minute'] = "0";
$item['hour'] = "0";
$item['mday'] = "*";
$item['month'] = "*";
$item['wday'] = "*";
break;
case "hourly":
$item['minute'] = "0";
$item['hour'] = "*";
$item['mday'] = "*";
$item['month'] = "*";
$item['wday'] = "*";
break;
} // end switch
$item['who'] = "root";
$item['command'] = $cron_cmd_file;
}
if (empty($item)) {
return;
}
if (isset($itemhash['ID'])) {
$config['cron']['item'][$itemhash['ID']] = $item;
} else {
$config['cron']['item'][] = $item;
}
}
/* /*
* This function can configure PPPoE, MLPPP (PPPoE), PPTP. * This function can configure PPPoE, MLPPP (PPPoE), PPTP.
* It writes the mpd config file to /var/etc every time the link is opened. * It writes the mpd config file to /var/etc every time the link is opened.
...@@ -1839,14 +1737,6 @@ EOD; ...@@ -1839,14 +1737,6 @@ EOD;
mwexec("/usr/local/sbin/mpd5 -b -k -d /var/etc -f mpd_{$interface}.conf -p /var/run/" . mwexec("/usr/local/sbin/mpd5 -b -k -d /var/etc -f mpd_{$interface}.conf -p /var/run/" .
escapeshellarg($ppp['type']) . "_{$interface}.pid -s ppp " . escapeshellarg($ppp['type']) . "client"); escapeshellarg($ppp['type']) . "_{$interface}.pid -s ppp " . escapeshellarg($ppp['type']) . "client");
// Check for PPPoE periodic reset request
if ($ppp['type'] == "pppoe") {
if (!empty($ppp['pppoe-reset-type'])) {
interface_setup_pppoe_reset_file($ppp['if'], $interface);
} else {
interface_setup_pppoe_reset_file($ppp['if']);
}
}
/* wait for up to 10 seconds for the interface to appear (ppp(oe)) */ /* wait for up to 10 seconds for the interface to appear (ppp(oe)) */
$i = 0; $i = 0;
while ($i < 10) { while ($i < 10) {
...@@ -4965,26 +4855,6 @@ function is_jumbo_capable($iface) ...@@ -4965,26 +4855,6 @@ function is_jumbo_capable($iface)
} }
} }
function interface_setup_pppoe_reset_file($pppif, $iface = '')
{
$cron_file = "/var/etc/pppoe_restart_{$pppif}";
if (!empty($iface) && !empty($pppif)) {
$cron_cmd = <<<EOD
#!/bin/sh
/usr/local/opnsense/service/configd_ctl.py interface reconfigure {$iface}
/usr/bin/logger -t {$pppif} "PPPoE periodic reset executed on {$iface}"
EOD;
@file_put_contents($cron_file, $cron_cmd);
chmod($cron_file, 0755);
killbypid('/var/run/cron.pid', 'HUP');
} else {
@unlink($cron_file);
}
}
function get_vip_descr($ipaddress) function get_vip_descr($ipaddress)
{ {
global $config; global $config;
......
...@@ -2344,25 +2344,8 @@ function configure_cron() ...@@ -2344,25 +2344,8 @@ function configure_cron()
{ {
global $config; global $config;
$obsoletes = array(
'/usr/local/etc/rc.backup_dhcpleases',
'/usr/local/etc/rc.backup_netflow',
'/usr/local/etc/rc.backup_rrd',
'/usr/local/etc/rc.filter_configure_sync',
'/usr/local/etc/rc.dyndns.update',
'/usr/local/etc/rc.update_bogons',
'/usr/local/etc/rc.update_urltables',
'/usr/local/opnsense/scripts/remote_backup.php',
'/usr/local/sbin/expiretable -v -t 3600 sshlockout',
'/usr/local/sbin/expiretable -v -t 3600 virusprot',
'adjkerntz -a',
/* old config migration for extra care: */
'checkreload.sh',
'newsyslog',
);
/* /*
* Strip old cron jobs that we no longer save explicitly. * Strip the cron jobs that we no longer save explicitly.
* This can be safely removed on our final road to 17.1. * This can be safely removed on our final road to 17.1.
*/ */
if (isset($config['cron']['item'])) { if (isset($config['cron']['item'])) {
...@@ -2372,10 +2355,8 @@ function configure_cron() ...@@ -2372,10 +2355,8 @@ function configure_cron()
/* PHP retains the index, can iterate all and unset */ /* PHP retains the index, can iterate all and unset */
foreach ($config['cron']['item'] as $item) { foreach ($config['cron']['item'] as $item) {
foreach ($obsoletes as $obsolete) { foreach ($obsoletes as $obsolete) {
if ($item['command'] === $obsolete) { unset($config['cron']['item'][$index]);
unset($config['cron']['item'][$index]); $flush = true;
$flush = true;
}
} }
$index++; $index++;
} }
...@@ -2457,10 +2438,6 @@ function configure_cron() ...@@ -2457,10 +2438,6 @@ function configure_cron()
$crontab_contents .= '# auto-generated at ' . date('F j, Y, g:i a') . "\n"; $crontab_contents .= '# auto-generated at ' . date('F j, Y, g:i a') . "\n";
$crontab_contents .= "#\n"; $crontab_contents .= "#\n";
if (isset($config['cron']['item'])) {
$autocron = array_merge($config['cron']['item'], $autocron);
}
foreach ($autocron as $item) { foreach ($autocron as $item) {
$crontab_contents .= "{$item['minute']}\t"; $crontab_contents .= "{$item['minute']}\t";
$crontab_contents .= "{$item['hour']}\t"; $crontab_contents .= "{$item['hour']}\t";
......
...@@ -2287,16 +2287,6 @@ function upgrade_063_to_064() { ...@@ -2287,16 +2287,6 @@ function upgrade_063_to_064() {
$ppp['ondemand'] = true; $ppp['ondemand'] = true;
if (isset($ifinfo['timeout'])) if (isset($ifinfo['timeout']))
$ppp['idletimeout'] = $ifinfo['timeout']; $ppp['idletimeout'] = $ifinfo['timeout'];
if (isset($ifinfo['pppoe']['pppoe-reset-type'])){
$ppp['pppoe-reset-type'] = $ifinfo['pppoe']['pppoe-reset-type'];
if (is_array($config['cron']['item'])) {
for ($i = 0; $i < count($config['cron']['item']); $i++) {
$item = $config['cron']['item'][$i];
if (strpos($item['command'], "/conf/pppoe{$ifname}restart") !== false)
$config['cron']['item'][$i]['command'] = "/var/etc/pppoe_restart_" . $ppp['if'];
}
}
}
if (isset($ifinfo['local'])) if (isset($ifinfo['local']))
$ppp['localip'] = $ifinfo['local']; $ppp['localip'] = $ifinfo['local'];
if (isset($ifinfo['subnet'])) if (isset($ifinfo['subnet']))
...@@ -2312,8 +2302,6 @@ function upgrade_063_to_064() { ...@@ -2312,8 +2302,6 @@ function upgrade_063_to_064() {
unset($ifcfg[$ifname]['provider']); unset($ifcfg[$ifname]['provider']);
unset($ifcfg[$ifname]['ondemand']); unset($ifcfg[$ifname]['ondemand']);
unset($ifcfg[$ifname]['timeout']); unset($ifcfg[$ifname]['timeout']);
unset($ifcfg[$ifname]['pppoe_reset']);
unset($ifcfg[$ifname]['pppoe_preset']);
unset($ifcfg[$ifname]['pppoe']); unset($ifcfg[$ifname]['pppoe']);
unset($ifcfg[$ifname]['pptp_username']); unset($ifcfg[$ifname]['pptp_username']);
unset($ifcfg[$ifname]['pptp_password']); unset($ifcfg[$ifname]['pptp_password']);
......
...@@ -411,10 +411,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -411,10 +411,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
} }
$std_ppp_copy_fieldnames = array( $std_ppp_copy_fieldnames = array("ptpid", "ports", "username", "phone", "apn", "provider", "idletimeout", "localip");
"ptpid", "ports", "username", "phone", "apn", "provider", "idletimeout", "pppoe-reset-type", "localip",
);
foreach ($std_ppp_copy_fieldnames as $fieldname) { foreach ($std_ppp_copy_fieldnames as $fieldname) {
$pconfig[$fieldname] = isset($a_ppps[$pppid][$fieldname]) ? $a_ppps[$pppid][$fieldname] : null; $pconfig[$fieldname] = isset($a_ppps[$pppid][$fieldname]) ? $a_ppps[$pppid][$fieldname] : null;
} }
...@@ -434,15 +431,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -434,15 +431,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($a_ppps[$pppid])) { if (isset($a_ppps[$pppid])) {
$pconfig['pppid'] = $pppid; $pconfig['pppid'] = $pppid;
$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
if (!empty($itemhash)) {
$cronitem = $itemhash['ITEM'];
$pconfig['pppoe_resetminute'] = $cronitem['minute'];
$pconfig['pppoe_resethour'] = $cronitem['hour'];
$pconfig['pppoe_resetmday'] = $cronitem['mday'];
$pconfig['pppoe_resetmonth'] = $cronitem['month'];
$pconfig['pppoe_resetwday'] = $cronitem['wday'];
}
} else { } else {
$pconfig['ptpid'] = interfaces_ptpid_next(); $pconfig['ptpid'] = interfaces_ptpid_next();
$pppid = count($a_ppps); $pppid = count($a_ppps);
...@@ -795,17 +783,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -795,17 +783,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$input_errors[] = gettext("The idle timeout value must be an integer."); $input_errors[] = gettext("The idle timeout value must be an integer.");
} }
if (!empty($pconfig['pppoe-reset-type'])) {
if (!empty($pconfig['pppoe_resethour']) && (!is_numericint($pconfig['pppoe_resethour']) || $pconfig['pppoe_resethour'] < 0 || $pconfig['pppoe_resethour'] > 23)) {
$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
}
if (!empty($pconfig['pppoe_resetminute']) && (!is_numericint($pconfig['pppoe_resetminute']) || $pconfig['pppoe_resetminute'] < 0 || $pconfig['pppoe_resetminute'] > 59)) {
$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
}
if (!empty($pconfig['pppoe_resetdate']) && !is_numeric(str_replace("/", "", $pconfig['pppoe_resetdate']))) {
$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
}
}
if (!empty($pconfig['localip']) && !is_ipaddrv4($pconfig['localip'])) { if (!empty($pconfig['localip']) && !is_ipaddrv4($pconfig['localip'])) {
$input_errors[] = gettext("A valid PPTP local IP address must be specified."); $input_errors[] = gettext("A valid PPTP local IP address must be specified.");
} }
...@@ -1037,10 +1014,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -1037,10 +1014,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($pconfig['pppoe_idletimeout'])) { if (!empty($pconfig['pppoe_idletimeout'])) {
$new_ppp_config['idletimeout'] = $pconfig['pppoe_idletimeout']; $new_ppp_config['idletimeout'] = $pconfig['pppoe_idletimeout'];
} }
if (!empty($pconfig['pppoe-reset-type'])) {
$new_ppp_config['pppoe-reset-type'] = $pconfig['pppoe-reset-type'];
}
break; break;
case "pptp": case "pptp":
case "l2tp": case "l2tp":
...@@ -1273,8 +1246,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -1273,8 +1246,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
exec('/bin/kill ' . $pid); exec('/bin/kill ' . $pid);
} }
} }
// yak... room for improvement here....
handle_pppoe_reset($pconfig);
// save to config // save to config
write_config(); write_config();
...@@ -1294,9 +1265,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -1294,9 +1265,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
mark_subsystem_dirty('interfaces'); mark_subsystem_dirty('interfaces');
/* regenerate cron settings/crontab file */
configure_cron();
header("Location: interfaces.php?if={$if}"); header("Location: interfaces.php?if={$if}");
exit; exit;
} }
...@@ -1629,21 +1597,6 @@ include("head.inc"); ...@@ -1629,21 +1597,6 @@ include("head.inc");
}); });
}); });
// pppoe reset_type
$("#reset_type").change(function() {
if ($(this).val() == 'preset') {
$('#pppoepresetwrap').show();
$('#pppoecustomwrap').hide();
}
else if ($(this).val() == 'custom') {
$('#pppoecustomwrap').show();
$('#pppoepresetwrap').hide();
} else {
$('#pppoecustomwrap').hide();
$('#pppoepresetwrap').hide();
}
});
$("#reset_type").change();
$("#mtu").change(function(){ $("#mtu").change(function(){
// ppp uses an mtu // ppp uses an mtu
if (!isNaN($("#mtu").val()) && $("#mtu").val() > 8) { if (!isNaN($("#mtu").val()) && $("#mtu").val() > 8) {
...@@ -2260,76 +2213,6 @@ include("head.inc"); ...@@ -2260,76 +2213,6 @@ include("head.inc");
</div> </div>
</td> </td>
</tr> </tr>
<tr>
<td><a id="help_for_periodic_reset" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Periodic reset");?></td>
<td>
<table class="table table-condensed">
<tr>
<td>
<select style="vertical-align:top" id="reset_type" name="pppoe-reset-type" class="selectpicker" data-style="btn-default">
<option value=""><?=gettext("Disabled"); ?></option>
<option value="custom" <?=$pconfig['pppoe-reset-type'] == "custom" ? "selected=\"selected\"" : ""; ?>><?=gettext("Custom"); ?></option>
<option value="preset" <?=$pconfig['pppoe-reset-type'] == "preset" ? "selected=\"selected\"" : ""; ?>><?=gettext("Pre-Set"); ?></option>
</select>
&nbsp;<?=gettext("Select a reset timing type"); ?>
</td>
</tr>
<tr>
<td>
<div style="<?=$pconfig['pppoe-reset-type'] != "custom" ? "display: none;" :"";?>" id="pppoecustomwrap">
<input type="text" name="pppoe_resethour" maxlength="2" id="pppoe_resethour" value="<?= $pconfig['pppoe_resethour']; ?>" />
<?=gettext("hour (0-23)"); ?><br />
<input type="text" name="pppoe_resetminute" maxlength="2" id="pppoe_resetminute" value="<?= $pconfig['pppoe_resetminute']; ?>" />
<?=gettext("minute (0-59)"); ?><br />
<?php
if (!empty($pconfig['pppoe_resetmday']) && $pconfig['pppoe_resetmday'] <> "*" && $pconfig['pppoe_resetmonth'] <> "*") {
$pconfig['pppoe_resetdate'] = "{$pconfig['pppoe_resetmonth']}/{$pconfig['pppoe_resetmday']}/" . date("Y");
}
?>
<input name="pppoe_resetdate" type="text" id="pppoe_resetdate" maxlength="10" value="<?=$pconfig['pppoe_resetdate'];?>" />
<?=gettext("reset at a specific date (mm/dd/yyyy)"); ?>
<div class="hidden" for="help_for_periodic_reset">
<span class="text-danger"><strong><?=gettext("Note:"); ?> </strong></span>
<?=gettext("If you leave the date field empty, the reset will be executed each day at the time you did specify using the minutes and hour field."); ?>
</div>
</div>
<div style="<?=$pconfig['pppoe-reset-type'] != "preset" ? "display: none;" :"";?>" id="pppoepresetwrap">
<?php
if ($pconfig['pppoe-reset-type'] == "preset") {
$resetTime = "{$pconfig['pppoe_resetminute']} {$pconfig['pppoe_resethour']} {$pconfig['pppoe_resetmday']} {$pconfig['pppoe_resetmonth']} {$pconfig['pppoe_resetwday']}";
switch ($resetTime) {
case "0 0 1 * *": // CRON_MONTHLY_PATTERN
$pconfig['pppoe_monthly'] = true;
break;
case "0 0 * * 0": // CRON_WEEKLY_PATTERN
$pconfig['pppoe_weekly'] = true;
break;
case "0 0 * * *": // CRON_DAILY_PATTERN
$pconfig['pppoe_daily'] = true;
break;
case "0 * * * *": //CRON_HOURLY_PATTERN
$pconfig['pppoe_hourly'] = true;
break;
}
}?>
<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?=!empty($pconfig['pppoe_monthly']) ? "checked=\"checked\"" : ""; ?> />
<?=gettext("reset at each month ('0 0 1 * *')"); ?>
<br />
<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?=!empty($pconfig['pppoe_weekly']) ? "checked=\"checked\"" : ""; ?> />
<?=gettext("reset at each week ('0 0 * * 0')"); ?>
<br />
<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?=!empty($pconfig['pppoe_daily']) ? "checked=\"checked\"" : ""; ?> />
<?=gettext("reset at each day ('0 0 * * *')"); ?>
<br />
<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?=!empty($pconfig['pppoe_hourly']) ? "checked=\"checked\"" : ""; ?> />
<?=gettext("reset at each hour ('0 * * * *')"); ?>
</p>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr> <tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Advanced and MLPPP"); ?></td> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Advanced and MLPPP"); ?></td>
<?php if (isset($pconfig['pppid'])): ?> <?php if (isset($pconfig['pppid'])): ?>
......
...@@ -57,8 +57,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -57,8 +57,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (ppp_inuse($a_ppps[$id]['if'])) { if (ppp_inuse($a_ppps[$id]['if'])) {
$input_errors[] = gettext("This point-to-point link cannot be deleted because it is still being used as an interface."); $input_errors[] = gettext("This point-to-point link cannot be deleted because it is still being used as an interface.");
} else { } else {
unset($a_ppps[$id]['pppoe-reset-type']);
handle_pppoe_reset($a_ppps[$id]);
unset($a_ppps[$id]); unset($a_ppps[$id]);
write_config(); write_config();
header("Location: interfaces_ppps.php"); header("Location: interfaces_ppps.php");
......
...@@ -49,7 +49,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -49,7 +49,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
// plain 1-on-1 copy // plain 1-on-1 copy
$copy_fields = array('ptpid', 'type', 'username', 'idletimeout', 'uptime', 'descr', 'simpin', 'pin-wait', $copy_fields = array('ptpid', 'type', 'username', 'idletimeout', 'uptime', 'descr', 'simpin', 'pin-wait',
'apn', 'apnum', 'phone', 'connect-timeout', 'provider', 'pppoe-reset-type'); 'apn', 'apnum', 'phone', 'connect-timeout', 'provider');
foreach ($copy_fields as $fieldname) { foreach ($copy_fields as $fieldname) {
if (isset($a_ppps[$id][$fieldname])) { if (isset($a_ppps[$id][$fieldname])) {
$pconfig[$fieldname] = $a_ppps[$id][$fieldname]; $pconfig[$fieldname] = $a_ppps[$id][$fieldname];
...@@ -77,24 +77,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -77,24 +77,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['initstr'] = isset($a_ppps[$id]['initstr']) ? base64_decode($a_ppps[$id]['initstr']) : null; $pconfig['initstr'] = isset($a_ppps[$id]['initstr']) ? base64_decode($a_ppps[$id]['initstr']) : null;
$pconfig['null_service'] = (isset($a_ppps[$id]['provider']) && empty($a_ppps[$id]['provider'])); $pconfig['null_service'] = (isset($a_ppps[$id]['provider']) && empty($a_ppps[$id]['provider']));
// init resetpppoe_reset vars
$pconfig['pppoe_resetminute'] = null;
$pconfig['pppoe_resethour'] = null;
$pconfig['pppoe_resetmday'] = null;
$pconfig['pppoe_resetmonth'] = null;
$pconfig['pppoe_resetwday'] = null;
// read resetpppoe_reset vars
if (!empty($a_ppps[$id]['pppoe-reset-type'])) {
$itemhash = getMPDCRONSettings($a_ppps[$id]['if']);
if (!empty($itemhash)) {
$cronitem = $itemhash['ITEM'];
$pconfig['pppoe_resetminute'] = $cronitem['minute'];
$pconfig['pppoe_resethour'] = $cronitem['hour'];
$pconfig['pppoe_resetmday'] = $cronitem['mday'];
$pconfig['pppoe_resetmonth'] = $cronitem['month'];
$pconfig['pppoe_resetwday'] = $cronitem['wday'];
}
}
if ($pconfig['ptpid'] == null) { if ($pconfig['ptpid'] == null) {
$pconfig['ptpid'] = interfaces_ptpid_next(); $pconfig['ptpid'] = interfaces_ptpid_next();
} }
...@@ -156,18 +138,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -156,18 +138,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$input_errors[] = gettext("The idle timeout value must be an integer."); $input_errors[] = gettext("The idle timeout value must be an integer.");
} }
if (!empty($pconfig['pppoe-reset-type'])) {
if (!empty($pconfig['pppoe_resethour']) && (!is_numericint($pconfig['pppoe_resethour']) || $pconfig['pppoe_resethour'] < 0 || $pconfig['pppoe_resethour'] > 23)) {
$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
}
if (!empty($pconfig['pppoe_resetminute']) && (!is_numericint($pconfig['pppoe_resetminute']) || $pconfig['pppoe_resetminute'] < 0 || $pconfig['pppoe_resetminute'] > 59)) {
$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
}
if (!empty($pconfig['pppoe_resetdate']) && !is_numeric(str_replace("/", "", $pconfig['pppoe_resetdate']))) {
$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
}
}
foreach($pconfig['ports'] as $iface_idx => $iface){ foreach($pconfig['ports'] as $iface_idx => $iface){
if (!empty($pconfig['localip'][$iface_idx]) && !is_ipaddr($pconfig['localip'][$iface_idx])) { if (!empty($pconfig['localip'][$iface_idx]) && !is_ipaddr($pconfig['localip'][$iface_idx])) {
$input_errors[] = sprintf(gettext("A valid local IP address must be specified for %s."),$iface); $input_errors[] = sprintf(gettext("A valid local IP address must be specified for %s."),$iface);
...@@ -243,9 +213,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -243,9 +213,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} else { } else {
$ppp['provider'] = !empty($pconfig['null_service']); $ppp['provider'] = !empty($pconfig['null_service']);
} }
if (!empty($pconfig['pppoe-reset-type'])) {
$ppp['pppoe-reset-type'] = $pconfig['pppoe-reset-type'];
}
break; break;
case "pptp": case "pptp":
case "l2tp": case "l2tp":
...@@ -271,11 +238,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -271,11 +238,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!is_dir('/var/spool/lock')) { if (!is_dir('/var/spool/lock')) {
mwexec('/bin/mkdir -p /var/spool/lock'); mwexec('/bin/mkdir -p /var/spool/lock');
} }
/* handle_pppoe_reset is called here because if user changes Link Type from PPPoE to another type we
must be able to clear the config data in the <cron> section of config.xml if it exists
*/
// yak... room for improvement here.... (see interfaces.php as well)
handle_pppoe_reset($pconfig);
if (isset($id)) { if (isset($id)) {
$a_ppps[$id] = $ppp; $a_ppps[$id] = $ppp;
...@@ -284,7 +246,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -284,7 +246,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
write_config(); write_config();
configure_cron();
$iflist = get_configured_interface_with_descr(); $iflist = get_configured_interface_with_descr();
foreach ($iflist as $pppif => $ifdescr) { foreach ($iflist as $pppif => $ifdescr) {
if ($config['interfaces'][$pppif]['if'] == $ppp['if']) if ($config['interfaces'][$pppif]['if'] == $ppp['if'])
...@@ -305,7 +266,7 @@ include("head.inc"); ...@@ -305,7 +266,7 @@ include("head.inc");
$(document).ready(function() { $(document).ready(function() {
// change type // change type
$("#type").change(function(){ $("#type").change(function(){
$('#ppp,#ppp_adv,#pppoe,#pppoe_adv,#ppp_provider,#phone_num,#apn_').hide(); $('#ppp,#ppp_adv,#pppoe,#ppp_provider,#phone_num,#apn_').hide();
$('#ports > [data-type="serial"]').hide(); $('#ports > [data-type="serial"]').hide();
$('#ports > [data-type="serial"]').prop('disabled', true); $('#ports > [data-type="serial"]').prop('disabled', true);
$('#ports > [data-type="interface"]').hide(); $('#ports > [data-type="interface"]').hide();
...@@ -333,7 +294,6 @@ include("head.inc"); ...@@ -333,7 +294,6 @@ include("head.inc");
break; break;
case "pppoe": case "pppoe":
$('#pppoe').show(); $('#pppoe').show();
$('#pppoe_adv').show();
// fall through to show interface items // fall through to show interface items
default: default:
$('#ports > [data-type="interface"]').show(); $('#ports > [data-type="interface"]').show();
...@@ -643,81 +603,6 @@ include("head.inc"); ...@@ -643,81 +603,6 @@ include("head.inc");
</div> </div>
<div class="tab-content content-box col-xs-12 __mb" > <div class="tab-content content-box col-xs-12 __mb" >
<div class="table-responsive"> <div class="table-responsive">
<!-- Advanced PPOE -->
<table class="table table-striped" id="pppoe_adv" style="display:none">
<thead>
<tr style="display:none" class="act_show_advanced">
<th colspan="2"><?= gettext("Advanced Options"); ?></th>
</tr>
</thead>
<tbody>
<tr style="display:none" class="act_show_advanced">
<td width="22%"><a id="help_for_reset_type" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Periodic reset");?></td>
<td width="78%">
<select style="vertical-align:top" id="reset_type" name="pppoe-reset-type" class="selectpicker" data-style="btn-default" onchange="show_reset_settings(this.value);">
<option value=""><?=gettext("Disabled"); ?></option>
<option value="custom" <?=$pconfig['pppoe-reset-type'] == "custom" ? "selected=\"selected\"" : ""; ?>><?=gettext("Custom"); ?></option>
<option value="preset" <?=$pconfig['pppoe-reset-type'] == "preset" ? "selected=\"selected\"" : ""; ?>><?=gettext("Pre-Set"); ?></option>
</select>
<div class="hidden" for="help_for_reset_type">
<?=gettext("Select a reset timing type"); ?>
</div>
<div style="<?=$pconfig['pppoe-reset-type'] != "custom" ? "display: none;" :"";?>" id="pppoecustomwrap">
<hr/>
<input type="text" name="pppoe_resethour" id="pppoe_resethour" value="<?=$pconfig['pppoe_resethour']; ?>" />
<?= gettext("hour (0-23)"); ?><br />
<input type="text" name="pppoe_resetminute" id="pppoe_resetminute" value="<?=$pconfig['pppoe_resetminute']; ?>" />
<?= gettext("minute (0-59)"); ?><br />
<?php
if (!empty($pconfig['pppoe_resetmday']) && $pconfig['pppoe_resetmday'] <> "*" && $pconfig['pppoe_resetmonth'] <> "*") {
$pconfig['pppoe_resetdate'] = "{$pconfig['pppoe_resetmonth']}/{$pconfig['pppoe_resetmday']}/" . date("Y");
} elseif (!isset($pconfig['pppoe_resetdate'])) {
$pconfig['pppoe_resetdate'] = null;
}
?>
<input name="pppoe_resetdate" type="text" id="pppoe_resetdate" value="<?=$pconfig['pppoe_resetdate'];?>" />
<?= gettext("reset at a specific date (mm/dd/yyyy)"); ?>
<div class="hidden" for="help_for_reset_type">
<span class="text-warning"><strong><?=gettext("Note:");?></strong></span><br/>
<?= gettext("If you leave the date field empty, the reset will be executed each day at the time you did specify using the minutes and hour field."); ?>
</div>
</div>
<?php
if ($pconfig['pppoe-reset-type'] == "preset") {
$resetTime = "{$pconfig['pppoe_resetminute']} {$pconfig['pppoe_resethour']} {$pconfig['pppoe_resetmday']} {$pconfig['pppoe_resetmonth']} {$pconfig['pppoe_resetwday']}";
switch ($resetTime) {
case "0 0 1 * *": // CRON_MONTHLY_PATTERN
$pconfig['pppoe_monthly'] = true;
break;
case "0 0 * * 0": // CRON_WEEKLY_PATTERN
$pconfig['pppoe_weekly'] = true;
break;
case "0 0 * * *": // CRON_DAILY_PATTERN
$pconfig['pppoe_daily'] = true;
break;
case "0 * * * *": //CRON_HOURLY_PATTERN
$pconfig['pppoe_hourly'] = true;
break;
}
}?>
<div style="<?=$pconfig['pppoe-reset-type'] != "preset" ? "display: none;" :"";?>" id="pppoepresetwrap">
<input name="pppoe_pr_preset_val" type="radio" id="pppoe_monthly" value="monthly" <?=!empty($pconfig['pppoe_monthly']) ? "checked=\"checked\"" : ""; ?> />
<?=gettext("reset at each month ('0 0 1 * *')"); ?>
<br />
<input name="pppoe_pr_preset_val" type="radio" id="pppoe_weekly" value="weekly" <?=!empty($pconfig['pppoe_weekly']) ? "checked=\"checked\"" : ""; ?> />
<?=gettext("reset at each week ('0 0 * * 0')"); ?>
<br />
<input name="pppoe_pr_preset_val" type="radio" id="pppoe_daily" value="daily" <?=!empty($pconfig['pppoe_daily']) ? "checked=\"checked\"" : ""; ?> />
<?=gettext("reset at each day ('0 0 * * *')"); ?>
<br />
<input name="pppoe_pr_preset_val" type="radio" id="pppoe_hourly" value="hourly" <?=!empty($pconfig['pppoe_hourly']) ? "checked=\"checked\"" : ""; ?> />
<?=gettext("reset at each hour ('0 * * * *')"); ?>
</div>
</td>
</tr>
</tbody>
</table>
<!-- Advanced PPP --> <!-- Advanced PPP -->
<table class="table table-striped" id="ppp_adv" style="display:none"> <table class="table table-striped" id="ppp_adv" style="display:none">
<thead> <thead>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment