summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Schulthess2017-01-20 12:35:10 +0100
committerChristoph Schulthess2017-01-20 12:35:10 +0100
commit9d71e59e1030a951c00a7c511ce79a074df30d2e (patch)
tree100888a2a48d9838dcca9d7372c1edeb68925c1a
parentpreliminary debugrequest version (diff)
downloadslx-admin-9d71e59e1030a951c00a7c511ce79a074df30d2e.tar.gz
slx-admin-9d71e59e1030a951c00a7c511ce79a074df30d2e.tar.xz
slx-admin-9d71e59e1030a951c00a7c511ce79a074df30d2e.zip
deleted unused files
-rw-r--r--modules-available/debugconfig/api.inc.php115
-rw-r--r--modules-available/debugconfig/inc/baseconfigutil.inc.php83
-rw-r--r--modules-available/debugconfig/inc/validator.inc.php106
-rw-r--r--modules-available/debugconfig/install.inc.php58
4 files changed, 0 insertions, 362 deletions
diff --git a/modules-available/debugconfig/api.inc.php b/modules-available/debugconfig/api.inc.php
deleted file mode 100644
index af780d99..00000000
--- a/modules-available/debugconfig/api.inc.php
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php
-
-$ip = $_SERVER['REMOTE_ADDR'];
-if (substr($ip, 0, 7) === '::ffff:') {
- $ip = substr($ip, 7);
-}
-
-$uuid = Request::any('uuid', false, 'string');
-if ($uuid !== false && strlen($uuid) !== 36) {
- $uuid = false;
-}
-
-/**
- * Escape given string so it is a valid string in sh that can be surrounded
- * by single quotes ('). This basically turns _'_ into _'"'"'_
- *
- * @param string $string input
- * @return string escaped sh string
- */
-function escape($string)
-{
- return str_replace("'", "'\"'\"'", $string);
-}
-
-/*
- * We gather all config variables here. First, let other modules generate
- * their desired config vars. Afterwards, add the global config vars from
- * db. If a variable is already set, it will not be overridden by the
- * global setting.
- */
-
-$configVars = array();
-function handleModule($file, $ip, $uuid) // Pass ip and uuid instead of global to make them read only
-{
- global $configVars;
- include_once $file;
-}
-
-// Handle any hooks by other modules first
-// other modules should generally only populate $configVars
-foreach (glob('modules/*/baseconfig/getconfig.inc.php') as $file) {
- preg_match('#^modules/([^/]+)/#', $file, $out);
- $mod = Module::get($out[1]);
- if ($mod === false)
- continue;
- $mod->activate();
- foreach ($mod->getDependencies() as $dep) {
- $depFile = 'modules/' . $dep . '/baseconfig/getconfig.inc.php';
- if (file_exists($depFile) && Module::isAvailable($dep)) {
- handleModule($depFile, $ip, $uuid);
- }
- }
- handleModule($file, $ip, $uuid);
-}
-
-// Rest is handled by module
-$defaults = BaseConfigUtil::getVariables();
-
-// Dump global config from DB
-$res = Database::simpleQuery('SELECT setting, value, enabled FROM setting_global');
-while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- if (isset($configVars[$row['setting']]) // Already set by a hook above, ignore
- || !isset($defaults[$row['setting']])) // Setting is not defined in any <module>/baseconfig/settings.json
- continue;
- if ($row['enabled'] != 1) {
- // Setting is disabled
- $configVars[$row['setting']] = false;
- } else {
- $configVars[$row['setting']] = $row['value'];
- }
-}
-
-// Fallback to default values from json files
-foreach ($defaults as $setting => $value) {
- if (isset($configVars[$setting])) {
- if ($configVars[$setting] === false) {
- unset($configVars[$setting]);
- }
- } else {
- $configVars[$setting] = $value['defaultvalue'];
- }
-}
-
-// All done, now output
-
-if (Request::any('save') === 'true') {
- // output AND save to disk: Generate contents
- $lines = '';
- foreach ($configVars as $setting => $value) {
- $lines .= $setting . "='" . escape($value) . "'\n";
- }
- // Save to all the locations
- $data = Property::getVersionCheckInformation();
- if (is_array($data) && isset($data['systems'])) {
- foreach ($data['systems'] as $system) {
- $path = CONFIG_HTTP_DIR . '/' . $system['id'] . '/config';
- if (file_put_contents($path, $lines) > 0) {
- echo "# Saved config to $path\n";
- } else {
- echo "# Error saving config to $path\n";
- }
- }
- }
- // Output to browser
- echo $lines;
-} else {
- // Only output to client
- foreach ($configVars as $setting => $value) {
- echo $setting, "='", escape($value), "'\n";
- }
-}
-
-// For quick testing or custom extensions: Include external file that should do nothing
-// more than outputting more key-value-pairs. It's expected in the webroot of slxadmin
-if (file_exists('client_config_additional.php')) @include('client_config_additional.php');
diff --git a/modules-available/debugconfig/inc/baseconfigutil.inc.php b/modules-available/debugconfig/inc/baseconfigutil.inc.php
deleted file mode 100644
index 3039ea12..00000000
--- a/modules-available/debugconfig/inc/baseconfigutil.inc.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-
-class BaseConfigUtil
-{
-
- /**
- * Return all config variables to be handled directly by the baseconfig edit module.
- * The array will contain a list of mapping of type:
- * VARNAME => array(
- * catid => xx,
- * defaultvalue => xx,
- * permissions => xx,
- * validator => xx,
- * )
- *
- * @param \Module $module optional, only consider given module, not all enabled modules
- * @return array all known config variables
- */
- public static function getVariables($module = false)
- {
- $settings = array();
- if ($module === false) {
- $module = '*';
- } else {
- $module = $module->getIdentifier();
- }
- foreach (glob("modules/{$module}/baseconfig/settings.json", GLOB_NOSORT) as $file) {
- $data = json_decode(file_get_contents($file), true);
- if (!is_array($data))
- continue;
- preg_match('#^modules/([^/]+)/#', $file, $out);
- foreach ($data as &$entry) {
- $entry['module'] = $out[1];
- }
- $settings += $data;
- }
- return $settings;
- }
-
- public static function getCategories($module = false)
- {
- $categories = array();
- if ($module === false) {
- $module = '*';
- } else {
- $module = $module->getIdentifier();
- }
- foreach (glob("modules/{$module}/baseconfig/categories.json", GLOB_NOSORT) as $file) {
- $data = json_decode(file_get_contents($file), true);
- if (!is_array($data))
- continue;
- preg_match('#^modules/([^/]+)/#', $file, $out);
- foreach ($data as &$entry) {
- $entry = array('module' => $out[1], 'sortpos' => $entry);
- }
- $categories += $data;
- }
- return $categories;
- }
-
- /**
- * Mark variables that would be shadowed according to the given values.
- *
- * @param $vars list of vars as obtained from BaseConfigUtil::getVariables()
- * @param $values key-value-pairs of variable assignments to work with
- */
- public static function markShadowedVars(&$vars, $values) {
- foreach ($vars as $key => &$var) {
- if (!isset($var['shadows']))
- continue;
- foreach ($var['shadows'] as $triggerVal => $destSettings) {
- if (isset($values[$key]) && $values[$key] !== $triggerVal)
- continue;
- foreach ($destSettings as $destSetting) {
- if (isset($vars[$destSetting])) {
- $vars[$destSetting]['shadowed'] = true;
- }
- }
- }
- }
- }
-
-}
diff --git a/modules-available/debugconfig/inc/validator.inc.php b/modules-available/debugconfig/inc/validator.inc.php
deleted file mode 100644
index ec7b95aa..00000000
--- a/modules-available/debugconfig/inc/validator.inc.php
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-
-/**
- * This class contains all the helper functions that
- * can be referenced by a config setting. Every function
- * here is supposed to validate the given config value
- * and either return the validated and possibly sanitized
- * value, or false to indicate that the given value is invalid.
- * The passed value is a reference, as it can also be modified
- * by the validator to tweak the value that is being
- * displayed in the web interface, compared to the returned
- * value, which will only be used by the client directly,
- * and is not displayed by the web interface.
- */
-class Validator
-{
-
- public static function validate($condition, &$displayValue)
- {
- if (empty($condition))
- return $displayValue;
- $data = explode(':', $condition, 2);
- switch ($data[0]) {
- case 'regex':
- if (preg_match($data[1], $displayValue))
- return $displayValue;
- return false;
- case 'list':
- return self::validateList($data[1], $displayValue);
- case 'function':
- return self::$data[1]($displayValue);
- case 'multilist':
- return self::validateMultiList($data[1], $displayValue);
- case 'multiinput':
- return self::validateMultiInput($data[1], $displayValue);
- default:
- Util::traceError('Unknown validation method: ' . $data[0]);
- }
- return false; // make code inspector happy - doesn't know traceError doesn't return
- }
-
-
- /**
- * Validate linux password. If already in $6$ hash form,
- * the unchanged value will be returned.
- * if empty, an empty string will also be returned.
- * Otherwise it it assumed that the value is a plain text
- * password that is supposed to be hashed.
- */
- private static function linuxPassword(&$displayValue)
- {
- if (empty($displayValue))
- return '';
- if (preg_match('/^\$[156]\$.+\$./', $displayValue))
- return $displayValue;
- return Crypto::hash6($displayValue);
- }
-
- /**
- * "Fix" network share path for SMB shares where a backslash
- * is used instead of a slash.
- * @param string $displayValue network path
- * @return string cleaned up path
- */
- private static function networkShare(&$displayValue)
- {
- $displayValue = trim($displayValue);
- if (substr($displayValue, 0, 2) === '\\\\')
- $displayValue = str_replace('\\', '/', $displayValue);
- $returnValue = $displayValue;
- if (substr($returnValue, 0, 2) === '//')
- $returnValue = str_replace(' ', '\\040', $returnValue);
- return $returnValue;
- }
-
- /**
- * Validate value against list.
- * @param string $list The list as a string of items, separated by "|"
- * @param string $displayValue The value to validate
- * @return boolean|string The value, if in list, false otherwise
- */
- private static function validateList($list, &$displayValue)
- {
- $list = explode('|', $list);
- if (in_array($displayValue, $list))
- return $displayValue;
- return false;
- }
- private static function validateMultiList($list, &$displayValue)
- {
- $allowedValues = explode('|', $list);
- $values = [];
- foreach ($displayValue as $v) {
- if (in_array($v, $allowedValues)) {
- $values[] = $v;
- }
- }
- $displayValue = implode(' ', $values);
- return $displayValue;
- }
-
- private static function validateMultiInput(&$list, &$displayValue)
- {
- return $displayValue;
- }
-}
diff --git a/modules-available/debugconfig/install.inc.php b/modules-available/debugconfig/install.inc.php
deleted file mode 100644
index b4eada5d..00000000
--- a/modules-available/debugconfig/install.inc.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-$res = array();
-
-$res[] = tableCreate('setting_global', "
- `setting` varchar(28) NOT NULL,
- `value` text NOT NULL,
- `displayvalue` text NOT NULL,
- `enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT '1',
- PRIMARY KEY (`setting`)
-");
-
-// Update path
-
-// Add toggle field
-
-if (!tableHasColumn('setting_global', 'enabled')) {
- if (tableHasColumn('setting_global', 'toggle')) {
- $ret = Database::exec("ALTER TABLE `setting_global` CHANGE `toggle` `enabled` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1'");
- } else {
- $ret = Database::exec("ALTER TABLE `setting_global` ADD COLUMN `enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT '1'");
- }
- if ($ret === false) {
- finalResponse(UPDATE_FAILED, 'Adding enabled to setting_global failed: ' . Database::lastError());
- }
-}
-
-// Add displayvalue field
-
-if (!tableHasColumn('setting_global', 'displayvalue')) {
- Database::exec("ALTER TABLE `setting_global` ADD `displayvalue` TEXT NOT NULL");
- Database::exec("UPDATE `setting_global` SET `displayvalue` = `value`");
- $res[] = UPDATE_DONE;
-}
-
-// Delete old tables
-
-/*
-Keep disabled for a while, in case some customer made unexpected important changes etc...
-
-if (tableExists('setting')) {
- Database::exec('DROP TABLE setting');
-}
-if (tableExists('setting_distro')) {
- Database::exec('DROP TABLE setting_distro');
-}
-if (tableExists('cat_setting')) {
- Database::exec('DROP TABLE cat_setting');
-}
-*/
-
-// Create response for browser
-
-if (in_array(UPDATE_DONE, $res)) {
- finalResponse(UPDATE_DONE, 'Tables created successfully');
-}
-
-finalResponse(UPDATE_NOOP, 'Everything already up to date');