/** * process post-params on config-update and init settings-array * * @return array with settings */ function processSettingsParams() { // move hack unset($_POST['addCatButton']); unset($_POST['remCatButton']); unset($_POST['categorylist']); unset($_POST['category']); // init settings array from params // process and handle all specials and exceptions while doing this. $settings = array(); // good-look-stats $hackStatsPrefix = "hack_goodlookstats_settings_"; $hackStatsStringLen = strlen($hackStatsPrefix); $settingsHackAry = array(); for ($i = 0; $i <= 5; $i++) { $settingsHackAry[$i] = 0; } $hackStatsUpdate = false; // index-page $indexPageSettingsPrefix = "index_page_settings_"; $indexPageSettingsPrefixLen = strlen($indexPageSettingsPrefix); $settingsIndexPageAry = array(); for ($j = 0; $j <= 10; $j++) { $settingsIndexPageAry[$j] = 0; } $indexPageSettingsUpdate = false; // foreach ($_POST as $key => $value) { if (substr($key, 0, $hackStatsStringLen) == $hackStatsPrefix) { // good-look-stats $idx = (int) substr($key, -1, 1); if ($value != "0") { $settingsHackAry[$idx] = 1; } else { $settingsHackAry[$idx] = 0; } $hackStatsUpdate = true; } else { if (substr($key, 0, $indexPageSettingsPrefixLen) == $indexPageSettingsPrefix) { // index-page $idx = (int) substr($key, $indexPageSettingsPrefixLen - strlen($key)); if ($value != "0") { $settingsIndexPageAry[$idx] = 1; } else { $settingsIndexPageAry[$idx] = 0; } $indexPageSettingsUpdate = true; } else { switch ($key) { case "path": // tf-path $settings[$key] = trim(checkDirPathString($value)); break; case "move_paths": // move-hack-paths $dirAry = explode(":", $value); $val = ""; for ($idx = 0; $idx < count($dirAry); $idx++) { if ($idx > 0) { $val .= ':'; } $val .= trim(checkDirPathString($dirAry[$idx])); } $settings[$key] = trim($val); break; default: // "normal" key-val-pair $settings[$key] = $value; } } } } // good-look-stats if ($hackStatsUpdate) { $settings['hack_goodlookstats_settings'] = convertArrayToByte($settingsHackAry); } // index-page if ($indexPageSettingsUpdate) { $settings['index_page_settings'] = convertArrayToInteger($settingsIndexPageAry); } // return return $settings; }
/** * process post-params on config-update and init settings-array * * @param $updateIndexSettings * @param $updateGoodlookinSettings * @return array with settings */ function processSettingsParams($updateIndexSettings = true, $updateGoodlookinSettings = true) { // move if (isset($_POST['categorylist'])) { unset($_POST['categorylist']); } if (isset($_POST['category'])) { unset($_POST['category']); } // res-dir if (isset($_POST['resdirlist'])) { unset($_POST['resdirlist']); } if (isset($_POST['resdirentry'])) { unset($_POST['resdirentry']); } // init settings array from params // process and handle all specials and exceptions while doing this. $settings = array(); // index-page if ($updateIndexSettings) { $indexPageSettingsPrefix = "index_page_settings_"; $indexPageSettingsPrefixLen = strlen($indexPageSettingsPrefix); $settingsIndexPageAry = array(); for ($j = 0; $j <= 11; $j++) { $settingsIndexPageAry[$j] = 0; } } // good-look-stats if ($updateGoodlookinSettings) { $hackStatsPrefix = "hack_goodlookstats_settings_"; $hackStatsStringLen = strlen($hackStatsPrefix); $settingsHackAry = array(); for ($i = 0; $i <= 5; $i++) { $settingsHackAry[$i] = 0; } } // foreach ($_POST as $key => $value) { if ($updateIndexSettings && substr($key, 0, $hackStatsStringLen) == $hackStatsPrefix) { // good-look-stats $idx = intval(substr($key, -1, 1)); $settingsHackAry[$idx] = $value != "0" ? 1 : 0; } else { if ($updateGoodlookinSettings && substr($key, 0, $indexPageSettingsPrefixLen) == $indexPageSettingsPrefix) { // index-page $idx = intval(substr($key, $indexPageSettingsPrefixLen - strlen($key))); $settingsIndexPageAry[$idx] = $value != "0" ? 1 : 0; } else { switch ($key) { case "path": // tf-path $settings[$key] = trim(checkDirPathString($value)); break; case "docroot": // tf-docroot $settings[$key] = trim(checkDirPathString($value)); break; case "move_paths": // move-hack-paths if (strlen($value) > 0) { $val = ""; $dirAry = explode(":", $value); for ($idx = 0; $idx < count($dirAry); $idx++) { if ($idx > 0) { $val .= ':'; } $val .= trim(checkDirPathString($dirAry[$idx])); } $settings[$key] = trim($val); } else { $settings[$key] = ""; } break; default: // "normal" key-val-pair $settings[$key] = $value; } } } } // index-page if ($updateIndexSettings) { $settings['index_page_settings'] = convertArrayToInteger($settingsIndexPageAry); } // good-look-stats if ($updateGoodlookinSettings) { $settings['hack_goodlookstats_settings'] = convertArrayToByte($settingsHackAry); } // return return $settings; }