From f757ffcc51d23c27eacdfd02d609dafd51e24444 Mon Sep 17 00:00:00 2001 From: Florin-Ciprian Bodin Date: Tue, 14 Nov 2023 05:42:34 +0200 Subject: [PATCH] Update config.php step 2 to integration with request class --- config.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/config.php b/config.php index f392fe8..07a320e 100644 --- a/config.php +++ b/config.php @@ -35,13 +35,18 @@ if (!defined('IN_AUTOINDEX') || !IN_AUTOINDEX) die(); } +/** +* Checking Request Class +**/ +$request = is_object($request) ? $request : new RequestVars('', false); + $strings = array('base_dir', 'icon_path', 'flag_path', 'language', 'assets_path', 'template', 'log_file', 'description_file', 'user_list', 'download_count', 'hidden_files', 'banned_list'); $checkboxes = array('show_dir_size', 'use_login_system', 'force_download', 'search_enabled', 'anti_leech', 'must_login_to_download', 'archive', 'parse_htaccess'); $numbers = array('days_new', 'thumbnail_height', 'bandwidth_limit', 'md5_show', 'entries_per_page'); - -if (count($_POST) >= count($strings) + count($numbers)) +//debug code here: print_r('post array: ' . $request->post_array() . ', strings: ' . count($strings) . ', numbers: ' . count($numbers)); +if ($request->post_array() >= count($strings) + count($numbers)) { $directories = array('base_dir', 'icon_path', 'flag_path', 'assets_path', 'template'); $output = "= count($strings) + count($numbers)) $output .= "$setting\tfalse\n"; continue; } - $_POST[$setting] = str_replace('\\', '/', $_POST[$setting]); - if (in_array($setting, $directories) && !preg_match('#/$#', $_POST[$setting])) + $request->recursive_set_var($setting, str_replace('\\', '/', $request->post($setting)), false); + if (in_array($setting, $directories) && !preg_match('#/$#', $request->post($setting))) //make sure there is a slash at the end of directories { - $_POST[$setting] .= '/'; + $request->recursive_set_var($setting, $request->post($setting) . '/', false); } - $output .= "$setting\t{$_POST[$setting]}\n"; + $output .= "$setting\t{$request->post($setting)}\n"; } + $_POST[$setting] = $request->post($setting); foreach ($checkboxes as $setting) { $output .= "$setting\t" . (isset($_POST[$setting]) ? 'true' : 'false') @@ -145,7 +151,6 @@ if (count($_POST) >= count($strings) + count($numbers)) //begin display of "configuration complete" page echo ''; ?> - @@ -197,7 +202,6 @@ if (count($_POST) >= count($strings) + count($numbers)) die(); } } - //list of default settings $settings = array( 'base_dir' => './', @@ -226,21 +230,17 @@ $settings = array( 'md5_show' => '20', 'parse_htaccess' => 'true' ); - global $config; -if (isset($config)) -//if we're reconfiguring the script, use the current settings +if (isset($config)) //if we're reconfiguring the script, use the current settings { foreach ($settings as $key => $data) { $settings[$key] = $config -> __get($key); } } - //begin display of main configuration page: echo ''; ?> -