diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-07-27 10:05:23 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-07-27 10:05:23 +0200 |
| commit | 5bf66662a9bdd62c5bccab15e607cd95cfb8fcab (patch) | |
| tree | 39a1a4629749056191c05dfd899f931701b7acf3 /srcs/phpmyadmin/libraries/classes/Setup | |
| parent | 5afd237bbd22028b85532b8c0b3fcead49a00764 (diff) | |
| download | ft_server-master.tar.gz ft_server-master.tar.bz2 ft_server-master.zip | |
Removed wordpress and phpmyadmin, my server doesn't handle it well and it brings shame on my famillyHEADmaster
Diffstat (limited to 'srcs/phpmyadmin/libraries/classes/Setup')
3 files changed, 0 insertions, 459 deletions
diff --git a/srcs/phpmyadmin/libraries/classes/Setup/ConfigGenerator.php b/srcs/phpmyadmin/libraries/classes/Setup/ConfigGenerator.php deleted file mode 100644 index 8ba09ab..0000000 --- a/srcs/phpmyadmin/libraries/classes/Setup/ConfigGenerator.php +++ /dev/null @@ -1,184 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Config file generator - * - * @package PhpMyAdmin-Setup - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Setup; - -use PhpMyAdmin\Config\ConfigFile; - -/** - * Config file generation class - * - * @package PhpMyAdmin - */ -class ConfigGenerator -{ - /** - * Creates config file - * - * @param ConfigFile $cf Config file instance - * - * @return string - */ - public static function getConfigFile(ConfigFile $cf) - { - $crlf = (isset($_SESSION['eol']) && $_SESSION['eol'] == 'win') - ? "\r\n" - : "\n"; - $conf = $cf->getConfig(); - - // header - $ret = '<?php' . $crlf - . '/*' . $crlf - . ' * Generated configuration file' . $crlf - . ' * Generated by: phpMyAdmin ' - . $GLOBALS['PMA_Config']->get('PMA_VERSION') - . ' setup script' . $crlf - . ' * Date: ' . gmdate(DATE_RFC1123) . $crlf - . ' */' . $crlf . $crlf; - - //servers - if (! empty($conf['Servers'])) { - $ret .= self::getServerPart($cf, $crlf, $conf['Servers']); - unset($conf['Servers']); - } - - // other settings - $persistKeys = $cf->getPersistKeysMap(); - - foreach ($conf as $k => $v) { - $k = preg_replace('/[^A-Za-z0-9_]/', '_', $k); - $ret .= self::_getVarExport($k, $v, $crlf); - if (isset($persistKeys[$k])) { - unset($persistKeys[$k]); - } - } - // keep 1d array keys which are present in $persist_keys (config.values.php) - foreach (array_keys($persistKeys) as $k) { - if (mb_strpos($k, '/') === false) { - $k = preg_replace('/[^A-Za-z0-9_]/', '_', $k); - $ret .= self::_getVarExport($k, $cf->getDefault($k), $crlf); - } - } - $ret .= '?' . '>'; - - return $ret; - } - - /** - * Returns exported configuration variable - * - * @param string $var_name configuration name - * @param mixed $var_value configuration value(s) - * @param string $crlf line ending - * - * @return string - */ - private static function _getVarExport($var_name, $var_value, $crlf) - { - if (! is_array($var_value) || empty($var_value)) { - return "\$cfg['$var_name'] = " - . var_export($var_value, true) . ';' . $crlf; - } - $ret = ''; - if (self::_isZeroBasedArray($var_value)) { - $ret = "\$cfg['$var_name'] = " - . self::_exportZeroBasedArray($var_value, $crlf) - . ';' . $crlf; - } else { - // string keys: $cfg[key][subkey] = value - foreach ($var_value as $k => $v) { - $k = preg_replace('/[^A-Za-z0-9_]/', '_', $k); - $ret .= "\$cfg['$var_name']['$k'] = " - . var_export($v, true) . ';' . $crlf; - } - } - return $ret; - } - - /** - * Check whether $array is a continuous 0-based array - * - * @param array $array Array to check - * - * @return boolean - */ - private static function _isZeroBasedArray(array $array) - { - for ($i = 0, $nb = count($array); $i < $nb; $i++) { - if (! isset($array[$i])) { - return false; - } - } - return true; - } - - /** - * Exports continuous 0-based array - * - * @param array $array Array to export - * @param string $crlf Newline string - * - * @return string - */ - private static function _exportZeroBasedArray(array $array, $crlf) - { - $retv = []; - foreach ($array as $v) { - $retv[] = var_export($v, true); - } - $ret = "array("; - if (count($retv) <= 4) { - // up to 4 values - one line - $ret .= implode(', ', $retv); - } else { - // more than 4 values - value per line - $imax = count($retv); - for ($i = 0; $i < $imax; $i++) { - $ret .= ($i > 0 ? ',' : '') . $crlf . ' ' . $retv[$i]; - } - } - $ret .= ')'; - return $ret; - } - - /** - * Generate server part of config file - * - * @param ConfigFile $cf Config file - * @param string $crlf Carriage return char - * @param array $servers Servers list - * - * @return string|null - */ - protected static function getServerPart(ConfigFile $cf, $crlf, array $servers) - { - if ($cf->getServerCount() === 0) { - return null; - } - - $ret = "/* Servers configuration */$crlf\$i = 0;" . $crlf . $crlf; - foreach ($servers as $id => $server) { - $ret .= '/* Server: ' - . strtr($cf->getServerName($id) . " [$id] ", '*/', '-') - . "*/" . $crlf - . '$i++;' . $crlf; - foreach ($server as $k => $v) { - $k = preg_replace('/[^A-Za-z0-9_]/', '_', $k); - $ret .= "\$cfg['Servers'][\$i]['$k'] = " - . (is_array($v) && self::_isZeroBasedArray($v) - ? self::_exportZeroBasedArray($v, $crlf) - : var_export($v, true)) - . ';' . $crlf; - } - $ret .= $crlf; - } - $ret .= '/* End of servers configuration */' . $crlf . $crlf; - return $ret; - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Setup/FormProcessing.php b/srcs/phpmyadmin/libraries/classes/Setup/FormProcessing.php deleted file mode 100644 index dce9ecc..0000000 --- a/srcs/phpmyadmin/libraries/classes/Setup/FormProcessing.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Formset processing library - * - * @package PhpMyAdmin-Setup - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Setup; - -use PhpMyAdmin\Config\FormDisplay; -use PhpMyAdmin\Core; -use PhpMyAdmin\Response; -use PhpMyAdmin\Template; -use PhpMyAdmin\Url; - -/** - * PhpMyAdmin\Setup\FormProcessing class - * - * @package PhpMyAdmin-Setup - */ -class FormProcessing -{ - /** - * Processes forms registered in $form_display, handles error correction - * - * @param FormDisplay $form_display Form to display - * - * @return void - */ - public static function process(FormDisplay $form_display) - { - if (isset($_GET['mode']) && $_GET['mode'] == 'revert') { - // revert erroneous fields to their default values - $form_display->fixErrors(); - $response = Response::getInstance(); - $response->disable(); - $response->generateHeader303('index.php' . Url::getCommonRaw()); - } - - if (! $form_display->process(false)) { - // handle form view and failed POST - echo $form_display->getDisplay(true, true); - return; - } - - // check for form errors - if (! $form_display->hasErrors()) { - $response = Response::getInstance(); - $response->disable(); - $response->generateHeader303('index.php' . Url::getCommonRaw()); - return; - } - - // form has errors, show warning - $page = isset($_GET['page']) ? $_GET['page'] : ''; - $formset = isset($_GET['formset']) ? $_GET['formset'] : ''; - $formId = Core::isValid($_GET['id'], 'numeric') ? $_GET['id'] : ''; - if ($formId === null && $page == 'servers') { - // we've just added a new server, get its id - $formId = $form_display->getConfigFile()->getServerCount(); - } - - $urlParams = [ - 'page' => $page, - 'formset' => $formset, - 'id' => $formId, - ]; - - $template = new Template(); - echo $template->render('setup/error', [ - 'url_params' => $urlParams, - 'errors' => $form_display->displayErrors(), - ]); - } -} diff --git a/srcs/phpmyadmin/libraries/classes/Setup/Index.php b/srcs/phpmyadmin/libraries/classes/Setup/Index.php deleted file mode 100644 index 9518221..0000000 --- a/srcs/phpmyadmin/libraries/classes/Setup/Index.php +++ /dev/null @@ -1,198 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Various checks and message functions used on index page. - * - * @package PhpMyAdmin-Setup - */ -declare(strict_types=1); - -namespace PhpMyAdmin\Setup; - -use PhpMyAdmin\Sanitize; -use PhpMyAdmin\VersionInformation; - -/** - * PhpMyAdmin\Setup\Index class - * - * Various checks and message functions used on index page. - * - * @package PhpMyAdmin-Setup - */ -class Index -{ - /** - * Initializes message list - * - * @return void - */ - public static function messagesBegin() - { - if (! isset($_SESSION['messages']) || ! is_array($_SESSION['messages'])) { - $_SESSION['messages'] = [ - 'error' => [], - 'notice' => [], - ]; - } else { - // reset message states - foreach ($_SESSION['messages'] as &$messages) { - foreach ($messages as &$msg) { - $msg['fresh'] = false; - $msg['active'] = false; - } - } - } - } - - /** - * Adds a new message to message list - * - * @param string $type one of: notice, error - * @param string $msgId unique message identifier - * @param string $title language string id (in $str array) - * @param string $message message text - * - * @return void - */ - public static function messagesSet($type, $msgId, $title, $message) - { - $fresh = ! isset($_SESSION['messages'][$type][$msgId]); - $_SESSION['messages'][$type][$msgId] = [ - 'fresh' => $fresh, - 'active' => true, - 'title' => $title, - 'message' => $message, - ]; - } - - /** - * Cleans up message list - * - * @return void - */ - public static function messagesEnd() - { - foreach ($_SESSION['messages'] as &$messages) { - $remove_ids = []; - foreach ($messages as $id => &$msg) { - if ($msg['active'] == false) { - $remove_ids[] = $id; - } - } - foreach ($remove_ids as $id) { - unset($messages[$id]); - } - } - } - - /** - * Prints message list, must be called after self::messagesEnd() - * - * @return array - */ - public static function messagesShowHtml() - { - $return = []; - foreach ($_SESSION['messages'] as $type => $messages) { - foreach ($messages as $id => $msg) { - $return[] = [ - 'id' => $id, - 'title' => $msg['title'], - 'type' => $type, - 'message' => $msg['message'], - 'is_hidden' => ! $msg['fresh'] && $type !== 'error', - ]; - } - } - return $return; - } - - /** - * Checks for newest phpMyAdmin version and sets result as a new notice - * - * @return void - */ - public static function versionCheck() - { - // version check messages should always be visible so let's make - // a unique message id each time we run it - $message_id = uniqid('version_check'); - - // Fetch data - $versionInformation = new VersionInformation(); - $version_data = $versionInformation->getLatestVersion(); - - if (empty($version_data)) { - self::messagesSet( - 'error', - $message_id, - __('Version check'), - __( - 'Reading of version failed. ' - . 'Maybe you\'re offline or the upgrade server does not respond.' - ) - ); - return; - } - - $releases = $version_data->releases; - $latestCompatible = $versionInformation->getLatestCompatibleVersion($releases); - if ($latestCompatible != null) { - $version = $latestCompatible['version']; - $date = $latestCompatible['date']; - } else { - return; - } - - $version_upstream = $versionInformation->versionToInt($version); - if ($version_upstream === false) { - self::messagesSet( - 'error', - $message_id, - __('Version check'), - __('Got invalid version string from server') - ); - return; - } - - $version_local = $versionInformation->versionToInt( - $GLOBALS['PMA_Config']->get('PMA_VERSION') - ); - if ($version_local === false) { - self::messagesSet( - 'error', - $message_id, - __('Version check'), - __('Unparsable version string') - ); - return; - } - - if ($version_upstream > $version_local) { - $version = htmlspecialchars($version); - $date = htmlspecialchars($date); - self::messagesSet( - 'notice', - $message_id, - __('Version check'), - sprintf(__('A newer version of phpMyAdmin is available and you should consider upgrading. The newest version is %s, released on %s.'), $version, $date) - ); - } else { - if ($version_local % 100 == 0) { - self::messagesSet( - 'notice', - $message_id, - __('Version check'), - Sanitize::sanitizeMessage(sprintf(__('You are using Git version, run [kbd]git pull[/kbd] :-)[br]The latest stable version is %s, released on %s.'), $version, $date)) - ); - } else { - self::messagesSet( - 'notice', - $message_id, - __('Version check'), - __('No newer stable version is available') - ); - } - } - } -} |
