From 85669dbdb00072d20f9d6ff12fd589a908e18581 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Tue, 8 Dec 2015 20:34:51 +0100 Subject: [PATCH] (legacy) refactor system_hasync.php --- src/www/system_hasync.php | 634 ++++++++++++++++++-------------------- 1 file changed, 303 insertions(+), 331 deletions(-) diff --git a/src/www/system_hasync.php b/src/www/system_hasync.php index 70e190fd2..4de9c7005 100644 --- a/src/www/system_hasync.php +++ b/src/www/system_hasync.php @@ -1,70 +1,74 @@ . - All rights reserved. + Copyright (C) 2014-2015 Deciso B.V. + Copyright (C) 2012 Darren Embry . + All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + 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. + 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. + 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. + 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. */ require_once("guiconfig.inc"); require_once("interfaces.inc"); -$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_hasync.php'); if (!isset($config['hasync']) || !is_array($config['hasync'])) { $config['hasync'] = array(); } - $a_hasync = &$config['hasync']; -$checkbox_names = array( - 'pfsyncenabled', - 'synchronizeusers', - 'synchronizeauthservers', - 'synchronizecerts', - 'synchronizerules', - 'synchronizeschedules', - 'synchronizealiases', - 'synchronizenat', - 'synchronizeipsec', - 'synchronizeopenvpn', - 'synchronizedhcpd', - 'synchronizewol', - 'synchronizestaticroutes', - 'synchronizelb', - 'synchronizevirtualip', - 'synchronizednsforwarder', +$checkbox_names = array('pfsyncenabled', 'synchronizeusers', 'synchronizeauthservers', 'synchronizecerts', + 'synchronizerules', 'synchronizeschedules', 'synchronizealiases', 'synchronizenat', + 'synchronizeipsec', 'synchronizeopenvpn', 'synchronizedhcpd', 'synchronizewol', + 'synchronizestaticroutes', 'synchronizelb', 'synchronizevirtualip', + 'synchronizednsforwarder', ); -if ($_POST) { + +if ($_SERVER['REQUEST_METHOD'] === 'GET') { + $pconfig = array(); + foreach ($checkbox_names as $name) { + if (isset($a_hasync[$name])) { + $pconfig[$name] = $a_hasync[$name]; + } else { + $pconfig[$name] = null; + } + } + foreach (array('pfsyncpeerip','pfsyncinterface','synchronizetoip','username','password') as $tag) { + if (isset($a_hasync[$tag])) { + $pconfig[$tag] = $a_hasync[$tag]; + } else { + $pconfig[$tag] = null; + } + } + +} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $pconfig = $_POST; foreach ($checkbox_names as $name) { - if (isset($pconfig[$name])) { - $a_hasync[$name] = $pconfig[$name]; - } else { - $a_hasync[$name] = false; - } + if (isset($pconfig[$name])) { + $a_hasync[$name] = $pconfig[$name]; + } else { + $a_hasync[$name] = false; + } } $a_hasync['pfsyncpeerip'] = $pconfig['pfsyncpeerip']; $a_hasync['pfsyncinterface'] = $pconfig['pfsyncinterface']; @@ -77,300 +81,268 @@ if ($_POST) { exit(); } -foreach ($checkbox_names as $name) { - if (isset($a_hasync[$name])) { - $pconfig[$name] = $a_hasync[$name]; - } else { - $pconfig[$name] = null; - } -} -foreach (array('pfsyncpeerip','pfsyncinterface','synchronizetoip','username','password') as $tag) { - if (isset($a_hasync[$tag])) { - $pconfig[$tag] = $a_hasync[$tag]; - } else { - $pconfig[$tag] = null; - } -} - -$ifaces = get_configured_interface_with_descr(); -$ifaces["lo0"] = "loopback"; - +legacy_html_escape_form_data($pconfig); include("head.inc"); - ?> - - -
-
- -
- -
-
- -
- -
- - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- /> - ','','','
','
') ?> -
-
- + + + + + + + + + + + - - - - - - - - - - -
+ + +
+ /> + +
+ -

-
- -
  • -
  • -
  • -
    -
    -
    - ' /> - -
     
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - ' /> -
    -
    - -
  • -
  • -
    -
    -
    - ' /> -
    -
    -
    - -
    -
    - ' /> -
    -
    -
    - -
    -
    - /> - -
    - /> - -
    - /> - -
    - /> - -
    - /> - -
    - /> - -
    - /> - -
    - /> - -
    - /> - -
    -
    - /> - -
    - /> - -
    - /> - -
    - /> - -
    - /> - -
    - /> - -
      - - - " onclick="window.location.href=''" /> -
    - - - - - - - + + + + +
    + + +
    + + +
    + + +
    + + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + /> + +
    + + " onclick="window.location.href=''" /> +
    + +
    - -
    +
    + +