init web ems all

This commit is contained in:
agtuser
2024-09-27 17:13:36 +08:00
parent 81c97acbe9
commit 5cc56f8078
4263 changed files with 798779 additions and 0 deletions

11
phpMyAdmin/setup/ajax.js Executable 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) {
}
};

50
phpMyAdmin/setup/config.php Executable file
View File

@@ -0,0 +1,50 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Front controller for config view / download and clear
*
* @package PhpMyAdmin-Setup
*/
use PhpMyAdmin\Setup\ConfigGenerator;
use PhpMyAdmin\Config\Forms\Setup\ConfigForm;
use PhpMyAdmin\Core;
use PhpMyAdmin\Url;
use PhpMyAdmin\Response;
/**
* Core libraries.
*/
require './lib/common.inc.php';
$form_display = new ConfigForm($GLOBALS['ConfigFile']);
$form_display->save('Config');
$response = Response::getInstance();
if (isset($_POST['eol'])) {
$_SESSION['eol'] = ($_POST['eol'] == 'unix') ? 'unix' : 'win';
}
if (Core::ifSetOr($_POST['submit_clear'], '')) {
//
// Clear current config and return to main page
//
$GLOBALS['ConfigFile']->resetConfigData();
// drop post data
$response->generateHeader303('index.php' . Url::getCommonRaw());
exit;
} elseif (Core::ifSetOr($_POST['submit_download'], '')) {
//
// Output generated config file
//
Core::downloadHeader('config.inc.php', 'text/plain');
$response->disable();
echo ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']);
exit;
} else {
//
// Show generated config file in a <textarea>
//
$response->generateHeader303('index.php' . Url::getCommonRaw(array('page' => 'config')));
exit;
}

View File

@@ -0,0 +1,39 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Config file view and save screen
*
* @package PhpMyAdmin-Setup
*/
use PhpMyAdmin\Config\FormDisplayTemplate;
use PhpMyAdmin\Core;
use PhpMyAdmin\Setup\ConfigGenerator;
if (!defined('PHPMYADMIN')) {
exit;
}
echo '<h2>' , __('Configuration file') , '</h2>';
echo FormDisplayTemplate::displayFormTop('config.php');
echo '<input type="hidden" name="eol" value="'
, htmlspecialchars(Core::ifSetOr($_GET['eol'], 'unix')) , '" />';
echo FormDisplayTemplate::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 '</td>';
echo '</tr>';
echo FormDisplayTemplate::displayFieldsetBottom(false);
echo FormDisplayTemplate::displayFormBottom();

View File

@@ -0,0 +1,25 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Form edit view
*
* @package PhpMyAdmin-Setup
*/
use PhpMyAdmin\Config\Forms\Setup\SetupFormList;
use PhpMyAdmin\Core;
use PhpMyAdmin\Setup\FormProcessing;
if (!defined('PHPMYADMIN')) {
exit;
}
$formset_id = Core::isValid($_GET['formset'], 'scalar') ? $_GET['formset'] : null;
$mode = isset($_GET['mode']) ? $_GET['mode'] : null;
$form_class = SetupFormList::get($formset_id);
if (is_null($form_class)) {
Core::fatalError(__('Incorrect form specified!'));
}
echo '<h2>' , $form_class::getName() , '</h2>';
$form_display = new $form_class($GLOBALS['ConfigFile']);
FormProcessing::process($form_display);

View File

@@ -0,0 +1,270 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Overview (main page)
*
* @package PhpMyAdmin-Setup
*/
use PhpMyAdmin\Config\ConfigFile;
use PhpMyAdmin\Config\FormDisplay;
use PhpMyAdmin\Config\FormDisplayTemplate;
use PhpMyAdmin\Config\ServerConfigChecks;
use PhpMyAdmin\Core;
use PhpMyAdmin\LanguageManager;
use PhpMyAdmin\Sanitize;
use PhpMyAdmin\Setup\Index as SetupIndex;
use PhpMyAdmin\Url;
if (!defined('PHPMYADMIN')) {
exit;
}
// prepare unfiltered language list
$all_languages = LanguageManager::getInstance()->sortedLanguages();
/** @var ConfigFile $cf */
$cf = $GLOBALS['ConfigFile'];
// message handling
SetupIndex::messagesBegin();
//
// Check phpMyAdmin version
//
if (isset($_GET['version_check'])) {
SetupIndex::versionCheck();
}
//
// Perform various security, compatibility and consistency checks
//
$configChecker = new ServerConfigChecks($GLOBALS['ConfigFile']);
$configChecker->performConfigChecks();
//
// Https connection warning (check done on the client side)
//
$text = __(
'You are not using a secure connection; all data (including potentially '
. 'sensitive information, like passwords) is transferred unencrypted!'
);
$text .= ' <a href="#">';
$text .= __(
'If your server is also configured to accept HTTPS requests '
. 'follow this link to use a secure connection.'
);
$text .= '</a>';
SetupIndex::messagesSet('notice', 'no_https', __('Insecure connection'), $text);
echo '<form id="select_lang" method="post">';
echo 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 */
SetupIndex::messagesSet(
'notice', uniqid('config_saved'), __('Configuration saved.'),
Sanitize::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 */
SetupIndex::messagesSet(
'notice', uniqid('config_not_saved'), __('Configuration not saved!'),
Sanitize::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
SetupIndex::messagesEnd();
SetupIndex::messagesShowHtml();
echo '<a href="#" id="show_hidden_messages" class="hide">';
echo __('Show hidden messages (#MSG_COUNT)');
echo '</a>';
echo '<fieldset class="simple"><legend>';
echo __('Servers');
echo '</legend>';
//
// Display server list
//
echo FormDisplayTemplate::displayFormTop(
'index.php', 'get',
array(
'page' => 'servers',
'mode' => 'add'
)
);
echo '<div class="form">';
if ($cf->getServerCount() > 0) {
echo '<table cellspacing="0" class="datatable">';
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 class="nowrap">';
echo '<small>';
echo '<a href="' , Url::getCommon(array('page' => 'servers', 'mode' => 'edit', 'id' => $id)), '">'
, __('Edit') , '</a>';
echo ' | ';
echo '<a class="delete-server" href="' . Url::getCommon(array('page' => 'servers', 'mode' => 'remove', 'id' => $id));
echo '" data-post="' . Url::getCommon(array('token' => $_SESSION[' PMA_token ']), '', false) . '">';
echo __('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 left">';
echo '<input type="submit" name="submit" value="' , __('New server') , '" />';
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</div>';
echo FormDisplayTemplate::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 FormDisplayTemplate::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 FormDisplayTemplate::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 FormDisplayTemplate::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 = Core::ifSetOr($_SESSION['eol'], (PMA_IS_WINDOWS ? 'win' : 'unix'));
echo FormDisplayTemplate::displayInput(
'eol', __('End of line'), 'select',
$eol, '', true, $opts
);
echo '<tr>';
echo '<td colspan="2" class="lastrow 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_clear" value="' , __('Clear')
, '" class="red" />';
echo '</td>';
echo '</tr>';
echo '</table>';
echo FormDisplayTemplate::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="' , Url::getCommon(array('version_check' => '1')), '">'
, __('Check for latest version') , '</a>';
echo '</div>';

View File

@@ -0,0 +1,33 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Menu items
*
* @package PhpMyAdmin-Setup
*/
use PhpMyAdmin\Url;
use PhpMyAdmin\Config\Forms\Setup\SetupFormList;
if (!defined('PHPMYADMIN')) {
exit;
}
$formset_id = isset($_GET['formset']) ? $_GET['formset'] : null;
echo '<ul>';
echo '<li><a href="index.php' , Url::getCommon() , '"'
, ($formset_id === null ? ' class="active' : '')
, '">' , __('Overview') , '</a></li>';
$ignored = array('Config', 'Servers');
foreach (SetupFormList::getAll() as $formset) {
if (in_array($formset, $ignored)) {
continue;
}
$form_class = SetupFormList::get($formset);
echo '<li><a href="index.php' , Url::getCommon(array('page' => 'form', 'formset' => $formset)) , '" '
, ($formset_id === $formset ? ' class="active' : '')
, '">' , $form_class::getName() , '</a></li>';
}
echo '</ul>';

View File

@@ -0,0 +1,44 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Server create and edit view
*
* @package PhpMyAdmin-Setup
*/
use PhpMyAdmin\Config\ConfigFile;
use PhpMyAdmin\Config\Forms\Setup\ServersForm;
use PhpMyAdmin\Core;
use PhpMyAdmin\Setup\FormProcessing;
use PhpMyAdmin\Url;
if (!defined('PHPMYADMIN')) {
exit;
}
$mode = isset($_GET['mode']) ? $_GET['mode'] : null;
$id = Core::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 && $_SERVER['REQUEST_METHOD'] == 'POST') {
$cf->removeServer($id);
header('Location: index.php' . Url::getCommonRaw());
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 ServersForm($cf, $id);
FormProcessing::process($form_display);

67
phpMyAdmin/setup/index.php Executable file
View File

@@ -0,0 +1,67 @@
<?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
*/
use PhpMyAdmin\Core;
/**
* Core libraries.
*/
require './lib/common.inc.php';
if (@file_exists(CONFIG_FILE) && ! $cfg['DBG']['demo']) {
Core::fatalError(__('Configuration already exists, setup is disabled!'));
}
$page = Core::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
Core::fatalError(__('Wrong GET file attribute value'));
}
// Handle done action info
$action_done = Core::isValid($_GET['action_done'], 'scalar') ? $_GET['action_done'] : null;
$action_done = preg_replace('/[^a-z_]/', '', $action_done);
Core::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/vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="../js/vendor/jquery/jquery-ui.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 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 = 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, 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;
}
}

View File

@@ -0,0 +1,79 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Formset processing library
*
* @package PhpMyAdmin-Setup
*/
namespace PhpMyAdmin\Setup;
use PhpMyAdmin\Config\FormDisplay;
use PhpMyAdmin\Core;
use PhpMyAdmin\Url;
use PhpMyAdmin\Response;
/**
* 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();
}
?>
<div class="error">
<h4><?php echo __('Warning') ?></h4>
<?php echo __('Submitted form contains errors') ?><br />
<a href="<?php echo Url::getCommon(array('page' => $page, 'formset' => $formset, 'id' => $formId, '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 Url::getCommon() ?>">
<?php echo __('Ignore errors') ?>
</a>
&nbsp;
<a class="btn" href="<?php echo Url::getCommon(array('page' => $page, 'formset' => $formset, 'id' => $formId, 'mode' => 'edit')) ?>">
<?php echo __('Show form') ?>
</a>
<?php
}
}

191
phpMyAdmin/setup/lib/Index.php Executable file
View File

@@ -0,0 +1,191 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Various checks and message functions used on index page.
*
* @package PhpMyAdmin-Setup
*/
namespace PhpMyAdmin\Setup;
use PhpMyAdmin\VersionInformation;
use PhpMyAdmin\Sanitize;
/**
* 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'] = 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
*/
public static function 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
*/
public static function 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 self::messagesEnd()
*
* @return void
*/
public static function messagesShowHtml()
{
foreach ($_SESSION['messages'] as $type => $messages) {
foreach ($messages as $id => $msg) {
if (! $msg['fresh'] && $type != 'error') {
$extra = ' hiddenmessage';
} else {
$extra = '';
}
echo '<div class="' , $type, $extra , '" id="' , $id , '">'
, '<h4>' , $msg['title'] , '</h4>'
, $msg['message'] , '</div>';
}
}
}
/**
* 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::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 {
self::messagesSet(
'notice',
$message_id,
__('Version check'),
__('No newer stable version is available')
);
}
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Loads libraries/common.inc.php and preforms some additional actions
*
* @package PhpMyAdmin-Setup
*/
use PhpMyAdmin\Config\ConfigFile;
/**
* Do not include full common.
* @ignore
*/
define('PMA_MINIMUM_COMMON', true);
chdir('..');
if (!file_exists('./libraries/common.inc.php')) {
die('Bad invocation!');
}
require_once './libraries/common.inc.php';
require_once './setup/lib/ConfigGenerator.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['PMA_Config']->set('is_setup', true);
$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/auth_type',
'Servers/1/user',
'Servers/1/password'
)
);
// allows for redirection even after sending some data
ob_start();

228
phpMyAdmin/setup/scripts.js Executable file
View File

@@ -0,0 +1,228 @@
/* 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
//
$(function () {
if (window.location.protocol === 'https:') {
$('#no_https').remove();
} else {
$('#no_https a').click(function () {
var old_location = window.location;
window.location.href = 'https:' + old_location.href.substring(old_location.protocol.length);
return false;
});
}
var hiddenmessages = $('.hiddenmessage');
if (hiddenmessages.length > 0) {
hiddenmessages.hide();
var link = $('#show_hidden_messages');
link.click(function (e) {
e.preventDefault();
hiddenmessages.show();
$(this).remove();
});
link.html(link.html().replace('#MSG_COUNT', hiddenmessages.length));
link.show();
}
});
// 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
// ------------------------------------------------------------------
$(function () {
$('.delete-server').on('click', function (e) {
e.preventDefault();
var $this = $(this);
$.post($this.attr('href'), $this.attr('data-post'), function () {
window.location.replace('index.php');
});
});
});

611
phpMyAdmin/setup/styles.css Executable file
View File

@@ -0,0 +1,611 @@
/* 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;
}
.hide {
display: none;
}

36
phpMyAdmin/setup/validate.php Executable file
View File

@@ -0,0 +1,36 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Validation callback.
*
* @package PhpMyAdmin-Setup
*/
use PhpMyAdmin\Config\Validator;
use PhpMyAdmin\Core;
/**
* Core libraries.
*/
require './lib/common.inc.php';
$validators = array();
Core::headerJSON();
$ids = Core::isValid($_POST['id'], 'scalar') ? $_POST['id'] : null;
$vids = explode(',', $ids);
$vals = Core::isValid($_POST['values'], 'scalar') ? $_POST['values'] : null;
$values = json_decode($vals);
if (!($values instanceof stdClass)) {
Core::fatalError(__('Wrong data'));
}
$values = (array)$values;
$result = 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) : '';