Initial commit

This commit is contained in:
2022-11-21 09:47:28 +01:00
commit 76cec83d26
11652 changed files with 1980467 additions and 0 deletions

11
#pma/setup/ajax.js Normal file
View File

@ -0,0 +1,11 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Dummy implementation of the ajax page loader
*/
var AJAX = {
registerOnload: function (idx, func) {
$(document).ready(func);
},
registerTeardown: function (idx, func) {
}
};

102
#pma/setup/config.php Normal file
View File

@ -0,0 +1,102 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Front controller for config view / download and clear
*
* @package PhpMyAdmin-Setup
*/
use PMA\libraries\config\FormDisplay;
use PMA\setup\lib\ConfigGenerator;
/**
* Core libraries.
*/
require './lib/common.inc.php';
require './libraries/config/setup.forms.php';
/**
* Loads configuration file path
*
* Do this in a function to avoid messing up with global $cfg
*
* @param string $config_file_path
*
* @return array
*/
function loadConfig($config_file_path)
{
$cfg = array();
if (file_exists($config_file_path)) {
include $config_file_path;
}
return $cfg;
}
$form_display = new FormDisplay($GLOBALS['ConfigFile']);
$form_display->registerForm('_config.php', $forms['_config.php']);
$form_display->save('_config.php');
$config_file_path = $GLOBALS['ConfigFile']->getFilePath();
if (isset($_POST['eol'])) {
$_SESSION['eol'] = ($_POST['eol'] == 'unix') ? 'unix' : 'win';
}
if (PMA_ifSetOr($_POST['submit_clear'], '')) {
//
// Clear current config and return to main page
//
$GLOBALS['ConfigFile']->resetConfigData();
// drop post data
header('HTTP/1.1 303 See Other');
header('Location: index.php' . PMA_URL_getCommon());
exit;
} elseif (PMA_ifSetOr($_POST['submit_download'], '')) {
//
// Output generated config file
//
PMA_downloadHeader('config.inc.php', 'text/plain');
echo ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']);
exit;
} elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
//
// Save generated config file on the server
//
$result = @file_put_contents(
$config_file_path,
ConfigGenerator::getConfigFile($GLOBALS['ConfigFile'])
);
if ($result === false) {
$state = 'config_not_saved';
} else {
$state = 'config_saved';
}
header('HTTP/1.1 303 See Other');
header('Location: index.php' . PMA_URL_getCommon() . '&action_done=' . $state);
exit;
} elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
//
// Load config file from the server
//
$GLOBALS['ConfigFile']->setConfigData(
loadConfig($config_file_path)
);
header('HTTP/1.1 303 See Other');
header('Location: index.php' . PMA_URL_getCommon());
exit;
} elseif (PMA_ifSetOr($_POST['submit_delete'], '')) {
//
// Delete config file on the server
//
@unlink($config_file_path);
header('HTTP/1.1 303 See Other');
header('Location: index.php' . PMA_URL_getCommon());
exit;
} else {
//
// Show generated config file in a <textarea>
//
header('HTTP/1.1 303 See Other');
header('Location: index.php' . PMA_URL_getCommon() . '&page=config');
exit;
}

View File

@ -0,0 +1,52 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Config file view and save screen
*
* @package PhpMyAdmin-Setup
*/
use PMA\setup\lib\ConfigGenerator;
if (!defined('PHPMYADMIN')) {
exit;
}
/**
* Core libraries.
*/
require_once './libraries/config/FormDisplay.tpl.php';
require_once './setup/lib/index.lib.php';
$config_readable = false;
$config_writable = false;
$config_exists = false;
PMA_checkConfigRw($config_readable, $config_writable, $config_exists);
echo '<h2>' , __('Configuration file') , '</h2>';
echo PMA_displayFormTop('config.php');
echo '<input type="hidden" name="eol" value="'
, htmlspecialchars(PMA_ifSetOr($_GET['eol'], 'unix')) , '" />';
echo PMA_displayFieldsetTop('config.inc.php', '', null, array('class' => 'simple'));
echo '<tr>';
echo '<td>';
echo '<textarea cols="50" rows="20" name="textconfig" '
, 'id="textconfig" spellcheck="false">';
echo htmlspecialchars(ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']));
echo '</textarea>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="lastrow" style="text-align: left">';
echo '<input type="submit" name="submit_download" value="'
, __('Download') , '" class="green" />';
echo '<input type="submit" name="submit_save" value="' , __('Save') , '"';
if (!$config_writable) {
echo ' disabled="disabled"';
}
echo '/>';
echo '</td>';
echo '</tr>';
echo PMA_displayFieldsetBottomSimple();
echo PMA_displayFormBottom();

View File

@ -0,0 +1,35 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Form edit view
*
* @package PhpMyAdmin-Setup
*/
use PMA\libraries\config\FormDisplay;
if (!defined('PHPMYADMIN')) {
exit;
}
/**
* Core libraries.
*/
require_once './setup/lib/form_processing.lib.php';
require './libraries/config/setup.forms.php';
$formset_id = PMA_isValid($_GET['formset'], 'scalar') ? $_GET['formset'] : null;
$mode = isset($_GET['mode']) ? $_GET['mode'] : null;
if (! isset($forms[$formset_id]) || substr($formset_id, 0, 1) === '_') {
PMA_fatalError(__('Incorrect formset, check $formsets array in setup/frames/form.inc.php!'));
}
if (isset($GLOBALS['strConfigFormset_' . $formset_id])) {
echo '<h2>' , $GLOBALS['strConfigFormset_' . $formset_id] , '</h2>';
}
$form_display = new FormDisplay($GLOBALS['ConfigFile']);
foreach ($forms[$formset_id] as $form_name => $form) {
$form_display->registerForm($form_name, $form);
}
PMA_Process_formset($form_display);

View File

@ -0,0 +1,326 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Overview (main page)
*
* @package PhpMyAdmin-Setup
*/
use PMA\libraries\config\ConfigFile;
use PMA\libraries\config\FormDisplay;
use PMA\libraries\config\ServerConfigChecks;
use PMA\libraries\LanguageManager;
if (!defined('PHPMYADMIN')) {
exit;
}
/**
* Core libraries.
*/
require_once './libraries/display_select_lang.lib.php';
require_once './setup/lib/index.lib.php';
require_once './libraries/config/FormDisplay.tpl.php';
// prepare unfiltered language list
$all_languages = LanguageManager::getInstance()->sortedLanguages();
/** @var ConfigFile $cf */
$cf = $GLOBALS['ConfigFile'];
$separator = PMA_URL_getArgSeparator('html');
// message handling
PMA_messagesBegin();
//
// Check phpMyAdmin version
//
if (isset($_GET['version_check'])) {
PMA_versionCheck();
}
//
// Perform various security, compatibility and consistency checks
//
$configChecker = new ServerConfigChecks($GLOBALS['ConfigFile']);
$configChecker->performConfigChecks();
//
// Check whether we can read/write configuration
//
$config_readable = false;
$config_writable = false;
$config_exists = false;
PMA_checkConfigRw($config_readable, $config_writable, $config_exists);
if (!$config_writable || !$config_readable) {
PMA_messagesSet(
'error', 'config_rw', __('Cannot load or save configuration'),
PMA_sanitize(
__(
'Please create web server writable folder [em]config[/em] in '
. 'phpMyAdmin top level directory as described in '
. '[doc@setup_script]documentation[/doc]. Otherwise you will be '
. 'only able to download or display it.'
)
)
);
}
//
// Check https connection
//
$is_https = !empty($_SERVER['HTTPS'])
&& mb_strtolower($_SERVER['HTTPS']) == 'on';
if (!$is_https) {
$text = __(
'You are not using a secure connection; all data (including potentially '
. 'sensitive information, like passwords) is transferred unencrypted!'
);
$text .= ' <a href="#" onclick="window.location.href = \'https:\' + window.location.href.substring(window.location.protocol.length);">';
// Temporary workaround to use tranlated message in older releases
$text .= str_replace(
array('[a@%s]', '[/a]'),
array('', ''),
__(
'If your server is also configured to accept HTTPS requests '
. 'follow [a@%s]this link[/a] to use a secure connection.'
)
);
$text .= '</a>';
PMA_messagesSet('notice', 'no_https', __('Insecure connection'), $text);
}
echo '<form id="select_lang" method="post" action="'
, htmlspecialchars($_SERVER['REQUEST_URI']) , '">';
echo PMA_URL_getHiddenInputs();
echo '<bdo lang="en" dir="ltr"><label for="lang">';
echo __('Language') , (__('Language') != 'Language' ? ' - Language' : '');
echo '</label></bdo><br />';
echo '<select id="lang" name="lang" class="autosubmit" lang="en" dir="ltr">';
// create language list
$lang_list = array();
foreach ($all_languages as $each_lang) {
//Is current one active?
$selected = $each_lang->isActive() ? ' selected="selected"' : '';
echo '<option value="' , $each_lang->getCode() , '"' , $selected , '>' , $each_lang->getName()
, '</option>' , "\n";
}
echo '</select>';
echo '</form>';
// Check for done action info and set notice message if present
switch ($action_done) {
case 'config_saved':
/* Use uniqid to display this message every time configuration is saved */
PMA_messagesSet(
'notice', uniqid('config_saved'), __('Configuration saved.'),
PMA_sanitize(
__(
'Configuration saved to file config/config.inc.php in phpMyAdmin '
. 'top level directory, copy it to top level one and delete '
. 'directory config to use it.'
)
)
);
break;
case 'config_not_saved':
/* Use uniqid to display this message every time configuration is saved */
PMA_messagesSet(
'notice', uniqid('config_not_saved'), __('Configuration not saved!'),
PMA_sanitize(
__(
'Please create web server writable folder [em]config[/em] in '
. 'phpMyAdmin top level directory as described in '
. '[doc@setup_script]documentation[/doc]. Otherwise you will be '
. 'only able to download or display it.'
)
)
);
break;
default:
break;
}
echo '<h2>' , __('Overview') , '</h2>';
// message handling
PMA_messagesEnd();
PMA_messagesShowHtml();
echo '<a href="#" id="show_hidden_messages" style="display:none">';
echo __('Show hidden messages (#MSG_COUNT)');
echo '</a>';
echo '<fieldset class="simple"><legend>';
echo __('Servers');
echo '</legend>';
//
// Display server list
//
echo PMA_displayFormTop(
'index.php', 'get',
array(
'page' => 'servers',
'mode' => 'add'
)
);
echo '<div class="form">';
if ($cf->getServerCount() > 0) {
echo '<table cellspacing="0" class="datatable" style="table-layout: fixed">';
echo '<tr>';
echo '<th>#</th>';
echo '<th>' , __('Name') , '</th>';
echo '<th>' , __('Authentication type') , '</th>';
echo '<th colspan="2">DSN</th>';
echo '</tr>';
foreach ($cf->getServers() as $id => $server) {
echo '<tr>';
echo '<td>' , $id , '</td>';
echo '<td>' , htmlspecialchars($cf->getServerName($id)) , '</td>';
echo '<td>'
, htmlspecialchars($cf->getValue("Servers/$id/auth_type"))
, '</td>';
echo '<td>' , htmlspecialchars($cf->getServerDSN($id)) , '</td>';
echo '<td style="white-space: nowrap">';
echo '<small>';
echo '<a href="' , PMA_URL_getCommon() , $separator , 'page=servers'
, $separator , 'mode=edit' , $separator , 'id=' , $id , '">'
, __('Edit') , '</a>';
echo ' | ';
echo '<a href="' , PMA_URL_getCommon() , $separator , 'page=servers'
, $separator , 'mode=remove' , $separator , 'id=' , $id , '">'
, __('Delete') , '</a>';
echo '</small>';
echo '</td>';
echo '</tr>';
}
echo '</table>';
} else {
echo '<table width="100%">';
echo '<tr>';
echo '<td>';
echo '<i>' , __('There are no configured servers') , '</i>';
echo '</td>';
echo '</tr>';
echo '</table>';
}
echo '<table width="100%">';
echo '<tr>';
echo '<td class="lastrow" style="text-align: left">';
echo '<input type="submit" name="submit" value="' , __('New server') , '" />';
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</div>';
echo PMA_displayFormBottom();
echo '</fieldset>';
echo '<fieldset class="simple"><legend>' , __('Configuration file') , '</legend>';
//
// Display config file settings and load/save form
//
$form_display = new FormDisplay($cf);
echo PMA_displayFormTop('config.php');
echo '<table width="100%" cellspacing="0">';
// Display language list
$opts = array(
'doc' => $form_display->getDocLink('DefaultLang'),
'values' => array(),
'values_escaped' => true);
foreach ($all_languages as $each_lang) {
$opts['values'][$each_lang->getCode()] = $each_lang->getName();
}
echo PMA_displayInput(
'DefaultLang', __('Default language'), 'select',
$cf->getValue('DefaultLang'), '', true, $opts
);
// Display server list
$opts = array(
'doc' => $form_display->getDocLink('ServerDefault'),
'values' => array(),
'values_disabled' => array());
if ($cf->getServerCount() > 0) {
$opts['values']['0'] = __('let the user choose');
$opts['values']['-'] = '------------------------------';
if ($cf->getServerCount() == 1) {
$opts['values_disabled'][] = '0';
}
$opts['values_disabled'][] = '-';
foreach ($cf->getServers() as $id => $server) {
$opts['values'][(string)$id] = $cf->getServerName($id) . " [$id]";
}
} else {
$opts['values']['1'] = __('- none -');
$opts['values_escaped'] = true;
}
echo PMA_displayInput(
'ServerDefault', __('Default server'), 'select',
$cf->getValue('ServerDefault'), '', true, $opts
);
// Display EOL list
$opts = array(
'values' => array(
'unix' => 'UNIX / Linux (\n)',
'win' => 'Windows (\r\n)'),
'values_escaped' => true);
$eol = PMA_ifSetOr($_SESSION['eol'], (PMA_IS_WINDOWS ? 'win' : 'unix'));
echo PMA_displayInput(
'eol', __('End of line'), 'select',
$eol, '', true, $opts
);
echo '<tr>';
echo '<td colspan="2" class="lastrow" style="text-align: left">';
echo '<input type="submit" name="submit_display" value="' , __('Display') , '" />';
echo '<input type="submit" name="submit_download" value="' , __('Download') , '" />';
echo '&nbsp; &nbsp;';
echo '<input type="submit" name="submit_save" value="' , __('Save') , '"';
if (!$config_writable) {
echo ' disabled="disabled"';
}
echo '/>';
echo '<input type="submit" name="submit_load" value="' , __('Load') , '"';
if (!$config_exists) {
echo ' disabled="disabled"';
}
echo '/>';
echo '<input type="submit" name="submit_delete" value="' , __('Delete') , '"';
if (!$config_exists || !$config_writable) {
echo ' disabled="disabled"';
}
echo '/>';
echo '&nbsp; &nbsp;';
echo '<input type="submit" name="submit_clear" value="' , __('Clear')
, '" class="red" />';
echo '</td>';
echo '</tr>';
echo '</table>';
echo PMA_displayFormBottom();
echo '</fieldset>';
echo '<div id="footer">';
echo '<a href="../url.php?url=https://www.phpmyadmin.net/">' , __('phpMyAdmin homepage') , '</a>';
echo '<a href="../url.php?url=https://www.phpmyadmin.net/donate/">'
, __('Donate') , '</a>';
echo '<a href="' , PMA_URL_getCommon() , $separator , 'version_check=1">'
, __('Check for latest version') , '</a>';
echo '</div>';

View File

@ -0,0 +1,37 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Menu items
*
* @package PhpMyAdmin-Setup
*/
if (!defined('PHPMYADMIN')) {
exit;
}
$formset_id = isset($_GET['formset']) ? $_GET['formset'] : null;
$separator = PMA_URL_getArgSeparator('html');
echo '<ul>';
echo '<li><a href="index.php' , PMA_URL_getCommon() , '"'
, ($formset_id === null ? ' class="active' : '')
, '">' , __('Overview') , '</a></li>';
$formsets = array(
'Features' => __('Features'),
'Sql_queries' => __('SQL queries'),
'Navi_panel' => __('Navigation panel'),
'Main_panel' => __('Main panel'),
'Import' => __('Import'),
'Export' => __('Export')
);
foreach ($formsets as $formset => $label) {
echo '<li><a href="' , PMA_URL_getCommon() , $separator , 'page=form'
, $separator , 'formset=' , $formset , '" '
, ($formset_id === $formset ? ' class="active' : '')
, '">' , $label , '</a></li>';
}
echo '</ul>';

View File

@ -0,0 +1,51 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Server create and edit view
*
* @package PhpMyAdmin-Setup
*/
use PMA\libraries\config\ConfigFile;
use PMA\libraries\config\FormDisplay;
if (!defined('PHPMYADMIN')) {
exit;
}
/**
* Core libraries.
*/
require_once './setup/lib/form_processing.lib.php';
require './libraries/config/setup.forms.php';
$mode = isset($_GET['mode']) ? $_GET['mode'] : null;
$id = PMA_isValid($_GET['id'], 'numeric') ? intval($_GET['id']) : null;
/** @var ConfigFile $cf */
$cf = $GLOBALS['ConfigFile'];
$server_exists = !empty($id) && $cf->get("Servers/$id") !== null;
if ($mode == 'edit' && $server_exists) {
$page_title = __('Edit server')
. ' ' . $id
. ' <small>(' . htmlspecialchars($cf->getServerDSN($id)) . ')</small>';
} elseif ($mode == 'remove' && $server_exists) {
$cf->removeServer($id);
header('Location: index.php' . PMA_URL_getCommon());
exit;
} elseif ($mode == 'revert' && $server_exists) {
// handled by process_formset()
} else {
$page_title = __('Add a new server');
$id = 0;
}
if (isset($page_title)) {
echo '<h2>' , $page_title . '</h2>';
}
$form_display = new FormDisplay($cf);
foreach ($forms['Servers'] as $form_name => $form) {
$form_display->registerForm($form_name, $form, $id);
}
PMA_Process_formset($form_display);

61
#pma/setup/index.php Normal file
View File

@ -0,0 +1,61 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Front controller for setup script
*
* @package PhpMyAdmin-Setup
* @license https://www.gnu.org/licenses/gpl.html GNU GPL 2.0
*/
/**
* Core libraries.
*/
require './lib/common.inc.php';
$page = PMA_isValid($_GET['page'], 'scalar') ? $_GET['page'] : null;
$page = preg_replace('/[^a-z]/', '', $page);
if ($page === '') {
$page = 'index';
}
if (!file_exists("./setup/frames/$page.inc.php")) {
// it will happen only when entering URL by hand, we don't care for these cases
PMA_fatalError(__('Wrong GET file attribute value'));
}
// Handle done action info
$action_done = PMA_isValid($_GET['action_done'], 'scalar') ? $_GET['action_done'] : null;
$action_done = preg_replace('/[^a-z_]/', '', $action_done);
PMA_noCacheHeader();
?>
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>phpMyAdmin setup</title>
<link href="../favicon.ico" rel="icon" type="image/x-icon" />
<link href="../favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="../js/jquery/jquery-ui-1.11.4.min.js">
</script>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript" src="../js/config.js"></script>
<script type="text/javascript" src="scripts.js"></script>
<script type="text/javascript" src="../js/messages.php"></script>
</head>
<body>
<h1><span class="blue">php</span><span class="orange">MyAdmin</span> setup</h1>
<div id="menu">
<?php
require './setup/frames/menu.inc.php';
?>
</div>
<div id="page">
<?php
require "./setup/frames/$page.inc.php";
?>
</div>
</body>
</html>

View File

@ -0,0 +1,182 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Config file generator
*
* @package PhpMyAdmin-Setup
*/
namespace PMA\setup\lib;
use PMA\libraries\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 = array();
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
*/
protected static function getServerPart(ConfigFile $cf, $crlf, $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;
}
}

View File

@ -0,0 +1,54 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Loads libraries/common.inc.php and preforms some additional actions
*
* @package PhpMyAdmin-Setup
*/
use PMA\libraries\config\ConfigFile;
/**
* Do not include full common.
* @ignore
*/
define('PMA_MINIMUM_COMMON', true);
define('PMA_SETUP', true);
chdir('..');
if (!file_exists('./libraries/common.inc.php')) {
die('Bad invocation!');
}
require_once './libraries/common.inc.php';
require_once './libraries/config/config_functions.lib.php';
require_once './libraries/config/messages.inc.php';
require_once './libraries/url_generating.lib.php';
require_once './libraries/user_preferences.lib.php';
// use default error handler
restore_error_handler();
// Save current language in a cookie, required since we use PMA_MINIMUM_COMMON
$GLOBALS['PMA_Config']->setCookie('pma_lang', $GLOBALS['lang']);
$GLOBALS['ConfigFile'] = new ConfigFile();
$GLOBALS['ConfigFile']->setPersistKeys(
array(
'DefaultLang',
'ServerDefault',
'UploadDir',
'SaveDir',
'Servers/1/verbose',
'Servers/1/host',
'Servers/1/port',
'Servers/1/socket',
'Servers/1/connect_type',
'Servers/1/auth_type',
'Servers/1/user',
'Servers/1/password'
)
);
// allows for redirection even after sending some data
ob_start();

View File

@ -0,0 +1,81 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Formset processing library
*
* @package PhpMyAdmin-Setup
*/
use PMA\libraries\config\FormDisplay;
/**
* Processes forms registered in $form_display, handles error correction
*
* @param FormDisplay $form_display Form to display
*
* @return void
*/
function PMA_Process_formset(FormDisplay $form_display)
{
if (isset($_GET['mode']) && $_GET['mode'] == 'revert') {
// revert erroneous fields to their default values
$form_display->fixErrors();
PMA_generateHeader303();
}
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()) {
PMA_generateHeader303();
return;
}
// form has errors, show warning
$separator = PMA_URL_getArgSeparator('html');
$page = isset($_GET['page']) ? htmlspecialchars($_GET['page']) : null;
$formset = isset($_GET['formset']) ? htmlspecialchars($_GET['formset']) : null;
$formset = $formset ? "{$separator}formset=$formset" : '';
$formId = PMA_isValid($_GET['id'], 'numeric') ? $_GET['id'] : null;
if ($formId === null && $page == 'servers') {
// we've just added a new server, get its id
$formId = $form_display->getConfigFile()->getServerCount();
}
$formId = $formId ? "{$separator}id=$formId" : '';
?>
<div class="error">
<h4><?php echo __('Warning') ?></h4>
<?php echo __('Submitted form contains errors') ?><br />
<a href="<?php echo PMA_URL_getCommon() , $separator ?>page=<?php echo $page , $formset , $formId , $separator ?>mode=revert">
<?php echo __('Try to revert erroneous fields to their default values') ?>
</a>
</div>
<?php echo $form_display->displayErrors() ?>
<a class="btn" href="index.php<?php echo PMA_URL_getCommon() ?>">
<?php echo __('Ignore errors') ?>
</a>
&nbsp;
<a class="btn" href="<?php echo PMA_URL_getCommon() , $separator ?>page=<?php echo $page , $formset , $formId , $separator ?>mode=edit">
<?php echo __('Show form') ?>
</a>
<?php
}
/**
* Generate header for 303
*
* @return void
*/
function PMA_generateHeader303()
{
// drop post data
header('HTTP/1.1 303 See Other');
header('Location: index.php' . PMA_URL_getCommon());
if (!defined('TESTSUITE')) {
exit;
}
}

View File

@ -0,0 +1,213 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Various checks and message functions used on index page.
*
* @package PhpMyAdmin-Setup
*/
use PMA\libraries\VersionInformation;
if (!defined('PHPMYADMIN')) {
exit;
}
/**
* Initializes message list
*
* @return void
*/
function PMA_messagesBegin()
{
if (! isset($_SESSION['messages']) || !is_array($_SESSION['messages'])) {
$_SESSION['messages'] = array('error' => array(), 'notice' => array());
} 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
*/
function PMA_messagesSet($type, $msgId, $title, $message)
{
$fresh = ! isset($_SESSION['messages'][$type][$msgId]);
$_SESSION['messages'][$type][$msgId] = array(
'fresh' => $fresh,
'active' => true,
'title' => $title,
'message' => $message);
}
/**
* Cleans up message list
*
* @return void
*/
function PMA_messagesEnd()
{
foreach ($_SESSION['messages'] as &$messages) {
$remove_ids = array();
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 PMA_messagesEnd()
*
* @return void
*/
function PMA_messagesShowHtml()
{
$old_ids = array();
foreach ($_SESSION['messages'] as $type => $messages) {
foreach ($messages as $id => $msg) {
echo '<div class="' , $type , '" id="' , $id , '">'
, '<h4>' , $msg['title'] , '</h4>'
, $msg['message'] , '</div>';
if (!$msg['fresh'] && $type != 'error') {
$old_ids[] = $id;
}
}
}
echo "\n" , '<script type="text/javascript">';
foreach ($old_ids as $id) {
echo "\nhiddenMessages.push('$id');";
}
echo "\n</script>\n";
}
/**
* Checks for newest phpMyAdmin version and sets result as a new notice
*
* @return void
*/
function PMA_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)) {
PMA_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) {
PMA_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) {
PMA_messagesSet(
'error',
$message_id,
__('Version check'),
__('Unparsable version string')
);
return;
}
if ($version_upstream > $version_local) {
$version = htmlspecialchars($version);
$date = htmlspecialchars($date);
PMA_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) {
PMA_messagesSet(
'notice',
$message_id,
__('Version check'),
PMA_sanitize(sprintf(__('You are using Git version, run [kbd]git pull[/kbd] :-)[br]The latest stable version is %s, released on %s.'), $version, $date))
);
} else {
PMA_messagesSet(
'notice',
$message_id,
__('Version check'),
__('No newer stable version is available')
);
}
}
}
/**
* Checks whether config file is readable/writable
*
* @param bool &$is_readable whether the file is readable
* @param bool &$is_writable whether the file is writable
* @param bool &$file_exists whether the file exists
*
* @return void
*/
function PMA_checkConfigRw(&$is_readable, &$is_writable, &$file_exists)
{
$file_path = $GLOBALS['ConfigFile']->getFilePath();
$file_dir = dirname($file_path);
$is_readable = true;
$is_writable = @is_dir($file_dir);
if (SETUP_DIR_WRITABLE) {
$is_writable = $is_writable && @is_writable($file_dir);
}
$file_exists = file_exists($file_path);
if ($file_exists) {
$is_readable = is_readable($file_path);
$is_writable = $is_writable && @is_writable($file_path);
}
}

215
#pma/setup/scripts.js Normal file
View File

@ -0,0 +1,215 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Functions used in Setup configuration forms
*/
// show this window in top frame
if (top != self) {
window.top.location.href = location;
}
// ------------------------------------------------------------------
// Messages
//
// stores hidden message ids
var hiddenMessages = [];
$(function () {
var hidden = hiddenMessages.length;
for (var i = 0; i < hidden; i++) {
$('#' + hiddenMessages[i]).css('display', 'none');
}
if (hidden > 0) {
var link = $('#show_hidden_messages');
link.click(function (e) {
e.preventDefault();
for (var i = 0; i < hidden; i++) {
$('#' + hiddenMessages[i]).show(500);
}
$(this).remove();
});
link.html(link.html().replace('#MSG_COUNT', hidden));
link.css('display', '');
}
});
//set document width
$(document).ready(function(){
width = 0;
$('ul.tabs li').each(function(){
width += $(this).width() + 10;
});
var contentWidth = width;
width += 250;
$('body').css('min-width', width);
$('.tabs_contents').css('min-width', contentWidth);
});
//
// END: Messages
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// Form validation and field operations
//
/**
* Calls server-side validation procedures
*
* @param {Element} parent input field in <fieldset> or <fieldset>
* @param {String} id validator id
* @param {Object} values values hash {element1_id: value, ...}
*/
function ajaxValidate(parent, id, values)
{
parent = $(parent);
// ensure that parent is a fieldset
if (parent.attr('tagName') != 'FIELDSET') {
parent = parent.closest('fieldset');
if (parent.length === 0) {
return false;
}
}
if (parent.data('ajax') !== null) {
parent.data('ajax').abort();
}
parent.data('ajax', $.ajax({
url: 'validate.php',
cache: false,
type: 'POST',
data: {
token: parent.closest('form').find('input[name=token]').val(),
id: id,
values: JSON.stringify(values)
},
success: function (response) {
if (response === null) {
return;
}
var error = {};
if (typeof response != 'object') {
error[parent.id] = [response];
} else if (typeof response.error != 'undefined') {
error[parent.id] = [response.error];
} else {
for (var key in response) {
var value = response[key];
error[key] = jQuery.isArray(value) ? value : [value];
}
}
displayErrors(error);
},
complete: function () {
parent.removeData('ajax');
}
}));
return true;
}
/**
* Automatic form submission on change.
*/
$(document).on('change', '.autosubmit', function (e) {
e.target.form.submit();
});
$.extend(true, validators, {
// field validators
_field: {
/**
* hide_db field
*
* @param {boolean} isKeyUp
*/
hide_db: function (isKeyUp) {
if (!isKeyUp && this.value !== '') {
var data = {};
data[this.id] = this.value;
ajaxValidate(this, 'Servers/1/hide_db', data);
}
return true;
},
/**
* TrustedProxies field
*
* @param {boolean} isKeyUp
*/
TrustedProxies: function (isKeyUp) {
if (!isKeyUp && this.value !== '') {
var data = {};
data[this.id] = this.value;
ajaxValidate(this, 'TrustedProxies', data);
}
return true;
}
},
// fieldset validators
_fieldset: {
/**
* Validates Server fieldset
*
* @param {boolean} isKeyUp
*/
Server: function (isKeyUp) {
if (!isKeyUp) {
ajaxValidate(this, 'Server', getAllValues());
}
return true;
},
/**
* Validates Server_login_options fieldset
*
* @param {boolean} isKeyUp
*/
Server_login_options: function (isKeyUp) {
return validators._fieldset.Server.apply(this, [isKeyUp]);
},
/**
* Validates Server_pmadb fieldset
*
* @param {boolean} isKeyUp
*/
Server_pmadb: function (isKeyUp) {
if (isKeyUp) {
return true;
}
var prefix = getIdPrefix($(this).find('input'));
if ($('#' + prefix + 'pmadb').val() !== '') {
ajaxValidate(this, 'Server_pmadb', getAllValues());
}
return true;
}
}
});
//
// END: Form validation and field operations
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// User preferences allow/disallow UI
//
$(function () {
$('.userprefs-allow').click(function (e) {
if (this != e.target) {
return;
}
var el = $(this).find('input');
if (el.prop('disabled')) {
return;
}
el.prop('checked', !el.prop('checked'));
});
});
//
// END: User preferences allow/disallow UI
// ------------------------------------------------------------------

608
#pma/setup/styles.css Normal file
View File

@ -0,0 +1,608 @@
/* global styles */
body {
margin-right: auto;
min-width: 960px;
padding-bottom: 1em;
color: #444;
font: .8em sans-serif;
background: url(../themes/pmahomme/img/left_nav_bg.png) repeat-y 80px 0 #f3f3f3;
}
input,
button,
select,
textarea,
th,
td {
font: 1em sans-serif;
}
img {
border: 0;
}
a,
a:link,
a:visited,
a:active {
text-decoration: none;
color: #235a81;
cursor: pointer;
outline: none;
}
a:hover {
text-decoration: underline;
color: #235a81;
}
h1 {
font-size: 1.5em;
}
/* language selection box */
#select_lang {
position: absolute;
right: 1em;
top: 1em;
}
/* menu */
#menu {
float: left;
width: 220px;
font-size: 1.1em;
}
#menu ul {
margin: 1em 1em 1em .5em;
padding: 0;
list-style: none;
}
#menu li a {
padding: .5em .6em;
margin-right: .6em;
display: block;
color: #333;
text-decoration: none;
zoom: 1; /* IE fix */
}
#menu li a:hover, #menu li a:active, #menu li a.active {
background-color: #e4e4e4;
}
/* page contents and footer layout */
#page {
margin-left: 220px;
margin-right: 25px;
}
#footer {
margin-top: 1em;
}
#footer a {
margin-right: 0.5em;
text-decoration: none;
font-size: small;
}
/* phpMyAdmin logo colors */
.blue {
color: #666699;
}
.orange {
color: #FF9900;
}
.red {
color: #C00;
}
/* main page messages */
/* message boxes: error, confirmation */
.success h4,
.notice h4,
div.error h4 {
border-bottom: 1px solid;
font-weight: bold;
margin: 0 0 .2em 0;
}
div.success,
div.notice,
div.error {
margin: .5em 0 1.3em 0;
border: 1px solid;
background: no-repeat 10px 10px;
padding: 10px 10px 10px 25px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0 1px 1px #fff inset;
-webkit-box-shadow: 0 1px 1px #fff inset;
box-shadow: 0 1px 1px #fff inset;
}
.success a,
.notice a,
.error a {
text-decoration: underline;
}
.success {
color: #000;
background-color: #ebf8a4;
}
h1.success,
div.success {
border-color: #a2d246;
background: url(../themes/pmahomme/img/s_success.png) no-repeat 5px 10px;
}
.success h4 {
border-color: #00FF00;
}
.notice {
color: #000;
background-color: #e8eef1;
}
h1.notice,
div.notice {
border-color: #3a6c7e;
background: url(../themes/pmahomme/img/s_notice.png) no-repeat 5px 10px;
}
.notice h4 {
border-color: #ffb10a;
}
.error {
border: 1px solid maroon !important;
color: #000;
background: pink;
}
h1.error,
div.error {
border-color: #333;
background: url(../themes/pmahomme/img/s_error.png) no-repeat 5px 10px;
}
div.error h4 {
border-color: #ff0000;
}
div.notice[id^=version_check] {
border-color: #002DFF;
background-color: #EEF;
}
div.notice[id^=version_check] h4 {
border-color: #002DFF;
}
/* form tabs */
ul.tabs {
margin: 1.1em 2px 0;
padding: 0 0 3px 0;
list-style: none;
font-weight: bold;
}
ul.tabs li {
float: left;
margin-bottom: -1px;
}
ul.tabs li a {
display: block;
margin: 1px .2em 0;
white-space: nowrap;
text-decoration: none;
border: 1px solid #D5D5D5;
border-bottom: 1px solid #aaa;
}
ul.tabs li a {
padding: 7px 10px;
-webkit-border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
background: #f2f2f2;
color: #555;
text-shadow: 0 1px 0 #fff;
}
ul.tabs li a:hover,
ul.tabs li a:active {
background: #e5e5e5;
}
ul.tabs li.active a {
background-color: #fff;
margin-top: 1px;
color: #000;
text-shadow: none;
border-color: #aaa;
border-bottom: 1px solid #fff;
}
.tabs_contents {
margin-top: 13px;
}
.tabs_contents fieldset {
margin-top: 0;
}
.tabs_contents legend {
display: none;
}
/* "restore default value" and "set value: foo" buttons */
.restore-default img, .set-value img {
margin-bottom: -3px;
}
.userprefs-comment {
cursor: help;
float: right;
}
/* forms */
fieldset {
margin-top: 1em;
border-radius: 4px 4px 0 0;
-moz-border-radius: 4px 4px 0 0;
-webkit-border-radius: 4px 4px 0 0;
border: #aaa solid 1px;
padding: 1.5em;
background: #eee;
text-shadow: 0 1px 0 #fff;
-moz-box-shadow: 1px 1px 2px #fff inset;
-webkit-box-shadow: 1px 1px 2px #fff inset;
box-shadow: 1px 1px 2px #fff inset;
}
fieldset.optbox {
padding: 0;
}
fieldset fieldset {
margin: .8em;
border: 1px solid #aaa;
background: #E8E8E8;
}
fieldset legend {
font-weight: bold;
color: #444;
padding: 5px 10px;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border: 1px solid #aaa;
background-color: #fff;
-moz-box-shadow: 3px 3px 15px #bbb;
-webkit-box-shadow: 3px 3px 15px #bbb;
box-shadow: 3px 3px 15px #bbb;
}
.form {
border: 2px #DEE1FF solid;
}
fieldset p {
margin: 0;
padding: .5em;
background: #fff;
border-top: 0;
}
fieldset .errors { /* form error list */
margin: 0 -2px 1em -2px;
padding: 0.5em 1.5em;
background: #FBEAD9;
border: 1px #C83838 solid;
border-width: 1px 0;
list-style: none;
font-family: sans-serif;
font-size: small;
}
fieldset .inline_errors { /* field error list */
margin: 0.3em 0.3em 0.3em 0;
padding: 0;
list-style: none;
color: #9A0000;
font-size: small;
}
table caption, table th, table td {
text-shadow: 0 1px 0 #FFFFFF;
}
fieldset th {
width: 40%;
min-width: 350px;
padding: 0.3em 0.3em 0.3em 0.5em;
text-align: left;
font-weight: bold;
vertical-align: top;
}
fieldset.simple th {
width: auto;
min-width: 0;
}
fieldset .doc {
margin-left: 1em;
}
fieldset td {
padding-top: 0.3em;
vertical-align: top;
}
fieldset td.userprefs-allow {
padding: 0;
vertical-align: middle;
text-align: center;
width: 3em;
}
fieldset td.userprefs-allow:hover {
cursor: pointer;
background-color: #EEE;
}
fieldset th small {
display: block;
font-weight: normal;
font-family: sans-serif;
font-size: x-small;
color: #666;
}
fieldset th, fieldset td, .form .lastrow {
border-top: 1px solid #D5D5D5;
}
fieldset .group-header th {
background: #EAEDFF;
border: none;
}
fieldset .group-field-1 th, fieldset .group-header-2 th {
padding-left: 1em;
}
fieldset .group-field-2 th, fieldset .group-header-3 th {
padding-left: 2em;
}
fieldset .group-field-3 th {
padding-left: 3em;
}
fieldset .lastrow, .form .lastrow {
border-top: 1px #000 solid;
background: #D3DCE3;
padding: .5em;
text-align: center;
}
input[type=text],
input[type=password],
input[type=number] {
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
box-shadow: 0 1px 2px #ddd;
-moz-box-shadow: 0 1px 2px #ddd;
-webkit-box-shadow: 0 1px 2px #ddd;
background: white;
border: 1px solid #aaa;
color: #555;
padding: 4px;
margin: 6px;
}
input[type=submit],
button[type=submit]:not(.mult_submit) {
font-weight: bold !important;
}
input[type=submit],
button[type=submit]:not(.mult_submit),
input[type=reset],
input[name=submit_reset],
input.button {
margin-left: 14px;
border: 1px solid #aaa;
padding: 3px 7px;
color: #111;
text-decoration: none;
background: #ddd;
border-radius: 12px;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
text-shadow: 0 1px 0 #fff;
background-image: url(../themes/svg_gradient.php?from=ffffff&to=cccccc);
background-size: 100% 100%;
background: -webkit-linear-gradient(top, #ffffff, #cccccc);
background: -moz-linear-gradient(top, #ffffff, #cccccc);
background: -ms-linear-gradient(top, #ffffff, #cccccc);
background: -o-linear-gradient(top, #ffffff, #cccccc);
}
input[type=submit]:hover,
button[type=submit]:not(.mult_submit):hover,
input[type=reset]:hover,
input[name=submit_reset]:hover,
input.button:hover {
position: relative;
background-image: url(../themes/svg_gradient.php?from=cccccc&to=dddddd);
background-size: 100% 100%;
background: -webkit-linear-gradient(top, #cccccc, #dddddd);
background: -moz-linear-gradient(top, #cccccc, #dddddd);
background: -ms-linear-gradient(top, #cccccc, #dddddd);
background: -o-linear-gradient(top, #cccccc, #dddddd);
cursor: pointer;
}
input[type=submit]:active,
button[type=submit]:not(.mult_submit):active,
input[type=reset]:active,
input[name=submit_reset]:active,
input.button:active {
position: relative;
top: 1px;
left: 1px;
}
input[type="checkbox"],
input[type="radio"] {
vertical-align: -11%;
}
select {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
-moz-box-shadow: 0 1px 2px #ddd;
-webkit-box-shadow: 0 1px 2px #ddd;
box-shadow: 0 1px 2px #ddd;
border: 1px solid #aaa;
color: #333;
padding: 3px;
background: white;
margin: 6px;
}
fieldset.simple th, fieldset.simple td {
border-top: none;
border-bottom: 1px #555 dotted;
}
fieldset.simple .lastrow {
border: 0;
}
/* form elements */
span.checkbox {
padding: 2px;
display: inline-block;
}
.custom { /* customized field */
background: #FFC;
}
.checkbox.custom {
padding: 1px;
border: 1px #EDEC90 solid;
}
.field-error {
border-color: #C11 !important;
}
.field-comment {
position: relative;
}
.field-comment-mark {
cursor: help;
padding: 0 0.2em;
font-weight: bold;
font-style: italic;
}
.field-comment-warning {
color: #A00;
}
.green { /* default form button */
color: #080 !important;
}
table.datatable {
margin: 0.5em 0 1em;
}
table.datatable th {
padding: 0 1em 0 0.5em;
border-bottom: 1px #999 solid;
text-align: left;
}
table.datatable td {
padding: 1px 0.5em;
border-bottom: 1px #DEE1FF solid;
}
/* textarea with config file's contents */
#textconfig {
width: 100%;
border: 0;
}
/* error list */
dd {
margin-left: 0.5em;
}
dd:before {
content: "\25B8 ";
}
/* links on failed validation page, when saving a form */
a.btn {
padding: 1px 5px;
text-decoration: none;
background: #E2E8FF;
border: 1px #A6C8FF solid;
border-top-color: #AFD0FF;
border-left-color: #AFD0FF;
font-weight: bold;
}
a.btn:hover, a.btn:active {
background: #E6F5FF;
color: #004C96;
}

34
#pma/setup/validate.php Normal file
View File

@ -0,0 +1,34 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Validation callback.
*
* @package PhpMyAdmin-Setup
*/
/**
* Core libraries.
*/
require './lib/common.inc.php';
$validators = array();
require './libraries/config/Validator.php';
PMA_headerJSON();
$ids = PMA_isValid($_POST['id'], 'scalar') ? $_POST['id'] : null;
$vids = explode(',', $ids);
$vals = PMA_isValid($_POST['values'], 'scalar') ? $_POST['values'] : null;
$values = json_decode($vals);
if (!($values instanceof stdClass)) {
PMA_fatalError(__('Wrong data'));
}
$values = (array)$values;
$result = PMA\libraries\config\Validator::validate($GLOBALS['ConfigFile'], $vids, $values, true);
if ($result === false) {
$result = sprintf(
__('Wrong data or no validation for %s'),
implode(',', $vids)
);
}
echo $result !== true ? json_encode($result) : '';