From 8a06fdc8bb4fb57effeef7c79ee84a7c67670035 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 26 Jun 2015 16:53:02 +0200 Subject: [PATCH] upnp: make it services_upnp.php for consistency Further stripping of unused XML elements. --- .../app/models/OPNsense/Base/Menu/Menu.xml | 2 +- .../OPNsense/Core/ACL_Legacy_Page_Map.json | 2 +- src/pkg/miniupnpd.xml | 7 - .../{service_upnp.php => services_upnp.php} | 216 ++---------------- src/www/shortcuts.inc | 2 +- 5 files changed, 24 insertions(+), 205 deletions(-) rename src/www/{service_upnp.php => services_upnp.php} (84%) diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/Menu/Menu.xml b/src/opnsense/mvc/app/models/OPNsense/Base/Menu/Menu.xml index 4a0df09da..39f624086 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/Menu/Menu.xml +++ b/src/opnsense/mvc/app/models/OPNsense/Base/Menu/Menu.xml @@ -106,7 +106,7 @@ - + diff --git a/src/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.json b/src/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.json index 628503fc9..af4e399ee 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.json +++ b/src/opnsense/mvc/app/models/OPNsense/Core/ACL_Legacy_Page_Map.json @@ -1247,7 +1247,7 @@ "name": "WebCfg - Service: Univeral Plug and Play page", "descr": "Allow access to the 'Service: Univeral Plug and Play' page.", "match": [ - "service_upnp.php*" + "services_upnp.php*" ] }, "page-status-upnpstatus": { diff --git a/src/pkg/miniupnpd.xml b/src/pkg/miniupnpd.xml index 6471977dd..0eb4db482 100644 --- a/src/pkg/miniupnpd.xml +++ b/src/pkg/miniupnpd.xml @@ -3,13 +3,6 @@ Services: Universal Plug and Play miniupnpd 20100712 - Change - - Universal Plug and Play - Set UPnP & NAT-PMP settings such as interfaces to listen on. -
Services
- /service_upnp&id=0 -
miniupnpd miniupnpd.sh diff --git a/src/www/service_upnp.php b/src/www/services_upnp.php similarity index 84% rename from src/www/service_upnp.php rename to src/www/services_upnp.php index f098bbf91..21c435a80 100644 --- a/src/www/service_upnp.php +++ b/src/www/services_upnp.php @@ -63,9 +63,6 @@ $pkg = parse_xml_config_raw('/usr/local/pkg/miniupnpd.xml', 'packagegui', false) require_once 'miniupnpd.inc'; -$package_name = $pkg['menu'][0]['name']; -$section = $pkg['menu'][0]['section']; -$config_path = $pkg['configpath']; $name = $pkg['name']; $title = $pkg['title']; $pgtitle = $title; @@ -84,20 +81,15 @@ if(!is_numeric($id)) { exit; } -// grab the installedpackages->package_name section. if($config['installedpackages'] && !is_array($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'])) $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'] = array(); -// If the first entry in the array is an empty tag, kill it. if ($config['installedpackages'] && (count($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']) > 0) && ($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'][0] == "")) array_shift($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']); $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']; -if($_GET['savemsg'] <> "") - $savemsg = htmlspecialchars($_GET['savemsg']); - before_form_miniupnpd($pkg); if ($_POST) { @@ -179,9 +171,9 @@ if ($_POST) { if($pkg['aftersaveredirect'] <> "") { redirectHeader($pkg['aftersaveredirect']); } elseif(!$pkg['adddeleteeditpagefields']) { - redirectHeader("service_upnp.php?id=0"); + redirectHeader("services_upnp.php?id=0"); } elseif(!$pkg['preoutput']) { - redirectHeader("service_upnp.php"); + redirectHeader("services_upnp.php"); } exit; } else { @@ -192,9 +184,6 @@ if ($_POST) { } } -$title = $pkg['title']; -$pgtitle = $title; - include("head.inc"); ?> @@ -309,80 +298,19 @@ include("head.inc");
-
-
+
- "") { - $tab_array = array(); - foreach($pkg['tabs']['tab'] as $tab) { - if($tab['tab_level']) - $tab_level = $tab['tab_level']; - else - $tab_level = 1; - if(isset($tab['active'])) { - $active = true; - } else { - $active = false; - } - if(isset($tab['no_drop_down'])) - $no_drop_down = true; - $urltmp = ""; - if($tab['url'] <> "") $urltmp = $tab['url']; - if($tab['xml'] <> "") $urltmp = "service_upnp.php"; - - $addresswithport = getenv("HTTP_HOST"); - $colonpos = strpos($addresswithport, ":"); - if ($colonpos !== False) { - //my url is actually just the IP address of the opnsense box - $myurl = substr($addresswithport, 0, $colonpos); - } else { - $myurl = $addresswithport; - } - // eval url so that above $myurl item can be processed if need be. - $url = str_replace('$myurl', $myurl, $urltmp); - - $tab_array[$tab_level][] = array( - $tab['text'], - $active, - $url - ); - } - - ksort($tab_array); - foreach($tab_array as $tabid => $tab) { - /* -echo ''; -*/ - } -} - -?> - "") $savevalue = $pkg['savetext']; - /* If a package's XML has configured, then setup - * the table rows for the fields that have set. - * These fields will be placed below other fields in a seprate area titled 'Advanced Features'. - * These advanced fields are not normally configured and generally left to default to 'default settings'. - */ - if ($pkg['advanced_options'] == "enabled") { - $adv_filed_count = 0; - $advanced = ""; - $advanced .= "\n"; - } foreach ($pkg['fields']['field'] as $pkga) { if ($pkga['type'] == "sorting") continue; @@ -390,22 +318,13 @@ echo '"; $input .= "\n"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) { - $advanced .= $input; - $adv_filed_count++; - } - else - echo $input; + echo $input; continue; } if($pkga['combinefields']=="begin"){ $input=""; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) - $advanced .= $input; - else - echo $input; - } + echo $input; $size = ""; if (isset($pkga['dontdisplayname'])){ @@ -416,7 +335,6 @@ echo '"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) { $advanced .= $input; $adv_filed_count++; } @@ -430,30 +348,17 @@ echo '"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) { - $advanced .= $input; - $adv_filed_count++; - } - else - echo $input; + echo $input; } if($pkga['combinefields']=="begin"){ $input="
'; - display_top_tabs($tab, $no_drop_down, $tabid); - echo '
 
". gettext("Advanced features") . "
'; if ($pkga['type'] == "listtopic") { $input = "
 
{$pkga['name']}
'; $colspan="colspan='2'"; else $input .= " 
'; $input= "
"; $input .= fixup_string($pkga['fielddescr']); $input .= ""; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) - $advanced .= $input; - else - echo $input; + echo $input; } $class=(isset($pkga['combinefields']) ? '' : 'class="vtable"'); if (!isset($pkga['placeonbottom'])){ $input="
"; } - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) - $advanced .= "{$input}\n"; - else - echo "{$input}\n"; + echo "{$input}\n"; #increment counter $i++; } - #print advanced settings if any after reading all fields - if (isset($advanced) && $adv_filed_count > 0) - echo $advanced; - ?> @@ -890,22 +734,6 @@ echo '
"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)){ - $advanced .= $input; - $adv_filed_count++; - } - else - echo $input; + echo $input; } // if user is editing a record, load in the data. @@ -472,34 +377,19 @@ echo '
'; $size = ($pkga['size'] ? " size='{$pkga['size']}' " : ""); $input = "\n"; $input .= "
" . fixup_string($pkga['description']) . "\n"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) { - $js_array[] = $pkga['fieldname']; - $advanced .= display_advanced_field($pkga['fieldname']).$input ."\n"; - } - else - echo $input; + echo $input; break; case "password": $size = ($pkga['size'] ? " size='{$pkga['size']}' " : ""); $input = "\n"; $input .= "
" . fixup_string($pkga['description']) . "\n"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) { - $js_array[] = $pkga['fieldname']; - $advanced .= display_advanced_field($pkga['fieldname']).$input ."\n"; - } - else - echo $input; + echo $input; break; case "info": $input = fixup_string($pkga['description']) . "\n"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) { - $js_array[] = $pkga['fieldname']; - $advanced .= display_advanced_field($pkga['fieldname']).$input ."\n"; - } - else - echo $input; + echo $input; break; case "select": @@ -520,13 +410,7 @@ echo '
'; $input .= "\t\n"; } $input .= "\n
\n" . fixup_string($pkga['description']) . "\n"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) { - $js_array[] = $pkga['fieldname']; - $advanced .= display_advanced_field($pkga['fieldname']).$input; - $advanced .= "\n"; - } - else - echo $input; + echo $input; break; case "select_source": @@ -543,13 +427,7 @@ echo '
'; $onchange = (isset($pkga['onchange']) ? "onchange=\"{$pkga['onchange']}\"" : ''); $input = "
'; $input .= "\t\n"; } $input .= "\n
\n" . fixup_string($pkga['description']) . "\n"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) - $advanced .= $input; - else - echo $input; + echo $input; break; case "vpn_selection" : @@ -579,13 +454,7 @@ echo '
'; $input .= "\n"; $input .= "
" . fixup_string($pkga['description']) . "\n"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) { - $js_array[] = $pkga['fieldname']; - $advanced .= display_advanced_field($pkga['fieldname']).$input; - $advanced .= "\n"; - } - else - echo $input; + echo $input; break; case "checkbox": @@ -596,13 +465,7 @@ echo '
'; $input = "\n"; $input .= "
" . fixup_string($pkga['description']) . "\n"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) { - $js_array[] = $pkga['fieldname']; - $advanced .= display_advanced_field($pkga['fieldname']).$input; - $advanced .= "\n"; - } - else - echo $input; + echo $input; break; case "textarea": @@ -615,13 +478,7 @@ echo '
'; $wrap =($pkga['wrap'] == "off" ? 'wrap="off" style="white-space:nowrap;"' : ''); $input = "\n"; $input .= "
" . fixup_string($pkga['description']) . "\n"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) { - $js_array[] = $pkga['fieldname']; - $advanced .= display_advanced_field($pkga['fieldname']).$input; - $advanced .= "\n"; - } - else - echo $input; + echo $input; break; case "aliases": @@ -725,19 +582,13 @@ echo '
'; $input .= "\n"; } $input .= "\n
" . fixup_string($pkga['description']) . "\n"; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) - $advanced .= $input; - else - echo $input; + echo $input; break; case "radio": $input = ""; - if(isset($pkga['advancedfield']) && isset($adv_filed_count)) - $advanced .= $input; - else - echo $input; - break; + echo $input; + break; case "button": $input = "\n"; @@ -849,18 +700,11 @@ echo '
'; if($pkga['usecolspan2']) $input.= "
 
'; -\n"; - echo "//\n"; - echo "\n"; - } -?> - \n"; return $div; } - -?> diff --git a/src/www/shortcuts.inc b/src/www/shortcuts.inc index f137fb8ac..24bf00be7 100644 --- a/src/www/shortcuts.inc +++ b/src/www/shortcuts.inc @@ -133,7 +133,7 @@ function get_shortcut_log_link($shortcut_section, $addspace = true) { } $shortcuts['upnp'] = array(); -$shortcuts['upnp']['main'] = "service_upnp.php"; +$shortcuts['upnp']['main'] = "services_upnp.php"; $shortcuts['upnp']['log'] = "diag_logs_routing.php"; $shortcuts['upnp']['status'] = "status_upnp.php"; $shortcuts['upnp']['service'] = "miniupnpd";