From 9f2bbdb44c5700384a37a9586d260492f14f7602 Mon Sep 17 00:00:00 2001 From: Steve Beaver Date: Tue, 14 Feb 2017 15:33:13 -0500 Subject: GET/POST conversion --- src/usr/local/www/services_captiveportal.php | 29 +++++++++++----------- .../www/services_captiveportal_filemanager.php | 24 +++++++++--------- .../local/www/services_captiveportal_hostname.php | 17 ++++++------- .../www/services_captiveportal_hostname_edit.php | 18 ++++++-------- src/usr/local/www/services_captiveportal_ip.php | 17 ++++++------- .../local/www/services_captiveportal_ip_edit.php | 18 ++++---------- src/usr/local/www/services_captiveportal_mac.php | 19 ++++++-------- .../local/www/services_captiveportal_mac_edit.php | 19 ++++++-------- .../local/www/services_captiveportal_vouchers.php | 24 ++++++++---------- .../www/services_captiveportal_vouchers_edit.php | 16 +++--------- src/usr/local/www/services_captiveportal_zones.php | 6 ++--- .../www/services_captiveportal_zones_edit.php | 3 ++- 12 files changed, 88 insertions(+), 122 deletions(-) diff --git a/src/usr/local/www/services_captiveportal.php b/src/usr/local/www/services_captiveportal.php index 0a08480..3141c88 100644 --- a/src/usr/local/www/services_captiveportal.php +++ b/src/usr/local/www/services_captiveportal.php @@ -35,7 +35,7 @@ require_once("filter.inc"); require_once("shaper.inc"); require_once("captiveportal.inc"); -if (substr($_GET['act'], 0, 3) == "get") { +if (substr($_REQUEST['act'], 0, 3) == "get") { $nocsrf = true; } @@ -45,10 +45,8 @@ global $cpzone; global $cpzoneid; $cpzoneid = 1; /* Just a default */ -$cpzone = $_GET['zone']; -if (isset($_POST['zone'])) { - $cpzone = $_POST['zone']; -} +$cpzone = $_REQUEST['zone']; + $cpzone = strtolower($cpzone); if (empty($cpzone) || empty($config['captiveportal'][$cpzone])) { @@ -59,18 +57,19 @@ if (empty($cpzone) || empty($config['captiveportal'][$cpzone])) { if (!is_array($config['captiveportal'])) { $config['captiveportal'] = array(); } + $a_cp =& $config['captiveportal']; $pgtitle = array(gettext("Services"), gettext("Captive Portal"), $a_cp[$cpzone]['zone'], gettext("Configuration")); $pglinks = array("", "services_captiveportal_zones.php", "@self", "@self"); $shortcut_section = "captiveportal"; -if ($_GET['act'] == "viewhtml") { +if ($_REQUEST['act'] == "viewhtml") { if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['htmltext']) { echo base64_decode($a_cp[$cpzone]['page']['htmltext']); } exit; -} else if ($_GET['act'] == "gethtmlhtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['htmltext']) { +} else if ($_REQUEST['act'] == "gethtmlhtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['htmltext']) { $file_data = base64_decode($a_cp[$cpzone]['page']['htmltext']); $file_size = strlen($file_data); @@ -80,17 +79,17 @@ if ($_GET['act'] == "viewhtml") { echo $file_data; exit; -} else if ($_GET['act'] == "delhtmlhtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['htmltext']) { +} else if ($_REQUEST['act'] == "delhtmlhtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['htmltext']) { unset($a_cp[$cpzone]['page']['htmltext']); write_config(sprintf(gettext("Captive Portal: zone %s: Restore default portal page"), $cpzone)); header("Location: services_captiveportal.php?zone={$cpzone}"); exit; -} else if ($_GET['act'] == "viewerrhtml") { +} else if ($_REQUEST['act'] == "viewerrhtml") { if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['errtext']) { echo base64_decode($a_cp[$cpzone]['page']['errtext']); } exit; -} else if ($_GET['act'] == "geterrhtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['errtext']) { +} else if ($_REQUEST['act'] == "geterrhtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['errtext']) { $file_data = base64_decode($a_cp[$cpzone]['page']['errtext']); $file_size = strlen($file_data); @@ -100,17 +99,17 @@ if ($_GET['act'] == "viewhtml") { echo $file_data; exit; -} else if ($_GET['act'] == "delerrhtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['errtext']) { +} else if ($_REQUEST['act'] == "delerrhtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['errtext']) { unset($a_cp[$cpzone]['page']['errtext']); write_config(sprintf(gettext("Captive Portal: zone %s: Restore default error page"), $cpzone)); header("Location: services_captiveportal.php?zone={$cpzone}"); exit; -} else if ($_GET['act'] == "viewlogouthtml") { +} else if ($_REQUEST['act'] == "viewlogouthtml") { if ($a_cp[$cpzone] && $a_cp[$cpzone]['page']['logouttext']) { echo base64_decode($a_cp[$cpzone]['page']['logouttext']); } exit; -} else if ($_GET['act'] == "getlogouthtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['logouttext']) { +} else if ($_REQUEST['act'] == "getlogouthtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['logouttext']) { $file_data = base64_decode($a_cp[$cpzone]['page']['logouttext']); $file_size = strlen($file_data); @@ -120,7 +119,7 @@ if ($_GET['act'] == "viewhtml") { echo $file_data; exit; -} else if ($_GET['act'] == "dellogouthtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['logouttext']) { +} else if ($_REQUEST['act'] == "dellogouthtml" && $a_cp[$cpzone] && $a_cp[$cpzone]['page']['logouttext']) { unset($a_cp[$cpzone]['page']['logouttext']); write_config(sprintf(gettext("Captive Portal: zone %s: Restore default logout page"), $cpzone)); header("Location: services_captiveportal.php?zone={$cpzone}"); @@ -205,7 +204,7 @@ if ($a_cp[$cpzone]) { } } -if ($_POST) { +if ($_POST['save']) { unset($input_errors); $pconfig = $_POST; diff --git a/src/usr/local/www/services_captiveportal_filemanager.php b/src/usr/local/www/services_captiveportal_filemanager.php index 3320662..4240402 100644 --- a/src/usr/local/www/services_captiveportal_filemanager.php +++ b/src/usr/local/www/services_captiveportal_filemanager.php @@ -48,10 +48,8 @@ require_once("filter.inc"); require_once("shaper.inc"); require_once("captiveportal.inc"); -$cpzone = $_GET['zone']; -if (isset($_POST['zone'])) { - $cpzone = $_POST['zone']; -} +$cpzone = $_REQUEST['zone']; + $cpzone = strtolower(htmlspecialchars($cpzone)); if (empty($cpzone)) { @@ -62,6 +60,7 @@ if (empty($cpzone)) { if (!is_array($config['captiveportal'])) { $config['captiveportal'] = array(); } + $a_cp =& $config['captiveportal']; $pgtitle = array(gettext("Services"), gettext("Captive Portal"), $a_cp[$cpzone]['zone'], gettext("File Manager")); @@ -71,6 +70,7 @@ $shortcut_section = "captiveportal"; if (!is_array($a_cp[$cpzone]['element'])) { $a_cp[$cpzone]['element'] = array(); } + $a_element =& $a_cp[$cpzone]['element']; // Calculate total size of all files @@ -79,7 +79,7 @@ foreach ($a_element as $element) { $total_size += $element['size']; } -if ($_POST) { +if ($_POST['Submit']) { unset($input_errors); if (is_uploaded_file($_FILES['new']['tmp_name'])) { @@ -120,10 +120,10 @@ if ($_POST) { exit; } } -} else if (($_GET['act'] == "del") && !empty($cpzone) && $a_element[$_GET['id']]) { - @unlink("{$g['captiveportal_element_path']}/" . $a_element[$_GET['id']]['name']); - @unlink("{$g['captiveportal_path']}/" . $a_element[$_GET['id']]['name']); - unset($a_element[$_GET['id']]); +} else if (($_POST['act'] == "del") && !empty($cpzone) && $a_element[$_POST['id']]) { + @unlink("{$g['captiveportal_element_path']}/" . $a_element[$_POST['id']]['name']); + @unlink("{$g['captiveportal_path']}/" . $a_element[$_POST['id']]['name']); + unset($a_element[$_POST['id']]); write_config(); header("Location: services_captiveportal_filemanager.php?zone={$cpzone}"); exit; @@ -144,7 +144,7 @@ $tab_array[] = array(gettext("Vouchers"), false, "services_captiveportal_voucher $tab_array[] = array(gettext("File Manager"), true, "services_captiveportal_filemanager.php?zone={$cpzone}"); display_top_tabs($tab_array, true); -if ($_GET['act'] == 'add') { +if ($_REQUEST['act'] == 'add') { $form = new Form(false); @@ -200,7 +200,7 @@ if (is_array($a_cp[$cpzone]['element'])): - " href="services_captiveportal_filemanager.php?zone=&act=del&id="> + " href="services_captiveportal_filemanager.php?zone=&act=del&id=" usepost>