No changes between revisions
/Web/Maintenance/phpMyAdmin/libraries/.htaccess
0,0 → 1,4
# This folder does not require access over HTTP
Order deny,allow
Deny from all
Allow from none
/Web/Maintenance/phpMyAdmin/libraries/Config.class.php
0,0 → 1,820
<?php
/* $Id: Config.class.php,v 1.21.2.18.2.8 2006/08/22 17:00:00 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
class PMA_Config
{
/**
* @var string default config source
*/
var $default_source = './libraries/config.default.php';
 
/**
* @var array configuration settings
*/
var $settings = array();
 
/**
* @var string config source
*/
var $source = '';
 
/**
* @var int source modification time
*/
var $source_mtime = 0;
var $default_source_mtime = 0;
 
/**
* @var boolean
*/
var $error_config_file = false;
 
/**
* @var boolean
*/
var $error_config_default_file = false;
 
/**
* @var boolean
*/
var $error_pma_uri = false;
 
/**
* @var array
*/
var $default_server = array();
 
/**
* @var boolean wether init is done or mot
* set this to false to force some initial checks
* like checking for required functions
*/
var $done = false;
 
/**
* constructor
*
* @param string source to read config from
*/
function __construct($source = null)
{
$this->settings = array();
 
// functions need to refresh in case of config file changed goes in
// PMA_Config::load()
$this->load($source);
 
// other settings, independant from config file, comes in
$this->checkSystem();
 
$this->checkIsHttps();
}
 
/**
* sets system and application settings
*/
function checkSystem()
{
$this->set('PMA_VERSION', '2.8.2.4');
/**
* @deprecated
*/
$this->set('PMA_THEME_VERSION', 2);
/**
* @deprecated
*/
$this->set('PMA_THEME_GENERATION', 2);
 
$this->checkPhpVersion();
$this->checkWebServerOs();
$this->checkWebServer();
$this->checkGd2();
$this->checkClient();
$this->checkUpload();
$this->checkUploadSize();
$this->checkOutputCompression();
}
 
/**
* wether to use gzip output compression or not
*/
function checkOutputCompression()
{
// If zlib output compression is set in the php configuration file, no
// output buffering should be run
if ( @ini_get('zlib.output_compression') ) {
$this->set('OBGzip', false);
}
 
// disable output-buffering (if set to 'auto') for IE6, else enable it.
if ( strtolower($this->get('OBGzip')) == 'auto' ) {
if ( $this->get('PMA_USR_BROWSER_AGENT') == 'IE'
&& $this->get('PMA_USR_BROWSER_VER') >= 6
&& $this->get('PMA_USR_BROWSER_VER') < 7 ) {
$this->set('OBGzip', false);
} else {
$this->set('OBGzip', true);
}
}
}
 
/**
* Determines platform (OS), browser and version of the user
* Based on a phpBuilder article:
* @see http://www.phpbuilder.net/columns/tim20000821.php
*/
function checkClient()
{
if (PMA_getenv('HTTP_USER_AGENT')) {
$HTTP_USER_AGENT = PMA_getenv('HTTP_USER_AGENT');
} elseif (!isset($HTTP_USER_AGENT)) {
$HTTP_USER_AGENT = '';
}
 
// 1. Platform
if (strstr($HTTP_USER_AGENT, 'Win')) {
$this->set('PMA_USR_OS', 'Win');
} elseif (strstr($HTTP_USER_AGENT, 'Mac')) {
$this->set('PMA_USR_OS', 'Mac');
} elseif (strstr($HTTP_USER_AGENT, 'Linux')) {
$this->set('PMA_USR_OS', 'Linux');
} elseif (strstr($HTTP_USER_AGENT, 'Unix')) {
$this->set('PMA_USR_OS', 'Unix');
} elseif (strstr($HTTP_USER_AGENT, 'OS/2')) {
$this->set('PMA_USR_OS', 'OS/2');
} else {
$this->set('PMA_USR_OS', 'Other');
}
 
// 2. browser and version
// (must check everything else before Mozilla)
 
if (preg_match('@Opera(/| )([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
$this->set('PMA_USR_BROWSER_VER', $log_version[2]);
$this->set('PMA_USR_BROWSER_AGENT', 'OPERA');
} elseif (preg_match('@MSIE ([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
$this->set('PMA_USR_BROWSER_VER', $log_version[1]);
$this->set('PMA_USR_BROWSER_AGENT', 'IE');
} elseif (preg_match('@OmniWeb/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
$this->set('PMA_USR_BROWSER_VER', $log_version[1]);
$this->set('PMA_USR_BROWSER_AGENT', 'OMNIWEB');
//} elseif (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
// Konqueror 2.2.2 says Konqueror/2.2.2
// Konqueror 3.0.3 says Konqueror/3
} elseif (preg_match('@(Konqueror/)(.*)(;)@', $HTTP_USER_AGENT, $log_version)) {
$this->set('PMA_USR_BROWSER_VER', $log_version[2]);
$this->set('PMA_USR_BROWSER_AGENT', 'KONQUEROR');
} elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)
&& preg_match('@Safari/([0-9]*)@', $HTTP_USER_AGENT, $log_version2)) {
$this->set('PMA_USR_BROWSER_VER', $log_version[1] . '.' . $log_version2[1]);
$this->set('PMA_USR_BROWSER_AGENT', 'SAFARI');
} elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
$this->set('PMA_USR_BROWSER_VER', $log_version[1]);
$this->set('PMA_USR_BROWSER_AGENT', 'MOZILLA');
} else {
$this->set('PMA_USR_BROWSER_VER', 0);
$this->set('PMA_USR_BROWSER_AGENT', 'OTHER');
}
}
 
/**
* Whether GD2 is present
*/
function checkGd2()
{
if ( $this->get('GD2Available') == 'yes' ) {
$this->set('PMA_IS_GD2', 1);
} elseif ( $this->get('GD2Available') == 'no' ) {
$this->set('PMA_IS_GD2', 0);
} else {
if (!@extension_loaded('gd')) {
PMA_dl('gd');
}
if (!@function_exists('imagecreatetruecolor')) {
$this->set('PMA_IS_GD2', 0);
} else {
if (@function_exists('gd_info')) {
$gd_nfo = gd_info();
if (strstr($gd_nfo["GD Version"], '2.')) {
$this->set('PMA_IS_GD2', 1);
} else {
$this->set('PMA_IS_GD2', 0);
}
} else {
/* We must do hard way... */
ob_start();
phpinfo(INFO_MODULES); /* Only modules */
$a = strip_tags(ob_get_contents());
ob_end_clean();
/* Get GD version string from phpinfo output */
if (preg_match('@GD Version[[:space:]]*\(.*\)@', $a, $v)) {
if (strstr($v, '2.')) {
$this->set('PMA_IS_GD2', 1);
} else {
$this->set('PMA_IS_GD2', 0);
}
} else {
$this->set('PMA_IS_GD2', 0);
}
}
}
}
}
 
/**
* Whether the Web server php is running on is IIS
*/
function checkWebServer()
{
if (PMA_getenv('SERVER_SOFTWARE')
// some versions return Microsoft-IIS, some Microsoft/IIS
// we could use a preg_match() but it's slower
&& stristr(PMA_getenv('SERVER_SOFTWARE'), 'Microsoft')
&& stristr(PMA_getenv('SERVER_SOFTWARE'), 'IIS')) {
$this->set('PMA_IS_IIS', 1);
} else {
$this->set('PMA_IS_IIS', 0);
}
}
 
/**
* Whether the os php is running on is windows or not
*/
function checkWebServerOs()
{
// Default to Unix or Equiv
$this->set('PMA_IS_WINDOWS', 0);
// If PHP_OS is defined then continue
if (defined('PHP_OS')) {
if (stristr(PHP_OS, 'win') ) {
// Is it some version of Windows
$this->set('PMA_IS_WINDOWS', 1);
} elseif (stristr(PHP_OS, 'OS/2')) {
// Is it OS/2 (No file permissions like Windows)
$this->set('PMA_IS_WINDOWS', 1);
}
}
}
 
/**
* detects PHP version
*/
function checkPhpVersion()
{
$match = array();
if ( ! preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@',
phpversion(), $match) ) {
$result = preg_match('@([0-9]{1,2}).([0-9]{1,2})@',
phpversion(), $match);
}
if ( isset( $match ) && ! empty( $match[1] ) ) {
if ( ! isset( $match[2] ) ) {
$match[2] = 0;
}
if ( ! isset( $match[3] ) ) {
$match[3] = 0;
}
$this->set('PMA_PHP_INT_VERSION',
(int) sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));
} else {
$this->set('PMA_PHP_INT_VERSION', 0);
}
$this->set('PMA_PHP_STR_VERSION', phpversion());
}
 
/**
* re-init object after loadiong from session file
* checks config file for changes and relaods if neccessary
*/
function __wakeup()
{
if (! $this->checkConfigSource()
|| $this->source_mtime !== filemtime($this->getSource())
|| $this->default_source_mtime !== filemtime($this->default_source)
|| $this->error_config_file
|| $this->error_config_default_file) {
$this->settings = array();
$this->load();
$this->checkSystem();
}
// check for https needs to be done everytime,
// as https and http uses same session so this info can not be stored
// in session
$this->checkIsHttps();
 
$this->checkCollationConnection();
}
 
/**
* loads default values from default source
*
* @uses file_exists()
* @uses $this->default_source
* @uses $this->error_config_default_file
* @uses $this->settings
* @return boolean success
*/
function loadDefaults()
{
$cfg = array();
if ( ! file_exists($this->default_source) ) {
$this->error_config_default_file = true;
return false;
}
include $this->default_source;
 
$this->default_source_mtime = filemtime($this->default_source);
 
$this->default_server = $cfg['Servers'][1];
unset( $cfg['Servers'] );
 
$this->settings = PMA_array_merge_recursive($this->settings, $cfg);
 
$this->error_config_default_file = false;
 
return true;
}
 
/**
* loads configuration from $source, usally the config file
* should be called on object creation and from __wakeup if config file
* has changed
*
* @param string $source config file
*/
function load($source = null)
{
$this->loadDefaults();
 
if ( null !== $source ) {
$this->setSource($source);
}
 
if ( ! $this->checkConfigSource() ) {
return false;
}
 
$cfg = array();
 
/**
* Parses the configuration file
*/
$old_error_reporting = error_reporting(0);
if ( function_exists('file_get_contents') ) {
$eval_result =
eval( '?>' . file_get_contents($this->getSource()) );
} else {
$eval_result =
eval( '?>' . implode("\n", file($this->getSource())) );
}
error_reporting($old_error_reporting);
 
if ( $eval_result === false ) {
$this->error_config_file = true;
} else {
$this->error_config_file = false;
$this->source_mtime = filemtime($this->getSource());
}
 
/**
* @TODO check validity of $_COOKIE['pma_collation_connection']
*/
if ( ! empty( $_COOKIE['pma_collation_connection'] ) ) {
$this->set('collation_connection',
strip_tags($_COOKIE['pma_collation_connection']) );
} else {
$this->set('collation_connection',
$this->get('DefaultConnectionCollation') );
}
 
$this->checkCollationConnection();
//$this->checkPmaAbsoluteUri();
$this->settings = PMA_array_merge_recursive($this->settings, $cfg);
return true;
}
 
/**
* set source
* @param string $source
*/
function setSource($source)
{
$this->source = trim($source);
}
 
/**
* checks if the config folder still exists and terminates app if true
*/
function checkConfigFolder()
{
// Refuse to work while there still might be some world writable dir:
if (is_dir('./config')) {
die('Remove "./config" directory before using phpMyAdmin!');
}
}
 
/**
* check config source
*
* @return boolean wether source is valid or not
*/
function checkConfigSource()
{
if (! $this->getSource()) {
// no configuration file set at all
return false;
}
 
if ( ! file_exists($this->getSource()) ) {
// do not trigger error here
// https://sf.net/tracker/?func=detail&aid=1370269&group_id=23067&atid=377408
/*
trigger_error(
'phpMyAdmin-ERROR: unkown configuration source: ' . $source,
E_USER_WARNING);
*/
$this->source_mtime = 0;
return false;
}
 
if ( ! is_readable($this->getSource()) ) {
$this->source_mtime = 0;
die('Existing configuration file (' . $this->getSource() . ') is not readable.');
}
 
// Check for permissions (on platforms that support it):
$perms = @fileperms($this->getSource());
if (!($perms === false) && ($perms & 2)) {
// This check is normally done after loading configuration
$this->checkWebServerOs();
if ($this->get('PMA_IS_WINDOWS') == 0) {
$this->source_mtime = 0;
die('Wrong permissions on configuration file, should not be world writable!');
}
}
 
return true;
}
 
/**
* returns specific config setting
* @param string $setting
* @return mixed value
*/
function get($setting)
{
if ( isset( $this->settings[$setting] ) ) {
return $this->settings[$setting];
}
return null;
}
 
/**
* sets configuration variable
*
* @uses $this->settings
* @param string $setting configuration option
* @param string $value new value for configuration option
*/
function set($setting, $value)
{
$this->settings[$setting] = $value;
}
 
/**
* returns source for current config
* @return string config source
*/
function getSource()
{
return $this->source;
}
 
/**
* old PHP 4 style constructor
*
* @deprecated
*/
function PMA_Config($source = null)
{
$this->__construct($source);
}
 
/**
* $cfg['PmaAbsoluteUri'] is a required directive else cookies won't be
* set properly and, depending on browsers, inserting or updating a
* record might fail
*/
function checkPmaAbsoluteUri()
{
// Setup a default value to let the people and lazy syadmins work anyway,
// they'll get an error if the autodetect code doesn't work
$pma_absolute_uri = $this->get('PmaAbsoluteUri');
if ( strlen($pma_absolute_uri) < 1 ) {
$url = array();
 
// At first we try to parse REQUEST_URI, it might contain full URI
if (PMA_getenv('REQUEST_URI')) {
$url = parse_url(PMA_getenv('REQUEST_URI'));
}
 
// If we don't have scheme, we didn't have full URL so we need to
// dig deeper
if ( empty( $url['scheme'] ) ) {
// Scheme
if (PMA_getenv('HTTP_SCHEME')) {
$url['scheme'] = PMA_getenv('HTTP_SCHEME');
} else {
$url['scheme'] =
PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
? 'https'
: 'http';
}
 
// Host and port
if (PMA_getenv('HTTP_HOST')) {
if (strpos(PMA_getenv('HTTP_HOST'), ':') !== false) {
list( $url['host'], $url['port'] ) =
explode(':', PMA_getenv('HTTP_HOST'));
} else {
$url['host'] = PMA_getenv('HTTP_HOST');
}
} elseif (PMA_getenv('SERVER_NAME')) {
$url['host'] = PMA_getenv('SERVER_NAME');
} else {
$this->error_pma_uri = true;
return false;
}
 
// If we didn't set port yet...
if (empty($url['port']) && PMA_getenv('SERVER_PORT')) {
$url['port'] = PMA_getenv('SERVER_PORT');
}
 
// And finally the path could be already set from REQUEST_URI
if ( empty( $url['path'] ) ) {
if (PMA_getenv('PATH_INFO')) {
$path = parse_url(PMA_getenv('PATH_INFO'));
} else {
// PHP_SELF in CGI often points to cgi executable, so use it
// as last choice
$path = parse_url(PMA_getenv('PHP_SELF'));
}
$url['path'] = $path['path'];
}
}
 
// Make url from parts we have
$pma_absolute_uri = $url['scheme'] . '://';
// Was there user information?
if (!empty($url['user'])) {
$pma_absolute_uri .= $url['user'];
if (!empty($url['pass'])) {
$pma_absolute_uri .= ':' . $url['pass'];
}
$pma_absolute_uri .= '@';
}
// Add hostname
$pma_absolute_uri .= $url['host'];
// Add port, if it not the default one
if ( ! empty( $url['port'] )
&& ( ( $url['scheme'] == 'http' && $url['port'] != 80 )
|| ( $url['scheme'] == 'https' && $url['port'] != 443 ) ) ) {
$pma_absolute_uri .= ':' . $url['port'];
}
// And finally path, without script name, the 'a' is there not to
// strip our directory, when path is only /pmadir/ without filename.
// Backslashes returned by Windows have to be changed.
// Only replace backslashes by forward slashes if on Windows,
// as the backslash could be valid on a non-Windows system.
if ($this->get('PMA_IS_WINDOWS') == 1) {
$path = str_replace("\\", "/", dirname($url['path'] . 'a'));
} else {
$path = dirname($url['path'] . 'a');
}
 
// To work correctly within transformations overview:
if (defined('PMA_PATH_TO_BASEDIR') && PMA_PATH_TO_BASEDIR == '../../') {
if ($this->get('PMA_IS_WINDOWS') == 1) {
$path = str_replace("\\", "/", dirname(dirname($path)));
} else {
$path = dirname(dirname($path));
}
}
// in vhost situations, there could be already an ending slash
if (substr($path, -1) != '/') {
$path .= '/';
}
$pma_absolute_uri .= $path;
 
// We used to display a warning if PmaAbsoluteUri wasn't set, but now
// the autodetect code works well enough that we don't display the
// warning at all. The user can still set PmaAbsoluteUri manually.
// See
// http://sf.net/tracker/?func=detail&aid=1257134&group_id=23067&atid=377411
 
} else {
// The URI is specified, however users do often specify this
// wrongly, so we try to fix this.
 
// Adds a trailing slash et the end of the phpMyAdmin uri if it
// does not exist.
if (substr($pma_absolute_uri, -1) != '/') {
$pma_absolute_uri .= '/';
}
 
// If URI doesn't start with http:// or https://, we will add
// this.
if ( substr($pma_absolute_uri, 0, 7) != 'http://'
&& substr($pma_absolute_uri, 0, 8) != 'https://' ) {
$pma_absolute_uri =
(PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
? 'https'
: 'http')
. ':' . (substr($pma_absolute_uri, 0, 2) == '//' ? '' : '//')
. $pma_absolute_uri;
}
}
 
$this->set('PmaAbsoluteUri', $pma_absolute_uri);
}
 
/**
* check selected collation_connection
* @TODO check validity of $_REQUEST['collation_connection']
*/
function checkCollationConnection()
{
// (could be improved by executing it after the MySQL connection only if
// PMA_MYSQL_INT_VERSION >= 40100 )
if ( ! empty( $_REQUEST['collation_connection'] ) ) {
$this->set('collation_connection',
strip_tags($_REQUEST['collation_connection']) );
}
}
 
/**
* checks if upload is enabled
*
*/
function checkUpload()
{
$this->set('enable_upload', true);
if ( strtolower(@ini_get('file_uploads')) == 'off'
|| @ini_get('file_uploads') == 0 ) {
$this->set('enable_upload', false);
}
}
 
/**
* Maximum upload size as limited by PHP
* Used with permission from Moodle (http://moodle.org) by Martin Dougiamas
*
* this section generates $max_upload_size in bytes
*/
function checkUploadSize()
{
if ( ! $filesize = ini_get('upload_max_filesize') ) {
$filesize = "5M";
}
 
if ( $postsize = ini_get('post_max_size') ) {
$this->set('max_upload_size',
min(get_real_size($filesize), get_real_size($postsize)) );
} else {
$this->set('max_upload_size', get_real_size($filesize));
}
}
 
/**
* check for https
*/
function checkIsHttps()
{
$this->set('is_https', PMA_Config::isHttps());
}
 
/**
* @static
*/
function isHttps()
{
$is_https = false;
 
$url = array();
 
// At first we try to parse REQUEST_URI, it might contain full URI
if (PMA_getenv('REQUEST_URI')) {
$url = parse_url(PMA_getenv('REQUEST_URI'));
}
 
// If we don't have scheme, we didn't have full URL so we need to
// dig deeper
if ( empty( $url['scheme'] ) ) {
// Scheme
if (PMA_getenv('HTTP_SCHEME')) {
$url['scheme'] = PMA_getenv('HTTP_SCHEME');
} else {
$url['scheme'] =
PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
? 'https'
: 'http';
}
}
 
if ( isset( $url['scheme'] )
&& $url['scheme'] == 'https' ) {
$is_https = true;
} else {
$is_https = false;
}
 
return $is_https;
}
 
/**
* detect correct cookie path
*/
function checkCookiePath()
{
$this->set('cookie_path', PMA_Config::getCookiePath());
}
 
/**
* @static
*/
function getCookiePath()
{
static $cookie_path = null;
 
if ( null !== $cookie_path ) {
return $cookie_path;
}
 
$url = '';
 
if (PMA_getenv('REQUEST_URI')) {
$url = PMA_getenv('REQUEST_URI');
}
 
// If we don't have path
if (empty($url)) {
if (PMA_getenv('PATH_INFO')) {
$url = PMA_getenv('PATH_INFO');
} elseif (PMA_getenv('PHP_SELF')) {
// PHP_SELF in CGI often points to cgi executable, so use it
// as last choice
$url = PMA_getenv('PHP_SELF');
} elseif (PMA_getenv('SCRIPT_NAME')) {
$url = PMA_getenv('PHP_SELF');
}
}
 
$url = parse_url($url);
$cookie_path = substr($url['path'], 0, strrpos($url['path'], '/')) . '/';
 
return $cookie_path;
}
 
/**
* enables backward compatibility
*/
function enableBc()
{
$GLOBALS['cfg'] =& $this->settings;
$GLOBALS['default_server'] =& $this->default_server;
$GLOBALS['collation_connection'] = $this->get('collation_connection');
$GLOBALS['is_upload'] = $this->get('enable_upload');
$GLOBALS['max_upload_size'] = $this->get('max_upload_size');
$GLOBALS['cookie_path'] = $this->get('cookie_path');
$GLOBALS['is_https'] = $this->get('is_https');
 
$defines = array(
'PMA_VERSION',
'PMA_THEME_VERSION',
'PMA_THEME_GENERATION',
'PMA_PHP_STR_VERSION',
'PMA_PHP_INT_VERSION',
'PMA_IS_WINDOWS',
'PMA_IS_IIS',
'PMA_IS_GD2',
'PMA_USR_OS',
'PMA_USR_BROWSER_VER',
'PMA_USR_BROWSER_AGENT',
);
 
foreach ( $defines as $define ) {
if ( ! defined($define) ) {
define($define, $this->get($define));
}
}
}
 
/**
* @todo finish
*/
function save() {}
}
?>
/Web/Maintenance/phpMyAdmin/libraries/Theme.class.php
0,0 → 1,286
<?php
/* $Id: Theme.class.php,v 1.5 2005/12/01 08:59:12 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
class PMA_Theme {
/**
* @var string version
*/
var $version = '0.0.0.0';
 
/**
* @var string name
*/
var $name = '';
 
/**
* @var string id
*/
var $id = '';
 
/**
* @var string
*/
var $path = '';
 
/**
* @var string
*/
var $img_path = '';
 
/**
* @var array valid css types
*/
var $types = array( 'left', 'right', 'print' );
 
/**
* @var integer last modification time for info file
*/
var $mtime_info = 0;
 
function __wakeup() {
$this->loadInfo();
$this->checkImgPath();
}
 
function loadInfo() {
if ( ! file_exists( $this->getPath() . '/info.inc.php' ) ) {
return false;
}
 
if ( $this->mtime_info === filemtime( $this->getPath() . '/info.inc.php' ) ) {
return true;
}
 
@include( $this->getPath() . '/info.inc.php' );
 
// did it set correctly?
if ( ! isset( $theme_name ) ) {
return false;
}
 
$this->mtime_info = filemtime( $this->getPath() . '/info.inc.php' );
 
if ( isset( $theme_full_version ) ) {
$this->setVersion( $theme_full_version );
} elseif ( isset( $theme_generation, $theme_version ) ) {
$this->setVersion( $theme_generation . '.' . $theme_version );
}
$this->setName( $theme_name );
 
return true;
}
 
/**
* returns theme object loaded from given folder
* or false if theme is invalid
*
* @static
* @param string path to theme
* @return object PMA_Theme
*/
function load( $folder ) {
 
$theme = new PMA_Theme();
 
$theme->setPath( $folder );
 
if ( ! $theme->loadInfo() ) {
return false;
}
 
$theme->checkImgPath();
 
return $theme;
}
 
function checkImgPath() {
if ( is_dir( $this->getPath() . '/img/' ) ) {
$this->setImgPath( $this->getPath() . '/img/' );
return true;
} elseif ( is_dir( $GLOBALS['cfg']['ThemePath'] . '/original/img/' ) ) {
$this->setImgPath( $GLOBALS['cfg']['ThemePath'] . '/original/img/' );
return true;
} else {
$GLOBALS['PMA_errors'][] =
sprintf( $GLOBALS['strThemeNoValidImgPath'], $this->getName() );
trigger_error(
sprintf( $GLOBALS['strThemeNoValidImgPath'], $this->getName() ),
E_USER_WARNING );
return false;
}
}
 
/**
* returns path to theme
* @uses $this->$path as return value
* @return string $path path to theme
*/
function getPath() {
return $this->path;
}
 
/**
* returns layout file
*
* @return string layout file
*/
function getLayoutFile() {
return $this->getPath() . '/layout.inc.php';
}
 
/**
* set path to theme
* @uses $this->$path to set it
* @param string $path path to theme
*/
function setPath( $path ) {
$this->path = trim( $path );
}
 
/**
* sets version
* @uses $this->version
* @param string new version
*/
function setVersion( $version ) {
$this->version = trim( $version );
}
 
/**
* returns version
* @uses $this->version
* @return string version
*/
function getVersion() {
return $this->version;
}
 
/**
* checks theme version agaisnt $version
* returns true if theme version is equal or higher to $version
*
* @uses version_compare()
* @uses $this->getVersion()
* @param string $version version to compare to
* @return boolean
*/
function checkVersion( $version ) {
return version_compare( $this->getVersion(), $version, 'lt' );
}
 
/**
* sets name
* @param string $name new name
*/
function setName( $name ) {
$this->name = trim( $name );
}
 
/**
* returns name
* @return string name
*/
function getName() {
return $this->name;
}
 
/**
* sets id
* @param string $id new id
*/
function setId( $id ) {
$this->id = trim( $id );
}
 
/**
* returns id
* @return string id
*/
function getId() {
return $this->id;
}
 
function setImgPath( $path ) {
$this->img_path = $path;
}
 
function getImgPath() {
return $this->img_path;
}
 
/**
* load css (send to stdout, normaly the browser)
*
* @uses $this->getPath()
* @uses $this->types
* @uses PMA_SQP_buildCssData()
* @uses file_exists()
* @uses in_array()
* @param string $type left, right or print
*/
function loadCss( &$type ) {
if ( empty( $type ) || ! in_array( $type, $this->types ) ) {
$type = 'left';
}
 
if ( $type == 'right' ) {
echo PMA_SQP_buildCssData();
}
 
$_css_file = $this->getPath()
. '/css/theme_' . $type . '.css.php';
 
if ( file_exists( $_css_file ) ) {
if ( $GLOBALS['text_dir'] === 'ltr' ) {
$right = 'right';
$left = 'left';
} else {
$right = 'left';
$left = 'right';
}
 
include( $_css_file );
}
}
 
/**
* prints out the preview for this theme
*
* @uses $this->getName()
* @uses $this->getVersion()
* @uses $this->getId()
* @uses $this->getPath()
* @uses $GLOBALS['strThemeNoPreviewAvailable']
* @uses $GLOBALS['strTakeIt']
* @uses PMA_generate_common_url()
* @uses addslashes()
* @uses file_exists()
* @uses htmlspecialchars()
*/
function printPreview() {
echo '<div class="theme_preview">';
echo '<h2>' . htmlspecialchars( $this->getName() )
.' (' . htmlspecialchars( $this->getVersion() ) . ')</h2>'
.'<p>'
.'<a target="_top" href="index.php'
.PMA_generate_common_url( array( 'set_theme' => $this->getId() ) ) . '"'
.' onclick="takeThis(\'' . addslashes( $this->getId() ) . '\');'
.' return false;">';
if ( @file_exists( $this->getPath() . '/screen.png' ) ) {
// if screen exists then output
 
echo '<img src="' . $this->getPath() . '/screen.png" border="1"'
.' alt="' . htmlspecialchars( $this->getName() ) . '"'
.' title="' . htmlspecialchars( $this->getName() ) . '" /><br />';
} else {
echo $GLOBALS['strThemeNoPreviewAvailable'];
}
 
echo '[ <strong>' . $GLOBALS['strTakeIt'] . '</strong> ]</a>'
.'</p>'
.'</div>';
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/Theme_Manager.class.php
0,0 → 1,345
<?php
/* $Id: Theme_Manager.class.php,v 1.5.2.5 2006/05/02 09:28:57 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
require_once('./libraries/Theme.class.php');
 
class PMA_Theme_Manager {
 
/**
* @var string path to theme folder
* @protected
*/
var $_themes_path;
 
/**
* @var array available themes
*/
var $themes = array();
 
/**
* @var string cookie name
*/
var $cookie_name = 'pma_theme';
 
/**
* @var boolean
*/
var $per_server = false;
 
/**
* @var string name of active theme
*/
var $active_theme = '';
 
/**
* @var object PMA_Theme active theme
*/
var $theme = null;
 
/**
* @var string
*/
var $theme_default = 'original';
 
function __construct()
{
$this->init();
}
 
/**
* sets path to folder containing the themes
*
* @param string $path path to themes folder
* @return boolean success
*/
function setThemesPath($path)
{
if (! $this->_checkThemeFolder($path)) {
return false;
}
 
$this->_themes_path = trim($path);
return true;
}
 
/**
* @public
* @return string
*/
function getThemesPath()
{
return $this->_themes_path;
}
 
/**
* sets if there are different themes per server
*
* @param boolean $per_server
*/
function setThemePerServer($per_server)
{
$this->per_server = (bool) $per_server;
}
 
function init()
{
$this->themes = array();
$this->theme_default = 'original';
$this->active_theme = '';
 
if (! $this->setThemesPath($GLOBALS['cfg']['ThemePath'])) {
return false;
}
 
$this->setThemePerServer($GLOBALS['cfg']['ThemePerServer']);
 
$this->loadThemes();
 
$this->theme = new PMA_Theme;
 
 
if ( ! $this->checkTheme($GLOBALS['cfg']['ThemeDefault'])) {
$GLOBALS['PMA_errors'][] = sprintf( $GLOBALS['strThemeDefaultNotFound'],
$GLOBALS['cfg']['ThemeDefault'] );
trigger_error(
sprintf($GLOBALS['strThemeDefaultNotFound'],
$GLOBALS['cfg']['ThemeDefault']),
E_USER_WARNING);
$GLOBALS['cfg']['ThemeDefault'] = false;
}
 
$this->theme_default = $GLOBALS['cfg']['ThemeDefault'];
 
// check if user have a theme cookie
if (! $this->getThemeCookie()
|| ! $this->setActiveTheme($this->getThemeCookie())) {
// otherwise use default theme
if ($GLOBALS['cfg']['ThemeDefault']) {
$this->setActiveTheme($GLOBALS['cfg']['ThemeDefault']);
} else {
// or original theme
$this->setActiveTheme('original');
}
}
}
 
function checkConfig()
{
if ($this->_themes_path != trim($GLOBALS['cfg']['ThemePath'])
|| $this->theme_default != $GLOBALS['cfg']['ThemeDefault']) {
$this->init();
}
}
 
function setActiveTheme($theme = null)
{
if ( ! $this->checkTheme($theme)) {
$GLOBALS['PMA_errors'][] = sprintf($GLOBALS['strThemeNotFound'],
PMA_sanitize($theme));
trigger_error(
sprintf($GLOBALS['strThemeNotFound'], PMA_sanitize($theme)),
E_USER_WARNING);
return false;
}
 
$this->active_theme = $theme;
$this->theme = $this->themes[$theme];
 
// need to set later
//$this->setThemeCookie();
 
return true;
}
 
/**
* @return string cookie name
*/
function getThemeCookieName()
{
// Allow different theme per server
if (isset($GLOBALS['server']) && $this->per_server) {
return $this->cookie_name . '-' . $GLOBALS['server'];
} else {
return $this->cookie_name;
}
}
 
/**
* returns name of theme stored in the cookie
* @return string theme name from cookie
*/
function getThemeCookie()
{
if (isset($_COOKIE[$this->getThemeCookieName()])) {
return $_COOKIE[$this->getThemeCookieName()];
}
 
return false;
}
 
/**
* save theme in cookie
*
* @uses PMA_setCookie();
* @uses PMA_Theme_Manager::getThemeCookieName()
* @uses PMA_Theme_Manager::$theme
* @uses PMA_Theme_Manager::$theme_default
* @uses PMA_Theme::getId()
*/
function setThemeCookie()
{
PMA_setCookie($this->getThemeCookieName(), $this->theme->id,
$this->theme_default);
return true;
}
 
/**
* old PHP 4 constructor
*/
function PMA_Theme_Manager()
{
$this->__construct();
}
 
/**
* @private
* @param string $folder
* @return boolean
*/
/*private*/ function _checkThemeFolder($folder)
{
if (! is_dir($folder)) {
$GLOBALS['PMA_errors'][] =
sprintf($GLOBALS['strThemePathNotFound'],
htmlspecialchars($folder));
trigger_error(
sprintf($GLOBALS['strThemePathNotFound'],
htmlspecialchars($folder)),
E_USER_WARNING);
return false;
}
 
return true;
}
 
/**
* read all themes
*/
function loadThemes()
{
$this->themes = array();
 
if ($handleThemes = opendir($this->getThemesPath())) {
// check for themes directory
while (false !== ($PMA_Theme = readdir($handleThemes))) {
if (array_key_exists($PMA_Theme, $this->themes)) {
$this->themes[$PMA_Theme] = $this->themes[$PMA_Theme];
continue;
}
$new_theme = PMA_Theme::load($this->getThemesPath() . '/' . $PMA_Theme);
if ($new_theme) {
$new_theme->setId($PMA_Theme);
$this->themes[$PMA_Theme] = $new_theme;
}
} // end get themes
closedir($handleThemes);
} else {
trigger_error(
'phpMyAdmin-ERROR: can not open themes folder: ' . $this->getThemesPath(),
E_USER_WARNING);
return false;
} // end check for themes directory
 
ksort($this->themes);
return true;
}
 
/**
* checks if given theme name is a known theme
*
* @param string $theme name fo theme to check for
*/
function checkTheme($theme)
{
if (! array_key_exists($theme, $this->themes)) {
return false;
}
 
return true;
}
 
/**
* returns HTML selectbox, with or without form enclsoed
*
* @param boolean $form wether enclosed by from tags or not
*/
function getHtmlSelectBox($form = true)
{
$select_box = '';
 
if ($form) {
$select_box .= '<form name="setTheme" method="post" action="index.php"'
.' target="_parent">';
$select_box .= PMA_generate_common_hidden_inputs();
}
 
$theme_selected = FALSE;
$theme_preview_path= './themes.php';
$theme_preview_href = '<a href="' . $theme_preview_path . '" target="themes" onclick="'
. "window.open('" . $theme_preview_path . "','themes','left=10,top=20,width=510,height=350,scrollbars=yes,status=yes,resizable=yes');"
. '">';
$select_box .= $theme_preview_href . $GLOBALS['strTheme'] . '</a>:' . "\n";
 
$select_box .= '<select name="set_theme" xml:lang="en" dir="ltr"'
.' onchange="this.form.submit();" >';
foreach ($this->themes as $each_theme_id => $each_theme) {
$select_box .= '<option value="' . $each_theme_id . '"';
if ($this->active_theme === $each_theme_id) {
$select_box .= ' selected="selected"';
}
$select_box .= '>' . htmlspecialchars($each_theme->getName()) . '</option>';
}
$select_box .= '</select>';
 
if ($form) {
$select_box .= '<noscript><input type="submit" value="' . $GLOBALS['strGo'] . '" /></noscript>';
$select_box .= '</form>';
}
 
return $select_box;
}
 
/**
* enables backward compatibility
*/
function makeBc()
{
$GLOBALS['theme'] = $this->theme->getId();
$GLOBALS['pmaThemePath'] = $this->theme->getPath();
$GLOBALS['pmaThemeImage'] = $this->theme->getImgPath();
 
/**
* load layout file if exists
*/
if (@file_exists($GLOBALS['pmaThemePath'] . 'layout.inc.php')) {
include $GLOBALS['pmaThemePath'] . 'layout.inc.php';
}
 
 
}
 
/**
* prints out preview for every theme
*
* @uses $this->themes
* @uses PMA_Theme::printPreview()
*/
function printPreviews()
{
foreach ($this->themes as $each_theme) {
$each_theme->printPreview();
} // end 'open themes'
}
}
?>
/Web/Maintenance/phpMyAdmin/libraries/auth/config.auth.lib.php
0,0 → 1,137
<?php
/* $Id: config.auth.lib.php,v 2.18.8.1 2006/08/11 16:41:26 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// +--------------------------------------------------------------------------+
// | Set of functions used to run config authentication (ie no |
// | authentication). |
// +--------------------------------------------------------------------------+
 
 
/**
* Displays authentication form
*
* @return boolean always true
*
* @access public
*/
function PMA_auth()
{
return TRUE;
} // end of the 'PMA_auth()' function
 
 
/**
* Gets advanced authentication settings
*
* @return boolean always true
*
* @access public
*/
function PMA_auth_check()
{
return TRUE;
} // end of the 'PMA_auth_check()' function
 
 
/**
* Set the user and password after last checkings if required
*
* @return boolean always true
*
* @access public
*/
function PMA_auth_set_user()
{
return TRUE;
} // end of the 'PMA_auth_set_user()' function
 
 
/**
* User is not allowed to login to MySQL -> authentication failed
*
* @global string the MySQL error message PHP returns
* @global string the connection type (persistent or not)
* @global string the MySQL server port to use
* @global string the MySQL socket port to use
* @global array the current server settings
* @global string the font face to use in case of failure
* @global string the default font size to use in case of failure
* @global string the big font size to use in case of failure
* @global boolean tell the "PMA_mysqlDie()" function headers have been
* sent
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth_fails()
{
global $php_errormsg, $cfg;
 
$conn_error = PMA_DBI_getError();
if (!$conn_error) {
if (isset($php_errormsg)) {
$conn_error = $php_errormsg;
} else {
$conn_error = $GLOBALS['strConnectionError'];
}
}
 
// Defines the charset to be used
header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
/* HTML header */
$page_title = $GLOBALS['strAccessDenied'];
require('./libraries/header_meta_style.inc.php');
?>
</head>
 
<body>
<br /><br />
<center>
<h1><?php echo sprintf($GLOBALS['strWelcome'], ' phpMyAdmin ' . PMA_VERSION); ?></h1>
</center>
<br />
<table border="0" cellpadding="0" cellspacing="3" align="center" width="80%">
<tr>
<td>
<?php
echo "\n";
$GLOBALS['is_header_sent'] = TRUE;
 
//TODO: I have included this div from libraries/header.inc.php to work around
// an undefined variable in tooltip.js, when the server
// is not responding. Work has to be done to merge all code that
// starts the page (DOCTYPE and this div) to one place
?>
<div id="TooltipContainer" onmouseover="holdTooltip();" onmouseout="swapTooltip('default');"></div>
<?php
 
if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
echo '<p>' . $GLOBALS['strAccessDenied'] . '</p>' . "\n";
} else {
// Check whether user has configured something
if ($_SESSION['PMA_Config']->source_mtime == 0) {
echo '<p>' . sprintf($GLOBALS['strAccessDeniedCreateConfig'], '<a href="scripts/setup.php">', '</a>') . '</p>' . "\n";
} elseif (!isset($GLOBALS['errno']) || (isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002) && $GLOBALS['errno'] != 2003) {
// if we display the "Server not responding" error, do not confuse users
// by telling them they have a settings problem
// (note: it's true that they could have a badly typed host name, but
// anyway the current $strAccessDeniedExplanation tells that the server
// rejected the connection, which is not really what happened)
// 2002 is the error given by mysqli
// 2003 is the error given by mysql
echo '<p>' . $GLOBALS['strAccessDeniedExplanation'] . '</p>' . "\n";
}
PMA_mysqlDie($conn_error, '');
}
?>
</td>
</tr>
</table>
<?php
require_once('./libraries/footer.inc.php');
return TRUE;
} // end of the 'PMA_auth_fails()' function
 
?>
/Web/Maintenance/phpMyAdmin/libraries/auth/cookie.auth.lib.php
0,0 → 1,524
<?php
/* $Id: cookie.auth.lib.php,v 2.55.2.1.4.1 2006/08/21 11:45:16 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// +--------------------------------------------------------------------------+
// | Set of functions used to run cookie based authentication. |
// | Thanks to Piotr Roszatycki <d3xter at users.sourceforge.net> and |
// | Dan Wilson who built this patch for the Debian package. |
// +--------------------------------------------------------------------------+
 
 
if (!isset($coming_from_common)) {
exit;
}
 
// timestamp for login timeout
$current_time = time();
 
// Uses faster mcrypt library if available
// (Note: mcrypt.lib.php needs $cookie_path and $is_https)
if (function_exists('mcrypt_encrypt') || PMA_dl('mcrypt')) {
require_once('./libraries/mcrypt.lib.php');
} else {
require_once('./libraries/blowfish.php');
}
 
/**
* Sorts available languages by their true names
*
* @param array the array to be sorted
* @param mixed a required parameter
*
* @return the sorted array
*
* @access private
*/
function PMA_cookie_cmp(&$a, $b)
{
return (strcmp($a[1], $b[1]));
} // end of the 'PMA_cmp()' function
 
 
/**
* Displays authentication form
*
* @global string the font face to use
* @global string the default font size to use
* @global string the big font size to use
* @global array the list of servers settings
* @global array the list of available translations
* @global string the current language
* @global integer the current server id
* @global string the currect charset for MySQL
* @global array the array of cookie variables if register_globals is
* off
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth()
{
global $cfg, $lang, $server, $convcharset, $conn_error;
 
// Tries to get the username from cookie whatever are the values of the
// 'register_globals' and the 'variables_order' directives if last login
// should be recalled, else skip the IE autocomplete feature.
if ($cfg['LoginCookieRecall'] && !empty($GLOBALS['cfg']['blowfish_secret'])) {
// username
// do not try to use pma_cookie_username as it was encoded differently
// in previous versions and would produce an undefined offset in blowfish
if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_username-' . $server])) {
$default_user = $_COOKIE['pma_cookie_username-' . $server];
}
$decrypted_user = isset($default_user) ? PMA_blowfish_decrypt($default_user, $GLOBALS['cfg']['blowfish_secret']) : '';
if (!empty($decrypted_user)) {
$pos = strrpos($decrypted_user, ':');
$default_user = substr($decrypted_user, 0, $pos);
} else {
$default_user = '';
}
// server name
if (!empty($GLOBALS['pma_cookie_servername'])) {
$default_server = $GLOBALS['pma_cookie_servername'];
} elseif (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) {
$default_server = $_COOKIE['pma_cookie_servername-' . $server];
}
 
$autocomplete = '';
} else {
$default_user = '';
$autocomplete = ' autocomplete="off"';
}
 
$cell_align = ($GLOBALS['text_dir'] == 'ltr') ? 'left' : 'right';
 
// Defines the charset to be used
header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
// Defines the "item" image depending on text direction
$item_img = $GLOBALS['pmaThemeImage'] . 'item_ltr.png';
 
/* HTML header */
$page_title = 'phpMyAdmin ' . PMA_VERSION;
require('./libraries/header_meta_style.inc.php');
?>
<script type="text/javascript" language="javascript">
//<![CDATA[
// show login form in top frame
if (top != self) {
window.top.location.href=location;
}
//]]>
</script>
</head>
 
<body class="loginform">
 
<?php require('./libraries/header_custom.inc.php'); ?>
 
<a href="http://www.phpmyadmin.net" target="_blank" class="logo"><?php
$logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png';
if (@file_exists($logo_image)) {
echo '<img src="' . $logo_image . '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />';
} else {
echo '<img name="imLogo" id="imLogo" src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo.png' . '" '
. 'border="0" width="88" height="31" alt="phpMyAdmin" />';
}
?></a>
<h1>
<?php
echo sprintf( $GLOBALS['strWelcome'],
'<bdo dir="ltr" xml:lang="en">phpMyAdmin ' . PMA_VERSION . '</bdo>');
?>
</h1>
<?php
 
// Show error message
if ( !empty($conn_error)) {
echo '<div class="error"><h1>' . $GLOBALS['strError'] . '</h1>' . "\n";
echo $conn_error . '</div>' . "\n";
}
 
// Displays the languages form
if (empty($cfg['Lang'])) {
echo "\n";
require_once('./libraries/display_select_lang.lib.php');
PMA_select_language(TRUE);
}
echo "\n\n";
 
// Displays the warning message and the login form
 
if (empty($GLOBALS['cfg']['blowfish_secret'])) {
?>
<div class="error"><h1><?php echo $GLOBALS['strError']; ?></h1>
<?php echo $GLOBALS['strSecretRequired']; ?>
</div>
<?php
require('./libraries/footer_custom.inc.php');
echo ' </body>' . "\n"
. '</html>';
exit();
}
?>
<br />
<!-- Login form -->
<form method="post" action="index.php" name="login_form"<?php echo $autocomplete; ?> target="_top" class="login">
<fieldset>
<legend><?php echo $GLOBALS['strLogin']; ?></legend>
 
<?php if ($GLOBALS['cfg']['AllowArbitraryServer']) { ?>
<div class="item">
<label for="input_servername"><?php echo $GLOBALS['strLogServer']; ?></label>
<input type="text" name="pma_servername" id="input_servername" value="<?php echo (isset($default_server) ? htmlspecialchars($default_server) : ''); ?>" size="24" class="textfield" />
</div>
<?php } ?>
<div class="item">
<label for="input_username"><?php echo $GLOBALS['strLogUsername']; ?></label>
<input type="text" name="pma_username" id="input_username" value="<?php echo (isset($default_user) ? htmlspecialchars($default_user) : ''); ?>" size="24" class="textfield" />
</div>
<div class="item">
<label for="input_password"><?php echo $GLOBALS['strLogPassword']; ?></label>
<input type="password" name="pma_password" id="input_password" value="" size="24" class="textfield" />
</div>
<?php
if (count($cfg['Servers']) > 1) {
echo "\n";
?>
<div class="item">
<label for="select_server"><?php echo $GLOBALS['strServerChoice']; ?>:</label>
<select name="server" id="select_server"
<?php
if ($GLOBALS['cfg']['AllowArbitraryServer']) {
echo ' onchange="document.forms[\'login_form\'].elements[\'pma_servername\'].value = \'\'" ';
}
?>
>
<?php
require_once('./libraries/select_server.lib.php');
PMA_select_server(FALSE, FALSE);
?>
</select>
</div>
<?php
} else {
echo ' <input type="hidden" name="server" value="' . $server . '" />';
} // end if (server choice)
?>
</fieldset>
<fieldset class="tblFooters">
<input value="<?php echo $GLOBALS['strGo']; ?>" type="submit" />
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
<?php
if (isset($GLOBALS['target'])) {
echo ' <input type="hidden" name="target" value="' . htmlspecialchars($GLOBALS['target']) . '" />' . "\n";
}
if (isset($GLOBALS['db'])) {
echo ' <input type="hidden" name="db" value="' . htmlspecialchars($GLOBALS['db']) . '" />' . "\n";
}
if (isset($GLOBALS['table'])) {
echo ' <input type="hidden" name="table" value="' . htmlspecialchars($GLOBALS['table']) . '" />' . "\n";
}
?>
</fieldset>
</form>
 
<div class="notice"><?php echo $GLOBALS['strCookiesRequired']; ?></div>
 
<?php
if ( ! empty( $GLOBALS['PMA_errors'] ) && is_array( $GLOBALS['PMA_errors'] ) ) {
foreach ( $GLOBALS['PMA_errors'] as $error ) {
echo '<div class="error">' . $error . '</div>' . "\n";
}
}
?>
 
<script type="text/javascript" language="javascript">
<!--
var uname = document.forms['login_form'].elements['pma_username'];
var pword = document.forms['login_form'].elements['pma_password'];
if (uname.value == '') {
uname.focus();
} else {
pword.focus();
}
//-->
</script>
 
<?php require('./libraries/footer_custom.inc.php'); ?>
 
</body>
 
</html>
<?php
exit();
 
return TRUE;
} // end of the 'PMA_auth()' function
 
 
/**
* Gets advanced authentication settings
*
* @global string the username if register_globals is on
* @global string the password if register_globals is on
* @global array the array of cookie variables if register_globals is
* off
* @global string the servername sent by the login form
* @global string the username sent by the login form
* @global string the password sent by the login form
* @global string the username of the user who logs out
* @global boolean whether the login/password pair is grabbed from a
* cookie or not
*
* @return boolean whether we get authentication settings or not
*
* @access public
*/
function PMA_auth_check()
{
global $PHP_AUTH_USER, $PHP_AUTH_PW, $pma_auth_server;
global $pma_servername, $pma_username, $pma_password, $old_usr, $server;
global $from_cookie;
 
// avoid an error in mcrypt
if (empty($GLOBALS['cfg']['blowfish_secret'])) {
return FALSE;
}
 
// Initialization
$PHP_AUTH_USER = $PHP_AUTH_PW = '';
$from_cookie = FALSE;
$from_form = FALSE;
 
// The user wants to be logged out -> delete password cookie
if (!empty($old_usr)) {
setcookie('pma_cookie_password-' . $server, '', 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
}
 
// The user just logged in
elseif (!empty($pma_username)) {
$PHP_AUTH_USER = $pma_username;
$PHP_AUTH_PW = (empty($pma_password)) ? '' : $pma_password;
if ($GLOBALS['cfg']['AllowArbitraryServer']) {
$pma_auth_server = $pma_servername;
}
$from_form = TRUE;
}
 
// At the end, try to set the $PHP_AUTH_USER & $PHP_AUTH_PW variables
// from cookies whatever are the values of the 'register_globals' and
// the 'variables_order' directives
else {
if ($GLOBALS['cfg']['AllowArbitraryServer']) {
// servername
if (!empty($pma_cookie_servername)) {
$pma_auth_server = $pma_cookie_servername;
$from_cookie = TRUE;
} elseif (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername-' . $server])) {
$pma_auth_server = $_COOKIE['pma_cookie_servername-' . $server];
$from_cookie = TRUE;
}
}
 
// username
if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_username-' . $server])) {
$PHP_AUTH_USER = $_COOKIE['pma_cookie_username-' . $server];
$from_cookie = TRUE;
}
$decrypted_user = PMA_blowfish_decrypt($PHP_AUTH_USER, $GLOBALS['cfg']['blowfish_secret']);
if (!empty($decrypted_user)) {
$pos = strrpos($decrypted_user, ':');
$PHP_AUTH_USER = substr($decrypted_user, 0, $pos);
$decrypted_time = (int)substr($decrypted_user, $pos + 1);
} else {
$decrypted_time = 0;
}
 
// User inactive too long
if ($decrypted_time > 0 && $decrypted_time < $GLOBALS['current_time'] - $GLOBALS['cfg']['LoginCookieValidity']) {
// Display an error message only if the inactivity has lasted
// less than 4 times the timeout value. This is to avoid
// alerting users with a error after "much" time has passed,
// for example next morning.
if ($decrypted_time > $GLOBALS['current_time'] - ($GLOBALS['cfg']['LoginCookieValidity'] * 4)) {
$GLOBALS['no_activity'] = TRUE;
PMA_auth_fails();
}
return FALSE;
}
 
// password
if (!empty($pma_cookie_password)) {
$PHP_AUTH_PW = $pma_cookie_password;
} elseif (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_password-' . $server])) {
$PHP_AUTH_PW = $_COOKIE['pma_cookie_password-' . $server];
} else {
$from_cookie = FALSE;
}
$PHP_AUTH_PW = PMA_blowfish_decrypt($PHP_AUTH_PW, $GLOBALS['cfg']['blowfish_secret'] . $decrypted_time);
 
if ($PHP_AUTH_PW == "\xff(blank)") {
$PHP_AUTH_PW = '';
}
}
 
// Returns whether we get authentication settings or not
if (!$from_cookie && !$from_form) {
return FALSE;
} elseif ($from_cookie) {
return TRUE;
} else {
// we don't need to strip here, it is done in grab_globals
return TRUE;
}
} // end of the 'PMA_auth_check()' function
 
 
/**
* Set the user and password after last checkings if required
*
* @global array the valid servers settings
* @global integer the id of the current server
* @global array the current server settings
* @global string the current username
* @global string the current password
* @global boolean whether the login/password pair has been grabbed from
* a cookie or not
*
* @return boolean always true
*
* @access public
*/
function PMA_auth_set_user()
{
global $cfg, $server;
global $PHP_AUTH_USER, $PHP_AUTH_PW, $pma_auth_server;
global $from_cookie;
 
// Ensures valid authentication mode, 'only_db', bookmark database and
// table names and relation table name are used
if ($cfg['Server']['user'] != $PHP_AUTH_USER) {
$servers_cnt = count($cfg['Servers']);
for ($i = 1; $i <= $servers_cnt; $i++) {
if (isset($cfg['Servers'][$i])
&& ($cfg['Servers'][$i]['host'] == $cfg['Server']['host'] && $cfg['Servers'][$i]['user'] == $PHP_AUTH_USER)) {
$server = $i;
$cfg['Server'] = $cfg['Servers'][$i];
break;
}
} // end for
} // end if
 
$pma_server_changed = FALSE;
if ($GLOBALS['cfg']['AllowArbitraryServer']
&& isset($pma_auth_server) && !empty($pma_auth_server)
&& ($cfg['Server']['host'] != $pma_auth_server)
) {
$cfg['Server']['host'] = $pma_auth_server;
$pma_server_changed = TRUE;
}
$cfg['Server']['user'] = $PHP_AUTH_USER;
$cfg['Server']['password'] = $PHP_AUTH_PW;
 
// Name and password cookies needs to be refreshed each time
// Duration = one month for username
setcookie('pma_cookie_username-' . $server,
PMA_blowfish_encrypt($cfg['Server']['user'] . ':' . $GLOBALS['current_time'],
$GLOBALS['cfg']['blowfish_secret']),
time() + (60 * 60 * 24 * 30),
$GLOBALS['cookie_path'], '',
$GLOBALS['is_https']);
 
// Duration = till the browser is closed for password (we don't want this to be saved)
setcookie('pma_cookie_password-' . $server,
PMA_blowfish_encrypt(!empty($cfg['Server']['password']) ? $cfg['Server']['password'] : "\xff(blank)",
$GLOBALS['cfg']['blowfish_secret'] . $GLOBALS['current_time']),
0,
$GLOBALS['cookie_path'], '',
$GLOBALS['is_https']);
 
// Set server cookies if required (once per session) and, in this case, force
// reload to ensure the client accepts cookies
if (!$from_cookie) {
if ($GLOBALS['cfg']['AllowArbitraryServer']) {
if (isset($pma_auth_server) && !empty($pma_auth_server) && $pma_server_changed) {
// Duration = one month for serverrname
setcookie('pma_cookie_servername-' . $server,
$cfg['Server']['host'],
time() + (60 * 60 * 24 * 30),
$GLOBALS['cookie_path'], '',
$GLOBALS['is_https']);
} else {
// Delete servername cookie
setcookie('pma_cookie_servername-' . $server, '', 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
}
}
 
// URL where to go:
$redirect_url = $cfg['PmaAbsoluteUri'] . 'index.php';
 
// any parameters to pass?
$url_params = array();
if ( isset($GLOBALS['db']) && strlen($GLOBALS['db']) ) {
$url_params['db'] = $GLOBALS['db'];
}
if ( isset($GLOBALS['table']) && strlen($GLOBALS['table']) ) {
$url_params['table'] = $GLOBALS['table'];
}
// Language change from the login panel needs to be remembered
if ( ! empty($GLOBALS['lang']) ) {
$url_params['lang'] = $GLOBALS['lang'];
}
// any target to pass?
if ( ! empty($GLOBALS['target']) && $GLOBALS['target'] != 'index.php' ) {
$url_params['target'] = $GLOBALS['target'];
}
 
define('PMA_COMING_FROM_COOKIE_LOGIN',1);
PMA_sendHeaderLocation( $redirect_url . PMA_generate_common_url( $url_params, '&' ) );
exit();
} // end if
 
return TRUE;
} // end of the 'PMA_auth_set_user()' function
 
 
/**
* User is not allowed to login to MySQL -> authentication failed
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth_fails()
{
global $conn_error, $server;
 
// Deletes password cookie and displays the login form
setcookie('pma_cookie_password-' . $server, '', 0, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
 
if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
$conn_error = $GLOBALS['strAccessDenied'];
} elseif (isset($GLOBALS['no_activity']) && $GLOBALS['no_activity']) {
$conn_error = sprintf($GLOBALS['strNoActivity'], $GLOBALS['cfg']['LoginCookieValidity']);
// Remember where we got timeout to return on same place
if (PMA_getenv('SCRIPT_NAME')) {
$GLOBALS['target'] = basename(PMA_getenv('SCRIPT_NAME'));
}
} elseif (PMA_DBI_getError()) {
$conn_error = PMA_sanitize(PMA_DBI_getError());
} elseif (isset($php_errormsg)) {
$conn_error = $php_errormsg;
} else {
$conn_error = $GLOBALS['strCannotLogin'];
}
 
PMA_auth();
 
return TRUE;
} // end of the 'PMA_auth_fails()' function
 
?>
/Web/Maintenance/phpMyAdmin/libraries/auth/http.auth.lib.php
0,0 → 1,190
<?php
/* $Id: http.auth.lib.php,v 2.14.2.1 2006/04/11 16:33:33 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// +--------------------------------------------------------------------------+
// | Set of functions used to run http authentication. |
// | NOTE: Requires PHP loaded as a Apache module. |
// +--------------------------------------------------------------------------+
 
 
/**
* Displays authentication form
*
* @global string the font face to use in case of failure
* @global string the default font size to use in case of failure
* @global string the big font size to use in case of failure
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth() {
 
header('WWW-Authenticate: Basic realm="phpMyAdmin ' . sprintf($GLOBALS['strRunning'], (empty($GLOBALS['cfg']['Server']['verbose']) ? str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['host']) : str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['verbose']))) . '"');
header('HTTP/1.0 401 Unauthorized');
header('status: 401 Unauthorized');
 
// Defines the charset to be used
header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
/* HTML header */
$page_title = $GLOBALS['strAccessDenied'];
require('./libraries/header_meta_style.inc.php');
?>
</head>
<body>
<?php require('./libraries/header_custom.inc.php'); ?>
 
<br /><br />
<center>
<h1><?php echo sprintf($GLOBALS['strWelcome'], ' phpMyAdmin ' . PMA_VERSION); ?></h1>
</center>
<br />
<div class="warning"><?php echo $GLOBALS['strWrongUser']; ?></div>
 
<?php require('./libraries/footer_custom.inc.php'); ?>
 
</body>
</html>
<?php
exit();
} // end of the 'PMA_auth()' function
 
 
/**
* Gets advanced authentication settings
*
* @global string the username if register_globals is on
* @global string the password if register_globals is on
* @global array the array of server variables if register_globals is
* off
* @global array the array of environment variables if register_globals
* is off
* @global string the username for the ? server
* @global string the password for the ? server
* @global string the username for the WebSite Professional server
* @global string the password for the WebSite Professional server
* @global string the username of the user who logs out
*
* @return boolean whether we get authentication settings or not
*
* @access public
*/
function PMA_auth_check()
{
global $PHP_AUTH_USER, $PHP_AUTH_PW;
global $old_usr;
 
// Grabs the $PHP_AUTH_USER variable whatever are the values of the
// 'register_globals' and the 'variables_order' directives
// loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
if (empty($PHP_AUTH_USER)) {
if (PMA_getenv('PHP_AUTH_USER')) {
$PHP_AUTH_USER = PMA_getenv('PHP_AUTH_USER');
} elseif (PMA_getenv('REMOTE_USER')) {
// CGI, might be encoded, see bellow
$PHP_AUTH_USER = PMA_getenv('REMOTE_USER');
} elseif (PMA_getenv('AUTH_USER')) {
// WebSite Professional
$PHP_AUTH_USER = PMA_getenv('AUTH_USER');
} elseif (PMA_getenv('HTTP_AUTHORIZATION')) {
// IIS, might be encoded, see bellow
$PHP_AUTH_USER = PMA_getenv('HTTP_AUTHORIZATION');
} elseif (PMA_getenv('Authorization')) {
// FastCGI, might be encoded, see bellow
$PHP_AUTH_USER = PMA_getenv('Authorization');
}
}
// Grabs the $PHP_AUTH_PW variable whatever are the values of the
// 'register_globals' and the 'variables_order' directives
// loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
if (empty($PHP_AUTH_PW)) {
if (PMA_getenv('PHP_AUTH_PW')) {
$PHP_AUTH_PW = PMA_getenv('PHP_AUTH_PW');
} elseif (PMA_getenv('REMOTE_PASSWORD')) {
// Apache/CGI
$PHP_AUTH_PW = PMA_getenv('REMOTE_PASSWORD');
} elseif (PMA_getenv('AUTH_PASSWORD')) {
// WebSite Professional
$PHP_AUTH_PW = PMA_getenv('AUTH_PASSWORD');
}
}
 
// Decode possibly encoded information (used by IIS/CGI/FastCGI)
if (strcmp(substr($PHP_AUTH_USER, 0, 6), 'Basic ') == 0) {
$usr_pass = base64_decode(substr($PHP_AUTH_USER, 6));
if (!empty($usr_pass) && strpos($usr_pass, ':') !== FALSE) {
list($PHP_AUTH_USER, $PHP_AUTH_PW) = explode(':', $usr_pass);
}
unset($usr_pass);
}
 
// User logged out -> ensure the new username is not the same
if (!empty($old_usr)
&& (isset($PHP_AUTH_USER) && $old_usr == $PHP_AUTH_USER)) {
$PHP_AUTH_USER = '';
}
 
// Returns whether we get authentication settings or not
if (empty($PHP_AUTH_USER)) {
return FALSE;
} else {
return TRUE;
}
} // end of the 'PMA_auth_check()' function
 
 
/**
* Set the user and password after last checkings if required
*
* @global array the valid servers settings
* @global integer the id of the current server
* @global array the current server settings
* @global string the current username
* @global string the current password
*
* @return boolean always true
*
* @access public
*/
function PMA_auth_set_user()
{
global $cfg, $server;
global $PHP_AUTH_USER, $PHP_AUTH_PW;
 
// Ensures valid authentication mode, 'only_db', bookmark database and
// table names and relation table name are used
if ($cfg['Server']['user'] != $PHP_AUTH_USER) {
$servers_cnt = count($cfg['Servers']);
for ($i = 1; $i <= $servers_cnt; $i++) {
if (isset($cfg['Servers'][$i])
&& ($cfg['Servers'][$i]['host'] == $cfg['Server']['host'] && $cfg['Servers'][$i]['user'] == $PHP_AUTH_USER)) {
$server = $i;
$cfg['Server'] = $cfg['Servers'][$i];
break;
}
} // end for
} // end if
 
$cfg['Server']['user'] = $PHP_AUTH_USER;
$cfg['Server']['password'] = $PHP_AUTH_PW;
 
return TRUE;
} // end of the 'PMA_auth_set_user()' function
 
 
/**
* User is not allowed to login to MySQL -> authentication failed
*
* @return boolean always true (no return indeed)
*
* @access public
*/
function PMA_auth_fails()
{
PMA_auth();
 
return TRUE;
} // end of the 'PMA_auth_fails()' function
 
?>
/Web/Maintenance/phpMyAdmin/libraries/blowfish.php
0,0 → 1,566
<?php
 
/* $Id: blowfish.php,v 2.5 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* The Cipher_blowfish:: class implements the Cipher interface enryption data
* using the Blowfish algorithm.
*
* $Horde: horde/lib/Cipher/blowfish.php,v 1.2.2.3 2003/01/03 13:23:22 jan Exp $
*
* Copyright 2002-2003 Mike Cochrane <mike@graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike@graftonhall.co.nz>
* @version $Revision: 2.5 $
* @since Horde 2.2
* @package horde.cipher
*/
 
// Change for phpMyAdmin by lem9:
//class Horde_Cipher_blowfish extends Horde_Cipher {
class Horde_Cipher_blowfish {
 
/* Pi Array */
var $p = array(
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
0x9216D5D9, 0x8979FB1B);
 
/* S Boxes */
var $s1 = array(
0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A);
var $s2 = array(
0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7);
var $s3 = array(
0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0);
var $s4 = array(
0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6);
 
/* The number of rounds to do */
var $_rounds = 16;
 
/* Constructor */
function Cipher_blowfish($params = null)
{
}
 
/**
* Set the key to be used for en/decryption
*
* @param String $key The key to use
*/
function setKey($key)
{
$key = $this->_formatKey($key);
$keyPos = $keyXor = 0;
 
$iMax = count($this->p);
$keyLen = count($key);
for ($i = 0; $i < $iMax; $i++) {
for ($t = 0; $t < 4; $t++) {
$keyXor = ($keyXor << 8) | (($key[$keyPos]) & 0x0ff);
if (++$keyPos == $keyLen) {
$keyPos = 0;
}
}
$this->p[$i] = $this->p[$i] ^ $keyXor;
}
 
$encZero = array('L' => 0, 'R' => 0);
for ($i = 0; $i + 1 < $iMax; $i += 2) {
$encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
$this->p[$i] = $encZero['L'];
$this->p[$i + 1] = $encZero['R'];
}
 
$iMax = count($this->s1);
for ($i = 0; $i < $iMax; $i += 2) {
$encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
$this->s1[$i] = $encZero['L'];
$this->s1[$i + 1] = $encZero['R'];
}
 
$iMax = count($this->s2);
for ($i = 0; $i < $iMax; $i += 2) {
$encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
$this->s2[$i] = $encZero['L'];
$this->s2[$i + 1] = $encZero['R'];
}
 
$iMax = count($this->s3);
for ($i = 0; $i < $iMax; $i += 2) {
$encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
$this->s3[$i] = $encZero['L'];
$this->s3[$i + 1] = $encZero['R'];
}
 
$iMax = count($this->s4);
for ($i = 0; $i < $iMax; $i += 2) {
$encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
$this->s4[$i] = $encZero['L'];
$this->s4[$i + 1] = $encZero['R'];
}
 
}
 
/**
* Return the size of the blocks that this cipher needs
*
* @return Integer The number of characters per block
*/
function getBlockSize()
{
return 8;
}
 
/**
* Encrypt a block on data.
*
* @param String $block The data to encrypt
* @param optional String $key The key to use
*
* @return String the encrypted output
*/
function encryptBlock($block, $key = null)
{
if (!is_null($key)) {
$this->setKey($key);
}
 
list($L, $R) = array_values(unpack('N*', $block));
$parts = $this->_encryptBlock($L, $R);
return pack("NN", $parts['L'], $parts['R']);
}
/**
* Encrypt a block on data.
*
* @param String $L The data to encrypt.
* @param String $R The data to encrypt.
*
* @return String The encrypted output.
*/
function _encryptBlock($L, $R)
{
$L ^= $this->p[0];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[1];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[2];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[3];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[4];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[5];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[6];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[7];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[8];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[9];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[10];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[11];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[12];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[13];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[14];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[15];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[16];
$R ^= $this->p[17];
 
return array('L' => $R, 'R' => $L);
}
 
/**
* Decrypt a block on data.
*
* @param String $block The data to decrypt
* @param optional String $key The key to use
*
* @return String the decrypted output
*/
function decryptBlock($block, $key = null)
{
if (!is_null($key)) {
$this->setKey($key);
}
 
// change for phpMyAdmin
$L = null;
$R = null;
 
$retarray = array_values(unpack('N*', $block));
if (isset($retarray[0])) {
$L = $retarray[0];
}
if (isset($retarray[1])) {
$R = $retarray[1];
}
// end change for phpMyAdmin
 
$L ^= $this->p[17];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[16];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[15];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[14];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[13];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[12];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[11];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[10];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[9];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[8];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[7];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[6];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[5];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[4];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[3];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[2];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[1];
 
$decrypted = pack("NN", $R ^ $this->p[0], $L);
return $decrypted;
}
 
/**
* Converts a text key into an array.
*
* @return array The key.
*/
function _formatKey($key)
{
return array_values(unpack('C*', $key));
}
 
}
 
// higher-level functions:
 
/**
* String padding
*
* @param string input string
* @param integer length of the result
* @param string the filling string
* @param integer padding mode
*
* @return string the padded string
*
* @access public
*/
function full_str_pad($input, $pad_length, $pad_string = '', $pad_type = 0) {
$str = '';
$length = $pad_length - strlen($input);
if ($length > 0) { // str_repeat doesn't like negatives
if ($pad_type == STR_PAD_RIGHT) { // STR_PAD_RIGHT == 1
$str = $input.str_repeat($pad_string, $length);
} elseif ($pad_type == STR_PAD_BOTH) { // STR_PAD_BOTH == 2
$str = str_repeat($pad_string, floor($length/2));
$str .= $input;
$str .= str_repeat($pad_string, ceil($length/2));
} else { // defaults to STR_PAD_LEFT == 0
$str = str_repeat($pad_string, $length).$input;
}
} else { // if $length is negative or zero we don't need to do anything
$str = $input;
}
return $str;
}
 
/**
* Encryption using blowfish algorithm
*
* @param string original data
* @param string the secret
*
* @return string the encrypted result
*
* @access public
*
* @author lem9
*/
function PMA_blowfish_encrypt($data, $secret) {
$pma_cipher = new Horde_Cipher_blowfish;
$encrypt = '';
for ($i=0; $i<strlen($data); $i+=8) {
$block = substr($data, $i, 8);
if (strlen($block) < 8) {
$block = full_str_pad($block, 8, "\0", 1);
}
$encrypt .= $pma_cipher->encryptBlock($block, $secret);
}
return base64_encode($encrypt);
}
 
/**
* Decryption using blowfish algorithm
*
* @param string encrypted data
* @param string the secret
*
* @return string original data
*
* @access public
*
* @author lem9
*/
function PMA_blowfish_decrypt($encdata, $secret) {
$pma_cipher = new Horde_Cipher_blowfish;
$decrypt = '';
$data = base64_decode($encdata);
for ($i=0; $i<strlen($data); $i+=8) {
$decrypt .= $pma_cipher->decryptBlock(substr($data, $i, 8), $secret);
}
return trim($decrypt);
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/bookmark.lib.php
0,0 → 1,208
<?php
/* $Id: bookmark.lib.php,v 2.16 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Set of functions used with the bookmark feature
*/
 
 
/**
* Defines the bookmark parameters for the current user
*
* @return array the bookmark parameters for the current user
*
* @global integer the id of the current server
*
* @access public
*/
function PMA_getBookmarksParam()
{
global $server;
 
$cfgBookmark = '';
 
// No server selected -> no bookmark table
if ($server == 0) {
return '';
}
 
$cfgBookmark['user'] = $GLOBALS['cfg']['Server']['user'];
$cfgBookmark['db'] = $GLOBALS['cfg']['Server']['pmadb'];
$cfgBookmark['table'] = $GLOBALS['cfg']['Server']['bookmarktable'];
 
return $cfgBookmark;
} // end of the 'PMA_getBookmarksParam()' function
 
 
/**
* Gets the list of bookmarks defined for the current database
*
* @global resource the controluser db connection handle
*
* @param string the current database name
* @param array the bookmark parameters for the current user
*
* @return mixed the bookmarks list if defined, false else
*
* @access public
*/
function PMA_listBookmarks($db, $cfgBookmark)
{
global $controllink;
 
$query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')'
. ' ORDER BY label';
$result = PMA_DBI_query($query, $controllink, PMA_DBI_QUERY_STORE);
 
// There are some bookmarks -> store them
// use the unique id as the key
if ($result && PMA_DBI_num_rows($result) > 0) {
while ($row = PMA_DBI_fetch_row($result)) {
$bookmark_list[$row[1]] = $row[0];
} // end while
return $bookmark_list;
}
// No bookmarks for the current database
else {
return FALSE;
}
} // end of the 'PMA_listBookmarks()' function
 
 
/**
* Gets the sql command from a bookmark
*
* @global resource the controluser db connection handle
*
* @param string the current database name
* @param array the bookmark parameters for the current user
* @param mixed the id of the bookmark to get
* @param string which field to look up the $id
* @param boolean TRUE: get all bookmarks regardless of the owning user
*
* @return string the sql query
*
* @access public
*/
function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id', $action_bookmark_all = FALSE)
{
global $controllink;
 
if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
return '';
}
 
$query = 'SELECT query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. ($action_bookmark_all? '' : ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')' )
. ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
$result = PMA_DBI_try_query($query, $controllink);
if (!$result) {
return FALSE;
}
list($bookmark_query) = PMA_DBI_fetch_row($result) or array(FALSE);
 
return $bookmark_query;
} // end of the 'PMA_queryBookmarks()' function
 
 
/**
* Gets bookmarked DefaultQuery for a Table
*
* @global resource the controluser db connection handle
*
* @param string the current database name
* @param array the bookmark parameters for the current user
* @param array the list of all labels to look for
*
* @return array bookmark SQL statements
*
* @access public
*/
function &PMA_queryDBBookmarks($db, $cfgBookmark, &$table_array)
{
global $controllink;
$bookmarks = array();
 
if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
return $bookmarks;
}
 
$search_for = array();
foreach ($table_array AS $table => $table_sortkey) {
$search_for[] = "'" . PMA_sqlAddslashes($table) . "'";
}
 
$query = 'SELECT label, query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. (count($search_for) > 0 ? ' AND label IN (' . implode(', ', $search_for) . ')' : '');
$result = PMA_DBI_try_query($query, $controllink, PMA_DBI_QUERY_STORE);
if (!$result || PMA_DBI_num_rows($result) < 1) {
return $bookmarks;
}
while ($row = PMA_DBI_fetch_assoc($result)) {
$bookmarks[$row['label']] = $row['query'];
}
 
return $bookmarks;
} // end of the 'PMA_queryBookmarks()' function
 
/**
* Adds a bookmark
*
* @global resource the controluser db connection handle
*
* @param array the properties of the bookmark to add
* @param array the bookmark parameters for the current user
* @param boolean whether to make the bookmark available for all users
*
* @return boolean whether the INSERT succeeds or not
*
* @access public
*/
function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
{
global $controllink;
 
$query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' (id, dbase, user, query, label) VALUES (NULL, \'' . PMA_sqlAddslashes($fields['dbase']) . '\', \'' . ($all_users ? '' : PMA_sqlAddslashes($fields['user'])) . '\', \'' . PMA_sqlAddslashes(urldecode($fields['query'])) . '\', \'' . PMA_sqlAddslashes($fields['label']) . '\')';
$result = PMA_DBI_query($query, $controllink);
 
return TRUE;
} // end of the 'PMA_addBookmarks()' function
 
 
/**
* Deletes a bookmark
*
* @global resource the controluser db connection handle
*
* @param string the current database name
* @param array the bookmark parameters for the current user
* @param integer the id of the bookmark to get
*
* @access public
*/
function PMA_deleteBookmarks($db, $cfgBookmark, $id)
{
global $controllink;
 
$query = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')'
. ' AND id = ' . $id;
$result = PMA_DBI_try_query($query, $controllink);
} // end of the 'PMA_deleteBookmarks()' function
 
 
/**
* Bookmark Support
*/
$cfg['Bookmark'] = PMA_getBookmarksParam();
 
?>
/Web/Maintenance/phpMyAdmin/libraries/charset_conversion.lib.php
0,0 → 1,304
<?php
/* $Id: charset_conversion.lib.php,v 2.9 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/**
* Charset conversion functions.
*/
 
 
/**
* Loads the recode or iconv extensions if any of it is not loaded yet
*/
if (isset($cfg['AllowAnywhereRecoding'])
&& $cfg['AllowAnywhereRecoding']
&& $allow_recoding) {
 
if ($cfg['RecodingEngine'] == 'recode') {
if (!@extension_loaded('recode')) {
PMA_dl('recode');
if (!@extension_loaded('recode')) {
echo $strCantLoadRecodeIconv;
exit;
}
}
$PMA_recoding_engine = 'recode';
} elseif ($cfg['RecodingEngine'] == 'iconv') {
if (!@extension_loaded('iconv')) {
PMA_dl('iconv');
if (!@extension_loaded('iconv')) {
echo $strCantLoadRecodeIconv;
exit;
}
}
$PMA_recoding_engine = 'iconv';
} else {
if (@extension_loaded('iconv')) {
$PMA_recoding_engine = 'iconv';
} elseif (@extension_loaded('recode')) {
$PMA_recoding_engine = 'recode';
} else {
PMA_dl('iconv');
if (!@extension_loaded('iconv')) {
PMA_dl('recode');
if (!@extension_loaded('recode')) {
echo $strCantLoadRecodeIconv;
exit;
} else {
$PMA_recoding_engine = 'recode';
}
} else {
$PMA_recoding_engine = 'iconv';
}
}
}
} // end load recode/iconv extension
 
define('PMA_CHARSET_NONE', 0);
define('PMA_CHARSET_ICONV', 1);
define('PMA_CHARSET_LIBICONV', 2);
define('PMA_CHARSET_RECODE', 3);
 
if (!isset($cfg['IconvExtraParams'])) {
$cfg['IconvExtraParams'] = '';
}
 
// Finally detects which function will we use:
if (isset($cfg['AllowAnywhereRecoding'])
&& $cfg['AllowAnywhereRecoding']
&& $allow_recoding) {
 
if (!isset($PMA_recoding_engine)) {
$PMA_recoding_engine = $cfg['RecodingEngine'];
}
if ($PMA_recoding_engine == 'iconv') {
if (@function_exists('iconv')) {
$PMA_recoding_engine = PMA_CHARSET_ICONV;
} elseif (@function_exists('libiconv')) {
$PMA_recoding_engine = PMA_CHARSET_LIBICONV;
} else {
$PMA_recoding_engine = PMA_CHARSET_NONE;
 
if (!isset($GLOBALS['is_header_sent'])) {
include('./libraries/header.inc.php');
}
echo $strCantUseRecodeIconv;
require_once('./libraries/footer.inc.php');
exit();
}
} elseif ($PMA_recoding_engine == 'recode') {
if (@function_exists('recode_string')) {
$PMA_recoding_engine = PMA_CHARSET_RECODE;
} else {
$PMA_recoding_engine = PMA_CHARSET_NONE;
 
require_once('./libraries/header.inc.php');
echo $strCantUseRecodeIconv;
require_once('./libraries/footer.inc.php');
exit;
}
} else {
if (@function_exists('iconv')) {
$PMA_recoding_engine = PMA_CHARSET_ICONV;
} elseif (@function_exists('libiconv')) {
$PMA_recoding_engine = PMA_CHARSET_LIBICONV;
} elseif (@function_exists('recode_string')) {
$PMA_recoding_engine = PMA_CHARSET_RECODE;
} else {
$PMA_recoding_engine = PMA_CHARSET_NONE;
 
require_once('./libraries/header.inc.php');
echo $strCantUseRecodeIconv;
require_once('./libraries/footer.inc.php');
exit;
}
}
} else {
$PMA_recoding_engine = PMA_CHARSET_NONE;
}
 
 
/**
* Converts encoding according to current settings.
*
* @param mixed what to convert (string or array of strings or object returned by mysql_fetch_field)
*
* @return string converted string or array of strings
*
* @global array the configuration array
* @global boolean whether recoding is allowed or not
* @global string the current charset
* @global array the charset to convert to
*
* @access public
*
* @author nijel
*/
function PMA_convert_display_charset($what) {
global $cfg, $allow_recoding, $charset, $convcharset;
 
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)
|| $convcharset == $charset // rabus: if input and output charset are the same, we don't have to do anything...
// this constant is not defined before the login:
|| (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 40100) ) { // lem9: even if AllowAnywhereRecoding is TRUE, do not recode for MySQL >= 4.1.x since MySQL does the job
return $what;
} elseif (is_array($what)) {
$result = array();
foreach ($what AS $key => $val) {
if (is_string($val) || is_array($val)) {
if (is_string($key)) {
$result[PMA_convert_display_charset($key)] = PMA_convert_display_charset($val);
} else {
$result[$key] = PMA_convert_display_charset($val);
}
} else {
$result[$key] = $val;
}
} // end while
return $result;
} elseif (is_string($what)) {
 
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
return recode_string($convcharset . '..' . $charset, $what);
case PMA_CHARSET_ICONV:
return iconv($convcharset, $charset . $cfg['IconvExtraParams'], $what);
case PMA_CHARSET_LIBICONV:
return libiconv($convcharset, $charset, $what);
default:
return $what;
}
} elseif (is_object($what)) {
// isn't it object returned from mysql_fetch_field ?
if (@is_string($what->name)) {
$what->name = PMA_convert_display_charset($what->name);
}
if (@is_string($what->table)) {
$what->table = PMA_convert_display_charset($what->table);
}
if (@is_string($what->Database)) {
$what->Database = PMA_convert_display_charset($what->Database);
}
return $what;
} else {
// when we don't know what it is we don't touch it...
return $what;
}
} // end of the "PMA_convert_display_charset()" function
 
 
/**
* Converts encoding of text according to current settings.
*
* @param string what to convert
*
* @return string converted text
*
* @global array the configuration array
* @global boolean whether recoding is allowed or not
* @global string the current charset
* @global array the charset to convert to
*
* @access public
*
* @author nijel
*/
function PMA_convert_charset($what) {
global $cfg, $allow_recoding, $charset, $convcharset;
 
if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)
|| $convcharset == $charset) { // rabus: if input and output charset are the same, we don't have to do anything...
return $what;
} else {
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
return recode_string($charset . '..' . $convcharset, $what);
case PMA_CHARSET_ICONV:
return iconv($charset, $convcharset . $cfg['IconvExtraParams'], $what);
case PMA_CHARSET_LIBICONV:
return libiconv($charset, $convcharset, $what);
default:
return $what;
}
}
} // end of the "PMA_convert_charset()" function
 
/**
* Converts encoding of text according to parameters with detected
* conversion function.
*
* @param string source charset
* @param string target charset
* @param string what to convert
*
* @return string converted text
*
* @access public
*
* @author nijel
*/
function PMA_convert_string($src_charset, $dest_charset, $what) {
if ($src_charset == $dest_charset) {
return $what;
}
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
return recode_string($src_charset . '..' . $dest_charset, $what);
case PMA_CHARSET_ICONV:
return iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what);
case PMA_CHARSET_LIBICONV:
return libiconv($src_charset, $dest_charset, $what);
default:
return $what;
}
} // end of the "PMA_convert_string()" function
 
 
/**
* Converts encoding of file according to parameters with detected
* conversion function. The old file will be unlinked and new created and
* its file name is returned.
*
* @param string source charset
* @param string target charset
* @param string file to convert
*
* @return string new temporay file
*
* @access public
*
* @author nijel
*/
function PMA_convert_file($src_charset, $dest_charset, $file) {
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
case PMA_CHARSET_ICONV:
case PMA_CHARSET_LIBICONV:
$tmpfname = tempnam('', 'PMA_convert_file');
$fin = fopen($file, 'r');
$fout = fopen($tmpfname, 'w');
if ($GLOBALS['PMA_recoding_engine'] == PMA_CHARSET_RECODE) {
recode_file($src_charset . '..' . $dest_charset, $fin, $fout);
} else {
while (!feof($fin)) {
$line = fgets($fin, 4096);
if ($GLOBALS['PMA_recoding_engine'] == PMA_CHARSET_ICONV) {
$dist = iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $line);
} else {
$dist = libiconv($src_charset, $dest_charset, $line);
}
fputs($fout, $dist);
} // end while
}
fclose($fin);
fclose($fout);
unlink($file);
 
return $tmpfname;
default:
return $file;
}
} // end of the "PMA_convert_file()" function
 
?>
/Web/Maintenance/phpMyAdmin/libraries/check_user_privileges.lib.php
0,0 → 1,175
<?php
/* $Id: check_user_privileges.lib.php,v 1.12 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// Get user's global privileges and some db-specific privileges
// ($controllink and $userlink are links to MySQL defined in the "common.lib.php" library)
// Note: if no controluser is defined, $controllink contains $userlink
 
/**
* returns true (int > 0) if current user is superuser
* otherwise 0
*
* @return integer $is_superuser
*/
function PMA_isSuperuser() {
return PMA_DBI_try_query( 'SELECT COUNT(*) FROM mysql.user',
$GLOBALS['userlink'], PMA_DBI_QUERY_STORE );
}
 
$is_create_db_priv = false;
$is_process_priv = true;
$is_reload_priv = false;
$db_to_create = '';
$dbs_where_create_table_allowed = array();
 
// We were trying to find if user if superuser with 'USE mysql'
// but users with the global priv CREATE TEMPORARY TABLES or LOCK TABLES
// can do a 'USE mysql' (even if they cannot see the tables)
$is_superuser = PMA_isSuperuser();
 
function PMA_analyseShowGrant($rs_usr, &$is_create_db_priv, &$db_to_create, &$is_reload_priv, &$dbs_where_create_table_allowed) {
 
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards
while ($row = PMA_DBI_fetch_row($rs_usr)) {
$show_grants_dbname = substr($row[0], strpos($row[0], ' ON ') + 4, (strpos($row[0], '.', strpos($row[0], ' ON ')) - strpos($row[0], ' ON ') - 4));
$show_grants_dbname = ereg_replace('^`(.*)`', '\\1', $show_grants_dbname);
$show_grants_str = substr($row[0], 6, (strpos($row[0], ' ON ') - 6));
if ($show_grants_str == 'RELOAD') {
$is_reload_priv = true;
}
if (($show_grants_str == 'ALL') || ($show_grants_str == 'ALL PRIVILEGES') || ($show_grants_str == 'CREATE') || strpos($show_grants_str, 'CREATE')) {
if ($show_grants_dbname == '*') {
// a global CREATE privilege
$is_create_db_priv = true;
$is_reload_priv = true;
$db_to_create = '';
$dbs_where_create_table_allowed[] = '*';
break;
} else {
// this array may contain wildcards
$dbs_where_create_table_allowed[] = $show_grants_dbname;
 
// before MySQL 4.1.0, we cannot use backquotes around a dbname
// for the USE command, so the USE will fail if the dbname contains
// a "-" and we cannot detect if such a db already exists;
// since 4.1.0, we need to use backquotes if the dbname contains a "-"
// in a USE command
 
if (PMA_MYSQL_INT_VERSION > 40100) {
$dbname_to_test = PMA_backquote($show_grants_dbname);
} else {
$dbname_to_test = $show_grants_dbname;
}
 
if ( (ereg($re0 . '%|_', $show_grants_dbname)
&& !ereg('\\\\%|\\\\_', $show_grants_dbname))
// does this db exist?
|| (!PMA_DBI_try_query('USE ' . ereg_replace($re1 .'(%|_)', '\\1\\3', $dbname_to_test), null, PMA_DBI_QUERY_STORE) && substr(PMA_DBI_getError(), 1, 4) != 1044)
) {
$db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname));
$db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
$is_create_db_priv = true;
 
// TODO: collect $db_to_create into an array, to display a drop-down
// in the "Create new database" dialog
//
// we don't break, we want all possible databases
//break;
} // end if
} // end elseif
} // end if
} // end while
} // end function
 
// Detection for some CREATE privilege.
 
// Since MySQL 4.1.2, we can easily detect current user's grants
// using $userlink (no control user needed)
// and we don't have to try any other method for detection
 
if (PMA_MYSQL_INT_VERSION >= 40102) {
$rs_usr = PMA_DBI_try_query('SHOW GRANTS', $userlink, PMA_DBI_QUERY_STORE);
if ($rs_usr) {
PMA_analyseShowGrant($rs_usr, $is_create_db_priv, $db_to_create, $is_reload_priv, $dbs_where_create_table_allowed);
PMA_DBI_free_result($rs_usr);
unset($rs_usr);
}
} else {
 
// Before MySQL 4.1.2, we first try to find a priv in mysql.user. Hopefuly
// the controluser is correctly defined; but here, $controllink could contain
// $userlink so maybe the SELECT will fail
 
if (!$is_create_db_priv) {
$res = PMA_DBI_query('SELECT USER();', null, PMA_DBI_QUERY_STORE);
list($mysql_cur_user_and_host) = PMA_DBI_fetch_row($res);
$mysql_cur_user = substr($mysql_cur_user_and_host, 0, strrpos($mysql_cur_user_and_host, '@'));
 
$local_query = 'SELECT Create_priv, Reload_priv FROM mysql.user WHERE ' . PMA_convert_using('User') . ' = ' . PMA_convert_using(PMA_sqlAddslashes($mysql_cur_user), 'quoted') . ' OR ' . PMA_convert_using('User') . ' = ' . PMA_convert_using('', 'quoted') . ';';
$rs_usr = PMA_DBI_try_query($local_query, $controllink, PMA_DBI_QUERY_STORE); // Debug: or PMA_mysqlDie('', $local_query, false);
if ($rs_usr) {
while ($result_usr = PMA_DBI_fetch_assoc($rs_usr)) {
if (!$is_create_db_priv) {
$is_create_db_priv = ($result_usr['Create_priv'] == 'Y');
}
if (!$is_reload_priv) {
$is_reload_priv = ($result_usr['Reload_priv'] == 'Y');
}
} // end while
PMA_DBI_free_result($rs_usr);
unset($rs_usr, $result_usr);
if ($is_create_db_priv) {
$dbs_where_create_table_allowed[] = '*';
}
} // end if
} // end if
 
// If the user has Create priv on a inexistant db, show him in the dialog
// the first inexistant db name that we find, in most cases it's probably
// the one he just dropped :)
if (!$is_create_db_priv) {
$local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE ' . PMA_convert_using('Create_priv') . ' = ' . PMA_convert_using('Y', 'quoted') . ' AND (' . PMA_convert_using('User') . ' = ' .PMA_convert_using(PMA_sqlAddslashes($mysql_cur_user), 'quoted') . ' OR ' . PMA_convert_using('User') . ' = ' . PMA_convert_using('', 'quoted') . ');';
 
$rs_usr = PMA_DBI_try_query($local_query, $controllink, PMA_DBI_QUERY_STORE);
if ($rs_usr) {
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards
while ($row = PMA_DBI_fetch_assoc($rs_usr)) {
$dbs_where_create_table_allowed[] = $row['Db'];
if (ereg($re0 . '(%|_)', $row['Db'])
|| (!PMA_DBI_try_query('USE ' . ereg_replace($re1 . '(%|_)', '\\1\\3', $row['Db'])) && substr(PMA_DBI_getError(), 1, 4) != 1044)) {
$db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $row['Db']));
$db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
$is_create_db_priv = true;
break;
} // end if
} // end while
PMA_DBI_free_result($rs_usr);
unset($rs_usr, $row, $re0, $re1);
} else {
// Finally, let's try to get the user's privileges by using SHOW
// GRANTS...
// Maybe we'll find a little CREATE priv there :)
$rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user_and_host . ';', $controllink, PMA_DBI_QUERY_STORE);
if (!$rs_usr) {
// OK, now we'd have to guess the user's hostname, but we
// only try out the 'username'@'%' case.
$rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . PMA_convert_using(PMA_sqlAddslashes($mysql_cur_user), 'quoted') . ';', $controllink, PMA_DBI_QUERY_STORE);
}
unset($local_query);
if ($rs_usr) {
PMA_analyseShowGrant($rs_usr, $is_create_db_priv, $db_to_create, $is_reload_priv, $dbs_where_create_table_allowed);
PMA_DBI_free_result($rs_usr);
unset($rs_usr);
} // end if
} // end elseif
} // end if
} // end else (MySQL < 4.1.2)
 
// If disabled, don't show it
if (!$cfg['SuggestDBName']) {
$db_to_create = '';
}
?>
/Web/Maintenance/phpMyAdmin/libraries/common.lib.php
0,0 → 1,3417
<?php
/* $Id: common.lib.php,v 2.266.2.27.2.2 2006/08/21 11:45:16 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Misc stuff and functions used by almost all the scripts.
* Among other things, it contains the advanced authentication work.
*/
 
/**
* Order of sections for common.lib.php:
*
* the include of libraries/defines_mysql.lib.php must be after the connection
* to db to get the MySql version
*
* the authentication libraries must be before the connection to db
*
* ... so the required order is:
*
* LABEL_definition_of_functions
* - definition of functions
* LABEL_variables_init
* - init some variables always needed
* LABEL_parsing_config_file
* - parsing of the config file
* LABEL_loading_language_file
* - loading language file
* LABEL_theme_setup
* - setting up themes
*
* - load of mysql extension (if necessary) label_loading_mysql
* - loading of an authentication library label_
* - db connection
* - authentication work
* - load of the libraries/defines_mysql.lib.php library to get the MySQL
* release number
*/
 
/**
* For now, avoid warnings of E_STRICT mode
* (this must be done before function definitions)
*/
 
if (defined('E_STRICT')) {
$old_error_reporting = error_reporting(0);
if ($old_error_reporting & E_STRICT) {
error_reporting($old_error_reporting ^ E_STRICT);
} else {
error_reporting($old_error_reporting);
}
unset($old_error_reporting);
}
 
/**
* Avoid object cloning errors
*/
 
@ini_set('zend.ze1_compatibility_mode',false);
 
 
/******************************************************************************/
/* definition of functions LABEL_definition_of_functions */
/**
* Removes insecure parts in a path; used before include() or
* require() when a part of the path comes from an insecure source
* like a cookie or form.
*
* @param string The path to check
*
* @return string The secured path
*
* @access public
* @author Marc Delisle (lem9@users.sourceforge.net)
*/
function PMA_securePath($path)
{
// change .. to .
$path = preg_replace('@\.\.*@', '.', $path);
 
return $path;
} // end function
 
/**
* returns array with dbs grouped with extended infos
*
* @uses $GLOBALS['dblist'] from PMA_availableDatabases()
* @uses $GLOBALS['num_dbs'] from PMA_availableDatabases()
* @uses $GLOBALS['cfgRelation']['commwork']
* @uses $GLOBALS['cfg']['ShowTooltip']
* @uses $GLOBALS['cfg']['LeftFrameDBTree']
* @uses $GLOBALS['cfg']['LeftFrameDBSeparator']
* @uses $GLOBALS['cfg']['ShowTooltipAliasDB']
* @uses PMA_availableDatabases()
* @uses PMA_getTableCount()
* @uses PMA_getComments()
* @uses PMA_availableDatabases()
* @uses is_array()
* @uses implode()
* @uses strstr()
* @uses explode()
* @return array db list
*/
function PMA_getDbList()
{
if (empty($GLOBALS['dblist'])) {
PMA_availableDatabases();
}
$dblist = $GLOBALS['dblist'];
$dbgroups = array();
$parts = array();
foreach ($dblist as $key => $db) {
// garvin: Get comments from PMA comments table
$db_tooltip = '';
if ($GLOBALS['cfg']['ShowTooltip']
&& $GLOBALS['cfgRelation']['commwork']) {
$_db_tooltip = PMA_getComments($db);
if (is_array($_db_tooltip)) {
$db_tooltip = implode(' ', $_db_tooltip);
}
}
 
if ($GLOBALS['cfg']['LeftFrameDBTree']
&& $GLOBALS['cfg']['LeftFrameDBSeparator']
&& strstr($db, $GLOBALS['cfg']['LeftFrameDBSeparator']))
{
$pos = strrpos($db, $GLOBALS['cfg']['LeftFrameDBSeparator']);
$group = substr($db, 0, $pos);
$disp_name_cut = substr($db, $pos);
} else {
$group = $db;
$disp_name_cut = $db;
}
 
$disp_name = $db;
if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
$disp_name = $db_tooltip;
$disp_name_cut = $db_tooltip;
$db_tooltip = $db;
}
 
$dbgroups[$group][$db] = array(
'name' => $db,
'disp_name_cut' => $disp_name_cut,
'disp_name' => $disp_name,
'comment' => $db_tooltip,
'num_tables' => PMA_getTableCount($db),
);
} // end foreach ($dblist as $db)
return $dbgroups;
}
 
/**
* returns html code for select form element with dbs
*
* @return string html code select
*/
function PMA_getHtmlSelectDb($selected = '')
{
$dblist = PMA_getDbList();
// TODO: IE can not handle different text directions in select boxes
// so, as mostly names will be in english, we set the whole selectbox to LTR
// and EN
$return = '<select name="db" id="lightm_db" xml:lang="en" dir="ltr"'
.' onchange="if (this.value != \'\') window.parent.openDb(this.value);">' . "\n"
.'<option value="" dir="' . $GLOBALS['text_dir'] . '">(' . $GLOBALS['strDatabases'] . ') ...</option>'
."\n";
foreach ($dblist as $group => $dbs) {
if (count($dbs) > 1) {
$return .= '<optgroup label="' . htmlspecialchars($group)
. '">' . "\n";
// wether display db_name cuted by the group part
$cut = true;
} else {
// .. or full
$cut = false;
}
foreach ($dbs as $db) {
$return .= '<option value="' . $db['name'] . '"'
.' title="' . $db['comment'] . '"';
if ($db['name'] == $selected) {
$return .= ' selected="selected"';
}
$return .= '>' . ($cut ? $db['disp_name_cut'] : $db['disp_name'])
.' (' . $db['num_tables'] . ')</option>' . "\n";
}
if (count($dbs) > 1) {
$return .= '</optgroup>' . "\n";
}
}
$return .= '</select>';
 
return $return;
}
 
/**
* returns count of tables in given db
*
* @param string $db database to count tables for
* @return integer count of tables in $db
*/
function PMA_getTableCount($db)
{
$tables = PMA_DBI_try_query(
'SHOW TABLES FROM ' . PMA_backquote($db) . ';',
null, PMA_DBI_QUERY_STORE);
if ($tables) {
$num_tables = PMA_DBI_num_rows($tables);
PMA_DBI_free_result($tables);
} else {
$num_tables = 0;
}
 
return $num_tables;
}
 
 
/**
* Get the complete list of Databases a user can access
*
* @param boolean whether to include check on failed 'only_db' operations
* @param resource database handle (superuser)
* @param integer amount of databases inside the 'only_db' container
* @param resource possible resource from a failed previous query
* @param resource database handle (user)
* @param array configuration
* @param array previous list of databases
*
* @return array all databases a user has access to
*
* @access private
*/
function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $userlink,
$cfg, $dblist)
{
if ($only_db_check == false) {
// try to get the available dbs list
// use userlink by default
$dblist = PMA_DBI_get_dblist();
$dblist_cnt = count($dblist);
 
// PMA_DBI_get_dblist() relies on the ability to run "SHOW DATABASES".
// On servers started with --skip-show-database, this is not possible
// so we have here a fallback method, which relies on the controluser
// being able to access the "mysql" db, as explained in the doc.
 
if (!$dblist_cnt) {
$auth_query = 'SELECT User, Select_priv '
. 'FROM mysql.user '
. 'WHERE User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\'';
$rs = PMA_DBI_try_query($auth_query, $controllink);
} // end
}
 
// Access to "mysql" db allowed and dblist still empty -> gets the
// usable db list
if (!$dblist_cnt && ($rs && @PMA_DBI_num_rows($rs))) {
$row = PMA_DBI_fetch_assoc($rs);
PMA_DBI_free_result($rs);
// Correction uva 19991215
// Previous code assumed database "mysql" admin table "db" column
// "db" contains literal name of user database, and works if so.
// Mysql usage generally (and uva usage specifically) allows this
// column to contain regular expressions (we have all databases
// owned by a given student/faculty/staff beginning with user i.d.
// and governed by default by a single set of privileges with
// regular expression as key). This breaks previous code.
// This maintenance is to fix code to work correctly for regular
// expressions.
if ($row['Select_priv'] != 'Y') {
 
// 1. get allowed dbs from the "mysql.db" table
// lem9: User can be blank (anonymous user)
$local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Select_priv = \'Y\' AND (User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\' OR User = \'\')';
$rs = PMA_DBI_try_query($local_query, $controllink);
if ($rs && @PMA_DBI_num_rows($rs)) {
// Will use as associative array of the following 2 code
// lines:
// the 1st is the only line intact from before
// correction,
// the 2nd replaces $dblist[] = $row['Db'];
$uva_mydbs = array();
// Code following those 2 lines in correction continues
// populating $dblist[], as previous code did. But it is
// now populated with actual database names instead of
// with regular expressions.
while ($row = PMA_DBI_fetch_assoc($rs)) {
// loic1: all databases cases - part 1
if ( !isset($row['Db']) || ! strlen($row['Db']) || $row['Db'] == '%') {
$uva_mydbs['%'] = 1;
break;
}
// loic1: avoid multiple entries for dbs
if (!isset($uva_mydbs[$row['Db']])) {
$uva_mydbs[$row['Db']] = 1;
}
} // end while
PMA_DBI_free_result($rs);
$uva_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['controllink']);
// loic1: all databases cases - part 2
if (isset($uva_mydbs['%'])) {
while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
$dblist[] = $uva_row[0];
} // end while
} else {
while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
$uva_db = $uva_row[0];
if (isset($uva_mydbs[$uva_db]) && $uva_mydbs[$uva_db] == 1) {
$dblist[] = $uva_db;
$uva_mydbs[$uva_db] = 0;
} elseif (!isset($dblist[$uva_db])) {
foreach ($uva_mydbs AS $uva_matchpattern => $uva_value) {
// loic1: fixed bad regexp
// TODO: db names may contain characters
// that are regexp instructions
$re = '(^|(\\\\\\\\)+|[^\])';
$uva_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $uva_matchpattern));
// Fixed db name matching
// 2000-08-28 -- Benjamin Gandon
if (ereg('^' . $uva_regex . '$', $uva_db)) {
$dblist[] = $uva_db;
break;
}
} // end while
} // end if ... elseif ...
} // end while
} // end else
PMA_DBI_free_result($uva_alldbs);
unset($uva_mydbs);
} // end if
 
// 2. get allowed dbs from the "mysql.tables_priv" table
$local_query = 'SELECT DISTINCT Db FROM mysql.tables_priv WHERE Table_priv LIKE \'%Select%\' AND User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\'';
$rs = PMA_DBI_try_query($local_query, $controllink);
if ($rs && @PMA_DBI_num_rows($rs)) {
while ($row = PMA_DBI_fetch_assoc($rs)) {
if (!in_array($row['Db'], $dblist)) {
$dblist[] = $row['Db'];
}
} // end while
PMA_DBI_free_result($rs);
} // end if
} // end if
} // end building available dbs from the "mysql" db
 
return $dblist;
}
 
/**
* Converts numbers like 10M into bytes
*
* @param string $size
* @return integer $size
*/
function get_real_size($size = 0)
{
if (!$size) {
return 0;
}
$scan['MB'] = 1048576;
$scan['Mb'] = 1048576;
$scan['M'] = 1048576;
$scan['m'] = 1048576;
$scan['KB'] = 1024;
$scan['Kb'] = 1024;
$scan['K'] = 1024;
$scan['k'] = 1024;
 
while (list($key) = each($scan)) {
if ((strlen($size) > strlen($key))
&& (substr($size, strlen($size) - strlen($key)) == $key)) {
$size = substr($size, 0, strlen($size) - strlen($key)) * $scan[$key];
break;
}
}
return $size;
} // end function get_real_size()
 
/**
* loads php module
*
* @uses PHP_OS
* @uses extension_loaded()
* @uses ini_get()
* @uses function_exists()
* @uses ob_start()
* @uses phpinfo()
* @uses strip_tags()
* @uses ob_get_contents()
* @uses ob_end_clean()
* @uses preg_match()
* @uses strtoupper()
* @uses substr()
* @uses dl()
* @param string $module name if module to load
* @return boolean success loading module
*/
function PMA_dl($module)
{
static $dl_allowed = null;
 
if (extension_loaded($module)) {
return true;
}
 
if (null === $dl_allowed) {
if (!@ini_get('safe_mode')
&& @ini_get('enable_dl')
&& @function_exists('dl')) {
ob_start();
phpinfo(INFO_GENERAL); /* Only general info */
$a = strip_tags(ob_get_contents());
ob_end_clean();
if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) {
if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) {
$dl_allowed = true;
} else {
$dl_allowed = false;
}
} else {
$dl_allowed = true;
}
} else {
$dl_allowed = false;
}
}
 
if (!$dl_allowed) {
return false;
}
 
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$module_file = 'php_' . $module . '.dll';
} else {
$module_file = $module . '.so';
}
 
return @dl($module_file);
}
 
/**
* merges array recursive like array_merge_recursive() but keyed-values are
* always overwritten.
*
* array PMA_array_merge_recursive(array $array1[, array $array2[, array ...]])
*
* @see http://php.net/array_merge
* @see http://php.net/array_merge_recursive
* @uses func_num_args()
* @uses func_get_arg()
* @uses is_array()
* @uses call_user_func_array()
* @param array array to merge
* @param array array to merge
* @param array ...
* @return array merged array
*/
function PMA_array_merge_recursive()
{
switch(func_num_args()) {
case 0 :
return false;
break;
case 1 :
// when does that happen?
return func_get_arg(0);
break;
case 2 :
$args = func_get_args();
if (!is_array($args[0]) || !is_array($args[1])) {
return $args[1];
}
foreach ($args[1] AS $key2 => $value2) {
if (isset($args[0][$key2]) && !is_int($key2)) {
$args[0][$key2] = PMA_array_merge_recursive($args[0][$key2],
$value2);
} else {
// we erase the parent array, otherwise we cannot override a directive that
// contains array elements, like this:
// (in config.default.php) $cfg['ForeignKeyDropdownOrder'] = array('id-content','content-id');
// (in config.inc.php) $cfg['ForeignKeyDropdownOrder'] = array('content-id');
if (is_int($key2) && $key2 == 0) {
unset($args[0]);
}
$args[0][$key2] = $value2;
}
}
return $args[0];
break;
default :
$args = func_get_args();
$args[1] = PMA_array_merge_recursive($args[0], $args[1]);
array_shift($args);
return call_user_func_array('PMA_array_merge_recursive', $args);
break;
}
}
 
/**
* calls $function vor every element in $array recursively
*
* @param array $array array to walk
* @param string $function function to call for every array element
*/
function PMA_arrayWalkRecursive(&$array, $function, $apply_to_keys_also = false)
{
foreach ($array as $key => $value) {
if (is_array($value)) {
PMA_arrayWalkRecursive($array[$key], $function, $apply_to_keys_also);
} else {
$array[$key] = $function($value);
}
 
if ($apply_to_keys_also && is_string($key)) {
$new_key = $function($key);
if ($new_key != $key) {
$array[$new_key] = $array[$key];
unset($array[$key]);
}
}
}
}
 
/**
* boolean phpMyAdmin.PMA_checkPageValidity(string &$page, array $whitelist)
*
* checks given given $page against given $whitelist and returns true if valid
* it ignores optionaly query paramters in $page (script.php?ignored)
*
* @uses in_array()
* @uses urldecode()
* @uses substr()
* @uses strpos()
* @param string &$page page to check
* @param array $whitelist whitelist to check page against
* @return boolean whether $page is valid or not (in $whitelist or not)
*/
function PMA_checkPageValidity(&$page, $whitelist)
{
if (! isset($page)) {
return false;
}
 
if (in_array($page, $whitelist)) {
return true;
} elseif (in_array(substr($page, 0, strpos($page . '?', '?')), $whitelist)) {
return true;
} else {
$_page = urldecode($page);
if (in_array(substr($_page, 0, strpos($_page . '?', '?')), $whitelist)) {
return true;
}
}
return false;
}
 
/**
* trys to find the value for the given environment vriable name
*
* searchs in $_SERVER, $_ENV than trys getenv() and apache_getenv()
* in this order
*
* @param string $var_name variable name
* @return string value of $var or empty string
*/
function PMA_getenv($var_name) {
if (isset($_SERVER[$var_name])) {
return $_SERVER[$var_name];
} elseif (isset($_ENV[$var_name])) {
return $_ENV[$var_name];
} elseif (getenv($var_name)) {
return getenv($var_name);
} elseif (function_exists('apache_getenv')
&& apache_getenv($var_name, true)) {
return apache_getenv($var_name, true);
}
 
return '';
}
 
/**
* include here only libraries which contain only function definitions
* no code im main()!
*/
/* Input sanitizing */
require_once './libraries/sanitizing.lib.php';
require_once './libraries/Theme.class.php';
require_once './libraries/Theme_Manager.class.php';
require_once './libraries/Config.class.php';
 
 
 
if (!defined('PMA_MINIMUM_COMMON')) {
/**
* Displays the maximum size for an upload
*
* @param integer the size
*
* @return string the message
*
* @access public
*/
function PMA_displayMaximumUploadSize($max_upload_size)
{
list($max_size, $max_unit) = PMA_formatByteDown($max_upload_size);
return '(' . sprintf($GLOBALS['strMaximumSize'], $max_size, $max_unit) . ')';
}
 
/**
* Generates a hidden field which should indicate to the browser
* the maximum size for upload
*
* @param integer the size
*
* @return string the INPUT field
*
* @access public
*/
function PMA_generateHiddenMaxFileSize($max_size)
{
return '<input type="hidden" name="MAX_FILE_SIZE" value="' .$max_size . '" />';
}
 
/**
* Add slashes before "'" and "\" characters so a value containing them can
* be used in a sql comparison.
*
* @param string the string to slash
* @param boolean whether the string will be used in a 'LIKE' clause
* (it then requires two more escaped sequences) or not
* @param boolean whether to treat cr/lfs as escape-worthy entities
* (converts \n to \\n, \r to \\r)
*
* @param boolean whether this function is used as part of the
* "Create PHP code" dialog
*
* @return string the slashed string
*
* @access public
*/
function PMA_sqlAddslashes($a_string = '', $is_like = false, $crlf = false, $php_code = false)
{
if ($is_like) {
$a_string = str_replace('\\', '\\\\\\\\', $a_string);
} else {
$a_string = str_replace('\\', '\\\\', $a_string);
}
 
if ($crlf) {
$a_string = str_replace("\n", '\n', $a_string);
$a_string = str_replace("\r", '\r', $a_string);
$a_string = str_replace("\t", '\t', $a_string);
}
 
if ($php_code) {
$a_string = str_replace('\'', '\\\'', $a_string);
} else {
$a_string = str_replace('\'', '\'\'', $a_string);
}
 
return $a_string;
} // end of the 'PMA_sqlAddslashes()' function
 
 
/**
* Add slashes before "_" and "%" characters for using them in MySQL
* database, table and field names.
* Note: This function does not escape backslashes!
*
* @param string the string to escape
*
* @return string the escaped string
*
* @access public
*/
function PMA_escape_mysql_wildcards($name)
{
$name = str_replace('_', '\\_', $name);
$name = str_replace('%', '\\%', $name);
 
return $name;
} // end of the 'PMA_escape_mysql_wildcards()' function
 
/**
* removes slashes before "_" and "%" characters
* Note: This function does not unescape backslashes!
*
* @param string $name the string to escape
* @return string the escaped string
* @access public
*/
function PMA_unescape_mysql_wildcards($name)
{
$name = str_replace('\\_', '_', $name);
$name = str_replace('\\%', '%', $name);
 
return $name;
} // end of the 'PMA_unescape_mysql_wildcards()' function
 
/**
* format sql strings
*
* @param mixed pre-parsed SQL structure
*
* @return string the formatted sql
*
* @global array the configuration array
* @global boolean whether the current statement is a multiple one or not
*
* @access public
*
* @author Robin Johnson <robbat2@users.sourceforge.net>
*/
function PMA_formatSql($parsed_sql, $unparsed_sql = '')
{
global $cfg;
 
// Check that we actually have a valid set of parsed data
// well, not quite
// first check for the SQL parser having hit an error
if (PMA_SQP_isError()) {
return $parsed_sql;
}
// then check for an array
if (!is_array($parsed_sql)) {
// We don't so just return the input directly
// This is intended to be used for when the SQL Parser is turned off
$formatted_sql = '<pre>' . "\n"
. (($cfg['SQP']['fmtType'] == 'none' && $unparsed_sql != '') ? $unparsed_sql : $parsed_sql) . "\n"
. '</pre>';
return $formatted_sql;
}
 
$formatted_sql = '';
 
switch ($cfg['SQP']['fmtType']) {
case 'none':
if ($unparsed_sql != '') {
$formatted_sql = "<pre>\n" . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n</pre>";
} else {
$formatted_sql = PMA_SQP_formatNone($parsed_sql);
}
break;
case 'html':
$formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'color');
break;
case 'text':
//$formatted_sql = PMA_SQP_formatText($parsed_sql);
$formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'text');
break;
default:
break;
} // end switch
 
return $formatted_sql;
} // end of the "PMA_formatSql()" function
 
 
/**
* Displays a link to the official MySQL documentation
*
* @param string chapter of "HTML, one page per chapter" documentation
* @param string contains name of page/anchor that is being linked
* @param bool whether to use big icon (like in left frame)
*
* @return string the html link
*
* @access public
*/
function PMA_showMySQLDocu($chapter, $link, $big_icon = false)
{
global $cfg;
 
if ($cfg['MySQLManualType'] == 'none' || empty($cfg['MySQLManualBase'])) {
return '';
}
 
// Fixup for newly used names:
$chapter = str_replace('_', '-', strtolower($chapter));
$link = str_replace('_', '-', strtolower($link));
 
switch ($cfg['MySQLManualType']) {
case 'chapters':
if (empty($chapter)) {
$chapter = 'index';
}
$url = $cfg['MySQLManualBase'] . '/' . $chapter . '.html#' . $link;
break;
case 'big':
$url = $cfg['MySQLManualBase'] . '#' . $link;
break;
case 'searchable':
if (empty($link)) {
$link = 'index';
}
$url = $cfg['MySQLManualBase'] . '/' . $link . '.html';
break;
case 'viewable':
default:
if (empty($link)) {
$link = 'index';
}
$mysql = '5.0';
if (defined('PMA_MYSQL_INT_VERSION')) {
if (PMA_MYSQL_INT_VERSION < 50000) {
$mysql = '4.1';
} elseif (PMA_MYSQL_INT_VERSION >= 50100) {
$mysql = '5.1';
} elseif (PMA_MYSQL_INT_VERSION >= 50000) {
$mysql = '5.0';
}
}
$url = $cfg['MySQLManualBase'] . '/' . $mysql . '/en/' . $link . '.html';
break;
}
 
if ($big_icon) {
return '<a href="' . $url . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_sqlhelp.png" width="16" height="16" alt="' . $GLOBALS['strDocu'] . '" title="' . $GLOBALS['strDocu'] . '" /></a>';
} elseif ($GLOBALS['cfg']['ReplaceHelpImg']) {
return '<a href="' . $url . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png" width="11" height="11" alt="' . $GLOBALS['strDocu'] . '" title="' . $GLOBALS['strDocu'] . '" /></a>';
} else {
return '[<a href="' . $url . '" target="mysql_doc">' . $GLOBALS['strDocu'] . '</a>]';
}
} // end of the 'PMA_showMySQLDocu()' function
 
/**
* Displays a hint icon, on mouse over show the hint
*
* @param string the error message
*
* @access public
*/
function PMA_showHint($hint_message)
{
//return '<img class="lightbulb" src="' . $GLOBALS['pmaThemeImage'] . 'b_tipp.png" width="16" height="16" border="0" alt="' . $hint_message . '" title="' . $hint_message . '" align="middle" onclick="alert(\'' . PMA_jsFormat($hint_message, false) . '\');" />';
return '<img class="lightbulb" src="' . $GLOBALS['pmaThemeImage'] . 'b_tipp.png" width="16" height="16" alt="Tip" title="Tip" onmouseover="pmaTooltip(\'' . PMA_jsFormat($hint_message, false) . '\'); return false;" onmouseout="swapTooltip(\'default\'); return false;" />';
}
 
/**
* Displays a MySQL error message in the right frame.
*
* @param string the error message
* @param string the sql query that failed
* @param boolean whether to show a "modify" link or not
* @param string the "back" link url (full path is not required)
* @param boolean EXIT the page?
*
* @global array the configuration array
*
* @access public
*/
function PMA_mysqlDie($error_message = '', $the_query = '',
$is_modify_link = true, $back_url = '',
$exit = true)
{
global $cfg, $table, $db, $sql_query;
 
require_once './libraries/header.inc.php';
 
if (!$error_message) {
$error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
}
 
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
$formatted_sql = htmlspecialchars($the_query);
} elseif (empty($the_query) || trim($the_query) == '') {
$formatted_sql = '';
} else {
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
}
// ---
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
echo ' <div class="error"><h1>' . $GLOBALS['strError'] . '</h1>' . "\n";
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString() . "\n";
echo '<br />' . "\n";
}
// ---
// modified to show me the help on sql errors (Michael Keck)
echo ' <p><strong>' . $GLOBALS['strSQLQuery'] . ':</strong>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) { // please show me help to the error on select
echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
}
if ($is_modify_link && isset($db)) {
if (isset($table)) {
$doedit_goto = '<a href="tbl_properties.php?' . PMA_generate_common_url($db, $table) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">';
} else {
$doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">';
}
if ($GLOBALS['cfg']['PropertiesIconic']) {
echo $doedit_goto
. '<img class="icon" src=" '. $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" alt="' . $GLOBALS['strEdit'] .'" />'
. '</a>';
} else {
echo ' ['
. $doedit_goto . $GLOBALS['strEdit'] . '</a>'
. ']' . "\n";
}
} // end if
echo ' </p>' . "\n"
.' <p>' . "\n"
.' ' . $formatted_sql . "\n"
.' </p>' . "\n";
} // end if
 
$tmp_mysql_error = ''; // for saving the original $error_message
if (!empty($error_message)) {
$tmp_mysql_error = strtolower($error_message); // save the original $error_message
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $error_message);
}
// modified to show me the help on error-returns (Michael Keck)
echo '<p>' . "\n"
. ' <strong>' . $GLOBALS['strMySQLSaid'] . '</strong>'
. PMA_showMySQLDocu('Error-returns', 'Error-returns')
. "\n"
. '</p>' . "\n";
 
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping, we do a couple of replacements
 
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', '&nbsp;&nbsp;', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
 
echo '<code>' . "\n"
. $error_message . "\n"
. '</code><br />' . "\n";
 
// feature request #1036254:
// Add a link by MySQL-Error #1062 - Duplicate entry
// 2004-10-20 by mkkeck
// 2005-01-17 modified by mkkeck bugfix
if (substr($error_message, 1, 4) == '1062') {
// get the duplicate entry
 
// get table name
// TODO: what would be the best delimiter, while avoiding
// special characters that can become high-ascii after editing,
// depending upon which editor is used by the developer?
$error_table = array();
if (preg_match('@ALTER\s*TABLE\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {
$error_table = $error_table[1];
} elseif (preg_match('@INSERT\s*INTO\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {
$error_table = $error_table[1];
} elseif (preg_match('@UPDATE\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {
$error_table = $error_table[1];
} elseif (preg_match('@INSERT\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {
$error_table = $error_table[1];
}
 
// get fields
$error_fields = array();
if (preg_match('@\(([^\)]+)\)@i', $the_query, $error_fields)) {
$error_fields = explode(',', $error_fields[1]);
} elseif (preg_match('@(`[^`]+`)\s*=@i', $the_query, $error_fields)) {
$error_fields = explode(',', $error_fields[1]);
}
if (is_array($error_table) || is_array($error_fields)) {
 
// duplicate value
$duplicate_value = array();
preg_match('@\'([^\']+)\'@i', $tmp_mysql_error, $duplicate_value);
$duplicate_value = $duplicate_value[1];
 
$sql = '
SELECT *
FROM ' . PMA_backquote($error_table) . '
WHERE CONCAT_WS("-", ' . implode(', ', $error_fields) . ')
= "' . PMA_sqlAddslashes($duplicate_value) . '"
ORDER BY ' . implode(', ', $error_fields);
unset($error_table, $error_fields, $duplicate_value);
 
echo ' <form method="post" action="import.php" style="padding: 0; margin: 0">' ."\n"
.' <input type="hidden" name="sql_query" value="' . htmlentities($sql) . '" />' . "\n"
.' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n"
.' <input type="submit" name="submit" value="' . $GLOBALS['strBrowse'] . '" />' . "\n"
.' </form>' . "\n";
unset($sql);
}
} // end of show duplicate entry
 
echo '</div>';
echo '<fieldset class="tblFooters">';
 
if (!empty($back_url) && $exit) {
$goto_back_url='<a href="' . (strstr($back_url, '?') ? $back_url . '&amp;no_history=true' : $back_url . '?no_history=true') . '">';
echo '[ ' . $goto_back_url . $GLOBALS['strBack'] . '</a> ]';
}
echo ' </fieldset>' . "\n\n";
if ($exit) {
require_once './libraries/footer.inc.php';
}
} // end of the 'PMA_mysqlDie()' function
 
/**
* Returns a string formatted with CONVERT ... USING
* if MySQL supports it
*
* @param string the string itself
* @param string the mode: quoted or unquoted (this one by default)
*
* @return the formatted string
*
* @access private
*/
function PMA_convert_using($string, $mode='unquoted')
{
if ($mode == 'quoted') {
$possible_quote = "'";
} else {
$possible_quote = "";
}
 
if (PMA_MYSQL_INT_VERSION >= 40100) {
list($conn_charset) = explode('_', $GLOBALS['collation_connection']);
$converted_string = "CONVERT(" . $possible_quote . $string . $possible_quote . " USING " . $conn_charset . ")";
} else {
$converted_string = $possible_quote . $string . $possible_quote;
}
return $converted_string;
} // end function
 
/**
* Send HTTP header, taking IIS limits into account (600 seems ok)
*
* @param string $uri the header to send
* @return boolean always true
*/
function PMA_sendHeaderLocation($uri)
{
if (PMA_IS_IIS && strlen($uri) > 600) {
 
echo '<html><head><title>- - -</title>' . "\n";
echo '<meta http-equiv="expires" content="0">' . "\n";
echo '<meta http-equiv="Pragma" content="no-cache">' . "\n";
echo '<meta http-equiv="Cache-Control" content="no-cache">' . "\n";
echo '<meta http-equiv="Refresh" content="0;url=' .$uri . '">' . "\n";
echo '<script type="text/javascript" language="javascript">' . "\n";
echo '//<![CDATA[' . "\n";
echo 'setTimeout ("window.location = unescape(\'"' . $uri . '"\')",2000); </script>' . "\n";
echo '//]]>' . "\n";
echo '</head>' . "\n";
echo '<body>' . "\n";
echo '<script type="text/javascript" language="javascript">' . "\n";
echo '//<![CDATA[' . "\n";
echo 'document.write (\'<p><a href="' . $uri . '">' . $GLOBALS['strGo'] . '</a></p>\');' . "\n";
echo '//]]>' . "\n";
echo '</script></body></html>' . "\n";
 
} else {
if (SID) {
if (strpos($uri, '?') === false) {
header('Location: ' . $uri . '?' . SID);
} else {
// use seperators defined by php, but prefer ';'
// as recommended by W3C
$php_arg_separator_input = ini_get('arg_separator.input');
if (strpos($php_arg_separator_input, ';') !== false) {
$separator = ';';
} elseif (strlen($php_arg_separator_input) > 0) {
$separator = $php_arg_separator_input{0};
} else {
$separator = '&';
}
header('Location: ' . $uri . $separator . SID);
}
} else {
session_write_close();
// bug #1523784, IE6 does not like 'Refresh: 0', it
// results in a blank page
if (PMA_IS_IIS && defined('PMA_COMING_FROM_COOKIE_LOGIN')) {
header('Refresh: 0; ' . $uri);
} else {
header('Location: ' . $uri);
}
}
}
}
 
/**
* Get the list and number of available databases.
*
* @param string the url to go back to in case of error
*
* @return boolean always true
*
* @global array the list of available databases
* @global integer the number of available databases
* @global array current configuration
*/
function PMA_availableDatabases($error_url = '')
{
global $dblist;
global $num_dbs;
global $cfg;
 
// 1. A list of allowed databases has already been defined by the
// authentication process -> gets the available databases list
if (count($dblist)) {
foreach ($dblist as $key => $db) {
if (!@PMA_DBI_select_db($db) || (!empty($GLOBALS['cfg']['Server']['hide_db']) && preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db))) {
unset($dblist[$key]);
} // end if
} // end for
} // end if
// 2. Allowed database list is empty -> gets the list of all databases
// on the server
elseif (empty($cfg['Server']['only_db'])) {
$dblist = PMA_DBI_get_dblist(); // needed? or PMA_mysqlDie('', 'SHOW DATABASES;', false, $error_url);
} // end else
 
$num_dbs = count($dblist);
 
// natural order for db list; but do not sort if user asked
// for a specific order with the 'only_db' mechanism
if (!is_array($GLOBALS['cfg']['Server']['only_db'])
&& $GLOBALS['cfg']['NaturalOrder']) {
natsort($dblist);
}
 
return true;
} // end of the 'PMA_availableDatabases()' function
 
/**
* returns array with tables of given db with extended infomation and grouped
*
* @uses $GLOBALS['cfg']['LeftFrameTableSeparator']
* @uses $GLOBALS['cfg']['LeftFrameTableLevel']
* @uses $GLOBALS['cfg']['ShowTooltipAliasTB']
* @uses $GLOBALS['cfg']['NaturalOrder']
* @uses PMA_DBI_fetch_result()
* @uses PMA_backquote()
* @uses count()
* @uses array_merge
* @uses uksort()
* @uses strstr()
* @uses explode()
* @param string $db name of db
* return array (rekursive) grouped table list
*/
function PMA_getTableList($db, $tables = null)
{
$sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
 
if ( null === $tables ) {
$tables = PMA_DBI_get_tables_full($db);
if ($GLOBALS['cfg']['NaturalOrder']) {
uksort($tables, 'strnatcasecmp');
}
}
 
if (count($tables) < 1) {
return $tables;
}
 
$default = array(
'Name' => '',
'Rows' => 0,
'Comment' => '',
'disp_name' => '',
);
 
$table_groups = array();
 
foreach ($tables as $table_name => $table) {
 
// check for correct row count
if (null === $table['Rows']) {
// Do not check exact row count here,
// if row count is invalid possibly the table is defect
// and this would break left frame;
// but we can check row count if this is a view,
// since PMA_countRecords() returns a limited row count
// in this case.
 
// set this because PMA_countRecords() can use it
$tbl_is_view = PMA_tableIsView($db, $table['Name']);
 
if ($tbl_is_view) {
$table['Rows'] = PMA_countRecords($db, $table['Name'],
$return = true);
}
}
 
// in $group we save the reference to the place in $table_groups
// where to store the table info
if ($GLOBALS['cfg']['LeftFrameDBTree']
&& $sep && strstr($table_name, $sep))
{
$parts = explode($sep, $table_name);
 
$group =& $table_groups;
$i = 0;
$group_name_full = '';
while ($i < count($parts) - 1
&& $i < $GLOBALS['cfg']['LeftFrameTableLevel']) {
$group_name = $parts[$i] . $sep;
$group_name_full .= $group_name;
 
if (!isset($group[$group_name])) {
$group[$group_name] = array();
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
} elseif (!isset($group[$group_name]['is' . $sep . 'group'])) {
$table = $group[$group_name];
$group[$group_name] = array();
$group[$group_name][$group_name] = $table;
unset($table);
$group[$group_name]['is' . $sep . 'group'] = true;
$group[$group_name]['tab' . $sep . 'count'] = 1;
$group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
} else {
$group[$group_name]['tab' . $sep . 'count']++;
}
$group =& $group[$group_name];
$i++;
}
} else {
if (!isset($table_groups[$table_name])) {
$table_groups[$table_name] = array();
}
$group =& $table_groups;
}
 
 
if ($GLOBALS['cfg']['ShowTooltipAliasTB']
&& $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested') {
// switch tooltip and name
$table['Comment'] = $table['Name'];
$table['disp_name'] = $table['Comment'];
} else {
$table['disp_name'] = $table['Name'];
}
 
$group[$table_name] = array_merge($default, $table);
}
 
return $table_groups;
}
 
/* ----------------------- Set of misc functions ----------------------- */
 
 
/**
* Adds backquotes on both sides of a database, table or field name.
* and escapes backquotes inside the name with another backquote
*
* <code>
* echo PMA_backquote('owner`s db'); // `owner``s db`
* </code>
*
* @param mixed $a_name the database, table or field name to "backquote"
* or array of it
* @param boolean $do_it a flag to bypass this function (used by dump
* functions)
* @return mixed the "backquoted" database, table or field name if the
* current MySQL release is >= 3.23.6, the original one
* else
* @access public
*/
function PMA_backquote($a_name, $do_it = true)
{
if (! $do_it) {
return $a_name;
}
 
if (is_array($a_name)) {
$result = array();
foreach ($a_name as $key => $val) {
$result[$key] = PMA_backquote($val);
}
return $result;
}
 
// '0' is also empty for php :-(
if (strlen($a_name) && $a_name != '*') {
return '`' . str_replace('`', '``', $a_name) . '`';
} else {
return $a_name;
}
} // end of the 'PMA_backquote()' function
 
 
/**
* Format a string so it can be passed to a javascript function.
* This function is used to displays a javascript confirmation box for
* "DROP/DELETE/ALTER" queries.
*
* @param string the string to format
* @param boolean whether to add backquotes to the string or not
*
* @return string the formated string
*
* @access public
*/
function PMA_jsFormat($a_string = '', $add_backquotes = true)
{
if (is_string($a_string)) {
$a_string = htmlspecialchars($a_string);
$a_string = str_replace('\\', '\\\\', $a_string);
$a_string = str_replace('\'', '\\\'', $a_string);
$a_string = str_replace('#', '\\#', $a_string);
$a_string = str_replace("\012", '\\\\n', $a_string);
$a_string = str_replace("\015", '\\\\r', $a_string);
}
 
return (($add_backquotes) ? PMA_backquote($a_string) : $a_string);
} // end of the 'PMA_jsFormat()' function
 
 
/**
* Defines the <CR><LF> value depending on the user OS.
*
* @return string the <CR><LF> value to use
*
* @access public
*/
function PMA_whichCrlf()
{
$the_crlf = "\n";
 
// The 'PMA_USR_OS' constant is defined in "./libraries/defines.lib.php"
// Win case
if (PMA_USR_OS == 'Win') {
$the_crlf = "\r\n";
}
// Mac case
elseif (PMA_USR_OS == 'Mac') {
$the_crlf = "\r";
}
// Others
else {
$the_crlf = "\n";
}
 
return $the_crlf;
} // end of the 'PMA_whichCrlf()' function
 
/**
* Checks if this "table" is a view
*
* @param string the database name
* @param string the table name
*
* @return boolean whether this is a view
*
* @access public
*/
function PMA_tableIsView($db, $table) {
// maybe we already know if the table is a view
// TODO: see what we could do with the possible existence
// of $table_is_view
if (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view']) {
return true;
}
// old MySQL version: no view
if (PMA_MYSQL_INT_VERSION < 50000) {
return false;
}
if ( false === PMA_DBI_fetch_value('SELECT TABLE_NAME FROM information_schema.VIEWS WHERE TABLE_SCHEMA = \'' . $db . '\' AND TABLE_NAME = \'' . $table . '\';')) {
return false;
} else {
return true;
}
}
 
/**
* Counts and returns (or displays) the number of records in a table
*
* Revision 13 July 2001: Patch for limiting dump size from
* vinay@sanisoft.com & girish@sanisoft.com
*
* @param string the current database name
* @param string the current table name
* @param boolean whether to retain or to displays the result
* @param boolean whether to force an exact count
*
* @return mixed the number of records if retain is required, true else
*
* @access public
*/
function PMA_countRecords($db, $table, $ret = false, $force_exact = false)
{
global $err_url, $cfg;
if (!$force_exact) {
$result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\';');
$showtable = PMA_DBI_fetch_assoc($result);
$num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
if ($num < $cfg['MaxExactCount']) {
unset($num);
}
PMA_DBI_free_result($result);
}
 
$tbl_is_view = PMA_tableIsView($db, $table);
 
if (!isset($num)) {
if (! $tbl_is_view) {
$num = PMA_DBI_fetch_value('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
// necessary?
if (! $num) {
$num = 0;
}
// since counting all rows of a view could be too long
} else {
// try_query because if can fail (a VIEW was based on a
// table that no longer exists)
$result = PMA_DBI_try_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $cfg['MaxExactCount'], null, PMA_DBI_QUERY_STORE);
if (!PMA_DBI_getError()) {
$num = PMA_DBI_num_rows($result);
} else {
$num = 0;
}
}
}
if ($ret) {
return $num;
} else {
// Note: as of PMA 2.8.0, we no longer seem to be using
// PMA_countRecords() in display mode.
echo number_format($num, 0, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator']);
if ($tbl_is_view) {
echo '&nbsp;' . sprintf($GLOBALS['strViewMaxExactCount'], $cfg['MaxExactCount'], '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]');
}
return true;
}
} // end of the 'PMA_countRecords()' function
 
/**
* Reloads navigation if needed.
*
* @global mixed configuration
* @global bool whether to reload
*
* @access public
*/
function PMA_reloadNavigation()
{
global $cfg;
 
// Reloads the navigation frame via JavaScript if required
if (isset($GLOBALS['reload']) && $GLOBALS['reload']) {
echo "\n";
$reload_url = './left.php?' . PMA_generate_common_url((isset($GLOBALS['db']) ? $GLOBALS['db'] : ''), '', '&');
?>
<script type="text/javascript" language="javascript">
//<![CDATA[
if (typeof(window.parent) != 'undefined'
&& typeof(window.parent.frames[0]) != 'undefined') {
window.parent.goTo('<?php echo $reload_url; ?>');
}
//]]>
</script>
<?php
unset($GLOBALS['reload']);
}
}
 
/**
* Displays a message at the top of the "main" (right) frame
*
* @param string the message to display
*
* @global array the configuration array
*
* @access public
*/
function PMA_showMessage($message)
{
global $cfg;
 
// Sanitizes $message
$message = PMA_sanitize($message);
 
// Corrects the tooltip text via JS if required
if ( isset($GLOBALS['table']) && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) {
$result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
if ($result) {
$tbl_status = PMA_DBI_fetch_assoc($result);
$tooltip = (empty($tbl_status['Comment']))
? ''
: $tbl_status['Comment'] . ' ';
$tooltip .= '(' . PMA_formatNumber($tbl_status['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')';
PMA_DBI_free_result($result);
$uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false);
echo "\n";
?>
<script type="text/javascript" language="javascript">
//<![CDATA[
window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsFormat($tooltip, false); ?>');
//]]>
</script>
<?php
} // end if
} // end if ... elseif
 
// Checks if the table needs to be repaired after a TRUNCATE query.
if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query'])
&& $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
if (!isset($tbl_status)) {
$result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
if ($result) {
$tbl_status = PMA_DBI_fetch_assoc($result);
PMA_DBI_free_result($result);
}
}
if (isset($tbl_status) && (int) $tbl_status['Index_length'] > 1024) {
PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
}
}
unset($tbl_status);
?>
<br />
<div align="<?php echo $GLOBALS['cell_align_left']; ?>">
<?php
if (!empty($GLOBALS['show_error_header'])) {
?>
<div class="error">
<h1><?php echo $GLOBALS['strError']; ?></h1>
<?php
}
 
echo $message;
if (isset($GLOBALS['special_message'])) {
echo PMA_sanitize($GLOBALS['special_message']);
unset($GLOBALS['special_message']);
}
 
if (!empty($GLOBALS['show_error_header'])) {
echo '</div>';
}
 
if ($cfg['ShowSQL'] == true
&& (!empty($GLOBALS['sql_query']) || !empty($GLOBALS['display_query']))) {
$local_query = !empty($GLOBALS['display_query']) ? $GLOBALS['display_query'] : (($cfg['SQP']['fmtType'] == 'none' && isset($GLOBALS['unparsed_sql']) && $GLOBALS['unparsed_sql'] != '') ? $GLOBALS['unparsed_sql'] : $GLOBALS['sql_query']);
// Basic url query part
$url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : '');
 
// Html format the query to be displayed
// The nl2br function isn't used because its result isn't a valid
// xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />")
// If we want to show some sql code it is easiest to create it here
/* SQL-Parser-Analyzer */
 
if (!empty($GLOBALS['show_as_php'])) {
$new_line = '\'<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. \' ';
}
if (isset($new_line)) {
/* SQL-Parser-Analyzer */
$query_base = PMA_sqlAddslashes(htmlspecialchars($local_query), false, false, true);
/* SQL-Parser-Analyzer */
$query_base = preg_replace("@((\015\012)|(\015)|(\012))+@", $new_line, $query_base);
} else {
$query_base = $local_query;
}
 
// Parse SQL if needed
if (isset($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) {
$parsed_sql = $GLOBALS['parsed_sql'];
} else {
// when the query is large (for example an INSERT of binary
// data), the parser chokes; so avoid parsing it
if (strlen($query_base) < 1000) {
$parsed_sql = PMA_SQP_parse($query_base);
}
}
 
// Analyze it
if (isset($parsed_sql)) {
$analyzed_display_query = PMA_SQP_analyze($parsed_sql);
}
 
// Here we append the LIMIT added for navigation, to
// enable its display. Adding it higher in the code
// to $local_query would create a problem when
// using the Refresh or Edit links.
 
// Only append it on SELECTs.
 
// FIXME: what would be the best to do when someone
// hits Refresh: use the current LIMITs ?
 
if (isset($analyzed_display_query[0]['queryflags']['select_from'])
&& isset($GLOBALS['sql_limit_to_append'])) {
$query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit'];
// Need to reparse query
$parsed_sql = PMA_SQP_parse($query_base);
}
 
if (!empty($GLOBALS['show_as_php'])) {
$query_base = '$sql = \'' . $query_base;
} elseif (!empty($GLOBALS['validatequery'])) {
$query_base = PMA_validateSQL($query_base);
} else {
if (isset($parsed_sql)) {
$query_base = PMA_formatSql($parsed_sql, $query_base);
}
}
 
// Prepares links that may be displayed to edit/explain the query
// (don't go to default pages, we must go to the page
// where the query box is available)
// (also, I don't see why we should check the goto variable)
 
//if (!isset($GLOBALS['goto'])) {
//$edit_target = (isset($GLOBALS['table'])) ? $cfg['DefaultTabTable'] : $cfg['DefaultTabDatabase'];
$edit_target = isset($GLOBALS['db']) ? (isset($GLOBALS['table']) ? 'tbl_properties.php' : 'db_details.php') : 'server_sql.php';
//} elseif ($GLOBALS['goto'] != 'main.php') {
// $edit_target = $GLOBALS['goto'];
//} else {
// $edit_target = '';
//}
 
if (isset($cfg['SQLQuery']['Edit'])
&& ($cfg['SQLQuery']['Edit'] == true)
&& (!empty($edit_target))) {
 
if ($cfg['EditInWindow'] == true) {
$onclick = 'window.parent.focus_querywindow(\'' . urlencode($local_query) . '\'); return false;';
} else {
$onclick = '';
}
 
$edit_link = $edit_target
. $url_qpart
. '&amp;sql_query=' . urlencode($local_query)
. '&amp;show_query=1#querybox';
$edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']';
} else {
$edit_link = '';
}
 
// Want to have the query explained (Mike Beck 2002-05-22)
// but only explain a SELECT (that has not been explained)
/* SQL-Parser-Analyzer */
if (isset($cfg['SQLQuery']['Explain'])
&& $cfg['SQLQuery']['Explain'] == true) {
 
// Detect if we are validating as well
// To preserve the validate uRL data
if (!empty($GLOBALS['validatequery'])) {
$explain_link_validate = '&amp;validatequery=1';
} else {
$explain_link_validate = '';
}
 
$explain_link = 'import.php'
. $url_qpart
. $explain_link_validate
. '&amp;sql_query=';
 
if (preg_match('@^SELECT[[:space:]]+@i', $local_query)) {
$explain_link .= urlencode('EXPLAIN ' . $local_query);
$message = $GLOBALS['strExplain'];
} elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $local_query)) {
$explain_link .= urlencode(substr($local_query, 8));
$message = $GLOBALS['strNoExplain'];
} else {
$explain_link = '';
}
if (!empty($explain_link)) {
$explain_link = ' [' . PMA_linkOrButton($explain_link, $message) . ']';
}
} else {
$explain_link = '';
} //show explain
 
// Also we would like to get the SQL formed in some nice
// php-code (Mike Beck 2002-05-22)
if (isset($cfg['SQLQuery']['ShowAsPHP'])
&& $cfg['SQLQuery']['ShowAsPHP'] == true) {
$php_link = 'import.php'
. $url_qpart
. '&amp;show_query=1'
. '&amp;sql_query=' . urlencode($local_query)
. '&amp;show_as_php=';
 
if (!empty($GLOBALS['show_as_php'])) {
$php_link .= '0';
$message = $GLOBALS['strNoPhp'];
} else {
$php_link .= '1';
$message = $GLOBALS['strPhp'];
}
$php_link = ' [' . PMA_linkOrButton($php_link, $message) . ']';
 
if (isset($GLOBALS['show_as_php']) && $GLOBALS['show_as_php'] == '1') {
$runquery_link
= 'import.php'
. $url_qpart
. '&amp;show_query=1'
. '&amp;sql_query=' . urlencode($local_query);
$php_link .= ' [' . PMA_linkOrButton($runquery_link, $GLOBALS['strRunQuery']) . ']';
}
 
} else {
$php_link = '';
} //show as php
 
// Refresh query
if (isset($cfg['SQLQuery']['Refresh'])
&& $cfg['SQLQuery']['Refresh']
&& preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $local_query)) {
$refresh_link = 'import.php'
. $url_qpart
. '&amp;show_query=1'
. (isset($_GET['pos']) ? '&amp;pos=' . $_GET['pos'] : '')
. '&amp;sql_query=' . urlencode($local_query);
$refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']';
} else {
$refresh_link = '';
} //show as php
 
if (isset($cfg['SQLValidator']['use'])
&& $cfg['SQLValidator']['use'] == true
&& isset($cfg['SQLQuery']['Validate'])
&& $cfg['SQLQuery']['Validate'] == true) {
$validate_link = 'import.php'
. $url_qpart
. '&amp;show_query=1'
. '&amp;sql_query=' . urlencode($local_query)
. '&amp;validatequery=';
if (!empty($GLOBALS['validatequery'])) {
$validate_link .= '0';
$validate_message = $GLOBALS['strNoValidateSQL'] ;
} else {
$validate_link .= '1';
$validate_message = $GLOBALS['strValidateSQL'] ;
}
$validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']';
} else {
$validate_link = '';
} //validator
unset($local_query);
 
// Displays the message
echo '<fieldset class="">' . "\n";
echo ' <legend>' . $GLOBALS['strSQLQuery'] . ':</legend>';
echo ' ' . $query_base;
 
//Clean up the end of the PHP
if (!empty($GLOBALS['show_as_php'])) {
echo '\';';
}
echo '</fieldset>' . "\n";
 
if (!empty($edit_target)) {
echo '<fieldset class="tblFooters">';
echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link;
echo '</fieldset>';
}
}
?>
</div><br />
<?php
} // end of the 'PMA_showMessage()' function
 
 
/**
* Formats $value to byte view
*
* @param double the value to format
* @param integer the sensitiveness
* @param integer the number of decimals to retain
*
* @return array the formatted value and its unit
*
* @access public
*
* @author staybyte
* @version 1.2 - 18 July 2002
*/
function PMA_formatByteDown($value, $limes = 6, $comma = 0)
{
$dh = pow(10, $comma);
$li = pow(10, $limes);
$return_value = $value;
$unit = $GLOBALS['byteUnits'][0];
 
for ($d = 6, $ex = 15; $d >= 1; $d--, $ex-=3) {
if (isset($GLOBALS['byteUnits'][$d]) && $value >= $li * pow(10, $ex)) {
$value = round($value / (pow(1024, $d) / $dh)) /$dh;
$unit = $GLOBALS['byteUnits'][$d];
break 1;
} // end if
} // end for
 
if ($unit != $GLOBALS['byteUnits'][0]) {
$return_value = number_format($value, $comma, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator']);
} else {
$return_value = number_format($value, 0, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator']);
}
 
return array($return_value, $unit);
} // end of the 'PMA_formatByteDown' function
 
/**
* Formats $value to the given length and appends SI prefixes
* $comma is not substracted from the length
* with a $length of 0 no truncation occurs, number is only formated
* to the current locale
* <code>
* echo PMA_formatNumber(123456789, 6); // 123,457 k
* echo PMA_formatNumber(-123456789, 4, 2); // -123.46 M
* echo PMA_formatNumber(-0.003, 6); // -3 m
* echo PMA_formatNumber(0.003, 3, 3); // 0.003
* echo PMA_formatNumber(0.00003, 3, 2); // 0.03 m
* echo PMA_formatNumber(0, 6); // 0
* </code>
* @param double $value the value to format
* @param integer $length the max length
* @param integer $comma the number of decimals to retain
* @param boolean $only_down do not reformat numbers below 1
*
* @return string the formatted value and its unit
*
* @access public
*
* @author staybyte, sebastian mendel
* @version 1.1.0 - 2005-10-27
*/
function PMA_formatNumber($value, $length = 3, $comma = 0, $only_down = false)
{
if ($length === 0) {
return number_format($value,
$comma,
$GLOBALS['number_decimal_separator'],
$GLOBALS['number_thousands_separator']);
}
 
// this units needs no translation, ISO
$units = array(
-8 => 'y',
-7 => 'z',
-6 => 'a',
-5 => 'f',
-4 => 'p',
-3 => 'n',
-2 => '&micro;',
-1 => 'm',
0 => ' ',
1 => 'k',
2 => 'M',
3 => 'G',
4 => 'T',
5 => 'P',
6 => 'E',
7 => 'Z',
8 => 'Y'
);
 
// we need at least 3 digits to be displayed
if (3 > $length + $comma) {
$length = 3 - $comma;
}
 
// check for negativ value to retain sign
if ($value < 0) {
$sign = '-';
$value = abs($value);
} else {
$sign = '';
}
 
$dh = pow(10, $comma);
$li = pow(10, $length);
$unit = $units[0];
 
if ($value >= 1) {
for ($d = 8; $d >= 0; $d--) {
if (isset($units[$d]) && $value >= $li * pow(1000, $d-1)) {
$value = round($value / (pow(1000, $d) / $dh)) /$dh;
$unit = $units[$d];
break 1;
} // end if
} // end for
} elseif (!$only_down && (float) $value !== 0.0) {
for ($d = -8; $d <= 8; $d++) {
if (isset($units[$d]) && $value <= $li * pow(1000, $d-1)) {
$value = round($value / (pow(1000, $d) / $dh)) /$dh;
$unit = $units[$d];
break 1;
} // end if
} // end for
} // end if ($value >= 1) elseif (!$only_down && (float) $value !== 0.0)
 
$value = number_format($value,
$comma,
$GLOBALS['number_decimal_separator'],
$GLOBALS['number_thousands_separator']);
 
return $sign . $value . ' ' . $unit;
} // end of the 'PMA_formatNumber' function
 
/**
* Extracts ENUM / SET options from a type definition string
*
* @param string The column type definition
*
* @return array The options or
* boolean false in case of an error.
*
* @author rabus
*/
function PMA_getEnumSetOptions($type_def)
{
$open = strpos($type_def, '(');
$close = strrpos($type_def, ')');
if (!$open || !$close) {
return false;
}
$options = substr($type_def, $open + 2, $close - $open - 3);
$options = explode('\',\'', $options);
return $options;
} // end of the 'PMA_getEnumSetOptions' function
 
/**
* Writes localised date
*
* @param string the current timestamp
*
* @return string the formatted date
*
* @access public
*/
function PMA_localisedDate($timestamp = -1, $format = '')
{
global $datefmt, $month, $day_of_week;
 
if ($format == '') {
$format = $datefmt;
}
 
if ($timestamp == -1) {
$timestamp = time();
}
 
$date = preg_replace('@%[aA]@', $day_of_week[(int)strftime('%w', $timestamp)], $format);
$date = preg_replace('@%[bB]@', $month[(int)strftime('%m', $timestamp)-1], $date);
 
return strftime($date, $timestamp);
} // end of the 'PMA_localisedDate()' function
 
 
/**
* returns a tab for tabbed navigation.
* If the variables $link and $args ar left empty, an inactive tab is created
*
* @uses array_merge()
* basename()
* $GLOBALS['strEmpty']
* $GLOBALS['strDrop']
* $GLOBALS['active_page']
* $GLOBALS['PHP_SELF']
* htmlentities()
* PMA_generate_common_url()
* $GLOBALS['url_query']
* urlencode()
* $GLOBALS['cfg']['MainPageIconic']
* $GLOBALS['pmaThemeImage']
* sprintf()
* trigger_error()
* E_USER_NOTICE
* @param array $tab array with all options
* @return string html code for one tab, a link if valid otherwise a span
* @access public
*/
function PMA_getTab($tab)
{
// default values
$defaults = array(
'text' => '',
'class' => '',
'active' => false,
'link' => '',
'sep' => '?',
'attr' => '',
'args' => '',
);
 
$tab = array_merge($defaults, $tab);
 
// determine additionnal style-class
if (empty($tab['class'])) {
if ($tab['text'] == $GLOBALS['strEmpty']
|| $tab['text'] == $GLOBALS['strDrop']) {
$tab['class'] = 'caution';
} elseif (!empty($tab['active'])
|| (isset($GLOBALS['active_page'])
&& $GLOBALS['active_page'] == $tab['link'])
|| basename(PMA_getenv('PHP_SELF')) == $tab['link'])
{
$tab['class'] = 'active';
}
}
 
// build the link
if (!empty($tab['link'])) {
$tab['link'] = htmlentities($tab['link']);
$tab['link'] = $tab['link'] . $tab['sep']
.(empty($GLOBALS['url_query']) ?
PMA_generate_common_url() : $GLOBALS['url_query']);
if (!empty($tab['args'])) {
foreach ($tab['args'] as $param => $value) {
$tab['link'] .= '&amp;' . urlencode($param) . '='
. urlencode($value);
}
}
}
 
// display icon, even if iconic is disabled but the link-text is missing
if (($GLOBALS['cfg']['MainPageIconic'] || empty($tab['text']))
&& isset($tab['icon'])) {
$image = '<img class="icon" src="' . htmlentities($GLOBALS['pmaThemeImage'])
.'%1$s" width="16" height="16" alt="%2$s" />%2$s';
$tab['text'] = sprintf($image, htmlentities($tab['icon']), $tab['text']);
}
// check to not display an empty link-text
elseif (empty($tab['text'])) {
$tab['text'] = '?';
trigger_error('empty linktext in function ' . __FUNCTION__ . '()',
E_USER_NOTICE);
}
 
if (!empty($tab['link'])) {
$out = '<a class="tab' . htmlentities($tab['class']) . '"'
.' href="' . $tab['link'] . '" ' . $tab['attr'] . '>'
. $tab['text'] . '</a>';
} else {
$out = '<span class="tab' . htmlentities($tab['class']) . '">'
. $tab['text'] . '</span>';
}
 
return $out;
} // end of the 'PMA_getTab()' function
 
/**
* returns html-code for a tab navigation
*
* @uses PMA_getTab()
* @uses htmlentities()
* @param array $tabs one element per tab
* @param string $tag_id id used for the html-tag
* @return string html-code for tab-navigation
*/
function PMA_getTabs($tabs, $tag_id = 'topmenu')
{
$tab_navigation =
'<div id="' . htmlentities($tag_id) . 'container">' . "\n"
.'<ul id="' . htmlentities($tag_id) . '">' . "\n";
 
foreach ($tabs as $tab) {
$tab_navigation .= '<li>' . PMA_getTab($tab) . '</li>' . "\n";
}
 
$tab_navigation .=
'</ul>' . "\n"
.'<div class="clearfloat"></div>'
.'</div>' . "\n";
 
return $tab_navigation;
}
 
 
/**
* Displays a link, or a button if the link's URL is too large, to
* accommodate some browsers' limitations
*
* @param string the URL
* @param string the link message
* @param mixed $tag_params string: js confirmation
* array: additional tag params (f.e. style="")
* @param boolean $new_form we set this to false when we are already in
* a form, to avoid generating nested forms
*
* @return string the results to be echoed or saved in an array
*/
function PMA_linkOrButton($url, $message, $tag_params = array(),
$new_form = true, $strip_img = false, $target = '')
{
if (! is_array($tag_params)) {
$tmp = $tag_params;
$tag_params = array();
if (!empty($tmp)) {
$tag_params['onclick'] = 'return confirmLink(this, \'' . $tmp . '\')';
}
unset($tmp);
}
if (! empty($target)) {
$tag_params['target'] = htmlentities($target);
}
 
$tag_params_strings = array();
foreach ($tag_params as $par_name => $par_value) {
// htmlentities() only on non javascript
$par_value = substr($par_name, 0, 2) == 'on'
? $par_value
: htmlentities($par_value);
$tag_params_strings[] = $par_name . '="' . $par_value . '"';
}
 
// previously the limit was set to 2047, it seems 1000 is better
if (strlen($url) <= 1000) {
// no whitespace within an <a> else Safari will make it part of the link
$ret = "\n" . '<a href="' . $url . '" '
. implode(' ', $tag_params_strings) . '>'
. $message . '</a>' . "\n";
} else {
// no spaces (linebreaks) at all
// or after the hidden fields
// IE will display them all
 
// add class=link to submit button
if (empty($tag_params['class'])) {
$tag_params['class'] = 'link';
}
$url = str_replace('&amp;', '&', $url);
$url_parts = parse_url($url);
$query_parts = explode('&', $url_parts['query']);
if ($new_form) {
$ret = '<form action="' . $url_parts['path'] . '" class="link"'
. ' method="post"' . $target . ' style="display: inline;">';
$subname_open = '';
$subname_close = '';
$submit_name = '';
} else {
$query_parts[] = 'redirect=' . $url_parts['path'];
if (empty($GLOBALS['subform_counter'])) {
$GLOBALS['subform_counter'] = 0;
}
$GLOBALS['subform_counter']++;
$ret = '';
$subname_open = 'subform[' . $GLOBALS['subform_counter'] . '][';
$subname_close = ']';
$submit_name = ' name="usesubform[' . $GLOBALS['subform_counter'] . ']"';
}
foreach ($query_parts AS $query_pair) {
list($eachvar, $eachval) = explode('=', $query_pair);
$ret .= '<input type="hidden" name="' . $subname_open . $eachvar
. $subname_close . '" value="'
. htmlspecialchars(urldecode($eachval)) . '" />';
} // end while
 
if (stristr($message, '<img')) {
if ($strip_img) {
$message = trim(strip_tags($message));
$ret .= '<input type="submit"' . $submit_name . ' '
. implode(' ', $tag_params_strings)
. ' value="' . htmlspecialchars($message) . '" />';
} else {
$ret .= '<input type="image"' . $submit_name . ' '
. implode(' ', $tag_params_strings)
. ' src="' . preg_replace(
'/^.*\ssrc="([^"]*)".*$/si', '\1', $message) . '"'
. ' value="' . htmlspecialchars(
preg_replace('/^.*\salt="([^"]*)".*$/si', '\1',
$message))
. '" />';
}
} else {
$message = trim(strip_tags($message));
$ret .= '<input type="submit"' . $submit_name . ' '
. implode(' ', $tag_params_strings)
. ' value="' . htmlspecialchars($message) . '" />';
}
if ($new_form) {
$ret .= '</form>';
}
} // end if... else...
 
return $ret;
} // end of the 'PMA_linkOrButton()' function
 
 
/**
* Returns a given timespan value in a readable format.
*
* @param int the timespan
*
* @return string the formatted value
*/
function PMA_timespanFormat($seconds)
{
$return_string = '';
$days = floor($seconds / 86400);
if ($days > 0) {
$seconds -= $days * 86400;
}
$hours = floor($seconds / 3600);
if ($days > 0 || $hours > 0) {
$seconds -= $hours * 3600;
}
$minutes = floor($seconds / 60);
if ($days > 0 || $hours > 0 || $minutes > 0) {
$seconds -= $minutes * 60;
}
return sprintf($GLOBALS['timespanfmt'], (string)$days, (string)$hours, (string)$minutes, (string)$seconds);
}
 
/**
* Takes a string and outputs each character on a line for itself. Used
* mainly for horizontalflipped display mode.
* Takes care of special html-characters.
* Fulfills todo-item
* http://sf.net/tracker/?func=detail&aid=544361&group_id=23067&atid=377411
*
* @param string The string
* @param string The Separator (defaults to "<br />\n")
*
* @access public
* @author Garvin Hicking <me@supergarv.de>
* @return string The flipped string
*/
function PMA_flipstring($string, $Separator = "<br />\n")
{
$format_string = '';
$charbuff = false;
 
for ($i = 0; $i < strlen($string); $i++) {
$char = $string{$i};
$append = false;
 
if ($char == '&') {
$format_string .= $charbuff;
$charbuff = $char;
$append = true;
} elseif (!empty($charbuff)) {
$charbuff .= $char;
} elseif ($char == ';' && !empty($charbuff)) {
$format_string .= $charbuff;
$charbuff = false;
$append = true;
} else {
$format_string .= $char;
$append = true;
}
 
if ($append && ($i != strlen($string))) {
$format_string .= $Separator;
}
}
 
return $format_string;
}
 
 
/**
* Function added to avoid path disclosures.
* Called by each script that needs parameters, it displays
* an error message and, by default, stops the execution.
*
* Not sure we could use a strMissingParameter message here,
* would have to check if the error message file is always available
*
* @param array The names of the parameters needed by the calling
* script.
* @param boolean Stop the execution?
* (Set this manually to false in the calling script
* until you know all needed parameters to check).
* @param boolean Whether to include this list in checking for special params.
* @global string path to current script
* @global boolean flag whether any special variable was required
*
* @access public
* @author Marc Delisle (lem9@users.sourceforge.net)
*/
function PMA_checkParameters($params, $die = true, $request = true)
{
global $PHP_SELF, $checked_special;
 
if (!isset($checked_special)) {
$checked_special = false;
}
 
$reported_script_name = basename($PHP_SELF);
$found_error = false;
$error_message = '';
 
foreach ($params AS $param) {
if ($request && $param != 'db' && $param != 'table') {
$checked_special = true;
}
 
if (!isset($GLOBALS[$param])) {
$error_message .= $reported_script_name . ': Missing parameter: ' . $param . ' <a href="./Documentation.html#faqmissingparameters" target="documentation"> (FAQ 2.8)</a><br />';
$found_error = true;
}
}
if ($found_error) {
require_once './libraries/header_meta_style.inc.php';
echo '</head><body><p>' . $error_message . '</p></body></html>';
if ($die) {
exit();
}
}
} // end function
 
/**
* Function to generate unique condition for specified row.
*
* @param resource handle for current query
* @param integer number of fields
* @param array meta information about fields
* @param array current row
*
* @access public
* @author Michal Cihar (michal@cihar.com)
* @return string calculated condition
*/
function PMA_getUvaCondition($handle, $fields_cnt, $fields_meta, $row)
{
$primary_key = '';
$unique_key = '';
$uva_nonprimary_condition = '';
 
for ($i = 0; $i < $fields_cnt; ++$i) {
$field_flags = PMA_DBI_field_flags($handle, $i);
$meta = $fields_meta[$i];
// do not use an alias in a condition
$column_for_condition = $meta->name;
if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
$alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
if (strlen($alias)) {
$true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
if ($alias == $meta->name) {
$column_for_condition = $true_column;
} // end if
} // end if
} // end while
}
 
// to fix the bug where float fields (primary or not)
// can't be matched because of the imprecision of
// floating comparison, use CONCAT
// (also, the syntax "CONCAT(field) IS NULL"
// that we need on the next "if" will work)
if ($meta->type == 'real') {
$condition = ' CONCAT(' . PMA_backquote($column_for_condition) . ') ';
} else {
// string and blob fields have to be converted using
// the system character set (always utf8) since
// mysql4.1 can use different charset for fields.
if (PMA_MYSQL_INT_VERSION >= 40100 && ($meta->type == 'string' || $meta->type == 'blob')) {
$condition = ' CONVERT(' . PMA_backquote($column_for_condition) . ' USING utf8) ';
} else {
$condition = ' ' . PMA_backquote($column_for_condition) . ' ';
}
} // end if... else...
 
if (!isset($row[$i]) || is_null($row[$i])) {
$condition .= 'IS NULL AND';
} else {
// timestamp is numeric on some MySQL 4.1
if ($meta->numeric && $meta->type != 'timestamp') {
$condition .= '= ' . $row[$i] . ' AND';
} elseif ($meta->type == 'blob'
// hexify only if this is a true not empty BLOB
&& stristr($field_flags, 'BINARY')
&& !empty($row[$i])) {
// use a CAST if possible, to avoid problems
// if the field contains wildcard characters % or _
if (PMA_MYSQL_INT_VERSION < 40002) {
$condition .= 'LIKE 0x' . bin2hex($row[$i]). ' AND';
} else {
$condition .= '= CAST(0x' . bin2hex($row[$i]). ' AS BINARY) AND';
}
} else {
$condition .= '= \'' . PMA_sqlAddslashes($row[$i], false, true) . '\' AND';
}
}
if ($meta->primary_key > 0) {
$primary_key .= $condition;
} elseif ($meta->unique_key > 0) {
$unique_key .= $condition;
}
$uva_nonprimary_condition .= $condition;
} // end for
 
// Correction uva 19991216: prefer primary or unique keys
// for condition, but use conjunction of all values if no
// primary key
if ($primary_key) {
$uva_condition = $primary_key;
} elseif ($unique_key) {
$uva_condition = $unique_key;
} else {
$uva_condition = $uva_nonprimary_condition;
}
 
return preg_replace('|\s?AND$|', '', $uva_condition);
} // end function
 
/**
* Function to generate unique condition for specified row.
*
* @param string name of button element
* @param string class of button element
* @param string name of image element
* @param string text to display
* @param string image to display
*
* @access public
* @author Michal Cihar (michal@cihar.com)
*/
function PMA_buttonOrImage($button_name, $button_class, $image_name, $text,
$image)
{
global $pmaThemeImage, $propicon;
 
/* Opera has trouble with <input type="image"> */
/* IE has trouble with <button> */
if (PMA_USR_BROWSER_AGENT != 'IE') {
echo '<button class="' . $button_class . '" type="submit"'
.' name="' . $button_name . '" value="' . $text . '"'
.' title="' . $text . '">' . "\n"
.'<img class="icon" src="' . $pmaThemeImage . $image . '"'
.' title="' . $text . '" alt="' . $text . '" width="16"'
.' height="16" />'
.($propicon == 'both' ? '&nbsp;' . $text : '') . "\n"
.'</button>' . "\n";
} else {
echo '<input type="image" name="' . $image_name . '" value="'
. $text . '" title="' . $text . '" src="' . $pmaThemeImage
. $image . '" />'
. ($propicon == 'both' ? '&nbsp;' . $text : '') . "\n";
}
} // end function
 
/**
* Generate a pagination selector for browsing resultsets
*
* @param string URL for the JavaScript
* @param string Number of rows in the pagination set
* @param string current page number
* @param string number of total pages
* @param string If the number of pages is lower than this
* variable, no pages will be ommitted in
* pagination
* @param string How many rows at the beginning should always
* be shown?
* @param string How many rows at the end should always
* be shown?
* @param string Percentage of calculation page offsets to
* hop to a next page
* @param string Near the current page, how many pages should
* be considered "nearby" and displayed as
* well?
*
* @access public
* @author Garvin Hicking (pma@supergarv.de)
*/
function PMA_pageselector($url, $rows, $pageNow = 1, $nbTotalPage = 1,
$showAll = 200, $sliceStart = 5, $sliceEnd = 5, $percent = 20,
$range = 10)
{
$gotopage = $GLOBALS['strPageNumber']
. ' <select name="goToPage" onchange="goToUrl(this, \''
. $url . '\');">' . "\n";
if ($nbTotalPage < $showAll) {
$pages = range(1, $nbTotalPage);
} else {
$pages = array();
 
// Always show first X pages
for ($i = 1; $i <= $sliceStart; $i++) {
$pages[] = $i;
}
 
// Always show last X pages
for ($i = $nbTotalPage - $sliceEnd; $i <= $nbTotalPage; $i++) {
$pages[] = $i;
}
 
// garvin: Based on the number of results we add the specified
// $percent percentate to each page number,
// so that we have a representing page number every now and then to
// immideately jump to specific pages.
// As soon as we get near our currently chosen page ($pageNow -
// $range), every page number will be
// shown.
$i = $sliceStart;
$x = $nbTotalPage - $sliceEnd;
$met_boundary = false;
while ($i <= $x) {
if ($i >= ($pageNow - $range) && $i <= ($pageNow + $range)) {
// If our pageselector comes near the current page, we use 1
// counter increments
$i++;
$met_boundary = true;
} else {
// We add the percentate increment to our current page to
// hop to the next one in range
$i = $i + floor($nbTotalPage / $percent);
 
// Make sure that we do not cross our boundaries.
if ($i > ($pageNow - $range) && !$met_boundary) {
$i = $pageNow - $range;
}
}
 
if ($i > 0 && $i <= $x) {
$pages[] = $i;
}
}
 
// Since because of ellipsing of the current page some numbers may be double,
// we unify our array:
sort($pages);
$pages = array_unique($pages);
}
 
foreach ($pages AS $i) {
if ($i == $pageNow) {
$selected = 'selected="selected" style="font-weight: bold"';
} else {
$selected = '';
}
$gotopage .= ' <option ' . $selected . ' value="' . (($i - 1) * $rows) . '">' . $i . '</option>' . "\n";
}
 
$gotopage .= ' </select>';
 
return $gotopage;
} // end function
 
/**
* @TODO add documentation
*/
function PMA_generateFieldSpec($name, $type, $length, $attribute,
$collation, $null, $default, $default_current_timestamp, $extra,
$comment='', &$field_primary, $index, $default_orig = false)
{
 
// $default_current_timestamp has priority over $default
// TODO: on the interface, some js to clear the default value
// when the default current_timestamp is checked
 
$query = PMA_backquote($name) . ' ' . $type;
 
if ($length != ''
&& !preg_match('@^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$@i', $type)) {
$query .= '(' . $length . ')';
}
 
if ($attribute != '') {
$query .= ' ' . $attribute;
}
 
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($collation)
&& $collation != 'NULL'
&& preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type)) {
$query .= PMA_generateCharsetQueryPart($collation);
}
 
if (!($null === false)) {
if (!empty($null)) {
$query .= ' NOT NULL';
} else {
$query .= ' NULL';
}
}
 
if ($default_current_timestamp && strpos(' ' . strtoupper($type), 'TIMESTAMP') == 1) {
$query .= ' DEFAULT CURRENT_TIMESTAMP';
// 0 is empty in PHP
// auto_increment field cannot have a default value
} elseif ($extra !== 'AUTO_INCREMENT' && (!empty($default) || $default == '0' || $default != $default_orig)) {
if (strtoupper($default) == 'NULL') {
$query .= ' DEFAULT NULL';
} else {
if (!empty($default) || $default == '0') {
$query .= ' DEFAULT \'' . PMA_sqlAddslashes($default) . '\'';
}
}
}
 
if (!empty($extra)) {
$query .= ' ' . $extra;
// An auto_increment field must be use as a primary key
if ($extra == 'AUTO_INCREMENT' && isset($field_primary)) {
$primary_cnt = count($field_primary);
for ($j = 0; $j < $primary_cnt && $field_primary[$j] != $index; $j++) {
// void
} // end for
if (isset($field_primary[$j]) && $field_primary[$j] == $index) {
$query .= ' PRIMARY KEY';
unset($field_primary[$j]);
} // end if
} // end if (auto_increment)
}
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($comment)) {
$query .= " COMMENT '" . PMA_sqlAddslashes($comment) . "'";
}
return $query;
} // end function
 
/**
* @TODO add documentation
*/
function PMA_generateAlterTable($oldcol, $newcol, $type, $length,
$attribute, $collation, $null, $default, $default_current_timestamp,
$extra, $comment='', $default_orig)
{
$empty_a = array();
return PMA_backquote($oldcol) . ' '
. PMA_generateFieldSpec($newcol, $type, $length, $attribute,
$collation, $null, $default, $default_current_timestamp, $extra,
$comment, $empty_a, -1, $default_orig);
} // end function
 
/**
* @TODO add documentation
*/
function PMA_userDir($dir)
{
global $cfg;
 
if (substr($dir, -1) != '/') {
$dir .= '/';
}
 
return str_replace('%u', $cfg['Server']['user'], $dir);
}
 
/**
* returns html code for db link to default db page
*
* @uses $GLOBALS['cfg']['DefaultTabDatabase']
* @uses $GLOBALS['db']
* @uses $GLOBALS['strJumpToDB']
* @uses PMA_generate_common_url()
* @param string $database
* @return string html link to default db page
*/
function PMA_getDbLink($database = null)
{
if (!strlen($database)) {
if (!strlen($GLOBALS['db'])) {
return '';
}
$database = $GLOBALS['db'];
}
 
return '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url($database) . '"'
.' title="' . sprintf($GLOBALS['strJumpToDB'], htmlspecialchars($database)) . '">'
.htmlspecialchars($database) . '</a>';
}
 
/**
* removes cookie
*
* @uses $GLOBALS['cookie_path']
* @uses $GLOBALS['is_https']
* @uses setcookie()
* @uses time()
* @param string $cookie name of cookie to remove
* @return boolean result of setcookie()
*/
function PMA_removeCookie($cookie)
{
return setcookie($cookie, '', time() - 3600,
$GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
}
 
/**
* sets cookie if value is different from current cokkie value,
* or removes if value is equal to default
*
* @uses $GLOBALS['cookie_path']
* @uses $GLOBALS['is_https']
* @uses $_COOKIE
* @uses PMA_removeCookie()
* @uses setcookie()
* @uses time()
* @param string $cookie name of cookie to remove
* @param mixed $value new cookie value
* @param string $default default value
* @return boolean result of setcookie()
*/
function PMA_setCookie($cookie, $value, $default = null)
{
if (strlen($value) && null !== $default && $value === $default) {
// remove cookie, default value is used
return PMA_removeCookie($cookie);
}
 
if (! strlen($value) && isset($_COOKIE[$cookie])) {
// remove cookie, value is empty
return PMA_removeCookie($cookie);
}
 
if (! isset($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) {
// set cookie with new value
return setcookie($cookie, $value, time() + 60*60*24*30,
$GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
}
 
// cookie has already $value as value
return true;
}
 
 
/**
* include here only libraries which contain only function definitions
* no code im main()!
*/
/**
* Include URL/hidden inputs generating.
*/
require_once './libraries/url_generating.lib.php';
 
}
 
 
/******************************************************************************/
/* start procedural code label_start_procedural */
 
/**
* protect against older PHP versions' bug about GLOBALS overwrite
* (no need to localize this message :))
* but what if script.php?GLOBALS[admin]=1&GLOBALS[_REQUEST]=1 ???
*/
if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])
|| isset($_SERVER['GLOBALS']) || isset($_COOKIE['GLOBALS'])
|| isset($_ENV['GLOBALS'])) {
die('GLOBALS overwrite attempt');
}
 
/**
* just to be sure there was no import (registering) before here
* we empty the global space
*/
$variables_whitelist = array (
'GLOBALS',
'_SERVER',
'_GET',
'_POST',
'_REQUEST',
'_FILES',
'_ENV',
'_COOKIE',
'_SESSION',
);
 
foreach (get_defined_vars() as $key => $value) {
if (!in_array($key, $variables_whitelist)) {
unset($$key);
}
}
unset($key, $value);
 
 
/**
* check if a subform is submitted
*/
$__redirect = null;
if (isset($_POST['usesubform'])) {
// if a subform is present and should be used
// the rest of the form is deprecated
$subform_id = key($_POST['usesubform']);
$subform = $_POST['subform'][$subform_id];
$_POST = $subform;
$_REQUEST = $subform;
if (isset($_POST['redirect'])
&& $_POST['redirect'] != basename(PMA_getenv('PHP_SELF'))) {
$__redirect = $_POST['redirect'];
unset($_POST['redirect']);
} // end if (isset($_POST['redirect']))
unset($subform_id, $subform);
} // end if (isset($_POST['usesubform']))
// end check if a subform is submitted
 
if (get_magic_quotes_gpc()) {
PMA_arrayWalkRecursive($_GET, 'stripslashes', true);
PMA_arrayWalkRecursive($_POST, 'stripslashes', true);
PMA_arrayWalkRecursive($_COOKIE, 'stripslashes', true);
PMA_arrayWalkRecursive($_REQUEST, 'stripslashes', true);
}
 
require_once './libraries/session.inc.php';
 
/**
* include deprecated grab_globals only if required
*/
if (empty($__redirect) && !defined('PMA_NO_VARIABLES_IMPORT')) {
require './libraries/grab_globals.lib.php';
}
 
/**
* init some variables LABEL_variables_init
*/
 
/**
* @var array $GLOBALS['PMA_errors'] holds errors
*/
$GLOBALS['PMA_errors'] = array();
 
/**
* @var array $GLOBALS['url_params'] holds params to be passed to next page
*/
$GLOBALS['url_params'] = array();
 
/**
* @var array whitelist for $goto
*/
$goto_whitelist = array(
//'browse_foreigners.php',
//'calendar.php',
//'changelog.php',
//'chk_rel.php',
'db_create.php',
'db_datadict.php',
'db_details.php',
'db_details_export.php',
'db_details_importdocsql.php',
'db_details_qbe.php',
'db_details_structure.php',
'db_import.php',
'db_operations.php',
'db_printview.php',
'db_search.php',
//'Documentation.html',
//'error.php',
'export.php',
'import.php',
//'index.php',
//'left.php',
//'license.php',
'main.php',
'pdf_pages.php',
'pdf_schema.php',
//'phpinfo.php',
'querywindow.php',
//'readme.php',
'server_binlog.php',
'server_collations.php',
'server_databases.php',
'server_engines.php',
'server_export.php',
'server_import.php',
'server_privileges.php',
'server_processlist.php',
'server_sql.php',
'server_status.php',
'server_variables.php',
'sql.php',
'tbl_addfield.php',
'tbl_alter.php',
'tbl_change.php',
'tbl_create.php',
'tbl_import.php',
'tbl_indexes.php',
'tbl_move_copy.php',
'tbl_printview.php',
'tbl_properties.php',
'tbl_properties_export.php',
'tbl_properties_operations.php',
'tbl_properties_structure.php',
'tbl_relation.php',
'tbl_replace.php',
'tbl_row_action.php',
'tbl_select.php',
//'themes.php',
'transformation_overview.php',
'transformation_wrapper.php',
'translators.html',
'user_password.php',
);
 
/**
* check $__redirect against whitelist
*/
if (! PMA_checkPageValidity($__redirect, $goto_whitelist)) {
$__redirect = null;
}
 
/**
* @var string $goto holds page that should be displayed
*/
// Security fix: disallow accessing serious server files via "?goto="
if (PMA_checkPageValidity($_REQUEST['goto'], $goto_whitelist)) {
$GLOBALS['goto'] = $_REQUEST['goto'];
$GLOBALS['url_params']['goto'] = $_REQUEST['goto'];
} else {
unset($_REQUEST['goto'], $_GET['goto'], $_POST['goto'], $_COOKIE['goto']);
$GLOBALS['goto'] = '';
}
 
/**
* @var string $back returning page
*/
if (PMA_checkPageValidity($_REQUEST['back'], $goto_whitelist)) {
$GLOBALS['back'] = $_REQUEST['back'];
} else {
unset($_REQUEST['back'], $_GET['back'], $_POST['back'], $_COOKIE['back']);
}
 
/**
* Check whether user supplied token is valid, if not remove any
* possibly dangerous stuff from request.
*/
if (!isset($_REQUEST['token']) || $_SESSION['PMA_token'] != $_REQUEST['token']) {
/* List of parameters which are allowed from unsafe source */
$allow_list = array(
'db', 'table', 'lang', 'server', 'convcharset', 'collation_connection', 'target',
/* Session ID */
'phpMyAdmin',
/* Cookie preferences */
'pma_lang', 'pma_charset', 'pma_collation_connection', 'pma_convcharset',
/* Possible login form */
'pma_username', 'pma_password',
);
$keys = array_keys($_REQUEST);
/* Remove any non allowed stuff from requests */
foreach($keys as $key) {
if (!in_array($key, $allow_list)) {
unset($_REQUEST[$key]);
unset($_GET[$key]);
unset($_POST[$key]);
unset($GLOBALS[$key]);
} else {
// allowed stuff could be compromised so escape it
$_REQUEST[$key] = htmlspecialchars($_REQUEST[$key], ENT_QUOTES);
}
}
}
 
/**
* @var string $convcharset
* @see also select_lang.lib.php
*/
if (isset($_REQUEST['convcharset'])) {
$convcharset = strip_tags($_REQUEST['convcharset']);
}
 
/**
* @var string $db current selected database
*/
if (isset($_REQUEST['db'])) {
// can we strip tags from this?
// only \ and / is not allowed in db names for MySQL
$GLOBALS['db'] = $_REQUEST['db'];
$GLOBALS['url_params']['db'] = $GLOBALS['db'];
} else {
$GLOBALS['db'] = '';
}
 
/**
* @var string $db current selected database
*/
if (isset($_REQUEST['table'])) {
// can we strip tags from this?
// only \ and / is not allowed in table names for MySQL
$GLOBALS['table'] = $_REQUEST['table'];
$GLOBALS['url_params']['table'] = $GLOBALS['table'];
} else {
$GLOBALS['table'] = '';
}
 
/**
* @var string $sql_query sql query to be executed
*/
if (isset($_REQUEST['sql_query'])) {
$GLOBALS['sql_query'] = $_REQUEST['sql_query'];
}
 
//$_REQUEST['set_theme'] // checked later in this file LABEL_theme_setup
//$_REQUEST['server']; // checked later in this file
//$_REQUEST['lang']; // checked by LABEL_loading_language_file
 
 
 
/******************************************************************************/
/* parsing config file LABEL_parsing_config_file */
 
if (empty($_SESSION['PMA_Config'])) {
/**
* We really need this one!
*/
if (!function_exists('preg_replace')) {
header('Location: error.php'
. '?lang=' . urlencode($available_languages[$lang][2])
. '&char=' . urlencode($charset)
. '&dir=' . urlencode($text_dir)
. '&type=' . urlencode($strError)
. '&error=' . urlencode(
strtr(sprintf($strCantLoad, 'pcre'),
array('<br />' => '[br]')))
. '&' . SID
);
exit();
}
 
$_SESSION['PMA_Config'] = new PMA_Config('./config.inc.php');
 
} elseif (version_compare(phpversion(), '5', 'lt')) {
$_SESSION['PMA_Config']->__wakeup();
}
 
if (!defined('PMA_MINIMUM_COMMON')) {
$_SESSION['PMA_Config']->checkPmaAbsoluteUri();
}
 
// BC
$_SESSION['PMA_Config']->enableBc();
 
 
/**
* check https connection
*/
if ($_SESSION['PMA_Config']->get('ForceSSL')
&& !$_SESSION['PMA_Config']->get('is_https')) {
PMA_sendHeaderLocation(
preg_replace('/^http/', 'https',
$_SESSION['PMA_Config']->get('PmaAbsoluteUri'))
. PMA_generate_common_url($_GET));
exit;
}
 
 
/******************************************************************************/
/* loading language file LABEL_loading_language_file */
 
/**
* Added messages while developing:
*/
if (file_exists('./lang/added_messages.php')) {
include './lang/added_messages.php';
}
 
/**
* Includes the language file if it hasn't been included yet
*/
require_once './libraries/select_lang.lib.php';
 
 
/**
* check for errors occured while loading config
*/
if ($_SESSION['PMA_Config']->error_config_file) {
$GLOBALS['PMA_errors'][] = $strConfigFileError
.'<br /><br />'
.'<a href="' . $_SESSION['PMA_Config']->getSource() . '"'
.' target="_blank">' . $_SESSION['PMA_Config']->getSource() . '</a>';
}
if ($_SESSION['PMA_Config']->error_config_default_file) {
$GLOBALS['PMA_errors'][] = sprintf($strConfigDefaultFileError,
$_SESSION['PMA_Config']->default_source);
}
if ($_SESSION['PMA_Config']->error_pma_uri) {
$GLOBALS['PMA_errors'][] = sprintf($strPmaUriError);
}
 
/**
* Servers array fixups.
* $default_server comes from PMA_Config::enableBc()
* @todo merge into PMA_Config
*/
// Do we have some server?
if (!isset($cfg['Servers']) || count($cfg['Servers']) == 0) {
// No server => create one with defaults
$cfg['Servers'] = array(1 => $default_server);
} else {
// We have server(s) => apply default config
$new_servers = array();
 
foreach ($cfg['Servers'] as $server_index => $each_server) {
if (!is_int($server_index) || $server_index < 1) {
$GLOBALS['PMA_errors'][] = sprintf($strInvalidServerIndex, $server_index);
continue;
}
 
$each_server = array_merge($default_server, $each_server);
 
// Don't use servers with no hostname
if ($each_server['connect_type'] == 'tcp' && empty($each_server['host'])) {
$GLOBALS['PMA_errors'][] = sprintf($strInvalidServerHostname, $server_index);
continue;
}
 
// Final solution to bug #582890
// If we are using a socket connection
// and there is nothing in the verbose server name
// or the host field, then generate a name for the server
// in the form of "Server 2", localized of course!
if ($each_server['connect_type'] == 'socket' && empty($each_server['host']) && empty($each_server['verbose'])) {
$each_server['verbose'] = $GLOBALS['strServer'] . $server_index;
}
 
$new_servers[$server_index] = $each_server;
}
$cfg['Servers'] = $new_servers;
unset($new_servers, $server_index, $each_server);
}
 
// Cleanup
unset($default_server);
 
 
/******************************************************************************/
/* setup themes LABEL_theme_setup */
 
if (!isset($_SESSION['PMA_Theme_Manager'])) {
$_SESSION['PMA_Theme_Manager'] = new PMA_Theme_Manager;
} else {
$_SESSION['PMA_Theme_Manager']->checkConfig();
}
 
if (isset($_REQUEST['set_theme'])) {
// if user submit a theme
$_SESSION['PMA_Theme_Manager']->setActiveTheme($_REQUEST['set_theme']);
}
 
$_SESSION['PMA_Theme'] = $_SESSION['PMA_Theme_Manager']->theme;
 
// BC
$GLOBALS['theme'] = $_SESSION['PMA_Theme']->getName();
$GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath();
$GLOBALS['pmaThemeImage'] = $_SESSION['PMA_Theme']->getImgPath();
 
/**
* load layout file if exists
*/
if (@file_exists($_SESSION['PMA_Theme']->getLayoutFile())) {
include $_SESSION['PMA_Theme']->getLayoutFile();
}
 
if (!defined('PMA_MINIMUM_COMMON')) {
/**
* Charset conversion.
*/
require_once './libraries/charset_conversion.lib.php';
 
/**
* String handling
*/
require_once './libraries/string.lib.php';
 
/**
* @var array database list
*/
$dblist = array();
 
/**
* If no server is selected, make sure that $cfg['Server'] is empty (so
* that nothing will work), and skip server authentication.
* We do NOT exit here, but continue on without logging into any server.
* This way, the welcome page will still come up (with no server info) and
* present a choice of servers in the case that there are multiple servers
* and '$cfg['ServerDefault'] = 0' is set.
*/
if (!empty($_REQUEST['server']) && !empty($cfg['Servers'][$_REQUEST['server']])) {
$GLOBALS['server'] = $_REQUEST['server'];
$cfg['Server'] = $cfg['Servers'][$GLOBALS['server']];
} else {
if (!empty($cfg['Servers'][$cfg['ServerDefault']])) {
$GLOBALS['server'] = $cfg['ServerDefault'];
$cfg['Server'] = $cfg['Servers'][$GLOBALS['server']];
} else {
$GLOBALS['server'] = 0;
$cfg['Server'] = array();
}
}
$GLOBALS['url_params']['server'] = $GLOBALS['server'];
 
 
if (!empty($cfg['Server'])) {
 
/**
* Loads the proper database interface for this server
*/
require_once './libraries/database_interface.lib.php';
 
// Gets the authentication library that fits the $cfg['Server'] settings
// and run authentication
 
// (for a quick check of path disclosure in auth/cookies:)
$coming_from_common = true;
 
if (!file_exists('./libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php')) {
header('Location: error.php'
. '?lang=' . urlencode($available_languages[$lang][2])
. '&char=' . urlencode($charset)
. '&dir=' . urlencode($text_dir)
. '&type=' . urlencode($strError)
. '&error=' . urlencode(
$strInvalidAuthMethod . ' '
. $cfg['Server']['auth_type'])
. '&' . SID
);
exit();
}
require_once './libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php';
if (!PMA_auth_check()) {
PMA_auth();
} else {
PMA_auth_set_user();
}
 
// Check IP-based Allow/Deny rules as soon as possible to reject the
// user
// Based on mod_access in Apache:
// http://cvs.apache.org/viewcvs.cgi/httpd-2.0/modules/aaa/mod_access.c?rev=1.37&content-type=text/vnd.viewcvs-markup
// Look at: "static int check_dir_access(request_rec *r)"
// Robbat2 - May 10, 2002
if (isset($cfg['Server']['AllowDeny'])
&& isset($cfg['Server']['AllowDeny']['order'])) {
 
require_once './libraries/ip_allow_deny.lib.php';
 
$allowDeny_forbidden = false; // default
if ($cfg['Server']['AllowDeny']['order'] == 'allow,deny') {
$allowDeny_forbidden = true;
if (PMA_allowDeny('allow')) {
$allowDeny_forbidden = false;
}
if (PMA_allowDeny('deny')) {
$allowDeny_forbidden = true;
}
} elseif ($cfg['Server']['AllowDeny']['order'] == 'deny,allow') {
if (PMA_allowDeny('deny')) {
$allowDeny_forbidden = true;
}
if (PMA_allowDeny('allow')) {
$allowDeny_forbidden = false;
}
} elseif ($cfg['Server']['AllowDeny']['order'] == 'explicit') {
if (PMA_allowDeny('allow')
&& !PMA_allowDeny('deny')) {
$allowDeny_forbidden = false;
} else {
$allowDeny_forbidden = true;
}
} // end if ... elseif ... elseif
 
// Ejects the user if banished
if ($allowDeny_forbidden) {
PMA_auth_fails();
}
unset($allowDeny_forbidden); //Clean up after you!
} // end if
 
// is root allowed?
if (!$cfg['Server']['AllowRoot'] && $cfg['Server']['user'] == 'root') {
$allowDeny_forbidden = true;
PMA_auth_fails();
unset($allowDeny_forbidden); //Clean up after you!
}
 
// The user can work with only some databases
if (isset($cfg['Server']['only_db']) && $cfg['Server']['only_db'] != '') {
if (is_array($cfg['Server']['only_db'])) {
$dblist = $cfg['Server']['only_db'];
} else {
$dblist[] = $cfg['Server']['only_db'];
}
} // end if
 
$bkp_track_err = @ini_set('track_errors', 1);
 
// Try to connect MySQL with the control user profile (will be used to
// get the privileges list for the current user but the true user link
// must be open after this one so it would be default one for all the
// scripts)
if ($cfg['Server']['controluser'] != '') {
$controllink = PMA_DBI_connect($cfg['Server']['controluser'],
$cfg['Server']['controlpass'], true);
} else {
$controllink = PMA_DBI_connect($cfg['Server']['user'],
$cfg['Server']['password'], true);
} // end if ... else
 
// Pass #1 of DB-Config to read in master level DB-Config will go here
// Robbat2 - May 11, 2002
 
// Connects to the server (validates user's login)
$userlink = PMA_DBI_connect($cfg['Server']['user'],
$cfg['Server']['password'], false);
 
// Pass #2 of DB-Config to read in user level DB-Config will go here
// Robbat2 - May 11, 2002
 
@ini_set('track_errors', $bkp_track_err);
unset($bkp_track_err);
 
/**
* SQL Parser code
*/
require_once './libraries/sqlparser.lib.php';
 
/**
* SQL Validator interface code
*/
require_once './libraries/sqlvalidator.lib.php';
 
// if 'only_db' is set for the current user, there is no need to check for
// available databases in the "mysql" db
$dblist_cnt = count($dblist);
if ($dblist_cnt) {
$true_dblist = array();
$is_show_dbs = true;
 
$dblist_asterisk_bool = false;
for ($i = 0; $i < $dblist_cnt; $i++) {
 
// The current position
if ($dblist[$i] == '*' && $dblist_asterisk_bool == false) {
$dblist_asterisk_bool = true;
$dblist_full = PMA_safe_db_list(false, $controllink, false,
$userlink, $cfg, $dblist);
foreach ($dblist_full as $dbl_val) {
if (!in_array($dbl_val, $dblist)) {
$true_dblist[] = $dbl_val;
}
}
 
continue;
} elseif ($dblist[$i] == '*') {
// We don't want more than one asterisk inside our 'only_db'.
continue;
}
if ($is_show_dbs && preg_match('/(^|[^\\\\])(_|%)/', $dblist[$i])) {
$local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\'';
// here, a PMA_DBI_query() could fail silently
// if SHOW DATABASES is disabled
$rs = PMA_DBI_try_query($local_query, $userlink);
 
if ($i == 0 && ! $rs) {
$error_code = substr(PMA_DBI_getError($userlink), 1, 4);
if ($error_code == 1227 || $error_code == 1045) {
// "SHOW DATABASES" statement is disabled or not allowed to user
$true_dblist[] = str_replace('\\_', '_', str_replace('\\%', '%', $dblist[$i]));
$is_show_dbs = false;
}
unset($error_code);
}
// Debug
// elseif (PMA_DBI_getError($controllink)) {
// PMA_mysqlDie(PMA_DBI_getError($controllink), $local_query, false);
// }
while ($row = @PMA_DBI_fetch_row($rs)) {
$true_dblist[] = $row[0];
} // end while
if ($rs) {
PMA_DBI_free_result($rs);
}
} else {
$true_dblist[] = str_replace('\\_', '_',
str_replace('\\%', '%', $dblist[$i]));
} // end if... else...
} // end for
$dblist = $true_dblist;
unset($true_dblist, $i, $dbl_val);
$only_db_check = true;
} // end if
 
// 'only_db' is empty for the current user...
else {
$only_db_check = false;
} // end if (!$dblist_cnt)
 
if (isset($dblist_full) && !count($dblist_full)) {
$dblist = PMA_safe_db_list($only_db_check, $controllink,
$dblist_cnt, $userlink, $cfg, $dblist);
}
unset($only_db_check, $dblist_full);
 
} // end server connecting
 
 
// Kanji encoding convert feature appended by Y.Kawada (2002/2/20)
if (@function_exists('mb_convert_encoding')
&& strpos(' ' . $lang, 'ja-')
&& file_exists('./libraries/kanji-encoding.lib.php')) {
require_once './libraries/kanji-encoding.lib.php';
define('PMA_MULTIBYTE_ENCODING', 1);
} // end if
 
/**
* save some settings in cookies
*/
PMA_setCookie('pma_lang', $GLOBALS['lang']);
PMA_setCookie('pma_charset', $GLOBALS['convcharset']);
PMA_setCookie('pma_collation_connection', $GLOBALS['collation_connection']);
 
$_SESSION['PMA_Theme_Manager']->setThemeCookie();
 
} // end if !defined('PMA_MINIMUM_COMMON')
 
if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) {
// to handle bug #1388167
if (isset($_GET['is_js_confirmed'])) {
$is_js_confirmed = 1;
}
require $__redirect;
exit();
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/config.default.php
0,0 → 1,822
<?php
 
/* !!! DO NOT EDIT THIS FILE, EDIT config.inc.php INSTEAD !!! */
 
/* $Id: config.default.php,v 1.8 2005/12/16 14:07:10 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* phpMyAdmin default configuration, you can copy values from here to your
* config.inc.php
*
* All directives are explained in Documentation.html
*/
 
 
/**
* Your phpMyAdmin URL.
*
* Complete the variable below with the full url ie
* http://www.your_web.net/path_to_your_phpMyAdmin_directory/
*
* It must contain characters that are valid for a URL, and the path is
* case sensitive on some Web servers, for example Unix-based servers.
*
* In most cases you can leave this variable empty, as the correct value
* will be detected automatically. However, we recommend that you do
* test to see that the auto-detection code works in your system. A good
* test is to browse a table, then edit a row and save it. There will be
* an error message if phpMyAdmin cannot auto-detect the correct value.
*/
$cfg['PmaAbsoluteUri'] = '';
 
/**
* Disable the default warning that is displayed on the DB Details Structure page if
* any of the required Tables for the relationfeatures could not be found
*/
$cfg['PmaNoRelation_DisableWarning'] = FALSE;
 
/**
* The 'cookie' auth_type uses blowfish algorithm to encrypt the password. If
* at least one server configuration uses 'cookie' auth_type, enter here a
* passphrase that will be used by blowfish. The maximum length seems to be 46
* characters.
*/
$cfg['blowfish_secret'] = '';
 
/**
* Server(s) configuration
*/
$i = 0;
// The $cfg['Servers'] array starts with $cfg['Servers'][1]. Do not use
// $cfg['Servers'][0]. You can disable a server config entry by setting host
// to ''. If you want more than one server, just copy following section
// (including $i incrementation) serveral times. There is no need to define
// full server array, just define values you need to change.
$i++;
$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname or IP address
$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port
$cfg['Servers'][$i]['socket'] = ''; // Path to the socket - leave blank for default socket
$cfg['Servers'][$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')
$cfg['Servers'][$i]['extension'] = 'mysql'; // The php MySQL extension to use ('mysql' or 'mysqli')
$cfg['Servers'][$i]['compress'] = FALSE; // Use compressed protocol for the MySQL connection
// (requires PHP >= 4.3.0)
$cfg['Servers'][$i]['controluser'] = ''; // MySQL control user settings
// (this user must have read-only
$cfg['Servers'][$i]['controlpass'] = ''; // access to the "mysql/user"
// and "mysql/db" tables).
// The controluser is also
// used for all relational
// features (pmadb)
$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed
// with 'config' auth_type)
$cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only
// this db is displayed in left frame
// It may also be an array of db-names, where sorting order is relevant.
$cfg['Servers'][$i]['hide_db'] = ''; // Database name to be hidden from listings
$cfg['Servers'][$i]['verbose'] = ''; // Verbose name for this host - leave blank to show the hostname
 
$cfg['Servers'][$i]['pmadb'] = ''; // Database used for Relation, Bookmark and PDF Features
// (see scripts/create_tables.sql)
// - leave blank for no support
// DEFAULT: 'phpmyadmin'
$cfg['Servers'][$i]['bookmarktable'] = ''; // Bookmark table
// - leave blank for no bookmark support
// DEFAULT: 'pma_bookmark'
$cfg['Servers'][$i]['relation'] = ''; // table to describe the relation between links (see doc)
// - leave blank for no relation-links support
// DEFAULT: 'pma_relation'
$cfg['Servers'][$i]['table_info'] = ''; // table to describe the display fields
// - leave blank for no display fields support
// DEFAULT: 'pma_table_info'
$cfg['Servers'][$i]['table_coords'] = ''; // table to describe the tables position for the PDF schema
// - leave blank for no PDF schema support
// DEFAULT: 'pma_table_coords'
$cfg['Servers'][$i]['pdf_pages'] = ''; // table to describe pages of relationpdf
// - leave blank if you don't want to use this
// DEFAULT: 'pma_pdf_pages'
$cfg['Servers'][$i]['column_info'] = ''; // table to store column information
// - leave blank for no column comments/mime types
// DEFAULT: 'pma_column_info'
$cfg['Servers'][$i]['history'] = ''; // table to store SQL history
// - leave blank for no SQL query history
// DEFAULT: 'pma_history'
$cfg['Servers'][$i]['verbose_check'] = TRUE; // set to FALSE if you know that your pma_* tables
// are up to date. This prevents compatibility
// checks and thereby increases performance.
$cfg['Servers'][$i]['AllowRoot'] = TRUE; // whether to allow root login
$cfg['Servers'][$i]['AllowDeny']['order'] // Host authentication order, leave blank to not use
= '';
$cfg['Servers'][$i]['AllowDeny']['rules'] // Host authentication rules, leave blank for defaults
= array();
 
// If you have more than one server configured, you can set $cfg['ServerDefault']
// to any one of them to autoconnect to that server when phpMyAdmin is started,
// or set it to 0 to be given a list of servers without logging in
// If you have only one server configured, $cfg['ServerDefault'] *MUST* be
// set to that server.
$cfg['ServerDefault'] = 1; // Default server (0 = no default server)
 
/**
* Other core phpMyAdmin settings
*/
$cfg['OBGzip'] = 'auto'; // use GZIP output buffering if possible (TRUE|FALSE|'auto')
$cfg['PersistentConnections'] = FALSE; // use persistent connections to MySQL database
$cfg['ForceSSL'] = FALSE; // whether to force using https
$cfg['ExecTimeLimit'] = 300; // maximum execution time in seconds (0 for no limit)
$cfg['MemoryLimit'] = 0; // maximum allocated bytes (0 for no limit)
$cfg['SkipLockedTables'] = FALSE; // mark used tables, make possible to show
// locked tables (since MySQL 3.23.30)
$cfg['ShowSQL'] = TRUE; // show SQL queries as run
$cfg['AllowUserDropDatabase'] = FALSE; // show a 'Drop database' link to normal users
$cfg['Confirm'] = TRUE; // confirm 'DROP TABLE' & 'DROP DATABASE'
$cfg['LoginCookieRecall'] = TRUE; // recall previous login in cookie auth. mode or not
$cfg['LoginCookieValidity'] = 1800; // validity of cookie login (in seconds)
$cfg['UseDbSearch'] = TRUE; // whether to enable the "database search" feature
// or not
$cfg['IgnoreMultiSubmitErrors'] = FALSE; // if set to true, PMA continues computing multiple-statement queries
// even if one of the queries failed
$cfg['VerboseMultiSubmit'] = TRUE; // if set to true, PMA will show the affected rows of EACH statement on
// multiple-statement queries. See the libraries/import.php file for
// hardcoded defaults on how many queries a statement may contain!
$cfg['AllowArbitraryServer'] = FALSE; // allow login to any user entered server in cookie based auth
 
// Left frame setup
$cfg['LeftFrameLight'] = TRUE; // use a select-based menu and display only the
// current tables in the left frame.
$cfg['LeftFrameDBTree'] = TRUE; // turn the select-based light menu into a tree
$cfg['LeftFrameDBSeparator'] = '_'; // the separator to sub-tree the select-based light menu tree
$cfg['LeftFrameTableSeparator']= '__'; // Which string will be used to generate table prefixes
// to split/nest tables into multiple categories
$cfg['LeftFrameTableLevel'] = '1'; // How many sublevels should be displayed when splitting
// up tables by the above Separator
$cfg['ShowTooltip'] = TRUE; // display table comment as tooltip in left frame
$cfg['ShowTooltipAliasDB'] = FALSE; // if ShowToolTip is enabled, this defines that table/db comments
$cfg['ShowTooltipAliasTB'] = FALSE; // are shown (in the left menu and db_details_structure) instead of
// table/db names. Setting ShowTooltipAliasTB to 'nested' will only
// use the Aliases for nested descriptors, not the table itself.
 
$cfg['LeftDisplayLogo'] = TRUE; // display logo at top of left frame
$cfg['LeftDisplayServers'] = FALSE; // display server choice at top of left frame
$cfg['DisplayServersList'] = FALSE; // server choice as links
 
// In the main frame, at startup...
$cfg['ShowStats'] = TRUE; // allow to display statistics and space usage in
// the pages about database details and table
// properties
$cfg['ShowPhpInfo'] = FALSE; // information" and "change password" links for
$cfg['ShowChgPassword'] = FALSE; // simple users or not
$cfg['SuggestDBName'] = TRUE; // suggest a new DB name if possible (false = keep empty)
 
// In browse mode...
$cfg['ShowBlob'] = FALSE; // display blob field contents
$cfg['NavigationBarIconic'] = 'both'; // Use icons instead of text for the navigation bar buttons
// and on right panel top menu (server db table) (TRUE|FALSE|'both')
$cfg['ShowAll'] = FALSE; // allows to display all the rows
$cfg['MaxRows'] = 30; // maximum number of rows to display
$cfg['Order'] = 'ASC'; // default for 'ORDER BY' clause (valid
// values are 'ASC', 'DESC' or 'SMART' -ie
// descending order for fields of type
// TIME, DATE, DATETIME & TIMESTAMP,
// ascending order else-)
 
// In edit mode...
$cfg['ProtectBinary'] = 'blob'; // disallow editing of binary fields
// valid values are:
// FALSE allow editing
// 'blob' allow editing except for BLOB fields
// 'all' disallow editing
$cfg['ShowFunctionFields'] = TRUE; // Display the function fields in edit/insert mode
$cfg['CharEditing'] = 'input';
// Which editor should be used for CHAR/VARCHAR fields:
// input - allows limiting of input length
// textarea - allows newlines in fields
$cfg['InsertRows'] = 2; // How many rows can be inserted at one time
 
$cfg['ForeignKeyDropdownOrder'] = // Sort order for items in a foreign-key dropdown box.
array( 'content-id', 'id-content'); // 'content' is the referenced data, 'id' is the key value.
$cfg['ForeignKeyMaxLimit'] = 100; // A dropdown will be used if fewer items are present
 
 
// For the export features...
$cfg['ZipDump'] = TRUE; // Allow the use of zip/gzip/bzip
$cfg['GZipDump'] = TRUE; // compression for
$cfg['BZipDump'] = TRUE; // dump files
$cfg['CompressOnFly'] = TRUE; // Will compress gzip/bzip2 exports on
// fly without need for much memory.
// If you encounter problems with
// created gzip/bzip2 files disable
// this feature.
 
// Tabs display settings
$cfg['LightTabs'] = FALSE; // use graphically less intense menu tabs
$cfg['PropertiesIconic'] = TRUE; // Use icons instead of text for the table display of a database (TRUE|FALSE|'both')
$cfg['PropertiesNumColumns'] = 1; // How many columns should be used for table display of a database?
// (a value larger than 1 results in some information being hidden)
 
$cfg['DefaultTabServer'] = 'main.php';
// Possible values:
// 'main.php' = the welcome page
// (recommended for multiuser setups)
// 'server_databases.php' = list of databases
// 'server_status.php' = runtime information
// 'server_variables.php' = MySQL server variables
// 'server_privileges.php' = user management
// 'server_processlist.php' = process list
$cfg['DefaultTabDatabase'] = 'db_details_structure.php';
// Possible values:
// 'db_details_structure.php' = tables list
// 'db_details.php' = sql form
// 'db_search.php' = search query
// 'db_operations.php' = operations on database
$cfg['DefaultTabTable'] = 'tbl_properties_structure.php';
// Possible values:
// 'tbl_properties_structure.php' = fields list
// 'tbl_properties.php' = sql form
// 'tbl_select.php' = select page
// 'tbl_change.php' = insert row page
// 'sql.php' = browse page
 
/**
* Export defaults
*/
 
$cfg['Export']['format'] = 'sql'; // sql/latex/excel/csv/xml/xls/htmlexcel/htmlword
$cfg['Export']['compression'] = 'none'; // none/zip/gzip/bzip2
 
$cfg['Export']['asfile'] = FALSE;
$cfg['Export']['charset'] = '';
$cfg['Export']['onserver'] = FALSE;
$cfg['Export']['onserver_overwrite'] = FALSE;
$cfg['Export']['remember_file_template'] = TRUE;
$cfg['Export']['file_template_table'] = '__TABLE__';
$cfg['Export']['file_template_database'] = '__DB__';
$cfg['Export']['file_template_server'] = '__SERVER__';
 
$cfg['Export']['htmlexcel_columns'] = FALSE;
$cfg['Export']['htmlexcel_null'] = 'NULL';
 
$cfg['Export']['htmlword_structure'] = TRUE;
$cfg['Export']['htmlword_data'] = TRUE;
$cfg['Export']['htmlword_columns'] = FALSE;
$cfg['Export']['htmlword_null'] = 'NULL';
 
$cfg['Export']['xls_columns'] = FALSE;
$cfg['Export']['xls_null'] = 'NULL';
 
$cfg['Export']['csv_columns'] = FALSE;
$cfg['Export']['csv_null'] = 'NULL';
$cfg['Export']['csv_separator'] = ';';
$cfg['Export']['csv_enclosed'] = '&quot;';
$cfg['Export']['csv_escaped'] = '\\';
$cfg['Export']['csv_terminated'] = 'AUTO';
$cfg['Export']['excel_columns'] = FALSE;
$cfg['Export']['excel_null'] = 'NULL';
$cfg['Export']['excel_edition'] = 'win'; // win/mac
 
$cfg['Export']['latex_structure'] = TRUE;
$cfg['Export']['latex_data'] = TRUE;
$cfg['Export']['latex_columns'] = TRUE;
$cfg['Export']['latex_relation'] = TRUE;
$cfg['Export']['latex_comments'] = TRUE;
$cfg['Export']['latex_mime'] = TRUE;
$cfg['Export']['latex_null'] = '\textit{NULL}';
$cfg['Export']['latex_caption'] = TRUE;
$cfg['Export']['latex_data_label'] = 'tab:__TABLE__-data';
$cfg['Export']['latex_structure_label'] = 'tab:__TABLE__-structure';
 
$cfg['Export']['sql_structure'] = TRUE;
$cfg['Export']['sql_data'] = TRUE;
$cfg['Export']['sql_compat'] = 'NONE';
$cfg['Export']['sql_disable_fk'] = FALSE;
$cfg['Export']['sql_use_transaction'] = FALSE;
$cfg['Export']['sql_drop_database'] = FALSE;
$cfg['Export']['sql_drop_table'] = FALSE;
$cfg['Export']['sql_if_not_exists'] = FALSE;
$cfg['Export']['sql_auto_increment'] = TRUE;
$cfg['Export']['sql_backquotes'] = TRUE;
$cfg['Export']['sql_dates'] = FALSE;
$cfg['Export']['sql_relation'] = FALSE;
$cfg['Export']['sql_columns'] = TRUE;
$cfg['Export']['sql_delayed'] = FALSE;
$cfg['Export']['sql_ignore'] = FALSE;
$cfg['Export']['sql_hex_for_binary'] = TRUE;
$cfg['Export']['sql_type'] = 'insert'; // insert/update/replace
$cfg['Export']['sql_extended'] = TRUE;
$cfg['Export']['sql_max_query_size'] = 50000;
$cfg['Export']['sql_comments'] = FALSE;
$cfg['Export']['sql_mime'] = FALSE;
$cfg['Export']['sql_header_comment'] = ''; // \n is replaced by new line
 
$cfg['Export']['pdf_structure'] = FALSE;
$cfg['Export']['pdf_data'] = TRUE;
$cfg['Export']['pdf_report_title'] = '';
 
/**
* Import defaults
*/
$cfg['Import']['format'] = 'sql';
$cfg['Import']['allow_interrupt'] = TRUE;
$cfg['Import']['skip_queries'] = '0';
$cfg['Import']['csv_replace'] = FALSE;
$cfg['Import']['csv_terminated'] = ';';
$cfg['Import']['csv_enclosed'] = '"';
$cfg['Import']['csv_escaped'] = '\\';
$cfg['Import']['csv_new_line'] = 'auto';
$cfg['Import']['csv_columns'] = '';
$cfg['Import']['ldi_replace'] = FALSE;
$cfg['Import']['ldi_terminated'] = ';';
$cfg['Import']['ldi_enclosed'] = '"';
$cfg['Import']['ldi_escaped'] = '\\';
$cfg['Import']['ldi_new_line'] = 'auto';
$cfg['Import']['ldi_columns'] = '';
$cfg['Import']['ldi_local_option'] = 'auto'; // 'auto' for autodetection, TRUE or FALSE for forcing
 
 
/**
* Link to the official MySQL documentation.
* Be sure to include no trailing slash on the path.
* See http://dev.mysql.com/doc/ for more information
* about MySQL manuals and their types.
*/
$cfg['MySQLManualBase'] = 'http://dev.mysql.com/doc/refman';
 
/**
* Type of MySQL documentation:
* viewable - "viewable online", current one used on MySQL website
* searchable - "Searchable, with user comments"
* chapters - "HTML, one page per chapter"
* chapters_old - "HTML, one page per chapter", format used prior to MySQL 5.0 release
* big - "HTML, all on one page"
* old - old style used in phpMyAdmin 2.3.0 and sooner
* none - do not show documentation links
*/
$cfg['MySQLManualType'] = 'viewable';
 
 
/**
* PDF options
*/
$cfg['PDFPageSizes'] = array('A3', 'A4', 'A5', 'letter', 'legal');
$cfg['PDFDefaultPageSize'] = 'A4';
 
 
/**
* Language and charset conversion settings
*/
// Default language to use, if not browser-defined or user-defined
$cfg['DefaultLang'] = 'en-iso-8859-1';
 
// Default connection collation (used for MySQL >= 4.1)
$cfg['DefaultConnectionCollation'] = 'utf8_unicode_ci';
 
// Force: always use this language - must be defined in
// libraries/select_lang.lib.php
// $cfg['Lang'] = 'en-iso-8859-1';
 
// Regullar expression to limit listed languages, eg. '^(cs|en)' for Czech and
// English only
$cfg['FilterLanguages'] = '';
 
// Default charset to use for recoding of MySQL queries, does not take
// any effect when charsets recoding is switched off by
// $cfg['AllowAnywhereRecoding'] or in language file
// (see $cfg['AvailableCharsets'] to possible choices, you can add your own)
$cfg['DefaultCharset'] = 'iso-8859-1';
 
// Allow charset recoding of MySQL queries, must be also enabled in language
// file to make harder using other language files than unicode.
// Default value is FALSE to avoid problems on servers without the iconv
// extension and where dl() is not supported
$cfg['AllowAnywhereRecoding'] = FALSE;
 
// You can select here which functions will be used for charset conversion.
// Possible values are:
// auto - automatically use available one (first is tested iconv, then
// recode)
// iconv - use iconv or libiconv functions
// recode - use recode_string function
$cfg['RecodingEngine'] = 'auto';
 
// Specify some parameters for iconv used in charset conversion. See iconv
// documentation for details:
// http://www.gnu.org/software/libiconv/documentation/libiconv/iconv_open.3.html
$cfg['IconvExtraParams'] = '//TRANSLIT';
 
// Available charsets for MySQL conversion. currently contains all which could
// be found in lang/* files and few more.
// Charsets will be shown in same order as here listed, so if you frequently
// use some of these move them to the top.
$cfg['AvailableCharsets'] = array(
'iso-8859-1',
'iso-8859-2',
'iso-8859-3',
'iso-8859-4',
'iso-8859-5',
'iso-8859-6',
'iso-8859-7',
'iso-8859-8',
'iso-8859-9',
'iso-8859-10',
'iso-8859-11',
'iso-8859-12',
'iso-8859-13',
'iso-8859-14',
'iso-8859-15',
'windows-1250',
'windows-1251',
'windows-1252',
'windows-1256',
'windows-1257',
'koi8-r',
'big5',
'gb2312',
'utf-16',
'utf-8',
'utf-7',
'x-user-defined',
'euc-jp',
'ks_c_5601-1987',
'tis-620',
'SHIFT_JIS'
);
 
/**
* Customization & design
*
* The graphical settings are now located in themes/themename/layout.inc.php
*/
 
$cfg['LeftPointerEnable'] = TRUE; // enable the left panel pointer
// (used when LeftFrameLight is FALSE)
// see also LeftPointerColor
// in layout.inc.php
 
$cfg['BrowsePointerEnable'] = TRUE; // enable the browse pointer
// see also BrowsePointerColor
// in layout.inc.php
 
$cfg['BrowseMarkerEnable'] = TRUE; // enable the browse marker
// see also BrowseMarkerColor
// in layout.inc.php
 
$cfg['TextareaCols'] = 40; // textarea size (columns) in edit mode
// (this value will be emphasized (*2) for sql
// query textareas and (*1.25) for query window)
$cfg['TextareaRows'] = 7; // textarea size (rows) in edit mode
$cfg['LongtextDoubleTextarea'] = TRUE; // double size of textarea size for longtext fields
$cfg['TextareaAutoSelect'] = TRUE; // autoselect when clicking in the textarea of the querybox
$cfg['CharTextareaCols'] = 40; // textarea size (columns) for CHAR/VARCHAR
$cfg['CharTextareaRows'] = 2; // textarea size (rows) for CHAR/VARCHAR
$cfg['CtrlArrowsMoving'] = TRUE; // Enable Ctrl+Arrows moving between fields when editing?
$cfg['LimitChars'] = 50; // Max field data length in browse mode for all non-numeric fields
$cfg['ModifyDeleteAtLeft'] = TRUE; // show edit/delete links on left side of browse
// (or at the top with vertical browse)
$cfg['ModifyDeleteAtRight'] = FALSE; // show edit/delete links on right side of browse
// (or at the bottom with vertical browse)
$cfg['DefaultDisplay'] = 'horizontal'; // default display direction
// (horizontal|vertical|horizontalflipped)
$cfg['DefaultPropDisplay'] = 'horizontal'; // default display direction for altering/
// creating columns (tbl_properties)
// (horizontal|vertical)
 
$cfg['HeaderFlipType'] = 'css'; // table-header rotation via faking or css? (css|fake)
// NOTE: CSS only works in IE browsers!
$cfg['ShowBrowseComments'] = TRUE; // shows stored relation-comments in 'browse' mode.
$cfg['ShowPropertyComments']= TRUE; // shows stored relation-comments in 'table property' mode.
$cfg['RepeatCells'] = 100; // repeat header names every X cells? (0 = deactivate)
 
$cfg['EditInWindow'] = TRUE; // Set to TRUE if Edit link should open the query to edit in the query window (assuming Javascript is enabled), and to FALSE if we should edit in the right panel
$cfg['QueryWindowWidth'] = 550; // Width of Query window
$cfg['QueryWindowHeight'] = 310; // Height of Query window
$cfg['QueryHistoryDB'] = FALSE; // Set to TRUE if you want DB-based query history.
// If FALSE, this utilizes JS-routines to display
// query history (lost by window close)
$cfg['QueryWindowDefTab'] = 'sql'; // which tab to display in the querywindow on startup
// (sql|files|history|full)
$cfg['QueryHistoryMax'] = 25; // When using DB-based query history, how many entries
// should be kept?
$cfg['BrowseMIME'] = TRUE; // Use MIME-Types (stored in column comments table) for
$cfg['MaxExactCount'] = 20000; // When approximate count < this, PMA will get exact count for
// table rows.
$cfg['WYSIWYG-PDF'] = TRUE; // Utilize DHTML/JS capabilities to allow WYSIWYG editing of
// the PDF page editor. Requires an IE6/Mozilla based browser.
 
$cfg['NaturalOrder'] = TRUE; // Sort table and database in natural order
 
 
//-----------------------------------------------------------------------------
// custom-setup by mkkeck: 2004-05-04
// some specials for new icons and scrollings
// FIXME:
// 2004-05-08 rabus: We need to rearrange these variables.
 
$cfg['ShowHttpHostTitle'] = TRUE; // show HttpHost in browsers window title (true|false)?
$cfg['SetHttpHostTitle'] = ''; // if ShowHttpHostTitle=true, please set your host (server)
// or an other string, wich should be shown in browsers window title.
// If not set (or empty), the PMA will get your real Host-Adress.
 
$cfg['ErrorIconic'] = TRUE; // show some icons for warning, error and information messages (true|false)?
$cfg['MainPageIconic'] = TRUE; // show icons in list on main page and on menu tabs (true|false)?
$cfg['ReplaceHelpImg'] = TRUE; // show help button instead of strDocu (true|false)?
 
// theme manager
$cfg['ThemePath'] = './themes'; // using themes manager please set up here the path to 'themes'
// else leave empty
$cfg['ThemeManager'] = TRUE; // if you want to use selectable themes and if ThemesPath not empty
// set it to true, else set it to false (default is false);
$cfg['ThemeDefault'] = 'original'; // set up default theme, if ThemePath not empty
// you can set up here an valid path to themes or 'original' for
// the original pma-theme
$cfg['ThemePerServer'] = FALSE; // allow diferent theme for each configured server
 
//-----------------------------------------------------------------------------
 
 
/**
* Default queries
* %d will be replaced by the database name.
* %t will be replaced by the table name.
* %f will be replaced by a list of field names.
* (%t and %f only applies to DefaultQueryTable)
*/
$cfg['DefaultQueryTable'] = 'SELECT * FROM %t WHERE 1';
$cfg['DefaultQueryDatabase'] = '';
 
/**
* SQL Query box settings
* These are the links display in all of the SQL Query boxes
*/
$cfg['SQLQuery']['Edit'] = TRUE; // Edit link to change a query
$cfg['SQLQuery']['Explain'] = TRUE; // EXPLAIN on SELECT queries
$cfg['SQLQuery']['ShowAsPHP'] = TRUE; // Wrap a query in PHP
$cfg['SQLQuery']['Validate'] = FALSE; // Validate a query (see $cfg['SQLValidator'] as well)
$cfg['SQLQuery']['Refresh'] = TRUE; // Refresh the results page
 
 
/**
* Webserver upload/save/import directories
*/
$cfg['UploadDir'] = ''; // Directory for uploaded files that can be executed by
// phpMyAdmin. For example './upload'. Leave empty for
// no upload directory support. Use %u for username
// inclusion.
$cfg['SaveDir'] = ''; // Directory where phpMyAdmin can save exported data on
// server. For example './save'. Leave empty for no save
// directory support. Use %u for username inclusion.
$cfg['docSQLDir'] = ''; // Directory for docSQL imports, phpMyAdmin can import
// docSQL files from that directory. For example
// './docSQL'. Leave empty for no docSQL import support.
$cfg['TempDir'] = ''; // Directory where phpMyAdmin can save temporary files.
// This is needed for MS Excel export, see documentation
// how to enable that.
 
 
/**
* Misc. settings
*/
$cfg['GD2Available'] = 'auto'; // Is GD >= 2 available? Set to yes/no/auto. 'auto'
// does autodetection, which is a bit expensive for
// php < 4.3.0, but it is the only safe vay how to
// determine GD version.
/**
* SQL Parser Settings
*/
$cfg['SQP']['fmtType'] = 'html'; // Pretty-printing style to use on queries (html, text, none)
$cfg['SQP']['fmtInd'] = '1'; // Amount to indent each level (floats ok)
$cfg['SQP']['fmtIndUnit'] = 'em'; // Units for indenting each level (CSS Types - {em,px,pt})
// The graphical settings are now located in themes/themename/layout.inc.php
 
/**
* If you wish to use the SQL Validator service, you should be
* aware of the following:
* All SQL statements are stored anonymously for statistical purposes.
* Mimer SQL Validator, Copyright 2002 Upright Database Technology.
* All rights reserved.
*/
$cfg['SQLValidator']['use'] = FALSE; // Make the SQL Validator available
$cfg['SQLValidator']['username'] = ''; // If you have a custom username, specify it here (defaults to anonymous)
$cfg['SQLValidator']['password'] = ''; // Password for username
 
/**
* Developers ONLY!
* To use the following, please install the DBG extension from http://dd.cron.ru/dbg/
*/
$cfg['DBG']['enable'] = FALSE; // Make the DBG stuff available
$cfg['DBG']['profile']['enable'] = FALSE; // Produce profiling results of PHP
$cfg['DBG']['profile']['threshold'] = 0.5; // Threshold of long running code to display
// Anything below the threshold is not displayed
 
 
/**
* MySQL settings
*/
// Column types;
// varchar, tinyint, text and date are listed first, based on estimated popularity
$cfg['ColumnTypes'] = array(
'VARCHAR',
'TINYINT',
'TEXT',
'DATE',
'SMALLINT',
'MEDIUMINT',
'INT',
'BIGINT',
'FLOAT',
'DOUBLE',
'DECIMAL',
'DATETIME',
'TIMESTAMP',
'TIME',
'YEAR',
'CHAR',
'TINYBLOB',
'TINYTEXT',
'BLOB',
'MEDIUMBLOB',
'MEDIUMTEXT',
'LONGBLOB',
'LONGTEXT',
'ENUM',
'SET',
'BOOL'
);
 
// Attributes
// Note: the "ON UPDATE CURRENT_TIMESTAMP" attribute is added dynamically
// for MySQL >= 4.1.2, in libraries/tbl_properties.inc.php
 
$cfg['AttributeTypes'] = array(
'',
'BINARY',
'UNSIGNED',
'UNSIGNED ZEROFILL'
);
 
// Available functions
if ($cfg['ShowFunctionFields']) {
$cfg['Functions'] = array(
'ASCII',
'CHAR',
'SOUNDEX',
'LCASE',
'UCASE',
'NOW',
'PASSWORD',
'OLD_PASSWORD',
'MD5',
'SHA1',
'ENCRYPT',
'COMPRESS',
'UNCOMPRESS',
'RAND',
'LAST_INSERT_ID',
'COUNT',
'AVG',
'SUM',
'CURDATE',
'CURTIME',
'FROM_DAYS',
'FROM_UNIXTIME',
'PERIOD_ADD',
'PERIOD_DIFF',
'TO_DAYS',
'UNIX_TIMESTAMP',
'USER',
'WEEKDAY',
'CONCAT'
);
 
// Which column types will be mapped to which Group?
$cfg['RestrictColumnTypes'] = array(
'VARCHAR' => 'FUNC_CHAR',
'TINYINT' => 'FUNC_NUMBER',
'TEXT' => 'FUNC_CHAR',
'DATE' => 'FUNC_DATE',
'SMALLINT' => 'FUNC_NUMBER',
'MEDIUMINT' => 'FUNC_NUMBER',
'INT' => 'FUNC_NUMBER',
'BIGINT' => 'FUNC_NUMBER',
'FLOAT' => 'FUNC_NUMBER',
'DOUBLE' => 'FUNC_NUMBER',
'DECIMAL' => 'FUNC_NUMBER',
'DATETIME' => 'FUNC_DATE',
'TIMESTAMP' => 'FUNC_DATE',
'TIME' => 'FUNC_DATE',
'YEAR' => 'FUNC_DATE',
'CHAR' => 'FUNC_CHAR',
'TINYBLOB' => 'FUNC_CHAR',
'TINYTEXT' => 'FUNC_CHAR',
'BLOB' => 'FUNC_CHAR',
'MEDIUMBLOB' => 'FUNC_CHAR',
'MEDIUMTEXT' => 'FUNC_CHAR',
'LONGBLOB' => 'FUNC_CHAR',
'LONGTEXT' => 'FUNC_CHAR',
'ENUM' => '',
'SET' => ''
);
 
// Map above defined groups to any function
$cfg['RestrictFunctions'] = array(
'FUNC_CHAR' => array(
'ASCII',
'CHAR',
'SOUNDEX',
'LCASE',
'UCASE',
'PASSWORD',
'OLD_PASSWORD',
'MD5',
'SHA1',
'ENCRYPT',
'COMPRESS',
'UNCOMPRESS',
'LAST_INSERT_ID',
'USER',
'CONCAT'
),
 
'FUNC_DATE' => array(
'NOW',
'CURDATE',
'CURTIME',
'FROM_DAYS',
'FROM_UNIXTIME',
'PERIOD_ADD',
'PERIOD_DIFF',
'TO_DAYS',
'UNIX_TIMESTAMP',
'WEEKDAY'
),
 
'FUNC_NUMBER' => array(
'ASCII',
'CHAR',
'MD5',
'SHA1',
'ENCRYPT',
'RAND',
'LAST_INSERT_ID',
'UNIX_TIMESTAMP',
'COUNT',
'AVG',
'SUM'
)
);
 
// Default functions for above defined groups
$cfg['DefaultFunctions'] = array(
'FUNC_CHAR' => '',
'FUNC_DATE' => '',
'FUNC_NUMBER' => '',
'first_timestamp' => 'NOW'
);
 
 
} // end if
 
// Search operators
$cfg['NumOperators'] = array(
'=',
'>',
'>=',
'<',
'<=',
'!=',
'LIKE',
'NOT LIKE'
);
 
$cfg['TextOperators'] = array(
'LIKE',
'LIKE %...%',
'NOT LIKE',
'=',
'!=',
'REGEXP',
'NOT REGEXP'
);
 
$cfg['EnumOperators'] = array(
'=',
'!='
);
 
$cfg['SetOperators'] = array(
'IN',
'NOT IN'
);
 
$cfg['NullOperators'] = array(
'IS NULL',
'IS NOT NULL'
);
 
$cfg['UnaryOperators'] = array(
'IS NULL' => 1,
'IS NOT NULL' => 1
);
 
?>
/Web/Maintenance/phpMyAdmin/libraries/database_interface.lib.php
0,0 → 1,1037
<?php
/* $Id: database_interface.lib.php,v 2.39.2.2 2006/03/08 17:54:29 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Common Option Constants For DBI Functions
*/
// PMA_DBI_try_query()
define('PMA_DBI_QUERY_STORE', 1); // Force STORE_RESULT method, ignored by classic MySQL.
define('PMA_DBI_QUERY_UNBUFFERED', 2); // Do not read whole query
// PMA_DBI_get_variable()
define('PMA_DBI_GETVAR_SESSION', 1);
define('PMA_DBI_GETVAR_GLOBAL', 2);
 
/**
* Loads the mysql extensions if it is not loaded yet
*
* @param string $extension mysql extension to load
*/
function PMA_DBI_checkAndLoadMysqlExtension( $extension = 'mysql' ) {
if ( ! function_exists( $extension . '_connect' ) ) {
PMA_dl( $extension );
// check whether mysql is available
if ( ! function_exists( $extension . '_connect' ) ) {
return false;
}
}
 
return true;
}
 
 
/**
* check for requested extension
*/
if ( ! PMA_DBI_checkAndLoadMysqlExtension( $GLOBALS['cfg']['Server']['extension'] ) ) {
 
// if it fails try alternative extension ...
// and display an error ...
 
// TODO 2.7.1: add different messages for alternativ extension
// and complete fail (no alternativ extension too)
$GLOBALS['PMA_errors'][] =
sprintf( PMA_sanitize( $GLOBALS['strCantLoad'] ),
$GLOBALS['cfg']['Server']['extension'] )
.' - <a href="./Documentation.html#faqmysql" target="documentation">'
.$GLOBALS['strDocu'] . '</a>';
 
if ( $GLOBALS['cfg']['Server']['extension'] === 'mysql' ) {
$alternativ_extension = 'mysqli';
} else {
$alternativ_extension = 'mysql';
}
 
if ( ! PMA_DBI_checkAndLoadMysqlExtension( $alternativ_extension ) ) {
// if alternativ fails too ...
header( 'Location: error.php'
. '?lang=' . urlencode( $available_languages[$lang][2] )
. '&char=' . urlencode( $charset )
. '&dir=' . urlencode( $text_dir )
. '&type=' . urlencode( $strError )
. '&error=' . urlencode(
sprintf( $GLOBALS['strCantLoad'],
$GLOBALS['cfg']['Server']['extension'] )
.' - [a@./Documentation.html#faqmysql@documentation]'
.$GLOBALS['strDocu'] . '[/a]' )
. '&' . SID
);
exit();
}
 
$GLOBALS['cfg']['Server']['extension'] = $alternativ_extension;
unset( $alternativ_extension );
}
 
/**
* Including The DBI Plugin
*/
require_once('./libraries/dbi/' . $GLOBALS['cfg']['Server']['extension'] . '.dbi.lib.php');
 
/**
* Common Functions
*/
function PMA_DBI_query($query, $link = null, $options = 0) {
$res = PMA_DBI_try_query($query, $link, $options)
or PMA_mysqlDie(PMA_DBI_getError($link), $query);
return $res;
}
 
/**
* converts charset of a mysql message, usally coming from mysql_error(),
* into PMA charset, usally UTF-8
* uses language to charset mapping from mysql/share/errmsg.txt
* and charset names to ISO charset from information_schema.CHARACTER_SETS
*
* @uses $GLOBALS['cfg']['IconvExtraParams']
* @uses $GLOBALS['charset'] as target charset
* @uses PMA_DBI_fetch_value() to get server_language
* @uses preg_match() to filter server_language
* @uses in_array()
* @uses function_exists() to check for a convert function
* @uses iconv() to convert message
* @uses libiconv() to convert message
* @uses recode_string() to convert message
* @uses mb_convert_encoding() to convert message
* @param string $message
* @return string $message
*/
function PMA_DBI_convert_message( $message ) {
// latin always last!
$encodings = array(
'japanese' => 'EUC-JP', //'ujis',
'japanese-sjis' => 'Shift-JIS', //'sjis',
'korean' => 'EUC-KR', //'euckr',
'russian' => 'KOI8-R', //'koi8r',
'ukrainian' => 'KOI8-U', //'koi8u',
'greek' => 'ISO-8859-7', //'greek',
'serbian' => 'CP1250', //'cp1250',
'estonian' => 'ISO-8859-13', //'latin7',
'slovak' => 'ISO-8859-2', //'latin2',
'czech' => 'ISO-8859-2', //'latin2',
'hungarian' => 'ISO-8859-2', //'latin2',
'polish' => 'ISO-8859-2', //'latin2',
'romanian' => 'ISO-8859-2', //'latin2',
'spanish' => 'CP1252', //'latin1',
'swedish' => 'CP1252', //'latin1',
'italian' => 'CP1252', //'latin1',
'norwegian-ny' => 'CP1252', //'latin1',
'norwegian' => 'CP1252', //'latin1',
'portuguese' => 'CP1252', //'latin1',
'danish' => 'CP1252', //'latin1',
'dutch' => 'CP1252', //'latin1',
'english' => 'CP1252', //'latin1',
'french' => 'CP1252', //'latin1',
'german' => 'CP1252', //'latin1',
);
 
if ( $server_language = PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE \'language\';', 0, 1 ) ) {
$found = array();
if ( preg_match( '&(?:\\\|\\/)([^\\\\\/]*)(?:\\\|\\/)$&i', $server_language, $found )) {
$server_language = $found[1];
}
}
 
if ( ! empty( $server_language ) && isset( $encodings[$server_language] ) ) {
if ( function_exists( 'iconv' ) ) {
$message = iconv( $encodings[$server_language],
$GLOBALS['charset'] . $GLOBALS['cfg']['IconvExtraParams'], $message);
} elseif ( function_exists( 'recode_string' ) ) {
$message = recode_string( $encodings[$server_language] . '..' . $GLOBALS['charset'],
$message );
} elseif ( function_exists( 'libiconv' ) ) {
$message = libiconv( $encodings[$server_language], $GLOBALS['charset'], $message );
} elseif ( function_exists( 'mb_convert_encoding' ) ) {
// do not try unsupported charsets
if ( ! in_array( $server_language, array( 'ukrainian', 'greek', 'serbian' ) ) ) {
$message = mb_convert_encoding( $message, $GLOBALS['charset'],
$encodings[$server_language] );
}
}
} else {
// lang not found, try all
// what TODO ?
}
 
return $message;
}
 
/**
* returns array with database names
*
* @return array $databases
*/
function PMA_DBI_get_dblist($link = null)
{
$dbs_array = PMA_DBI_fetch_result('SHOW DATABASES;', $link);
 
// Before MySQL 4.0.2, SHOW DATABASES could send the
// whole list, so check if we really have access:
if (PMA_MYSQL_INT_VERSION < 40002 || !empty($GLOBALS['cfg']['Server']['hide_db'])) {
foreach ($dbs_array as $key => $db) {
if (!@PMA_DBI_select_db($db, $link) || (!empty($GLOBALS['cfg']['Server']['hide_db']) && preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db))) {
unset( $dbs_array[$key] );
}
}
// re-index values
$dbs_array = array_values( $dbs_array );
}
 
return $dbs_array;
}
 
/**
* returns array with table names for given db
*
* @param string $database name of database
* @param mixed $link mysql link resource|object
* @return array tables names
*/
function PMA_DBI_get_tables($database, $link = null)
{
return PMA_DBI_fetch_result('SHOW TABLES FROM ' . PMA_backquote($database) . ';',
null, 0, $link, PMA_DBI_QUERY_STORE);
}
 
/**
* returns array of all tables in given db or dbs
* this function expects unqoted names:
* RIGHT: my_database
* WRONG: `my_database`
* WRONG: my\_database
* if $tbl_is_group is true, $table is used as filter for table names
* if $tbl_is_group is 'comment, $table is used as filter for table comments
*
* <code>
* PMA_DBI_get_tables_full( 'my_database' );
* PMA_DBI_get_tables_full( 'my_database', 'my_table' ) );
* PMA_DBI_get_tables_full( 'my_database', 'my_tables_', true ) );
* PMA_DBI_get_tables_full( 'my_database', 'my_tables_', 'comment' ) );
* </code>
*
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_DBI_fetch_result()
* @uses PMA_escape_mysql_wildcards()
* @uses PMA_backquote()
* @uses is_array()
* @uses addslashes()
* @uses strpos()
* @uses strtoupper()
* @param string $databases database
* @param string $table table
* @param boolean|string $tbl_is_group $table is a table group
* @param resource $link mysql link
* @return array list of tbales in given db(s)
*/
function PMA_DBI_get_tables_full($database, $table = false,
$tbl_is_group = false, $link = null)
{
// prepare and check parameters
if ( ! is_array($database) ) {
$databases = array(addslashes($database));
} else {
$databases = array_map('addslashes', $database);
}
 
$tables = array();
 
if ( PMA_MYSQL_INT_VERSION >= 50002 ) {
// get table information from information_schema
if ( $table ) {
if ( true === $tbl_is_group ) {
$sql_where_table = 'AND `TABLE_NAME` LIKE \''
. PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} elseif ( 'comment' === $tbl_is_group ) {
$sql_where_table = 'AND `TABLE_COMMENT` LIKE \''
. PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} else {
$sql_where_table = 'AND `TABLE_NAME` = \'' . addslashes($table) . '\'';
}
} else {
$sql_where_table = '';
}
 
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
$sql = '
SELECT *,
`TABLE_SCHEMA` AS `Db`,
`TABLE_NAME` AS `Name`,
`ENGINE` AS `Engine`,
`ENGINE` AS `Type`,
`VERSION` AS `Version`,
`ROW_FORMAT` AS `Row_format`,
`TABLE_ROWS` AS `Rows`,
`AVG_ROW_LENGTH` AS `Avg_row_length`,
`DATA_LENGTH` AS `Data_length`,
`MAX_DATA_LENGTH` AS `Max_data_length`,
`INDEX_LENGTH` AS `Index_length`,
`DATA_FREE` AS `Data_free`,
`AUTO_INCREMENT` AS `Auto_increment`,
`CREATE_TIME` AS `Create_time`,
`UPDATE_TIME` AS `Update_time`,
`CHECK_TIME` AS `Check_time`,
`TABLE_COLLATION` AS `Collation`,
`CHECKSUM` AS `Checksum`,
`CREATE_OPTIONS` AS `Create_options`,
`TABLE_COMMENT` AS `Comment`
FROM `information_schema`.`TABLES`
WHERE `TABLE_SCHEMA` IN (\'' . implode("', '", $databases) . '\')
' . $sql_where_table;
$tables = PMA_DBI_fetch_result($sql, array('TABLE_SCHEMA', 'TABLE_NAME'),
null, $link);
unset( $sql_where_table, $sql );
} else {
foreach ( $databases as $each_database ) {
if ( true === $tbl_is_group ) {
$sql = 'SHOW TABLE STATUS FROM '
. PMA_backquote($each_database)
.' LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} else {
$sql = 'SHOW TABLE STATUS FROM '
. PMA_backquote($each_database) . ';';
}
$each_tables = PMA_DBI_fetch_result($sql, 'Name', null, $link);
foreach ( $each_tables as $table_name => $each_table ) {
if ( 'comment' === $tbl_is_group
&& 0 === strpos($each_table['Comment'], $table) )
{
// remove table from list
unset( $each_tables[$table_name] );
continue;
}
 
if ( ! isset( $each_tables[$table_name]['Type'] )
&& isset( $each_tables[$table_name]['Engine'] ) ) {
// pma BC, same parts of PMA still uses 'Type'
$each_tables[$table_name]['Type']
=& $each_tables[$table_name]['Engine'];
} elseif ( ! isset( $each_tables[$table_name]['Engine'] )
&& isset( $each_tables[$table_name]['Type'] ) ) {
// old MySQL reports Type, newer MySQL reports Engine
$each_tables[$table_name]['Engine']
=& $each_tables[$table_name]['Type'];
}
 
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
$each_tables[$table_name]['TABLE_SCHEMA'] = $each_database;
$each_tables[$table_name]['TABLE_NAME'] =& $each_tables[$table_name]['Name'];
$each_tables[$table_name]['ENGINE'] =& $each_tables[$table_name]['Engine'];
$each_tables[$table_name]['VERSION'] =& $each_tables[$table_name]['Version'];
$each_tables[$table_name]['ROW_FORMAT'] =& $each_tables[$table_name]['Row_format'];
$each_tables[$table_name]['TABLE_ROWS'] =& $each_tables[$table_name]['Rows'];
$each_tables[$table_name]['AVG_ROW_LENGTH'] =& $each_tables[$table_name]['Avg_row_length'];
$each_tables[$table_name]['DATA_LENGTH'] =& $each_tables[$table_name]['Data_length'];
$each_tables[$table_name]['MAX_DATA_LENGTH'] =& $each_tables[$table_name]['Max_data_length'];
$each_tables[$table_name]['INDEX_LENGTH'] =& $each_tables[$table_name]['Index_length'];
$each_tables[$table_name]['DATA_FREE'] =& $each_tables[$table_name]['Data_free'];
$each_tables[$table_name]['AUTO_INCREMENT'] =& $each_tables[$table_name]['Auto_increment'];
$each_tables[$table_name]['CREATE_TIME'] =& $each_tables[$table_name]['Create_time'];
$each_tables[$table_name]['UPDATE_TIME'] =& $each_tables[$table_name]['Update_time'];
$each_tables[$table_name]['CHECK_TIME'] =& $each_tables[$table_name]['Check_time'];
$each_tables[$table_name]['TABLE_COLLATION'] =& $each_tables[$table_name]['Collation'];
$each_tables[$table_name]['CHECKSUM'] =& $each_tables[$table_name]['Checksum'];
$each_tables[$table_name]['CREATE_OPTIONS'] =& $each_tables[$table_name]['Create_options'];
$each_tables[$table_name]['TABLE_COMMENT'] =& $each_tables[$table_name]['Comment'];
 
if ( strtoupper( $each_tables[$table_name]['Comment'] ) === 'VIEW' ) {
$each_tables[$table_name]['TABLE_TYPE'] = 'VIEW';
} else {
// TODO difference between 'TEMPORARY' and 'BASE TABLE'
// but how to detect?
$each_tables[$table_name]['TABLE_TYPE'] = 'BASE TABLE';
}
}
 
$tables[$each_database] = $each_tables;
}
}
 
if ( $GLOBALS['cfg']['NaturalOrder'] ) {
foreach ( $tables as $key => $val ) {
uksort($tables[$key], 'strnatcasecmp');
}
}
 
if (! is_array($database)) {
if (isset($tables[$database])) {
return $tables[$database];
} elseif (isset($tables[strtolower($database)])) {
// on windows with lower_case_table_names = 1
// MySQL returns
// with SHOW DATABASES or information_schema.SCHEMATA: `Test`
// but information_schema.TABLES gives `test`
// bug #1436171
// sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
return $tables[strtolower($database)];
} else {
return $tables;
}
} else {
return $tables;
}
}
 
/**
* returns array with databases containing extended infos about them
*
* @param string $databases database
* @param boolean $force_stats retrieve stats also for MySQL < 5
* @param resource $link mysql link
* @return array $databases
*/
function PMA_DBI_get_databases_full( $database = null, $force_stats = false, $link = null ) {
 
// initialize to avoid errors when there are no databases
$databases = array();
 
if ( PMA_MYSQL_INT_VERSION >= 50002 ) {
// get table information from information_schema
if ( $database ) {
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \''
. addslashes( $database ) . '\'';
} else {
$sql_where_schema = '';
}
 
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
$sql = '
SELECT `information_schema`.`SCHEMATA`.*,
COUNT(`information_schema`.`TABLES`.`TABLE_SCHEMA`)
AS `SCHEMA_TABLES`,
SUM(`information_schema`.`TABLES`.`TABLE_ROWS`)
AS `SCHEMA_TABLE_ROWS`,
SUM(`information_schema`.`TABLES`.`DATA_LENGTH`)
AS `SCHEMA_DATA_LENGTH`,
SUM(`information_schema`.`TABLES`.`MAX_DATA_LENGTH`)
AS `SCHEMA_MAX_DATA_LENGTH`,
SUM(`information_schema`.`TABLES`.`INDEX_LENGTH`)
AS `SCHEMA_INDEX_LENGTH`,
SUM(`information_schema`.`TABLES`.`DATA_LENGTH`
+ `information_schema`.`TABLES`.`INDEX_LENGTH`)
AS `SCHEMA_LENGTH`,
SUM(`information_schema`.`TABLES`.`DATA_FREE`)
AS `SCHEMA_DATA_FREE`
FROM `information_schema`.`SCHEMATA`
LEFT JOIN `information_schema`.`TABLES`
ON `information_schema`.`TABLES`.`TABLE_SCHEMA`
= `information_schema`.`SCHEMATA`.`SCHEMA_NAME`
' . $sql_where_schema . '
GROUP BY `information_schema`.`SCHEMATA`.`SCHEMA_NAME`';
$databases = PMA_DBI_fetch_result( $sql, 'SCHEMA_NAME', null, $link );
unset( $sql_where_schema, $sql );
} else {
foreach ( PMA_DBI_get_dblist( $link ) as $database_name ) {
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
 
if ( $force_stats ) {
require_once 'mysql_charsets.lib.php';
 
$databases[$database_name]['DEFAULT_COLLATION_NAME']
= PMA_getDbCollation( $database_name );
 
// get additonal info about tables
$databases[$database_name]['SCHEMA_TABLES'] = 0;
$databases[$database_name]['SCHEMA_TABLE_ROWS'] = 0;
$databases[$database_name]['SCHEMA_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
 
$res = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote( $database_name ) . ';');
while ( $row = PMA_DBI_fetch_assoc( $res ) ) {
$databases[$database_name]['SCHEMA_TABLES']++;
$databases[$database_name]['SCHEMA_TABLE_ROWS']
+= $row['Rows'];
$databases[$database_name]['SCHEMA_DATA_LENGTH']
+= $row['Data_length'];
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH']
+= $row['Max_data_length'];
$databases[$database_name]['SCHEMA_INDEX_LENGTH']
+= $row['Index_length'];
$databases[$database_name]['SCHEMA_DATA_FREE']
+= $row['Data_free'];
$databases[$database_name]['SCHEMA_LENGTH']
+= $row['Data_length'] + $row['Index_length'];
}
PMA_DBI_free_result( $res );
unset( $res );
}
}
}
 
if ( $GLOBALS['cfg']['NaturalOrder'] ) {
uksort( $databases, 'strnatcasecmp' );
}
 
return $databases;
}
 
/**
* returns detailed array with all columns for given table in database,
* or all tables/databases
*
* @param string $database name of database
* @param string $table name of table to retrieve columns from
* @param string $column name of specific column
* @param mixed $link mysql link resource
*/
function PMA_DBI_get_columns_full($database = null, $table = null,
$column = null, $link = null)
{
$columns = array();
 
if ( PMA_MYSQL_INT_VERSION >= 50002 ) {
$sql_wheres = array();
$array_keys = array();
 
// get columns information from information_schema
if ( null !== $database ) {
$sql_wheres[] = '`TABLE_SCHEMA` = \'' . addslashes($database) . '\' ';
} else {
$array_keys[] = 'TABLE_SCHEMA';
}
if ( null !== $table ) {
$sql_wheres[] = '`TABLE_NAME` = \'' . addslashes($table) . '\' ';
} else {
$array_keys[] = 'TABLE_NAME';
}
if ( null !== $column ) {
$sql_wheres[] = '`COLUMN_NAME` = \'' . addslashes($column) . '\' ';
} else {
$array_keys[] = 'COLUMN_NAME';
}
 
// for PMA bc:
// `[SCHEMA_FIELD_NAME]` AS `[SHOW_FULL_COLUMNS_FIELD_NAME]`
$sql = '
SELECT *,
`COLUMN_NAME` AS `Field`,
`COLUMN_TYPE` AS `Type`,
`COLLATION_NAME` AS `Collation`,
`IS_NULLABLE` AS `Null`,
`COLUMN_KEY` AS `Key`,
`COLUMN_DEFAULT` AS `Default`,
`EXTRA` AS `Extra`,
`PRIVILEGES` AS `Privileges`,
`COLUMN_COMMENT` AS `Comment`
FROM `information_schema`.`COLUMNS`';
if ( count($sql_wheres) ) {
$sql .= "\n" . ' WHERE ' . implode(' AND ', $sql_wheres);
}
 
$columns = PMA_DBI_fetch_result($sql, $array_keys, null, $link);
unset( $sql_wheres, $sql );
} else {
if ( null === $database ) {
$databases = PMA_DBI_get_dblist();
foreach ( $databases as $database ) {
$columns[$database] = PMA_DBI_get_columns_full($database, null,
null, $link);
}
return $columns;
} elseif ( null === $table ) {
$tables = PMA_DBI_get_tables($database);
foreach ( $tables as $table ) {
$columns[$table] = PMA_DBI_get_columns_full(
$database, $table, null, $link);
}
return $columns;
}
 
$sql = 'SHOW FULL COLUMNS FROM '
. PMA_backquote($database) . '.' . PMA_backquote($table);
if ( null !== $column ) {
$sql .= " LIKE '" . $column . "'";
}
 
$columns = PMA_DBI_fetch_result( $sql, 'Field', null, $link );
 
$ordinal_position = 1;
foreach ( $columns as $column_name => $each_column ) {
 
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
$columns[$column_name]['COLUMN_NAME'] =& $columns[$column_name]['Field'];
$columns[$column_name]['COLUMN_TYPE'] =& $columns[$column_name]['Type'];
$columns[$column_name]['COLLATION_NAME'] =& $columns[$column_name]['Collation'];
$columns[$column_name]['IS_NULLABLE'] =& $columns[$column_name]['Null'];
$columns[$column_name]['COLUMN_KEY'] =& $columns[$column_name]['Key'];
$columns[$column_name]['COLUMN_DEFAULT'] =& $columns[$column_name]['Default'];
$columns[$column_name]['EXTRA'] =& $columns[$column_name]['Extra'];
$columns[$column_name]['PRIVILEGES'] =& $columns[$column_name]['Privileges'];
$columns[$column_name]['COLUMN_COMMENT'] =& $columns[$column_name]['Comment'];
 
$columns[$column_name]['TABLE_CATALOG'] = null;
$columns[$column_name]['TABLE_SCHEMA'] = $database;
$columns[$column_name]['TABLE_NAME'] = $table;
$columns[$column_name]['ORDINAL_POSITION'] = $ordinal_position;
$columns[$column_name]['DATA_TYPE'] =
substr($columns[$column_name]['COLUMN_TYPE'], 0,
strpos($columns[$column_name]['COLUMN_TYPE'], '('));
// @TODO guess CHARACTER_MAXIMUM_LENGTH from COLUMN_TYPE
$columns[$column_name]['CHARACTER_MAXIMUM_LENGTH'] = null;
// @TODO guess CHARACTER_OCTET_LENGTH from CHARACTER_MAXIMUM_LENGTH
$columns[$column_name]['CHARACTER_OCTET_LENGTH'] = null;
$columns[$column_name]['NUMERIC_PRECISION'] = null;
$columns[$column_name]['NUMERIC_SCALE'] = null;
$columns[$column_name]['CHARACTER_SET_NAME'] =
substr($columns[$column_name]['COLLATION_NAME'], 0,
strpos($columns[$column_name]['COLLATION_NAME'], '_'));
 
$ordinal_position++;
}
 
if ( null !== $column ) {
reset($columns);
$columns = current($columns);
}
}
 
return $columns;
}
 
/**
* @TODO should only return columns names, for more info use PMA_DBI_get_columns_full()
*
* @param string $database name of database
* @param string $table name of table to retrieve columns from
* @param mixed $link mysql link resource
*/
function PMA_DBI_get_fields($database, $table, $link = null)
{
// here we use a try_query because when coming from
// tbl_create + tbl_properties.inc.php, the table does not exist
$fields = PMA_DBI_fetch_result(
'SHOW FULL COLUMNS
FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table),
null, null, $link);
if ( ! is_array($fields) || count($fields) < 1 ) {
return false;
}
return $fields;
}
 
/**
* returns value of given mysql server variable
*
* @param string $var mysql server variable name
* @param int $type PMA_DBI_GETVAR_SESSION|PMA_DBI_GETVAR_GLOBAL
* @param mixed $link mysql link resource|object
* @return mixed value for mysql server variable
*/
function PMA_DBI_get_variable($var, $type = PMA_DBI_GETVAR_SESSION, $link = null)
{
if ($link === null) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return false;
}
}
if (PMA_MYSQL_INT_VERSION < 40002) {
$type = 0;
}
switch ($type) {
case PMA_DBI_GETVAR_SESSION:
$modifier = ' SESSION';
break;
case PMA_DBI_GETVAR_GLOBAL:
$modifier = ' GLOBAL';
break;
default:
$modifier = '';
}
return PMA_DBI_fetch_value(
'SHOW' . $modifier . ' VARIABLES LIKE \'' . $var . '\';', 0, 1, $link);
}
 
/**
* @uses ./libraries/charset_conversion.lib.php
* @uses PMA_DBI_QUERY_STORE
* @uses PMA_REMOVED_NON_UTF_8
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_MYSQL_STR_VERSION
* @uses PMA_DBI_GETVAR_SESSION
* @uses PMA_DBI_fetch_value()
* @uses PMA_DBI_query()
* @uses PMA_DBI_get_variable()
* @uses $GLOBALS['collation_connection']
* @uses $GLOBALS['charset_connection']
* @uses $GLOBALS['available_languages']
* @uses $GLOBALS['mysql_charset_map']
* @uses $GLOBALS['charset']
* @uses $GLOBALS['lang']
* @uses $GLOBALS['cfg']['Lang']
* @uses $GLOBALS['cfg']['ColumnTypes']
* @uses defined()
* @uses explode()
* @uses sprintf()
* @uses intval()
* @uses define()
* @uses defined()
* @uses substr()
* @uses count()
* @param mixed $link mysql link resource|object
* @param boolean $is_controluser
*/
function PMA_DBI_postConnect($link, $is_controluser = false)
{
if (!defined('PMA_MYSQL_INT_VERSION')) {
$mysql_version = PMA_DBI_fetch_value(
'SELECT VERSION()', 0, 0, $link, PMA_DBI_QUERY_STORE);
if ( $mysql_version ) {
$match = explode('.', $mysql_version);
define('PMA_MYSQL_INT_VERSION',
(int) sprintf('%d%02d%02d', $match[0], $match[1],
intval($match[2])));
define('PMA_MYSQL_STR_VERSION', $mysql_version);
unset($mysql_version, $match);
} else {
define('PMA_MYSQL_INT_VERSION', 32332);
define('PMA_MYSQL_STR_VERSION', '3.23.32');
}
}
 
if (!defined('PMA_ENGINE_KEYWORD')) {
if (PMA_MYSQL_INT_VERSION >= 40102) {
define('PMA_ENGINE_KEYWORD','ENGINE');
} else {
define('PMA_ENGINE_KEYWORD','TYPE');
}
}
 
if (PMA_MYSQL_INT_VERSION >= 40100) {
 
// If $lang is defined and we are on MySQL >= 4.1.x,
// we auto-switch the lang to its UTF-8 version (if it exists and user
// didn't force language)
if ( !empty($GLOBALS['lang'])
&& (substr($GLOBALS['lang'], -5) != 'utf-8')
&& !isset($GLOBALS['cfg']['Lang']) ) {
$lang_utf_8_version =
substr($GLOBALS['lang'], 0, strpos($GLOBALS['lang'], '-'))
. '-utf-8';
if (!empty($GLOBALS['available_languages'][$lang_utf_8_version])) {
$GLOBALS['lang'] = $lang_utf_8_version;
$GLOBALS['charset'] = 'utf-8';
}
}
 
// and we remove the non-UTF-8 choices to avoid confusion
if (!defined('PMA_REMOVED_NON_UTF_8')) {
foreach ( $GLOBALS['available_languages'] as $each_lang => $dummy ) {
if ( substr($each_lang, -5) != 'utf-8' ) {
unset( $GLOBALS['available_languages'][$each_lang] );
}
}
define('PMA_REMOVED_NON_UTF_8', 1);
}
 
$mysql_charset = $GLOBALS['mysql_charset_map'][$GLOBALS['charset']];
if ( $is_controluser
|| empty($GLOBALS['collation_connection'])
|| (strpos($GLOBALS['collation_connection'], '_')
? substr($GLOBALS['collation_connection'], 0, strpos($GLOBALS['collation_connection'], '_'))
: $GLOBALS['collation_connection']) == $mysql_charset) {
 
PMA_DBI_query('SET NAMES ' . $mysql_charset . ';', $link,
PMA_DBI_QUERY_STORE);
} else {
PMA_DBI_query('SET CHARACTER SET ' . $mysql_charset . ';', $link,
PMA_DBI_QUERY_STORE);
}
if (!empty($GLOBALS['collation_connection'])) {
PMA_DBI_query('SET collation_connection = \'' . $GLOBALS['collation_connection'] . '\';',
$link, PMA_DBI_QUERY_STORE);
}
if (!$is_controluser) {
$GLOBALS['collation_connection'] = PMA_DBI_get_variable('collation_connection',
PMA_DBI_GETVAR_SESSION, $link);
$GLOBALS['charset_connection'] = PMA_DBI_get_variable('character_set_connection',
PMA_DBI_GETVAR_SESSION, $link);
}
 
// Add some field types to the list, this needs to be done once per session!
if ($GLOBALS['cfg']['ColumnTypes'][count($GLOBALS['cfg']['ColumnTypes']) - 1] != 'VARBINARY') {
$GLOBALS['cfg']['ColumnTypes'][] = 'BINARY';
$GLOBALS['cfg']['ColumnTypes'][] = 'VARBINARY';
}
 
} else {
require_once('./libraries/charset_conversion.lib.php');
}
}
 
/**
* returns a single value from the given result or query,
* if the query or the result has more than one row or field
* the first field of the first row is returned
*
* <code>
* $sql = 'SELECT `name` FROM `user` WHERE `id` = 123';
* $user_name = PMA_DBI_fetch_value( $sql );
* // produces
* // $user_name = 'John Doe'
* </code>
*
* @uses is_string()
* @uses is_int()
* @uses PMA_DBI_try_query()
* @uses PMA_DBI_num_rows()
* @uses PMA_DBI_fetch_row()
* @uses PMA_DBI_fetch_assoc()
* @uses PMA_DBI_free_result()
* @param string|mysql_result $result query or mysql result
* @param integer $row_number row to fetch the value from,
* starting at 0, with 0 beeing default
* @param integer|string $field field to fetch the value from,
* starting at 0, with 0 beeing default
* @param resource $link mysql link
* @param mixed $options
* @return mixed value of first field in first row from result
* or false if not found
*/
function PMA_DBI_fetch_value( $result, $row_number = 0, $field = 0, $link = null, $options = 0 ) {
$value = false;
 
if ( is_string( $result ) ) {
$result = PMA_DBI_try_query( $result, $link, $options | PMA_DBI_QUERY_STORE );
}
 
// return false if result is empty or false
// or requested row is larger than rows in result
if ( PMA_DBI_num_rows( $result ) < ( $row_number + 1 ) ) {
return $value;
}
 
// if $field is an integer use non associative mysql fetch function
if ( is_int( $field ) ) {
$fetch_function = 'PMA_DBI_fetch_row';
} else {
$fetch_function = 'PMA_DBI_fetch_assoc';
}
 
// get requested row
for ( $i = 0; $i <= $row_number; $i++ ) {
$row = $fetch_function( $result );
}
PMA_DBI_free_result( $result );
 
// return requested field
if ( isset( $row[$field] ) ) {
$value = $row[$field];
}
unset( $row );
 
return $value;
}
 
/**
* returns only the first row from the result
*
* <code>
* $sql = 'SELECT * FROM `user` WHERE `id` = 123';
* $user = PMA_DBI_fetch_single_row( $sql );
* // produces
* // $user = array( 'id' => 123, 'name' => 'John Doe' )
* </code>
*
* @uses is_string()
* @uses PMA_DBI_try_query()
* @uses PMA_DBI_num_rows()
* @uses PMA_DBI_fetch_row()
* @uses PMA_DBI_fetch_assoc()
* @uses PMA_DBI_fetch_array()
* @uses PMA_DBI_free_result()
* @param string|mysql_result $result query or mysql result
* @param string $type NUM|ASSOC|BOTH
* returned array should either numeric
* associativ or booth
* @param resource $link mysql link
* @param mixed $options
* @return array|boolean first row from result
* or false if result is empty
*/
function PMA_DBI_fetch_single_row( $result, $type = 'ASSOC', $link = null, $options = 0 ) {
if ( is_string( $result ) ) {
$result = PMA_DBI_try_query( $result, $link, $options | PMA_DBI_QUERY_STORE );
}
 
// return null if result is empty or false
if ( ! PMA_DBI_num_rows( $result ) ) {
return false;
}
 
switch ( $type ) {
case 'NUM' :
$fetch_function = 'PMA_DBI_fetch_row';
break;
case 'ASSOC' :
$fetch_function = 'PMA_DBI_fetch_assoc';
break;
case 'BOTH' :
default :
$fetch_function = 'PMA_DBI_fetch_array';
break;
}
 
$row = $fetch_function( $result );
PMA_DBI_free_result( $result );
return $row;
}
 
/**
* returns all rows in the resultset in one array
*
* <code>
* $sql = 'SELECT * FROM `user`';
* $users = PMA_DBI_fetch_result( $sql );
* // produces
* // $users[] = array( 'id' => 123, 'name' => 'John Doe' )
*
* $sql = 'SELECT `id`, `name` FROM `user`';
* $users = PMA_DBI_fetch_result( $sql, 'id' );
* // produces
* // $users['123'] = array( 'id' => 123, 'name' => 'John Doe' )
*
* $sql = 'SELECT `id`, `name` FROM `user`';
* $users = PMA_DBI_fetch_result( $sql, 0 );
* // produces
* // $users['123'] = array( 0 => 123, 1 => 'John Doe' )
*
* $sql = 'SELECT `id`, `name` FROM `user`';
* $users = PMA_DBI_fetch_result( $sql, 'id', 'name' );
* // or
* $users = PMA_DBI_fetch_result( $sql, 0, 1 );
* // produces
* // $users['123'] = 'John Doe'
*
* $sql = 'SELECT `name` FROM `user`';
* $users = PMA_DBI_fetch_result( $sql );
* // produces
* // $users[] = 'John Doe'
* </code>
*
* @uses is_string()
* @uses is_int()
* @uses PMA_DBI_try_query()
* @uses PMA_DBI_num_rows()
* @uses PMA_DBI_num_fields()
* @uses PMA_DBI_fetch_row()
* @uses PMA_DBI_fetch_assoc()
* @uses PMA_DBI_free_result()
* @param string|mysql_result $result query or mysql result
* @param string|integer $key field-name or offset
* used as key for array
* @param string|integer $value value-name or offset
* used as value for array
* @param resource $link mysql link
* @param mixed $options
* @return array resultrows or values indexed by $key
*/
function PMA_DBI_fetch_result( $result, $key = null, $value = null,
$link = null, $options = 0 )
{
$resultrows = array();
 
if ( is_string($result) ) {
$result = PMA_DBI_try_query($result, $link, $options);
}
 
// return empty array if result is empty or false
if ( ! $result ) {
return $resultrows;
}
 
$fetch_function = 'PMA_DBI_fetch_assoc';
 
// no nested array if only one field is in result
if ( null === $key && 1 === PMA_DBI_num_fields($result) ) {
$value = 0;
$fetch_function = 'PMA_DBI_fetch_row';
}
 
// if $key is an integer use non associative mysql fetch function
if ( is_int($key) ) {
$fetch_function = 'PMA_DBI_fetch_row';
}
 
if ( null === $key && null === $value ) {
while ( $row = $fetch_function($result) ) {
$resultrows[] = $row;
}
} elseif ( null === $key ) {
while ( $row = $fetch_function($result) ) {
$resultrows[] = $row[$value];
}
} elseif ( null === $value ) {
if ( is_array($key) ) {
while ( $row = $fetch_function($result) ) {
$result_target =& $resultrows;
foreach ( $key as $key_index ) {
if ( ! isset( $result_target[$row[$key_index]] ) ) {
$result_target[$row[$key_index]] = array();
}
$result_target =& $result_target[$row[$key_index]];
}
$result_target = $row;
}
} else {
while ( $row = $fetch_function($result) ) {
$resultrows[$row[$key]] = $row;
}
}
} else {
if ( is_array($key) ) {
while ( $row = $fetch_function($result) ) {
$result_target =& $resultrows;
foreach ( $key as $key_index ) {
if ( ! isset( $result_target[$row[$key_index]] ) ) {
$result_target[$row[$key_index]] = array();
}
$result_target =& $result_target[$row[$key_index]];
}
$result_target = $row[$value];
}
} else {
while ( $row = $fetch_function($result) ) {
$resultrows[$row[$key]] = $row[$value];
}
}
}
 
PMA_DBI_free_result($result);
return $resultrows;
}
 
/**
* return default table engine for given database
*
* @return string default table engine
*/
function PMA_DBI_get_default_engine()
{
if ( PMA_MYSQL_INT_VERSION > 50002 ) {
return PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE \'storage_engine\';', 0, 1 );
} else {
return PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE \'table_type\';', 0, 1 );
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/db_config.lib.php
0,0 → 1,92
<?php
/* $Id: db_config.lib.php,v 2.4 2004/05/20 16:14:10 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Database based configuration system
* Robin Johnson <robbat2@users.sourceforge.net>
* May 19, 2002
*/
 
/**
* Converts attributes of an object to xml code
*
* Original obj2xml() function by <jgettys@gnuvox.com>
* as found on http://www.php.net/manual/en/function.get-defined-vars.php
* Fixed and improved by Robin Johnson <robbat2@users.sourceforge.net>
*
* @param object the source
* @param string identication
*
* @access public
*/
function obj2xml($v, $indent = '') {
$attr = '';
foreach ($v AS $key => $val) {
if (is_string($key) && ($key == '__attr')) {
continue;
}
 
// Check for __attr
if (is_object($val->__attr)) {
foreach ($val->__attr AS $key2 => $val2) {
$attr .= " $key2=\"$val2\"";
}
} else {
$attr = '';
}
 
// Preserve data type information
$attr .= ' type="' . gettype($val) . '"';
 
if (is_array($val) || is_object($val)) {
echo "$indent<$key$attr>\n";
obj2xml($val, $indent . ' ');
echo "$indent</$key>\n";
} else {
if (is_string($val) && ($val == '')) {
echo "$indent<$key$attr />\n";
} else {
echo "$indent<$key$attr>$val</$key>\n";
}
}
} // end while
} // end of the "obj2xml()" function
 
 
$cfg['DBConfig']['AllowUserOverride'] = array(
'Servers/*/bookmarkdb',
'Servers/*/bookmarktable',
'Servers/*/relation',
'Servers/*/pdf_table_position',
'ShowSQL',
'Confirm',
'LeftFrameLight',
'ShowTooltip',
'ShowBlob',
'NavigationBarIconic',
'ShowAll',
'MaxRows',
'Order',
'ProtectBinary',
'ShowFunctionFields',
'LeftWidth',
'LeftBgColor',
'LeftPointerColor',
'RightBgColor',
'Border',
'ThBgcolor',
'BgcolorOne',
'BgcolorTwo',
'BrowsePointerColor',
'BrowseMarkerColor',
'TextareaCols',
'TextareaRows',
'LimitChars',
'ModifyDeleteAtLeft',
'ModifyDeleteAtRight',
'DefaultDisplay',
'RepeatCells'
);
 
?>
/Web/Maintenance/phpMyAdmin/libraries/db_details_common.inc.php
0,0 → 1,61
<?php
/* $Id: db_details_common.inc.php,v 1.3 2006/01/14 23:17:16 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Gets some core libraries
*/
require_once('./libraries/common.lib.php');
require_once('./libraries/bookmark.lib.php');
 
PMA_checkParameters(array('db'));
 
if ( PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema' ) {
$cfg['ShowStats'] = false;
$db_is_information_schema = true;
} else {
$db_is_information_schema = false;
}
 
/**
* Defines the urls to return to in case of error in a sql statement
*/
$err_url_0 = 'main.php?' . PMA_generate_common_url();
$err_url = $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db);
 
 
/**
* Ensures the database exists (else move to the "parent" script) and displays
* headers
*/
if (!isset($is_db) || !$is_db) {
// Not a valid db name -> back to the welcome page
if (isset($db) && strlen($db)) {
$is_db = PMA_DBI_select_db($db);
}
if (!isset($db) || !strlen($db) || !$is_db) {
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit;
}
} // end if (ensures db exists)
 
/**
* Changes database charset if requested by the user
*/
if (isset($submitcollation) && !empty($db_collation) && PMA_MYSQL_INT_VERSION >= 40101) {
list($db_charset) = explode('_', $db_collation);
$sql_query = 'ALTER DATABASE ' . PMA_backquote($db) . ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
$result = PMA_DBI_query($sql_query);
$message = $strSuccess;
unset($db_charset, $db_collation);
}
 
$js_to_run = 'functions.js';
require_once('./libraries/header.inc.php');
 
/**
* Set parameters for links
*/
$url_query = PMA_generate_common_url($db);
 
?>
/Web/Maintenance/phpMyAdmin/libraries/db_details_db_info.inc.php
0,0 → 1,138
<?php
/* $Id: db_details_db_info.inc.php,v 1.2 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
// Check parameters
 
require_once('./libraries/common.lib.php');
 
PMA_checkParameters(array('db'));
 
if ( PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema' ) {
$cfg['ShowStats'] = false;
$db_is_information_schema = true;
} else {
$db_is_information_schema = false;
}
 
function fillTooltip( &$tooltip_truename, &$tooltip_aliasname, &$tmp ) {
$tooltip_truename[$tmp['Name']] = ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested' ? (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']) : $tmp['Name']);
$tooltip_aliasname[$tmp['Name']] = ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] != 'nested' ? $tmp['Name'] : (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']));
if (isset($tmp['Create_time']) && !empty($tmp['Create_time'])) {
$tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Create_time']));
}
 
if (isset($tmp['Update_time']) && !empty($tmp['Update_time'])) {
$tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Update_time']));
}
 
if (isset($tmp['Check_time']) && !empty($tmp['Check_time'])) {
$tooltip_aliasname[$tmp['Name']] .= ', ' . $GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmp['Check_time']));
}
 
return true;
}
 
/**
* Gets the list of the table in the current db and informations about these
* tables if possible
*/
// staybyte: speedup view on locked tables - 11 June 2001
$tables = array();
 
// When used in Nested table group mode, only show tables matching the given groupname
if (!empty($tbl_group) && !$cfg['ShowTooltipAliasTB']) {
$tbl_group_sql = ' LIKE "' . PMA_escape_mysql_wildcards( $tbl_group ) . '%"';
} else {
$tbl_group_sql = '';
}
 
if ( $cfg['ShowTooltip'] ) {
$tooltip_truename = array();
$tooltip_aliasname = array();
}
 
// Special speedup for newer MySQL Versions (in 4.0 format changed)
if ( true === $cfg['SkipLockedTables'] ) {
$db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
// Blending out tables in use
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
// if in use memorize tablename
if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
$sot_cache[$tmp[0]] = TRUE;
}
}
PMA_DBI_free_result($db_info_result);
 
if (isset($sot_cache)) {
$db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', null, PMA_DBI_QUERY_STORE);
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
if (!isset($sot_cache[$tmp[0]])) {
$sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
$sts_tmp = PMA_DBI_fetch_assoc($sts_result);
PMA_DBI_free_result($sts_result);
unset($sts_result);
 
if (!isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
$sts_tmp['Type'] =& $sts_tmp['Engine'];
}
 
if (!empty($tbl_group) && $cfg['ShowTooltipAliasTB'] && !preg_match('@' . preg_quote($tbl_group, '@') . '@i', $sts_tmp['Comment'])) {
continue;
}
 
if ($cfg['ShowTooltip']) {
fillTooltip($tooltip_truename, $tooltip_aliasname, $sts_tmp);
}
 
$tables[$sts_tmp['Name']] = $sts_tmp;
} else { // table in use
$tables[$tmp[0]] = array('Name' => $tmp[0]);
}
}
PMA_DBI_free_result($db_info_result);
if ( $GLOBALS['cfg']['NaturalOrder'] ) {
uksort( $tables, 'strnatcasecmp' );
}
 
$sot_ready = TRUE;
}
}
} else {
PMA_DBI_free_result($db_info_result);
unset($db_info_result);
}
}
 
if ( ! isset( $sot_ready ) ) {
if ( ! empty( $tbl_group ) && ! $cfg['ShowTooltipAliasTB'] ) {
// only tables for selected group
$tables = PMA_DBI_get_tables_full( $db, $tbl_group, true );
} elseif ( ! empty( $tbl_group ) && $cfg['ShowTooltipAliasTB'] ) {
// only tables for selected group,
// but grouping is done on comment ...
$tables = PMA_DBI_get_tables_full( $db, $tbl_group, 'comment' );
} else {
// all tables in db
$tables = PMA_DBI_get_tables_full( $db );
}
if ( $cfg['ShowTooltip'] ) {
foreach ( $tables as $each_table ) {
fillTooltip( $tooltip_truename, $tooltip_aliasname, $each_table );
}
}
}
 
$num_tables = count( $tables );
 
/**
* Displays top menu links
*/
require('./libraries/db_details_links.inc.php');
?>
/Web/Maintenance/phpMyAdmin/libraries/db_details_links.inc.php
0,0 → 1,119
<?php
/* $Id: db_details_links.inc.php,v 1.2 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
require_once('./libraries/common.lib.php');
 
/**
* If coming from a Show MySQL link on the home page,
* put something in $sub_part
*/
if (empty($sub_part)) {
$sub_part = '_structure';
}
 
/**
* Checks for superuser privileges
*/
// We were checking privileges with 'USE mysql' but users with the global
// priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
// (even if they cannot see the tables)
 
$is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', null, PMA_DBI_QUERY_STORE);
 
/**
* Prepares links
*/
// Drop link if allowed
// rabus: Don't even try to drop information_schema. You won't be able to. Believe me. You won't.
// nijel: Don't allow to easilly drop mysql database, RFE #1327514.
if (($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) && ! $db_is_information_schema && ($db != 'mysql')) {
$tab_drop['link'] = 'sql.php';
$tab_drop['args']['sql_query'] = 'DROP DATABASE ' . PMA_backquote($db);
$tab_drop['args']['zero_rows'] = sprintf($GLOBALS['strDatabaseHasBeenDropped'], htmlspecialchars(PMA_backquote($db)));
$tab_drop['args']['goto'] = 'main.php';
$tab_drop['args']['back'] = 'db_details' . $sub_part . '.php';
$tab_drop['args']['reload'] = 1;
$tab_drop['args']['purge'] = 1;
$tab_drop['attr'] = 'onclick="return confirmLinkDropDB(this, \'DROP DATABASE ' . PMA_jsFormat($db) . '\')"';
}
 
/**
* export, search and qbe links if there is at least one table
*/
if ( $num_tables > 0 ) {
$tab_export['link'] = 'db_details_export.php';
$tab_search['link'] = 'db_search.php';
$tab_qbe['link'] = 'db_details_qbe.php';
}
 
$tab_structure['link'] = 'db_details_structure.php';
$tab_structure['text'] = $GLOBALS['strStructure'];
$tab_structure['icon'] = 'b_props.png';
 
$tab_sql['link'] = 'db_details.php';
$tab_sql['args']['db_query_force'] = 1;
$tab_sql['text'] = $GLOBALS['strSQL'];
$tab_sql['icon'] = 'b_sql.png';
 
$tab_export['text'] = $GLOBALS['strExport'];
$tab_export['icon'] = 'b_export.png';
$tab_search['text'] = $GLOBALS['strSearch'];
$tab_search['icon'] = 'b_search.png';
 
$tab_qbe['text'] = $GLOBALS['strQBE'];
$tab_qbe['icon'] = 's_db.png';
 
 
if ( ! $db_is_information_schema ) {
$tab_import['link'] = 'db_import.php';
$tab_import['text'] = $GLOBALS['strImport'];
$tab_import['icon'] = 'b_import.png';
$tab_drop['text'] = $GLOBALS['strDrop'];
$tab_drop['icon'] = 'b_deltbl.png';
$tab_drop['class'] = 'caution';
$tab_operation['link'] = 'db_operations.php';
$tab_operation['text'] = $GLOBALS['strOperations'];
$tab_operation['icon'] = 'b_tblops.png';
if ( $is_superuser ) {
$tab_privileges['link'] = 'server_privileges.php';
$tab_privileges['args']['checkprivs'] = $db;
// stay on database view
$tab_privileges['args']['viewing_mode'] = 'db';
$tab_privileges['text'] = $GLOBALS['strPrivileges'];
$tab_privileges['icon'] = 's_rights.png';
}
}
 
/**
* Displays tab links
*/
$tabs = array();
$tabs[] =& $tab_structure;
$tabs[] =& $tab_sql;
$tabs[] =& $tab_search;
$tabs[] =& $tab_qbe;
$tabs[] =& $tab_export;
if ( ! $db_is_information_schema ) {
$tabs[] =& $tab_import;
$tabs[] =& $tab_operation;
if ( $is_superuser ) {
$tabs[] =& $tab_privileges;
}
if ( $is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase'] ) {
$tabs[] =& $tab_drop;
}
}
 
echo PMA_getTabs( $tabs );
unset( $tabs );
 
/**
* Displays a message
*/
if (!empty($message)) {
PMA_showMessage($message);
unset($message);
}
?>
<br />
/Web/Maintenance/phpMyAdmin/libraries/db_table_exists.lib.php
0,0 → 1,74
<?php
/* $Id: db_table_exists.lib.php,v 2.11.2.2 2006/04/12 18:51:11 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Ensure the database and the table exist (else move to the "parent" script)
* and display headers
*/
if (empty($is_db)) {
if (isset($db) && strlen($db)) {
$is_db = @PMA_DBI_select_db($db);
} else {
$is_db = false;
}
 
if (! $is_db) {
// not a valid db name -> back to the welcome page
if (! defined('IS_TRANSFORMATION_WRAPPER')) {
$url_params = array('reload' => 1);
if (isset($message)) {
$url_params['message'] = $message;
}
PMA_sendHeaderLocation(
$cfg['PmaAbsoluteUri'] . 'main.php'
. PMA_generate_common_url($url_params, '&'));
}
exit;
}
} // end if (ensures db exists)
 
if (empty($is_table)) {
// Not a valid table name -> back to the db_details.php
if (isset($table) && strlen($table)) {
$_result = PMA_DBI_try_query(
'SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, true) . '\';',
null, PMA_DBI_QUERY_STORE);
$is_table = @PMA_DBI_num_rows($_result);
PMA_DBI_free_result($_result);
} else {
$is_table = false;
}
 
if (! $is_table) {
if (! defined('IS_TRANSFORMATION_WRAPPER')) {
if (isset($table) && strlen($table)) {
// SHOW TABLES doesn't show temporary tables, so try select
// (as it can happen just in case temporary table, it should be
// fast):
 
// @todo should this check really only happen if IS_TRANSFORMATION_WRAPPER?
$_result = PMA_DBI_try_query(
'SELECT COUNT(*) FROM `' . PMA_sqlAddslashes($table, true) . '`;',
null, PMA_DBI_QUERY_STORE);
$is_table = ($_result && @PMA_DBI_num_rows($_result));
PMA_DBI_free_result($_result);
}
 
if (! $is_table) {
$url_params = array('reload' => 1, 'db' => $db);
if (isset($message)) {
$url_params['message'] = $message;
}
PMA_sendHeaderLocation(
$cfg['PmaAbsoluteUri'] . 'db_details.php'
. PMA_generate_common_url($url_params, '&'));
}
}
 
if (! $is_table) {
exit;
}
}
} // end if (ensures table exists)
?>
/Web/Maintenance/phpMyAdmin/libraries/dbg/profiling.php
0,0 → 1,105
<?php
/* $Id: profiling.php,v 2.10 2006/01/17 17:03:02 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* holds function for dumping profiling data
*
* allways use $GLOBALS here, as this script is included by footer.inc.hp
* which can also be included from inside a function
*/
 
if ( ! empty( $GLOBALS['DBG'] )
&& $GLOBALS['cfg']['DBG']['profile']['enable'] ) {
 
/**
* Displays profiling results when called
* WARNING: this function is SLOW
*/
function dbg_dump_profiling_results() {
/* Applies to the original 'dbg_dump_profiling_results' function,
* sourced from http://dd.cron.ru/dbg/download.php?h=prof_sample2
* Copyright (c) 2002. Dmitri Dmitrienko
* LICENCE: This source file is subject to Mozilla Public License (MPL)
* AUTHOR: Dmitri Dmitrienko <dd@cron.ru>
*/
dbg_get_profiler_results( $dbg_prof_results = '' );
$cwdlen = strlen(getcwd()); // gma added var, $cwdlen = strlen(getcwd());
echo '<br /><table xml:lang="en" dir="ltr" width="1000" cellspacing="0" cellpadding="2" style="font:8pt courier">' . "\n" .
'<thead>' . "\n";
// gma added "$tr ="
$tr = '<tr>' . "\n" .
'<th>' . $GLOBALS['strDBGModule'] . '</th>' . "\n" .
'<th>' . $GLOBALS['strDBGLine'] . '</th>' . "\n" .
'<th>' . $GLOBALS['strDBGHits'] . '</th>' . "\n" .
'<th>' . $GLOBALS['strDBGTimePerHitMs'] . '</th>' . "\n" .
'<th>' . $GLOBALS['strDBGTotalTimeMs'] . '</th>' . "\n" .
'<th>' . $GLOBALS['strDBGMinTimeMs'] . '</th>' . "\n" .
'<th>' . $GLOBALS['strDBGMaxTimeMs'] . '</th>' . "\n" .
'<th>' . $GLOBALS['strDBGContextID'] . '</th>' . "\n" .
'<th>' . $GLOBALS['strDBGContext'] . '</th>' . "\n" .
'</tr>' . "\n"; // gma change "." to ";"
echo $tr.'</thead><tbody style="vertical-align: top">' . "\n";
$lines = 0; // gma added "echo $tr." and "$lines = 0;"
$ctx_name = '';
$mod_name = '';
$ctx_id = '';
$odd_row = true;
foreach ( $dbg_prof_results['line_no'] as $idx => $line_no ) {
dbg_get_module_name( $dbg_prof_results['mod_no'][$idx], $mod_name );
 
//if (strpos("!".$mod_name, 'dbg.php') > 0) continue;
 
$time_sum = $dbg_prof_results['tm_sum'][$idx] * 1000;
$time_avg_hit = $time_sum / $dbg_prof_results['hit_count'][$idx];
 
$time_sum = sprintf( '%.3f', $time_sum );
$time_avg_hit = sprintf('%.3f', $time_avg_hit);
$time_min = sprintf( '%.3f', $dbg_prof_results['tm_min'][$idx] * 1000 );
$time_max = sprintf( '%.3f', $dbg_prof_results['tm_max'][$idx] * 1000 );
dbg_get_source_context( $dbg_prof_results['mod_no'][$idx],
$line_no, $ctx_id );
 
// use a default context name if needed
if ( dbg_get_context_name( $ctx_id, $ctx_name )
&& strlen($ctx_name) == 0 ) {
$ctx_name = "::main";
}
 
if ( $time_avg_hit > $GLOBALS['cfg']['DBG']['profile']['threshold'] ) {
echo '<tr class="' . $odd_row ? 'odd' : 'even' . '">' .
// gma changed "$mod_name" to "substr($mod_name, $cwdlen+1)"
'<td>' . substr($mod_name, $cwdlen+1) . '</td>' .
'<td>' . $line_no . '</td>' .
'<td>' . $dbg_prof_results['hit_count'][$idx] . '</td>' .
'<td>' . $time_avg_hit . '</td>' .
'<td>' . $time_sum . '</td>' .
'<td>' . $time_min . '</td>' .
'<td>' . $time_max . '</td>' .
'<td>' . $ctx_id . '</td>' .
'<td>' . $ctx_name . '</td>' .
'</tr>' . "\n";
// gma added line. Repeats the header every x lines.
if ( $lines === 19 ) {
$odd_row = true;
$lines = 0;
echo $tr;
} else {
$odd_row = ! $odd_row;
$lines++;
}
}
}
echo '</tbody></table>';
}
}
/* gma ... Developer Notes
These two scriptlets can be used as On/Off buttons in your browsers, add to links.
ON:
javascript: document.cookie = 'DBGSESSID=' + escape('1;d=1,p=1') + '; path=/'; document.execCommand('refresh');
or ...
javascript: document.cookie = 'DBGSESSID=' + escape('1;d=0,p=1') + '; path=/'; document.execCommand('refresh');
OFF:
javascript: document.cookie = 'DBGSESSID=' + escape('1;d=0,p=0') + '; path=/'; document.execCommand('refresh');
*/
?>
/Web/Maintenance/phpMyAdmin/libraries/dbg/setup.php
0,0 → 1,24
<?php
/* $Id: setup.php,v 2.6 2005/11/03 12:22:08 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* checks for DBG extension and trys to load if not loaded
*
* allways use $GLOBALS here, as this script is included by footer.inc.hp
* which can also be included from inside a function
*/
if ( $GLOBALS['cfg']['DBG']['enable'] ) {
/**
* Loads the DBG extension if needed
*/
if ( ! @extension_loaded('dbg') && ! PMA_dl('dbg') ) {
echo '<div class="warning">'
.sprintf( $GLOBALS['strCantLoad'], 'DBG' )
.' <a href="./Documentation.html#faqdbg" target="documentation">'
.$GLOBALS['strDocu'] . '</a>'
.'</div>';
} else {
$GLOBALS['DBG'] = true;
}
}
?>
/Web/Maintenance/phpMyAdmin/libraries/dbi/mysql.dbi.lib.php
0,0 → 1,346
<?php
/* $Id: mysql.dbi.lib.php,v 2.43 2006/01/17 17:03:02 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Interface to the classic MySQL extension
*/
 
// MySQL client API
if (!defined('PMA_MYSQL_CLIENT_API')) {
if (function_exists('mysql_get_client_info')) {
$client_api = explode('.', mysql_get_client_info());
define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2])));
unset($client_api);
} else {
define('PMA_MYSQL_CLIENT_API', 32332); // always expect the worst...
}
}
 
function PMA_DBI_connect($user, $password, $is_controluser = FALSE) {
global $cfg, $php_errormsg;
 
$server_port = (empty($cfg['Server']['port']))
? ''
: ':' . $cfg['Server']['port'];
 
if (strtolower($cfg['Server']['connect_type']) == 'tcp') {
$cfg['Server']['socket'] = '';
}
 
$server_socket = (empty($cfg['Server']['socket']))
? ''
: ':' . $cfg['Server']['socket'];
 
if (PMA_PHP_INT_VERSION >= 40300 && PMA_MYSQL_CLIENT_API >= 32349) {
$client_flags = $cfg['Server']['compress'] && defined('MYSQL_CLIENT_COMPRESS') ? MYSQL_CLIENT_COMPRESS : 0;
// always use CLIENT_LOCAL_FILES as defined in mysql_com.h
// for the case where the client library was not compiled
// with --enable-local-infile
$client_flags |= 128;
}
 
if (empty($client_flags)) {
$connect_func = 'mysql_' . ($cfg['PersistentConnections'] ? 'p' : '') . 'connect';
$link = @$connect_func($cfg['Server']['host'] . $server_port . $server_socket, $user, $password);
} else {
if ($cfg['PersistentConnections']) {
$link = @mysql_pconnect($cfg['Server']['host'] . $server_port . $server_socket, $user, $password, $client_flags);
} else {
$link = @mysql_connect($cfg['Server']['host'] . $server_port . $server_socket, $user, $password, FALSE, $client_flags);
}
}
 
if (empty($link)) {
PMA_auth_fails();
} // end if
 
PMA_DBI_postConnect($link, $is_controluser);
 
return $link;
}
 
function PMA_DBI_select_db($dbname, $link = null) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
if (PMA_MYSQL_INT_VERSION < 40100) {
$dbname = PMA_convert_charset($dbname);
}
return mysql_select_db($dbname, $link);
}
 
function PMA_DBI_try_query($query, $link = null, $options = 0) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION < 40100) {
$query = PMA_convert_charset($query);
}
if ($options == ($options | PMA_DBI_QUERY_STORE)) {
return @mysql_query($query, $link);
} elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) {
return @mysql_unbuffered_query($query, $link);
} else {
return @mysql_query($query, $link);
}
}
 
// The following function is meant for internal use only.
// Do not call it from outside this library!
function PMA_mysql_fetch_array($result, $type = FALSE) {
global $cfg, $allow_recoding, $charset, $convcharset;
 
if ($type != FALSE) {
$data = mysql_fetch_array($result, $type);
} else {
$data = mysql_fetch_array($result);
}
 
/* No data returned => do not touch it */
if (! $data) {
return $data;
}
 
if (!defined('PMA_MYSQL_INT_VERSION') || PMA_MYSQL_INT_VERSION >= 40100
|| !(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
/* No recoding -> return data as we got them */
return $data;
} else {
$ret = array();
$num = mysql_num_fields($result);
$i = 0;
for ($i = 0; $i < $num; $i++) {
$name = mysql_field_name($result, $i);
$flags = mysql_field_flags($result, $i);
/* Field is BINARY (either marked manually, or it is BLOB) => do not convert it */
if (stristr($flags, 'BINARY')) {
if (isset($data[$i])) {
$ret[$i] = $data[$i];
}
if (isset($data[$name])) {
$ret[PMA_convert_display_charset($name)] = $data[$name];
}
} else {
if (isset($data[$i])) {
$ret[$i] = PMA_convert_display_charset($data[$i]);
}
if (isset($data[$name])) {
$ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]);
}
}
}
return $ret;
}
}
 
function PMA_DBI_fetch_array($result) {
return PMA_mysql_fetch_array($result);
}
 
function PMA_DBI_fetch_assoc($result) {
return PMA_mysql_fetch_array($result, MYSQL_ASSOC);
}
 
function PMA_DBI_fetch_row($result) {
return PMA_mysql_fetch_array($result, MYSQL_NUM);
}
 
/**
* Frees the memory associated with the results
*
* @param result $result,... one or more mysql result resources
*/
function PMA_DBI_free_result() {
foreach ( func_get_args() as $result ) {
if ( is_resource($result)
&& get_resource_type($result) === 'mysql result' ) {
mysql_free_result($result);
}
}
}
 
/**
* Returns a string representing the type of connection used
* @uses mysql_get_host_info()
* @uses $GLOBALS['userlink'] as default for $link
* @param resource $link mysql link
* @return string type of connection used
*/
function PMA_DBI_get_host_info($link = null)
{
if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return false;
}
}
return mysql_get_host_info($link);
}
 
/**
* Returns the version of the MySQL protocol used
* @uses mysql_get_proto_info()
* @uses $GLOBALS['userlink'] as default for $link
* @param resource $link mysql link
* @return integer version of the MySQL protocol used
*/
function PMA_DBI_get_proto_info($link = null)
{
if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return false;
}
}
return mysql_get_proto_info($link);
}
 
/**
* returns a string that represents the client library version
* @uses mysql_get_client_info()
* @return string MySQL client library version
*/
function PMA_DBI_get_client_info() {
return mysql_get_client_info();
}
 
/**
* returns last error message or false if no errors occured
*
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_convert_display_charset()
* @uses PMA_DBI_convert_message()
* @uses $GLOBALS['errno']
* @uses $GLOBALS['userlink']
* @uses $GLOBALS['strServerNotResponding']
* @uses $GLOBALS['strSocketProblem']
* @uses mysql_errno()
* @uses mysql_error()
* @uses defined()
* @param resource $link mysql link
* @return string|boolean $error or false
*/
function PMA_DBI_getError($link = null)
{
unset($GLOBALS['errno']);
if (null === $link && isset($GLOBALS['userlink'])) {
$link =& $GLOBALS['userlink'];
 
// Do not stop now. On the initial connection, we don't have a $link,
// we don't have a $GLOBALS['userlink'], but we can catch the error code
// } else {
// return FALSE;
}
 
if (null !== $link) {
$error_number = mysql_errno($link);
$error_message = mysql_error($link);
} else {
$error_number = mysql_errno();
$error_message = mysql_error();
}
if (0 == $error_number) {
return false;
}
 
// keep the error number for further check after the call to PMA_DBI_getError()
$GLOBALS['errno'] = $error_number;
 
if (! empty($error_message)) {
$error_message = PMA_DBI_convert_message($error_message);
}
 
// Some errors messages cannot be obtained by mysql_error()
if ($error_number == 2002) {
$error = '#' . ((string) $error_number) . ' - ' . $GLOBALS['strServerNotResponding'] . ' ' . $GLOBALS['strSocketProblem'];
} elseif ($error_number == 2003 ) {
$error = '#' . ((string) $error_number) . ' - ' . $GLOBALS['strServerNotResponding'];
} elseif (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 40100) {
$error = '#' . ((string) $error_number) . ' - ' . $error_message;
} else {
$error = '#' . ((string) $error_number) . ' - ' . PMA_convert_display_charset($error_message);
}
return $error;
}
 
function PMA_DBI_close($link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
return @mysql_close($link);
}
 
function PMA_DBI_num_rows($result) {
if (!is_bool($result)) {
return mysql_num_rows($result);
} else {
return 0;
}
}
 
function PMA_DBI_insert_id($link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
return mysql_insert_id($link);
}
 
function PMA_DBI_affected_rows($link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
return mysql_affected_rows($link);
}
 
function PMA_DBI_get_fields_meta($result) {
$fields = array();
$num_fields = mysql_num_fields($result);
for ($i = 0; $i < $num_fields; $i++) {
$fields[] = PMA_convert_display_charset(mysql_fetch_field($result, $i));
}
return $fields;
}
 
function PMA_DBI_num_fields($result) {
return mysql_num_fields($result);
}
 
function PMA_DBI_field_len($result, $i) {
return mysql_field_len($result, $i);
}
 
function PMA_DBI_field_name($result, $i) {
return mysql_field_name($result, $i);
}
 
function PMA_DBI_field_flags($result, $i) {
return PMA_convert_display_charset(mysql_field_flags($result, $i));
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/dbi/mysqli.dbi.lib.php
0,0 → 1,467
<?php
/* $Id: mysqli.dbi.lib.php,v 2.43.2.1 2006/02/22 15:30:38 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Interface to the improved MySQL extension (MySQLi)
*/
 
// MySQL client API
if (!defined('PMA_MYSQL_CLIENT_API')) {
$client_api = explode('.', mysqli_get_client_info());
define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2])));
unset($client_api);
}
 
// Constants from mysql_com.h of MySQL 4.1.3
 
define('NOT_NULL_FLAG', 1);
define('PRI_KEY_FLAG', 2);
define('UNIQUE_KEY_FLAG', 4);
define('MULTIPLE_KEY_FLAG', 8);
define('BLOB_FLAG', 16);
define('UNSIGNED_FLAG', 32);
define('ZEROFILL_FLAG', 64);
define('BINARY_FLAG', 128);
define('ENUM_FLAG', 256);
define('AUTO_INCREMENT_FLAG', 512);
define('TIMESTAMP_FLAG', 1024);
define('SET_FLAG', 2048);
define('NUM_FLAG', 32768);
define('PART_KEY_FLAG', 16384);
define('UNIQUE_FLAG', 65536);
 
/**
* @see http://bugs.php.net/36007
*/
if (! defined('MYSQLI_TYPE_NEWDECIMAL')) {
define('MYSQLI_TYPE_NEWDECIMAL', 246);
}
if (! defined('MYSQLI_TYPE_BIT')) {
define('MYSQLI_TYPE_BIT', 16);
}
 
function PMA_DBI_connect($user, $password, $is_controluser = FALSE)
{
global $cfg, $php_errormsg;
 
$server_port = (empty($cfg['Server']['port']))
? FALSE
: (int) $cfg['Server']['port'];
 
if (strtolower($cfg['Server']['connect_type']) == 'tcp') {
$cfg['Server']['socket'] = '';
}
 
// NULL enables connection to the default socket
$server_socket = (empty($cfg['Server']['socket']))
? null
: $cfg['Server']['socket'];
 
$link = mysqli_init();
 
mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, TRUE);
 
$client_flags = $cfg['Server']['compress'] && defined('MYSQLI_CLIENT_COMPRESS') ? MYSQLI_CLIENT_COMPRESS : 0;
 
$return_value = @mysqli_real_connect($link, $cfg['Server']['host'], $user, $password, FALSE, $server_port, $server_socket, $client_flags);
 
if ($return_value == FALSE) {
PMA_auth_fails();
} // end if
 
PMA_DBI_postConnect($link, $is_controluser);
 
return $link;
}
 
function PMA_DBI_select_db($dbname, $link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
if (PMA_MYSQL_INT_VERSION < 40100) {
$dbname = PMA_convert_charset($dbname);
}
return mysqli_select_db($link, $dbname);
}
 
function PMA_DBI_try_query($query, $link = null, $options = 0)
{
if ($options == ($options | PMA_DBI_QUERY_STORE)) {
$method = MYSQLI_STORE_RESULT;
} elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) {
$method = MYSQLI_USE_RESULT;
} else {
$method = MYSQLI_USE_RESULT;
}
 
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION < 40100) {
$query = PMA_convert_charset($query);
}
return mysqli_query($link, $query, $method);
// From the PHP manual:
// "note: returns TRUE on success or FALSE on failure. For SELECT,
// SHOW, DESCRIBE or EXPLAIN, mysqli_query() will return a result object"
// so, do not use the return value to feed mysqli_num_rows() if it's
// a boolean
}
 
// The following function is meant for internal use only.
// Do not call it from outside this library!
function PMA_mysqli_fetch_array($result, $type = FALSE)
{
global $cfg, $allow_recoding, $charset, $convcharset;
 
if ($type != FALSE) {
$data = @mysqli_fetch_array($result, $type);
} else {
$data = @mysqli_fetch_array($result);
}
 
/* No data returned => do not touch it */
if (! $data) {
return $data;
}
 
if (!defined('PMA_MYSQL_INT_VERSION') || PMA_MYSQL_INT_VERSION >= 40100
|| !(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
/* No recoding -> return data as we got them */
return $data;
} else {
$ret = array();
$num = mysqli_num_fields($result);
if ($num > 0) {
$fields = PMA_DBI_get_fields_meta($result);
}
// sometimes, mysqli_fetch_fields() does not return results
// (as seen in PHP 5.1.0-dev), so for now, return $data unchanged
if (!$fields) {
return $data;
}
$i = 0;
for ($i = 0; $i < $num; $i++) {
if (!isset($fields[$i]->type)) {
/* No meta information available -> we guess that it should be converted */
if (isset($data[$i])) {
$ret[$i] = PMA_convert_display_charset($data[$i]);
}
if (isset($fields[$i]->name) && isset($data[$fields[$i]->name])) {
$ret[PMA_convert_display_charset($fields[$i]->name)] = PMA_convert_display_charset($data[$fields[$i]->name]);
}
} else {
/* Meta information available -> check type of field and convert it according to the type */
if (stristr($fields[$i]->type, 'BLOB') || stristr($fields[$i]->type, 'BINARY')) {
if (isset($data[$i])) {
$ret[$i] = $data[$i];
}
if (isset($data[$fields[$i]->name])) {
$ret[PMA_convert_display_charset($fields[$i]->name)] = $data[$fields[$i]->name];
}
} else {
if (isset($data[$i])) {
$ret[$i] = PMA_convert_display_charset($data[$i]);
}
if (isset($data[$fields[$i]->name])) {
$ret[PMA_convert_display_charset($fields[$i]->name)] = PMA_convert_display_charset($data[$fields[$i]->name]);
}
}
}
}
return $ret;
}
}
 
function PMA_DBI_fetch_array($result)
{
return PMA_mysqli_fetch_array($result, MYSQLI_BOTH);
}
 
function PMA_DBI_fetch_assoc($result)
{
return PMA_mysqli_fetch_array($result, MYSQLI_ASSOC);
}
 
function PMA_DBI_fetch_row($result)
{
return PMA_mysqli_fetch_array($result, MYSQLI_NUM);
}
 
/**
* Frees the memory associated with the results
*
* @param result $result,... one or more mysql result resources
*/
function PMA_DBI_free_result()
{
foreach (func_get_args() as $result) {
if (is_object($result)
&& is_a($result, 'mysqli_result')) {
mysqli_free_result($result);
}
}
}
 
/**
* Returns a string representing the type of connection used
* @uses mysqli_get_host_info()
* @uses $GLOBALS['userlink'] as default for $link
* @param resource $link mysql link
* @return string type of connection used
*/
function PMA_DBI_get_host_info($link = null)
{
if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return false;
}
}
return mysqli_get_host_info($link);
}
 
/**
* Returns the version of the MySQL protocol used
* @uses mysqli_get_proto_info()
* @uses $GLOBALS['userlink'] as default for $link
* @param resource $link mysql link
* @return integer version of the MySQL protocol used
*/
function PMA_DBI_get_proto_info( $link = null )
{
if (null === $link) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return false;
}
}
return mysqli_get_proto_info($link);
}
 
/**
* returns a string that represents the client library version
* @uses mysqli_get_client_info()
* @return string MySQL client library version
*/
function PMA_DBI_get_client_info() {
return mysqli_get_client_info();
}
 
/**
* returns last error message or false if no errors occured
*
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_convert_display_charset()
* @uses PMA_DBI_convert_message()
* @uses $GLOBALS['errno']
* @uses $GLOBALS['userlink']
* @uses $GLOBALS['strServerNotResponding']
* @uses $GLOBALS['strSocketProblem']
* @uses mysqli_errno()
* @uses mysqli_error()
* @uses mysqli_connect_errno()
* @uses mysqli_connect_error()
* @uses defined()
* @param resource $link mysql link
* @return string|boolean $error or false
*/
function PMA_DBI_getError($link = null)
{
unset($GLOBALS['errno']);
 
if (null === $link && isset($GLOBALS['userlink'])) {
$link =& $GLOBALS['userlink'];
// Do not stop now. We still can get the error code
// with mysqli_connect_errno()
// } else {
// return false;
}
 
if (null !== $link) {
$error_number = mysqli_errno($link);
$error_message = mysqli_error($link);
} else {
$error_number = mysqli_connect_errno();
$error_message = mysqli_connect_error();
}
if (0 == $error_number) {
return false;
}
 
// keep the error number for further check after the call to PMA_DBI_getError()
$GLOBALS['errno'] = $error_number;
 
if (! empty($error_message)) {
$error_message = PMA_DBI_convert_message($error_message);
}
 
if ($error_number == 2002) {
$error = '#' . ((string) $error_number) . ' - ' . $GLOBALS['strServerNotResponding'] . ' ' . $GLOBALS['strSocketProblem'];
} elseif (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 40100) {
$error = '#' . ((string) $error_number) . ' - ' . $error_message;
} else {
$error = '#' . ((string) $error_number) . ' - ' . PMA_convert_display_charset($error_message);
}
return $error;
}
 
function PMA_DBI_close($link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
return @mysqli_close($link);
}
 
function PMA_DBI_num_rows($result)
{
// see the note for PMA_DBI_try_query();
if (!is_bool($result)) {
return @mysqli_num_rows($result);
} else {
return 0;
}
}
 
function PMA_DBI_insert_id($link = '')
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
return mysqli_insert_id($link);
}
 
function PMA_DBI_affected_rows($link = null)
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
return mysqli_affected_rows($link);
}
 
function PMA_DBI_get_fields_meta($result)
{
// Build an associative array for a type look up
$typeAr = Array();
$typeAr[MYSQLI_TYPE_DECIMAL] = 'real';
$typeAr[MYSQLI_TYPE_NEWDECIMAL] = 'real';
$typeAr[MYSQLI_TYPE_BIT] = 'bool';
$typeAr[MYSQLI_TYPE_TINY] = 'int';
$typeAr[MYSQLI_TYPE_SHORT] = 'int';
$typeAr[MYSQLI_TYPE_LONG] = 'int';
$typeAr[MYSQLI_TYPE_FLOAT] = 'real';
$typeAr[MYSQLI_TYPE_DOUBLE] = 'real';
$typeAr[MYSQLI_TYPE_NULL] = 'null';
$typeAr[MYSQLI_TYPE_TIMESTAMP] = 'timestamp';
$typeAr[MYSQLI_TYPE_LONGLONG] = 'int';
$typeAr[MYSQLI_TYPE_INT24] = 'int';
$typeAr[MYSQLI_TYPE_DATE] = 'date';
$typeAr[MYSQLI_TYPE_TIME] = 'time';
$typeAr[MYSQLI_TYPE_DATETIME] = 'datetime';
$typeAr[MYSQLI_TYPE_YEAR] = 'year';
$typeAr[MYSQLI_TYPE_NEWDATE] = 'date';
$typeAr[MYSQLI_TYPE_ENUM] = 'unknown';
$typeAr[MYSQLI_TYPE_SET] = 'unknown';
$typeAr[MYSQLI_TYPE_TINY_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_MEDIUM_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_LONG_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_VAR_STRING] = 'string';
$typeAr[MYSQLI_TYPE_STRING] = 'string';
$typeAr[MYSQLI_TYPE_CHAR] = 'string';
$typeAr[MYSQLI_TYPE_GEOMETRY] = 'unknown';
 
$fields = mysqli_fetch_fields($result);
 
// this happens sometimes (seen under MySQL 4.0.25)
if (!is_array($fields)) {
return FALSE;
}
 
foreach ($fields as $k => $field) {
$fields[$k]->type = $typeAr[$fields[$k]->type];
$fields[$k]->flags = PMA_DBI_field_flags($result, $k);
 
// Enhance the field objects for mysql-extension compatibilty
$flags = explode(' ', $fields[$k]->flags);
array_unshift($flags, 'dummy');
$fields[$k]->multiple_key = (int)(array_search('multiple_key', $flags, true) > 0);
$fields[$k]->primary_key = (int)(array_search('primary_key', $flags, true) > 0);
$fields[$k]->unique_key = (int)(array_search('unique_key', $flags, true) > 0);
$fields[$k]->not_null = (int)(array_search('not_null', $flags, true) > 0);
$fields[$k]->unsigned = (int)(array_search('unsigned', $flags, true) > 0);
$fields[$k]->zerofill = (int)(array_search('zerofill', $flags, true) > 0);
$fields[$k]->numeric = (int)(array_search('num', $flags, true) > 0);
$fields[$k]->blob = (int)(array_search('blob', $flags, true) > 0);
}
return $fields;
}
 
function PMA_DBI_num_fields($result)
{
return mysqli_num_fields($result);
}
 
function PMA_DBI_field_len($result, $i)
{
$info = mysqli_fetch_field_direct($result, $i);
// stdClass::$length will be integrated in
// mysqli-ext when mysql4.1 has been released.
return @$info->length;
}
 
function PMA_DBI_field_name($result, $i)
{
$info = mysqli_fetch_field_direct($result, $i);
return $info->name;
}
 
function PMA_DBI_field_flags($result, $i)
{
$f = mysqli_fetch_field_direct($result, $i);
$f = $f->flags;
$flags = '';
if ($f & UNIQUE_FLAG) { $flags .= 'unique ';}
if ($f & NUM_FLAG) { $flags .= 'num ';}
if ($f & PART_KEY_FLAG) { $flags .= 'part_key ';}
if ($f & SET_FLAG) { $flags .= 'set ';}
if ($f & TIMESTAMP_FLAG) { $flags .= 'timestamp ';}
if ($f & AUTO_INCREMENT_FLAG) { $flags .= 'auto_increment ';}
if ($f & ENUM_FLAG) { $flags .= 'enum ';}
if ($f & BINARY_FLAG) { $flags .= 'binary ';}
if ($f & ZEROFILL_FLAG) { $flags .= 'zerofill ';}
if ($f & UNSIGNED_FLAG) { $flags .= 'unsigned ';}
if ($f & BLOB_FLAG) { $flags .= 'blob ';}
if ($f & MULTIPLE_KEY_FLAG) { $flags .= 'multiple_key ';}
if ($f & UNIQUE_KEY_FLAG) { $flags .= 'unique_key ';}
if ($f & PRI_KEY_FLAG) { $flags .= 'primary_key ';}
if ($f & NOT_NULL_FLAG) { $flags .= 'not_null ';}
return PMA_convert_display_charset(trim($flags));
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/display_create_database.lib.php
0,0 → 1,35
<?php
/* $Id: display_create_database.lib.php,v 1.5 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// Displays form for creating database (if user has privileges for that)
 
require_once('./libraries/check_user_privileges.lib.php');
 
if ($is_create_db_priv) {
// The user is allowed to create a db
?>
<form method="post" action="db_create.php"><b>
<?php echo '<label for="text_create_db">' . $strCreateNewDatabase . '</label>&nbsp;' . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE'); ?></b><br />
<?php echo PMA_generate_common_hidden_inputs('', '', 5); ?>
<input type="hidden" name="reload" value="1" />
<input type="text" name="db" value="<?php echo $db_to_create; ?>" maxlength="64" class="textfield" id="text_create_db"/>
<?php
if (PMA_MYSQL_INT_VERSION >= 40101) {
require_once('./libraries/mysql_charsets.lib.php');
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, TRUE, 5);
}
?>
<input type="submit" value="<?php echo $strCreate; ?>" id="buttonGo" />
</form>
<?php
} else {
?>
<!-- db creation no privileges message -->
<b><?php echo $strCreateNewDatabase . ':&nbsp;' . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE'); ?></b><br />
<?php
echo '<span class="noPrivileges">'
. ($cfg['ErrorIconic'] ? '<img src="' . $pmaThemeImage . 's_error2.png" width="11" height="11" hspace="2" border="0" align="middle" />' : '')
. '' . $strNoPrivileges .'</span>';
} // end create db form or message
?>
/Web/Maintenance/phpMyAdmin/libraries/display_create_table.lib.php
0,0 → 1,126
<?php
/* $Id: display_create_table.lib.php,v 1.9 2006/01/19 17:12:12 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// Displays form for creating a table (if user has privileges for that)
 
require_once('./libraries/check_user_privileges.lib.php');
 
// for MySQL >= 4.1.0, we should be able to detect if user has a CREATE
// privilege by looking at SHOW GRANTS output;
// for < 4.1.0, it could be more difficult because the logic tries to
// detect the current host and it might be expressed in many ways; also
// on a shared server, the user might be unable to define a controluser
// that has the proper rights to the "mysql" db;
// so we give up and assume that user has the right to create a table
//
// Note: in this case we could even skip the following "foreach" logic
 
// Addendum, 2006-01-19: ok, I give up. We got some reports about servers
// where the hostname field in mysql.user is not the same as the one
// in mysql.db for a user. In this case, SHOW GRANTS does not return
// the db-specific privileges. And probably, those users are on a shared
// server, so can't set up a control user with rights to the "mysql" db.
// We cannot reliably detect the db-specific privileges, so no more
// warnings about the lack of privileges for CREATE TABLE. Tested
// on MySQL 5.0.18.
 
$is_create_table_priv = true;
 
/*
if (PMA_MYSQL_INT_VERSION >= 40100) {
$is_create_table_priv = false;
} else {
$is_create_table_priv = true;
}
 
foreach ( $dbs_where_create_table_allowed as $allowed_db ) {
 
// if we find the exact db name, we stop here
if ($allowed_db == $db) {
$is_create_table_priv = TRUE;
break;
}
 
// '*' indicates a global CREATE priv
if ($allowed_db == '*') {
$is_create_table_priv = TRUE;
break;
}
 
if (ereg('%|_', $allowed_db)) {
// take care of wildcards and escaped wildcards,
// transforming them into regexp patterns
$max_position = strlen($allowed_db) - 1;
$i = 0;
$pattern = '';
while ($i <= $max_position) {
if ($allowed_db[$i] == '\\'){
if ($i < $max_position - 1 && $allowed_db[$i+1] == '_'){
$chunk = '_';
$i++;
} elseif ($i < $max_position - 1 && $allowed_db[$i+1] == '%'){
$chunk = '%';
$i++;
} else {
$chunk = $allowed_db[$i];
}
} elseif ($allowed_db[$i] == '_'){
$chunk = '.';
} elseif ($allowed_db[$i] == '%'){
$chunk = '(.)*';
} else {
$chunk = $allowed_db[$i];
}
$pattern .= $chunk;
$i++;
} // end while
unset($i, $max_position, $chunk);
 
$matches = '';
if (preg_match('@' .$pattern . '@i', $db, $matches)) {
if ($matches[0] == $db) {
$is_create_table_priv = TRUE;
break;
//TODO: maybe receive in $allowed_db also the db names
// on which we cannot CREATE, and check them
// in this foreach, because if a user is allowed to CREATE
// on db foo% but forbidden on db foobar, he should not
// see the Create table dialog
}
}
}
} // end foreach
unset($i, $max_position, $chunk, $pattern);
*/
?>
<form method="post" action="tbl_create.php"
onsubmit="return (emptyFormElements(this, 'table') &amp;&amp; checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldCount']); ?>', 1))">
<fieldset>
<legend>
<?php
if ( $GLOBALS['cfg']['PropertiesIconic'] ) {
echo '<img class="icon" src="' . $pmaThemeImage . 'b_newtbl.png" width="16" height="16" alt="" />';
}
echo sprintf( $strCreateNewTable, PMA_getDbLink() );
?>
</legend>
<?php if ( $is_create_table_priv ) { ?>
<?php echo PMA_generate_common_hidden_inputs( $db ); ?>
<div class="formelement">
<?php echo $strName; ?>:
<input type="text" name="table" maxlength="64" size="30" />
</div>
<div class="formelement">
<?php echo $strNumberOfFields; ?>:
<input type="text" name="num_fields" size="2" />
</div>
<div class="clearfloat"></div>
</fieldset>
<fieldset class="tblFooters">
<input type="submit" value="<?php echo $strGo; ?>" />
<?php } else { ?>
<div class="error"><?php echo $strNoPrivileges; ?></div>
<?php } // end if else ?>
</fieldset>
</form>
/Web/Maintenance/phpMyAdmin/libraries/display_export.lib.php
0,0 → 1,935
<?php
/* $Id: display_export.lib.php,v 2.47.2.1 2006/06/15 20:22:56 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// Get relations & co. status
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
 
// Check if we have native MS Excel export using PEAR class Spreadsheet_Excel_Writer
if (!empty($GLOBALS['cfg']['TempDir'])) {
@include_once('Spreadsheet/Excel/Writer.php');
if (class_exists('Spreadsheet_Excel_Writer')) {
$xls = TRUE;
} else {
$xls = FALSE;
}
} else {
$xls = FALSE;
}
 
function PMA_exportCheckboxCheck($str) {
if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) {
echo ' checked="checked"';
}
}
 
function PMA_exportIsActive($what, $val) {
if (isset($GLOBALS['cfg']['Export'][$what]) && $GLOBALS['cfg']['Export'][$what] == $val) {
echo ' checked="checked"';
}
}
 
?>
<form method="post" action="export.php" name="dump">
 
<?php
$hide_structure = false;
$hide_sql = false;
$hide_xml = (bool) ! (isset($db) && strlen($db));
if ($export_type == 'server') {
echo PMA_generate_common_hidden_inputs('', '', 1);
} elseif ($export_type == 'database') {
echo PMA_generate_common_hidden_inputs($db, '', 1);
} else {
echo PMA_generate_common_hidden_inputs($db, $table, 1);
if (!isset($single_table)) {
$hide_structure = true;
$hide_sql = true;
} else {
// just to keep this value for possible next display of this form after saving on server
echo '<input type="hidden" name="single_table" value="TRUE" />' . "\n";
}
}
echo '<input type="hidden" name="export_type" value="' . $export_type . '" />' . "\n";
 
if (isset($sql_query)) {
echo '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n";
}
?>
 
<script type="text/javascript" language="javascript">
//<![CDATA[
function hide_them_all() {
document.getElementById("csv_options").style.display = 'none';
document.getElementById("excel_options").style.display = 'none';
document.getElementById("latex_options").style.display = 'none';
document.getElementById("htmlexcel_options").style.display = 'none';
document.getElementById("htmlword_options").style.display = 'none';
document.getElementById("pdf_options").style.display = 'none';
<?php if ($xls) { ?>
document.getElementById("xls_options").style.display = 'none';
<?php } ?>
<?php if (!$hide_sql) { ?>
document.getElementById("sql_options").style.display = 'none';
<?php } ?>
document.getElementById("none_options").style.display = 'none';
}
 
function show_checked_option() {
hide_them_all();
if (document.getElementById('radio_dump_latex').checked) {
document.getElementById('latex_options').style.display = 'block';
} else if (document.getElementById('radio_dump_htmlexcel').checked) {
document.getElementById('htmlexcel_options').style.display = 'block';
} else if (document.getElementById('radio_dump_pdf').checked) {
document.getElementById('pdf_options').style.display = 'block';
} else if (document.getElementById('radio_dump_htmlword').checked) {
document.getElementById('htmlword_options').style.display = 'block';
<?php if ($xls) { ?>
} else if (document.getElementById('radio_dump_xls').checked) {
document.getElementById('xls_options').style.display = 'block';
<?php } ?>
<?php if (!$hide_sql) { ?>
} else if (document.getElementById('radio_dump_sql').checked) {
document.getElementById('sql_options').style.display = 'block';
<?php } ?>
<?php if (!$hide_xml) { ?>
} else if (document.getElementById('radio_dump_xml').checked) {
document.getElementById('none_options').style.display = 'block';
<?php } ?>
} else if (document.getElementById('radio_dump_csv').checked) {
document.getElementById('csv_options').style.display = 'block';
} else if (document.getElementById('radio_dump_excel').checked) {
document.getElementById('excel_options').style.display = 'block';
} else {
if (document.getElementById('radio_dump_sql')) {
document.getElementById('radio_dump_sql').checked = true;
document.getElementById('sql_options').style.display = 'block';
} else if (document.getElementById('radio_dump_csv')) {
document.getElementById('radio_dump_csv').checked = true;
document.getElementById('csv_options').style.display = 'block';
} else {
document.getElementById('none_options').style.display = 'block';
}
}
}
//]]>
</script>
 
<fieldset id="fieldsetexport">
<legend><?php echo $export_page_title; ?></legend>
 
<?php
/*
* this table is needed to fix rendering in Opera <= 9 and Safari <= 2
* normaly just the two fieldset would have float: left
*/
?>
<table><tr><td>
 
<div id="div_container_exportoptions">
<fieldset id="exportoptions">
<legend><?php echo $strExport; ?></legend>
 
<?php if ( ! empty( $multi_values ) ) { ?>
<div class="formelementrow">
<?php echo $multi_values; ?>
</div>
<?php } ?>
 
<?php if ( ! $hide_sql ) { /* SQL */ ?>
<div class="formelementrow">
<input type="radio" name="what" value="sql" id="radio_dump_sql"
onclick="
if (this.checked) {
hide_them_all();
document.getElementById('sql_options').style.display = 'block';
}; return true"
<?php PMA_exportIsActive('format', 'sql'); ?> />
<label for="radio_dump_sql"><?php echo $strSQL; ?></label>
</div>
<?php } /* LaTeX table */ ?>
<div class="formelementrow">
<input type="radio" name="what" value="latex" id="radio_dump_latex"
onclick="
if (this.checked) {
hide_them_all();
document.getElementById('latex_options').style.display = 'block';
}; return true"
<?php PMA_exportIsActive('format', 'latex'); ?> />
<label for="radio_dump_latex"><?php echo $strLaTeX; ?></label>
</div>
<?php /* PDF */ ?>
<div class="formelementrow">
<input type="radio" name="what" value="pdf" id="radio_dump_pdf"
onclick="
if (this.checked) {
hide_them_all();
document.getElementById('pdf_options').style.display = 'block';
}; return true"
<?php PMA_exportIsActive('format', 'pdf'); ?> />
<label for="radio_dump_pdf"><?php echo $strPDF; ?></label>
</div>
<?php /* HTML Excel */ ?>
<div class="formelementrow">
<input type="radio" name="what" value="htmlexcel" id="radio_dump_htmlexcel"
onclick="
if (this.checked) {
hide_them_all();
document.getElementById('htmlexcel_options').style.display = 'block';
document.getElementById('checkbox_dump_asfile').checked = true;
}; return true"
<?php PMA_exportIsActive('format', 'htmlexcel'); ?> />
<label for="radio_dump_htmlexcel"><?php echo $strHTMLExcel; ?></label>
</div>
<?php /* HTML Word */ ?>
<div class="formelementrow">
<input type="radio" name="what" value="htmlword" id="radio_dump_htmlword"
onclick="
if (this.checked) {
hide_them_all();
document.getElementById('htmlword_options').style.display = 'block';
document.getElementById('checkbox_dump_asfile').checked = true;
}; return true"
<?php PMA_exportIsActive('format', 'htmlword'); ?> />
<label for="radio_dump_htmlword"><?php echo $strHTMLWord; ?></label>
</div>
<?php if ($xls) { /* Native Excel */ ?>
<div class="formelementrow">
<input type="radio" name="what" value="xls" id="radio_dump_xls"
onclick="
if (this.checked) {
hide_them_all();
document.getElementById('xls_options').style.display = 'block';
document.getElementById('checkbox_dump_asfile').checked = true;
}; return true"
<?php PMA_exportIsActive('format', 'xls'); ?> />
<label for="radio_dump_xls"><?php echo $strStrucNativeExcel; ?></label>
</div>
<?php } /* Excel CSV */ ?>
<div class="formelementrow">
<input type="radio" name="what" value="excel" id="radio_dump_excel"
onclick="
if (this.checked) {
hide_them_all();
document.getElementById('excel_options').style.display = 'block';
}; return true"
<?php PMA_exportIsActive('format', 'excel'); ?> />
<label for="radio_dump_excel"><?php echo $strStrucExcelCSV; ?></label>
</div>
<?php /* General CSV */ ?>
<div class="formelementrow">
<input type="radio" name="what" value="csv" id="radio_dump_csv"
onclick="if
(this.checked) {
hide_them_all();
document.getElementById('csv_options').style.display = 'block';
}; return true"
<?php PMA_exportIsActive('format', 'csv'); ?> />
<label for="radio_dump_csv"><?php echo $strStrucCSV;?></label>
</div>
<?php if (!$hide_xml) { /* XML */ ?>
<div class="formelementrow">
<input type="radio" name="what" value="xml" id="radio_dump_xml"
onclick="
if (this.checked) {
hide_them_all();
document.getElementById('none_options').style.display = 'block';
}; return true"
<?php PMA_exportIsActive('format', 'xml'); ?> />
<label for="radio_dump_xml"><?php echo $strXML; ?></label>
</div>
<?php } ?>
 
</fieldset>
</div>
 
</td><td>
 
<div id="div_container_sub_exportoptions">
<?php if ( ! $hide_sql ) { /* SQL options */ ?>
<fieldset id="sql_options">
<legend>
<?php
echo $strSQLOptions;
$goto_documentation = '<a href="./Documentation.html#faqexport" target="documentation">';
echo ( $cfg['ReplaceHelpImg'] ? '' : '(' )
. $goto_documentation
. ( $cfg['ReplaceHelpImg'] ?
'<img class="icon" src="' . $pmaThemeImage . 'b_help.png" alt="'
.$strDocu . '" width="11" height="11" />'
: $strDocu )
. '</a>' . ($cfg['ReplaceHelpImg'] ? '' : ')');
?>
</legend>
<div class="formelementrow">
<?php echo $strAddHeaderComment; ?>:<br />
<input type="text" name="header_comment" size="30"
value="<?php echo $cfg['Export']['sql_header_comment']; ?>" />
</div>
 
<div class="formelementrow">
<input type="checkbox" name="use_transaction" value="yes"
id="checkbox_use_transaction"
<?php PMA_exportCheckboxCheck('sql_use_transaction'); ?> />
<label for="checkbox_use_transaction">
<?php echo $strEncloseInTransaction; ?></label>
</div>
 
<div class="formelementrow">
<input type="checkbox" name="disable_fk" value="yes"
id="checkbox_disable_fk"
<?php PMA_exportCheckboxCheck('sql_disable_fk'); ?> />
<label for="checkbox_disable_fk">
<?php echo $strDisableForeignChecks; ?></label>
</div>
<?php if (PMA_MYSQL_INT_VERSION >= 40100) { ?>
<label for="select_sql_compat">
<?php echo $strSQLExportCompatibility; ?>:</label>
<select name="sql_compat" id="select_sql_compat">
<?php
$compats = array('NONE');
if (PMA_MYSQL_INT_VERSION >= 40101) {
$compats[] = 'ANSI';
$compats[] = 'DB2';
$compats[] = 'MAXDB';
$compats[] = 'MYSQL323';
$compats[] = 'MYSQL40';
$compats[] = 'MSSQL';
$compats[] = 'ORACLE';
$compats[] = 'POSTGRESQL';
if (PMA_MYSQL_INT_VERSION >= 50001) {
$compats[] = 'TRADITIONAL';
}
}
foreach ($compats as $x) {
echo '<option value="' . $x . '"'
. ($cfg['Export']['sql_compat'] == $x ? ' selected="selected"' : '' )
. '>' . $x . '</option>' . "\n";
}
?>
</select>
<?php echo PMA_showMySQLDocu('manual_MySQL_Database_Administration',
'Server_SQL_mode') . "\n";
} ?>
<?php if ( $export_type == 'server' ) { /* For databases */ ?>
<fieldset>
<legend><?php echo $strDatabaseExportOptions; ?></legend>
<input type="checkbox" name="drop_database" value="yes"
id="checkbox_drop_database"
<?php PMA_exportCheckboxCheck('sql_drop_database'); ?> />
<label for="checkbox_drop_database">
<?php echo $strAddDropDatabase; ?></label>
</fieldset>
<?php } if ( ! $hide_structure ) { /* SQL structure */ ?>
<fieldset>
<legend>
<input type="checkbox" name="sql_structure" value="structure"
id="checkbox_sql_structure"
<?php PMA_exportCheckboxCheck('sql_structure'); ?>
onclick="
if (!this.checked &amp;&amp; !document.getElementById('checkbox_sql_data').checked)
return false;
else return true;" />
<label for="checkbox_sql_structure">
<?php echo $strStructure; ?></label>
</legend>
 
<input type="checkbox" name="drop" value="1" id="checkbox_dump_drop"
<?php PMA_exportCheckboxCheck('sql_drop_table'); ?> />
<label for="checkbox_dump_drop">
<?php echo $strStrucDrop; ?></label><br />
 
<input type="checkbox" name="if_not_exists" value="1"
id="checkbox_dump_if_not_exists"
<?php PMA_exportCheckboxCheck('sql_if_not_exists'); ?> />
<label for="checkbox_dump_if_not_exists">
<?php echo $strAddIfNotExists; ?></label><br />
 
<input type="checkbox" name="sql_auto_increment" value="1"
id="checkbox_auto_increment"
<?php PMA_exportCheckboxCheck('sql_auto_increment'); ?> />
<label for="checkbox_auto_increment">
<?php echo $strAddAutoIncrement; ?></label><br />
 
<input type="checkbox" name="use_backquotes" value="1"
id="checkbox_dump_use_backquotes"
<?php PMA_exportCheckboxCheck('sql_backquotes'); ?> />
<label for="checkbox_dump_use_backquotes">
<?php echo $strUseBackquotes; ?></label><br />
 
<b><?php echo $strAddIntoComments; ?>:</b><br />
 
<input type="checkbox" name="sql_dates" value="yes"
id="checkbox_sql_dates"
<?php PMA_exportCheckboxCheck('sql_dates'); ?> />
<label for="checkbox_sql_dates">
<?php echo $strCreationDates; ?></label><br />
<?php if (!empty($cfgRelation['relation'])) { ?>
<input type="checkbox" name="sql_relation" value="yes"
id="checkbox_sql_use_relation"
<?php PMA_exportCheckboxCheck('sql_relation'); ?> />
<label for="checkbox_sql_use_relation"><?php echo $strRelations; ?></label><br />
<?php } if (!empty($cfgRelation['commwork']) && PMA_MYSQL_INT_VERSION < 40100) { ?>
<input type="checkbox" name="sql_comments" value="yes"
id="checkbox_sql_use_comments"
<?php PMA_exportCheckboxCheck('sql_comments'); ?> />
<label for="checkbox_sql_use_comments"><?php echo $strComments; ?></label><br />
<?php } if ($cfgRelation['mimework']) { ?>
<input type="checkbox" name="sql_mime" value="yes"
id="checkbox_sql_use_mime"
<?php PMA_exportCheckboxCheck('sql_mime'); ?> />
<label for="checkbox_sql_use_mime"><?php echo $strMIME_MIMEtype; ?></label><br />
<?php } ?>
</fieldset>
<?php
} /* end SQL STRUCTURE */
/* SQL data */
?>
<fieldset>
<legend>
<input type="checkbox" name="sql_data" value="data"
id="checkbox_sql_data" <?php PMA_exportCheckboxCheck('sql_data'); ?>
onclick="
if (!this.checked &amp;&amp; (!document.getElementById('checkbox_sql_structure') || !document.getElementById('checkbox_sql_structure').checked))
return false;
else return true;" />
<label for="checkbox_sql_data">
<?php echo $strData; ?></label>
</legend>
<input type="checkbox" name="showcolumns" value="yes"
id="checkbox_dump_showcolumns"
<?php PMA_exportCheckboxCheck('sql_columns'); ?> />
<label for="checkbox_dump_showcolumns">
<?php echo $strCompleteInserts; ?></label><br />
 
<input type="checkbox" name="extended_ins" value="yes"
id="checkbox_dump_extended_ins"
<?php PMA_exportCheckboxCheck('sql_extended'); ?> />
<label for="checkbox_dump_extended_ins">
<?php echo $strExtendedInserts; ?></label><br />
 
<label for="input_max_query_size">
<?php echo $strMaximalQueryLength; ?>:</label>
<input type="text" name="max_query_size" id="input_max_query_size"
value="<?php echo $cfg['Export']['sql_max_query_size'];?>" /><br />
 
<input type="checkbox" name="delayed" value="yes"
id="checkbox_dump_delayed"
<?php PMA_exportCheckboxCheck('sql_delayed'); ?> />
<label for="checkbox_dump_delayed">
<?php echo $strDelayedInserts; ?></label><br />
 
<input type="checkbox" name="sql_ignore" value="yes"
id="checkbox_dump_ignore"
<?php PMA_exportCheckboxCheck('sql_ignore'); ?> />
<label for="checkbox_dump_ignore">
<?php echo $strIgnoreInserts; ?></label><br />
 
<input type="checkbox" name="hexforbinary" value="yes"
id="checkbox_hexforbinary"
<?php PMA_exportCheckboxCheck('sql_hex_for_binary'); ?> />
<label for="checkbox_hexforbinary">
<?php echo $strHexForBinary; ?></label><br />
 
<label for="select_sql_type">
<?php echo $strSQLExportType; ?>:</label>
<select name="sql_type" id="select_sql_type">
<option value="insert"<?php echo $cfg['Export']['sql_type'] == 'insert' ? ' selected="selected"' : ''; ?>>INSERT</option>
<option value="update"<?php echo $cfg['Export']['sql_type'] == 'update' ? ' selected="selected"' : ''; ?>>UPDATE</option>
<option value="replace"<?php echo $cfg['Export']['sql_type'] == 'replace' ? ' selected="selected"' : ''; ?>>REPLACE</option>
</select>
</fieldset>
</fieldset>
<?php
} // end SQL-OPTIONS
?>
 
<?php /* LaTeX options */ ?>
<fieldset id="latex_options">
<legend><?php echo $strLaTeXOptions; ?></legend>
 
<div class="formelementrow">
<input type="checkbox" name="latex_caption" value="yes"
id="checkbox_latex_show_caption"
<?php PMA_exportCheckboxCheck('latex_caption'); ?> />
<label for="checkbox_latex_show_caption">
<?php echo $strLatexIncludeCaption; ?></label>
</div>
 
<?php if ( ! $hide_structure ) { /* LaTeX structure */ ?>
<fieldset>
<legend>
<input type="checkbox" name="latex_structure" value="structure"
id="checkbox_latex_structure"
<?php PMA_exportCheckboxCheck('latex_structure'); ?>
onclick="
if (!this.checked &amp;&amp; !document.getElementById('checkbox_latex_data').checked)
return false;
else return true;" />
<label for="checkbox_latex_structure">
<?php echo $strStructure; ?></label>
</legend>
 
<table>
<tr><td><label for="latex_structure_caption">
<?php echo $strLatexCaption; ?></label></td>
<td><input type="text" name="latex_structure_caption" size="30"
value="<?php echo $strLatexStructure; ?>"
id="latex_structure_caption" />
</td>
</tr>
<tr><td><label for="latex_structure_continued_caption">
<?php echo $strLatexContinuedCaption; ?></label></td>
<td><input type="text" name="latex_structure_continued_caption"
value="<?php echo $strLatexStructure . ' ' . $strLatexContinued; ?>"
size="30" id="latex_structure_continued_caption" />
</td>
</tr>
<tr><td><label for="latex_structure_label">
<?php echo $strLatexLabel; ?></label></td>
<td><input type="text" name="latex_structure_label" size="30"
value="<?php echo $cfg['Export']['latex_structure_label']; ?>"
id="latex_structure_label" />
</td>
</tr>
</table>
 
<?php if ( ! empty( $cfgRelation['relation']) ) { ?>
<input type="checkbox" name="latex_relation" value="yes"
id="checkbox_latex_use_relation"
<?php PMA_exportCheckboxCheck('latex_relation'); ?> />
<label for="checkbox_latex_use_relation">
<?php echo $strRelations; ?></label><br />
<?php } if ( $cfgRelation['commwork'] ) { ?>
<input type="checkbox" name="latex_comments" value="yes"
id="checkbox_latex_use_comments"
<?php PMA_exportCheckboxCheck('latex_comments'); ?> />
<label for="checkbox_latex_use_comments">
<?php echo $strComments; ?></label><br />
<?php } if ( $cfgRelation['mimework'] ) { ?>
<input type="checkbox" name="latex_mime" value="yes"
id="checkbox_latex_use_mime"
<?php PMA_exportCheckboxCheck('latex_mime'); ?> />
<label for="checkbox_latex_use_mime">
<?php echo $strMIME_MIMEtype; ?></label><br />
<?php } ?>
</fieldset>
<?php
} // end LaTeX STRUCTURE
/* LaTeX data */
?>
<fieldset>
<legend>
<input type="checkbox" name="latex_data" value="data"
id="checkbox_latex_data"
<?php PMA_exportCheckboxCheck('latex_data'); ?>
onclick="
if (!this.checked &amp;&amp; (!document.getElementById('checkbox_latex_structure') || !document.getElementById('checkbox_latex_structure').checked))
return false;
else return true;" />
<label for="checkbox_latex_data">
<?php echo $strData; ?></label>
</legend>
<input type="checkbox" name="latex_showcolumns" value="yes"
id="ch_latex_showcolumns"
<?php PMA_exportCheckboxCheck('latex_columns'); ?> />
<label for="ch_latex_showcolumns">
<?php echo $strColumnNames; ?></label><br />
<table>
<tr><td><label for="latex_data_caption">
<?php echo $strLatexCaption; ?></label></td>
<td><input type="text" name="latex_data_caption" size="30"
value="<?php echo $strLatexContent; ?>"
id="latex_data_caption" />
</td>
</tr>
<tr><td><label for="latex_data_continued_caption">
<?php echo $strLatexContinuedCaption; ?></label></td>
<td><input type="text" name="latex_data_continued_caption" size="30"
value="<?php echo $strLatexContent . ' ' . $strLatexContinued; ?>"
id="latex_data_continued_caption" />
</td>
</tr>
<tr><td><label for="latex_data_label">
<?php echo $strLatexLabel; ?></label></td>
<td><input type="text" name="latex_data_label" size="30"
value="<?php echo $cfg['Export']['latex_data_label']; ?>"
id="latex_data_label" />
</td>
</tr>
<tr><td><label for="latex_replace_null">
<?php echo $strReplaceNULLBy; ?></label></td>
<td><input type="text" name="latex_replace_null" size="20"
value="<?php echo $cfg['Export']['latex_null']; ?>"
id="latex_replace_null" />
</td>
</tr>
</table>
</fieldset>
</fieldset>
 
<?php /* CSV options */ ?>
<fieldset id="csv_options">
<input type="hidden" name="csv_data" value="csv_data" />
<legend><?php echo $strCSVOptions; ?></legend>
 
<table>
<tr><td><label for="export_separator">
<?php echo $strFieldsTerminatedBy; ?></label></td>
<td><input type="text" name="export_separator" size="2"
id="export_separator"
value="<?php echo $cfg['Export']['csv_separator']; ?>" />
</td>
</tr>
<tr><td><label for="enclosed">
<?php echo $strFieldsEnclosedBy; ?></label></td>
<td><input type="text" name="enclosed" size="2"
id="enclosed"
value="<?php echo $cfg['Export']['csv_enclosed']; ?>" />
</td>
</tr>
<tr><td><label for="escaped">
<?php echo $strFieldsEscapedBy; ?></label></td>
<td><input type="text" name="escaped" size="2"
id="escaped"
value="<?php echo $cfg['Export']['csv_escaped']; ?>" />
</td>
</tr>
<tr><td><label for="add_character">
<?php echo $strLinesTerminatedBy; ?></label></td>
<td><input type="text" name="add_character" size="2"
id="add_character"
value="<?php if ($cfg['Export']['csv_terminated'] == 'AUTO') echo ((PMA_whichCrlf() == "\n") ? '\n' : '\r\n'); else echo $cfg['Export']['csv_terminated']; ?>" />
</td>
</tr>
<tr><td><label for="csv_replace_null">
<?php echo $strReplaceNULLBy; ?></label></td>
<td><input type="text" name="csv_replace_null" size="20"
id="csv_replace_null"
value="<?php echo $cfg['Export']['csv_null']; ?>" />
</td>
</tr>
</table>
<input type="checkbox" name="showcsvnames" value="yes"
id="checkbox_dump_showcsvnames"
<?php PMA_exportCheckboxCheck('csv_columns'); ?> />
<label for="checkbox_dump_showcsvnames">
<?php echo $strPutColNames; ?></label>
</fieldset>
 
<?php /* Excel options */ ?>
<fieldset id="excel_options">
<input type="hidden" name="excel_data" value="excel_data" />
<legend><?php echo $strExcelOptions; ?></legend>
 
<table>
<tr><td><label for="excel_replace_null">
<?php echo $strReplaceNULLBy; ?></label>
</td>
<td><input type="text" name="excel_replace_null" size="20"
id="excel_replace_null"
value="<?php echo $cfg['Export']['excel_null']; ?>" />
</td>
</tr>
<tr><td><label for="select_excel_edition">
<?php echo $strExcelEdition; ?>:
</label>
</td>
<td><select name="excel_edition" id="select_excel_edition">
<option value="win"<?php echo $cfg['Export']['excel_edition'] == 'win' ? ' selected="selected"' : ''; ?>>Windows</option>
<option value="mac"<?php echo $cfg['Export']['excel_edition'] == 'mac' ? ' selected="selected"' : ''; ?>>Excel 2003 / Macintosh</option>
</select>
</td>
</tr>
</table>
 
<input type="checkbox" name="showexcelnames" value="yes"
id="checkbox_dump_showexcelnames"
<?php PMA_exportCheckboxCheck('excel_columns'); ?> />
<label for="checkbox_dump_showexcelnames">
<?php echo $strPutColNames; ?></label>
</fieldset>
 
<?php /* HTML Excel options */ ?>
<fieldset id="htmlexcel_options">
<input type="hidden" name="htmlexcel_data" value="htmlexcel_data" />
<legend><?php echo $strHTMLExcelOptions; ?></legend>
 
<div class="formelementrow">
<label for="htmlexcel_replace_null"><?php echo $strReplaceNULLBy; ?></label>
<input type="text" name="htmlexcel_replace_null" size="20"
value="<?php echo $cfg['Export']['htmlexcel_null']; ?>"
id="htmlexcel_replace_null" />
</div>
 
<div class="formelementrow">
<input type="checkbox" name="htmlexcel_shownames" value="yes"
id="checkbox_dump_htmlexcel_shownames"
<?php PMA_exportCheckboxCheck('htmlexcel_columns'); ?> />
<label for="checkbox_dump_htmlexcel_shownames">
<?php echo $strPutColNames; ?></label>
</div>
</fieldset>
 
<?php /* HTML Word options */ ?>
<fieldset id="htmlword_options">
<legend><?php echo $strHTMLWordOptions; ?></legend>
 
<div class="formelementrow">
<input type="checkbox" name="htmlword_structure" value="structure"
id="checkbox_htmlword_structure"
<?php PMA_exportCheckboxCheck('htmlword_structure'); ?>
onclick="
if (!this.checked &amp;&amp; (!document.getElementById('checkbox_htmlword_data') || !document.getElementById('checkbox_htmlword_data').checked))
return false;
else return true;" />
<label for="checkbox_htmlword_structure">
<?php echo $strStructure; ?></label>
</div>
 
<fieldset>
<legend>
<input type="checkbox" name="htmlword_data" value="data"
id="checkbox_htmlword_data"
<?php PMA_exportCheckboxCheck('htmlword_data'); ?>
onclick="
if (!this.checked &amp;&amp; (!document.getElementById('checkbox_htmlword_structure') || !document.getElementById('checkbox_htmlword_structure').checked))
return false;
else return true;" />
<label for="checkbox_htmlword_data">
<?php echo $strData; ?></label>
</legend>
 
<div class="formelementrow">
<label for="htmlword_replace_null">
<?php echo $strReplaceNULLBy; ?></label>
<input id="htmlword_replace_null" type="text" size="20"
name="htmlword_replace_null"
value="<?php echo $cfg['Export']['htmlword_null']; ?>" />
</div>
 
<div class="formelementrow">
<input type="checkbox" name="htmlword_shownames" value="yes"
id="checkbox_dump_htmlword_shownames"
<?php PMA_exportCheckboxCheck('htmlword_columns'); ?> />
<label for="checkbox_dump_htmlword_shownames">
<?php echo $strPutColNames; ?></label>
</div>
</fieldset>
</fieldset>
 
<?php if ( $xls ) { /* Native Excel options */ ?>
<fieldset id="xls_options">
<input type="hidden" name="xls_data" value="xls_data" />
<legend><?php echo $strExcelOptions; ?></legend>
 
<div class="formelementrow">
<label for="xls_replace_null"><?php echo $strReplaceNULLBy; ?></label>
<input type="text" name="xls_replace_null" size="20"
value="<?php echo $cfg['Export']['xls_null']; ?>"
id="xls_replace_null" />
</div>
 
<div class="formelementrow">
<input type="checkbox" name="xls_shownames" value="yes"
id="checkbox_dump_xls_shownames"
<?php PMA_exportCheckboxCheck('xls_columns'); ?> />
<label for="checkbox_dump_xls_shownames">
<?php echo $strPutColNames; ?></label>
</div>
</fieldset>
<?php } /* end if ( $xls ) */ ?>
 
<?php /* PDF options */ ?>
<fieldset id="pdf_options">
<input type="hidden" name="pdf_data" value="pdf_data" />
<legend><?php echo $strPDFOptions; ?></legend>
 
<div class="formelementrow">
<label for="pdf_report_title"><?php echo $strPDFReportTitle; ?></label>
<input type="text" name="pdf_report_title" size="50"
value="<?php echo $cfg['Export']['pdf_report_title']; ?>"
id="pdf_report_title" />
</div>
</fieldset>
 
<fieldset id="none_options">
<legend><?php echo $strXML; ?></legend>
<?php echo $strNoOptions; ?>
<input type="hidden" name="xml_data" value="xml_data" />
</fieldset>
 
</td></tr></table>
 
<script type="text/javascript" language="javascript">
//<![CDATA[
show_checked_option();
//]]>
</script>
 
<?php if ( isset($table) && strlen($table) && ! isset( $num_tables ) ) { ?>
<div class="formelementrow">
<?php
echo sprintf( $strDumpXRows,
'<input type="text" name="limit_to" size="5" value="'
. ( isset( $unlim_num_rows ) ? $unlim_num_rows : PMA_countRecords( $db, $table, TRUE ) )
. '" onfocus="this.select()" />',
'<input type="text" name="limit_from" value="0" size="5"'
.' onfocus="this.select()" /> ');
?>
</div>
<?php } ?>
</fieldset>
 
<fieldset>
<legend>
<input type="checkbox" name="asfile" value="sendit"
id="checkbox_dump_asfile" <?php PMA_exportCheckboxCheck('asfile'); ?> />
<label for="checkbox_dump_asfile"><?php echo $strSend; ?></label>
</legend>
 
<?php if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) { ?>
<input type="checkbox" name="onserver" value="saveit"
id="checkbox_dump_onserver"
onclick="document.getElementById('checkbox_dump_asfile').checked = true;"
<?php PMA_exportCheckboxCheck('onserver'); ?> />
<label for="checkbox_dump_onserver">
<?php echo sprintf($strSaveOnServer, htmlspecialchars(PMA_userDir($cfg['SaveDir']))); ?>
</label>,<br />
<input type="checkbox" name="onserverover" value="saveitover"
id="checkbox_dump_onserverover"
onclick="document.getElementById('checkbox_dump_onserver').checked = true;
document.getElementById('checkbox_dump_asfile').checked = true;"
<?php PMA_exportCheckboxCheck('onserver_overwrite'); ?> />
<label for="checkbox_dump_onserverover">
<?php echo $strOverwriteExisting; ?></label>
<br />
<?php } ?>
 
<label for="filename_template">
<?php echo $strFileNameTemplate; ?>
<sup>(1)</sup></label>:
<input type="text" name="filename_template" id="filename_template"
<?php
echo ' value="';
if ($export_type == 'database') {
if (isset($_COOKIE) && !empty($_COOKIE['pma_db_filename_template'])) {
echo $_COOKIE['pma_db_filename_template'];
} else {
echo $GLOBALS['cfg']['Export']['file_template_database'];
}
} elseif ($export_type == 'table') {
if (isset($_COOKIE) && !empty($_COOKIE['pma_table_filename_template'])) {
echo $_COOKIE['pma_table_filename_template'];
} else {
echo $GLOBALS['cfg']['Export']['file_template_table'];
}
} else {
if (isset($_COOKIE) && !empty($_COOKIE['pma_server_filename_template'])) {
echo $_COOKIE['pma_server_filename_template'];
} else {
echo $GLOBALS['cfg']['Export']['file_template_server'];
}
}
echo '" />';
?>
 
(
<input type="checkbox" name="remember_template"
id="checkbox_remember_template"
<?php PMA_exportCheckboxCheck('remember_file_template'); ?> />
<label for="checkbox_remember_template">
<?php echo $strFileNameTemplateRemember; ?></label>
)
 
<div class="formelementrow">
<?php
// charset of file
if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
echo ' <label for="select_charset_of_file">'
. $strCharsetOfFile . '</label>' . "\n";
 
$temp_charset = reset($cfg['AvailableCharsets']);
echo ' <select id="select_charset_of_file" name="charset_of_file" size="1">' . "\n";
foreach ($cfg['AvailableCharsets'] as $key => $temp_charset) {
echo ' <option value="' . $temp_charset . '"';
if ((empty($cfg['Export']['charset']) && $temp_charset == $charset)
|| $temp_charset == $cfg['Export']['charset']) {
echo ' selected="selected"';
}
echo '>' . $temp_charset . '</option>' . "\n";
} // end foreach
echo ' </select>';
} // end if
?>
</div>
 
<?php
// zip, gzip and bzip2 encode features
$is_zip = ( $cfg['ZipDump'] && @function_exists('gzcompress') );
$is_gzip = ( $cfg['GZipDump'] && @function_exists('gzencode') );
$is_bzip = ( $cfg['BZipDump'] && @function_exists('bzcompress') );
 
if ( $is_zip || $is_gzip || $is_bzip ) { ?>
<div class="formelementrow">
<?php echo $strCompression; ?>:
<input type="radio" name="compression" value="none"
id="radio_compression_none"
onclick="document.getElementById('checkbox_dump_asfile').checked = true;"
<?php PMA_exportIsActive('compression', 'none'); ?> />
<label for="radio_compression_none"><?php echo $strNone; ?></label>
<?php
if ($is_zip) { ?>
<input type="radio" name="compression" value="zip"
id="radio_compression_zip"
onclick="document.getElementById('checkbox_dump_asfile').checked = true;"
<?php PMA_exportIsActive('compression', 'zip'); ?> />
<label for="radio_compression_zip"><?php echo $strZip; ?></label>
<?php } if ($is_gzip) { ?>
<input type="radio" name="compression" value="gzip"
id="radio_compression_gzip"
onclick="document.getElementById('checkbox_dump_asfile').checked = true;"
<?php PMA_exportIsActive('compression', 'gzip'); ?> />
<label for="radio_compression_gzip"><?php echo $strGzip; ?></label>
<?php } if ($is_bzip) { ?>
<input type="radio" name="compression" value="bzip"
id="radio_compression_bzip"
onclick="document.getElementById('checkbox_dump_asfile').checked = true;"
<?php PMA_exportIsActive('compression', 'bzip2'); ?> />
<label for="radio_compression_bzip"><?php echo $strBzip; ?></label>
<?php } ?>
</div>
<?php } else { ?>
<input type="hidden" name="compression" value="none" />
<?php } ?>
</fieldset>
 
<?php if (function_exists('PMA_set_enc_form')) { ?>
<!-- Encoding setting form appended by Y.Kawada -->
<!-- Japanese encoding setting -->
<fieldset>
<?php echo PMA_set_enc_form(' '); ?>
</fieldset>
<?php } ?>
 
<fieldset class="tblFooters">
<input type="submit" value="<?php echo $strGo; ?>" id="buttonGo" />
</fieldset>
</form>
 
<div class="notice">
<sup id="FileNameTemplateHelp">(1)</sup>
<?php
$trans = '__SERVER__/' . $strFileNameTemplateDescriptionServer;
if ($export_type == 'database' || $export_type == 'table') {
$trans .= ', __DB__/' . $strFileNameTemplateDescriptionDatabase;
}
if ($export_type == 'table') {
$trans .= ', __TABLE__/' . $strFileNameTemplateDescriptionTable;
}
echo sprintf($strFileNameTemplateDescription,
'<a href="http://www.php.net/strftime" target="documentation" title="'
. $strDocu . '">', '</a>', $trans); ?>
</div>
/Web/Maintenance/phpMyAdmin/libraries/display_import.lib.php
0,0 → 1,177
<?php
/* $Id: display_import.lib.php,v 1.17 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
require_once('./libraries/file_listing.php');
require_once('./libraries/plugin_interface.lib.php');
 
/* Scan for plugins */
$import_list = PMA_getPlugins('./libraries/import/', $import_type);
 
/* Fail if we didn't find any plugin */
if (empty($import_list)) {
$GLOBALS['show_error_header'] = TRUE;
PMA_showMessage($strCanNotLoadImportPlugins);
unset($GLOBALS['show_error_header']);
require('./libraries/footer.inc.php');
}
?>
 
<form action="import.php" method="post" enctype="multipart/form-data" name="import">
<?php
if ($import_type == 'server') {
echo PMA_generate_common_hidden_inputs('', '', 1);
} elseif ($import_type == 'database') {
echo PMA_generate_common_hidden_inputs($db, '', 1);
} else {
echo PMA_generate_common_hidden_inputs($db, $table, 1);
}
echo ' <input type="hidden" name="import_type" value="' . $import_type . '" />';
echo PMA_pluginGetJavascript($import_list);
?>
 
<h2><?php echo $strImport; ?></h2>
 
<!-- File name, and some other common options -->
<fieldset class="options">
<legend><?php echo $strFileToImport; ?></legend>
 
<div class="formelementrow">
<label for="input_import_file"><?php echo $strLocationTextfile; ?></label>
<input style="margin: 5px" type="file" name="import_file" id="input_import_file" onchange="match_file(this.value);" />
<?php
echo PMA_displayMaximumUploadSize($max_upload_size) . "\n";
// some browsers should respect this :)
echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
?>
</div>
<?php
if (!empty($cfg['UploadDir'])) {
$extensions = '';
foreach ($import_list as $key => $val) {
if (!empty($extensions)) {
$extensions .= '|';
}
$extensions .= $val['extension'];
}
$matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@';
 
$files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : '');
echo '<div class="formelementrow">' . "\n";
if ($files === FALSE) {
echo ' <div class="warning">' . "\n";
echo ' <strong>' . $strError . '</strong>: ' . "\n";
echo ' ' . $strWebServerUploadDirectoryError . "\n";
echo ' </div>' . "\n";
} elseif (!empty($files)) {
echo "\n";
echo ' <i>' . $strOr . '</i><br/><label for="select_local_import_file">' . $strWebServerUploadDirectory . '</label>&nbsp;: ' . "\n";
echo ' <select style="margin: 5px" size="1" name="local_import_file" onchange="match_file(this.value)" id="select_local_import_file">' . "\n";
echo ' <option value=""></option>' . "\n";
echo $files;
echo ' </select>' . "\n";
}
echo '</div>' . "\n";
} // end if (web-server upload directory)
 
// charset of file
echo '<div class="formelementrow">' . "\n";
if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n";
$temp_charset = reset($cfg['AvailableCharsets']);
echo $strCharsetOfFile . "\n"
. ' <select id="charset_of_file" name="charset_of_file" size="1">' . "\n"
. ' <option value="' . htmlentities( $temp_charset ) . '"';
if ($temp_charset == $charset) {
echo ' selected="selected"';
}
echo '>' . htmlentities( $temp_charset ) . '</option>' . "\n";
while ($temp_charset = next($cfg['AvailableCharsets'])) {
echo ' <option value="' . htmlentities( $temp_charset ) . '"';
if ($temp_charset == $charset) {
echo ' selected="selected"';
}
echo '>' . htmlentities( $temp_charset ) . '</option>' . "\n";
}
echo ' </select><br />' . "\n" . ' ';
} elseif (PMA_MYSQL_INT_VERSION >= 40100) {
echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n";
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', 'charset_of_file', 'utf8', FALSE);
} // end if (recoding)
echo '</div>' . "\n";
 
// zip, gzip and bzip2 encode features
$compressions = $strNone;
 
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
$compressions .= ', gzip';
}
if ($cfg['BZipDump'] && @function_exists('bzopen')) {
$compressions .= ', bzip2';
}
if ($cfg['ZipDump'] && @function_exists('gzinflate')) {
$compressions .= ', zip';
}
 
// We don't have show anything about compression, when no supported
if ($compressions != $strNone) {
echo '<div class="formelementrow">' . "\n";
printf( $strCompressionWillBeDetected, $compressions);
echo '</div>' . "\n";
}
echo "\n";
?>
</fieldset>
<fieldset class="options">
<legend><?php echo $strPartialImport; ?></legend>
 
<?php
if (isset($timeout_passed) && $timeout_passed) {
echo '<div class="formelementrow">' . "\n";
echo '<input type="hidden" name="skip" value="' . $offset . '" />';
echo sprintf($strTimeoutInfo, $offset) . '';
echo '</div>' . "\n";
}
?>
<div class="formelementrow">
<input type="checkbox" name="allow_interrupt" value="yes"
id="checkbox_allow_interrupt" <?php echo PMA_pluginCheckboxCheck('Import', 'allow_interrupt'); ?>/>
<label for="checkbox_allow_interrupt"><?php echo $strAllowInterrupt; ?></label><br />
</div>
 
<div class="formelementrow">
<label for="text_skip_queries"><?php echo $strSkipQueries; ?></label>
<input type="text" name="skip_queries" value="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id="text_skip_queries" />
</div>
</fieldset>
 
<fieldset class="options">
<legend><?php echo $strImportFormat; ?></legend>
<?php
// Let's show format options now
echo '<div style="float: left;">';
echo PMA_pluginGetChoice('Import', 'format', $import_list);
echo '</div>';
 
echo '<div style="float: left;">';
echo PMA_pluginGetOptions('Import', $import_list);
echo '</div>';
?>
<div class="clearfloat"></div>
</fieldset>
<?php
// Encoding setting form appended by Y.Kawada
if (function_exists('PMA_set_enc_form')) {
echo PMA_set_enc_form(' ');
}
echo "\n";
?>
<fieldset class="tblFooters">
<input type="submit" value="<?php echo $strGo; ?>" id="buttonGo" />
</fieldset>
</form>
<script type="text/javascript" language="javascript">
//<![CDATA[
init_options();
//]]>
</script>
/Web/Maintenance/phpMyAdmin/libraries/display_select_lang.lib.php
0,0 → 1,118
<?php
/*
* Code for displaying language selection
* $Id: display_select_lang.lib.php,v 1.8 2005/11/27 22:04:10 nijel Exp $
*/
 
/**
* Sorts available languages by their true english names
*
* @param array the array to be sorted
* @param mixed a required parameter
* @return the sorted array
* @access private
*/
function PMA_language_cmp( &$a, &$b ) {
return (strcmp($a[1], $b[1]));
} // end of the 'PMA_language_cmp()' function
 
/**
* Displays for for language selection
*
* @access public
*/
function PMA_select_language($use_fieldset = FALSE) {
global $cfg, $lang;
?>
 
<form method="post" action="index.php" target="_parent">
<?php
if (isset($GLOBALS['collation_connection'])) {
echo ' <input type="hidden" name="collation_connection" value="'
. htmlspecialchars($GLOBALS['collation_connection']) . '" />' . "\n";
}
if (isset($GLOBALS['convcharset'])) {
echo ' <input type="hidden" name="convcharset" value="'
. htmlspecialchars($GLOBALS['convcharset']) . '" />' . "\n";
}
if (isset($GLOBALS['db'])) {
echo ' <input type="hidden" name="db" value="'
. htmlspecialchars($GLOBALS['db']) . '" />' . "\n";
}
if (isset($GLOBALS['table'])) {
echo ' <input type="hidden" name="table" value="'
. htmlspecialchars($GLOBALS['table']) . '" />' . "\n";
}
if (isset($GLOBALS['server'])) {
echo ' <input type="hidden" name="server" value="'
. ((int)$GLOBALS['server']) . '" />' . "\n";
}
 
$language_title = 'Language <a href="./translators.html" target="documentation">' .
( $cfg['ReplaceHelpImg'] ?
'<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_info.png" width="11" height="11" alt="Info" />' :
'(*)' ) . '</a>';
if ($use_fieldset) {
echo '<fieldset><legend xml:lang="en" dir="ltr">' . $language_title . '</legend>';
} else {
echo '<bdo xml:lang="en" dir="ltr">' . $language_title . ':</bdo>';
}
?>
 
<select name="lang" onchange="this.form.submit();" xml:lang="en" dir="ltr">
<?php
 
uasort($GLOBALS['available_languages'], 'PMA_language_cmp');
foreach ($GLOBALS['available_languages'] AS $id => $tmplang) {
$lang_name = ucfirst(substr(strrchr($tmplang[0], '|'), 1));
 
// Include native name if non empty
if (!empty($tmplang[3])) {
$lang_name = $tmplang[3] . ' - '
. $lang_name;
}
 
// Include charset if it makes sense
if (!defined('PMA_REMOVED_NON_UTF_8')) {
$lang_name .= ' (' . substr($id, strpos($id, '-') + 1) . ')';
}
 
//Is current one active?
if ($lang == $id) {
$selected = ' selected="selected"';
} else {
$selected = '';
}
 
echo ' ';
echo '<option value="' . $id . '"' . $selected . '>' . $lang_name
. '</option>' . "\n";
}
?>
 
</select>
<?php
if ($use_fieldset) {
echo '</fieldset>';
}
?>
 
<noscript>
<?php
if ($use_fieldset) {
echo '<fieldset class="tblFooters">';
}
?>
 
<input type="submit" value="Go" />
<?php
if ($use_fieldset) {
echo '</fieldset>';
}
?>
 
</noscript>
</form>
<?php
} // End of function PMA_select_language
?>
/Web/Maintenance/phpMyAdmin/libraries/display_tbl.lib.php
0,0 → 1,1892
<?php
/* $Id: display_tbl.lib.php,v 2.96.2.7 2006/03/23 10:37:17 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Set of functions used to display the records returned by a sql query
*/
 
/**
* Avoids undefined variables
*/
if (!isset($pos)) {
$pos = 0;
}
 
/**
* Defines the display mode to use for the results of a sql query
*
* It uses a synthetic string that contains all the required informations.
* In this string:
* - the first two characters stand for the action to do while
* clicking on the "edit" link (eg 'ur' for update a row, 'nn' for no
* edit link...);
* - the next two characters stand for the action to do while
* clicking on the "delete" link (eg 'kp' for kill a process, 'nn' for
* no delete link...);
* - the next characters are boolean values (1/0) and respectively stand
* for sorting links, navigation bar, "insert a new row" link, the
* bookmark feature, the expand/collapse text/blob fields button and
* the "display printable view" option.
* Of course '0'/'1' means the feature won't/will be enabled.
*
* @param string the synthetic value for display_mode (see �1 a few
* lines above for explanations)
* @param integer the total number of rows returned by the sql query
* without any programmatically appended "LIMIT" clause
* (just a copy of $unlim_num_rows if it exists, else
* computed inside this function)
*
* @return array an array with explicit indexes for all the display
* elements
*
* @global string the database name
* @global string the table name
* @global integer the total number of rows returned by the sql query
* without any programmatically appended "LIMIT" clause
* @global array the properties of the fields returned by the query
* @global string the url to return to in case of error in a sql
* statement
*
* @access private
*
* @see PMA_displayTable()
*/
function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
{
global $db, $table;
global $unlim_num_rows, $fields_meta;
global $err_url;
 
// 1. Initializes the $do_display array
$do_display = array();
$do_display['edit_lnk'] = $the_disp_mode[0] . $the_disp_mode[1];
$do_display['del_lnk'] = $the_disp_mode[2] . $the_disp_mode[3];
$do_display['sort_lnk'] = (string) $the_disp_mode[4];
$do_display['nav_bar'] = (string) $the_disp_mode[5];
$do_display['ins_row'] = (string) $the_disp_mode[6];
$do_display['bkm_form'] = (string) $the_disp_mode[7];
$do_display['text_btn'] = (string) $the_disp_mode[8];
$do_display['pview_lnk'] = (string) $the_disp_mode[9];
 
// 2. Display mode is not "false for all elements" -> updates the
// display mode
if ($the_disp_mode != 'nnnn000000') {
// 2.0 Print view -> set all elements to FALSE!
if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
$do_display['edit_lnk'] = 'nn'; // no edit link
$do_display['del_lnk'] = 'nn'; // no delete link
$do_display['sort_lnk'] = (string) '0';
$do_display['nav_bar'] = (string) '0';
$do_display['ins_row'] = (string) '0';
$do_display['bkm_form'] = (string) '0';
$do_display['text_btn'] = (string) '0';
$do_display['pview_lnk'] = (string) '0';
}
// 2.1 Statement is a "SELECT COUNT", a
// "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or
// contains a "PROC ANALYSE" part
elseif ($GLOBALS['is_count'] || $GLOBALS['is_analyse'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) {
$do_display['edit_lnk'] = 'nn'; // no edit link
$do_display['del_lnk'] = 'nn'; // no delete link
$do_display['sort_lnk'] = (string) '0';
$do_display['nav_bar'] = (string) '0';
$do_display['ins_row'] = (string) '0';
$do_display['bkm_form'] = (string) '1';
if ($GLOBALS['is_analyse']) {
$do_display['text_btn'] = (string) '1';
} else {
$do_display['text_btn'] = (string) '0';
}
$do_display['pview_lnk'] = (string) '1';
}
// 2.2 Statement is a "SHOW..."
elseif ($GLOBALS['is_show']) {
// 2.2.1 TODO : defines edit/delete links depending on show statement
$tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which);
if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
$do_display['edit_lnk'] = 'nn'; // no edit link
$do_display['del_lnk'] = 'kp'; // "kill process" type edit link
} else {
// Default case -> no links
$do_display['edit_lnk'] = 'nn'; // no edit link
$do_display['del_lnk'] = 'nn'; // no delete link
}
// 2.2.2 Other settings
$do_display['sort_lnk'] = (string) '0';
$do_display['nav_bar'] = (string) '0';
$do_display['ins_row'] = (string) '0';
$do_display['bkm_form'] = (string) '1';
$do_display['text_btn'] = (string) '1';
$do_display['pview_lnk'] = (string) '1';
}
// 2.3 Other statements (ie "SELECT" ones) -> updates
// $do_display['edit_lnk'], $do_display['del_lnk'] and
// $do_display['text_btn'] (keeps other default values)
else {
$prev_table = $fields_meta[0]->table;
$do_display['text_btn'] = (string) '1';
for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++) {
$is_link = ($do_display['edit_lnk'] != 'nn'
|| $do_display['del_lnk'] != 'nn'
|| $do_display['sort_lnk'] != '0'
|| $do_display['ins_row'] != '0');
// 2.3.2 Displays edit/delete/sort/insert links?
if ($is_link
&& ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) {
$do_display['edit_lnk'] = 'nn'; // don't display links
$do_display['del_lnk'] = 'nn';
// TODO: May be problematic with same fields names in
// two joined table.
// $do_display['sort_lnk'] = (string) '0';
$do_display['ins_row'] = (string) '0';
if ($do_display['text_btn'] == '1') {
break;
}
} // end if (2.3.2)
// 2.3.3 Always display print view link
$do_display['pview_lnk'] = (string) '1';
$prev_table = $fields_meta[$i]->table;
} // end for
} // end if..elseif...else (2.1 -> 2.3)
} // end if (2)
 
// 3. Gets the total number of rows if it is unknown
if (isset($unlim_num_rows) && $unlim_num_rows != '') {
$the_total = $unlim_num_rows;
} elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
&& (isset($db) && strlen($db) && !empty($table))) {
$the_total = PMA_countRecords($db, $table, TRUE);
}
 
// 4. If navigation bar or sorting fields names urls should be
// displayed but there is only one row, change these settings to
// false
if ($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') {
 
if (isset($unlim_num_rows) && $unlim_num_rows < 2) {
// garvin: force display of navbar for vertical/horizontal display-choice.
// $do_display['nav_bar'] = (string) '0';
$do_display['sort_lnk'] = (string) '0';
}
 
} // end if (3)
 
// 5. Updates the synthetic var
$the_disp_mode = join('', $do_display);
 
return $do_display;
} // end of the 'PMA_setDisplayMode()' function
 
 
/**
* Displays a navigation bar to browse among the results of a sql query
*
* @param integer the offset for the "next" page
* @param integer the offset for the "previous" page
* @param string the url-encoded query
*
* @global string $db the database name
* @global string $table the table name
* @global string $goto the url to go back in case of errors
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global integer $num_rows the total number of rows returned by the
* sql query
* @global integer $unlim_num_rows the total number of rows returned by the
* sql any programmatically appended "LIMIT" clause
* @global integer $pos the current position in results
* @global mixed $session_max_rows the maximum number of rows per page
* ('all' = no limit)
* @global string $disp_direction the display mode
* (horizontal / vertical / horizontalflipped)
* @global integer $repeat_cells the number of row to display between two
* table headers
* @global boolean $is_innodb whether its InnoDB or not
* @global array $showtable table definitions
*
* @access private
*
* @see PMA_displayTable()
*/
function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query)
{
global $db, $table, $goto, $dontlimitchars;
global $num_rows, $unlim_num_rows, $pos, $session_max_rows;
global $disp_direction, $repeat_cells;
global $is_innodb;
global $showtable;
 
// FIXME: move this to a central place
// FIXME: for other future table types
$is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
 
?>
 
<!-- Navigation bar -->
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<?php
// Move to the beginning or to the previous page
if ($pos > 0 && $session_max_rows != 'all') {
// loic1: patch #474210 from Gosha Sakovich - part 1
if ($GLOBALS['cfg']['NavigationBarIconic']) {
$caption1 = '&lt;&lt;';
$caption2 = ' &lt; ';
$title1 = ' title="' . $GLOBALS['strPos1'] . '"';
$title2 = ' title="' . $GLOBALS['strPrevious'] . '"';
} else {
$caption1 = $GLOBALS['strPos1'] . ' &lt;&lt;';
$caption2 = $GLOBALS['strPrevious'] . ' &lt;';
$title1 = '';
$title2 = '';
} // end if... else...
?>
<td>
<form action="sql.php" method="post">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="0" />
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
<input type="submit" name="navig" value="<?php echo $caption1; ?>"<?php echo $title1; ?> />
</form>
</td>
<td>
<form action="sql.php" method="post">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="<?php echo $pos_prev; ?>" />
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
<input type="submit" name="navig" value="<?php echo $caption2; ?>"<?php echo $title2; ?> />
</form>
</td>
<?php
} // end move back
?>
<td>
&nbsp;&nbsp;&nbsp;
</td>
<td align="center">
<form action="sql.php" method="post"
onsubmit="return (checkFormElementInRange(this, 'session_max_rows', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']); ?>', 1) &amp;&amp; checkFormElementInRange(this, 'pos', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']); ?>', 0, <?php echo $unlim_num_rows - 1; ?>))">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
<input type="submit" name="navig" value="<?php echo $GLOBALS['strShow']; ?> :" />
<input type="text" name="session_max_rows" size="3" value="<?php echo (($session_max_rows != 'all') ? $session_max_rows : $GLOBALS['cfg']['MaxRows']); ?>" class="textfield" onfocus="this.select()" />
<?php echo $GLOBALS['strRowsFrom'] . "\n"; ?>
<input type="text" name="pos" size="6" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />
<br />
<?php
// Display mode (horizontal/vertical and repeat headers)
$param1 = ' <select name="disp_direction">' . "\n"
. ' <option value="horizontal"' . (($disp_direction == 'horizontal') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeHorizontal'] . '</option>' . "\n"
. ' <option value="horizontalflipped"' . (($disp_direction == 'horizontalflipped') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeFlippedHorizontal'] . '</option>' . "\n"
. ' <option value="vertical"' . (($disp_direction == 'vertical') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeVertical'] . '</option>' . "\n"
. ' </select>' . "\n"
. ' ';
$param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $repeat_cells . '" class="textfield" />' . "\n"
. ' ';
echo ' ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
?>
</form>
</td>
<td>
&nbsp;&nbsp;&nbsp;
</td>
<?php
// Move to the next page or to the last one
if (($pos + $session_max_rows < $unlim_num_rows) && $num_rows >= $session_max_rows
&& $session_max_rows != 'all') {
// loic1: patch #474210 from Gosha Sakovich - part 2
if ($GLOBALS['cfg']['NavigationBarIconic']) {
$caption3 = ' &gt; ';
$caption4 = '&gt;&gt;';
$title3 = ' title="' . $GLOBALS['strNext'] . '"';
$title4 = ' title="' . $GLOBALS['strEnd'] . '"';
} else {
$caption3 = '&gt; ' . $GLOBALS['strNext'];
$caption4 = '&gt;&gt; ' . $GLOBALS['strEnd'];
$title3 = '';
$title4 = '';
} // end if... else...
echo "\n";
?>
<td>
<form action="sql.php" method="post">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="<?php echo $pos_next; ?>" />
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
<input type="submit" name="navig" value="<?php echo $caption3; ?>"<?php echo $title3; ?> />
</form>
</td>
<td>
<form action="sql.php" method="post"
onsubmit="return <?php echo (($pos + $session_max_rows < $unlim_num_rows && $num_rows >= $session_max_rows) ? 'true' : 'false'); ?>">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="<?php echo @((ceil($unlim_num_rows / $session_max_rows)- 1) * $session_max_rows); ?>" />
<?php
if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
echo '<input type="hidden" name="find_real_end" value="1" />' . "\n";
// no backquote around this message
$onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], FALSE) . '\')"';
}
?>
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
<input type="submit" name="navig" value="<?php echo $caption4; ?>"<?php echo $title4; ?> <?php echo (empty($onclick) ? '' : $onclick); ?>/>
</form>
</td>
<?php
} // end move toward
 
 
//page redirection
$pageNow = @floor($pos / $session_max_rows) + 1;
$nbTotalPage = @ceil($unlim_num_rows / $session_max_rows);
 
if ($nbTotalPage > 1){ //if1
?>
<td>
&nbsp;&nbsp;&nbsp;
</td>
<td>
<?php //<form> for keep the form alignment of button < and << ?>
<form action="none">
<?php echo PMA_pageselector(
'sql.php?sql_query=' . $encoded_query .
'&amp;session_max_rows=' . $session_max_rows .
'&amp;disp_direction=' . $disp_direction .
'&amp;repeat_cells=' . $repeat_cells .
'&amp;goto=' . $goto .
'&amp;dontlimitchars=' . $dontlimitchars .
'&amp;' . PMA_generate_common_url($db, $table) .
'&amp;',
$session_max_rows,
$pageNow,
$nbTotalPage
);
?>
</form>
</td>
<?php
} //_if1
 
 
// Show all the records if allowed
if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
echo "\n";
?>
<td>
&nbsp;&nbsp;&nbsp;
</td>
<td>
<form action="sql.php" method="post">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="0" />
<input type="hidden" name="session_max_rows" value="all" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
<input type="submit" name="navig" value="<?php echo $GLOBALS['strShowAll']; ?>" />
</form>
</td>
<?php
} // end show all
echo "\n";
?>
</tr>
</table>
 
<?php
} // end of the 'PMA_displayTableNavigation()' function
 
 
/**
* Displays the headers of the results table
*
* @param array which elements to display
* @param array the list of fields properties
* @param integer the total number of fields returned by the sql query
* @param array the analyzed query
*
* @return boolean always true
*
* @global string $db the database name
* @global string $table the table name
* @global string $goto the url to go back in case of errors
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global string $sql_query the sql query
* @global integer $num_rows the total number of rows returned by the
* sql query
* @global integer $pos the current position in results
* @global integer $session_max_rows the maximum number of rows per page
* @global array $vertical_display informations used with vertical display
* mode
* @global string $disp_direction the display mode
* (horizontal/vertical/horizontalflipped)
* @global integer $repeat_cellsthe number of row to display between two
* table headers
*
* @access private
*
* @see PMA_displayTable()
*/
function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '')
{
global $db, $table, $goto, $dontlimitchars;
global $sql_query, $num_rows, $pos, $session_max_rows;
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
 
if ($analyzed_sql == '') {
$analyzed_sql = array();
}
 
// can the result be sorted?
if ($is_display['sort_lnk'] == '1') {
 
// Just as fallback
$unsorted_sql_query = $sql_query;
if (isset($analyzed_sql[0]['unsorted_query'])) {
$unsorted_sql_query = $analyzed_sql[0]['unsorted_query'];
}
 
// we need $sort_expression and $sort_expression_nodir
// even if there are many table references
 
$sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
 
// Get rid of ASC|DESC (TODO: analyzer)
preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
$sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
 
// sorting by indexes, only if it makes sense (only one table ref)
if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
 
// grab indexes data:
PMA_DBI_select_db($db);
if (!defined('PMA_IDX_INCLUDED')) {
$ret_keys = PMA_get_indexes($table);
}
 
$prev_index = '';
foreach ($ret_keys as $row) {
 
if ($row['Key_name'] != $prev_index ){
$indexes[] = $row['Key_name'];
$prev_index = $row['Key_name'];
}
$indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
$indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
if (isset($row['Cardinality'])) {
$indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
}
// I don't know what does the following column mean....
// $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
$indexes_info[$row['Key_name']]['Comment'] = (isset($row['Comment']))
? $row['Comment']
: '';
$indexes_info[$row['Key_name']]['Index_type'] = (isset($row['Index_type']))
? $row['Index_type']
: '';
 
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
if (isset($row['Sub_part'])) {
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
}
} // end while
 
// do we have any index?
if (isset($indexes_data)) {
 
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
$span = $fields_cnt;
if ($is_display['edit_lnk'] != 'nn') {
$span++;
}
if ($is_display['del_lnk'] != 'nn') {
$span++;
}
if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
$span++;
}
} else {
$span = $num_rows + floor($num_rows/$repeat_cells) + 1;
}
 
echo '<form action="sql.php" method="post">' . "\n";
echo PMA_generate_common_hidden_inputs($db, $table, 5);
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
echo $GLOBALS['strSortByKey'] . ': <select name="sql_query">' . "\n";
$used_index = false;
$local_order = (isset($sort_expression) ? $sort_expression : '');
foreach ($indexes_data AS $key => $val) {
$asc_sort = '';
$desc_sort = '';
foreach ($val AS $key2 => $val2) {
$asc_sort .= PMA_backquote($val2['Column_name']) . ' ASC , ';
$desc_sort .= PMA_backquote($val2['Column_name']) . ' DESC , ';
}
$asc_sort = substr($asc_sort, 0, -3);
$desc_sort = substr($desc_sort, 0, -3);
$used_index = $used_index || $local_order == $asc_sort || $local_order == $desc_sort;
echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $asc_sort) . '"' . ($local_order == $asc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strAscending'] . ')</option>';
echo "\n";
echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $desc_sort) . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strDescending'] . ')</option>';
echo "\n";
}
echo '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"' ) . '>' . $GLOBALS['strNone'] . '</option>';
echo "\n";
echo '</select>' . "\n";
echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
echo "\n";
echo '</form>' . "\n";
}
}
}
 
 
$vertical_display['emptypre'] = 0;
$vertical_display['emptyafter'] = 0;
$vertical_display['textbtn'] = '';
 
 
// Start of form for multi-rows delete
 
if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp' ) {
echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n";
echo PMA_generate_common_hidden_inputs($db, $table, 1);
echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
echo '<input type="hidden" name="goto" value="sql.php" />' . "\n";
}
 
echo '<table id="table_results" class="data">' . "\n";
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
echo '<thead><tr>' . "\n";
}
 
// 1. Displays the full/partial text button (part 1)...
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
$colspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
? ' colspan="3"'
: '';
} else {
$rowspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
? ' rowspan="3"'
: '';
}
$text_url = 'sql.php?'
. PMA_generate_common_url($db, $table)
. '&amp;sql_query=' . urlencode($sql_query)
. '&amp;session_max_rows=' . $session_max_rows
. '&amp;pos=' . $pos
. '&amp;disp_direction=' . $disp_direction
. '&amp;repeat_cells=' . $repeat_cells
. '&amp;goto=' . $goto
. '&amp;dontlimitchars=' . (($dontlimitchars) ? 0 : 1);
$text_message = '<img class="fulltext" src="' . $GLOBALS['pmaThemeImage'] . 's_'.($dontlimitchars ? 'partialtext' : 'fulltext') . '.png" width="50" height="20" alt="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" title="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" />';
$text_link = PMA_linkOrButton( $text_url, $text_message, array(), false );
 
// ... before the result table
if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
&& $is_display['text_btn'] == '1') {
$vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
?>
<th colspan="<?php echo $fields_cnt; ?>"><?php echo $text_link; ?></th>
</tr>
<tr>
<?php
} // end horizontal/horizontalflipped mode
else {
?>
<tr>
<th colspan="<?php echo $num_rows + floor($num_rows/$repeat_cells) + 1; ?>">
<?php echo $text_link; ?></th>
</tr>
<?php
} // end vertical mode
}
 
// ... at the left column of the result table header if possible
// and required
elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
$vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
?>
<th <?php echo $colspan; ?>><?php echo $text_link; ?></th>
<?php
} // end horizontal/horizontalflipped mode
else {
$vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
. ' ' . $text_link . "\n"
. ' </th>' . "\n";
} // end vertical mode
}
 
// ... elseif no button, displays empty(ies) col(s) if required
elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft']
&& ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
$vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
?>
<td<?php echo $colspan; ?>></td>
<?php
} // end horizontal/horizontalfipped mode
else {
$vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
} // end vertical mode
}
 
// 2. Displays the fields' name
// 2.0 If sorting links should be used, checks if the query is a "JOIN"
// statement (see 2.1.3)
 
// 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']).
// Do not show comments, if using horizontalflipped mode, because of space usage
if ($GLOBALS['cfg']['ShowBrowseComments'] && ($GLOBALS['cfgRelation']['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) && $disp_direction != 'horizontalflipped') {
$comments_map = array();
if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
$tb = $tbl['table_true_name'];
$comments_map[$tb] = PMA_getComments($db, $tb);
unset($tb);
}
}
}
 
if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
require_once('./libraries/transformations.lib.php');
$GLOBALS['mime_map'] = PMA_getMIME($db, $table);
}
 
if ($is_display['sort_lnk'] == '1') {
//$is_join = preg_match('@(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN@im', $sql_query, $select_stt);
$is_join = (isset($analyzed_sql[0]['queryflags']['join']) ?TRUE:FALSE);
$select_expr = $analyzed_sql[0]['select_expr_clause'];
} else {
$is_join = FALSE;
}
 
// garvin: See if we have to highlight any header fields of a WHERE query.
// Uses SQL-Parser results.
$highlight_columns = array();
if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
isset($analyzed_sql[0]['where_clause_identifiers'])) {
 
$wi = 0;
if (isset($analyzed_sql[0]['where_clause_identifiers']) && is_array($analyzed_sql[0]['where_clause_identifiers'])) {
foreach ($analyzed_sql[0]['where_clause_identifiers'] AS $wci_nr => $wci) {
$highlight_columns[$wci] = 'true';
}
}
}
 
for ($i = 0; $i < $fields_cnt; $i++) {
// garvin: See if this column should get highlight because it's used in the
// where-query.
if (isset($highlight_columns[$fields_meta[$i]->name]) || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)])) {
$column_style = 'style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '"';
} else {
$column_style = '';
}
 
// 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
if (isset($comments_map) &&
isset($comments_map[$fields_meta[$i]->table]) &&
isset($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name])) {
$comments = '<span class="tblcomment">' . htmlspecialchars($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name]) . '</span>';
} else {
$comments = '';
}
 
// 2.1 Results can be sorted
if ($is_display['sort_lnk'] == '1') {
 
// 2.1.1 Checks if the table name is required; it's the case
// for a query with a "JOIN" statement and if the column
// isn't aliased, or in queries like
// SELECT `1`.`master_field` , `2`.`master_field`
// FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
 
if (($is_join
&& !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . strtr($fields_meta[$i]->name, array('[' => '\\[', '~' => '\\~', '\\' => '\\\\')) . '~i', $select_expr, $parts))
|| ( isset($analyzed_sql[0]['select_expr'][$i]['expr'])
&& isset($analyzed_sql[0]['select_expr'][$i]['column'])
&& $analyzed_sql[0]['select_expr'][$i]['expr'] !=
$analyzed_sql[0]['select_expr'][$i]['column']
&& isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table)) ) {
$sort_tbl = PMA_backquote($fields_meta[$i]->table) . ' . ';
} else {
$sort_tbl = '';
}
// 2.1.2 Checks if the current column is used to sort the
// results
if (empty($sort_expression)) {
$is_in_sort = FALSE;
} else {
// field name may be preceded by a space, or any number
// of characters followed by a dot (tablename.fieldname)
// so do a direct comparison
// for the sort expression (avoids problems with queries
// like "SELECT id, count(id)..." and clicking to sort
// on id or on count(id) )
$is_in_sort = ($sort_tbl . PMA_backquote($fields_meta[$i]->name) == $sort_expression_nodir ? TRUE : FALSE);
}
// 2.1.3 Check the field name for backquotes.
// If it contains some, it's probably a function column
// like 'COUNT(`field`)'
if (strpos(' ' . $fields_meta[$i]->name, '`') > 0) {
$sort_order = ' ORDER BY \'' . $fields_meta[$i]->name . '\' ';
} else {
$sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($fields_meta[$i]->name) . ' ';
}
 
// 2.1.4 Do define the sorting url
if (!$is_in_sort) {
// loic1: patch #455484 ("Smart" order)
$GLOBALS['cfg']['Order'] = strtoupper($GLOBALS['cfg']['Order']);
if ($GLOBALS['cfg']['Order'] == 'SMART') {
$GLOBALS['cfg']['Order'] = (preg_match('@time|date@i', $fields_meta[$i]->type)) ? 'DESC' : 'ASC';
}
$sort_order .= $GLOBALS['cfg']['Order'];
$order_img = '';
} elseif (preg_match('@[[:space:]]ASC$@i', $sort_expression)) {
$sort_order .= ' DESC';
$order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
} elseif (preg_match('@[[:space:]]DESC$@i', $sort_expression)) {
$sort_order .= ' ASC';
$order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" width="11" height="9" alt="'. $GLOBALS['strDescending'] . '" title="'. $GLOBALS['strDescending'] . '" id="soimg' . $i . '" />';
} else {
$sort_order .= ' DESC';
$order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
}
 
if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))@i', $unsorted_sql_query, $regs3)) {
$sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
} else {
$sorted_sql_query = $unsorted_sql_query . $sort_order;
}
$url_query = PMA_generate_common_url($db, $table)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $session_max_rows
. '&amp;disp_direction=' . $disp_direction
. '&amp;repeat_cells=' . $repeat_cells
. '&amp;dontlimitchars=' . $dontlimitchars
. '&amp;sql_query=' . urlencode($sorted_sql_query);
$order_url = 'sql.php?' . $url_query;
 
// 2.1.5 Displays the sorting url
// added 20004-06-09: Michael Keck <mail@michaelkeck.de>
// enable sord order swapping for image
$order_link_params = array();
if (isset($order_img) && $order_img!='') {
if (strstr($order_img, 'asc')) {
$order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
$order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
} elseif (strstr($order_img, 'desc')) {
$order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
$order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
}
}
if ( $disp_direction == 'horizontalflipped'
&& $GLOBALS['cfg']['HeaderFlipType'] == 'css' ) {
$order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;';
}
$order_link_params['title'] = $GLOBALS['strSort'];
$order_link_content = ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name));
$order_link = PMA_linkOrButton( $order_url, $order_link_content . $order_img, $order_link_params, false, true );
 
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
?>
<th <?php echo $column_style; ?> <?php if ($disp_direction == 'horizontalflipped') { echo 'valign="bottom"'; } ?>>
<?php echo $order_link; ?>
<?php echo $comments; ?>
</th>
<?php
}
$vertical_display['desc'][] = ' <th ' . $column_style . '>' . "\n"
. $order_link
. $comments
. ' </th>' . "\n";
} // end if (2.1)
 
// 2.2 Results can't be sorted
else {
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
?>
<th <?php echo $column_style; ?> <?php if ($disp_direction == 'horizontalflipped') { echo 'valign="bottom"'; } ?> <?php echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'css' ? 'style="direction: ltr; writing-mode: tb-rl;"' : ''); ?>>
<?php echo ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake'? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name)) . "\n"; ?>
<?php echo $comments; ?>
</th>
<?php
}
$vertical_display['desc'][] = ' <th ' . $column_style . '>' . "\n"
. ' ' . htmlspecialchars($fields_meta[$i]->name) . "\n"
. $comments
. ' </th>';
} // end else (2.2)
} // end for
 
// 3. Displays the full/partial text button (part 2) at the right
// column of the result table header if possible and required...
if ($GLOBALS['cfg']['ModifyDeleteAtRight']
&& ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')
&& $is_display['text_btn'] == '1') {
$vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
echo "\n";
?>
<th <?php echo $colspan; ?>>
<?php echo $text_link; ?>
</th>
<?php
} // end horizontal/horizontalflipped mode
else {
$vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
. ' ' . $text_link . "\n"
. ' </th>' . "\n";
} // end vertical mode
}
 
// ... elseif no button, displays empty cols if required
// (unless coming from Browse mode print view)
elseif ($GLOBALS['cfg']['ModifyDeleteAtRight']
&& ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
&& (!$GLOBALS['is_header_sent'])) {
$vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
echo "\n";
?>
<td<?php echo $colspan; ?>></td>
<?php
} // end horizontal/horizontalflipped mode
else {
$vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
} // end vertical mode
}
 
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
?>
</tr>
</thead>
<?php
}
 
return TRUE;
} // end of the 'PMA_displayTableHeaders()' function
 
 
 
/**
* Displays the body of the results table
*
* @param integer the link id associated to the query which results have
* to be displayed
* @param array which elements to display
* @param array the list of relations
* @param array the analyzed query
*
* @return boolean always true
*
* @global string $db the database name
* @global string $table the table name
* @global string $goto the url to go back in case of errors
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global string $sql_query the sql query
* @global integer $pos the current position in results
* @global integer $session_max_rows the maximum number of rows per page
* @global array $fields_meta the list of fields properties
* @global integer $fields_cnt the total number of fields returned by
* the sql query
* @global array $vertical_display informations used with vertical display
* mode
* @global string $disp_direction the display mode
* (horizontal/vertical/horizontalflipped)
* @global integer $repeat_cells the number of row to display between two
* table headers
* @global array $highlight_columns collumn names to highlight
* @gloabl array $row current row data
*
* @access private
*
* @see PMA_displayTable()
*/
function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
global $db, $table, $goto, $dontlimitchars;
global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt;
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin
 
$url_sql_query = $sql_query;
 
// query without conditions to shorten urls when needed, 200 is just
// guess, it should depend on remaining url length
 
if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
strlen($sql_query) > 200) {
 
$url_sql_query = 'SELECT ';
if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
$url_sql_query .= ' DISTINCT ';
}
$url_sql_query .= $analyzed_sql[0]['select_expr_clause'];
if (!empty($analyzed_sql[0]['from_clause'])) {
$url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
}
}
 
if (!is_array($map)) {
$map = array();
}
$row_no = 0;
$vertical_display['edit'] = array();
$vertical_display['delete'] = array();
$vertical_display['data'] = array();
$vertical_display['row_delete'] = array();
 
// Correction uva 19991216 in the while below
// Previous code assumed that all tables have keys, specifically that
// the phpMyAdmin GUI should support row delete/edit only for such
// tables.
// Although always using keys is arguably the prescribed way of
// defining a relational table, it is not required. This will in
// particular be violated by the novice.
// We want to encourage phpMyAdmin usage by such novices. So the code
// below has been changed to conditionally work as before when the
// table being displayed has one or more keys; but to display
// delete/edit options correctly for tables without keys.
 
// loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row'
// to get the NULL values
 
// rabus: This function needs a little rework.
// Using MYSQL_BOTH just pollutes the memory!
 
// ne0x: Use function PMA_DBI_fetch_array() due to mysqli
// compatibility. Now this function is wrapped.
 
$odd_row = true;
while ($row = PMA_DBI_fetch_row($dt_result)) {
// lem9: "vertical display" mode stuff
if ( $row_no != 0 && $repeat_cells != 0 && !($row_no % $repeat_cells)
&& ( $disp_direction == 'horizontal'
|| $disp_direction == 'horizontalflipped') )
{
echo '<tr>' . "\n";
if ( $vertical_display['emptypre'] > 0 ) {
echo ' <th colspan="' . $vertical_display['emptypre'] . '">' . "\n"
.' &nbsp;</th>' . "\n";
}
 
foreach ( $vertical_display['desc'] as $val ) {
echo $val;
}
 
if ( $vertical_display['emptyafter'] > 0 ) {
echo ' <th colspan="' . $vertical_display['emptyafter'] . '">' . "\n"
.' &nbsp;</th>' . "\n";
}
echo '</tr>' . "\n";
} // end if
 
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
// loic1: pointer code part
echo ' <tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n";
$odd_row = ! $odd_row;
$bgcolor = '';
} elseif (isset($GLOBALS['printview']) && ($GLOBALS['printview'] == '1')) {
$bgcolor = ' bgcolor="#ffffff" ';
} else {
$bgcolor = ' bgcolor="' . ($row_no % 2 ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'] ) . '" ';
}
 
 
// 1. Prepares the row (gets primary keys to use)
// 1.1 Results from a "SELECT" statement -> builds the
// "primary" key to use in links
$uva_condition = urlencode(PMA_getUvaCondition($dt_result, $fields_cnt, $fields_meta, $row));
 
// 1.2 Defines the urls for the modify/delete link(s)
$url_query = PMA_generate_common_url($db, $table)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $session_max_rows
. '&amp;disp_direction=' . $disp_direction
. '&amp;repeat_cells=' . $repeat_cells
. '&amp;dontlimitchars=' . $dontlimitchars;
 
if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') {
// We need to copy the value or else the == 'both' check will always return true
 
if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
$iconic_spacer = '<div class="nowrap">';
} else {
$iconic_spacer = '';
}
 
// 1.2.1 Modify link(s)
if ($is_display['edit_lnk'] == 'ur') { // update row case
$lnk_goto = 'sql.php';
 
$edit_url = 'tbl_change.php'
. '?' . $url_query
. '&amp;primary_key=' . $uva_condition
. '&amp;sql_query=' . urlencode($url_sql_query)
. '&amp;goto=' . urlencode($lnk_goto);
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
$edit_str = $GLOBALS['strEdit'];
} else {
$edit_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" alt="' . $GLOBALS['strEdit'] . '" title="' . $GLOBALS['strEdit'] . '" />';
if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
$edit_str .= ' ' . $GLOBALS['strEdit'] . '</div>';
}
}
} // end if (1.2.1)
 
if ($table == $GLOBALS['cfg']['Bookmark']['table'] && $db == $GLOBALS['cfg']['Bookmark']['db'] && isset($row[1]) && isset($row[0])) {
$bookmark_go = '<a href="import.php?'
. PMA_generate_common_url($row[1], '')
. '&amp;id_bookmark=' . $row[0]
. '&amp;action_bookmark=0'
. '&amp;action_bookmark_all=1'
. '&amp;SQL=' . $GLOBALS['strExecuteBookmarked']
.' " title="' . $GLOBALS['strExecuteBookmarked'] . '">';
 
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
$bookmark_go .= $GLOBALS['strExecuteBookmarked'];
} else {
$bookmark_go .= $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_bookmark.png" alt="' . $GLOBALS['strExecuteBookmarked'] . '" title="' . $GLOBALS['strExecuteBookmarked'] . '" />';
if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
$bookmark_go .= ' ' . $GLOBALS['strExecuteBookmarked'] . '</div>';
}
}
 
$bookmark_go .= '</a>';
} else {
$bookmark_go = '';
}
 
// 1.2.2 Delete/Kill link(s)
if ($is_display['del_lnk'] == 'dr') { // delete row case
$lnk_goto = 'sql.php'
. '?' . str_replace('&amp;', '&', $url_query)
. '&sql_query=' . urlencode($url_sql_query)
. '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
. '&goto=' . (empty($goto) ? 'tbl_properties.php' : $goto);
$del_query = urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $uva_condition . '+LIMIT+1';
$del_url = 'sql.php'
. '?' . $url_query
. '&amp;sql_query=' . $del_query
. '&amp;zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
. '&amp;goto=' . urlencode($lnk_goto);
$js_conf = 'DELETE FROM ' . PMA_jsFormat($table)
. ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), FALSE))
. ' LIMIT 1';
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
$del_str = $GLOBALS['strDelete'];
} else {
$del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strDelete'] . '" title="' . $GLOBALS['strDelete'] . '" />';
if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
$del_str .= ' ' . $GLOBALS['strDelete'] . '</div>';
}
}
} elseif ($is_display['del_lnk'] == 'kp') { // kill process case
$lnk_goto = 'sql.php'
. '?' . str_replace('&amp;', '&', $url_query)
. '&sql_query=' . urlencode($url_sql_query)
. '&goto=main.php';
$del_url = 'sql.php?'
. PMA_generate_common_url('mysql')
. '&amp;sql_query=' . urlencode('KILL ' . $row[0])
. '&amp;goto=' . urlencode($lnk_goto);
$del_query = urlencode('KILL ' . $row[0]);
$js_conf = 'KILL ' . $row[0];
if ($GLOBALS['cfg']['PropertiesIconic'] === FALSE) {
$del_str = $GLOBALS['strKill'];
} else {
$del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strKill'] . '" title="' . $GLOBALS['strKill'] . '" />';
if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
$del_str .= ' ' . $GLOBALS['strKill'] . '</div>';
}
}
} // end if (1.2.2)
 
// 1.3 Displays the links at left if required
if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
&& ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
$doWriteModifyAt = 'left';
require('./libraries/display_tbl_links.lib.php');
} // end if (1.3)
} // end if (1)
 
// 2. Displays the rows' values
for ($i = 0; $i < $fields_cnt; ++$i) {
$meta = $fields_meta[$i];
// loic1: To fix bug #474943 under php4, the row pointer will
// depend on whether the "is_null" php4 function is
// available or not
$pointer = (function_exists('is_null') ? $i : $meta->name);
// garvin: See if this column should get highlight because it's used in the
// where-query.
if (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_backquote($meta->name)]))) {
$column_style = ' style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '" ';
} else {
$column_style = '';
}
 
if ($disp_direction == 'vertical' && (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1'))) {
if ($GLOBALS['cfg']['BrowsePointerColor'] == TRUE) {
$column_style .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
. ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');" ';
}
if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) {
$column_style .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
} else {
$column_style .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
}
}// end if
 
// garvin: Wrap MIME-transformations. [MIME]
$default_function = 'default_function'; // default_function
$transform_function = $default_function;
$transform_options = array();
 
if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
 
if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name]['transformation'])) {
$include_file = PMA_sanitizeTransformationFile($GLOBALS['mime_map'][$meta->name]['transformation']);
 
if (file_exists('./libraries/transformations/' . $include_file)) {
$transformfunction_name = preg_replace('@(\.inc\.php3?)$@i', '', $GLOBALS['mime_map'][$meta->name]['transformation']);
 
require_once('./libraries/transformations/' . $include_file);
 
if (function_exists('PMA_transformation_' . $transformfunction_name)) {
$transform_function = 'PMA_transformation_' . $transformfunction_name;
$transform_options = PMA_transformation_getOptions((isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : ''));
$meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']);
}
} // end if file_exists
} // end if transformation is set
} // end if mime/transformation works.
 
$transform_options['wrapper_link'] = '?'
. (isset($url_query) ? $url_query : '')
. '&amp;primary_key=' . (isset($uva_condition) ? $uva_condition : '')
. '&amp;sql_query=' . (isset($sql_query) ? urlencode($url_sql_query) : '')
. '&amp;goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '')
. '&amp;transform_key=' . urlencode($meta->name);
 
 
// n u m e r i c
if ($meta->numeric == 1) {
 
 
// lem9: if two fields have the same name (this is possible
// with self-join queries, for example), using $meta->name
// will show both fields NULL even if only one is NULL,
// so use the $pointer
// (works only if function_exists('is_null')
// PS: why not always work with the number ($i), since
// the default second parameter of
// mysql_fetch_array() is MYSQL_BOTH, so we always get
// associative and numeric indices?
 
//if (!isset($row[$meta->name])
if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n";
} elseif ($row[$i] != '') {
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $column_style . $bgcolor . ' class="nowrap">';
 
if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
$alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
if (isset($alias) && strlen($alias)) {
$true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
if ($alias == $meta->name) {
$meta->name = $true_column;
} // end if
} // end if
} // end while
}
 
if (isset($map[$meta->name])) {
// Field to display from the foreign table?
if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
$dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
. ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
. ' WHERE ' . PMA_backquote($map[$meta->name][1])
. ' = ' . $row[$i];
$dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
} else {
$dispval = $GLOBALS['strLinkNotFound'];
}
@PMA_DBI_free_result($dispresult);
} else {
$dispval = '';
} // end if... else...
 
if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
$vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . ' <code>[-&gt;' . $dispval . ']</code>';
} else {
$title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
 
$vertical_display['data'][$row_no][$i] .= '<a href="sql.php?'
. PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
. '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars
. '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]) . '"' . $title . '>'
. ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . '</a>';
}
} else {
$vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta));
}
$vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
} else {
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $column_style . $bgcolor . ' class="nowrap">&nbsp;</td>' . "\n";
}
 
// b l o b
 
} elseif ($GLOBALS['cfg']['ShowBlob'] == FALSE && stristr($meta->type, 'BLOB')) {
// loic1 : PMA_mysql_fetch_fields returns BLOB in place of
// TEXT fields type, however TEXT fields must be displayed
// even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type
// of the fields.
$field_flags = PMA_DBI_field_flags($dt_result, $i);
if (stristr($field_flags, 'BINARY')) {
$blobtext = '[BLOB';
if (!isset($row[$i]) || is_null($row[$i])) {
$blobtext .= ' - NULL';
$blob_size = 0;
} elseif (isset($row[$i])) {
$blob_size = strlen($row[$i]);
$display_blob_size = PMA_formatByteDown($blob_size, 3, 1);
$blobtext .= ' - '. $display_blob_size[0] . ' ' . $display_blob_size[1];
unset($display_blob_size);
}
 
$blobtext .= ']';
if (strpos($transform_function, 'octetstream')) {
$blobtext = $row[$i];
}
if ($blob_size > 0) {
$blobtext = ($default_function != $transform_function ? $transform_function($blobtext, $transform_options, $meta) : $default_function($blobtext, array(), $meta));
}
unset($blob_size);
 
$vertical_display['data'][$row_no][$i] = ' <td align="left"' . $column_style . $bgcolor . '>' . $blobtext . '</td>';
} else {
if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n";
} elseif ($row[$i] != '') {
// garvin: if a transform function for blob is set, none of these replacements will be made
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
$row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
}
// loic1: displays all space characters, 4 space
// characters for tabulations and <cr>/<lf>
$row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
 
$vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '>' . $row[$i] . '</td>' . "\n";
} else {
$vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '>&nbsp;</td>' . "\n";
}
}
} else {
if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '><i>NULL</i></td>' . "\n";
} elseif ($row[$i] != '') {
// loic1: support blanks in the key
$relation_id = $row[$i];
 
// nijel: Cut all fields to $GLOBALS['cfg']['LimitChars']
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
$row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
}
 
// loic1: displays special characters from binaries
$field_flags = PMA_DBI_field_flags($dt_result, $i);
if (stristr($field_flags, 'BINARY')) {
$row[$i] = str_replace("\x00", '\0', $row[$i]);
$row[$i] = str_replace("\x08", '\b', $row[$i]);
$row[$i] = str_replace("\x0a", '\n', $row[$i]);
$row[$i] = str_replace("\x0d", '\r', $row[$i]);
$row[$i] = str_replace("\x1a", '\Z', $row[$i]);
$row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
}
// loic1: displays all space characters, 4 space
// characters for tabulations and <cr>/<lf>
else {
$row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
}
 
// garvin: transform functions may enable nowrapping:
$function_nowrap = $transform_function . '_nowrap';
$bool_nowrap = (($default_function != $transform_function && function_exists($function_nowrap)) ? $function_nowrap($transform_options) : false);
 
// loic1: do not wrap if date field type
$nowrap = ((preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap) ? ' nowrap="nowrap"' : '');
$vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . $nowrap . '>';
 
if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
$alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
if (isset($alias) && strlen($alias)) {
$true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
if ($alias == $meta->name) {
$meta->name = $true_column;
} // end if
} // end if
} // end while
}
 
if (isset($map[$meta->name])) {
// Field to display from the foreign table?
if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
$dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
. ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
. ' WHERE ' . PMA_backquote($map[$meta->name][1])
. ' = \'' . PMA_sqlAddslashes($row[$i]) . '\'';
$dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
list($dispval) = PMA_DBI_fetch_row($dispresult);
@PMA_DBI_free_result($dispresult);
} else {
$dispval = $GLOBALS['strLinkNotFound'];
}
} else {
$dispval = '';
}
$title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
 
$vertical_display['data'][$row_no][$i] .= '<a href="sql.php?'
. PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
. '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars
. '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>'
. $row[$i] . '</a>';
} else {
$vertical_display['data'][$row_no][$i] .= $row[$i];
}
$vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
} else {
$vertical_display['data'][$row_no][$i] = ' <td' . $column_style . $bgcolor . '>&nbsp;</td>' . "\n";
}
}
 
// lem9: output stored cell
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
echo $vertical_display['data'][$row_no][$i];
}
 
if (isset($vertical_display['rowdata'][$i][$row_no])) {
$vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i];
} else {
$vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i];
}
} // end for (2)
 
// 3. Displays the modify/delete links on the right if required
if ($GLOBALS['cfg']['ModifyDeleteAtRight']
&& ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
$doWriteModifyAt = 'right';
require('./libraries/display_tbl_links.lib.php');
} // end if (3)
 
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
?>
</tr>
<?php
} // end if
 
// 4. Gather links of del_urls and edit_urls in an array for later
// output
if (!isset($vertical_display['edit'][$row_no])) {
$vertical_display['edit'][$row_no] = '';
$vertical_display['delete'][$row_no] = '';
$vertical_display['row_delete'][$row_no] = '';
}
 
$column_style_vertical = '';
if ($GLOBALS['cfg']['BrowsePointerEnable'] == TRUE) {
$column_style_vertical .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
. ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
}
$column_marker_vertical = '';
if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) {
$column_marker_vertical .= 'setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');';
}
 
if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
$vertical_display['row_delete'][$row_no] .= ' <td align="center" ' . $bgcolor . $column_style_vertical . '>' . "\n"
. ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[' . $uva_condition . ']"'
. ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'[%_PMA_CHECKBOX_DIR_%]\');"'
. ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n"
. ' </td>' . "\n";
} else {
unset($vertical_display['row_delete'][$row_no]);
}
 
if (isset($edit_url)) {
$vertical_display['edit'][$row_no] .= ' <td align="center"' . $bgcolor . $column_style_vertical . '>' . "\n"
. PMA_linkOrButton($edit_url, $edit_str, array(), FALSE)
. $bookmark_go
. ' </td>' . "\n";
} else {
unset($vertical_display['edit'][$row_no]);
}
 
if (isset($del_url)) {
$vertical_display['delete'][$row_no] .= ' <td align="center"' . $bgcolor . $column_style_vertical . '>' . "\n"
. PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE)
. ' </td>' . "\n";
} else {
unset($vertical_display['delete'][$row_no]);
}
 
echo (($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') ? "\n" : '');
$row_no++;
} // end while
 
if (isset($url_query)) {
$GLOBALS['url_query'] = $url_query;
}
 
return TRUE;
} // end of the 'PMA_displayTableBody()' function
 
 
/**
* Do display the result table with the vertical direction mode.
* Credits for this feature goes to Garvin Hicking <hicking@faktor-e.de>.
*
* @return boolean always true
*
* @global array $vertical_display the information to display
* @global integer $repeat_cells the number of row to display between two
* table headers
*
* @access private
*
* @see PMA_displayTable()
*/
function PMA_displayVerticalTable()
{
global $vertical_display, $repeat_cells;
 
// Displays "multi row delete" link at top if required
if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
echo '<tr>' . "\n";
echo $vertical_display['textbtn'];
$foo_counter = 0;
foreach ($vertical_display['row_delete'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
echo '<th>&nbsp;</th>' . "\n";
}
 
echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '', $val);
$foo_counter++;
} // end while
echo '</tr>' . "\n";
} // end if
 
// Displays "edit" link at top if required
if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn']))) {
echo '<tr>' . "\n";
if (!is_array($vertical_display['row_delete'])) {
echo $vertical_display['textbtn'];
}
$foo_counter = 0;
foreach ($vertical_display['edit'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
echo ' <th>&nbsp;</th>' . "\n";
}
 
echo $val;
$foo_counter++;
} // end while
echo '</tr>' . "\n";
} // end if
 
// Displays "delete" link at top if required
if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn']))) {
echo '<tr>' . "\n";
if (!is_array($vertical_display['edit']) && !is_array($vertical_display['row_delete'])) {
echo $vertical_display['textbtn'];
}
$foo_counter = 0;
foreach ($vertical_display['delete'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
echo '<th>&nbsp;</th>' . "\n";
}
 
echo $val;
$foo_counter++;
} // end while
echo '</tr>' . "\n";
} // end if
 
// Displays data
foreach ($vertical_display['desc'] AS $key => $val) {
 
echo '<tr>' . "\n";
echo $val;
 
$foo_counter = 0;
foreach ($vertical_display['rowdata'][$key] as $subval) {
if (($foo_counter != 0) && ($repeat_cells != 0) and !($foo_counter % $repeat_cells)) {
echo $val;
}
 
echo $subval;
$foo_counter++;
} // end while
 
echo '</tr>' . "\n";
} // end while
 
// Displays "multi row delete" link at bottom if required
if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
echo '<tr>' . "\n";
echo $vertical_display['textbtn'];
$foo_counter = 0;
foreach ($vertical_display['row_delete'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
echo '<th>&nbsp;</th>' . "\n";
}
 
echo str_replace('[%_PMA_CHECKBOX_DIR_%]', 'r', $val);
$foo_counter++;
} // end while
echo '</tr>' . "\n";
} // end if
 
// Displays "edit" link at bottom if required
if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn']))) {
echo '<tr>' . "\n";
if (!is_array($vertical_display['row_delete'])) {
echo $vertical_display['textbtn'];
}
$foo_counter = 0;
foreach ($vertical_display['edit'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
echo '<th>&nbsp;</th>' . "\n";
}
 
echo $val;
$foo_counter++;
} // end while
echo '</tr>' . "\n";
} // end if
 
// Displays "delete" link at bottom if required
if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn']))) {
echo '<tr>' . "\n";
if (!is_array($vertical_display['edit']) && !is_array($vertical_display['row_delete'])) {
echo $vertical_display['textbtn'];
}
$foo_counter = 0;
foreach ($vertical_display['delete'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
echo '<th>&nbsp;</th>' . "\n";
}
 
echo $val;
$foo_counter++;
} // end while
echo '</tr>' . "\n";
}
 
return TRUE;
} // end of the 'PMA_displayVerticalTable' function
 
 
/**
* Displays a table of results returned by a sql query.
* This function is called by the "sql.php" script.
*
* @param integer the link id associated to the query which results have
* to be displayed
* @param array the display mode
* @param array the analyzed query
*
* @global string $db the database name
* @global string $table the table name
* @global string $goto the url to go back in case of errors
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global string $sql_query the current sql query
* @global integer $num_rows the total number of rows returned by the
* sql query
* @global integer $unlim_num_rows the total number of rows returned by the
* sql query without any programmatically
* appended "LIMIT" clause
* @global integer $pos the current postion of the first record
* to be displayed
* @global array $fields_meta the list of fields properties
* @global integer $fields_cnt the total number of fields returned by
* the sql query
* @global array $vertical_display informations used with vertical display
* mode
* @global string $disp_direction the display mode
* (horizontal/vertical/horizontalflipped)
* @global integer $repeat_cells the number of row to display between two
* table headers
* @global array $highlight_columns collumn names to highlight
* @global array $cfgRelation the relation settings
*
* @access private
*
* @see PMA_showMessage(), PMA_setDisplayMode(),
* PMA_displayTableNavigation(), PMA_displayTableHeaders(),
* PMA_displayTableBody()
*/
function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
{
global $db, $table, $goto, $dontlimitchars;
global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
global $cfgRelation;
 
// 1. ----- Prepares the work -----
 
// 1.1 Gets the informations about which functionnalities should be
// displayed
$total = '';
$is_display = PMA_setDisplayMode($the_disp_mode, $total);
if ($total == '') {
unset($total);
}
 
// 1.2 Defines offsets for the next and previous pages
if ($is_display['nav_bar'] == '1') {
if (!isset($pos)) {
$pos = 0;
}
if ($GLOBALS['session_max_rows'] == 'all') {
$pos_next = 0;
$pos_prev = 0;
} else {
$pos_next = $pos + $GLOBALS['cfg']['MaxRows'];
$pos_prev = $pos - $GLOBALS['cfg']['MaxRows'];
if ($pos_prev < 0) {
$pos_prev = 0;
}
}
} // end if
 
// 1.3 Urlencodes the query to use in input form fields
$encoded_sql_query = urlencode($sql_query);
 
// 2. ----- Displays the top of the page -----
 
// 2.1 Displays a messages with position informations
if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
$selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
} else {
$selectstring = '';
}
$last_shown_rec = ($GLOBALS['session_max_rows'] == 'all' || $pos_next > $total)
? $total - 1
: $pos_next - 1;
PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec (" . PMA_formatNumber( $total, 0 ) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
if (PMA_tableIsView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) {
echo '<div class="notice">' . "\n";
echo PMA_sanitize(sprintf($GLOBALS['strViewMaxExactCount'], PMA_formatNumber($GLOBALS['cfg']['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n";
echo '</div>' . "\n";
}
} elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
PMA_showMessage($GLOBALS['strSQLQuery']);
}
 
// 2.3 Displays the navigation bars
if (!isset($table) || strlen(trim($table)) == 0) {
if (isset($analyzed_sql[0]['query_type'])
&& $analyzed_sql[0]['query_type'] == 'SELECT') {
// table does not always contain a real table name,
// for example in MySQL 5.0.x, the query SHOW STATUS
// returns STATUS as a table name
$table = $fields_meta[0]->table;
} else {
$table = '';
}
}
if ($is_display['nav_bar'] == '1') {
PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
echo "\n";
} elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
echo "\n" . '<br /><br />' . "\n";
}
 
// 2b ----- Get field references from Database -----
// (see the 'relation' config variable)
// loic1, 2002-03-02: extended to php3
 
// init map
$map = array();
 
// find tables
$target=array();
if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
foreach ($analyzed_sql[0]['table_ref'] AS $table_ref_position => $table_ref) {
$target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
}
}
$tabs = '(\'' . join('\',\'', $target) . '\')';
 
if ($cfgRelation['displaywork']) {
if (! isset($table) || ! strlen($table)) {
$exist_rel = FALSE;
} else {
$exist_rel = PMA_getForeigners($db, $table, '', 'both');
if ($exist_rel) {
foreach ($exist_rel AS $master_field => $rel) {
$display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
$map[$master_field] = array($rel['foreign_table'],
$rel['foreign_field'],
$display_field,
$rel['foreign_db']);
} // end while
} // end if
} // end if
} // end if
// end 2b
 
// 3. ----- Displays the results table -----
PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql);
$url_query='';
echo '<tbody>' . "\n";
PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
echo '</tbody>' . "\n";
// vertical output case
if ($disp_direction == 'vertical') {
PMA_displayVerticalTable();
} // end if
unset($vertical_display);
?>
</table>
 
<?php
// 4. ----- Displays the link for multi-fields delete
 
if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
 
$delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
 
$uncheckall_url = 'sql.php?'
. PMA_generate_common_url($db, $table)
. '&amp;sql_query=' . urlencode($sql_query)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $GLOBALS['session_max_rows']
. '&amp;pos=' . $pos
. '&amp;disp_direction=' . $disp_direction
. '&amp;repeat_cells=' . $repeat_cells
. '&amp;goto=' . $goto
. '&amp;dontlimitchars=' . $dontlimitchars;
$checkall_url = $uncheckall_url . '&amp;checkall=1';
 
if ( $disp_direction == 'vertical' ) {
$checkall_params['onclick'] = 'if ( setCheckboxes(\'rowsDeleteForm\', true) ) return false;';
$uncheckall_params['onclick'] = 'if ( setCheckboxes(\'rowsDeleteForm\', false) ) return false;';
} else {
$checkall_params['onclick'] = 'if ( markAllRows(\'rowsDeleteForm\') ) return false;';
$uncheckall_params['onclick'] = 'if ( unMarkAllRows(\'rowsDeleteForm\') ) return false;';
}
$checkall_link = PMA_linkOrButton( $checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false );
$uncheckall_link = PMA_linkOrButton( $uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false );
if ( $disp_direction != 'vertical' ) {
echo '<img class="selectallarrow" width="38" height="22"'
.' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"'
.' alt="' . $GLOBALS['strWithChecked'] . '" />';
}
echo $checkall_link . "\n"
.' / ' . "\n"
.$uncheckall_link . "\n"
.'<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
 
if ( $GLOBALS['cfg']['PropertiesIconic'] ) {
PMA_buttonOrImage('submit_mult', 'mult_submit',
'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
PMA_buttonOrImage('submit_mult', 'mult_submit',
'submit_mult_delete', $delete_text, 'b_drop.png');
if ($analyzed_sql[0]['querytype'] == 'SELECT') {
PMA_buttonOrImage('submit_mult', 'mult_submit',
'submit_mult_export', $GLOBALS['strExport'],
'b_tblexport.png');
}
echo "\n";
} else {
echo ' <input type="submit" name="submit_mult"'
.' value="' . htmlspecialchars($GLOBALS['strEdit']) . '"'
.' title="' . $GLOBALS['strEdit'] . '" />' . "\n";
echo ' <input type="submit" name="submit_mult"'
.' value="' . htmlspecialchars($delete_text) . '"'
.' title="' . $delete_text . '" />' . "\n";
if ($analyzed_sql[0]['querytype'] == 'SELECT') {
echo ' <input type="submit" name="submit_mult"'
.' value="' . htmlspecialchars($GLOBALS['strExport']) . '"'
.' title="' . $GLOBALS['strExport'] . '" />' . "\n";
}
}
echo '<input type="hidden" name="sql_query"'
.' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
echo '<input type="hidden" name="url_query"'
.' value="' . $GLOBALS['url_query'] . '" />' . "\n";
echo '</form>' . "\n";
}
 
// 5. ----- Displays the navigation bar at the bottom if required -----
 
if ($is_display['nav_bar'] == '1') {
echo '<br />' . "\n";
PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
} elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
echo "\n" . '<br /><br />' . "\n";
}
} // end of the 'PMA_displayTable()' function
 
function default_function($buffer) {
$buffer = htmlspecialchars($buffer);
$buffer = str_replace("\011", ' &nbsp;&nbsp;&nbsp;',
str_replace(' ', ' &nbsp;', $buffer));
$buffer = preg_replace("@((\015\012)|(\015)|(\012))@", '<br />', $buffer);
 
return $buffer;
}
?>
/Web/Maintenance/phpMyAdmin/libraries/display_tbl_links.lib.php
0,0 → 1,51
<?php
/* $Id: display_tbl_links.lib.php,v 2.13 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// modified 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
// - bugfix for select all checkboxes
// - copy right to left (or left to right) if user click on a check box
// - reversed the right modify links: 1. drop, 2. edit, 3. checkbox
// - also changes made in js/functions.js
 
if ( $doWriteModifyAt == 'left' ){
 
if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
echo ' <td align="center">' . "\n"
. ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '" name="rows_to_delete[' . $uva_condition . ']"'
. ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'l\');"'
. ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n"
. ' </td>' . "\n";
}
if (!empty($edit_url)) {
echo ' <td align="center">' . "\n"
. PMA_linkOrButton($edit_url, $edit_str, '', FALSE)
. $bookmark_go
. ' </td>' . "\n";
}
if (!empty($del_url)) {
echo ' <td align="center">' . "\n"
. PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE)
. ' </td>' . "\n";
}
} elseif ($doWriteModifyAt == 'right') {
if (!empty($del_url)) {
echo ' <td align="center">' . "\n"
. PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE)
. ' </td>' . "\n";
}
if (!empty($edit_url)) {
echo ' <td align="center">' . "\n"
. PMA_linkOrButton($edit_url, $edit_str, '', FALSE)
. $bookmark_go
. ' </td>' . "\n";
}
if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
echo ' <td align="center">' . "\n"
. ' <input type="checkbox" id="id_rows_to_delete' . $row_no . 'r" name="rows_to_delete[' . $uva_condition . ']"'
. ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'r\');"'
. ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n"
. ' </td>' . "\n";
}
}
?>
/Web/Maintenance/phpMyAdmin/libraries/engines/bdb.lib.php
0,0 → 1,70
<?php
/* $Id: bdb.lib.php,v 2.1 2005/12/07 10:28:50 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
class PMA_StorageEngine_bdb extends PMA_StorageEngine
{
/**
* @return array variable names
*/
function getVariables()
{
return array(
'version_bdb' => array(
'title' => $GLOBALS['strVersionInformation'],
),
'bdb_cache_size' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'bdb_home' => array(
),
'bdb_log_buffer_size' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'bdb_logdir' => array(
),
'bdb_max_lock' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'bdb_shared_data' => array(
),
'bdb_tmpdir' => array(
),
'bdb_data_direct' => array(
),
'bdb_lock_detect' => array(
),
'bdb_log_direct' => array(
),
'bdb_no_recover' => array(
),
'bdb_no_sync' => array(
),
'skip_sync_bdb_logs' => array(
),
'sync_bdb_logs' => array(
),
);
}
 
/**
* @return string LIKE pattern
*/
function getVariablesLikePattern()
{
return '%bdb%';
}
 
/**
* returns string with filename for the MySQL helppage
* about this storage engne
*
* @return string mysql helppage filename
*/
function getMysqlHelpPage()
{
return 'bdb';
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/engines/berkeleydb.lib.php
0,0 → 1,11
<?php
/* $Id: berkeleydb.lib.php,v 2.1 2005/12/07 10:28:50 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
include_once './libraries/engines/bdb.lib.php';
 
class PMA_StorageEngine_berkeleydb extends PMA_StorageEngine_bdb
{
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/engines/binlog.lib.php
0,0 → 1,19
<?php
/* $Id: binlog.lib.php,v 1.1 2005/12/07 10:55:34 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
class PMA_StorageEngine_binlog extends PMA_StorageEngine
{
/**
* returns string with filename for the MySQL helppage
* about this storage engne
*
* @return string mysql helppage filename
*/
function getMysqlHelpPage()
{
return 'binary-log';
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/engines/innobase.lib.php
0,0 → 1,8
<?php
/* $Id: innobase.lib.php,v 2.0 2005/03/05 13:24:28 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
include_once('./libraries/engines/innodb.lib.php');
class PMA_StorageEngine_innobase extends PMA_StorageEngine_innodb {}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/engines/innodb.lib.php
0,0 → 1,340
<?php
/* $Id: innodb.lib.php,v 2.8 2005/12/07 11:24:38 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
class PMA_StorageEngine_innodb extends PMA_StorageEngine
{
/**
* @uses $GLOBALS['strInnoDBDataHomeDir']
* @uses $GLOBALS['strInnoDBDataHomeDirDesc']
* @uses $GLOBALS['strInnoDBDataFilePath']
* @uses $GLOBALS['strInnoDBAutoextendIncrement']
* @uses $GLOBALS['strInnoDBAutoextendIncrementDesc']
* @uses $GLOBALS['strInnoDBBufferPoolSize']
* @uses $GLOBALS['strInnoDBBufferPoolSizeDesc']
* @uses PMA_ENGINE_DETAILS_TYPE_NUMERIC
* @uses PMA_ENGINE_DETAILS_TYPE_SIZE
* @return array
*/
function getVariables()
{
return array(
'innodb_data_home_dir' => array(
'title' => $GLOBALS['strInnoDBDataHomeDir'],
'desc' => $GLOBALS['strInnoDBDataHomeDirDesc'],
),
'innodb_data_file_path' => array(
'title' => $GLOBALS['strInnoDBDataFilePath'],
),
'innodb_autoextend_increment' => array(
'title' => $GLOBALS['strInnoDBAutoextendIncrement'],
'desc' => $GLOBALS['strInnoDBAutoextendIncrementDesc'],
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_buffer_pool_size' => array(
'title' => $GLOBALS['strInnoDBBufferPoolSize'],
'desc' => $GLOBALS['strInnoDBBufferPoolSizeDesc'],
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'innodb_additional_mem_pool_size' => array(
'title' => 'innodb_additional_mem_pool_size',
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'innodb_buffer_pool_awe_mem_mb' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'innodb_checksums' => array(
),
'innodb_commit_concurrency' => array(
),
'innodb_concurrency_tickets' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_doublewrite' => array(
),
'innodb_fast_shutdown' => array(
),
'innodb_file_io_threads' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_file_per_table' => array(
),
'innodb_flush_log_at_trx_commit' => array(
),
'innodb_flush_method' => array(
),
'innodb_force_recovery' => array(
),
'innodb_lock_wait_timeout' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_locks_unsafe_for_binlog' => array(
),
'innodb_log_arch_dir' => array(
),
'innodb_log_archive' => array(
),
'innodb_log_buffer_size' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'innodb_log_file_size' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'innodb_log_files_in_group' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_log_group_home_dir' => array(
),
'innodb_max_dirty_pages_pct' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_max_purge_lag' => array(
),
'innodb_mirrored_log_groups' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_open_files' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_support_xa' => array(
),
'innodb_sync_spin_loops' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_table_locks' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_thread_concurrency' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'innodb_thread_sleep_delay' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
);
}
 
/**
* @return string SQL query LIKE pattern
*/
function getVariablesLikePattern()
{
return 'innodb\\_%';
}
 
/**
* @uses $this->support
* @uses PMA_ENGINE_SUPPORT_YES
* @uses PMA_MYSQL_INT_VERSION
* @uses $GLOBALS['strBufferPool']
* @uses $GLOBALS['strInnodbStat']
* @return array detail pages
*/
function getInfoPages()
{
if ($this->support < PMA_ENGINE_SUPPORT_YES) {
return array();
}
$pages = array();
if (PMA_MYSQL_INT_VERSION >= 50002) {
$pages['Bufferpool'] = $GLOBALS['strBufferPool'];
}
$pages['Status'] = $GLOBALS['strInnodbStat'];
return $pages;
}
 
/**
* returns html tables with stats over inno db buffer pool
*
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_DBI_fetch_result()
* @uses PMA_formatNumber()
* @uses PMA_formatByteDown()
* @uses $GLOBALS['number_decimal_separator']
* @uses $GLOBALS['number_thousands_separator']
* @uses $GLOBALS['strBufferPoolUsage']
* @uses $GLOBALS['strTotalUC']
* @uses $GLOBALS['strInnoDBPages']
* @uses $GLOBALS['strFreePages']
* @uses $GLOBALS['strDirtyPages']
* @uses $GLOBALS['strDataPages']
* @uses $GLOBALS['strPagesToBeFlushed']
* @uses $GLOBALS['strBusyPages']
* @uses $GLOBALS['strLatchedPages']
* @uses $GLOBALS['strBufferPoolActivity']
* @uses $GLOBALS['strReadRequests']
* @uses $GLOBALS['strWriteRequests']
* @uses $GLOBALS['strBufferReadMisses']
* @uses $GLOBALS['strBufferWriteWaits']
* @uses $GLOBALS['strBufferReadMissesInPercent']
* @uses $GLOBALS['strBufferWriteWaitsInPercent']
* @uses join()
* @uses htmlspecialchars()
* @uses number_format()
* @return string html table with stats
*/
function getPageBufferpool()
{
if (PMA_MYSQL_INT_VERSION < 50002) {
return false;
}
// rabus: The following query is only possible because we know
// that we are on MySQL 5 here (checked above)!
// side note: I love MySQL 5 for this. :-)
$sql = '
SHOW STATUS
WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
OR Variable_name = \'Innodb_page_size\';';
$status = PMA_DBI_fetch_result( $sql, 0, 1 );
 
$output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n"
. ' <caption class="tblHeaders">' . "\n"
. ' ' . $GLOBALS['strBufferPoolUsage'] . "\n"
. ' </caption>' . "\n"
. ' <tfoot>' . "\n"
. ' <tr>' . "\n"
. ' <th colspan="2">' . "\n"
. ' ' . $GLOBALS['strTotalUC'] . "\n"
. ' : ' . PMA_formatNumber(
$status['Innodb_buffer_pool_pages_total'], 0)
. '&nbsp;' . $GLOBALS['strInnoDBPages']
. ' / '
. join('&nbsp;',
PMA_formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n"
. ' </th>' . "\n"
. ' </tr>' . "\n"
. ' </tfoot>' . "\n"
. ' <tbody>' . "\n"
. ' <tr class="odd">' . "\n"
. ' <th>' . $GLOBALS['strFreePages'] . '</th>' . "\n"
. ' <td class="value">'
. PMA_formatNumber($status['Innodb_buffer_pool_pages_free'], 0)
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="even">' . "\n"
. ' <th>' . $GLOBALS['strDirtyPages'] . '</th>' . "\n"
. ' <td class="value">'
. PMA_formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0)
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="odd">' . "\n"
. ' <th>' . $GLOBALS['strDataPages'] . '</th>' . "\n"
. ' <td class="value">'
. PMA_formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="even">' . "\n"
. ' <th>' . $GLOBALS['strPagesToBeFlushed'] . '</th>' . "\n"
. ' <td class="value">'
. PMA_formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="odd">' . "\n"
. ' <th>' . $GLOBALS['strBusyPages'] . '</th>' . "\n"
. ' <td class="value">'
. PMA_formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="even">' . "\n"
. ' <th>' . $GLOBALS['strLatchedPages'] . '</th>' . "\n"
. ' <td class="value">'
. PMA_formatNumber($status['Innodb_buffer_pool_pages_latched'], 0) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' </tbody>' . "\n"
. '</table>' . "\n\n"
. '<table class="data" id="table_innodb_bufferpool_activity">' . "\n"
. ' <caption class="tblHeaders">' . "\n"
. ' ' . $GLOBALS['strBufferPoolActivity'] . "\n"
. ' </caption>' . "\n"
. ' <tbody>' . "\n"
. ' <tr class="odd">' . "\n"
. ' <th>' . $GLOBALS['strReadRequests'] . '</th>' . "\n"
. ' <td class="value">'
. PMA_formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="even">' . "\n"
. ' <th>' . $GLOBALS['strWriteRequests'] . '</th>' . "\n"
. ' <td class="value">'
. PMA_formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="odd">' . "\n"
. ' <th>' . $GLOBALS['strBufferReadMisses'] . '</th>' . "\n"
. ' <td class="value">'
. PMA_formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="even">' . "\n"
. ' <th>' . $GLOBALS['strBufferWriteWaits'] . '</th>' . "\n"
. ' <td class="value">'
. PMA_formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="odd">' . "\n"
. ' <th>' . $GLOBALS['strBufferReadMissesInPercent'] . '</th>' . "\n"
. ' <td class="value">'
. ($status['Innodb_buffer_pool_read_requests'] == 0
? '---'
: htmlspecialchars(number_format($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 2, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator'])) . ' %') . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="even">' . "\n"
. ' <th>' . $GLOBALS['strBufferWriteWaitsInPercent'] . '</th>' . "\n"
. ' <td class="value">'
. ($status['Innodb_buffer_pool_write_requests'] == 0
? '---'
: htmlspecialchars(number_format($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 2, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator'])) . ' %') . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' </tbody>' . "\n"
. '</table>' . "\n";
return $output;
}
 
/**
* returns InnoDB status
*
* @uses htmlspecialchars()
* @uses PMA_DBI_fetch_value()
* @return string result of SHOW INNODB STATUS inside pre tags
*/
function getPageStatus()
{
return '<pre id="pre_innodb_status">' . "\n"
. htmlspecialchars(PMA_DBI_fetch_value('SHOW INNODB STATUS;')) . "\n"
. '</pre>' . "\n";
}
 
/**
* returns content for page $id
*
* @uses $this->getInfoPages()
* @uses array_key_exists()
* @param string $id page id
* @return string html output
*/
function getPage($id)
{
if ( ! array_key_exists( $id, $this->getInfoPages() ) ) {
return false;
}
 
$id = 'getPage' . $id;
 
return $this->$id();
}
 
/**
* returns string with filename for the MySQL helppage
* about this storage engne
*
* @return string mysql helppage filename
*/
function getMysqlHelpPage()
{
return 'innodb';
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/engines/memory.lib.php
0,0 → 1,24
<?php
/* $Id: memory.lib.php,v 1.1 2005/12/07 10:01:43 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* the MEMORY (HEAP) storage engine
*/
class PMA_StorageEngine_memory extends PMA_StorageEngine
{
/**
* returns array with variable names dedicated to MyISAM storage engine
*
* @return array variable names
*/
function getVariables()
{
return array(
'max_heap_table_size' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
);
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/engines/merge.lib.php
0,0 → 1,9
<?php
/* $Id: merge.lib.php,v 1.1 2005/12/07 10:49:43 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
class PMA_StorageEngine_merge extends PMA_StorageEngine
{
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/engines/mrg_myisam.lib.php
0,0 → 1,21
<?php
/* $Id: mrg_myisam.lib.php,v 1.1 2005/12/07 10:49:43 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
include_once './libraries/engines/merge.lib.php';
 
class PMA_StorageEngine_mrg_myisam extends PMA_StorageEngine_merge
{
/**
* returns string with filename for the MySQL helppage
* about this storage engne
*
* @return string mysql helppage filename
*/
function getMysqlHelpPage()
{
return 'merge';
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/engines/myisam.lib.php
0,0 → 1,59
<?php
/* $Id: myisam.lib.php,v 2.2 2005/12/07 09:51:29 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* the MyISAM storage engine
*/
class PMA_StorageEngine_myisam extends PMA_StorageEngine
{
/**
* returns array with variable names dedicated to MyISAM storage engine
*
* @return array variable names
*/
function getVariables()
{
return array(
'myisam_data_pointer_size' => array(
'title' => $GLOBALS['strMyISAMDataPointerSize'],
'desc' => $GLOBALS['strMyISAMDataPointerSizeDesc'],
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'myisam_recover_options' => array(
'title' => $GLOBALS['strMyISAMRecoverOptions'],
'desc' => $GLOBALS['strMyISAMRecoverOptionsDesc'],
),
'myisam_max_sort_file_size' => array(
'title' => $GLOBALS['strMyISAMMaxSortFileSize'],
'desc' => $GLOBALS['strMyISAMMaxSortFileSizeDesc'],
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'myisam_max_extra_sort_file_size' => array(
'title' => $GLOBALS['strMyISAMMaxExtraSortFileSize'],
'desc' => $GLOBALS['strMyISAMMaxExtraSortFileSizeDesc'],
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'myisam_repair_threads' => array(
'title' => $GLOBALS['strMyISAMRepairThreads'],
'desc' => $GLOBALS['strMyISAMRepairThreadsDesc'],
'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
),
'myisam_sort_buffer_size' => array(
'title' => $GLOBALS['strMyISAMSortBufferSize'],
'desc' => $GLOBALS['strMyISAMSortBufferSizeDesc'],
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'myisam_stats_method' => array(
),
'delay_key_write' => array(
),
'bulk_insert_buffer_size' => array(
'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
),
'skip_external_locking' => array(
),
);
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/engines/ndbcluster.lib.php
0,0 → 1,38
<?php
/* $Id: ndbcluster.lib.php,v 1.1 2005/12/07 10:41:35 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
class PMA_StorageEngine_ndbcluster extends PMA_StorageEngine
{
/**
* @return array
*/
function getVariables()
{
return array(
'ndb_connectstring' => array(
),
);
}
 
/**
* @return string SQL query LIKE pattern
*/
function getVariablesLikePattern()
{
return 'ndb\\_%';
}
 
/**
* returns string with filename for the MySQL helppage
* about this storage engne
*
* @return string mysql helppage filename
*/
function getMysqlHelpPage()
{
return 'ndbcluster';
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/export/csv.php
0,0 → 1,183
<?php
/* $Id: csv.php,v 2.9 2006/01/17 17:03:02 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Set of functions used to build CSV dumps of tables
*/
 
/**
* Outputs comment
*
* @param string Text of comment
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text) {
return TRUE;
}
 
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return TRUE;
}
 
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $what;
global $add_character;
global $export_separator;
global $enclosed;
global $escaped;
 
// Here we just prepare some values for export
if ($what == 'excel') {
$add_character = "\015\012";
$export_separator = isset($GLOBALS['excel_edition']) && $GLOBALS['excel_edition'] == 'mac' ? ';' : ',';
$enclosed = '"';
$escaped = '"';
if (isset($GLOBALS['showexcelnames']) && $GLOBALS['showexcelnames'] == 'yes') {
$GLOBALS['showcsvnames'] = 'yes';
}
} else {
if (empty($add_character)) {
$add_character = $GLOBALS['crlf'];
} else {
$add_character = str_replace('\\r', "\015", $add_character);
$add_character = str_replace('\\n', "\012", $add_character);
$add_character = str_replace('\\t', "\011", $add_character);
} // end if
$export_separator = str_replace('\\t', "\011", $export_separator);
}
return TRUE;
}
 
/**
* Outputs database header
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return TRUE;
}
 
/**
* Outputs database footer
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return TRUE;
}
 
/**
* Outputs create database database
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return TRUE;
}
 
/**
* Outputs the content of a table in CSV format
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what;
global $add_character;
global $export_separator;
global $enclosed;
global $escaped;
 
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
 
// If required, get fields name at the first line
if (isset($GLOBALS['showcsvnames']) && $GLOBALS['showcsvnames'] == 'yes') {
$schema_insert = '';
for ($i = 0; $i < $fields_cnt; $i++) {
if ($enclosed == '') {
$schema_insert .= stripslashes(PMA_DBI_field_name($result, $i));
} else {
$schema_insert .= $enclosed
. str_replace($enclosed, $escaped . $enclosed, stripslashes(PMA_DBI_field_name($result, $i)))
. $enclosed;
}
$schema_insert .= $export_separator;
} // end for
$schema_insert =trim(substr($schema_insert, 0, -1));
if (!PMA_exportOutputHandler($schema_insert . $add_character)) {
return FALSE;
}
} // end if
 
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = '';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$schema_insert .= $GLOBALS[$what . '_replace_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') {
// loic1 : always enclose fields
if ($what == 'excel') {
$row[$j] = ereg_replace("\015(\012)?", "\012", $row[$j]);
}
if ($enclosed == '') {
$schema_insert .= $row[$j];
} else {
$schema_insert .= $enclosed
. str_replace($enclosed, $escaped . $enclosed, $row[$j])
. $enclosed;
}
} else {
$schema_insert .= '';
}
if ($j < $fields_cnt-1) {
$schema_insert .= $export_separator;
}
} // end for
 
if (!PMA_exportOutputHandler($schema_insert . $add_character)) {
return FALSE;
}
} // end while
PMA_DBI_free_result($result);
 
return TRUE;
} // end of the 'PMA_getTableCsv()' function
?>
/Web/Maintenance/phpMyAdmin/libraries/export/htmlexcel.php
0,0 → 1,166
<?php
/* $Id: htmlexcel.php,v 1.2.2.1 2006/03/16 13:30:39 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Set of functions used to build CSV dumps of tables
*/
 
/**
* Outputs comment
*
* @param string Text of comment
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text) {
return TRUE;
}
 
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
if (!PMA_exportOutputHandler('
</table>
</div>
</body>
</html>
')) {
return FALSE;
}
return TRUE;
}
 
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $charset, $charset_of_file;
if (!PMA_exportOutputHandler('
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=<?php echo isset($charset_of_file) ? $charset_of_file : $charset; ?>" />
<style id="Classeur1_16681_Styles">
</style>
 
</head>
<body>
 
<div id="Classeur1_16681" align=center x:publishsource="Excel">
 
<table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse">
')) {
return FALSE;
}
 
return TRUE;
}
 
/**
* Outputs database header
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return TRUE;
}
 
/**
* Outputs database footer
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return TRUE;
}
 
/**
* Outputs create database database
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return TRUE;
}
 
/**
* Outputs the content of a table in CSV format
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what;
 
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
 
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_shownames']) && $GLOBALS[$what . '_shownames'] == 'yes') {
$schema_insert = '<tr>';
for ($i = 0; $i < $fields_cnt; $i++) {
$schema_insert .= '<td class=xl2216681 nowrap><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
} // end for
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end if
 
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = '<tr>';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$value = $GLOBALS[$what . '_replace_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') {
$value = $row[$j];
} else {
$value = '';
}
$schema_insert .= '<td class=xl2216681 nowrap>' . htmlspecialchars($value) . '</td>';
} // end for
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end while
PMA_DBI_free_result($result);
 
return TRUE;
}
?>
/Web/Maintenance/phpMyAdmin/libraries/export/htmlword.php
0,0 → 1,323
<?php
/* $Id: htmlword.php,v 1.7 2006/01/19 15:39:29 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Set of functions used to build CSV dumps of tables
*/
 
/**
* Outputs comment
*
* @param string Text of comment
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text) {
return TRUE;
}
 
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return PMA_exportOutputHandler('</body></html>');
}
 
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $charset, $charset_of_file;
return PMA_exportOutputHandler('<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=' . ( isset($charset_of_file) ? $charset_of_file : $charset ) .'" />
</head>
<body>');
}
 
/**
* Outputs database header
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
return PMA_exportOutputHandler('<h1>' . $GLOBALS['strDatabase'] . ' ' . $db . '</h1>');
}
 
/**
* Outputs database footer
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return TRUE;
}
 
/**
* Outputs create database database
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return TRUE;
}
 
/**
* Outputs the content of a table in CSV format
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
 
if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strDumpingData'] . ' ' . $table . '</h2>')) {
return FALSE;
}
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return FALSE;
}
 
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
 
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_shownames']) && $GLOBALS[$what . '_shownames'] == 'yes') {
$schema_insert = '<tr class="print-category">';
for ($i = 0; $i < $fields_cnt; $i++) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
} // end for
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end if
 
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = '<tr class="print-category">';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$value = $GLOBALS[$what . '_replace_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') {
$value = $row[$j];
} else {
$value = '';
}
$schema_insert .= '<td class="print">' . htmlspecialchars($value) . '</td>';
} // end for
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end while
PMA_DBI_free_result($result);
if (!PMA_exportOutputHandler('</table>')) {
return FALSE;
}
 
return TRUE;
}
 
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false)
{
global $cfgRelation;
 
if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strTableStructure'] . ' ' .$table . '</h2>')) {
return FALSE;
}
 
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
 
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result);
 
// Check if we can use Relations (Mike Beck)
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
 
if ($res_rel && count($res_rel) > 0) {
$have_rel = TRUE;
} else {
$have_rel = FALSE;
}
} else {
$have_rel = FALSE;
} // end if
 
/**
* Displays the table structure
*/
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return FALSE;
}
 
$columns_cnt = 4;
if ($do_relation && $have_rel) {
$columns_cnt++;
}
if ($do_comments && $cfgRelation['commwork']) {
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
}
 
$schema_insert = '<tr class="print-category">';
$schema_insert .= '<th class="print">' . htmlspecialchars($GLOBALS['strField']) . '</th>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars($GLOBALS['strType']) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars($GLOBALS['strNull']) . '</b></td>';
$schema_insert .= '<td class="print"><b>' . htmlspecialchars($GLOBALS['strDefault']) . '</b></td>';
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars($GLOBALS['strLinksTo']) . '</b></td>';
}
if ($do_comments && ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100)) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars($GLOBALS['strComments']) . '</b></td>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars('MIME') . '</b></td>';
$mime_map = PMA_getMIME($db, $table, true);
}
$schema_insert .= '</tr>';
 
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
 
while ($row = PMA_DBI_fetch_assoc($result)) {
 
$schema_insert = '<tr class="print-category">';
$type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001
// loic1: set or enum types: slashes single quotes inside options
if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) {
$tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
 
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = eregi_replace('BINARY', '', $type);
$type = eregi_replace('ZEROFILL', '', $type);
$type = eregi_replace('UNSIGNED', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
 
$binary = eregi('BINARY', $row['Type']);
$unsigned = eregi('UNSIGNED', $row['Type']);
$zerofill = eregi('ZEROFILL', $row['Type']);
}
$strAttribute = '&nbsp;';
if ($binary) {
$strAttribute = 'BINARY';
}
if ($unsigned) {
$strAttribute = 'UNSIGNED';
}
if ($zerofill) {
$strAttribute = 'UNSIGNED ZEROFILL';
}
if (!isset($row['Default'])) {
if ($row['Null'] != '') {
$row['Default'] = 'NULL';
}
} else {
$row['Default'] = $row['Default'];
}
 
$fmt_pre = '';
$fmt_post = '';
if (in_array($row['Field'], $unique_keys)) {
$fmt_pre = '<b>' . $fmt_pre;
$fmt_post = $fmt_post . '</b>';
}
if ($row['Key']=='PRI') {
$fmt_pre = '<i>' . $fmt_pre;
$fmt_post = $fmt_post . '</i>';
}
$schema_insert .= '<td class="print">' . $fmt_pre . htmlspecialchars($row['Field']) . $fmt_post . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars($type) . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars($row['Null'] == '' ? $GLOBALS['strNo'] : $GLOBALS['strYes']) . '</td>';
$schema_insert .= '<td class="print">' . htmlspecialchars(isset($row['Default']) ? $row['Default'] : '') . '</td>';
 
$field_name = $row['Field'];
 
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print">' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '') . '</td>';
}
if ($do_comments && $cfgRelation['commwork']) {
$schema_insert .= '<td class="print">' . ( isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '') . '</td>';
}
if ($do_mime && $cfgRelation['mimework']) {
$schema_insert .= '<td class="print">' . ( isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '') . '</td>';
}
 
$schema_insert .= '</tr>';
 
if (!PMA_exportOutputHandler($schema_insert)) {
return FALSE;
}
} // end while
PMA_DBI_free_result($result);
 
return PMA_exportOutputHandler('</table>');
}
?>
/Web/Maintenance/phpMyAdmin/libraries/export/latex.php
0,0 → 1,417
<?php
/* $Id: latex.php,v 2.16 2006/01/19 15:39:29 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Set of functions used to build dumps of tables
*/
 
/**
* Escapes some special characters for use in TeX/LaTeX
*
* @param string the string to convert
*
* @return string the converted string with escape codes
*
* @access private
*/
function PMA_texEscape($string) {
$escape = array('$', '%', '{', '}', '&', '#', '_', '^');
$cnt_escape = count($escape);
for ($k=0; $k < $cnt_escape; $k++) {
$string = str_replace($escape[$k], '\\' . $escape[$k], $string);
}
return $string;
}
 
/**
* Outputs comment
*
* @param string Text of comment
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text) {
return PMA_exportOutputHandler('% ' . $text . $GLOBALS['crlf']);
}
 
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return TRUE;
}
 
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $crlf;
global $cfg;
 
$head = '% phpMyAdmin LaTeX Dump' . $crlf
. '% version ' . PMA_VERSION . $crlf
. '% http://www.phpmyadmin.net' . $crlf
. '%' . $crlf
. '% ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host'];
if (!empty($cfg['Server']['port'])) {
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
. '% ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf
. '% ' . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf
. '% ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf;
return PMA_exportOutputHandler($head);
}
 
/**
* Outputs database header
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
global $crlf;
$head = '% ' . $crlf
. '% ' . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. '% ' . $crlf;
return PMA_exportOutputHandler($head);
}
 
/**
* Outputs database footer
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
return TRUE;
}
 
/**
* Outputs create database database
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return TRUE;
}
 
/**
* Outputs the content of a table in LaTeX table/sideways table environment
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
 
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
$columns[$i] = PMA_DBI_field_name($result, $i);
}
unset($i);
 
$buffer = $crlf . '%' . $crlf . '% ' . $GLOBALS['strData'] . ': ' . $table . $crlf . '%' . $crlf
. ' \\begin{longtable}{|';
 
for ($index=0;$index<$columns_cnt;$index++) {
$buffer .= 'l|';
}
$buffer .= '} ' . $crlf ;
 
$buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . $crlf;
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_caption'])
. '} \\label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_data_label']) . '} \\\\';
}
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
 
// show column names
if (isset($GLOBALS['latex_showcolumns'])) {
$buffer = '\\hline ';
for ($i = 0; $i < $columns_cnt; $i++) {
$buffer .= '\\multicolumn{1}{|c|}{\\textbf{' . PMA_texEscape(stripslashes($columns[$i])) . '}} & ';
}
 
$buffer = substr($buffer, 0, -2) . '\\\\ \\hline \hline ';
if (!PMA_exportOutputHandler($buffer . ' \\endfirsthead ' . $crlf)) {
return FALSE;
}
if (isset($GLOBALS['latex_caption'])) {
if (!PMA_exportOutputHandler('\\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_data_continued_caption']) . '} \\\\ ')) return FALSE;
}
if (!PMA_exportOutputHandler($buffer . '\\endhead \\endfoot' . $crlf)) {
return FALSE;
}
} else {
if (!PMA_exportOutputHandler('\\\\ \hline')) {
return FALSE;
}
}
 
// print the whole table
while ($record = PMA_DBI_fetch_assoc($result)) {
 
$buffer = '';
// print each row
for ($i = 0; $i < $columns_cnt; $i++) {
if ( isset($record[$columns[$i]]) && (!function_exists('is_null') || !is_null($record[$columns[$i]]))) {
$column_value = PMA_texEscape(stripslashes($record[$columns[$i]]));
} else {
$column_value = $GLOBALS['latex_replace_null'];
}
 
// last column ... no need for & character
if ($i == ($columns_cnt - 1)) {
$buffer .= $column_value;
} else {
$buffer .= $column_value . " & ";
}
}
$buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
}
 
$buffer = ' \\end{longtable}' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
 
PMA_DBI_free_result($result);
return TRUE;
 
} // end getTableLaTeX
 
/**
* Returns $table's structure as LaTeX
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param boolean whether to include relation comments
* @param boolean whether to include column comments
* @param boolean whether to include mime comments
*
* @return bool Whether it suceeded
*
* @access public
*/
// @@@ $strTableStructure
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false)
{
global $cfgRelation;
 
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result);
 
// Check if we can use Relations (Mike Beck)
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
 
if ($res_rel && count($res_rel) > 0) {
$have_rel = TRUE;
} else {
$have_rel = FALSE;
}
} else {
$have_rel = FALSE;
} // end if
 
/**
* Displays the table structure
*/
$buffer = $crlf . '%' . $crlf . '% ' . $GLOBALS['strStructure'] . ': ' . $table . $crlf . '%' . $crlf
. ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
 
$columns_cnt = 4;
$alignment = '|l|c|c|c|';
if ($do_relation && $have_rel) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_comments && $cfgRelation['commwork']) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
$alignment .='l|';
}
$buffer = $alignment . '} ' . $crlf ;
 
$header = ' \\hline ';
$header .= '\\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strField'] . '}} & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strType'] . '}} & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strNull'] . '}} & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strDefault'] . '}}';
if ($do_relation && $have_rel) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strLinksTo'] . '}}';
}
if ($do_comments && ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100)) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strComments'] . '}}';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
$mime_map = PMA_getMIME($db, $table, true);
}
 
$local_buffer = PMA_texEscape($table);
 
// Table caption for first page and label
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'. str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_structure_caption'])
. '} \\label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_structure_label'])
. '} \\\\' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline' . $crlf . '\\endfirsthead' . $crlf;
// Table caption on next pages
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'. str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_structure_continued_caption'])
. '} \\\\ ' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ';
 
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
 
while ($row = PMA_DBI_fetch_assoc($result)) {
 
$type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001
// loic1: set or enum types: slashes single quotes inside options
if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) {
$tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
 
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = eregi_replace('BINARY', '', $type);
$type = eregi_replace('ZEROFILL', '', $type);
$type = eregi_replace('UNSIGNED', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
 
$binary = eregi('BINARY', $row['Type']);
$unsigned = eregi('UNSIGNED', $row['Type']);
$zerofill = eregi('ZEROFILL', $row['Type']);
}
$strAttribute = '&nbsp;';
if ($binary) {
$strAttribute = 'BINARY';
}
if ($unsigned) {
$strAttribute = 'UNSIGNED';
}
if ($zerofill) {
$strAttribute = 'UNSIGNED ZEROFILL';
}
if (!isset($row['Default'])) {
if ($row['Null'] != '') {
$row['Default'] = 'NULL';
}
} else {
$row['Default'] = $row['Default'];
}
 
$field_name = $row['Field'];
 
$local_buffer = $field_name . "\000" . $type . "\000" . (($row['Null'] == '') ? $GLOBALS['strNo'] : $GLOBALS['strYes']) . "\000" . (isset($row['Default']) ? $row['Default'] : '');
 
if ($do_relation && $have_rel) {
$local_buffer .= "\000";
if (isset($res_rel[$field_name])) {
$local_buffer .= $res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')';
}
}
if ($do_comments && $cfgRelation['commwork']) {
$local_buffer .= "\000";
if (isset($comments[$field_name])) {
$local_buffer .= $comments[$field_name];
}
}
if ($do_mime && $cfgRelation['mimework']) {
$local_buffer .= "\000";
if (isset($mime_map[$field_name])) {
$local_buffer .= str_replace('_', '/', $mime_map[$field_name]['mimetype']);
}
}
$local_buffer = PMA_texEscape($local_buffer);
if ($row['Key']=='PRI') {
$pos=strpos($local_buffer, "\000");
$local_buffer = '\\textit{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
}
if (in_array($field_name, $unique_keys)) {
$pos=strpos($local_buffer, "\000");
$local_buffer = '\\textbf{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
}
$buffer = str_replace("\000", ' & ', $local_buffer);
$buffer .= ' \\\\ \\hline ' . $crlf;
 
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
} // end while
PMA_DBI_free_result($result);
 
$buffer = ' \\end{longtable}' . $crlf;
return PMA_exportOutputHandler($buffer);
} // end of the 'PMA_getTableStructureLaTeX()' function
?>
/Web/Maintenance/phpMyAdmin/libraries/export/pdf.php
0,0 → 1,402
<?php
/* $Id: pdf.php,v 1.3 2006/01/17 17:03:02 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Produce a PDF report (export) from a query
*/
 
 
define('FPDF_FONTPATH', './libraries/fpdf/font/');
//if ($charset == 'utf-8') {
define('PMA_PDF_FONT', 'FreeSans');
require_once('./libraries/fpdf/ufpdf.php');
class PMA_FPDF extends UFPDF
{
};
//} else {
// define('PMA_PDF_FONT', 'Arial');
// require_once('./libraries/fpdf/fpdf.php');
// class PMA_FPDF extends FPDF {
// };
//}
 
 
// Adapted from a LGPL script by Philip Clarke
 
class PMA_PDF extends PMA_FPDF
{
var $tablewidths;
var $headerset;
var $footerset;
 
// overloading of a fpdf function:
function _beginpage($orientation)
{
$this->page++;
// solved the problem of overwriting a page, if it already exists
if (!isset($this->pages[$this->page])) {
$this->pages[$this->page] = '';
}
$this->state = 2;
$this->x = $this->lMargin;
$this->y = $this->tMargin;
$this->lasth = 0;
$this->FontFamily = '';
//Page orientation
if (!$orientation) {
$orientation = $this->DefOrientation;
} else {
$orientation = strtoupper($orientation{0});
if ($orientation != $this->DefOrientation) {
$this->OrientationChanges[$this->page] = true;
}
}
if ($orientation != $this->CurOrientation) {
//Change orientation
if ($orientation == 'P') {
$this->wPt = $this->fwPt;
$this->hPt = $this->fhPt;
$this->w = $this->fw;
$this->h = $this->fh;
} else {
$this->wPt = $this->fhPt;
$this->hPt = $this->fwPt;
$this->w = $this->fh;
$this->h = $this->fw;
}
$this->PageBreakTrigger = $this->h - $this->bMargin;
$this->CurOrientation = $orientation;
}
}
 
function Header()
{
global $maxY;
 
// Check if header for this page already exists
if (!isset($this->headerset[$this->page])) {
$fullwidth = 0;
foreach ($this->tablewidths as $width) {
$fullwidth += $width;
}
$this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*2);
$this->cellFontSize = $this->FontSizePt ;
$this->SetFont(PMA_PDF_FONT, '', ($this->titleFontSize ? $this->titleFontSize : $this->FontSizePt));
$this->Cell(0, $this->FontSizePt, $this->titleText, 0, 1, 'C');
$l = ($this->lMargin);
$this->SetFont(PMA_PDF_FONT, '', $this->cellFontSize);
foreach ($this->colTitles as $col => $txt) {
$this->SetXY($l, ($this->tMargin));
$this->MultiCell($this->tablewidths[$col], $this->FontSizePt, $txt);
$l += $this->tablewidths[$col] ;
$maxY = ($maxY < $this->getY()) ? $this->getY() : $maxY ;
}
$this->SetXY($this->lMargin, $this->tMargin);
$this->setFillColor(200, 200, 200);
$l = ($this->lMargin);
foreach ($this->colTitles as $col => $txt) {
$this->SetXY($l, $this->tMargin);
$this->cell($this->tablewidths[$col], $maxY-($this->tMargin), '', 1, 0, 'L', 1);
$this->SetXY($l, $this->tMargin);
$this->MultiCell($this->tablewidths[$col], $this->FontSizePt, $txt, 0, 'C');
$l += $this->tablewidths[$col];
}
$this->setFillColor(255, 255, 255);
// set headerset
$this->headerset[$this->page] = 1;
}
 
$this->SetY($maxY);
}
 
function Footer()
{
// Check if footer for this page already exists
if (!isset($this->footerset[$this->page])) {
$this->SetY(-15);
//Page number
$this->Cell(0, 10, $GLOBALS['strPageNumber'] .' '.$this->PageNo() .'/{nb}', 'T', 0, 'C');
 
// set footerset
$this->footerset[$this->page] = 1;
}
}
 
function morepagestable($lineheight=8)
{
// some things to set and 'remember'
$l = $this->lMargin;
$startheight = $h = $this->GetY();
$startpage = $currpage = $this->page;
 
// calculate the whole width
$fullwidth = 0;
foreach ($this->tablewidths as $width) {
$fullwidth += $width;
}
 
// Now let's start to write the table
$row = 0;
$tmpheight = array();
$maxpage = 0;
 
while ($data = PMA_DBI_fetch_row($this->results)) {
$this->page = $currpage;
// write the horizontal borders
$this->Line($l, $h, $fullwidth+$l, $h);
// write the content and remember the height of the highest col
foreach ($data as $col => $txt) {
$this->page = $currpage;
$this->SetXY($l, $h);
$this->MultiCell($this->tablewidths[$col], $lineheight, $txt, 0, $this->colAlign[$col]);
 
$l += $this->tablewidths[$col];
 
if (!isset($tmpheight[$row.'-'.$this->page])) {
$tmpheight[$row.'-'.$this->page] = 0;
}
if ($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
$tmpheight[$row.'-'.$this->page] = $this->GetY();
}
if ($this->page > $maxpage) {
$maxpage = $this->page;
}
unset($data[$col]);
}
 
// get the height we were in the last used page
$h = $tmpheight[$row.'-'.$maxpage];
// set the "pointer" to the left margin
$l = $this->lMargin;
// set the $currpage to the last page
$currpage = $maxpage;
unset($data[$row]);
$row++;
}
// draw the borders
// we start adding a horizontal line on the last page
$this->page = $maxpage;
$this->Line($l, $h, $fullwidth+$l, $h);
// now we start at the top of the document and walk down
for ($i = $startpage; $i <= $maxpage; $i++) {
$this->page = $i;
$l = $this->lMargin;
$t = ($i == $startpage) ? $startheight : $this->tMargin;
$lh = ($i == $maxpage) ? $h : $this->h-$this->bMargin;
$this->Line($l, $t, $l, $lh);
foreach ($this->tablewidths as $width) {
$l += $width;
$this->Line($l, $t, $l, $lh);
}
}
// set it to the last page, if not it'll cause some problems
$this->page = $maxpage;
}
 
 
function mysql_report($query, $attr = array())
{
foreach ($attr as $key => $val){
$this->$key = $val ;
}
 
// Pass 1 for column widths
// TODO: force here a LIMIT to speed up pass 1 ?
$this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
$this->numFields = PMA_DBI_num_fields($this->results);
$this->fields = PMA_DBI_get_fields_meta($this->results);
 
// if column widths not set
if (!isset($this->tablewidths)){
 
// starting col width
$this->sColWidth = ($this->w - $this->lMargin - $this->rMargin) / $this->numFields;
 
// loop through results header and set initial col widths/ titles/ alignment
// if a col title is less than the starting col width / reduce that column size
for ($i=0; $i < $this->numFields; $i++){
$stringWidth = $this->getstringwidth($this->fields[$i]->name) + 6 ;
// set any column titles less than the start width to the column title width
if (($stringWidth) < $this->sColWidth){
$colFits[$i] = $stringWidth ;
}
$this->colTitles[$i] = $this->fields[$i]->name;
switch ($this->fields[$i]->type){
case 'int':
$this->colAlign[$i] = 'R';
break;
default:
$this->colAlign[$i] = 'L';
}
}
 
// loop through the data, any column whose contents is bigger i
// that the col size is resized
while ($row = PMA_DBI_fetch_row($this->results)) {
foreach ($colFits as $key => $val) {
$stringWidth = $this->getstringwidth($row[$key]) + 6 ;
if ($stringWidth > $this->sColWidth) {
// any col where row is bigger than the start width is now discarded
unset($colFits[$key]);
} else {
// if text is not bigger than the current column width setting enlarge the column
if ($stringWidth > $val) {
$colFits[$key] = ($stringWidth) ;
}
}
}
}
 
$totAlreadyFitted = 0;
foreach ($colFits as $key => $val){
// set fitted columns to smallest size
$this->tablewidths[$key] = $val;
// to work out how much (if any) space has been freed up
$totAlreadyFitted += $val;
}
 
$surplus = (sizeof($colFits) * $this->sColWidth) - $totAlreadyFitted;
for ($i=0; $i < $this->numFields; $i++) {
if (!in_array($i, array_keys($colFits))) {
$this->tablewidths[$i] = $this->sColWidth + ($surplus / ($this->numFields - sizeof($colFits)));
}
}
 
ksort($this->tablewidths);
 
}
 
PMA_DBI_free_result($this->results);
 
// Pass 2
 
$this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
$this->Open();
$this->setY($this->tMargin);
$this->AddPage();
$this->morepagestable($this->FontSizePt);
PMA_DBI_free_result($this->results);
 
} // end of mysql_report function
 
} // end of PMA_PDF class
 
/**
* Outputs comment
*
* @param string Text of comment
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text)
{
return TRUE;
}
 
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
return TRUE;
}
 
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
return TRUE;
}
 
/**
* Outputs database header
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
return TRUE;
}
 
/**
* Outputs database footer
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return TRUE;
}
 
/**
* Outputs create database database
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return TRUE;
}
 
/**
* Outputs the content of a table in PDF format
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
global $pdf_report_title;
 
// TODO: user-defined page orientation, paper size
$pdf = new PMA_PDF('L', 'pt', 'A3');
 
$pdf->AddFont('FreeSans', '', 'FreeSans.php');
$pdf->AddFont('FreeSans', 'B', 'FreeSansBold.php');
$pdf->SetFont(PMA_PDF_FONT, '', 11.5);
$pdf->AliasNbPages();
$attr=array('titleFontSize' => 18, 'titleText' => $pdf_report_title);
$pdf->mysql_report($sql_query, $attr);
 
// instead of $pdf->Output():
if ($pdf->state < 3) {
$pdf->Close();
}
if (!PMA_exportOutputHandler($pdf->buffer)) {
return FALSE;
}
 
return TRUE;
} // end of the 'PMA_exportData()' function
?>
/Web/Maintenance/phpMyAdmin/libraries/export/sql.php
0,0 → 1,654
<?php
/* $Id: sql.php,v 2.53.2.1 2006/05/05 09:20:37 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* Set of functions used to build SQL dumps of tables
*/
 
/**
* Marker for comments, -- is needed for ANSI SQL.
*/
$GLOBALS['comment_marker'] = '-- ';
 
/**
* Avoids undefined variables, use NULL so isset() returns false
*/
if ( ! isset( $use_backquotes ) ) {
$use_backquotes = null;
}
 
/**
* Outputs comment
*
* @param string Text of comment
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text)
{
return PMA_exportOutputHandler($GLOBALS['comment_marker'] . $text . $GLOBALS['crlf']);
}
 
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
global $crlf;
 
$foot = '';
 
if (isset($GLOBALS['disable_fk'])) {
$foot .= $crlf . 'SET FOREIGN_KEY_CHECKS=1;' . $crlf;
}
 
if (isset($GLOBALS['use_transaction'])) {
$foot .= $crlf . 'COMMIT;' . $crlf;
}
 
return PMA_exportOutputHandler($foot);
}
 
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
global $crlf;
global $cfg;
 
if (PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compat']) && $GLOBALS['sql_compat'] != 'NONE') {
PMA_DBI_try_query('SET SQL_MODE="' . $GLOBALS['sql_compat'] . '"');
}
 
$head = $GLOBALS['comment_marker'] . 'phpMyAdmin SQL Dump' . $crlf
. $GLOBALS['comment_marker'] . 'version ' . PMA_VERSION . $crlf
. $GLOBALS['comment_marker'] . 'http://www.phpmyadmin.net' . $crlf
. $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host'];
if (!empty($cfg['Server']['port'])) {
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf;
 
if (isset($GLOBALS['header_comment']) && !empty($GLOBALS['header_comment'])) {
$lines = explode('\n', $GLOBALS['header_comment']);
$head .= $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . implode($crlf . $GLOBALS['comment_marker'], $lines) . $crlf
. $GLOBALS['comment_marker'] . $crlf;
}
 
if (isset($GLOBALS['disable_fk'])) {
$head .= $crlf . 'SET FOREIGN_KEY_CHECKS=0;' . $crlf;
}
 
if (isset($GLOBALS['use_transaction'])) {
$head .= $crlf .'SET AUTOCOMMIT=0;' . $crlf
. 'START TRANSACTION;' . $crlf . $crlf;
}
 
return PMA_exportOutputHandler($head);
}
 
/**
* Outputs create database database
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
global $crlf;
if (isset($GLOBALS['drop_database'])) {
if (!PMA_exportOutputHandler('DROP DATABASE ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : $db) . ';' . $crlf)) {
return FALSE;
}
}
$create_query = 'CREATE DATABASE ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : $db);
if (PMA_MYSQL_INT_VERSION >= 40101) {
$collation = PMA_getDbCollation($db);
if (strpos($collation, '_')) {
$create_query .= ' DEFAULT CHARACTER SET ' . substr($collation, 0, strpos($collation, '_')) . ' COLLATE ' . $collation;
} else {
$create_query .= ' DEFAULT CHARACTER SET ' . $collation;
}
}
$create_query .= ';' . $crlf;
if (!PMA_exportOutputHandler($create_query)) {
return FALSE;
}
if (isset($GLOBALS['use_backquotes']) && PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compat']) && $GLOBALS['sql_compat'] == 'NONE') {
return PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf);
}
return PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
}
 
/**
* Outputs database header
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
global $crlf;
$head = $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. $GLOBALS['comment_marker'] . $crlf;
return PMA_exportOutputHandler($head);
}
 
/**
* Outputs database footer
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
$result = TRUE;
if (isset($GLOBALS['sql_constraints'])) {
$result = PMA_exportOutputHandler($GLOBALS['sql_constraints']);
unset($GLOBALS['sql_constraints']);
}
return $result;
}
 
/**
* Returns $table's CREATE definition
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param boolean whether to include creation/update/check dates
*
* @return string resulting schema
*
* @global boolean whether to add 'drop' statements or not
* @global boolean whether to use backquotes to allow the use of special
* characters in database, table and fields names or not
*
* @access public
*/
function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
{
global $drop;
global $use_backquotes;
global $cfgRelation;
global $sql_constraints;
 
$schema_create = '';
$auto_increment = '';
$new_crlf = $crlf;
 
// need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli
$result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table) . '\'', null, PMA_DBI_QUERY_STORE);
if ($result != FALSE) {
if (PMA_DBI_num_rows($result) > 0) {
$tmpres = PMA_DBI_fetch_assoc($result);
if (isset($GLOBALS['sql_auto_increment']) && !empty($tmpres['Auto_increment'])) {
$auto_increment .= ' AUTO_INCREMENT=' . $tmpres['Auto_increment'] . ' ';
}
 
if ($show_dates && isset($tmpres['Create_time']) && !empty($tmpres['Create_time'])) {
$schema_create .= $GLOBALS['comment_marker'] . $GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Create_time'])) . $crlf;
$new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf;
}
 
if ($show_dates && isset($tmpres['Update_time']) && !empty($tmpres['Update_time'])) {
$schema_create .= $GLOBALS['comment_marker'] . $GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Update_time'])) . $crlf;
$new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf;
}
 
if ($show_dates && isset($tmpres['Check_time']) && !empty($tmpres['Check_time'])) {
$schema_create .= $GLOBALS['comment_marker'] . $GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Check_time'])) . $crlf;
$new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf;
}
}
PMA_DBI_free_result($result);
}
 
$schema_create .= $new_crlf;
 
if (!empty($drop)) {
$schema_create .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table, $use_backquotes) . ';' . $crlf;
}
 
// Steve Alberty's patch for complete table dump,
// Whether to quote table and fields names or not
if ($use_backquotes) {
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 1');
} else {
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0');
}
 
$result = PMA_DBI_query('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), null, PMA_DBI_QUERY_UNBUFFERED);
if ($result != FALSE && ($row = PMA_DBI_fetch_row($result))) {
$create_query = $row[1];
unset($row);
 
// Convert end of line chars to one that we want (note that MySQL doesn't return query it will accept in all cases)
if (strpos($create_query, "(\r\n ")) {
$create_query = str_replace("\r\n", $crlf, $create_query);
} elseif (strpos($create_query, "(\n ")) {
$create_query = str_replace("\n", $crlf, $create_query);
} elseif (strpos($create_query, "(\r ")) {
$create_query = str_replace("\r", $crlf, $create_query);
}
 
// Should we use IF NOT EXISTS?
if (isset($GLOBALS['if_not_exists'])) {
$create_query = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_query);
}
 
// are there any constraints to cut out?
if (preg_match('@CONSTRAINT|FOREIGN[\s]+KEY@', $create_query)) {
 
// Split the query into lines, so we can easily handle it. We know lines are separated by $crlf (done few lines above).
$sql_lines = explode($crlf, $create_query);
$sql_count = count($sql_lines);
 
// lets find first line with constraints
for ($i = 0; $i < $sql_count; $i++) {
if (preg_match('@^[\s]*(CONSTRAINT|FOREIGN[\s]+KEY)@', $sql_lines[$i])) {
break;
}
}
 
// If we really found a constraint
if ($i != $sql_count) {
 
// remove , from the end of create statement
$sql_lines[$i - 1] = preg_replace('@,$@', '', $sql_lines[$i - 1]);
 
// prepare variable for constraints
if (!isset($sql_constraints)) {
if (isset($GLOBALS['no_constraints_comments'])) {
$sql_constraints = '';
} else {
$sql_constraints = $crlf . $GLOBALS['comment_marker'] .
$crlf . $GLOBALS['comment_marker'] . $GLOBALS['strConstraintsForDumped'] .
$crlf . $GLOBALS['comment_marker'] . $crlf;
}
}
 
// comments for current table
if (!isset($GLOBALS['no_constraints_comments'])) {
$sql_constraints .= $crlf . $GLOBALS['comment_marker'] .
$crlf . $GLOBALS['comment_marker'] . $GLOBALS['strConstraintsForTable'] . ' ' . PMA_backquote($table) .
$crlf . $GLOBALS['comment_marker'] . $crlf;
}
 
// let's do the work
$sql_constraints .= 'ALTER TABLE ' . PMA_backquote($table) . $crlf;
 
$first = TRUE;
for ($j = $i; $j < $sql_count; $j++) {
if (preg_match('@CONSTRAINT|FOREIGN[\s]+KEY@', $sql_lines[$j])) {
if (!$first) {
$sql_constraints .= $crlf;
}
if (strpos($sql_lines[$j], 'CONSTRAINT') === FALSE) {
$sql_constraints .= preg_replace('/(FOREIGN[\s]+KEY)/', 'ADD \1', $sql_lines[$j]);
} else {
$sql_constraints .= preg_replace('/(CONSTRAINT)/', 'ADD \1', $sql_lines[$j]);
}
$first = FALSE;
} else {
break;
}
}
$sql_constraints .= ';' . $crlf;
$create_query = implode($crlf, array_slice($sql_lines, 0, $i)) . $crlf . implode($crlf, array_slice($sql_lines, $j, $sql_count - 1));
unset($sql_lines);
}
}
$schema_create .= $create_query;
}
 
$schema_create .= $auto_increment;
 
PMA_DBI_free_result($result);
return $schema_create;
} // end of the 'PMA_getTableDef()' function
 
 
/**
* Returns $table's comments, relations etc.
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param boolean whether to include relation comments
* @param boolean whether to include column comments
* @param boolean whether to include mime comments
*
* @return string resulting comments
*
* @access public
*/
function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comments = false, $do_mime = false)
{
global $cfgRelation;
global $use_backquotes;
global $sql_constraints;
 
$schema_create = '';
 
// triggered only for MySQL < 4.1.x (pmadb-style comments)
if ($do_comments && $cfgRelation['commwork']) {
if (!($comments_map = PMA_getComments($db, $table))) {
unset($comments_map);
}
}
 
// Check if we can use Relations (Mike Beck)
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
 
if ($res_rel && count($res_rel) > 0) {
$have_rel = TRUE;
} else {
$have_rel = FALSE;
}
} else {
$have_rel = FALSE;
} // end if
 
if ($do_mime && $cfgRelation['mimework']) {
if (!($mime_map = PMA_getMIME($db, $table, true))) {
unset($mime_map);
}
}
 
if (isset($comments_map) && count($comments_map) > 0) {
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strCommentsForTable']. ' ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf;
foreach ($comments_map AS $comment_field => $comment) {
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment_field, $use_backquotes) . $crlf
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment, $use_backquotes) . $crlf;
}
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
}
 
if (isset($mime_map) && count($mime_map) > 0) {
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strMIMETypesForTable']. ' ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf;
@reset($mime_map);
foreach ($mime_map AS $mime_field => $mime) {
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime_field, $use_backquotes) . $crlf
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime['mimetype'], $use_backquotes) . $crlf;
}
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
}
 
if ($have_rel) {
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strRelationsForTable']. ' ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf;
foreach ($res_rel AS $rel_field => $rel) {
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel_field, $use_backquotes) . $crlf
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel['foreign_table'], $use_backquotes)
. ' -> ' . PMA_backquote($rel['foreign_field'], $use_backquotes) . $crlf;
}
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
}
 
return $schema_create;
 
} // end of the 'PMA_getTableComments()' function
 
/**
* Outputs table's structure
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param boolean whether to include relation comments
* @param boolean whether to include column comments
* @param boolean whether to include mime comments
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, $comments = FALSE, $mime = FALSE, $dates = FALSE)
{
$formatted_table_name = (isset($GLOBALS['use_backquotes']))
? PMA_backquote($table)
: '\'' . $table . '\'';
$dump = $crlf
. $GLOBALS['comment_marker'] . '--------------------------------------------------------' . $crlf
. $crlf . $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strTableStructure'] . ' ' . $formatted_table_name . $crlf
. $GLOBALS['comment_marker'] . $crlf
. PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf
. PMA_getTableComments($db, $table, $crlf, $relation, $comments, $mime);
 
 
return PMA_exportOutputHandler($dump);
}
 
/**
* Dispatches between the versions of 'getTableContent' to use depending
* on the php version
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @global boolean whether to use backquotes to allow the use of special
* characters in database, table and fields names or not
* @global integer the number of records
* @global integer the current record position
*
* @access public
*
* @see PMA_getTableContentFast(), PMA_getTableContentOld()
*
* @author staybyte
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $use_backquotes;
global $rows_cnt;
global $current_row;
 
$formatted_table_name = (isset($GLOBALS['use_backquotes']))
? PMA_backquote($table)
: '\'' . $table . '\'';
$head = $crlf
. $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strDumpingData'] . ' ' . $formatted_table_name . $crlf
. $GLOBALS['comment_marker'] . $crlf .$crlf;
 
if (!PMA_exportOutputHandler($head)) {
return FALSE;
}
 
$buffer = '';
 
// analyze the query to get the true column names, not the aliases
// (this fixes an undefined index, also if Complete inserts
// are used, we did not get the true column name in case of aliases)
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query));
 
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
if ($result != FALSE) {
$fields_cnt = PMA_DBI_num_fields($result);
 
// Get field information
$fields_meta = PMA_DBI_get_fields_meta($result);
$field_flags = array();
for ($j = 0; $j < $fields_cnt; $j++) {
$field_flags[$j] = PMA_DBI_field_flags($result, $j);
}
 
for ($j = 0; $j < $fields_cnt; $j++) {
if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) {
$field_set[$j] = PMA_backquote($analyzed_sql[0]['select_expr'][$j]['column'], $use_backquotes);
} else {
$field_set[$j] = PMA_backquote($fields_meta[$j]->name, $use_backquotes);
}
}
 
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'update') {
// update
$schema_insert = 'UPDATE ';
if (isset($GLOBALS['sql_ignore'])) {
$schema_insert .= 'IGNORE ';
}
$schema_insert .= PMA_backquote($table, $use_backquotes) . ' SET ';
unset($GLOBALS['extended_ins']);
} else {
// insert or replace
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'replace') {
$sql_command = 'REPLACE';
} else {
$sql_command = 'INSERT';
}
 
// delayed inserts?
if (isset($GLOBALS['delayed'])) {
$insert_delayed = ' DELAYED';
} else {
$insert_delayed = '';
}
 
// insert ignore?
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'insert' && isset($GLOBALS['sql_ignore'])) {
$insert_delayed .= ' IGNORE';
}
 
// scheme for inserting fields
if (isset($GLOBALS['showcolumns'])) {
$fields = implode(', ', $field_set);
$schema_insert = $sql_command . $insert_delayed .' INTO ' . PMA_backquote($table, $use_backquotes)
. ' (' . $fields . ') VALUES ';
} else {
$schema_insert = $sql_command . $insert_delayed .' INTO ' . PMA_backquote($table, $use_backquotes)
. ' VALUES ';
}
}
 
$search = array("\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required
$replace = array('\0', '\n', '\r', '\Z');
$current_row = 0;
$query_size = 0;
$separator = isset($GLOBALS['extended_ins']) ? ',' : ';';
 
while ($row = PMA_DBI_fetch_row($result)) {
$current_row++;
for ($j = 0; $j < $fields_cnt; $j++) {
// NULL
if (!isset($row[$j]) || is_null($row[$j])) {
$values[] = 'NULL';
// a number
// timestamp is numeric on some MySQL 4.1, BLOBs are sometimes numeric
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp'
&& ! $fields_meta[$j]->blob) {
$values[] = $row[$j];
// a binary field
// Note: with mysqli, under MySQL 4.1.3, we get the flag
// "binary" for those field types (I don't know why)
} elseif (stristr($field_flags[$j], 'BINARY')
&& isset($GLOBALS['hexforbinary'])
&& $fields_meta[$j]->type != 'datetime'
&& $fields_meta[$j]->type != 'date'
&& $fields_meta[$j]->type != 'time'
&& $fields_meta[$j]->type != 'timestamp'
) {
// empty blobs need to be different, but '0' is also empty :-(
if (empty($row[$j]) && $row[$j] != '0') {
$values[] = '\'\'';
} else {
$values[] = '0x' . bin2hex($row[$j]);
}
// something else -> treat as a string
} else {
$values[] = '\'' . str_replace($search, $replace, PMA_sqlAddslashes($row[$j])) . '\'';
} // end if
} // end for
 
// should we make update?
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'update') {
 
$insert_line = $schema_insert;
for ($i = 0; $i < $fields_cnt; $i++) {
if ($i > 0) {
$insert_line .= ', ';
}
$insert_line .= $field_set[$i] . ' = ' . $values[$i];
}
 
$insert_line .= ' WHERE ' . PMA_getUvaCondition($result, $fields_cnt, $fields_meta, $row);
 
} else {
 
// Extended inserts case
if (isset($GLOBALS['extended_ins'])) {
if ($current_row == 1) {
$insert_line = $schema_insert . '(' . implode(', ', $values) . ')';
} else {
$insert_line = '(' . implode(', ', $values) . ')';
if (isset($GLOBALS['max_query_size']) && $GLOBALS['max_query_size'] > 0 && $query_size + strlen($insert_line) > $GLOBALS['max_query_size']) {
if (!PMA_exportOutputHandler(';' . $crlf)) {
return FALSE;
}
$query_size = 0;
$current_row = 1;
$insert_line = $schema_insert . $insert_line;
}
}
$query_size += strlen($insert_line);
}
// Other inserts case
else {
$insert_line = $schema_insert . '(' . implode(', ', $values) . ')';
}
}
unset($values);
 
if (!PMA_exportOutputHandler(($current_row == 1 ? '' : $separator . $crlf) . $insert_line)) {
return FALSE;
}
 
} // end while
if ($current_row > 0) {
if (!PMA_exportOutputHandler(';' . $crlf)) {
return FALSE;
}
}
} // end if ($result != FALSE)
PMA_DBI_free_result($result);
 
return TRUE;
} // end of the 'PMA_exportData()' function
?>
/Web/Maintenance/phpMyAdmin/libraries/export/xls.php
0,0 → 1,165
<?php
/* $Id: xls.php,v 2.1 2006/01/17 17:03:02 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
require_once('Spreadsheet/Excel/Writer.php');
 
/**
* Set of functions used to build MS Excel dumps of tables
*/
 
/**
* Outputs comment
*
* @param string Text of comment
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text)
{
return TRUE;
}
 
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter()
{
global $workbook;
global $tmp_filename;
 
$res = $workbook->close();
if (PEAR::isError($res)) {
echo $res->getMessage();
return FALSE;
}
if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
return FALSE;
}
unlink($tmp_filename);
 
return TRUE;
}
 
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader()
{
global $workbook;
global $tmp_filename;
 
if (empty($GLOBALS['cfg']['TempDir'])) {
return FALSE;
}
$tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xls_');
$workbook = new Spreadsheet_Excel_Writer($tmp_filename);
 
return TRUE;
}
 
/**
* Outputs database header
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db)
{
return TRUE;
}
 
/**
* Outputs database footer
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db)
{
return TRUE;
}
 
/**
* Outputs create database database
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db)
{
return TRUE;
}
 
/**
* Outputs the content of a table in CSV format
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
global $workbook;
 
$worksheet =& $workbook->addWorksheet($table);
$workbook->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
 
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
$col = 0;
 
// If required, get fields name at the first line
if (isset($GLOBALS['xls_shownames']) && $GLOBALS['xls_shownames'] == 'yes') {
$schema_insert = '';
for ($i = 0; $i < $fields_cnt; $i++) {
$worksheet->write(0, $i, stripslashes(PMA_DBI_field_name($result, $i)));
} // end for
$col++;
} // end if
 
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = '';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$worksheet->write($col, $j, $GLOBALS['xls_replace_null']);
} elseif ($row[$j] == '0' || $row[$j] != '') {
// FIXME: we should somehow handle character set here!
$worksheet->write($col, $j, $row[$j]);
} else {
$worksheet->write($col, $j, '');
}
} // end for
$col++;
} // end while
PMA_DBI_free_result($result);
 
return TRUE;
}
?>
/Web/Maintenance/phpMyAdmin/libraries/export/xml.php
0,0 → 1,158
<?php
/* $Id: xml.php,v 2.8 2006/01/17 17:03:02 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Set of functions used to build XML dumps of tables
*/
 
/**
* Outputs comment
*
* @param string Text of comment
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text) {
return PMA_exportOutputHandler('<!-- ' . $text . ' -->' . $GLOBALS['crlf']);
}
 
/**
* Outputs export footer
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportFooter() {
return TRUE;
}
 
/**
* Outputs export header
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportHeader() {
global $crlf;
global $cfg;
 
if ($GLOBALS['output_charset_conversion']) {
$charset = $GLOBALS['charset_of_file'];
} else {
$charset = $GLOBALS['charset'];
}
 
$head = '<?xml version="1.0" encoding="' . $charset . '" ?>' . $crlf
. '<!--' . $crlf
. '-' . $crlf
. '- phpMyAdmin XML Dump' . $crlf
. '- version ' . PMA_VERSION . $crlf
. '- http://www.phpmyadmin.net' . $crlf
. '-' . $crlf
. '- ' . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host'];
if (!empty($cfg['Server']['port'])) {
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
. '- ' . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf
. '- ' . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf
. '- ' . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf
. '-->' . $crlf . $crlf;
return PMA_exportOutputHandler($head);
}
 
/**
* Outputs database header
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBHeader($db) {
global $crlf;
$head = '<!--' . $crlf
. '- ' . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. '-->' . $crlf
. '<' . $db . '>' . $crlf;
return PMA_exportOutputHandler($head);
}
 
/**
* Outputs database footer
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBFooter($db) {
global $crlf;
return PMA_exportOutputHandler('</' . $db . '>' . $crlf);
}
 
/**
* Outputs create database database
*
* @param string Database name
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportDBCreate($db) {
return TRUE;
}
 
 
/**
* Outputs the content of a table
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
 
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
$columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
}
unset($i);
 
$buffer = ' <!-- ' . $GLOBALS['strTable'] . ' ' . $table . ' -->' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
 
while ($record = PMA_DBI_fetch_row($result)) {
$buffer = ' <' . $table . '>' . $crlf;
for ($i = 0; $i < $columns_cnt; $i++) {
if ( isset($record[$i]) && !is_null($record[$i])) {
$buffer .= ' <' . $columns[$i] . '>' . htmlspecialchars($record[$i])
. '</' . $columns[$i] . '>' . $crlf;
}
}
$buffer .= ' </' . $table . '>' . $crlf;
 
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
}
PMA_DBI_free_result($result);
 
return TRUE;
} // end of the 'PMA_getTableXML()' function
?>
/Web/Maintenance/phpMyAdmin/libraries/file_listing.php
0,0 → 1,89
<?php
/* $Id: file_listing.php,v 1.4 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
// Functions for listing directories
 
/**
* Returns array of filtered file names
*
* @param string directory to list
* @param string regullar expression to match files
* @returns array sorted file list on success, FALSE on failure
*/
function PMA_getDirContent($dir, $expression = '')
{
if ($handle = @opendir($dir)) {
$result = array();
if (substr($dir, -1) != '/') {
$dir .= '/';
}
while ($file = @readdir($handle)) {
if (is_file($dir . $file) && ($expression == '' || preg_match($expression, $file))) {
$result[] = $file;
}
}
@closedir($handle);
asort($result);
return $result;
} else {
return FALSE;
}
}
 
/**
* Returns options of filtered file names
*
* @param string directory to list
* @param string regullar expression to match files
* @param string currently active choice
* @returns array sorted file list on success, FALSE on failure
*/
function PMA_getFileSelectOptions($dir, $extensions = '', $active = '')
{
$list = PMA_getDirContent($dir, $extensions);
if ($list === FALSE) {
return FALSE;
}
$result = '';
foreach ($list as $key => $val) {
$result .= '<option value="'. htmlspecialchars($val) . '"';
if ($val == $active) {
$result .= ' selected="selected"';
}
$result .= '>' . htmlspecialchars($val) . '</option>' . "\n";
}
return $result;
}
 
/**
* Get currently supported decompressions.
*
* @returns string | separated list of extensions usable in PMA_getDirContent
*/
function PMA_supportedDecompressions()
{
global $cfg;
$compressions = '';
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
if (!empty($compressions)) {
$compressions .= '|';
}
$compressions .= 'gz';
}
if ($cfg['BZipDump'] && @function_exists('bzopen')) {
if (!empty($compressions)) {
$compressions .= '|';
}
$compressions .= 'bz2';
}
if ($cfg['ZipDump'] && @function_exists('gzinflate')) {
if (!empty($compressions)) {
$compressions .= '|';
}
$compressions .= 'zip';
}
 
return $compressions;
}
/Web/Maintenance/phpMyAdmin/libraries/footer.inc.php
0,0 → 1,145
<?php
/* $Id: footer.inc.php,v 2.7.2.5 2006/05/12 14:33:45 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* WARNING: This script has to be included at the very end of your code because
* it will stop the script execution!
*
* always use $GLOBALS, as this script is also included by functions
*
*/
 
require_once './libraries/relation.lib.php'; // for PMA_setHistory()
 
/**
* updates javascript variables in index.php for coorect working with querywindow
* and navigation frame refreshing
*/
?>
<script type="text/javascript" language="javascript">
//<![CDATA[
<?php
if (! isset($GLOBALS['no_history']) && isset($GLOBALS['db'])
&& strlen($GLOBALS['db']) && empty($GLOBALS['error_message'])) {
$table = isset($GLOBALS['table']) ? $GLOBALS['table'] : ''; ?>
// updates current settings
if (window.parent.setAll) {
window.parent.setAll('<?php echo $GLOBALS['lang']; ?>', '<?php echo htmlspecialchars($GLOBALS['collation_connection']); ?>', '<?php echo $GLOBALS['server']; ?>', '<?php echo htmlspecialchars($GLOBALS['db']); ?>', '<?php echo htmlspecialchars($table); ?>');
}
<?php } ?>
 
<?php if (! empty($GLOBALS['reload'])) { ?>
// refresh navigation frame content
if (window.parent.refreshLeft) {
window.parent.refreshLeft();
}
<?php } ?>
 
<?php
if (! isset($GLOBALS['no_history']) && empty($GLOBALS['error_message'])) {
if (isset($GLOBALS['LockFromUpdate']) && $GLOBALS['LockFromUpdate'] == '1'
&& isset($GLOBALS['sql_query'])) {
// When the button 'LockFromUpdate' was selected in the querywindow,
// it does not submit it's contents to
// itself. So we create a SQL-history entry here.
if ($GLOBALS['cfg']['QueryHistoryDB'] && $GLOBALS['cfgRelation']['historywork']) {
PMA_setHistory((isset($GLOBALS['db']) ? $GLOBALS['db'] : ''),
(isset($GLOBALS['table']) ? $GLOBALS['table'] : ''),
$GLOBALS['cfg']['Server']['user'],
$GLOBALS['sql_query']);
}
}
?>
// set current db, table and sql query in the querywindow
if (window.parent.refreshLeft) {
window.parent.reload_querywindow(
"<?php echo isset($GLOBALS['db']) ? htmlspecialchars(addslashes($GLOBALS['db'])) : '' ?>",
"<?php echo isset($GLOBALS['table']) ? htmlspecialchars(addslashes($GLOBALS['table'])) : '' ?>",
"<?php echo isset($GLOBALS['sql_query']) ? htmlspecialchars(urlencode($GLOBALS['sql_query'])) : ''; ?>");
}
<?php } ?>
 
<?php if (! empty($GLOBALS['focus_querywindow'])) { ?>
// set focus to the querywindow
if (parent.querywindow && !parent.querywindow.closed && parent.querywindow.location) {
self.focus();
}
<?php } ?>
 
if (window.parent.frames[1]) {
// reset content frame name, as querywindow needs to set a unique name
// before submitting form data, and navigation frame needs the original name
if (window.parent.frames[1].name != 'frame_content') {
window.parent.frames[1].name = 'frame_content';
}
if (window.parent.frames[1].id != 'frame_content') {
window.parent.frames[1].id = 'frame_content';
}
//window.parent.frames[1].setAttribute('name', 'frame_content');
//window.parent.frames[1].setAttribute('id', 'frame_content');
}
//]]>
</script>
<?php
 
// Link to itself to replicate windows including frameset
if (!isset($GLOBALS['checked_special'])) {
$GLOBALS['checked_special'] = FALSE;
}
 
if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && !$GLOBALS['checked_special']) {
echo '<div id="selflink">' . "\n";
echo '<a href="index.php?target=' . basename(PMA_getenv('SCRIPT_NAME'));
$url = PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : '');
if (!empty($url)) {
echo '&amp;' . $url;
}
echo '" target="_blank">' . $GLOBALS['strOpenNewWindow'] . '</a>' . "\n";
echo '</div>' . "\n";
}
 
/**
* Close database connections
*/
if (isset($GLOBALS['controllink']) && $GLOBALS['controllink']) {
@PMA_DBI_close($GLOBALS['controllink']);
}
if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) {
@PMA_DBI_close($GLOBALS['userlink']);
}
 
// Include possible custom footers
require_once './libraries/footer_custom.inc.php';
 
/**
* Generates profiling data if requested
*/
if (! empty($GLOBALS['cfg']['DBG']['enable'])
&& ! empty($GLOBALS['cfg']['DBG']['profile']['enable'])) {
//run the basic setup code first
require_once './libraries/dbg/setup.php';
//if the setup ran fine, then do the profiling
if (! empty($GLOBALS['DBG'])) {
require_once './libraries/dbg/profiling.php';
dbg_dump_profiling_results();
}
}
 
?>
</body>
</html>
<?php
/**
* Sends bufferized data
*/
if (! empty($GLOBALS['cfg']['OBGzip'])
&& ! empty($GLOBALS['ob_mode'])) {
PMA_outBufferPost($GLOBALS['ob_mode']);
}
 
/**
* Stops the script execution
*/
exit;
?>
/Web/Maintenance/phpMyAdmin/libraries/footer_custom.inc.php
0,0 → 1,11
<?php
/* $Id: footer_custom.inc.php,v 2.2 2005/11/25 08:58:11 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// This file includes all custom footers if they exist.
 
// Include site footer
if (file_exists('./config.footer.inc.php')) {
require('./config.footer.inc.php');
}
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/README
0,0 → 1,3
The official site for fdpf is http://www.fpdf.org/
 
This directory contains some files from the fpdf 1.51 distribution.
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/FreeSans.ctg.z
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/FreeSans.php
0,0 → 1,150
<?php
$type='TrueTypeUnicode';
$name='FreeSans';
$desc=array('Ascent'=>1148,'Descent'=>-459,'CapHeight'=>1148,'Flags'=>32,'FontBBox'=>'[-797 -459 1632 1148]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>600);
$up=-151;
$ut=50;
$cw=array(
13=>333, 32=>278, 33=>278, 34=>355, 35=>556, 36=>556, 37=>889, 38=>667, 39=>191, 40=>333, 41=>333, 42=>389, 43=>584, 44=>278, 45=>333, 46=>278,
47=>278, 48=>556, 49=>556, 50=>556, 51=>556, 52=>556, 53=>556, 54=>556, 55=>556, 56=>556, 57=>556, 58=>278, 59=>278, 60=>584, 61=>584, 62=>584,
63=>556, 64=>1015, 65=>667, 66=>667, 67=>722, 68=>722, 69=>667, 70=>611, 71=>778, 72=>722, 73=>278, 74=>500, 75=>667, 76=>556, 77=>833, 78=>722,
79=>778, 80=>667, 81=>778, 82=>722, 83=>667, 84=>611, 85=>722, 86=>667, 87=>944, 88=>667, 89=>667, 90=>611, 91=>278, 92=>278, 93=>278, 94=>469,
95=>556, 96=>333, 97=>556, 98=>556, 99=>500, 100=>556, 101=>556, 102=>278, 103=>556, 104=>556, 105=>222, 106=>222, 107=>500, 108=>222, 109=>833, 110=>556,
111=>556, 112=>556, 113=>556, 114=>333, 115=>500, 116=>278, 117=>556, 118=>500, 119=>722, 120=>500, 121=>500, 122=>500, 123=>334, 124=>260, 125=>334, 126=>584,
8364=>556, 1027=>611, 8218=>222, 402=>556, 8222=>333, 8230=>1000, 8224=>556, 8225=>556, 710=>333, 8240=>1000, 352=>667, 8249=>333, 338=>1000, 1036=>667, 381=>611, 1039=>722,
8216=>222, 8217=>221, 8220=>333, 8221=>333, 8226=>350, 8211=>556, 8212=>1000, 732=>333, 8482=>1000, 353=>500, 8250=>333, 339=>944, 1116=>500, 382=>500, 376=>667, 160=>278,
161=>333, 162=>556, 163=>556, 164=>556, 165=>556, 166=>260, 167=>556, 168=>333, 169=>737, 170=>370, 171=>556, 172=>584, 173=>333, 174=>737, 175=>333, 176=>606,
177=>584, 178=>351, 179=>351, 180=>333, 181=>556, 182=>537, 183=>278, 184=>333, 185=>351, 186=>365, 187=>556, 188=>869, 189=>869, 190=>869, 191=>611, 192=>667,
193=>667, 194=>667, 195=>667, 196=>667, 197=>667, 198=>1000, 199=>722, 200=>667, 201=>667, 202=>667, 203=>667, 204=>278, 205=>278, 206=>278, 207=>278, 208=>722,
209=>722, 210=>778, 211=>778, 212=>778, 213=>778, 214=>778, 215=>584, 216=>778, 217=>722, 218=>722, 219=>722, 220=>722, 221=>666, 222=>666, 223=>611, 224=>556,
225=>556, 226=>556, 227=>556, 228=>556, 229=>556, 230=>889, 231=>500, 232=>556, 233=>556, 234=>556, 235=>556, 236=>278, 237=>278, 238=>278, 239=>278, 240=>556,
241=>556, 242=>556, 243=>556, 244=>556, 245=>556, 246=>556, 247=>584, 248=>611, 249=>556, 250=>556, 251=>556, 252=>556, 253=>500, 254=>555, 255=>500, 256=>667,
257=>556, 258=>667, 259=>556, 260=>667, 261=>556, 262=>722, 263=>500, 264=>722, 265=>500, 266=>722, 267=>500, 268=>722, 269=>500, 270=>722, 271=>635, 272=>722,
273=>556, 274=>667, 275=>556, 276=>667, 277=>556, 278=>667, 279=>556, 280=>667, 281=>556, 282=>667, 283=>556, 284=>778, 285=>556, 286=>778, 287=>556, 288=>778,
289=>556, 290=>778, 291=>556, 292=>722, 293=>556, 294=>722, 295=>556, 296=>278, 297=>278, 298=>278, 299=>222, 300=>278, 301=>278, 302=>278, 303=>222, 304=>278,
305=>278, 306=>700, 307=>374, 308=>500, 309=>222, 310=>667, 311=>500, 312=>500, 313=>556, 314=>222, 315=>556, 316=>222, 317=>556, 318=>292, 319=>556, 320=>500,
321=>556, 322=>222, 323=>722, 324=>556, 325=>722, 326=>556, 327=>722, 328=>556, 329=>556, 330=>722, 331=>556, 332=>778, 333=>556, 334=>778, 335=>556, 336=>778,
337=>556, 340=>722, 341=>333, 342=>722, 343=>333, 344=>722, 345=>333, 346=>667, 347=>500, 348=>667, 349=>500, 350=>667, 351=>500, 354=>611, 355=>278, 356=>611,
357=>308, 358=>611, 359=>278, 360=>722, 361=>556, 362=>722, 363=>556, 364=>722, 365=>556, 366=>722, 367=>556, 368=>722, 369=>556, 370=>722, 371=>556, 372=>944,
373=>722, 374=>667, 375=>500, 377=>611, 378=>500, 379=>611, 380=>500, 383=>278, 384=>556, 386=>667, 387=>556, 388=>667, 389=>556, 390=>722, 391=>722, 392=>500,
393=>722, 395=>667, 396=>556, 398=>667, 399=>778, 400=>667, 401=>611, 403=>778, 409=>500, 413=>722, 414=>556, 415=>778, 421=>556, 423=>667, 424=>500, 425=>611,
427=>278, 429=>278, 430=>611, 452=>1311, 453=>1208, 454=>1056, 455=>1056, 456=>778, 457=>444, 458=>1158, 459=>944, 460=>778, 461=>667, 462=>556, 463=>278, 464=>278,
465=>778, 466=>556, 467=>722, 468=>556, 469=>722, 470=>556, 471=>722, 472=>556, 473=>722, 474=>556, 475=>722, 476=>556, 477=>556, 478=>667, 479=>556, 480=>667,
481=>556, 482=>1000, 483=>889, 484=>778, 485=>556, 486=>778, 487=>556, 488=>667, 489=>500, 490=>778, 491=>556, 492=>778, 493=>556, 496=>222, 497=>1333, 498=>1222,
499=>1056, 500=>778, 501=>556, 504=>722, 505=>556, 506=>667, 507=>556, 508=>1000, 509=>889, 510=>778, 511=>611, 512=>667, 513=>556, 514=>667, 515=>556, 516=>667,
517=>556, 518=>667, 519=>556, 520=>278, 521=>278, 522=>278, 523=>278, 524=>778, 525=>556, 526=>778, 527=>556, 528=>722, 529=>333, 530=>722, 531=>333, 532=>722,
533=>556, 534=>722, 535=>556, 536=>667, 537=>500, 538=>611, 539=>278, 542=>722, 543=>556, 550=>667, 551=>556, 552=>667, 553=>556, 554=>778, 555=>556, 556=>778,
557=>556, 558=>778, 559=>556, 560=>778, 561=>556, 562=>667, 563=>500, 592=>556, 593=>556, 594=>556, 595=>556, 596=>500, 598=>556, 599=>556, 600=>556, 601=>556,
603=>500, 604=>500, 608=>556, 609=>556, 613=>556, 614=>556, 615=>556, 616=>222, 617=>222, 618=>278, 621=>222, 623=>833, 624=>833, 625=>833, 626=>556, 627=>556,
629=>556, 633=>333, 634=>333, 635=>333, 636=>333, 637=>333, 638=>278, 639=>278, 642=>500, 643=>278, 644=>278, 645=>278, 647=>278, 648=>278, 649=>556, 652=>500,
653=>722, 654=>500, 656=>500, 668=>500, 670=>500, 672=>556, 711=>333, 714=>333, 715=>333, 728=>333, 729=>333, 730=>333, 731=>333, 733=>333, 768=>0, 769=>0,
770=>0, 771=>0, 772=>0, 774=>0, 775=>0, 776=>0, 778=>0, 779=>0, 780=>0, 783=>0, 785=>0, 786=>0, 787=>0, 788=>0, 806=>0, 807=>0,
808=>0, 884=>199, 885=>199, 890=>332, 894=>278, 900=>414, 901=>747, 902=>730, 903=>278, 904=>664, 905=>681, 906=>230, 908=>792, 910=>710, 911=>758, 912=>286,
913=>684, 914=>628, 915=>582, 916=>684, 917=>650, 918=>628, 919=>683, 920=>750, 921=>236, 922=>684, 923=>684, 924=>800, 925=>654, 926=>630, 927=>750, 928=>721,
929=>638, 931=>628, 932=>628, 933=>684, 934=>717, 935=>723, 936=>745, 937=>720, 938=>236, 939=>684, 940=>608, 941=>528, 942=>547, 943=>307, 944=>515, 945=>596,
946=>516, 947=>531, 948=>560, 949=>510, 950=>462, 951=>526, 952=>526, 953=>286, 954=>516, 955=>560, 956=>574, 957=>504, 958=>470, 959=>550, 960=>661, 961=>566,
962=>535, 963=>616, 964=>532, 965=>515, 966=>741, 967=>572, 968=>662, 969=>740, 970=>286, 971=>515, 972=>553, 973=>518, 974=>740, 1024=>667, 1025=>667, 1026=>766,
1028=>722, 1029=>667, 1030=>278, 1031=>278, 1032=>500, 1033=>1080, 1034=>1014, 1035=>766, 1037=>722, 1038=>650, 1040=>667, 1041=>667, 1042=>667, 1043=>611, 1044=>812, 1045=>667,
1046=>1023, 1047=>667, 1048=>728, 1049=>728, 1050=>667, 1051=>673, 1052=>844, 1053=>719, 1054=>778, 1055=>719, 1056=>667, 1057=>722, 1058=>611, 1059=>650, 1060=>936, 1061=>667,
1062=>741, 1063=>648, 1064=>828, 1065=>850, 1066=>897, 1067=>872, 1068=>667, 1069=>722, 1070=>1032, 1071=>702, 1072=>556, 1073=>556, 1074=>522, 1075=>430, 1076=>602, 1077=>556,
1078=>837, 1079=>500, 1080=>567, 1081=>567, 1082=>510, 1083=>557, 1084=>618, 1085=>558, 1086=>556, 1087=>557, 1088=>576, 1089=>500, 1090=>496, 1091=>500, 1092=>912, 1093=>500,
1094=>578, 1095=>520, 1096=>692, 1097=>712, 1098=>734, 1099=>690, 1100=>552, 1101=>500, 1102=>758, 1103=>543, 1104=>556, 1105=>556, 1106=>568, 1107=>430, 1108=>500, 1109=>500,
1110=>222, 1111=>278, 1112=>222, 1113=>840, 1114=>850, 1115=>568, 1117=>556, 1118=>500, 1119=>556, 1164=>667, 1165=>552, 1166=>667, 1167=>556, 1168=>611, 1169=>430, 1170=>611,
1171=>430, 1172=>611, 1173=>430, 1174=>1023, 1175=>837, 1176=>667, 1177=>500, 1178=>667, 1179=>500, 1180=>667, 1181=>500, 1182=>667, 1183=>500, 1184=>667, 1185=>500, 1186=>722,
1187=>556, 1188=>1060, 1189=>764, 1190=>722, 1191=>556, 1192=>722, 1193=>500, 1194=>722, 1195=>500, 1196=>611, 1197=>496, 1198=>667, 1199=>500, 1200=>667, 1201=>500, 1202=>667,
1203=>500, 1204=>774, 1205=>608, 1206=>642, 1207=>508, 1208=>642, 1209=>508, 1210=>642, 1211=>508, 1212=>778, 1213=>556, 1214=>688, 1215=>556, 1216=>278, 1217=>1023, 1218=>837,
1219=>667, 1220=>500, 1223=>722, 1224=>556, 1227=>642, 1228=>508, 1232=>667, 1233=>556, 1234=>667, 1235=>556, 1236=>1000, 1237=>889, 1238=>667, 1239=>556, 1240=>778, 1241=>556,
1242=>778, 1243=>556, 1244=>1023, 1245=>837, 1246=>667, 1247=>500, 1248=>667, 1249=>500, 1250=>728, 1251=>567, 1252=>728, 1253=>567, 1254=>778, 1255=>556, 1256=>778, 1257=>556,
1258=>778, 1259=>556, 1260=>722, 1261=>500, 1262=>650, 1263=>500, 1264=>650, 1265=>500, 1266=>650, 1267=>500, 1268=>648, 1269=>520, 1272=>872, 1273=>690, 1329=>722, 1330=>705,
1331=>774, 1332=>754, 1333=>722, 1334=>751, 1335=>485, 1336=>722, 1337=>782, 1338=>655, 1339=>699, 1340=>417, 1341=>853, 1342=>791, 1343=>711, 1344=>588, 1345=>663, 1346=>665,
1347=>665, 1348=>756, 1349=>623, 1350=>773, 1351=>603, 1352=>722, 1353=>648, 1354=>722, 1355=>751, 1356=>750, 1357=>722, 1358=>748, 1359=>667, 1360=>699, 1361=>623, 1362=>417,
1363=>785, 1364=>638, 1365=>778, 1366=>716, 1370=>222, 1371=>133, 1372=>325, 1373=>333, 1374=>344, 1377=>833, 1378=>556, 1379=>572, 1380=>581, 1381=>550, 1382=>588, 1383=>448,
1384=>556, 1385=>568, 1386=>582, 1387=>545, 1388=>301, 1389=>799, 1390=>556, 1391=>554, 1392=>533, 1393=>548, 1394=>552, 1395=>552, 1396=>544, 1397=>222, 1398=>544, 1399=>456,
1400=>556, 1401=>390, 1402=>833, 1403=>509, 1404=>547, 1405=>533, 1406=>610, 1407=>887, 1408=>556, 1409=>545, 1410=>352, 1411=>853, 1412=>588, 1413=>579, 1414=>690, 1415=>545,
1417=>278, 1418=>367, 1456=>70, 1457=>335, 1458=>329, 1459=>329, 1460=>70, 1461=>200, 1462=>200, 1463=>188, 1464=>188, 1465=>70, 1467=>329, 1468=>70, 1469=>70, 1470=>488,
1471=>200, 1472=>212, 1473=>0, 1474=>0, 1475=>278, 1476=>70, 1488=>640, 1489=>591, 1490=>466, 1491=>598, 1492=>622, 1493=>212, 1494=>351, 1495=>623, 1496=>608, 1497=>200,
1498=>526, 1499=>550, 1500=>600, 1501=>623, 1502=>621, 1503=>212, 1504=>378, 1505=>607, 1506=>587, 1507=>575, 1508=>568, 1509=>540, 1510=>590, 1511=>606, 1512=>547, 1513=>776,
1514=>687, 1792=>600, 1793=>201, 1794=>201, 1795=>201, 1796=>201, 1797=>500, 1798=>500, 1799=>500, 1800=>370, 1801=>370, 1802=>574, 1803=>574, 1804=>645, 1805=>574, 1808=>452,
1809=>452, 1810=>574, 1811=>645, 1812=>645, 1813=>509, 1814=>509, 1815=>682, 1816=>585, 1817=>404, 1818=>627, 1819=>718, 1820=>718, 1821=>484, 1822=>682, 1823=>600, 1824=>660,
1825=>682, 1826=>538, 1827=>718, 1828=>718, 1829=>718, 1830=>574, 1831=>574, 1832=>638, 1833=>585, 1834=>509, 1835=>682, 1836=>682, 1840=>1, 1841=>1, 1842=>1, 1843=>1,
1844=>1, 1845=>1, 1846=>1, 1847=>1, 1848=>1, 1849=>1, 1850=>1, 1851=>1, 1852=>1, 1853=>1, 1854=>1, 1855=>1, 1856=>1, 1857=>1, 1858=>1, 1859=>1,
1860=>1, 1861=>1, 1862=>1, 1863=>1, 1864=>1, 1865=>1, 1866=>1, 2305=>6, 2306=>6, 2309=>644, 2310=>816, 2311=>392, 2312=>392, 2313=>459, 2314=>661, 2315=>641,
2317=>423, 2320=>423, 2321=>816, 2323=>816, 2324=>816, 2325=>393, 2326=>622, 2327=>424, 2328=>472, 2329=>508, 2330=>517, 2331=>583, 2332=>549, 2333=>503, 2334=>538, 2335=>444,
2336=>480, 2337=>519, 2338=>479, 2339=>504, 2340=>439, 2341=>542, 2342=>427, 2343=>520, 2344=>415, 2345=>415, 2346=>401, 2347=>401, 2348=>442, 2349=>520, 2350=>463, 2351=>451,
2352=>319, 2353=>319, 2354=>549, 2355=>641, 2357=>442, 2358=>589, 2359=>398, 2360=>506, 2361=>430, 2364=>6, 2365=>438, 2366=>172, 2367=>172, 2368=>172, 2369=>6, 2370=>6,
2371=>6, 2373=>6, 2375=>6, 2376=>6, 2377=>172, 2379=>172, 2380=>172, 2381=>6, 2384=>898, 2385=>6, 2406=>584, 2407=>584, 2408=>584, 2409=>584, 2410=>584, 2411=>584,
2412=>584, 2413=>584, 2414=>584, 2415=>584, 2416=>898, 2433=>300, 2434=>400, 2435=>300, 2437=>640, 2438=>780, 2439=>520, 2440=>520, 2441=>530, 2442=>550, 2443=>620, 2444=>420,
2447=>480, 2448=>620, 2451=>620, 2452=>720, 2453=>652, 2454=>500, 2455=>490, 2456=>466, 2457=>540, 2458=>490, 2459=>540, 2460=>630, 2461=>590, 2462=>680, 2463=>510, 2464=>490,
2465=>520, 2466=>520, 2467=>470, 2468=>540, 2469=>490, 2470=>470, 2471=>490, 2472=>452, 2474=>560, 2475=>650, 2476=>480, 2477=>588, 2478=>480, 2479=>470, 2480=>480, 2482=>472,
2486=>512, 2487=>470, 2488=>470, 2489=>520, 2492=>160, 2494=>180, 2495=>180, 2496=>180, 2497=>320, 2498=>329, 2499=>195, 2500=>260, 2503=>340, 2504=>340, 2507=>740, 2508=>740,
2509=>400, 2519=>180, 2524=>540, 2525=>520, 2527=>470, 2528=>612, 2529=>420, 2530=>234, 2531=>360, 2534=>460, 2535=>420, 2536=>520, 2537=>540, 2538=>400, 2539=>400, 2540=>560,
2541=>390, 2542=>480, 2543=>420, 2544=>480, 2545=>470, 2546=>400, 2547=>470, 2548=>400, 2549=>400, 2550=>400, 2551=>120, 2552=>440, 2553=>420, 2554=>420, 2565=>744, 2566=>914,
2567=>690, 2568=>670, 2569=>596, 2570=>596, 2575=>498, 2576=>744, 2579=>596, 2580=>744, 2581=>550, 2582=>534, 2583=>618, 2584=>690, 2585=>546, 2586=>518, 2587=>592, 2588=>492,
2589=>574, 2590=>514, 2591=>526, 2592=>556, 2593=>524, 2594=>528, 2595=>574, 2596=>484, 2597=>534, 2598=>504, 2599=>534, 2600=>538, 2602=>534, 2603=>506, 2604=>562, 2605=>516,
2606=>546, 2607=>670, 2608=>538, 2610=>726, 2611=>726, 2613=>514, 2614=>546, 2616=>546, 2617=>517, 2620=>286, 2622=>172, 2623=>190, 2624=>190, 2625=>1, 2626=>1, 2631=>1,
2632=>1, 2635=>1, 2636=>1, 2637=>1, 2649=>534, 2650=>618, 2651=>492, 2652=>484, 2654=>506, 2662=>616, 2663=>480, 2664=>560, 2665=>480, 2666=>468, 2667=>492, 2668=>514,
2669=>538, 2670=>572, 2671=>560, 2672=>1, 2674=>498, 2675=>596, 2676=>900, 2689=>33, 2690=>33, 2693=>767, 2694=>961, 2695=>500, 2696=>495, 2697=>528, 2698=>702, 2699=>885,
2709=>501, 2710=>612, 2711=>619, 2712=>569, 2713=>532, 2714=>358, 2715=>620, 2716=>606, 2717=>602, 2718=>631, 2719=>495, 2720=>528, 2721=>531, 2722=>511, 2723=>614, 2724=>294,
2725=>344, 2726=>425, 2727=>345, 2728=>611, 2730=>512, 2731=>578, 2732=>428, 2733=>423, 2734=>231, 2735=>582, 2736=>344, 2738=>558, 2739=>670, 2741=>537, 2742=>592, 2743=>568,
2744=>600, 2745=>544, 2749=>531, 2750=>232, 2751=>232, 2752=>232, 2753=>33, 2754=>33, 2755=>33, 2759=>33, 2760=>33, 2763=>232, 2764=>232, 2768=>903, 2790=>479, 2791=>416,
2792=>465, 2793=>469, 2794=>498, 2795=>463, 2796=>451, 2797=>510, 2798=>455, 2799=>488, 2818=>131, 2819=>302, 2821=>560, 2822=>644, 2823=>632, 2825=>630, 2827=>553, 2831=>604,
2835=>520, 2837=>572, 2838=>570, 2839=>580, 2840=>565, 2842=>580, 2844=>564, 2845=>575, 2847=>565, 2848=>565, 2849=>524, 2858=>572, 2859=>700, 2863=>655, 2864=>620, 2866=>652,
2867=>560, 2870=>565, 2871=>565, 2872=>545, 2873=>524, 2878=>128, 2879=>1, 2880=>190, 2881=>1, 2882=>1, 2883=>1, 2887=>396, 2912=>563, 2918=>508, 2919=>424, 2920=>440,
2921=>600, 2922=>600, 2923=>600, 2924=>600, 2925=>600, 2926=>511, 2927=>483, 2946=>479, 2947=>893, 2949=>1018, 2950=>1170, 2951=>916, 2952=>676, 2953=>836, 2954=>1225, 2958=>744,
2959=>744, 2960=>848, 2962=>813, 2963=>813, 2964=>813, 2965=>688, 2969=>744, 2970=>676, 2972=>848, 2974=>984, 2975=>777, 2979=>1338, 2980=>664, 2984=>561, 2985=>1029, 2986=>607,
2990=>697, 2991=>697, 2992=>434, 2993=>617, 2994=>869, 2995=>859, 2996=>697, 2997=>869, 2999=>1145, 3000=>1064, 3001=>1316, 3006=>424, 3007=>125, 3008=>596, 3009=>539, 3014=>596,
3015=>650, 3016=>973, 3018=>1286, 3019=>1286, 3020=>1706, 3021=>333, 3031=>859, 3034=>778, 3035=>881, 3036=>876, 3037=>648, 3041=>744, 3203=>342, 3205=>620, 3206=>591, 3207=>600,
3208=>776, 3209=>1138, 3210=>1464, 3214=>574, 3215=>570, 3216=>580, 3218=>589, 3219=>597, 3220=>625, 3221=>256, 3222=>565, 3223=>326, 3224=>604, 3225=>651, 3226=>408, 3228=>611,
3230=>843, 3231=>610, 3232=>258, 3233=>317, 3234=>328, 3235=>803, 3236=>317, 3237=>328, 3238=>352, 3239=>352, 3240=>317, 3248=>248, 3249=>621, 3250=>620, 3251=>620, 3302=>649,
3303=>550, 3304=>573, 3305=>567, 3306=>562, 3307=>557, 3308=>562, 3309=>567, 3310=>557, 3311=>557, 3458=>468, 3459=>318, 3461=>660, 3465=>778, 3466=>807, 3467=>830, 3473=>838,
3476=>860, 3481=>1000, 3482=>973, 3483=>860, 3484=>997, 3486=>740, 3488=>838, 3489=>886, 3490=>886, 3492=>1295, 3493=>1295, 3495=>838, 3496=>860, 3497=>860, 3498=>860, 3499=>1403,
3501=>973, 3502=>838, 3503=>660, 3504=>860, 3505=>973, 3507=>660, 3508=>886, 3509=>838, 3510=>860, 3511=>973, 3512=>838, 3513=>860, 3514=>886, 3515=>807, 3517=>830, 3520=>838,
3521=>973, 3522=>886, 3523=>886, 3524=>973, 3525=>830, 3526=>973, 3530=>0, 3535=>432, 3536=>380, 3537=>420, 3538=>0, 3539=>0, 3540=>0, 3542=>0, 3544=>501, 3545=>652,
3551=>648, 7680=>667, 7681=>556, 7682=>667, 7683=>556, 7684=>667, 7685=>556, 7686=>667, 7687=>556, 7688=>722, 7689=>500, 7690=>722, 7691=>556, 7692=>722, 7693=>556, 7694=>722,
7695=>556, 7696=>722, 7697=>556, 7698=>722, 7699=>556, 7700=>667, 7701=>556, 7702=>667, 7703=>556, 7704=>667, 7705=>556, 7706=>667, 7707=>556, 7708=>667, 7709=>556, 7710=>611,
7711=>278, 7712=>778, 7713=>556, 7714=>722, 7715=>556, 7716=>722, 7717=>556, 7718=>722, 7719=>556, 7720=>722, 7721=>556, 7722=>722, 7723=>556, 7724=>278, 7725=>222, 7726=>278,
7727=>278, 7728=>667, 7729=>500, 7730=>667, 7731=>500, 7732=>667, 7733=>500, 7734=>556, 7735=>222, 7736=>556, 7737=>222, 7738=>556, 7739=>222, 7740=>556, 7741=>222, 7742=>833,
7743=>833, 7744=>833, 7745=>833, 7746=>833, 7747=>833, 7748=>722, 7749=>556, 7750=>722, 7751=>556, 7752=>722, 7753=>556, 7754=>722, 7755=>556, 7756=>778, 7757=>556, 7758=>778,
7759=>556, 7760=>778, 7761=>556, 7762=>778, 7763=>556, 7764=>667, 7765=>556, 7766=>667, 7767=>556, 7768=>722, 7769=>333, 7770=>722, 7771=>333, 7772=>722, 7773=>333, 7774=>722,
7775=>333, 7776=>667, 7777=>500, 7778=>667, 7779=>500, 7780=>667, 7781=>500, 7782=>667, 7783=>500, 7784=>667, 7785=>500, 7786=>611, 7787=>278, 7788=>611, 7789=>278, 7790=>611,
7791=>278, 7792=>611, 7793=>278, 7794=>722, 7795=>556, 7796=>722, 7797=>556, 7798=>722, 7799=>556, 7800=>722, 7801=>556, 7802=>722, 7803=>556, 7804=>667, 7805=>500, 7806=>667,
7807=>500, 7808=>944, 7809=>722, 7810=>944, 7811=>722, 7812=>944, 7813=>722, 7814=>944, 7815=>722, 7816=>944, 7817=>722, 7818=>667, 7819=>500, 7820=>667, 7821=>500, 7822=>667,
7823=>500, 7824=>611, 7825=>500, 7826=>611, 7827=>500, 7828=>611, 7829=>500, 7830=>556, 7831=>278, 7832=>722, 7833=>500, 7835=>278, 7840=>667, 7841=>556, 7844=>667, 7845=>556,
7846=>667, 7847=>556, 7850=>667, 7851=>556, 7852=>667, 7853=>556, 7854=>667, 7855=>556, 7856=>667, 7857=>556, 7860=>667, 7861=>556, 7862=>667, 7863=>556, 7864=>667, 7865=>556,
7868=>667, 7869=>556, 7870=>667, 7871=>556, 7872=>667, 7873=>556, 7876=>667, 7877=>556, 7878=>667, 7879=>556, 7882=>278, 7883=>222, 7884=>778, 7885=>556, 7888=>778, 7889=>556,
7890=>778, 7891=>556, 7894=>778, 7895=>556, 7896=>778, 7897=>556, 7908=>722, 7909=>556, 7922=>667, 7923=>500, 7924=>667, 7925=>500, 7928=>667, 7929=>500, 7936=>596, 7937=>596,
7938=>596, 7939=>596, 7940=>596, 7941=>596, 7942=>596, 7943=>596, 7944=>684, 7945=>684, 7946=>684, 7947=>684, 7948=>684, 7949=>684, 7950=>684, 7951=>684, 7952=>510, 7953=>510,
7954=>510, 7955=>510, 7956=>510, 7957=>510, 7960=>650, 7961=>650, 7962=>650, 7963=>650, 7964=>650, 7965=>650, 7968=>526, 7969=>526, 7970=>526, 7971=>526, 7972=>526, 7973=>526,
7974=>526, 7975=>526, 7976=>683, 7977=>683, 7978=>683, 7979=>683, 7980=>683, 7981=>683, 7982=>683, 7983=>683, 7984=>286, 7985=>286, 7986=>286, 7987=>286, 7988=>286, 7989=>286,
7990=>286, 7991=>286, 7992=>236, 7993=>236, 7994=>236, 7995=>236, 7996=>236, 7997=>236, 7998=>236, 7999=>236, 8000=>550, 8001=>550, 8002=>550, 8003=>550, 8004=>550, 8005=>550,
8008=>750, 8009=>750, 8010=>750, 8011=>750, 8012=>750, 8013=>750, 8016=>515, 8017=>515, 8018=>515, 8019=>515, 8020=>515, 8021=>515, 8022=>515, 8023=>515, 8025=>684, 8027=>684,
8029=>684, 8031=>684, 8032=>740, 8033=>740, 8034=>740, 8035=>740, 8036=>740, 8037=>740, 8038=>740, 8039=>740, 8040=>720, 8041=>720, 8042=>720, 8043=>720, 8044=>720, 8045=>720,
8046=>720, 8047=>720, 8048=>596, 8049=>596, 8050=>510, 8051=>510, 8052=>526, 8053=>526, 8054=>286, 8055=>286, 8056=>550, 8057=>550, 8058=>515, 8059=>515, 8060=>740, 8061=>740,
8064=>596, 8065=>596, 8066=>596, 8067=>596, 8068=>596, 8069=>596, 8070=>596, 8071=>596, 8072=>882, 8073=>882, 8074=>882, 8075=>882, 8076=>882, 8077=>882, 8078=>882, 8079=>882,
8080=>526, 8081=>526, 8082=>526, 8083=>526, 8084=>526, 8085=>526, 8086=>526, 8087=>526, 8088=>857, 8089=>857, 8090=>857, 8091=>857, 8092=>857, 8093=>857, 8094=>857, 8095=>857,
8096=>740, 8097=>740, 8098=>740, 8099=>740, 8100=>740, 8101=>740, 8102=>740, 8103=>740, 8104=>945, 8105=>945, 8106=>945, 8107=>945, 8108=>945, 8109=>945, 8110=>945, 8111=>945,
8112=>596, 8113=>596, 8114=>596, 8115=>596, 8116=>596, 8118=>596, 8119=>596, 8120=>684, 8121=>684, 8122=>684, 8123=>684, 8124=>882, 8125=>278, 8126=>201, 8127=>333, 8128=>278,
8129=>333, 8130=>526, 8131=>526, 8132=>536, 8134=>526, 8135=>526, 8136=>650, 8137=>650, 8138=>683, 8139=>683, 8140=>857, 8141=>582, 8142=>582, 8143=>333, 8144=>286, 8145=>286,
8146=>286, 8147=>286, 8150=>286, 8151=>312, 8152=>236, 8153=>236, 8154=>236, 8155=>236, 8157=>582, 8158=>582, 8159=>333, 8160=>515, 8161=>515, 8162=>515, 8163=>515, 8164=>566,
8165=>566, 8166=>515, 8167=>515, 8168=>684, 8169=>684, 8170=>684, 8171=>684, 8172=>638, 8173=>333, 8174=>393, 8175=>333, 8178=>740, 8179=>740, 8180=>740, 8182=>740, 8183=>740,
8184=>750, 8185=>750, 8186=>720, 8187=>720, 8188=>939, 8189=>333, 8190=>333, 8208=>333, 8219=>221, 8223=>333, 8227=>350, 8241=>1360, 8242=>278, 8243=>469, 8244=>680, 8245=>278,
8246=>469, 8247=>680, 8251=>622, 8252=>556, 8253=>556, 8260=>167, 8263=>1112, 8264=>834, 8265=>834, 8267=>537, 8304=>351, 8305=>351, 8308=>351, 8309=>351, 8310=>351, 8311=>351,
8312=>351, 8313=>351, 8320=>351, 8321=>351, 8322=>351, 8323=>351, 8324=>351, 8325=>353, 8326=>351, 8327=>351, 8328=>351, 8329=>351, 8359=>1445, 8360=>1222, 8362=>869, 8459=>969,
8460=>615, 8464=>809, 8465=>519, 8466=>874, 8470=>1008, 8475=>850, 8476=>644, 8486=>720, 8487=>720, 8488=>512, 8490=>667, 8491=>667, 8492=>908, 8493=>623, 8496=>562, 8497=>611,
8498=>611, 8499=>1080, 8531=>869, 8532=>869, 8533=>869, 8534=>869, 8535=>869, 8536=>869, 8537=>869, 8538=>869, 8539=>869, 8540=>869, 8541=>869, 8542=>869, 8543=>869, 8544=>278,
8545=>556, 8546=>834, 8547=>945, 8548=>667, 8549=>945, 8550=>1223, 8551=>1501, 8552=>945, 8553=>667, 8554=>945, 8555=>1223, 8556=>556, 8557=>722, 8558=>722, 8559=>833, 8560=>222,
8561=>444, 8562=>666, 8563=>722, 8564=>500, 8565=>722, 8566=>944, 8567=>1166, 8568=>722, 8569=>500, 8570=>722, 8571=>944, 8572=>222, 8573=>500, 8574=>556, 8575=>833, 8592=>987,
8593=>603, 8594=>987, 8595=>603, 8596=>1042, 8597=>1042, 8629=>658, 8656=>987, 8657=>603, 8658=>987, 8659=>603, 8660=>1042, 8704=>667, 8706=>556, 8707=>667, 8709=>556, 8710=>711,
8711=>711, 8712=>713, 8713=>713, 8719=>823, 8720=>823, 8721=>804, 8722=>584, 8723=>584, 8727=>500, 8730=>542, 8733=>713, 8734=>713, 8736=>768, 8743=>603, 8744=>603, 8745=>768,
8746=>768, 8747=>556, 8748=>796, 8749=>956, 8750=>556, 8756=>863, 8764=>549, 8766=>584, 8769=>584, 8770=>584, 8771=>584, 8777=>636, 8800=>548, 8804=>584, 8805=>584, 8853=>768,
8854=>768, 8855=>768, 8869=>658, 8960=>823, 9674=>489, 9834=>555, 63033=>556, 63034=>556, 63035=>556, 63036=>556, 63037=>556, 63038=>556, 63039=>556, 63040=>556, 63041=>556, 63166=>222,
63171=>333, 63196=>556, 64256=>556, 64257=>500, 64258=>500, 64259=>778, 64260=>778, 64261=>556, 64262=>778, 64285=>200, 64286=>305, 64287=>400, 64288=>587, 64289=>890, 64290=>848, 64291=>872,
64292=>800, 64293=>850, 64294=>873, 64295=>797, 64296=>937, 64297=>584, 64298=>776, 64299=>776, 64300=>776, 64301=>776, 64302=>640, 64303=>640, 64304=>640, 64305=>591, 64306=>466, 64307=>598,
64308=>622, 64309=>262, 64310=>351, 64312=>608, 64313=>270, 64314=>526, 64315=>550, 64316=>600, 64318=>621, 64320=>378, 64321=>607, 64323=>575, 64324=>568, 64326=>590, 64327=>606, 64328=>547,
64329=>776, 64330=>687, 64331=>212, 64332=>591, 64333=>550, 64334=>568, 64335=>640, 65533=>788);
$enc='';
$diff='';
$file='FreeSans.z';
$ctg='FreeSans.ctg.z';
$originalsize=236376;
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/FreeSans.z
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/FreeSansBold.ctg.z
0,0 → 1,14
+¾ÆZ¬Ãz|ƒo±± ›ñ¶`+¶a;và{ìÄ.ìÆìÅ>ìÇÄ!ÆÅ1Ç œÄ)œÆœÅ9œÇ\Ä%\Æü€«¸†ñ®ãnâňæX‹h‘,²E±¨Í¢[ ‹i±,¶Å±¸Ïâ[Kh‰,±%±¤–Ì’[
+Ki©,µ¥±GìQ{Ì·´–ÎÒ[Ëh™,³e±¬ö„e³ì–Þ´œ–Ër[Ëkù,¿=e¬ =m…þÈl…ïÉ{ò¿÷(bE­˜=cÅíY{Ξ·¬„•´í%+e/[i+ce­œ•·
+ Õ…ʇ68týȆØPfÃm„}l#m”}b£mŒµq6Þ&ØÄИIö©}f“mŠMµi6ÝfØL›eŸÛ6Û¾´96×æÙ|[` m‘-¶%¶Ô–ÙrûÊVØJ[e«m}mkm­·oì[Û`m“m¶ïþ†sÙb[m›m·ö½í´]¶ÛöØ^Ûgû퀴Cv؎ØQ;fÇ턝´SvÚÎØY;gçí‚]´KvÙ®Øvծُö“]·vÓnÙm‚FÒ0#2#3
+¼¡¿æ¼±7ñ¦Þ̛{ oé­¼µ·ñ¶ÞÎÛûëÞÁßð7ý-ïèo{'ïÚ«‹wõnþŽw÷þ®÷ô^ÞÛßó>Þ×ûùû¡þ¼¿ð>È?ôÁþ‘ñ¡>̇ûÿ8œëHåŸøhãcCµq>Þ'øDŸäŸúg>Ù§øTŸæÓ}†ÏôYþ¹á³ýËð¼9>×ç…â|_à }‘/ö%¾Ô—ùò?ú–øW¾âÎÝJ_å«CqíkCq¯÷oîô}û+37ü¢e£oú•q›Ùv/ùo~Ké[|«oóí÷p¯¡ò}ñä;ØλÔÎÿ$¾ûNÜó«½{}ßµì¿Ï ý ~àN<è‡l&"""~ЈˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆÈïó#~ԏùq?á'ý”Ÿö3:£ÏÏþéçîG"""òpðó~áÿšwÑ/ùe¿â?øU¿æ?úO~ÝoøM¿å·0ð "ƒHAä J5ˆуAÌ V;t'TâñB×øA‚Ð5a(H$ ’ɂäAŠ eê^?­ˆˆÈ_¤~Јü5ÿž‡²
\ No newline at end of file
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/FreeSansBold.php
0,0 → 1,79
<?php
$type='TrueTypeUnicode';
$name='FreeSansBold';
$desc=array('Ascent'=>1159,'Descent'=>-355,'CapHeight'=>1159,'Flags'=>32,'FontBBox'=>'[-459 -355 1300 1159]','ItalicAngle'=>0,'StemV'=>120,'MissingWidth'=>600);
$up=-155;
$ut=69;
$cw=array(
13=>333, 32=>278, 33=>333, 34=>474, 35=>556, 36=>556, 37=>889, 38=>722, 39=>238, 40=>333, 41=>333, 42=>389, 43=>584, 44=>278, 45=>333, 46=>278,
47=>278, 48=>556, 49=>556, 50=>556, 51=>556, 52=>556, 53=>556, 54=>556, 55=>556, 56=>556, 57=>556, 58=>333, 59=>333, 60=>584, 61=>584, 62=>584,
63=>611, 64=>975, 65=>722, 66=>722, 67=>722, 68=>722, 69=>667, 70=>611, 71=>778, 72=>722, 73=>278, 74=>556, 75=>722, 76=>611, 77=>833, 78=>722,
79=>778, 80=>667, 81=>778, 82=>722, 83=>667, 84=>611, 85=>722, 86=>667, 87=>944, 88=>667, 89=>667, 90=>611, 91=>333, 92=>278, 93=>333, 94=>584,
95=>556, 96=>333, 97=>556, 98=>611, 99=>556, 100=>611, 101=>556, 102=>333, 103=>611, 104=>611, 105=>278, 106=>278, 107=>556, 108=>278, 109=>889, 110=>611,
111=>611, 112=>611, 113=>611, 114=>389, 115=>556, 116=>333, 117=>611, 118=>556, 119=>778, 120=>556, 121=>556, 122=>500, 123=>389, 124=>280, 125=>389, 126=>584,
8364=>556, 1027=>611, 8218=>278, 402=>556, 8222=>500, 8230=>1000, 8224=>556, 8225=>556, 710=>333, 8240=>1000, 352=>667, 8249=>333, 338=>1000, 1036=>722, 381=>611, 1039=>722,
8216=>278, 8217=>278, 8220=>500, 8221=>500, 8226=>350, 8211=>556, 8212=>1000, 732=>333, 8482=>1000, 353=>556, 8250=>333, 339=>944, 1116=>573, 382=>500, 376=>667, 161=>333,
162=>556, 163=>556, 164=>556, 165=>556, 166=>280, 167=>556, 168=>333, 169=>737, 170=>370, 171=>556, 172=>584, 174=>737, 175=>333, 176=>606, 177=>584, 178=>351,
179=>351, 180=>333, 181=>611, 182=>556, 183=>278, 184=>333, 185=>351, 186=>365, 187=>556, 188=>869, 189=>869, 190=>869, 191=>611, 192=>722, 193=>722, 194=>722,
195=>722, 196=>722, 197=>722, 198=>1000, 199=>722, 200=>667, 201=>667, 202=>667, 203=>667, 204=>278, 205=>278, 206=>278, 207=>278, 208=>722, 209=>722, 210=>778,
211=>778, 212=>778, 213=>778, 214=>778, 215=>584, 216=>778, 217=>722, 218=>722, 219=>722, 220=>722, 221=>667, 222=>667, 223=>611, 224=>556, 225=>556, 226=>556,
227=>556, 228=>556, 229=>556, 230=>889, 231=>556, 232=>556, 233=>556, 234=>556, 235=>556, 236=>278, 237=>278, 238=>278, 239=>278, 240=>611, 241=>611, 242=>611,
243=>611, 244=>611, 245=>611, 246=>611, 247=>584, 248=>611, 249=>611, 250=>611, 251=>611, 252=>611, 253=>556, 254=>611, 255=>556, 256=>722, 257=>556, 258=>722,
259=>556, 260=>722, 261=>556, 262=>722, 263=>556, 264=>722, 265=>556, 266=>722, 267=>556, 268=>722, 269=>556, 270=>722, 271=>611, 272=>722, 273=>611, 274=>667,
275=>556, 276=>667, 277=>556, 278=>667, 279=>556, 280=>667, 281=>556, 282=>667, 283=>556, 284=>778, 285=>611, 286=>778, 287=>611, 288=>778, 289=>611, 290=>778,
291=>611, 292=>722, 293=>611, 294=>722, 295=>611, 296=>278, 297=>278, 298=>278, 299=>278, 300=>278, 301=>278, 302=>278, 303=>278, 304=>278, 305=>278, 306=>808,
307=>492, 308=>556, 309=>278, 310=>722, 311=>556, 312=>573, 313=>611, 314=>278, 315=>611, 316=>278, 317=>611, 318=>278, 319=>611, 320=>556, 321=>611, 322=>278,
323=>722, 324=>611, 325=>722, 326=>611, 327=>722, 328=>611, 329=>611, 330=>722, 331=>611, 332=>778, 333=>611, 334=>778, 335=>611, 336=>778, 337=>611, 340=>722,
341=>389, 342=>722, 343=>389, 344=>722, 345=>389, 346=>667, 347=>556, 348=>667, 349=>556, 350=>667, 351=>556, 354=>611, 355=>333, 356=>611, 357=>333, 358=>611,
359=>333, 360=>722, 361=>611, 362=>722, 363=>611, 364=>722, 365=>611, 366=>722, 367=>611, 368=>722, 369=>611, 370=>722, 371=>611, 372=>944, 373=>778, 374=>667,
375=>556, 377=>611, 378=>500, 379=>611, 380=>500, 383=>333, 452=>1333, 453=>1222, 454=>1111, 455=>1167, 456=>889, 457=>556, 458=>1278, 459=>1000, 460=>889, 461=>722,
462=>556, 463=>278, 464=>278, 465=>778, 466=>611, 467=>722, 468=>611, 469=>722, 470=>611, 471=>722, 472=>611, 473=>722, 474=>611, 475=>722, 476=>611, 478=>722,
479=>556, 482=>1000, 483=>889, 486=>778, 487=>611, 488=>722, 489=>556, 490=>778, 491=>611, 492=>778, 493=>611, 497=>1333, 498=>1222, 499=>1111, 504=>722, 505=>611,
506=>722, 507=>556, 508=>1000, 509=>889, 510=>778, 511=>611, 514=>722, 515=>556, 518=>667, 519=>556, 522=>278, 523=>278, 526=>778, 527=>611, 530=>722, 531=>389,
534=>722, 535=>611, 536=>667, 537=>556, 538=>611, 539=>333, 711=>333, 728=>333, 729=>333, 730=>333, 731=>333, 733=>333, 884=>379, 885=>379, 890=>332, 894=>333,
900=>325, 901=>658, 902=>761, 903=>474, 904=>706, 905=>733, 906=>285, 908=>785, 910=>823, 911=>819, 913=>722, 914=>722, 915=>642, 916=>726, 917=>667, 918=>611,
919=>722, 920=>810, 921=>278, 922=>722, 923=>744, 924=>860, 925=>714, 926=>690, 927=>822, 928=>781, 929=>698, 931=>688, 932=>688, 933=>804, 934=>777, 935=>783,
936=>805, 937=>780, 938=>278, 939=>804, 940=>660, 941=>559, 942=>560, 943=>356, 944=>575, 945=>656, 946=>576, 947=>591, 948=>620, 949=>570, 950=>522, 951=>586,
952=>586, 953=>346, 954=>576, 955=>620, 956=>667, 957=>564, 958=>530, 959=>610, 960=>721, 961=>626, 962=>595, 963=>676, 964=>592, 965=>575, 966=>801, 967=>632,
968=>722, 969=>800, 970=>346, 971=>575, 972=>599, 973=>567, 974=>1125, 1024=>667, 1025=>709, 1026=>790, 1028=>722, 1029=>667, 1030=>278, 1031=>278, 1032=>556, 1033=>1110,
1034=>1113, 1035=>790, 1037=>726, 1038=>718, 1040=>722, 1041=>722, 1042=>722, 1043=>611, 1044=>900, 1045=>709, 1046=>1093, 1047=>672, 1048=>757, 1049=>757, 1050=>750, 1051=>729,
1052=>874, 1053=>753, 1054=>778, 1055=>753, 1056=>671, 1057=>722, 1058=>611, 1059=>718, 1060=>892, 1061=>667, 1062=>816, 1063=>685, 1064=>1057, 1065=>1183, 1066=>928, 1067=>949,
1068=>687, 1069=>722, 1070=>1109, 1071=>698, 1072=>556, 1073=>606, 1074=>572, 1075=>454, 1076=>685, 1077=>556, 1078=>809, 1079=>546, 1080=>615, 1081=>615, 1082=>573, 1083=>577,
1084=>666, 1085=>603, 1086=>611, 1087=>603, 1088=>611, 1089=>556, 1090=>454, 1091=>556, 1092=>957, 1093=>556, 1094=>652, 1095=>578, 1096=>886, 1097=>968, 1098=>693, 1099=>811,
1100=>562, 1101=>564, 1102=>908, 1103=>596, 1104=>556, 1105=>556, 1106=>606, 1107=>454, 1108=>556, 1109=>556, 1110=>278, 1111=>278, 1112=>278, 1113=>900, 1114=>611, 1115=>606,
1117=>608, 1118=>556, 1119=>608, 1164=>687, 1165=>562, 1166=>667, 1167=>611, 1168=>611, 1169=>454, 1170=>611, 1171=>454, 1172=>611, 1173=>454, 1174=>1093, 1175=>809, 1176=>672,
1177=>546, 1178=>722, 1179=>573, 1180=>722, 1181=>573, 1182=>722, 1183=>573, 1184=>722, 1185=>573, 1186=>722, 1187=>608, 1188=>722, 1189=>608, 1190=>722, 1191=>608, 1192=>722,
1193=>556, 1194=>722, 1195=>556, 1196=>611, 1197=>454, 1198=>667, 1199=>556, 1200=>667, 1201=>556, 1202=>667, 1203=>556, 1204=>814, 1205=>685, 1206=>675, 1207=>580, 1208=>675,
1209=>580, 1210=>675, 1211=>580, 1212=>722, 1213=>556, 1214=>722, 1215=>556, 1216=>278, 1217=>1093, 1218=>809, 1219=>722, 1220=>573, 1223=>722, 1224=>608, 1227=>675, 1228=>580,
1232=>722, 1233=>556, 1234=>722, 1235=>556, 1236=>1000, 1237=>889, 1238=>709, 1239=>556, 1240=>722, 1241=>556, 1242=>722, 1243=>556, 1244=>1093, 1245=>809, 1246=>672, 1247=>546,
1248=>672, 1249=>546, 1250=>757, 1251=>615, 1252=>757, 1253=>615, 1254=>778, 1255=>611, 1256=>778, 1257=>611, 1258=>778, 1259=>611, 1260=>722, 1261=>564, 1262=>718, 1263=>556,
1264=>718, 1265=>556, 1266=>718, 1267=>556, 1268=>685, 1269=>578, 1272=>949, 1273=>811, 1456=>82, 1457=>347, 1458=>341, 1459=>341, 1460=>82, 1461=>211, 1462=>211, 1463=>200,
1464=>200, 1465=>82, 1467=>341, 1468=>82, 1469=>82, 1470=>516, 1471=>200, 1472=>297, 1473=>1038, 1474=>1038, 1475=>333, 1476=>82, 1488=>714, 1489=>651, 1490=>557, 1491=>638,
1492=>682, 1493=>297, 1494=>443, 1495=>682, 1496=>670, 1497=>284, 1498=>590, 1499=>595, 1500=>667, 1501=>683, 1502=>704, 1503=>297, 1504=>429, 1505=>670, 1506=>653, 1507=>661,
1508=>660, 1509=>616, 1510=>671, 1511=>672, 1512=>600, 1513=>840, 1514=>756, 1520=>554, 1521=>550, 1522=>542, 1523=>238, 1524=>474, 1559=>556, 1560=>778, 1561=>944, 1562=>611,
1563=>278, 1564=>889, 1569=>844, 1576=>923, 1578=>922, 1579=>922, 1581=>649, 1582=>704, 1587=>1221, 7936=>656, 7937=>656, 7938=>656, 7939=>656, 7940=>656, 7941=>656, 7942=>656,
7943=>656, 7944=>722, 7945=>722, 7946=>722, 7947=>722, 7948=>722, 7949=>722, 7950=>722, 7951=>722, 7952=>570, 7953=>570, 7954=>570, 7955=>570, 7956=>570, 7957=>570, 7960=>667,
7961=>667, 7962=>667, 7963=>667, 7964=>667, 7965=>667, 7968=>586, 7969=>586, 7970=>586, 7971=>586, 7972=>586, 7973=>586, 7974=>586, 7975=>586, 7976=>722, 7977=>722, 7978=>722,
7979=>722, 7980=>722, 7981=>722, 7982=>722, 7983=>722, 7984=>346, 7985=>346, 7986=>346, 7987=>346, 7988=>346, 7989=>346, 7990=>346, 7991=>346, 7992=>278, 7993=>278, 7994=>278,
7995=>278, 7996=>278, 7997=>278, 7998=>278, 7999=>278, 8000=>610, 8001=>610, 8002=>610, 8003=>610, 8004=>610, 8005=>610, 8008=>822, 8009=>822, 8010=>822, 8011=>822, 8012=>822,
8013=>822, 8016=>575, 8017=>575, 8018=>575, 8019=>575, 8020=>575, 8021=>575, 8022=>575, 8023=>575, 8025=>804, 8027=>804, 8029=>804, 8031=>804, 8032=>800, 8033=>800, 8034=>800,
8035=>800, 8036=>800, 8037=>800, 8038=>800, 8039=>800, 8040=>780, 8041=>780, 8042=>780, 8043=>780, 8044=>780, 8045=>780, 8046=>780, 8047=>780, 8048=>656, 8049=>656, 8050=>570,
8051=>570, 8052=>586, 8053=>586, 8054=>346, 8055=>346, 8056=>610, 8057=>610, 8058=>575, 8059=>575, 8060=>800, 8061=>800, 8064=>656, 8065=>656, 8066=>656, 8067=>656, 8068=>656,
8069=>656, 8070=>656, 8071=>656, 8072=>968, 8073=>968, 8074=>968, 8075=>968, 8076=>968, 8077=>968, 8078=>968, 8079=>968, 8080=>586, 8081=>586, 8082=>586, 8083=>586, 8084=>586,
8085=>586, 8086=>586, 8087=>586, 8088=>968, 8089=>968, 8090=>968, 8091=>968, 8092=>968, 8093=>968, 8094=>968, 8095=>968, 8096=>800, 8097=>800, 8098=>800, 8099=>800, 8100=>800,
8101=>800, 8102=>800, 8103=>800, 8104=>1026, 8105=>1026, 8106=>1026, 8107=>1026, 8108=>1026, 8109=>1026, 8110=>1026, 8111=>1026, 8112=>656, 8113=>656, 8114=>656, 8115=>656, 8116=>660,
8118=>656, 8119=>656, 8120=>722, 8121=>722, 8122=>722, 8123=>722, 8124=>968, 8125=>278, 8126=>346, 8127=>278, 8128=>278, 8129=>333, 8130=>586, 8131=>586, 8132=>560, 8134=>586,
8135=>586, 8136=>667, 8137=>667, 8138=>722, 8139=>722, 8140=>968, 8141=>492, 8142=>489, 8143=>394, 8144=>346, 8145=>346, 8146=>346, 8147=>346, 8150=>346, 8151=>346, 8152=>278,
8153=>278, 8154=>278, 8155=>278, 8157=>481, 8158=>589, 8159=>333, 8160=>575, 8161=>575, 8162=>575, 8163=>575, 8164=>626, 8165=>626, 8166=>575, 8167=>575, 8168=>804, 8169=>804,
8170=>804, 8171=>804, 8172=>698, 8173=>333, 8174=>333, 8175=>333, 8178=>800, 8179=>800, 8180=>1125, 8182=>800, 8183=>800, 8184=>822, 8185=>822, 8186=>780, 8187=>780, 8188=>1111,
8189=>333, 8190=>278, 8260=>167, 8308=>351, 8321=>351, 8322=>351, 8323=>351, 8324=>351, 8362=>1049, 8543=>869, 8706=>490, 8710=>729, 8721=>711, 8722=>584, 8730=>542, 8800=>548,
8804=>584, 8805=>584, 9674=>489, 63033=>556, 63034=>556, 63035=>556, 63036=>556, 63037=>556, 63038=>556, 63039=>556, 63040=>556, 63041=>556, 63171=>333, 63196=>556, 64257=>611, 64258=>611,
64285=>284, 64286=>305, 64287=>542, 64288=>653, 64289=>964, 64290=>888, 64291=>932, 64292=>845, 64293=>917, 64294=>933, 64295=>850, 64296=>1006, 64297=>584, 64298=>840, 64299=>840, 64300=>840,
64301=>840, 64302=>714, 64303=>714, 64304=>714, 64305=>651, 64306=>557, 64307=>638, 64308=>682, 64309=>367, 64310=>443, 64312=>670, 64313=>354, 64314=>590, 64315=>595, 64316=>667, 64318=>704,
64320=>429, 64321=>670, 64323=>661, 64324=>660, 64326=>671, 64327=>672, 64328=>600, 64329=>840, 64330=>756, 64331=>297, 64332=>651, 64333=>595, 64334=>660, 64335=>714, 65182=>636);
$enc='';
$diff='';
$file='FreeSansBold.z';
$ctg='FreeSansBold.ctg.z';
$originalsize=88972;
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/FreeSansBold.z
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/courier.php
0,0 → 1,8
<?php
// vim: expandtab sw=4 ts=4 sts=4:
for ($i=0;$i<=255;$i++)
$fpdf_charwidths['courier'][chr($i)]=600;
$fpdf_charwidths['courierB']=$fpdf_charwidths['courier'];
$fpdf_charwidths['courierI']=$fpdf_charwidths['courier'];
$fpdf_charwidths['courierBI']=$fpdf_charwidths['courier'];
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/helvetica.php
0,0 → 1,16
<?php
// vim: expandtab sw=4 ts=4 sts=4:
$fpdf_charwidths['helvetica']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/helveticab.php
0,0 → 1,16
<?php
// vim: expandtab sw=4 ts=4 sts=4:
$fpdf_charwidths['helveticaB']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/helveticabi.php
0,0 → 1,16
<?php
// vim: expandtab sw=4 ts=4 sts=4:
$fpdf_charwidths['helveticaBI']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/helveticai.php
0,0 → 1,16
<?php
// vim: expandtab sw=4 ts=4 sts=4:
$fpdf_charwidths['helveticaI']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/symbol.php
0,0 → 1,16
<?php
// vim: expandtab sw=4 ts=4 sts=4:
$fpdf_charwidths['symbol']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549,
','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722,
'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768,
'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576,
'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0,
chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603,
chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768,
chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042,
chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329,
chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0);
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/tahoma.php
0,0 → 1,23
<?php
$type='TrueType';
$name='Tahoma';
$desc=array('Ascent'=>1000,'Descent'=>-207,'CapHeight'=>727,'Flags'=>32,'FontBBox'=>'[-600 -207 1338 1034]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>1000);
$up=-83;
$ut=63;
$cw=array(
chr(0)=>1000,chr(1)=>1000,chr(2)=>1000,chr(3)=>1000,chr(4)=>1000,chr(5)=>1000,chr(6)=>1000,chr(7)=>1000,chr(8)=>1000,chr(9)=>1000,chr(10)=>1000,chr(11)=>1000,chr(12)=>1000,chr(13)=>1000,chr(14)=>1000,chr(15)=>1000,chr(16)=>1000,chr(17)=>1000,chr(18)=>1000,chr(19)=>1000,chr(20)=>1000,chr(21)=>1000,
chr(22)=>1000,chr(23)=>1000,chr(24)=>1000,chr(25)=>1000,chr(26)=>1000,chr(27)=>1000,chr(28)=>1000,chr(29)=>1000,chr(30)=>1000,chr(31)=>1000,' '=>313,'!'=>332,'"'=>401,'#'=>728,'$'=>546,'%'=>977,'&'=>674,'\''=>211,'('=>383,')'=>383,'*'=>546,'+'=>728,
','=>303,'-'=>363,'.'=>303,'/'=>382,'0'=>546,'1'=>546,'2'=>546,'3'=>546,'4'=>546,'5'=>546,'6'=>546,'7'=>546,'8'=>546,'9'=>546,':'=>354,';'=>354,'<'=>728,'='=>728,'>'=>728,'?'=>474,'@'=>909,'A'=>600,
'B'=>589,'C'=>601,'D'=>678,'E'=>561,'F'=>521,'G'=>667,'H'=>675,'I'=>373,'J'=>417,'K'=>588,'L'=>498,'M'=>771,'N'=>667,'O'=>708,'P'=>551,'Q'=>708,'R'=>621,'S'=>557,'T'=>584,'U'=>656,'V'=>597,'W'=>902,
'X'=>581,'Y'=>576,'Z'=>559,'['=>383,'\\'=>382,']'=>383,'^'=>728,'_'=>546,'`'=>546,'a'=>525,'b'=>553,'c'=>461,'d'=>553,'e'=>526,'f'=>318,'g'=>553,'h'=>558,'i'=>229,'j'=>282,'k'=>498,'l'=>229,'m'=>840,
'n'=>558,'o'=>543,'p'=>553,'q'=>553,'r'=>360,'s'=>446,'t'=>334,'u'=>558,'v'=>498,'w'=>742,'x'=>495,'y'=>498,'z'=>444,'{'=>480,'|'=>382,'}'=>480,'~'=>728,chr(127)=>1000,chr(128)=>1000,chr(129)=>1000,chr(130)=>1000,chr(131)=>1000,
chr(132)=>1000,chr(133)=>1000,chr(134)=>1000,chr(135)=>1000,chr(136)=>1000,chr(137)=>1000,chr(138)=>1000,chr(139)=>1000,chr(140)=>1000,chr(141)=>1000,chr(142)=>1000,chr(143)=>1000,chr(144)=>1000,chr(145)=>1000,chr(146)=>1000,chr(147)=>1000,chr(148)=>1000,chr(149)=>1000,chr(150)=>1000,chr(151)=>1000,chr(152)=>1000,chr(153)=>1000,
chr(154)=>1000,chr(155)=>1000,chr(156)=>1000,chr(157)=>1000,chr(158)=>1000,chr(159)=>1000,chr(160)=>313,chr(161)=>600,chr(162)=>546,chr(163)=>518,chr(164)=>546,chr(165)=>498,chr(166)=>557,chr(167)=>546,chr(168)=>546,chr(169)=>557,chr(170)=>557,chr(171)=>584,chr(172)=>559,chr(173)=>363,chr(174)=>559,chr(175)=>559,
chr(176)=>471,chr(177)=>525,chr(178)=>546,chr(179)=>274,chr(180)=>546,chr(181)=>361,chr(182)=>446,chr(183)=>546,chr(184)=>546,chr(185)=>446,chr(186)=>446,chr(187)=>468,chr(188)=>444,chr(189)=>546,chr(190)=>444,chr(191)=>444,chr(192)=>621,chr(193)=>600,chr(194)=>600,chr(195)=>600,chr(196)=>600,chr(197)=>498,
chr(198)=>601,chr(199)=>601,chr(200)=>601,chr(201)=>561,chr(202)=>561,chr(203)=>561,chr(204)=>561,chr(205)=>373,chr(206)=>373,chr(207)=>678,chr(208)=>698,chr(209)=>667,chr(210)=>667,chr(211)=>708,chr(212)=>708,chr(213)=>708,chr(214)=>708,chr(215)=>728,chr(216)=>621,chr(217)=>656,chr(218)=>656,chr(219)=>656,
chr(220)=>656,chr(221)=>576,chr(222)=>584,chr(223)=>548,chr(224)=>360,chr(225)=>525,chr(226)=>525,chr(227)=>525,chr(228)=>525,chr(229)=>229,chr(230)=>461,chr(231)=>461,chr(232)=>461,chr(233)=>526,chr(234)=>526,chr(235)=>526,chr(236)=>526,chr(237)=>229,chr(238)=>229,chr(239)=>687,chr(240)=>573,chr(241)=>558,
chr(242)=>558,chr(243)=>543,chr(244)=>543,chr(245)=>543,chr(246)=>543,chr(247)=>728,chr(248)=>360,chr(249)=>558,chr(250)=>558,chr(251)=>558,chr(252)=>558,chr(253)=>498,chr(254)=>334,chr(255)=>546);
$enc='iso-8859-2';
$diff='128 /.notdef 130 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 142 /.notdef 145 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 158 /.notdef /.notdef 161 /Aogonek /breve /Lslash 165 /Lcaron /Sacute 169 /Scaron /Scedilla /Tcaron /Zacute 174 /Zcaron /Zdot 177 /aogonek /ogonek /lslash 181 /lcaron /sacute /caron 185 /scaron /scedilla /tcaron /zacute /hungarumlaut /zcaron /zdot /Racute 195 /Abreve 197 /Lacute /Cacute 200 /Ccaron 202 /Eogonek 204 /Ecaron 207 /Dcaron /Dslash /Nacute /Ncaron 213 /Odblacute 216 /Rcaron /Uring 219 /Udblacute 222 /Tcedilla 224 /racute 227 /abreve 229 /lacute /cacute 232 /ccaron 234 /eogonek 236 /ecaron 239 /dcaron /dmacron /nacute /ncaron 245 /odblacute 248 /rcaron /uring 251 /udblacute 254 /tcedilla /dotaccent';
$file='';
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/tahomab.php
0,0 → 1,23
<?php
$type='TrueType';
$name='Tahoma-Bold';
$desc=array('Ascent'=>1000,'Descent'=>-207,'CapHeight'=>727,'Flags'=>32,'FontBBox'=>'[-670 -207 1625 1065]','ItalicAngle'=>0,'StemV'=>120,'MissingWidth'=>1000);
$up=-70;
$ut=98;
$cw=array(
chr(0)=>1000,chr(1)=>1000,chr(2)=>1000,chr(3)=>1000,chr(4)=>1000,chr(5)=>1000,chr(6)=>1000,chr(7)=>1000,chr(8)=>1000,chr(9)=>1000,chr(10)=>1000,chr(11)=>1000,chr(12)=>1000,chr(13)=>1000,chr(14)=>1000,chr(15)=>1000,chr(16)=>1000,chr(17)=>1000,chr(18)=>1000,chr(19)=>1000,chr(20)=>1000,chr(21)=>1000,
chr(22)=>1000,chr(23)=>1000,chr(24)=>1000,chr(25)=>1000,chr(26)=>1000,chr(27)=>1000,chr(28)=>1000,chr(29)=>1000,chr(30)=>1000,chr(31)=>1000,' '=>293,'!'=>343,'"'=>489,'#'=>818,'$'=>637,'%'=>1199,'&'=>781,'\''=>275,'('=>454,')'=>454,'*'=>637,'+'=>818,
','=>313,'-'=>431,'.'=>313,'/'=>577,'0'=>637,'1'=>637,'2'=>637,'3'=>637,'4'=>637,'5'=>637,'6'=>637,'7'=>637,'8'=>637,'9'=>637,':'=>363,';'=>363,'<'=>818,'='=>818,'>'=>818,'?'=>566,'@'=>920,'A'=>685,
'B'=>686,'C'=>667,'D'=>757,'E'=>615,'F'=>581,'G'=>745,'H'=>764,'I'=>483,'J'=>500,'K'=>696,'L'=>572,'M'=>893,'N'=>771,'O'=>770,'P'=>657,'Q'=>770,'R'=>726,'S'=>633,'T'=>612,'U'=>739,'V'=>675,'W'=>1028,
'X'=>685,'Y'=>670,'Z'=>623,'['=>454,'\\'=>577,']'=>454,'^'=>818,'_'=>637,'`'=>546,'a'=>599,'b'=>632,'c'=>527,'d'=>629,'e'=>594,'f'=>382,'g'=>629,'h'=>640,'i'=>302,'j'=>363,'k'=>603,'l'=>302,'m'=>954,
'n'=>640,'o'=>617,'p'=>629,'q'=>629,'r'=>434,'s'=>515,'t'=>416,'u'=>640,'v'=>579,'w'=>890,'x'=>604,'y'=>576,'z'=>526,'{'=>623,'|'=>637,'}'=>623,'~'=>818,chr(127)=>1000,chr(128)=>1000,chr(129)=>1000,chr(130)=>1000,chr(131)=>1000,
chr(132)=>1000,chr(133)=>1000,chr(134)=>1000,chr(135)=>1000,chr(136)=>1000,chr(137)=>1000,chr(138)=>1000,chr(139)=>1000,chr(140)=>1000,chr(141)=>1000,chr(142)=>1000,chr(143)=>1000,chr(144)=>1000,chr(145)=>1000,chr(146)=>1000,chr(147)=>1000,chr(148)=>1000,chr(149)=>1000,chr(150)=>1000,chr(151)=>1000,chr(152)=>1000,chr(153)=>1000,
chr(154)=>1000,chr(155)=>1000,chr(156)=>1000,chr(157)=>1000,chr(158)=>1000,chr(159)=>1000,chr(160)=>293,chr(161)=>685,chr(162)=>546,chr(163)=>589,chr(164)=>637,chr(165)=>572,chr(166)=>633,chr(167)=>637,chr(168)=>546,chr(169)=>633,chr(170)=>633,chr(171)=>612,chr(172)=>623,chr(173)=>431,chr(174)=>623,chr(175)=>623,
chr(176)=>520,chr(177)=>599,chr(178)=>546,chr(179)=>335,chr(180)=>546,chr(181)=>490,chr(182)=>515,chr(183)=>546,chr(184)=>546,chr(185)=>515,chr(186)=>515,chr(187)=>619,chr(188)=>526,chr(189)=>546,chr(190)=>526,chr(191)=>526,chr(192)=>726,chr(193)=>685,chr(194)=>685,chr(195)=>685,chr(196)=>685,chr(197)=>572,
chr(198)=>667,chr(199)=>667,chr(200)=>667,chr(201)=>615,chr(202)=>615,chr(203)=>615,chr(204)=>615,chr(205)=>483,chr(206)=>483,chr(207)=>757,chr(208)=>774,chr(209)=>771,chr(210)=>771,chr(211)=>770,chr(212)=>770,chr(213)=>770,chr(214)=>770,chr(215)=>818,chr(216)=>726,chr(217)=>739,chr(218)=>739,chr(219)=>739,
chr(220)=>739,chr(221)=>670,chr(222)=>612,chr(223)=>646,chr(224)=>434,chr(225)=>599,chr(226)=>599,chr(227)=>599,chr(228)=>599,chr(229)=>302,chr(230)=>527,chr(231)=>527,chr(232)=>527,chr(233)=>594,chr(234)=>594,chr(235)=>594,chr(236)=>594,chr(237)=>302,chr(238)=>302,chr(239)=>817,chr(240)=>625,chr(241)=>640,
chr(242)=>640,chr(243)=>617,chr(244)=>617,chr(245)=>617,chr(246)=>617,chr(247)=>818,chr(248)=>434,chr(249)=>640,chr(250)=>640,chr(251)=>640,chr(252)=>640,chr(253)=>576,chr(254)=>416,chr(255)=>546);
$enc='iso-8859-2';
$diff='128 /.notdef 130 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 142 /.notdef 145 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 158 /.notdef /.notdef 161 /Aogonek /breve /Lslash 165 /Lcaron /Sacute 169 /Scaron /Scedilla /Tcaron /Zacute 174 /Zcaron /Zdot 177 /aogonek /ogonek /lslash 181 /lcaron /sacute /caron 185 /scaron /scedilla /tcaron /zacute /hungarumlaut /zcaron /zdot /Racute 195 /Abreve 197 /Lacute /Cacute 200 /Ccaron 202 /Eogonek 204 /Ecaron 207 /Dcaron /Dslash /Nacute /Ncaron 213 /Odblacute 216 /Rcaron /Uring 219 /Udblacute 222 /Tcedilla 224 /racute 227 /abreve 229 /lacute /cacute 232 /ccaron 234 /eogonek 236 /ecaron 239 /dcaron /dmacron /nacute /ncaron 245 /odblacute 248 /rcaron /uring 251 /udblacute 254 /tcedilla /dotaccent';
$file='';
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/times.php
0,0 → 1,16
<?php
// vim: expandtab sw=4 ts=4 sts=4:
$fpdf_charwidths['times']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722,
'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944,
'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980,
chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333,
chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500);
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/timesb.php
0,0 → 1,16
<?php
// vim: expandtab sw=4 ts=4 sts=4:
$fpdf_charwidths['timesB']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722,
'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000,
'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833,
'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333,
chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/timesbi.php
0,0 → 1,16
<?php
// vim: expandtab sw=4 ts=4 sts=4:
$fpdf_charwidths['timesBI']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667,
'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889,
'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333,
chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444);
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/timesi.php
0,0 → 1,16
<?php
// vim: expandtab sw=4 ts=4 sts=4:
$fpdf_charwidths['timesI']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611,
'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833,
'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722,
'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980,
chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333,
chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611,
chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444);
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/font/zapfdingbats.php
0,0 → 1,16
<?php
// vim: expandtab sw=4 ts=4 sts=4:
$fpdf_charwidths['zapfdingbats']=array(
chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,
chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,
','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,
'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,
'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,
'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,
chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,
chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,
chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,
chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,
chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/fpdf.php
0,0 → 1,1629
<?php
/*******************************************************************************
* Software: FPDF *
* Version: 1.52 *
* Date: 2003-12-30 *
* Author: Olivier PLATHEY *
* License: Freeware *
* *
* You may use, modify and redistribute this software as you wish. *
*******************************************************************************/
 
if(!class_exists('FPDF'))
{
define('FPDF_VERSION','1.52');
 
class FPDF
{
//Private properties
var $page; //current page number
var $n; //current object number
var $offsets; //array of object offsets
var $buffer; //buffer holding in-memory PDF
var $pages; //array containing pages
var $state; //current document state
var $compress; //compression flag
var $DefOrientation; //default orientation
var $CurOrientation; //current orientation
var $OrientationChanges; //array indicating orientation changes
var $k; //scale factor (number of points in user unit)
var $fwPt,$fhPt; //dimensions of page format in points
var $fw,$fh; //dimensions of page format in user unit
var $wPt,$hPt; //current dimensions of page in points
var $w,$h; //current dimensions of page in user unit
var $lMargin; //left margin
var $tMargin; //top margin
var $rMargin; //right margin
var $bMargin; //page break margin
var $cMargin; //cell margin
var $x,$y; //current position in user unit for cell positioning
var $lasth; //height of last cell printed
var $LineWidth; //line width in user unit
var $CoreFonts; //array of standard font names
var $fonts; //array of used fonts
var $FontFiles; //array of font files
var $diffs; //array of encoding differences
var $images; //array of used images
var $PageLinks; //array of links in pages
var $links; //array of internal links
var $FontFamily; //current font family
var $FontStyle; //current font style
var $underline; //underlining flag
var $CurrentFont; //current font info
var $FontSizePt; //current font size in points
var $FontSize; //current font size in user unit
var $DrawColor; //commands for drawing color
var $FillColor; //commands for filling color
var $TextColor; //commands for text color
var $ColorFlag; //indicates whether fill and text colors are different
var $ws; //word spacing
var $AutoPageBreak; //automatic page breaking
var $PageBreakTrigger; //threshold used to trigger page breaks
var $InFooter; //flag set when processing footer
var $ZoomMode; //zoom display mode
var $LayoutMode; //layout display mode
var $title; //title
var $subject; //subject
var $author; //author
var $keywords; //keywords
var $creator; //creator
var $AliasNbPages; //alias for total number of pages
 
/*******************************************************************************
* *
* Public methods *
* *
*******************************************************************************/
function FPDF($orientation='P',$unit='mm',$format='A4')
{
//Some checks
$this->_dochecks();
//Initialization of properties
$this->page=0;
$this->n=2;
$this->buffer='';
$this->pages=array();
$this->OrientationChanges=array();
$this->state=0;
$this->fonts=array();
$this->FontFiles=array();
$this->diffs=array();
$this->images=array();
$this->links=array();
$this->InFooter=false;
$this->lasth=0;
$this->FontFamily='';
$this->FontStyle='';
$this->FontSizePt=12;
$this->underline=false;
$this->DrawColor='0 G';
$this->FillColor='0 g';
$this->TextColor='0 g';
$this->ColorFlag=false;
$this->ws=0;
//Standard fonts
$this->CoreFonts=array('courier'=>'Courier','courierB'=>'Courier-Bold','courierI'=>'Courier-Oblique','courierBI'=>'Courier-BoldOblique',
'helvetica'=>'Helvetica','helveticaB'=>'Helvetica-Bold','helveticaI'=>'Helvetica-Oblique','helveticaBI'=>'Helvetica-BoldOblique',
'times'=>'Times-Roman','timesB'=>'Times-Bold','timesI'=>'Times-Italic','timesBI'=>'Times-BoldItalic',
'symbol'=>'Symbol','zapfdingbats'=>'ZapfDingbats');
//Scale factor
if($unit=='pt')
$this->k=1;
elseif($unit=='mm')
$this->k=72/25.4;
elseif($unit=='cm')
$this->k=72/2.54;
elseif($unit=='in')
$this->k=72;
else
$this->Error('Incorrect unit: '.$unit);
//Page format
if(is_string($format))
{
$format=strtolower($format);
if($format=='a3')
$format=array(841.89,1190.55);
elseif($format=='a4')
$format=array(595.28,841.89);
elseif($format=='a5')
$format=array(420.94,595.28);
elseif($format=='letter')
$format=array(612,792);
elseif($format=='legal')
$format=array(612,1008);
else
$this->Error('Unknown page format: '.$format);
$this->fwPt=$format[0];
$this->fhPt=$format[1];
}
else
{
$this->fwPt=$format[0]*$this->k;
$this->fhPt=$format[1]*$this->k;
}
$this->fw=$this->fwPt/$this->k;
$this->fh=$this->fhPt/$this->k;
//Page orientation
$orientation=strtolower($orientation);
if($orientation=='p' or $orientation=='portrait')
{
$this->DefOrientation='P';
$this->wPt=$this->fwPt;
$this->hPt=$this->fhPt;
}
elseif($orientation=='l' or $orientation=='landscape')
{
$this->DefOrientation='L';
$this->wPt=$this->fhPt;
$this->hPt=$this->fwPt;
}
else
$this->Error('Incorrect orientation: '.$orientation);
$this->CurOrientation=$this->DefOrientation;
$this->w=$this->wPt/$this->k;
$this->h=$this->hPt/$this->k;
//Page margins (1 cm)
$margin=28.35/$this->k;
$this->SetMargins($margin,$margin);
//Interior cell margin (1 mm)
$this->cMargin=$margin/10;
//Line width (0.2 mm)
$this->LineWidth=.567/$this->k;
//Automatic page break
$this->SetAutoPageBreak(true,2*$margin);
//Full width display mode
$this->SetDisplayMode('fullwidth');
//Compression
$this->SetCompression(true);
}
 
function SetMargins($left,$top,$right=-1)
{
//Set left, top and right margins
$this->lMargin=$left;
$this->tMargin=$top;
if($right==-1)
$right=$left;
$this->rMargin=$right;
}
 
function SetLeftMargin($margin)
{
//Set left margin
$this->lMargin=$margin;
if($this->page>0 and $this->x<$margin)
$this->x=$margin;
}
 
function SetTopMargin($margin)
{
//Set top margin
$this->tMargin=$margin;
}
 
function SetRightMargin($margin)
{
//Set right margin
$this->rMargin=$margin;
}
 
function SetAutoPageBreak($auto,$margin=0)
{
//Set auto page break mode and triggering margin
$this->AutoPageBreak=$auto;
$this->bMargin=$margin;
$this->PageBreakTrigger=$this->h-$margin;
}
 
function SetDisplayMode($zoom,$layout='continuous')
{
//Set display mode in viewer
if($zoom=='fullpage' or $zoom=='fullwidth' or $zoom=='real' or $zoom=='default' or !is_string($zoom))
$this->ZoomMode=$zoom;
else
$this->Error('Incorrect zoom display mode: '.$zoom);
if($layout=='single' or $layout=='continuous' or $layout=='two' or $layout=='default')
$this->LayoutMode=$layout;
else
$this->Error('Incorrect layout display mode: '.$layout);
}
 
function SetCompression($compress)
{
//Set page compression
if(function_exists('gzcompress'))
$this->compress=$compress;
else
$this->compress=false;
}
 
function SetTitle($title)
{
//Title of document
$this->title=$title;
}
 
function SetSubject($subject)
{
//Subject of document
$this->subject=$subject;
}
 
function SetAuthor($author)
{
//Author of document
$this->author=$author;
}
 
function SetKeywords($keywords)
{
//Keywords of document
$this->keywords=$keywords;
}
 
function SetCreator($creator)
{
//Creator of document
$this->creator=$creator;
}
 
function AliasNbPages($alias='{nb}')
{
//Define an alias for total number of pages
$this->AliasNbPages=$alias;
}
 
function Error($msg)
{
//Fatal error
die('<B>FPDF error: </B>'.$msg);
}
 
function Open()
{
//Begin document
if($this->state==0)
$this->_begindoc();
}
 
function Close()
{
//Terminate document
if($this->state==3)
return;
if($this->page==0)
$this->AddPage();
//Page footer
$this->InFooter=true;
$this->Footer();
$this->InFooter=false;
//Close page
$this->_endpage();
//Close document
$this->_enddoc();
}
 
function AddPage($orientation='')
{
//Start a new page
if($this->state==0)
$this->Open();
$family=$this->FontFamily;
$style=$this->FontStyle.($this->underline ? 'U' : '');
$size=$this->FontSizePt;
$lw=$this->LineWidth;
$dc=$this->DrawColor;
$fc=$this->FillColor;
$tc=$this->TextColor;
$cf=$this->ColorFlag;
if($this->page>0)
{
//Page footer
$this->InFooter=true;
$this->Footer();
$this->InFooter=false;
//Close page
$this->_endpage();
}
//Start new page
$this->_beginpage($orientation);
//Set line cap style to square
$this->_out('2 J');
//Set line width
$this->LineWidth=$lw;
$this->_out(sprintf('%.2f w',$lw*$this->k));
//Set font
if($family)
$this->SetFont($family,$style,$size);
//Set colors
$this->DrawColor=$dc;
if($dc!='0 G')
$this->_out($dc);
$this->FillColor=$fc;
if($fc!='0 g')
$this->_out($fc);
$this->TextColor=$tc;
$this->ColorFlag=$cf;
//Page header
$this->Header();
//Restore line width
if($this->LineWidth!=$lw)
{
$this->LineWidth=$lw;
$this->_out(sprintf('%.2f w',$lw*$this->k));
}
//Restore font
if($family)
$this->SetFont($family,$style,$size);
//Restore colors
if($this->DrawColor!=$dc)
{
$this->DrawColor=$dc;
$this->_out($dc);
}
if($this->FillColor!=$fc)
{
$this->FillColor=$fc;
$this->_out($fc);
}
$this->TextColor=$tc;
$this->ColorFlag=$cf;
}
 
function Header()
{
//To be implemented in your own inherited class
}
 
function Footer()
{
//To be implemented in your own inherited class
}
 
function PageNo()
{
//Get current page number
return $this->page;
}
 
function SetDrawColor($r,$g=-1,$b=-1)
{
//Set color for all stroking operations
if(($r==0 and $g==0 and $b==0) or $g==-1)
$this->DrawColor=sprintf('%.3f G',$r/255);
else
$this->DrawColor=sprintf('%.3f %.3f %.3f RG',$r/255,$g/255,$b/255);
if($this->page>0)
$this->_out($this->DrawColor);
}
 
function SetFillColor($r,$g=-1,$b=-1)
{
//Set color for all filling operations
if(($r==0 and $g==0 and $b==0) or $g==-1)
$this->FillColor=sprintf('%.3f g',$r/255);
else
$this->FillColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
$this->ColorFlag=($this->FillColor!=$this->TextColor);
if($this->page>0)
$this->_out($this->FillColor);
}
 
function SetTextColor($r,$g=-1,$b=-1)
{
//Set color for text
if(($r==0 and $g==0 and $b==0) or $g==-1)
$this->TextColor=sprintf('%.3f g',$r/255);
else
$this->TextColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255);
$this->ColorFlag=($this->FillColor!=$this->TextColor);
}
 
function GetStringWidth($s)
{
//Get width of a string in the current font
$s=(string)$s;
$cw=&$this->CurrentFont['cw'];
$w=0;
$l=strlen($s);
for($i=0;$i<$l;$i++)
$w+=$cw[$s{$i}];
return $w*$this->FontSize/1000;
}
 
function SetLineWidth($width)
{
//Set line width
$this->LineWidth=$width;
if($this->page>0)
$this->_out(sprintf('%.2f w',$width*$this->k));
}
 
function Line($x1,$y1,$x2,$y2)
{
//Draw a line
$this->_out(sprintf('%.2f %.2f m %.2f %.2f l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
}
 
function Rect($x,$y,$w,$h,$style='')
{
//Draw a rectangle
if($style=='F')
$op='f';
elseif($style=='FD' or $style=='DF')
$op='B';
else
$op='S';
$this->_out(sprintf('%.2f %.2f %.2f %.2f re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
}
 
function AddFont($family,$style='',$file='')
{
//Add a TrueType or Type1 font
$family=strtolower($family);
if($family=='arial')
$family='helvetica';
$style=strtoupper($style);
if($style=='IB')
$style='BI';
if(isset($this->fonts[$family.$style]))
$this->Error('Font already added: '.$family.' '.$style);
if($file=='')
$file=str_replace(' ','',$family).strtolower($style).'.php';
if(defined('FPDF_FONTPATH'))
$file=FPDF_FONTPATH.$file;
include($file);
if(!isset($name))
$this->Error('Could not include font definition file');
$i=count($this->fonts)+1;
$this->fonts[$family.$style]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc'=>$enc,'file'=>$file);
if($diff)
{
//Search existing encodings
$d=0;
$nb=count($this->diffs);
for($i=1;$i<=$nb;$i++)
if($this->diffs[$i]==$diff)
{
$d=$i;
break;
}
if($d==0)
{
$d=$nb+1;
$this->diffs[$d]=$diff;
}
$this->fonts[$family.$style]['diff']=$d;
}
if($file)
{
if($type=='TrueType')
$this->FontFiles[$file]=array('length1'=>$originalsize);
else
$this->FontFiles[$file]=array('length1'=>$size1,'length2'=>$size2);
}
}
 
function SetFont($family,$style='',$size=0)
{
//Select a font; size given in points
global $fpdf_charwidths;
 
$family=strtolower($family);
if($family=='')
$family=$this->FontFamily;
if($family=='arial')
$family='helvetica';
elseif($family=='symbol' or $family=='zapfdingbats')
$style='';
$style=strtoupper($style);
if(is_int(strpos($style,'U')))
{
$this->underline=true;
$style=str_replace('U','',$style);
}
else
$this->underline=false;
if($style=='IB')
$style='BI';
if($size==0)
$size=$this->FontSizePt;
//Test if font is already selected
if($this->FontFamily==$family and $this->FontStyle==$style and $this->FontSizePt==$size)
return;
//Test if used for the first time
$fontkey=$family.$style;
if(!isset($this->fonts[$fontkey]))
{
//Check if one of the standard fonts
if(isset($this->CoreFonts[$fontkey]))
{
if(!isset($fpdf_charwidths[$fontkey]))
{
//Load metric file
$file=$family;
if($family=='times' or $family=='helvetica')
$file.=strtolower($style);
$file.='.php';
if(defined('FPDF_FONTPATH'))
$file=FPDF_FONTPATH.$file;
include($file);
if(!isset($fpdf_charwidths[$fontkey]))
$this->Error('Could not include font metric file');
}
$i=count($this->fonts)+1;
$this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]);
}
else
$this->Error('Undefined font: '.$family.' '.$style);
}
//Select it
$this->FontFamily=$family;
$this->FontStyle=$style;
$this->FontSizePt=$size;
$this->FontSize=$size/$this->k;
$this->CurrentFont=&$this->fonts[$fontkey];
if($this->page>0)
$this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
}
 
function SetFontSize($size)
{
//Set font size in points
if($this->FontSizePt==$size)
return;
$this->FontSizePt=$size;
$this->FontSize=$size/$this->k;
if($this->page>0)
$this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
}
 
function AddLink()
{
//Create a new internal link
$n=count($this->links)+1;
$this->links[$n]=array(0,0);
return $n;
}
 
function SetLink($link,$y=0,$page=-1)
{
//Set destination of internal link
if($y==-1)
$y=$this->y;
if($page==-1)
$page=$this->page;
$this->links[$link]=array($page,$y);
}
 
function Link($x,$y,$w,$h,$link)
{
//Put a link on the page
$this->PageLinks[$this->page][]=array($x*$this->k,$this->hPt-$y*$this->k,$w*$this->k,$h*$this->k,$link);
}
 
function Text($x,$y,$txt)
{
//Output a string
$s=sprintf('BT %.2f %.2f Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
if($this->underline and $txt!='')
$s.=' '.$this->_dounderline($x,$y,$txt);
if($this->ColorFlag)
$s='q '.$this->TextColor.' '.$s.' Q';
$this->_out($s);
}
 
function AcceptPageBreak()
{
//Accept automatic page break or not
return $this->AutoPageBreak;
}
 
function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='')
{
//Output a cell
$k=$this->k;
if($this->y+$h>$this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak())
{
//Automatic page break
$x=$this->x;
$ws=$this->ws;
if($ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
$this->AddPage($this->CurOrientation);
$this->x=$x;
if($ws>0)
{
$this->ws=$ws;
$this->_out(sprintf('%.3f Tw',$ws*$k));
}
}
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$s='';
if($fill==1 or $border==1)
{
if($fill==1)
$op=($border==1) ? 'B' : 'f';
else
$op='S';
$s=sprintf('%.2f %.2f %.2f %.2f re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
}
if(is_string($border))
{
$x=$this->x;
$y=$this->y;
if(is_int(strpos($border,'L')))
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
if(is_int(strpos($border,'T')))
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
if(is_int(strpos($border,'R')))
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
if(is_int(strpos($border,'B')))
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
}
if($txt!='')
{
if($align=='R')
$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
elseif($align=='C')
$dx=($w-$this->GetStringWidth($txt))/2;
else
$dx=$this->cMargin;
if($this->ColorFlag)
$s.='q '.$this->TextColor.' ';
$txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
$s.=sprintf('BT %.2f %.2f Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
if($this->underline)
$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
if($this->ColorFlag)
$s.=' Q';
if($link)
$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
}
if($s)
$this->_out($s);
$this->lasth=$h;
if($ln>0)
{
//Go to next line
$this->y+=$h;
if($ln==1)
$this->x=$this->lMargin;
}
else
$this->x+=$w;
}
 
function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0)
{
//Output text with automatic or explicit line breaks
$cw=&$this->CurrentFont['cw'];
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("\r",'',$txt);
$nb=strlen($s);
if($nb>0 and $s[$nb-1]=="\n")
$nb--;
$b=0;
if($border)
{
if($border==1)
{
$border='LTRB';
$b='LRT';
$b2='LR';
}
else
{
$b2='';
if(is_int(strpos($border,'L')))
$b2.='L';
if(is_int(strpos($border,'R')))
$b2.='R';
$b=is_int(strpos($border,'T')) ? $b2.'T' : $b2;
}
}
$sep=-1;
$i=0;
$j=0;
$l=0;
$ns=0;
$nl=1;
while($i<$nb)
{
//Get next character
$c=$s{$i};
if($c=="\n")
{
//Explicit line break
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
$i++;
$sep=-1;
$j=$i;
$l=0;
$ns=0;
$nl++;
if($border and $nl==2)
$b=$b2;
continue;
}
if($c==' ')
{
$sep=$i;
$ls=$l;
$ns++;
}
$l+=isset($cw[ord($c)])?$cw[ord($c)]:0;
if($l>$wmax)
{
//Automatic line break
if($sep==-1)
{
if($i==$j)
$i++;
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
}
else
{
if($align=='J')
{
$this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
$this->_out(sprintf('%.3f Tw',$this->ws*$this->k));
}
$this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
$i=$sep+1;
}
$sep=-1;
$j=$i;
$l=0;
$ns=0;
$nl++;
if($border and $nl==2)
$b=$b2;
}
else
$i++;
}
//Last chunk
if($this->ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
if($border and is_int(strpos($border,'B')))
$b.='B';
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
$this->x=$this->lMargin;
}
 
function Write($h,$txt,$link='')
{
//Output text in flowing mode
$cw=&$this->CurrentFont['cw'];
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("\r",'',$txt);
$nb=strlen($s);
$sep=-1;
$i=0;
$j=0;
$l=0;
$nl=1;
while($i<$nb)
{
//Get next character
$c=$s{$i};
if($c=="\n")
{
//Explicit line break
$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
$i++;
$sep=-1;
$j=$i;
$l=0;
if($nl==1)
{
$this->x=$this->lMargin;
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
}
$nl++;
continue;
}
if($c==' ')
$sep=$i;
$l+=$cw[$c];
if($l>$wmax)
{
//Automatic line break
if($sep==-1)
{
if($this->x>$this->lMargin)
{
//Move to next line
$this->x=$this->lMargin;
$this->y+=$h;
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$i++;
$nl++;
continue;
}
if($i==$j)
$i++;
$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
}
else
{
$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link);
$i=$sep+1;
}
$sep=-1;
$j=$i;
$l=0;
if($nl==1)
{
$this->x=$this->lMargin;
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
}
$nl++;
}
else
$i++;
}
//Last chunk
if($i!=$j)
$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link);
}
 
function Image($file,$x,$y,$w=0,$h=0,$type='',$link='')
{
//Put an image on the page
if(!isset($this->images[$file]))
{
//First use of image, get info
if($type=='')
{
$pos=strrpos($file,'.');
if(!$pos)
$this->Error('Image file has no extension and no type was specified: '.$file);
$type=substr($file,$pos+1);
}
$type=strtolower($type);
$mqr=get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
if($type=='jpg' or $type=='jpeg')
$info=$this->_parsejpg($file);
elseif($type=='png')
$info=$this->_parsepng($file);
else
{
//Allow for additional formats
$mtd='_parse'.$type;
if(!method_exists($this,$mtd))
$this->Error('Unsupported image type: '.$type);
$info=$this->$mtd($file);
}
set_magic_quotes_runtime($mqr);
$info['i']=count($this->images)+1;
$this->images[$file]=$info;
}
else
$info=$this->images[$file];
//Automatic width and height calculation if needed
if($w==0 and $h==0)
{
//Put image at 72 dpi
$w=$info['w']/$this->k;
$h=$info['h']/$this->k;
}
if($w==0)
$w=$h*$info['w']/$info['h'];
if($h==0)
$h=$w*$info['h']/$info['w'];
$this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
if($link)
$this->Link($x,$y,$w,$h,$link);
}
 
function Ln($h='')
{
//Line feed; default value is last cell height
$this->x=$this->lMargin;
if(is_string($h))
$this->y+=$this->lasth;
else
$this->y+=$h;
}
 
function GetX()
{
//Get x position
return $this->x;
}
 
function SetX($x)
{
//Set x position
if($x>=0)
$this->x=$x;
else
$this->x=$this->w+$x;
}
 
function GetY()
{
//Get y position
return $this->y;
}
 
function SetY($y)
{
//Set y position and reset x
$this->x=$this->lMargin;
if($y>=0)
$this->y=$y;
else
$this->y=$this->h+$y;
}
 
function SetXY($x,$y)
{
//Set x and y positions
$this->SetY($y);
$this->SetX($x);
}
 
function Output($name='',$dest='')
{
//Output PDF to some destination
// lem9
//global $HTTP_SERVER_VARS;
 
//Finish document if necessary
if($this->state<3)
$this->Close();
//Normalize parameters
if(is_bool($dest))
$dest=$dest ? 'D' : 'F';
$dest=strtoupper($dest);
if($dest=='')
{
if($name=='')
{
$name='doc.pdf';
$dest='I';
}
else
$dest='F';
}
switch($dest)
{
case 'I':
//Send to standard output
// lem9
//if(isset($HTTP_SERVER_VARS['SERVER_NAME']))
if(PMA_getenv('SERVER_NAME'))
{
//We send to a browser
Header('Content-Type: application/pdf');
if(headers_sent())
$this->Error('Some data has already been output to browser, can\'t send PDF file');
Header('Content-Length: '.strlen($this->buffer));
Header('Content-disposition: inline; filename="'.$name.'"');
}
echo $this->buffer;
break;
case 'D':
//Download file
// lem9
//if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'],'MSIE'))
if(PMA_getenv('HTTP_USER_AGENT') and strpos(PMA_getenv('HTTP_USER_AGENT'), 'MSIE'))
Header('Content-Type: application/force-download');
else
Header('Content-Type: application/octet-stream');
if(headers_sent())
$this->Error('Some data has already been output to browser, can\'t send PDF file');
Header('Content-Length: '.strlen($this->buffer));
Header('Content-disposition: attachment; filename="'.$name.'"');
echo $this->buffer;
break;
case 'F':
//Save to local file
$f=fopen($name,'wb');
if(!$f)
$this->Error('Unable to create output file: '.$name);
fwrite($f,$this->buffer,strlen($this->buffer));
fclose($f);
break;
case 'S':
//Return as a string
return $this->buffer;
default:
$this->Error('Incorrect output destination: '.$dest);
}
return '';
}
 
/*******************************************************************************
* *
* Protected methods *
* *
*******************************************************************************/
function _dochecks()
{
//Check for locale-related bug
if(1.1==1)
$this->Error('Don\'t alter the locale before including class file');
//Check for decimal separator
if(sprintf('%.1f',1.0)!='1.0')
setlocale(LC_NUMERIC,'C');
}
 
function _begindoc()
{
//Start document
$this->state=1;
$this->_out('%PDF-1.3');
}
 
function _strreplace($what, $to, $where) {
return str_replace($what, $to, $where);
}
 
function _putpages()
{
$nb=$this->page;
if(!empty($this->AliasNbPages))
{
//Replace number of pages
for($n=1;$n<=$nb;$n++)
$this->pages[$n]=$this->_strreplace($this->AliasNbPages,$nb,$this->pages[$n]);
}
if($this->DefOrientation=='P')
{
$wPt=$this->fwPt;
$hPt=$this->fhPt;
}
else
{
$wPt=$this->fhPt;
$hPt=$this->fwPt;
}
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
for($n=1;$n<=$nb;$n++)
{
//Page
$this->_newobj();
$this->_out('<</Type /Page');
$this->_out('/Parent 1 0 R');
if(isset($this->OrientationChanges[$n]))
$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$hPt,$wPt));
$this->_out('/Resources 2 0 R');
if(isset($this->PageLinks[$n]))
{
//Links
$annots='/Annots [';
foreach($this->PageLinks[$n] as $pl)
{
$rect=sprintf('%.2f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
$annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
if(is_string($pl[4]))
$annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
else
{
$l=$this->links[$pl[4]];
$h=isset($this->OrientationChanges[$l[0]]) ? $wPt : $hPt;
$annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>',1+2*$l[0],$h-$l[1]*$this->k);
}
}
$this->_out($annots.']');
}
$this->_out('/Contents '.($this->n+1).' 0 R>>');
$this->_out('endobj');
//Page content
$p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n];
$this->_newobj();
$this->_out('<<'.$filter.'/Length '.strlen($p).'>>');
$this->_putstream($p);
$this->_out('endobj');
}
//Pages root
$this->offsets[1]=strlen($this->buffer);
$this->_out('1 0 obj');
$this->_out('<</Type /Pages');
$kids='/Kids [';
for($i=0;$i<$nb;$i++)
$kids.=(3+2*$i).' 0 R ';
$this->_out($kids.']');
$this->_out('/Count '.$nb);
$this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$wPt,$hPt));
$this->_out('>>');
$this->_out('endobj');
}
 
function _putfonts()
{
$nf=$this->n;
foreach($this->diffs as $diff)
{
//Encodings
$this->_newobj();
$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
$this->_out('endobj');
}
$mqr=get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
foreach($this->FontFiles as $file=>$info)
{
//Font file embedding
$this->_newobj();
$this->FontFiles[$file]['n']=$this->n;
if(defined('FPDF_FONTPATH'))
$file=FPDF_FONTPATH.$file;
$size=filesize($file);
if(!$size)
$this->Error('Font file not found');
$this->_out('<</Length '.$size);
if(substr($file,-2)=='.z')
$this->_out('/Filter /FlateDecode');
$this->_out('/Length1 '.$info['length1']);
if(isset($info['length2']))
$this->_out('/Length2 '.$info['length2'].' /Length3 0');
$this->_out('>>');
$f=fopen($file,'rb');
$this->_putstream(fread($f,$size));
fclose($f);
$this->_out('endobj');
}
set_magic_quotes_runtime($mqr);
foreach($this->fonts as $k=>$font)
{
//Font objects
$this->fonts[$k]['n']=$this->n+1;
$type=$font['type'];
$name=$font['name'];
if($type=='core')
{
//Standard font
$this->_newobj();
$this->_out('<</Type /Font');
$this->_out('/BaseFont /'.$name);
$this->_out('/Subtype /Type1');
if($name!='Symbol' and $name!='ZapfDingbats')
$this->_out('/Encoding /WinAnsiEncoding');
$this->_out('>>');
$this->_out('endobj');
}
elseif($type=='Type1' or $type=='TrueType')
{
//Additional Type1 or TrueType font
$this->_newobj();
$this->_out('<</Type /Font');
$this->_out('/BaseFont /'.$name);
$this->_out('/Subtype /'.$type);
$this->_out('/FirstChar 32 /LastChar 255');
$this->_out('/Widths '.($this->n+1).' 0 R');
$this->_out('/FontDescriptor '.($this->n+2).' 0 R');
if($font['enc'])
{
if(isset($font['diff']))
$this->_out('/Encoding '.($nf+$font['diff']).' 0 R');
else
$this->_out('/Encoding /WinAnsiEncoding');
}
$this->_out('>>');
$this->_out('endobj');
//Widths
$this->_newobj();
$cw=&$font['cw'];
$s='[';
for($i=32;$i<=255;$i++)
$s.=$cw[chr($i)].' ';
$this->_out($s.']');
$this->_out('endobj');
//Descriptor
$this->_newobj();
$s='<</Type /FontDescriptor /FontName /'.$name;
foreach($font['desc'] as $k=>$v)
$s.=' /'.$k.' '.$v;
$file=$font['file'];
if($file)
$s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R';
$this->_out($s.'>>');
$this->_out('endobj');
}
else
{
//Allow for additional types
$mtd='_put'.strtolower($type);
if(!method_exists($this,$mtd))
$this->Error('Unsupported font type: '.$type);
$this->$mtd($font);
}
}
}
 
function _putimages()
{
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->images);
while(list($file,$info)=each($this->images))
{
$this->_newobj();
$this->images[$file]['n']=$this->n;
$this->_out('<</Type /XObject');
$this->_out('/Subtype /Image');
$this->_out('/Width '.$info['w']);
$this->_out('/Height '.$info['h']);
if($info['cs']=='Indexed')
$this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
else
{
$this->_out('/ColorSpace /'.$info['cs']);
if($info['cs']=='DeviceCMYK')
$this->_out('/Decode [1 0 1 0 1 0 1 0]');
}
$this->_out('/BitsPerComponent '.$info['bpc']);
$this->_out('/Filter /'.$info['f']);
if(isset($info['parms']))
$this->_out($info['parms']);
if(isset($info['trns']) and is_array($info['trns']))
{
$trns='';
for($i=0;$i<count($info['trns']);$i++)
$trns.=$info['trns'][$i].' '.$info['trns'][$i].' ';
$this->_out('/Mask ['.$trns.']');
}
$this->_out('/Length '.strlen($info['data']).'>>');
$this->_putstream($info['data']);
unset($this->images[$file]['data']);
$this->_out('endobj');
//Palette
if($info['cs']=='Indexed')
{
$this->_newobj();
$pal=($this->compress) ? gzcompress($info['pal']) : $info['pal'];
$this->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
$this->_putstream($pal);
$this->_out('endobj');
}
}
}
 
function _putresources()
{
$this->_putfonts();
$this->_putimages();
//Resource dictionary
$this->offsets[2]=strlen($this->buffer);
$this->_out('2 0 obj');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
$this->_out('/Font <<');
foreach($this->fonts as $font)
$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
$this->_out('>>');
if(count($this->images))
{
$this->_out('/XObject <<');
foreach($this->images as $image)
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
$this->_out('>>');
}
$this->_out('>>');
$this->_out('endobj');
}
 
function _putinfo()
{
$this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION));
if(!empty($this->title))
$this->_out('/Title '.$this->_textstring($this->title));
if(!empty($this->subject))
$this->_out('/Subject '.$this->_textstring($this->subject));
if(!empty($this->author))
$this->_out('/Author '.$this->_textstring($this->author));
if(!empty($this->keywords))
$this->_out('/Keywords '.$this->_textstring($this->keywords));
if(!empty($this->creator))
$this->_out('/Creator '.$this->_textstring($this->creator));
$this->_out('/CreationDate '.$this->_textstring('D:'.date('YmdHis')));
}
 
function _putcatalog()
{
$this->_out('/Type /Catalog');
$this->_out('/Pages 1 0 R');
if($this->ZoomMode=='fullpage')
$this->_out('/OpenAction [3 0 R /Fit]');
elseif($this->ZoomMode=='fullwidth')
$this->_out('/OpenAction [3 0 R /FitH null]');
elseif($this->ZoomMode=='real')
$this->_out('/OpenAction [3 0 R /XYZ null null 1]');
elseif(!is_string($this->ZoomMode))
$this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']');
if($this->LayoutMode=='single')
$this->_out('/PageLayout /SinglePage');
elseif($this->LayoutMode=='continuous')
$this->_out('/PageLayout /OneColumn');
elseif($this->LayoutMode=='two')
$this->_out('/PageLayout /TwoColumnLeft');
}
 
function _puttrailer()
{
$this->_out('/Size '.($this->n+1));
$this->_out('/Root '.$this->n.' 0 R');
$this->_out('/Info '.($this->n-1).' 0 R');
}
 
function _enddoc()
{
$this->_putpages();
$this->_putresources();
//Info
$this->_newobj();
$this->_out('<<');
$this->_putinfo();
$this->_out('>>');
$this->_out('endobj');
//Catalog
$this->_newobj();
$this->_out('<<');
$this->_putcatalog();
$this->_out('>>');
$this->_out('endobj');
//Cross-ref
$o=strlen($this->buffer);
$this->_out('xref');
$this->_out('0 '.($this->n+1));
$this->_out('0000000000 65535 f ');
for($i=1;$i<=$this->n;$i++)
$this->_out(sprintf('%010d 00000 n ',$this->offsets[$i]));
//Trailer
$this->_out('trailer');
$this->_out('<<');
$this->_puttrailer();
$this->_out('>>');
$this->_out('startxref');
$this->_out($o);
$this->_out('%%EOF');
$this->state=3;
}
 
function _beginpage($orientation)
{
$this->page++;
$this->pages[$this->page]='';
$this->state=2;
$this->x=$this->lMargin;
$this->y=$this->tMargin;
$this->FontFamily='';
//Page orientation
if(!$orientation)
$orientation=$this->DefOrientation;
else
{
$orientation=strtoupper($orientation{0});
if($orientation!=$this->DefOrientation)
$this->OrientationChanges[$this->page]=true;
}
if($orientation!=$this->CurOrientation)
{
//Change orientation
if($orientation=='P')
{
$this->wPt=$this->fwPt;
$this->hPt=$this->fhPt;
$this->w=$this->fw;
$this->h=$this->fh;
}
else
{
$this->wPt=$this->fhPt;
$this->hPt=$this->fwPt;
$this->w=$this->fh;
$this->h=$this->fw;
}
$this->PageBreakTrigger=$this->h-$this->bMargin;
$this->CurOrientation=$orientation;
}
}
 
function _endpage()
{
//End of page contents
$this->state=1;
}
 
function _newobj()
{
//Begin a new object
$this->n++;
$this->offsets[$this->n]=strlen($this->buffer);
$this->_out($this->n.' 0 obj');
}
 
function _dounderline($x,$y,$txt)
{
//Underline text
$up=$this->CurrentFont['up'];
$ut=$this->CurrentFont['ut'];
$w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' ');
return sprintf('%.2f %.2f %.2f %.2f re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
}
 
function _parsejpg($file)
{
//Extract info from a JPEG file
$a=GetImageSize($file);
if(!$a)
$this->Error('Missing or incorrect image file: '.$file);
if($a[2]!=2)
$this->Error('Not a JPEG file: '.$file);
if(!isset($a['channels']) or $a['channels']==3)
$colspace='DeviceRGB';
elseif($a['channels']==4)
$colspace='DeviceCMYK';
else
$colspace='DeviceGray';
$bpc=isset($a['bits']) ? $a['bits'] : 8;
//Read whole file
$f=fopen($file,'rb');
$data='';
while(!feof($f))
$data.=fread($f,4096);
fclose($f);
return array('w'=>$a[0],'h'=>$a[1],'cs'=>$colspace,'bpc'=>$bpc,'f'=>'DCTDecode','data'=>$data);
}
 
function _parsepng($file)
{
//Extract info from a PNG file
$f=fopen($file,'rb');
if(!$f)
$this->Error('Can\'t open image file: '.$file);
//Check signature
if(fread($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
$this->Error('Not a PNG file: '.$file);
//Read header chunk
fread($f,4);
if(fread($f,4)!='IHDR')
$this->Error('Incorrect PNG file: '.$file);
$w=$this->_freadint($f);
$h=$this->_freadint($f);
$bpc=ord(fread($f,1));
if($bpc>8)
$this->Error('16-bit depth not supported: '.$file);
$ct=ord(fread($f,1));
if($ct==0)
$colspace='DeviceGray';
elseif($ct==2)
$colspace='DeviceRGB';
elseif($ct==3)
$colspace='Indexed';
else
$this->Error('Alpha channel not supported: '.$file);
if(ord(fread($f,1))!=0)
$this->Error('Unknown compression method: '.$file);
if(ord(fread($f,1))!=0)
$this->Error('Unknown filter method: '.$file);
if(ord(fread($f,1))!=0)
$this->Error('Interlacing not supported: '.$file);
fread($f,4);
$parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
//Scan chunks looking for palette, transparency and image data
$pal='';
$trns='';
$data='';
do
{
$n=$this->_freadint($f);
$type=fread($f,4);
if($type=='PLTE')
{
//Read palette
$pal=fread($f,$n);
fread($f,4);
}
elseif($type=='tRNS')
{
//Read transparency info
$t=fread($f,$n);
if($ct==0)
$trns=array(ord(substr($t,1,1)));
elseif($ct==2)
$trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));
else
{
$pos=strpos($t,chr(0));
if(is_int($pos))
$trns=array($pos);
}
fread($f,4);
}
elseif($type=='IDAT')
{
//Read image data block
$data.=fread($f,$n);
fread($f,4);
}
elseif($type=='IEND')
break;
else
fread($f,$n+4);
}
while($n);
if($colspace=='Indexed' and empty($pal))
$this->Error('Missing palette in '.$file);
fclose($f);
return array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$data);
}
 
function _freadint($f)
{
//Read a 4-byte integer from file
$i=ord(fread($f,1))<<24;
$i+=ord(fread($f,1))<<16;
$i+=ord(fread($f,1))<<8;
$i+=ord(fread($f,1));
return $i;
}
 
function _textstring($s)
{
//Format a text string
return '('.$this->_escape($s).')';
}
 
function _escape($s)
{
//Add \ before \, ( and )
return str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$s)));
}
 
function _putstream($s)
{
$this->_out('stream');
$this->_out($s);
$this->_out('endstream');
}
 
function _out($s)
{
//Add a line to the document
if($this->state==2)
$this->pages[$this->page].=$s."\n";
else
$this->buffer.=$s."\n";
}
//End of class
}
 
//Handle special IE contype request
// lem9
//if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and $HTTP_SERVER_VARS['HTTP_USER_AGENT']=='contype')
if(PMA_getenv('HTTP_USER_AGENT') == 'contype')
{
Header('Content-Type: application/pdf');
exit;
}
 
}
?>
/Web/Maintenance/phpMyAdmin/libraries/fpdf/ufpdf.php
0,0 → 1,483
<?php
/*******************************************************************************
* Software: UFPDF, Unicode Free PDF generator *
* Version: 0.1 *
* based on FPDF 1.52 by Olivier PLATHEY *
* Date: 2004-09-01 *
* Author: Steven Wittens <steven@acko.net> *
* License: GPL *
* *
* UFPDF is a modification of FPDF to support Unicode through UTF-8. *
* *
*******************************************************************************/
 
if(!class_exists('UFPDF'))
{
define('UFPDF_VERSION','0.1');
 
include_once './libraries/fpdf/fpdf.php';
 
class UFPDF extends FPDF
{
 
/*******************************************************************************
* *
* Public methods *
* *
*******************************************************************************/
function UFPDF($orientation='P',$unit='mm',$format='A4')
{
FPDF::FPDF($orientation, $unit, $format);
}
 
function GetStringWidth($s)
{
//Get width of a string in the current font
$s = (string)$s;
$codepoints=$this->utf8_to_codepoints($s);
$cw=&$this->CurrentFont['cw'];
$w=0;
foreach($codepoints as $cp)
$w+=isset($cw[$cp])?$cw[$cp]:0;
return $w*$this->FontSize/1000;
}
 
function AddFont($family,$style='',$file='')
{
//Add a TrueType or Type1 font
$family=strtolower($family);
if($family=='arial')
$family='helvetica';
$style=strtoupper($style);
if($style=='IB')
$style='BI';
if(isset($this->fonts[$family.$style]))
$this->Error('Font already added: '.$family.' '.$style);
if($file=='')
$file=str_replace(' ','',$family).strtolower($style).'.php';
if(defined('FPDF_FONTPATH'))
$file=FPDF_FONTPATH.$file;
include($file);
if(!isset($name))
$this->Error('Could not include font definition file');
$i=count($this->fonts)+1;
$this->fonts[$family.$style]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'file'=>$file,'ctg'=>$ctg);
if($file)
{
if($type=='TrueTypeUnicode')
$this->FontFiles[$file]=array('length1'=>$originalsize);
else
$this->FontFiles[$file]=array('length1'=>$size1,'length2'=>$size2);
}
}
 
function Text($x,$y,$txt)
{
//Output a string
$s=sprintf('BT %.2f %.2f Td %s Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escapetext($txt));
if($this->underline and $txt!='')
$s.=' '.$this->_dounderline($x,$y,$this->GetStringWidth($txt),$txt);
if($this->ColorFlag)
$s='q '.$this->TextColor.' '.$s.' Q';
$this->_out($s);
}
 
function AcceptPageBreak()
{
//Accept automatic page break or not
return $this->AutoPageBreak;
}
 
function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='')
{
//Output a cell
$k=$this->k;
if($this->y+$h>$this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak())
{
//Automatic page break
$x=$this->x;
$ws=$this->ws;
if($ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
$this->AddPage($this->CurOrientation);
$this->x=$x;
if($ws>0)
{
$this->ws=$ws;
$this->_out(sprintf('%.3f Tw',$ws*$k));
}
}
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$s='';
if($fill==1 or $border==1)
{
if($fill==1)
$op=($border==1) ? 'B' : 'f';
else
$op='S';
$s=sprintf('%.2f %.2f %.2f %.2f re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
}
if(is_string($border))
{
$x=$this->x;
$y=$this->y;
if(is_int(strpos($border,'L')))
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
if(is_int(strpos($border,'T')))
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
if(is_int(strpos($border,'R')))
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
if(is_int(strpos($border,'B')))
$s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
}
if($txt!='')
{
$width = $this->GetStringWidth($txt);
if($align=='R')
$dx=$w-$this->cMargin-$width;
elseif($align=='C')
$dx=($w-$width)/2;
else
$dx=$this->cMargin;
if($this->ColorFlag)
$s.='q '.$this->TextColor.' ';
$txtstring=$this->_escapetext($txt);
$s.=sprintf('BT %.2f %.2f Td %s Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txtstring);
if($this->underline)
$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$width,$txt);
if($this->ColorFlag)
$s.=' Q';
if($link)
$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$width,$this->FontSize,$link);
}
if($s)
$this->_out($s);
$this->lasth=$h;
if($ln>0)
{
//Go to next line
$this->y+=$h;
if($ln==1)
$this->x=$this->lMargin;
}
else
$this->x+=$w;
}
 
/*******************************************************************************
* *
* Protected methods *
* *
*******************************************************************************/
 
function _puttruetypeunicode($font) {
//Type0 Font
$this->_newobj();
$this->_out('<</Type /Font');
$this->_out('/Subtype /Type0');
$this->_out('/BaseFont /'. $font['name'] .'-UCS');
$this->_out('/Encoding /Identity-H');
$this->_out('/DescendantFonts ['. ($this->n + 1) .' 0 R]');
$this->_out('>>');
$this->_out('endobj');
 
//CIDFont
$this->_newobj();
$this->_out('<</Type /Font');
$this->_out('/Subtype /CIDFontType2');
$this->_out('/BaseFont /'. $font['name']);
$this->_out('/CIDSystemInfo <</Registry (Adobe) /Ordering (UCS) /Supplement 0>>');
$this->_out('/FontDescriptor '. ($this->n + 1) .' 0 R');
$c = 0;
$widths = '';
foreach ($font['cw'] as $i => $w) {
$widths .= $i .' ['. $w.'] ';
}
$this->_out('/W ['. $widths .']');
$this->_out('/CIDToGIDMap '. ($this->n + 2) .' 0 R');
$this->_out('>>');
$this->_out('endobj');
 
//Font descriptor
$this->_newobj();
$this->_out('<</Type /FontDescriptor');
$this->_out('/FontName /'.$font['name']);
$s = '';
foreach ($font['desc'] as $k => $v) {
$s .= ' /'. $k .' '. $v;
}
if ($font['file']) {
$s .= ' /FontFile2 '. $this->FontFiles[$font['file']]['n'] .' 0 R';
}
$this->_out($s);
$this->_out('>>');
$this->_out('endobj');
 
//Embed CIDToGIDMap
$this->_newobj();
if(defined('FPDF_FONTPATH'))
$file=FPDF_FONTPATH.$font['ctg'];
else
$file=$font['ctg'];
$size=filesize($file);
if(!$size)
$this->Error('Font file not found');
$this->_out('<</Length '.$size);
if(substr($file,-2) == '.z')
$this->_out('/Filter /FlateDecode');
$this->_out('>>');
$f = fopen($file,'rb');
$this->_putstream(fread($f,$size));
fclose($f);
$this->_out('endobj');
}
 
function _dounderline($x,$y,$width,$txt)
{
//Underline text
$up=$this->CurrentFont['up'];
$ut=$this->CurrentFont['ut'];
$w=$width+$this->ws*substr_count($txt,' ');
return sprintf('%.2f %.2f %.2f %.2f re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt);
}
 
function _textstring($s)
{
//Convert to UTF-16BE
$s = $this->utf8_to_utf16be($s);
//Escape necessary characters
return '('. strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\')) .')';
}
 
function _strreplace($what, $to, $where) {
$to = '' . $to;
return str_replace($this->utf8_to_utf16be($what, false), $this->utf8_to_utf16be($to, false), $where);
}
 
function _escapetext($s)
{
//Convert to UTF-16BE
$s = $this->utf8_to_utf16be($s, false);
//Escape necessary characters
return '('. strtr($s, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\')) .')';
}
 
function _putinfo()
{
$this->_out('/Producer '.$this->_textstring('UFPDF '. UFPDF_VERSION));
if(!empty($this->title))
$this->_out('/Title '.$this->_textstring($this->title));
if(!empty($this->subject))
$this->_out('/Subject '.$this->_textstring($this->subject));
if(!empty($this->author))
$this->_out('/Author '.$this->_textstring($this->author));
if(!empty($this->keywords))
$this->_out('/Keywords '.$this->_textstring($this->keywords));
if(!empty($this->creator))
$this->_out('/Creator '.$this->_textstring($this->creator));
$this->_out('/CreationDate '.$this->_textstring('D:'.date('YmdHis')));
}
 
// UTF-8 to UTF-16BE conversion.
// Correctly handles all illegal UTF-8 sequences.
function utf8_to_utf16be(&$txt, $bom = true) {
$l = strlen($txt);
$out = $bom ? "\xFE\xFF" : '';
for ($i = 0; $i < $l; ++$i) {
$c = ord($txt{$i});
// ASCII
if ($c < 0x80) {
$out .= "\x00". $txt{$i};
}
// Lost continuation byte
else if ($c < 0xC0) {
$out .= "\xFF\xFD";
continue;
}
// Multibyte sequence leading byte
else {
if ($c < 0xE0) {
$s = 2;
}
else if ($c < 0xF0) {
$s = 3;
}
else if ($c < 0xF8) {
$s = 4;
}
// 5/6 byte sequences not possible for Unicode.
else {
$out .= "\xFF\xFD";
while (ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) { ++$i; }
continue;
}
 
$q = array($c);
// Fetch rest of sequence
$l = strlen($txt);
while ($i + 1 < $l && ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) { ++$i; $q[] = ord($txt{$i}); }
 
// Check length
if (count($q) != $s) {
$out .= "\xFF\xFD";
continue;
}
 
switch ($s) {
case 2:
$cp = (($q[0] ^ 0xC0) << 6) | ($q[1] ^ 0x80);
// Overlong sequence
if ($cp < 0x80) {
$out .= "\xFF\xFD";
}
else {
$out .= chr($cp >> 8);
$out .= chr($cp & 0xFF);
}
continue;
 
case 3:
$cp = (($q[0] ^ 0xE0) << 12) | (($q[1] ^ 0x80) << 6) | ($q[2] ^ 0x80);
// Overlong sequence
if ($cp < 0x800) {
$out .= "\xFF\xFD";
}
// Check for UTF-8 encoded surrogates (caused by a bad UTF-8 encoder)
else if ($c > 0xD800 && $c < 0xDFFF) {
$out .= "\xFF\xFD";
}
else {
$out .= chr($cp >> 8);
$out .= chr($cp & 0xFF);
}
continue;
 
case 4:
$cp = (($q[0] ^ 0xF0) << 18) | (($q[1] ^ 0x80) << 12) | (($q[2] ^ 0x80) << 6) | ($q[3] ^ 0x80);
// Overlong sequence
if ($cp < 0x10000) {
$out .= "\xFF\xFD";
}
// Outside of the Unicode range
else if ($cp >= 0x10FFFF) {
$out .= "\xFF\xFD";
}
else {
// Use surrogates
$cp -= 0x10000;
$s1 = 0xD800 | ($cp >> 10);
$s2 = 0xDC00 | ($cp & 0x3FF);
 
$out .= chr($s1 >> 8);
$out .= chr($s1 & 0xFF);
$out .= chr($s2 >> 8);
$out .= chr($s2 & 0xFF);
}
continue;
}
}
}
return $out;
}
 
// UTF-8 to codepoint array conversion.
// Correctly handles all illegal UTF-8 sequences.
function utf8_to_codepoints(&$txt) {
$l = strlen($txt);
$out = array();
for ($i = 0; $i < $l; ++$i) {
$c = ord($txt{$i});
// ASCII
if ($c < 0x80) {
$out[] = ord($txt{$i});
}
// Lost continuation byte
else if ($c < 0xC0) {
$out[] = 0xFFFD;
continue;
}
// Multibyte sequence leading byte
else {
if ($c < 0xE0) {
$s = 2;
}
else if ($c < 0xF0) {
$s = 3;
}
else if ($c < 0xF8) {
$s = 4;
}
// 5/6 byte sequences not possible for Unicode.
else {
$out[] = 0xFFFD;
while (ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) { ++$i; }
continue;
}
 
$q = array($c);
// Fetch rest of sequence
$l = strlen($txt);
while ($i + 1 < $l && ord($txt{$i + 1}) >= 0x80 && ord($txt{$i + 1}) < 0xC0) { ++$i; $q[] = ord($txt{$i}); }
 
// Check length
if (count($q) != $s) {
$out[] = 0xFFFD;
continue;
}
 
switch ($s) {
case 2:
$cp = (($q[0] ^ 0xC0) << 6) | ($q[1] ^ 0x80);
// Overlong sequence
if ($cp < 0x80) {
$out[] = 0xFFFD;
}
else {
$out[] = $cp;
}
continue;
 
case 3:
$cp = (($q[0] ^ 0xE0) << 12) | (($q[1] ^ 0x80) << 6) | ($q[2] ^ 0x80);
// Overlong sequence
if ($cp < 0x800) {
$out[] = 0xFFFD;
}
// Check for UTF-8 encoded surrogates (caused by a bad UTF-8 encoder)
else if ($c > 0xD800 && $c < 0xDFFF) {
$out[] = 0xFFFD;
}
else {
$out[] = $cp;
}
continue;
 
case 4:
$cp = (($q[0] ^ 0xF0) << 18) | (($q[1] ^ 0x80) << 12) | (($q[2] ^ 0x80) << 6) | ($q[3] ^ 0x80);
// Overlong sequence
if ($cp < 0x10000) {
$out[] = 0xFFFD;
}
// Outside of the Unicode range
else if ($cp >= 0x10FFFF) {
$out[] = 0xFFFD;
}
else {
$out[] = $cp;
}
continue;
}
}
}
return $out;
}
 
//End of class
}
 
}
?>
/Web/Maintenance/phpMyAdmin/libraries/get_foreign.lib.php
0,0 → 1,73
<?php
/* $Id: get_foreign.lib.php,v 2.10 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/**
* Gets foreign keys in preparation for a drop-down selector
* Thanks to <markus@noga.de>
*/
 
 
// lem9: we always show the foreign field in the drop-down; if a display
// field is defined, we show it besides the foreign field
$foreign_link = false;
if ($foreigners && isset($foreigners[$field])) {
$foreigner = $foreigners[$field];
$foreign_db = $foreigner['foreign_db'];
$foreign_table = $foreigner['foreign_table'];
$foreign_field = $foreigner['foreign_field'];
 
// Count number of rows in the foreign table. Currently we do
// not use a drop-down if more than 200 rows in the foreign table,
// for speed reasons and because we need a better interface for this.
//
// We could also do the SELECT anyway, with a LIMIT, and ensure that
// the current value of the field is one of the choices.
 
$the_total = PMA_countRecords($foreign_db, $foreign_table, TRUE);
 
if ((isset($override_total) && $override_total == true) || $the_total < $cfg['ForeignKeyMaxLimit']) {
// foreign_display can be FALSE if no display field defined:
$foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
 
$f_query_main = 'SELECT ' . PMA_backquote($foreign_field)
. (($foreign_display == FALSE) ? '' : ', ' . PMA_backquote($foreign_display));
$f_query_from = ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table);
$f_query_filter = empty($foreign_filter) ? '' : ' WHERE ' . PMA_backquote($foreign_field)
. ' LIKE "%' . PMA_sqlAddslashes($foreign_filter, TRUE) . '%"'
. (($foreign_display == FALSE) ? '' : ' OR ' . PMA_backquote($foreign_display)
. ' LIKE "%' . PMA_sqlAddslashes($foreign_filter, TRUE) . '%"'
);
$f_query_order = ($foreign_display == FALSE) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display);
$f_query_limit = isset($foreign_limit) ? $foreign_limit : '';
 
if (!empty($foreign_filter)) {
$res = PMA_DBI_query('SELECT COUNT(*)' . $f_query_from . $f_query_filter);
if ($res) {
$the_total = PMA_DBI_fetch_value($res);
@PMA_DBI_free_result($res);
} else {
$the_total = 0;
}
}
 
$disp = PMA_DBI_query($f_query_main . $f_query_from . $f_query_filter . $f_query_order . $f_query_limit);
if ($disp) {
// garvin: If a resultset has been created, pre-cache it in the $disp_row array
// This helps us from not needing to use mysql_data_seek by accessing a pre-cached
// PHP array. Usually those resultsets are not that big, so a performance hit should
// not be expected.
$disp_row = array();
while ($single_disp_row = @PMA_DBI_fetch_assoc($disp)) {
$disp_row[] = $single_disp_row;
}
@PMA_DBI_free_result($disp);
}
} else {
unset($disp_row);
$foreign_link = true;
}
} // end if $foreigners
 
?>
/Web/Maintenance/phpMyAdmin/libraries/grab_globals.lib.php
0,0 → 1,119
<?php
/* $Id: grab_globals.lib.php,v 2.27.2.1 2006/04/11 16:33:33 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/**
* This library grabs the names and values of the variables sent or posted to a
* script in the $_* arrays and sets simple globals variables from them. It does
* the same work for the $PHP_SELF, $HTTP_ACCEPT_LANGUAGE and
* $HTTP_AUTHORIZATION variables.
*
* loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
*/
 
/**
* copy values from one array to another, usally from a superglobal into $GLOBALS
*
* @uses $GLOBALS['_import_blacklist']
* @uses preg_replace()
* @uses array_keys()
* @uses array_unique()
* @uses stripslashes()
* @param array $array values from
* @param array $target values to
* @param boolean $sanitize prevent importing key names in $_import_blacklist
*/
function PMA_gpc_extract($array, &$target, $sanitize = true)
{
if ( ! is_array($array) ) {
return false;
}
 
if ( $sanitize ) {
$valid_variables = preg_replace($GLOBALS['_import_blacklist'], '',
array_keys($array));
$valid_variables = array_unique($valid_variables);
} else {
$valid_variables = array_keys($array);
}
 
foreach ( $valid_variables as $key ) {
 
if ( strlen($key) === 0 ) {
continue;
}
 
if ( is_array($array[$key]) ) {
// there could be a variable coming from a cookie of
// another application, with the same name as this array
unset( $target[$key] );
 
PMA_gpc_extract($array[$key], $target[$key], false);
} else {
$target[$key] = $array[$key];
}
}
return true;
}
 
 
/**
* @var array $_import_blacklist variable names that should NEVER be imported
* from superglobals
*/
$_import_blacklist = array(
'/^cfg$/i', // PMA configuration
'/^server$/i', // selected server
'/^db$/i', // page to display
'/^table$/i', // page to display
'/^goto$/i', // page to display
'/^back$/i', // the page go back
'/^lang$/i', // selected language
'/^convcharset$/i', // PMA convert charset
'/^collation_connection$/i', //
'/^set_theme$/i', //
'/^sql_query$/i', // the query to be executed
'/^GLOBALS$/i', // the global scope
'/^str.*$/i', // PMA localized strings
'/^_.*$/i', // PMA does not use variables starting with _ from extern
'/^.*\s+.*$/i', // no whitespaces anywhere
'/^[0-9]+.*$/i', // numeric variable names
//'/^PMA_.*$/i', // other PMA variables
);
 
if ( ! empty( $_GET ) ) {
PMA_gpc_extract($_GET, $GLOBALS);
}
 
if ( ! empty( $_POST ) ) {
PMA_gpc_extract($_POST, $GLOBALS);
}
 
if ( ! empty( $_FILES ) ) {
foreach ( $_FILES AS $name => $value ) {
$$name = $value['tmp_name'];
${$name . '_name'} = $value['name'];
}
unset( $name, $value );
}
 
/**
* globalize some environment variables
*/
$server_vars = array('PHP_SELF', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_AUTHORIZATION');
foreach ( $server_vars as $current ) {
// its not important HOW we detect html tags
// its more important to prevent XSS
// so its not important if we result in an invalid string,
// its even better than a XSS capable string
if (PMA_getenv($current) && false === strpos(PMA_getenv($current), '<')) {
$$current = PMA_getenv($current);
// already importet by register_globals?
} elseif ( ! isset( $$current ) || false !== strpos($$current, '<') ) {
$$current = '';
}
}
unset($server_vars, $current, $_import_blacklist);
 
?>
/Web/Maintenance/phpMyAdmin/libraries/header.inc.php
0,0 → 1,236
<?php
/* $Id: header.inc.php,v 2.6 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
require_once('./libraries/common.lib.php');
 
if (empty($GLOBALS['is_header_sent'])) {
 
/**
* Gets a core script and starts output buffering work
*/
require_once('./libraries/common.lib.php');
require_once('./libraries/ob.lib.php');
if ($GLOBALS['cfg']['OBGzip']) {
$GLOBALS['ob_mode'] = PMA_outBufferModeGet();
if ($GLOBALS['ob_mode']) {
PMA_outBufferPre($GLOBALS['ob_mode']);
}
}
 
// garvin: For re-usability, moved http-headers and stylesheets
// to a seperate file. It can now be included by header.inc.php,
// querywindow.php.
 
require_once('./libraries/header_http.inc.php');
require_once('./libraries/header_meta_style.inc.php');
 
// generate title
$title = '';
if ($cfg['ShowHttpHostTitle']) {
$title .= (empty($GLOBALS['cfg']['SetHttpHostTitle']) && isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $GLOBALS['cfg']['SetHttpHostTitle']) . ' / ';
}
if (!empty($GLOBALS['cfg']['Server']) && isset($GLOBALS['cfg']['Server']['host'])) {
$title.=str_replace('\'', '\\\'', $GLOBALS['cfg']['Server']['host']);
}
if (isset($GLOBALS['db'])) {
$title .= ' / ' . str_replace('\'', '\\\'', $GLOBALS['db']);
}
if (isset($GLOBALS['table'])) {
$title .= (empty($title) ? '' : ' ') . ' / ' . str_replace('\'', '\\\'', $GLOBALS['table']);
}
$title .= ' | phpMyAdmin ' . PMA_VERSION;
?>
<script type="text/javascript" language="javascript">
<!--
// Updates the title of the frameset if possible (ns4 does not allow this)
if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
&& typeof(parent.document.title) == 'string') {
parent.document.title = '<?php echo PMA_sanitize($title); ?>';
}
<?php
// Add some javascript instructions if required
if (isset($js_to_run) && $js_to_run == 'functions.js') {
echo "\n";
?>
// js form validation stuff
var errorMsg0 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
var errorMsg1 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
var noDropDbMsg = '<?php echo((!$GLOBALS['cfg']['AllowUserDropDatabase']) ? str_replace('\'', '\\\'', $GLOBALS['strNoDropDatabases']) : ''); ?>';
var confirmMsg = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDoYouReally']) : ''); ?>';
var confirmMsgDropDB = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDropDatabaseStrongWarning']) : ''); ?>';
//-->
</script>
<script src="./js/functions.js" type="text/javascript" language="javascript"></script>
<?php
} elseif (isset($js_to_run) && $js_to_run == 'user_password.js') {
echo "\n";
?>
// js form validation stuff
var jsHostEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
var jsUserEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
var jsPasswordEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
//-->
</script>
<script src="./js/user_password.js" type="text/javascript" language="javascript"></script>
<?php
} elseif (isset($js_to_run) && $js_to_run == 'server_privileges.js') {
echo "\n";
?>
// js form validation stuff
var jsHostEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
var jsUserEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
var jsPasswordEmpty = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
//-->
</script>
<script src="./js/server_privileges.js" type="text/javascript" language="javascript"></script>
<script src="./js/functions.js" type="text/javascript" language="javascript"></script>
<?php
} elseif (isset($js_to_run) && $js_to_run == 'indexes.js') {
echo "\n";
?>
// js index validation stuff
var errorMsg0 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
var errorMsg1 = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
//-->
</script>
<script src="./js/indexes.js" type="text/javascript" language="javascript"></script>
<?php
} elseif (isset($js_to_run) && $js_to_run == 'tbl_change.js') {
echo "\n";
?>
//-->
</script>
<script src="./js/tbl_change.js" type="text/javascript" language="javascript"></script>
<?php
} else {
echo "\n";
?>
//-->
</script>
<?php
}
echo "\n";
 
// Reloads the navigation frame via JavaScript if required
PMA_reloadNavigation();
?>
<script src="./js/tooltip.js" type="text/javascript"
language="javascript"></script>
<meta name="OBGZip" content="<?php echo ($cfg['OBGzip'] ? 'true' : 'false'); ?>" />
</head>
 
<body>
<div id="TooltipContainer" onmouseover="holdTooltip();" onmouseout="swapTooltip('default');"></div>
<?php
 
// Include possible custom headers
require_once('./libraries/header_custom.inc.php');
 
if (!defined('PMA_DISPLAY_HEADING')) {
define('PMA_DISPLAY_HEADING', 1);
}
 
/**
* Display heading if needed. Design can be set in css file.
*/
 
if (PMA_DISPLAY_HEADING) {
$server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
? $GLOBALS['cfg']['Server']['verbose']
: $GLOBALS['cfg']['Server']['host'] . (empty($GLOBALS['cfg']['Server']['port'])
? ''
: ':' . $GLOBALS['cfg']['Server']['port']
)
);
$item = '<a href="%1$s?%2$s" class="item">';
if ( $GLOBALS['cfg']['NavigationBarIconic'] ) {
$separator = ' <span class="separator"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'item_ltr.png" width="5" height="9" alt="-" /></span>' . "\n";
$item .= ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . '%5$s" width="16" height="16" alt="" /> ' . "\n";
} else {
$separator = ' <span class="separator"> - </span>' . "\n";
}
 
if ( $GLOBALS['cfg']['NavigationBarIconic'] !== true ) {
$item .= '%4$s: ';
}
$item .= '%3$s</a>' . "\n";
 
echo '<div id="serverinfo">' . "\n";
printf( $item,
$GLOBALS['cfg']['DefaultTabServer'],
PMA_generate_common_url(),
htmlspecialchars($server_info),
$GLOBALS['strServer'],
's_host.png' );
 
if (isset($GLOBALS['db']) && strlen($GLOBALS['db'])) {
 
echo $separator;
printf( $item,
$GLOBALS['cfg']['DefaultTabDatabase'],
PMA_generate_common_url($GLOBALS['db']),
htmlspecialchars($GLOBALS['db']),
$GLOBALS['strDatabase'],
's_db.png' );
 
if (isset($GLOBALS['table']) && strlen($GLOBALS['table'])) {
require_once('./libraries/tbl_properties_table_info.inc.php');
 
echo $separator;
printf( $item,
$GLOBALS['cfg']['DefaultTabTable'],
PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']),
htmlspecialchars($GLOBALS['table']),
(isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? $GLOBALS['strView'] : $GLOBALS['strTable']),
(isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? 'b_views' : 's_tbl') . '.png' );
 
/**
* Displays table comment
* @uses $show_comment from libraries/tbl_properties_table_info.inc.php
* @uses $GLOBALS['avoid_show_comment'] from tbl_relation.php
*/
if (!empty($show_comment) && !isset($GLOBALS['avoid_show_comment'])) {
if (strstr($show_comment, '; InnoDB free')) {
$show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
}
echo '<span class="table_comment" id="span_table_comment">'
.'&quot;' . htmlspecialchars($show_comment)
.'&quot;</span>' . "\n";
} // end if
} else {
// no table selected, display database comment if present
/**
* Settings for relations stuff
*/
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
 
// Get additional information about tables for tooltip is done
// in libraries/db_details_db_info.inc.php only once
if ($cfgRelation['commwork']) {
$comment = PMA_getComments( $GLOBALS['db'] );
 
/**
* Displays table comment
*/
if ( is_array( $comment ) ) {
echo '<span class="table_comment"'
.' id="span_table_comment">&quot;'
.htmlspecialchars(implode(' ', $comment))
.'&quot;</span>' . "\n";
} // end if
}
}
}
echo '</div>';
 
}
/**
* Sets a variable to remember headers have been sent
*/
$GLOBALS['is_header_sent'] = TRUE;
}
?>
/Web/Maintenance/phpMyAdmin/libraries/header_custom.inc.php
0,0 → 1,11
<?php
/* $Id: header_custom.inc.php,v 2.2 2005/11/25 08:58:11 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// This file includes all custom headers if they exist.
 
// Include site header
if (file_exists('./config.header.inc.php')) {
require('./config.header.inc.php');
}
?>
/Web/Maintenance/phpMyAdmin/libraries/header_http.inc.php
0,0 → 1,21
<?php
/* $Id: header_http.inc.php,v 2.4 2005/11/24 08:15:00 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) {
die("GLOBALS overwrite attempt");
}
 
/**
* Sends http headers
*/
$GLOBALS['now'] = gmdate('D, d M Y H:i:s') . ' GMT';
header('Expires: ' . $GLOBALS['now']); // rfc2616 - Section 14.21
header('Last-Modified: ' . $GLOBALS['now']);
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0
if (!defined('IS_TRANSFORMATION_WRAPPER')) {
// Define the charset to be used
header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
}
?>
/Web/Maintenance/phpMyAdmin/libraries/header_meta_style.inc.php
0,0 → 1,39
<?php
/* $Id: header_meta_style.inc.php,v 2.16 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) {
die("GLOBALS overwrite attempt");
}
 
/**
* Sends the beginning of the html page then returns to the calling script
*/
// Defines the cell alignment values depending on text direction
if ($GLOBALS['text_dir'] == 'ltr') {
$GLOBALS['cell_align_left'] = 'left';
$GLOBALS['cell_align_right'] = 'right';
} else {
$GLOBALS['cell_align_left'] = 'right';
$GLOBALS['cell_align_right'] = 'left';
}
// removes the bug with the horizontal scrollbar in IE (it's allways shown, if need it or not)
echo "<?xml version=\"1.0\" encoding=\"" . $GLOBALS['charset'] . "\"?".">";
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][2]; ?>" lang="<?php echo $GLOBALS['available_languages'][$GLOBALS['lang']][2]; ?>" dir="<?php echo $GLOBALS['text_dir']; ?>">
<head>
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<title><?php
if (!empty($page_title)) {
echo htmlspecialchars($page_title);
} else {
echo 'phpMyAdmin';
}
?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $GLOBALS['charset']; ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : './'; ?>css/phpmyadmin.css.php?<?php echo PMA_generate_common_url(); ?>&amp;js_frame=<?php echo isset($print_view) ? 'print' : 'right'; ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : './'; ?>css/print.css?<?php echo PMA_generate_common_url(); ?>" media="print" />
/Web/Maintenance/phpMyAdmin/libraries/header_printview.inc.php
0,0 → 1,73
<?php
/* $Id: header_printview.inc.php,v 2.1 2005/11/24 09:12:17 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Gets a core script and starts output buffering work
*/
require_once('./libraries/common.lib.php');
require_once('./libraries/ob.lib.php');
if ($cfg['OBGzip']) {
$ob_mode = PMA_outBufferModeGet();
if ($ob_mode) {
PMA_outBufferPre($ob_mode);
}
}
 
// Check parameters
 
PMA_checkParameters(array('db', 'full_sql_query'));
 
 
// garvin: For re-usability, moved http-headers
// to a seperate file. It can now be included by libraries/header.inc.php,
// querywindow.php.
 
require_once('./libraries/header_http.inc.php');
 
/**
* Sends the beginning of the html page then returns to the calling script
*/
// Defines the cell alignment values depending on text direction
if ($text_dir == 'ltr') {
$cell_align_left = 'left';
$cell_align_right = 'right';
} else {
$cell_align_left = 'right';
$cell_align_right = 'left';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $available_languages[$lang][2]; ?>" lang="<?php echo $available_languages[$lang][2]; ?>" dir="<?php echo $text_dir; ?>">
 
<head>
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<title><?php echo $strSQLResult; ?> - phpMyAdmin <?php echo PMA_VERSION ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url( '', '' ); ?>&amp;js_frame=print" />
</style>
</head>
 
<body bgcolor="#ffffff">
<h1><?php echo $strSQLResult; ?></h1>
<p>
<b><?php echo $strHost; ?>:</b> <?php echo $cfg['Server']['verbose'] ? $cfg['Server']['verbose'] : $cfg['Server']['host'] . ((!empty($cfg['Server']['port'])) ? ':' . $cfg['Server']['port'] : ''); ?><br />
<b><?php echo $strDatabase; ?>:</b> <?php echo htmlspecialchars($db); ?><br />
<b><?php echo $strGenTime; ?>:</b> <?php echo PMA_localisedDate(); ?><br />
<b><?php echo $strGenBy; ?>:</b> phpMyAdmin&nbsp;<?php echo PMA_VERSION; ?>&nbsp;/ MySQL&nbsp;<?php echo PMA_MYSQL_STR_VERSION; ?><br />
<b><?php echo $strSQLQuery; ?>:</b> <?php echo htmlspecialchars($full_sql_query); ?>;
<?php if (isset($num_rows)) { ?><br />
<b><?php echo $strRows; ?>:</b> <?php echo $num_rows; ?>
<?php } ?>
</p>
 
 
<?php
 
/**
* Sets a variable to remember headers have been sent
*/
$is_header_sent = TRUE;
?>
/Web/Maintenance/phpMyAdmin/libraries/import/README
0,0 → 1,42
This directory holds import plugins for phpMyAdmin. Plugin should
basically look like following code. Official plugins need to have str*
messages with their definition in language files, if you build some
plugins for your use, you can use directly texts in plugin.
 
<?php
/* $Id: README,v 1.2 2005/09/24 11:41:58 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4 ft=php:
 
/* Demo import plugin for phpMyAdmin */
 
if (isset($import_list)) {
$import_list['name'] = array( // set name of your plugin
'text' => 'strName', // text to be displayed as choice
'extension' => '', // extension this plugin can handle
'options' => array( // array of options for your plugin (optional)
array('type' => '', 'name' => '', 'text' => ''), // type: bool or text, name: form element name, text: description in GUI, size: size of text element (optional). len: maximal size of input (optional)
);
'options_text' => 'strNameImportOptions', // text to describe plugin options (must be set if options are used)
);
} else {
/* We do not define function when plugin is just queried for information above */
$buffer = '';
while (!($finished && $i >= $len) && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
if ($data === FALSE) {
// subtract data we didn't handle yet and stop processing
$offset -= strlen($buffer);
break;
} elseif ($data === TRUE) {
// Handle rest of buffer
} else {
// Append new data to buffer
$buffer .= $data;
}
// PARSE $buffer here, post sql queries using:
PMA_importRunQuery($sql, $verbose_sql_with_comments);
} // End of import loop
// Commit any possible data in buffers
PMA_importRunQuery();
}
?>
/Web/Maintenance/phpMyAdmin/libraries/import/csv.php
0,0 → 1,280
<?php
/* $Id: csv.php,v 1.8.2.2 2006/04/21 07:54:53 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/* CSV import plugin for phpMyAdmin */
 
if ($plugin_param == 'table') {
if (isset($plugin_list)) {
$plugin_list['csv'] = array(
'text' => 'strCSV',
'extension' => 'csv',
'options' => array(
array('type' => 'bool', 'name' => 'replace', 'text' => 'strReplaceTable'),
array('type' => 'bool', 'name' => 'ignore', 'text' => 'strIgnoreDuplicates'),
array('type' => 'text', 'name' => 'terminated', 'text' => 'strFieldsTerminatedBy', 'size' => 2, 'len' => 2),
array('type' => 'text', 'name' => 'enclosed', 'text' => 'strFieldsEnclosedBy', 'size' => 2, 'len' => 2),
array('type' => 'text', 'name' => 'escaped', 'text' => 'strFieldsEscapedBy', 'size' => 2, 'len' => 2),
array('type' => 'text', 'name' => 'new_line', 'text' => 'strLinesTerminatedBy', 'size' => 2),
array('type' => 'text', 'name' => 'columns', 'text' => 'strColumnNames'),
),
'options_text' => 'strCSVImportOptions',
);
} else {
/* We do not define function when plugin is just queried for information above */
$replacements = array(
'\\n' => "\n",
'\\t' => "\t",
'\\r' => "\r",
);
$csv_terminated = strtr($csv_terminated, $replacements);
$csv_enclosed = strtr($csv_enclosed, $replacements);
$csv_escaped = strtr($csv_escaped, $replacements);
$csv_new_line = strtr($csv_new_line, $replacements);
 
if (strlen($csv_terminated) != 1) {
$message = sprintf($strInvalidCSVParameter, $strFieldsTerminatedBy);
$show_error_header = TRUE;
$error = TRUE;
} elseif (strlen($csv_enclosed) != 1) {
$message = sprintf($strInvalidCSVParameter, $strFieldsEnclosedBy);
$show_error_header = TRUE;
$error = TRUE;
} elseif (strlen($csv_escaped) != 1) {
$message = sprintf($strInvalidCSVParameter, $strFieldsEscapedBy);
$show_error_header = TRUE;
$error = TRUE;
} elseif (strlen($csv_new_line) != 1 && $csv_new_line != 'auto') {
$message = sprintf($strInvalidCSVParameter, $strLinesTerminatedBy);
$show_error_header = TRUE;
$error = TRUE;
}
 
$buffer = '';
if (isset($csv_replace)) {
$sql_template = 'REPLACE';
} else {
$sql_template = 'INSERT';
if (isset($csv_ignore)) {
$sql_template .= ' IGNORE';
}
}
$sql_template .= ' INTO ' . PMA_backquote($table);
$tmp_fields = PMA_DBI_get_fields($db, $table);
if (empty($csv_columns)) {
$fields = $tmp_fields;
} else {
$sql_template .= ' (';
$fields = array();
$tmp = split(',( ?)', $csv_columns);
foreach ($tmp as $key => $val) {
if (count($fields) > 0) {
$sql_template .= ', ';
}
$val = trim($val);
$found = FALSE;
foreach ($tmp_fields as $id => $field) {
if ($field['Field'] == $val) {
$found = TRUE;
break;
}
}
if (!$found) {
$message = sprintf($strInvalidColumn, $val);
$show_error_header = TRUE;
$error = TRUE;
break;
}
$fields[] = $field;
$sql_template .= PMA_backquote($val);
}
$sql_template .= ') ';
}
 
$required_fields = count($fields);
 
$sql_template .= ' VALUES (';
 
// Defaults for parser
$i = 0;
$len = 0;
$line = 1;
$lasti = -1;
$values = array();
$csv_finish = FALSE;
 
while (!($finished && $i >= $len) && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
if ($data === FALSE) {
// subtract data we didn't handle yet and stop processing
$offset -= strlen($buffer);
break;
} elseif ($data === TRUE) {
// Handle rest of buffer
} else {
// Append new data to buffer
$buffer .= $data;
// Do not parse string when we're not at the end and don't have new line inside
if (($csv_new_line == 'auto' && strpos($buffer, "\r") === FALSE && strpos($buffer, "\n") === FALSE)
|| ($csv_new_line != 'auto' && strpos($buffer, $csv_new_line) === FALSE)) {
continue;
}
}
 
// Current length of our buffer
$len = strlen($buffer);
// Currently parsed char
$ch = $buffer[$i];
while ($i < $len) {
// Deadlock protection
if ($lasti == $i && $lastlen == $len) {
$message = sprintf($strInvalidCSVFormat, $line);
$show_error_header = TRUE;
$error = TRUE;
break;
}
$lasti = $i;
$lastlen = $len;
 
// This can happen with auto EOL and \r at the end of buffer
if (!$csv_finish) {
// Grab empty field
if ($ch == $csv_terminated) {
$values[] = '';
if ($i == $len - 1) {
break;
}
$i++;
$ch = $buffer[$i];
continue;
}
 
// Grab one field
$fallbacki = $i;
if ($ch == $csv_enclosed) {
$need_end = TRUE;
if ($i == $len - 1) {
break;
}
$i++;
$ch = $buffer[$i];
} else {
$need_end = FALSE;
}
$fail = FALSE;
$value = '';
while (($need_end && $ch != $csv_enclosed) || (!$need_end && !($ch == $csv_terminated || $ch == $csv_new_line || ($csv_new_line == 'auto' && ($ch == "\r" || $ch == "\n"))))) {
if ($ch == $csv_escaped) {
if ($i == $len - 1) {
$fail = TRUE;
break;
}
$i++;
$ch = $buffer[$i];
}
$value .= $ch;
if ($i == $len - 1) {
if (!$finished) {
$fail = TRUE;
}
break;
}
$i++;
$ch = $buffer[$i];
}
if ($fail) {
$i = $fallbacki;
$ch = $buffer[$i];
break;
}
// Need to strip trailing enclosing char?
if ($need_end && $ch == $csv_enclosed) {
if ($finished && $i == $len - 1) {
$ch = NULL;
} elseif ($i == $len - 1) {
$i = $fallbacki;
$ch = $buffer[$i];
break;
} else {
$i++;
$ch = $buffer[$i];
}
}
// Are we at the end?
if ($ch == $csv_new_line || ($csv_new_line == 'auto' && ($ch == "\r" || $ch == "\n")) || ($finished && $i == $len - 1)) {
$csv_finish = TRUE;
}
// Go to next char
if ($ch == $csv_terminated) {
if ($i == $len - 1) {
$i = $fallbacki;
$ch = $buffer[$i];
break;
}
$i++;
$ch = $buffer[$i];
}
// If everything went okay, store value
$values[] = $value;
}
 
// End of line
if ($csv_finish || $ch == $csv_new_line || ($csv_new_line == 'auto' && ($ch == "\r" || $ch == "\n"))) {
if ($csv_new_line == 'auto' && $ch == "\r") { // Handle "\r\n"
if ($i >= ($len - 2) && !$finished) {
break; // We need more data to decide new line
}
if ($buffer[$i + 1] == "\n") {
$i++;
}
}
// We didn't parse value till the end of line, so there was empty one
if (!$csv_finish) {
$values[] = '';
}
// Do we have correct count of values?
if (count($values) != $required_fields) {
$message = sprintf($strInvalidCSVFieldCount, $line);
$show_error_header = TRUE;
$error = TRUE;
break;
}
$first = TRUE;
$sql = $sql_template;
foreach ($values as $key => $val) {
if (!$first) {
$sql .= ', ';
}
$sql .= '\'' . addslashes($val) . '\'';
$first = FALSE;
}
$sql .= ')';
 
// FIXME: maybe we could add original line to verbose SQL in comment
PMA_importRunQuery($sql, $sql);
$line++;
$csv_finish = FALSE;
$values = array();
$buffer = substr($buffer, $i + 1);
$len = strlen($buffer);
$i = 0;
$lasti = -1;
$ch = $buffer[0];
}
} // End of parser loop
} // End of import loop
 
// Commit any possible data in buffers
PMA_importRunQuery();
if (count($values) != 0 && !$error) {
$message = sprintf($strInvalidCSVFormat, $line);
$show_error_header = TRUE;
$error = TRUE;
}
}
}
?>
/Web/Maintenance/phpMyAdmin/libraries/import/ldi.php
0,0 → 1,102
<?php
/* $Id: ldi.php,v 1.7 2005/12/08 22:52:03 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/* CSV import plugin for phpMyAdmin */
 
if ($plugin_param == 'table') {
if (isset($plugin_list)) {
if ($GLOBALS['cfg']['Import']['ldi_local_option'] == 'auto') {
$GLOBALS['cfg']['Import']['ldi_local_option'] = FALSE;
 
if (PMA_MYSQL_INT_VERSION < 32349) {
$GLOBALS['cfg']['Import']['ldi_local_option'] = TRUE;
}
 
if (PMA_MYSQL_INT_VERSION > 40003) {
$result = PMA_DBI_try_query('SHOW VARIABLES LIKE \'local\\_infile\';');
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
$tmp = PMA_DBI_fetch_row($result);
if ($tmp[1] == 'ON') {
$GLOBALS['cfg']['Import']['ldi_local_option'] = TRUE;
}
}
PMA_DBI_free_result($result);
unset($result);
}
}
$plugin_list['ldi'] = array(
'text' => 'strLDI',
'extension' => 'ldi', // This is nonsense, however we want to default to our parser for csv
'options' => array(
array('type' => 'bool', 'name' => 'replace', 'text' => 'strReplaceTable'),
array('type' => 'bool', 'name' => 'ignore', 'text' => 'strIgnoreDuplicates'),
array('type' => 'text', 'name' => 'terminated', 'text' => 'strFieldsTerminatedBy', 'size' => 2, 'len' => 2),
array('type' => 'text', 'name' => 'enclosed', 'text' => 'strFieldsEnclosedBy', 'size' => 2, 'len' => 2),
array('type' => 'text', 'name' => 'escaped', 'text' => 'strFieldsEscapedBy', 'size' => 2, 'len' => 2),
array('type' => 'text', 'name' => 'new_line', 'text' => 'strLinesTerminatedBy', 'size' => 2),
array('type' => 'text', 'name' => 'columns', 'text' => 'strColumnNames'),
array('type' => 'bool', 'name' => 'local_option', 'text' => 'strLDILocal'),
),
'options_text' => 'strLDIImportOptions',
);
} else {
/* We do not define function when plugin is just queried for information above */
if ($import_file == 'none' || $compression != 'none' || $charset_conversion) {
// We handle only some kind of data!
$message = $strInvalidLDIImport;
$show_error_header = TRUE;
$error = TRUE;
} else {
$sql = 'LOAD DATA';
if (isset($ldi_local_option)) {
$sql .= ' LOCAL';
}
$sql .= ' INFILE \'' . PMA_sqlAddslashes($import_file) . '\'';
if (isset($ldi_replace)) {
$sql .= ' REPLACE';
} elseif (isset($ldi_ignore)) {
$sql .= ' IGNORE';
}
$sql .= ' INTO TABLE ' . PMA_backquote($table);
 
if (strlen($ldi_terminated) > 0) {
$sql .= ' FIELDS TERMINATED BY \'' . $ldi_terminated . '\'';
}
if (strlen($ldi_enclosed) > 0) {
$sql .= ' ENCLOSED BY \'' . PMA_sqlAddslashes($ldi_enclosed) . '\'';
}
if (strlen($ldi_escaped) > 0) {
$sql .= ' ESCAPED BY \'' . PMA_sqlAddslashes($ldi_escaped) . '\'';
}
if (strlen($ldi_new_line) > 0){
if ($ldi_new_line == 'auto') {
$ldi_new_line = PMA_whichCrlf() == "\n" ? '\n' : '\r\n';
}
$sql .= ' LINES TERMINATED BY \'' . $ldi_new_line . '\'';
}
if ($skip_queries > 0) {
$sql .= ' IGNORE ' . $skip_queries . ' LINES';
$skip_queries = 0;
}
if (strlen($ldi_columns) > 0) {
$sql .= ' (';
$tmp = split(',( ?)', $ldi_columns);
$cnt_tmp = count($tmp);
for ($i = 0; $i < $cnt_tmp; $i++) {
if ($i > 0) {
$sql .= ', ';
}
$sql .= PMA_backquote(trim($tmp[$i]));
} // end for
$sql .= ')';
}
PMA_importRunQuery($sql, $sql);
PMA_importRunQuery();
$finished = TRUE;
}
}
}
?>
/Web/Maintenance/phpMyAdmin/libraries/import/sql.php
0,0 → 1,200
<?php
/* $Id: sql.php,v 1.10.2.1 2006/03/23 16:58:09 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/* SQL import plugin for phpMyAdmin */
 
if (isset($plugin_list)) {
$plugin_list['sql'] = array(
'text' => 'strSQL',
'extension' => 'sql',
'options_text' => 'strSQLImportOptions',
);
} else {
/* We do not define function when plugin is just queried for information above */
$buffer = '';
// Defaults for parser
$sql = '';
$start_pos = 0;
$i = 0;
while (!($finished && $i >= $len) && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
if ($data === FALSE) {
// subtract data we didn't handle yet and stop processing
$offset -= strlen($buffer);
break;
} elseif ($data === TRUE) {
// Handle rest of buffer
} else {
// Append new data to buffer
$buffer .= $data;
// Do not parse string when we're not at the end and don't have ; inside
if ((strpos($buffer, ';') === FALSE) && !$finished) {
continue;
}
}
// Current length of our buffer
$len = strlen($buffer);
// Grab some SQL queries out of it
while ($i < $len) {
// Find first interesting character, several strpos seem to be faster than simple loop in php:
//while (($i < $len) && (strpos('\'";#-/', $buffer[$i]) === FALSE)) $i++;
//if ($i == $len) break;
$oi = $i;
$p1 = strpos($buffer, '\'', $i);
if ($p1 === FALSE) {
$p1 = 2147483647;
}
$p2 = strpos($buffer, '"', $i);
if ($p2 === FALSE) {
$p2 = 2147483647;
}
$p3 = strpos($buffer, ';', $i);
if ($p3 === FALSE) {
$p3 = 2147483647;
}
$p4 = strpos($buffer, '#', $i);
if ($p4 === FALSE) {
$p4 = 2147483647;
}
$p5 = strpos($buffer, '--', $i);
if ($p5 === FALSE || $p5 >= ($len - 2) || $buffer[$p5 + 2] > ' ') {
$p5 = 2147483647;
}
$p6 = strpos($buffer, '/*', $i);
if ($p6 === FALSE) {
$p6 = 2147483647;
}
$p7 = strpos($buffer, '`', $i);
if ($p7 === FALSE) {
$p7 = 2147483647;
}
$i = min ($p1, $p2, $p3, $p4, $p5, $p6, $p7);
if ($i == 2147483647) {
$i = $oi;
if (!$finished) {
break;
}
// at the end there might be some whitespace...
if (trim($buffer) == '') {
$buffer = '';
$len = 0;
break;
}
// We hit end of query, go there!
$i = strlen($buffer) - 1;
}
 
// Grab current character
$ch = $buffer[$i];
 
// Quotes
if (!(strpos('\'"`', $ch) === FALSE)) {
$quote = $ch;
$endq = FALSE;
while (!$endq) {
// Find next quote
$pos = strpos($buffer, $quote, $i + 1);
// No quote? Too short string
if ($pos === FALSE) {
// We hit end of string => unclosed quote, but we handle it as end of query
if ($finished) {
$endq = TRUE;
$i = $len - 1;
}
break;
}
// Was not the quote escaped?
$j = $pos - 1;
while ($buffer[$j] == '\\') $j--;
// Even count means it was not escaped
$endq = (((($pos - 1) - $j) % 2) == 0);
// Skip the string
$i = $pos;
}
if (!$endq) {
break;
}
$i++;
// Aren't we at the end?
if ($finished && $i == $len) {
$i--;
} else {
continue;
}
}
 
// Not enough data to decide
if ((($i == ($len - 1) && ($ch == '-' || $ch == '/'))
|| ($i == ($len - 2) && (($ch == '-' && $buffer[$i + 1] == '-') || ($ch == '/' && $buffer[$i + 1] == '*')))
) && !$finished) {
break;
}
// Comments
if ($ch == '#'
|| ($i < ($len - 1) && $ch == '-' && $buffer[$i + 1] == '-' && (($i < ($len - 2) && $buffer[$i + 2] <= ' ') || ($i == ($len - 1) && $finished)))
|| ($i < ($len - 1) && $ch == '/' && $buffer[$i + 1] == '*')
) {
// Copy current string to SQL
if ($start_pos != $i) {
$sql .= substr($buffer, $start_pos, $i - $start_pos);
}
// Skip the rest
$i = strpos($buffer, $ch == '/' ? '*/' : "\n", $i);
// didn't we hit end of string?
if ($i === FALSE) {
if ($finished) {
$i = $len - 1;
} else {
break;
}
}
// Skip *
if ($ch == '/') {
$i++;
}
// Skip last char
$i++;
// Next query part will start here
$start_pos = $i;
// Aren't we at the end?
if ($i == $len) {
$i--;
} else {
continue;
}
}
 
// End of SQL
if ($ch == ';' || ($finished && ($i == $len - 1))) {
$tmp_sql = $sql;
if ($start_pos < $len) {
$tmp_sql .= substr($buffer, $start_pos, $i - $start_pos + 1);
}
// Do not try to execute empty SQL
if (!preg_match('/^([\s]*;)*$/', trim($tmp_sql))) {
$sql = $tmp_sql;
PMA_importRunQuery($sql, substr($buffer, 0, $i + 1));
$buffer = substr($buffer, $i + 1);
// Reset parser:
$len = strlen($buffer);
$sql = '';
$i = 0;
$start_pos = 0;
// Any chance we will get a complete query?
if ((strpos($buffer, ';') === FALSE) && !$finished) {
break;
}
} else {
$i++;
$start_pos = $i;
}
}
} // End of parser loop
} // End of import loop
// Commit any possible data in buffers
PMA_importRunQuery('', substr($buffer, 0, $len));
PMA_importRunQuery();
}
?>
/Web/Maintenance/phpMyAdmin/libraries/import.lib.php
0,0 → 1,260
<?php
/* $Id: import.lib.php,v 1.9 2006/01/19 15:39:29 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/* Library that provides common import functions that are used by import plugins */
 
// We need to know something about user
require_once('./libraries/check_user_privileges.lib.php');
// We do this check
define('PMA_CHK_DROP', 1);
 
/**
* Check whether timeout is getting close
*
* @return boolean true if timeout is close
* @access public
*/
function PMA_checkTimeout()
{
global $timestamp, $maximum_time, $timeout_passed;
if ($maximum_time == 0) {
return FALSE;
} elseif ($timeout_passed) {
return TRUE;
/* 5 in next row might be too much */
} elseif ((time() - $timestamp) > ($maximum_time - 5)) {
$timeout_passed = TRUE;
return TRUE;
} else {
return FALSE;
}
}
 
/**
* Detects what compression filse uses
*
* @param string filename to check
* @return string MIME type of compression, none for none
* @access public
*/
function PMA_detectCompression($filepath)
{
$file = @fopen($filepath, 'rb');
if (!$file) {
return FALSE;
}
$test = fread($file, 4);
fclose($file);
if ($test[0] == chr(31) && $test[1] == chr(139)) {
return 'application/gzip';
}
if (substr($test, 0, 3) == 'BZh') {
return 'application/bzip2';
}
if ($test == "PK\003\004") {
return 'application/zip';
}
return 'none';
}
 
/**
* Runs query inside import buffer. This is needed to allow displaying
* of last SELECT or SHOW results and simmilar nice stuff.
*
* @param string query to run
* @param string query to display, this might be commented
* @access public
*/
function PMA_importRunQuery($sql = '', $full = '')
{
global $import_run_buffer, $go_sql, $complete_query, $display_query, $sql_query, $cfg, $my_die, $error, $reload, $finished, $timeout_passed, $skip_queries, $executed_queries, $max_sql_len, $read_multiply, $cfg, $sql_query_disabled, $db, $run_query, $is_superuser;
$read_multiply = 1;
if (isset($import_run_buffer)) {
// Should we skip something?
if ($skip_queries > 0) {
$skip_queries--;
} else {
if (!empty($import_run_buffer['sql']) && trim($import_run_buffer['sql']) != '') {
if (!$cfg['AllowUserDropDatabase']
&& !$is_superuser
&& preg_match('@DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE @i', $import_run_buffer['sql'])) {
$message = $GLOBALS['strNoDropDatabases'];
$show_error_header = TRUE;
$error = TRUE;
return;
}
$max_sql_len = max($max_sql_len, strlen($import_run_buffer['sql']));
if (!$sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
}
$executed_queries++;
if ($run_query && $finished && empty($sql) && !$error && (
(!empty($import_run_buffer['sql']) && preg_match('/^[\s]*(SELECT|SHOW)/i', $import_run_buffer['sql'])) ||
($executed_queries == 1)
)) {
$go_sql = TRUE;
if (!$sql_query_disabled) {
$complete_query = $sql_query;
$display_query = $sql_query;
} else {
$complete_query = '';
$display_query = '';
}
$sql_query = $import_run_buffer['sql'];
} elseif ($run_query) {
$result = PMA_DBI_try_query($import_run_buffer['sql']);
$msg = '# ';
if ($result === FALSE) { // execution failed
if (!isset($my_die)) {
$my_die = array();
}
$my_die[] = array('sql' => $import_run_buffer['full'], 'error' => PMA_DBI_getError());
 
if ($cfg['VerboseMultiSubmit']) {
$msg .= $GLOBALS['strError'];
}
 
if (!$cfg['IgnoreMultiSubmitErrors']) {
$error = TRUE;
return;
}
} elseif ($cfg['VerboseMultiSubmit']) {
$a_num_rows = (int)@PMA_DBI_num_rows($result);
$a_aff_rows = (int)@PMA_DBI_affected_rows();
if ($a_num_rows > 0) {
$msg .= $GLOBALS['strRows'] . ': ' . $a_num_rows;
} elseif ($a_aff_rows > 0) {
$a_rows =
$msg .= $GLOBALS['strAffectedRows'] . ' ' . $a_aff_rows;
} else {
$msg .= $GLOBALS['strEmptyResultSet'];
}
}
if (!$sql_query_disabled) {
$sql_query .= $msg . "\n";
}
 
// If a 'USE <db>' SQL-clause was found and the query succeeded, set our current $db to the new one
if ($result != FALSE && preg_match('@^[\s]*USE[[:space:]]*([\S]+)@i', $import_run_buffer['sql'], $match)) {
$db = trim($match[1]);
$reload = TRUE;
}
 
if ($result != FALSE && preg_match('@^[\s]*(DROP|CREATE)[\s]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)@im', $import_run_buffer['sql'])) {
$reload = TRUE;
}
} // end run query
} // end non empty query
elseif (!empty($import_run_buffer['full'])) {
if ($go_sql) {
$complete_query .= $import_run_buffer['full'];
$display_query .= $import_run_buffer['full'];
} else {
if (!$sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
}
}
}
// check length of query unless we decided to pass it to sql.php
if (!$go_sql) {
if ($cfg['VerboseMultiSubmit'] && !empty($sql_query)) {
if (strlen($sql_query) > 50000 || $executed_queries > 50 || $max_sql_len > 1000) {
$sql_query = '';
$sql_query_disabled = TRUE;
}
} else {
if (strlen($sql_query) > 10000 || $executed_queries > 10 || $max_sql_len > 500) {
$sql_query = '';
$sql_query_disabled = TRUE;
}
}
}
} // end do query (no skip)
} // end buffer exists
// Do we have something to push into buffer?
if (!empty($sql) || !empty($full)) {
$import_run_buffer = array('sql' => $sql, 'full' => $full);
} else {
unset($GLOBALS['import_run_buffer']);
}
}
 
 
/**
* Returns next part of imported file/buffer
*
* @param integer size of buffer to read (this is maximal size
* function will return)
* @return string part of file/buffer
* @access public
*/
function PMA_importGetNextChunk($size = 32768)
{
global $import_file, $import_text, $finished, $compression, $import_handle, $offset, $charset_conversion, $charset_of_file, $charset, $read_multiply, $read_limit;
// Add some progression while reading large amount of data
if ($read_multiply <= 8) {
$size *= $read_multiply;
} else {
$size *= 8;
}
$read_multiply++;
 
// We can not read too much
if ($size > $read_limit) {
$size = $read_limit;
}
 
if (PMA_checkTimeout()) {
return FALSE;
}
if ($finished) {
return TRUE;
}
 
if ($import_file == 'none') {
// Well this is not yet supported and tested, but should return content of textarea
if (strlen($import_text) < $size) {
$finished = TRUE;
return $import_text;
} else {
$r = substr($import_text, 0, $size);
$offset += $size;
$import_text = substr($import_text, $size);
return $r;
}
}
switch ($compression) {
case 'application/bzip2':
$result = bzread($import_handle, $size);
$finished = feof($import_handle);
break;
case 'application/gzip':
$result = gzread($import_handle, $size);
$finished = feof($import_handle);
break;
case 'application/zip':
$result = substr($import_text, 0, $size);
$import_text = substr($import_text, $size);
$finished = empty($import_text);
break;
case 'none':
$result = fread($import_handle, $size);
$finished = feof($import_handle);
break;
}
$offset += $size;
if ($charset_conversion) {
return PMA_convert_string($charset_of_file, $charset, $result);
} else {
return $result;
}
}
 
 
 
?>
/Web/Maintenance/phpMyAdmin/libraries/information_schema_relations.lib.php
0,0 → 1,129
<?php
/* $Id: information_schema_relations.lib.php,v 2.0 2005/03/27 23:23:39 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
$GLOBALS['information_schema_relations'] = array(
'CHARACTER_SETS' => array(
'DEFAULT_COLLATE_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
)
),
'COLLATIONS' => array(
'CHARACTER_SET_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
)
),
'COLLATION_CHARACTER_SET_APPLICABILITY' => array(
'CHARACTER_SET_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
),
'COLLATION_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
)
),
'COLUMNS' => array(
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'CHARACTER_SET_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
),
'COLLATION_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
)
),
'COLUMN_PRIVILEGES' => array(
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
),
'KEY_COLUMN_USAGE' => array(
'CONSTRAINT_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
),
'ROUTINES' => array(
'ROUTINE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
),
'SCHEMATA' => array(
'DEFAULT_CHARACTER_SET_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
)
),
'SCHEMA_PRIVILEGES' => array(
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
),
'TABLES' => array(
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'TABLE_COLLATION' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
)
),
'TABLE_CONSTRAINTS' => array(
'CONSTRAINT_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
),
'TABLE_PRIVILEGES' => array(
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
),
'VIEWS' => array(
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
)
);
 
?>
/Web/Maintenance/phpMyAdmin/libraries/ip_allow_deny.lib.php
0,0 → 1,237
<?php
/* $Id: ip_allow_deny.lib.php,v 2.7.2.1 2006/04/11 16:33:33 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* This library is used with the server IP allow/deny host authentication
* feature
*/
 
 
/**
* Gets the "true" IP address of the current user
*
* @return string the ip of the user
*
* @access private
*/
function PMA_getIp()
{
global $REMOTE_ADDR;
global $HTTP_X_FORWARDED_FOR, $HTTP_X_FORWARDED, $HTTP_FORWARDED_FOR, $HTTP_FORWARDED;
global $HTTP_VIA, $HTTP_X_COMING_FROM, $HTTP_COMING_FROM;
 
// Get some server/environment variables values
if (empty($REMOTE_ADDR) && PMA_getenv('REMOTE_ADDR')) {
$REMOTE_ADDR = PMA_getenv('REMOTE_ADDR');
}
if (empty($HTTP_X_FORWARDED_FOR) && PMA_getenv('HTTP_X_FORWARDED_FOR')) {
$HTTP_X_FORWARDED_FOR = PMA_getenv('HTTP_X_FORWARDED_FOR');
}
if (empty($HTTP_X_FORWARDED) && PMA_getenv('HTTP_X_FORWARDED')) {
$HTTP_X_FORWARDED = PMA_getenv('HTTP_X_FORWARDED');
}
if (empty($HTTP_FORWARDED_FOR) && PMA_getenv('HTTP_FORWARDED_FOR')) {
$HTTP_FORWARDED_FOR = PMA_getenv('HTTP_FORWARDED_FOR');
}
if (empty($HTTP_FORWARDED) && PMA_getenv('HTTP_FORWARDED')) {
$HTTP_FORWARDED = PMA_getenv('HTTP_FORWARDED');
}
if (empty($HTTP_VIA) && PMA_getenv('HTTP_VIA')) {
$HTTP_VIA = PMA_getenv('HTTP_VIA');
}
if (empty($HTTP_X_COMING_FROM) && PMA_getenv('HTTP_X_COMING_FROM')) {
$HTTP_X_COMING_FROM = PMA_getenv('HTTP_X_COMING_FROM');
}
if (empty($HTTP_COMING_FROM) && PMA_getenv('HTTP_COMING_FROM')) {
$HTTP_COMING_FROM = PMA_getenv('HTTP_COMING_FROM');
}
 
// Gets the default ip sent by the user
if (!empty($REMOTE_ADDR)) {
$direct_ip = $REMOTE_ADDR;
}
 
// Gets the proxy ip sent by the user
$proxy_ip = '';
if (!empty($HTTP_X_FORWARDED_FOR)) {
$proxy_ip = $HTTP_X_FORWARDED_FOR;
} elseif (!empty($HTTP_X_FORWARDED)) {
$proxy_ip = $HTTP_X_FORWARDED;
} elseif (!empty($HTTP_FORWARDED_FOR)) {
$proxy_ip = $HTTP_FORWARDED_FOR;
} elseif (!empty($HTTP_FORWARDED)) {
$proxy_ip = $HTTP_FORWARDED;
} elseif (!empty($HTTP_VIA)) {
$proxy_ip = $HTTP_VIA;
} elseif (!empty($HTTP_X_COMING_FROM)) {
$proxy_ip = $HTTP_X_COMING_FROM;
} elseif (!empty($HTTP_COMING_FROM)) {
$proxy_ip = $HTTP_COMING_FROM;
} // end if... elseif...
 
// Returns the true IP if it has been found, else FALSE
if (empty($proxy_ip)) {
// True IP without proxy
return $direct_ip;
} else {
$is_ip = preg_match('|^([0-9]{1,3}\.){3,3}[0-9]{1,3}|', $proxy_ip, $regs);
if ($is_ip && (count($regs) > 0)) {
// True IP behind a proxy
return $regs[0];
} else {
// Can't define IP: there is a proxy but we don't have
// information about the true IP
return FALSE;
}
} // end if... else...
} // end of the 'PMA_getIp()' function
 
 
/**
* Based on IP Pattern Matcher
* Originally by J.Adams <jna@retina.net>
* Found on <http://www.php.net/manual/en/function.ip2long.php>
* Modified by Robbat2 <robbat2@users.sourceforge.net>
*
* Matches:
* xxx.xxx.xxx.xxx (exact)
* xxx.xxx.xxx.[yyy-zzz] (range)
* xxx.xxx.xxx.xxx/nn (CIDR)
*
* Does not match:
* xxx.xxx.xxx.xx[yyy-zzz] (range, partial octets not supported)
*
* @param string string of IP range to match
* @param string string of IP to test against range
*
* @return boolean always true
*
* @access public
*/
function PMA_ipMaskTest($testRange, $ipToTest)
{
$result = TRUE;
 
if (preg_match('|([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/([0-9]+)|', $testRange, $regs)) {
// performs a mask match
$ipl = ip2long($ipToTest);
$rangel = ip2long($regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' . $regs[4]);
 
$maskl = 0;
 
for ($i = 0; $i < 31; $i++) {
if ($i < $regs[5] - 1) {
$maskl = $maskl + pow(2, (30 - $i));
} // end if
} // end for
 
if (($maskl & $rangel) == ($maskl & $ipl)) {
return TRUE;
} else {
return FALSE;
}
} else {
// range based
$maskocts = explode('.', $testRange);
$ipocts = explode('.', $ipToTest);
 
// perform a range match
for ($i = 0; $i < 4; $i++) {
if (preg_match('|\[([0-9]+)\-([0-9]+)\]|', $maskocts[$i], $regs)) {
if (($ipocts[$i] > $regs[2])
|| ($ipocts[$i] < $regs[1])) {
$result = FALSE;
} // end if
} else {
if ($maskocts[$i] <> $ipocts[$i]) {
$result = FALSE;
} // end if
} // end if/else
} //end for
} //end if/else
 
return $result;
} // end of the "PMA_IPMaskTest()" function
 
 
/**
* Runs through IP Allow/Deny rules the use of it below for more information
*
* @param string 'allow' | 'deny' type of rule to match
*
* @return bool Matched a rule ?
*
* @access public
*
* @see PMA_getIp()
*/
function PMA_allowDeny($type)
{
global $cfg;
 
// Grabs true IP of the user and returns if it can't be found
$remote_ip = PMA_getIp();
if (empty($remote_ip)) {
return FALSE;
}
 
// copy username
$username = $cfg['Server']['user'];
 
// copy rule database
$rules = $cfg['Server']['AllowDeny']['rules'];
 
// lookup table for some name shortcuts
$shortcuts = array(
'all' => '0.0.0.0/0',
'localhost' => '127.0.0.1/8'
);
 
// Provide some useful shortcuts if server gives us address:
if (PMA_getenv('SERVER_ADDR')) {
$shortcuts['localnetA'] = PMA_getenv('SERVER_ADDR') . '/8';
$shortcuts['localnetB'] = PMA_getenv('SERVER_ADDR') . '/16';
$shortcuts['localnetC'] = PMA_getenv('SERVER_ADDR') . '/24';
}
 
foreach ($rules AS $rule) {
// extract rule data
$rule_data = explode(' ', $rule);
 
// check for rule type
if ($rule_data[0] != $type) {
continue;
}
 
// check for username
if (($rule_data[1] != '%') //wildcarded first
&& ($rule_data[1] != $username)) {
continue;
}
 
// check if the config file has the full string with an extra
// 'from' in it and if it does, just discard it
if ($rule_data[2] == 'from') {
$rule_data[2] = $rule_data[3];
}
 
// Handle shortcuts with above array
// DON'T use "array_key_exists" as it's only PHP 4.1 and newer.
if (isset($shortcuts[$rule_data[2]])) {
$rule_data[2] = $shortcuts[$rule_data[2]];
}
 
// Add code for host lookups here
// Excluded for the moment
 
// Do the actual matching now
if (PMA_ipMaskTest($rule_data[2], $remote_ip)) {
return TRUE;
}
} // end while
 
return FALSE;
} // end of the "PMA_AllowDeny()" function
 
?>
/Web/Maintenance/phpMyAdmin/libraries/kanji-encoding.lib.php
0,0 → 1,149
<?php
/* $Id: kanji-encoding.lib.php,v 2.2 2003/11/26 22:52:23 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/**
* Set of functions for kanji-encoding convert (available only with japanese
* language)
*
* PHP4 configure requirements:
* --enable-mbstring --enable-mbstr-enc-trans --enable-mbregex
*
* 2002/2/22 - by Yukihiro Kawada <kawada@den.fujifilm.co.jp>
*/
 
/**
* Gets the php internal encoding codes and sets the available encoding
* codes list
* 2002/1/4 by Y.Kawada
*
* @global string the current encoding code
* @global string the available encoding codes list
*
* @return boolean always true
*/
function PMA_internal_enc_check() {
global $internal_enc, $enc_list;
 
$internal_enc = mb_internal_encoding();
if ($internal_enc == 'EUC-JP') {
$enc_list = 'ASCII,EUC-JP,SJIS,JIS';
} else {
$enc_list = 'ASCII,SJIS,EUC-JP,JIS';
}
 
return TRUE;
} // end of the 'PMA_internal_enc_check' function
 
 
/**
* Reverses SJIS & EUC-JP position in the encoding codes list
* 2002/1/4 by Y.Kawada
*
* @global string the available encoding codes list
*
* @return boolean always true
*/
function PMA_change_enc_order() {
global $enc_list;
 
$p = explode(',', $enc_list);
if ($p[1] == 'EUC-JP') {
$enc_list = 'ASCII,SJIS,EUC-JP,JIS';
} else {
$enc_list = 'ASCII,EUC-JP,SJIS,JIS';
}
 
return TRUE;
} // end of the 'PMA_change_enc_order' function
 
 
/**
* Kanji string encoding convert
* 2002/1/4 by Y.Kawada
*
* @param string the string to convert
* @param string the destinasion encoding code
* @param string set 'kana' convert to JIS-X208-kana
*
* @global string the available encoding codes list
*
* @return string the converted string
*/
function PMA_kanji_str_conv($str, $enc, $kana) {
global $enc_list;
 
if ($enc == '' && $kana == '') {
return $str;
}
$nw = mb_detect_encoding($str, $enc_list);
 
if ($kana == 'kana') {
$dist = mb_convert_kana($str, 'KV', $nw);
$str = $dist;
}
if ($nw != $enc && $enc != '') {
$dist = mb_convert_encoding($str, $enc, $nw);
} else {
$dist = $str;
}
return $dist;
} // end of the 'PMA_kanji_str_conv' function
 
 
/**
* Kanji file encoding convert
* 2002/1/4 by Y.Kawada
*
* @param string the name of the file to convert
* @param string the destinasion encoding code
* @param string set 'kana' convert to JIS-X208-kana
*
* @return string the name of the converted file
*/
function PMA_kanji_file_conv($file, $enc, $kana) {
if ($enc == '' && $kana == '') {
return $file;
}
 
$tmpfname = tempnam('', $enc);
$fpd = fopen($tmpfname, 'wb');
$fps = fopen($file, 'r');
PMA_change_enc_order();
while (!feof($fps)) {
$line = fgets($fps, 4096);
$dist = PMA_kanji_str_conv($line, $enc, $kana);
fputs($fpd, $dist);
} // end while
PMA_change_enc_order();
fclose($fps);
fclose($fpd);
unlink($file);
 
return $tmpfname;
} // end of the 'PMA_kanji_file_conv' function
 
 
/**
* Defines radio form fields to switch between encoding modes
* 2002/1/4 by Y.Kawada
*
* @param string spaces character to prepend the output with
*
* @return string xhtml code for the radio controls
*/
function PMA_set_enc_form($spaces) {
return "\n"
. $spaces . '<input type="radio" name="knjenc" value="" checked="checked" />non' . "\n"
. $spaces . '<input type="radio" name="knjenc" value="EUC-JP" />EUC' . "\n"
. $spaces . '<input type="radio" name="knjenc" value="SJIS" />SJIS' . "\n"
. $spaces . '&nbsp;' . $GLOBALS['strEncto'] . '<br />' . "\n"
. $spaces . '<input type="checkbox" name="xkana" value="kana" />' . "\n"
. $spaces . '&nbsp;' . $GLOBALS['strXkana'] . '<br />' . "\n";
} // end of the 'PMA_set_enc_form' function
 
 
PMA_internal_enc_check();
 
?>
/Web/Maintenance/phpMyAdmin/libraries/left_header.inc.php
0,0 → 1,90
<?php
/* $Id: left_header.inc.php,v 2.10 2006/01/14 23:17:16 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* displays the pma logo, links and db and server selection in left frame
*
*/
 
if ( empty( $query_url ) ) {
$db = ! isset( $db ) ? '' : $db;
$table = ! isset( $table ) ? '' : $table;
$query_url = PMA_generate_common_url( $db, $table );
}
 
// display Logo, depending on $GLOBALS['cfg']['LeftDisplayLogo']
if ( $GLOBALS['cfg']['LeftDisplayLogo'] ) {
$logo = 'phpMyAdmin';
if ( @file_exists( $GLOBALS['pmaThemeImage'] . 'logo_left.png' ) ) {
$logo = '<img src="' . $GLOBALS['pmaThemeImage'] . 'logo_left.png" '
.'alt="' . $logo . '" id="imgpmalogo" />';
} elseif ( @file_exists( $GLOBALS['pmaThemeImage'] . 'pma_logo2.png' ) ) {
$logo = '<img src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo2.png" '
.'alt="' . $logo . '" id="imgpmalogo" />';
}
echo '<div id="pmalogo">' . "\n"
.'<a href="http://www.phpmyadmin.net/" target="_blank">'
.$logo . '</a>' . "\n"
.'</div>' . "\n";
} // end of display logo
?>
<div id="leftframelinks">
<?php
echo '<a href="main.php?' . $query_url . '"'
.' title="' . $strHome . '">'
.( $GLOBALS['cfg']['MainPageIconic']
? '<img class="icon" src="' . $pmaThemeImage . 'b_home.png" width="16" '
.' height="16" alt="' . $strHome . '" />'
: $strHome )
.'</a>' . "\n";
// if we have chosen server
if ( $server != 0 ) {
// Logout for advanced authentication
if ( $GLOBALS['cfg']['Server']['auth_type'] != 'config' ) {
echo ($GLOBALS['cfg']['MainPageIconic'] ? '' : ' - ');
echo '<a href="index.php?' . $query_url . '&amp;old_usr='
.urlencode($PHP_AUTH_USER) . '" target="_parent"'
.' title="' . $strLogout . '" >'
.( $GLOBALS['cfg']['MainPageIconic']
? '<img class="icon" src="' . $pmaThemeImage . 's_loggoff.png" '
.' width="16" height="16" alt="' . $strLogout . '" />'
: $strLogout )
.'</a>' . "\n";
} // end if ($GLOBALS['cfg']['Server']['auth_type'] != 'config'
 
$anchor = 'querywindow.php?' . PMA_generate_common_url( $db, $table );
if ($GLOBALS['cfg']['MainPageIconic']) {
$query_frame_link_text =
'<img class="icon" src="' . $pmaThemeImage . 'b_selboard.png"'
.' width="16" height="16" alt="' . $strQueryFrame . '" />';
} else {
echo '<br />' . "\n";
$query_frame_link_text = $strQueryFrame;
}
echo '<a href="' . $anchor . '&amp;no_js=true"'
.' title="' . $strQueryFrame . '"';
echo ' onclick="javascript:window.parent.open_querywindow();'
.' return false;"';
echo '>' . $query_frame_link_text . '</a>' . "\n";
} // end if ($server != 0)
 
if ($GLOBALS['cfg']['MainPageIconic']) {
echo ' <a href="Documentation.html" target="documentation"'
.' title="' . $strPmaDocumentation . '" >'
.'<img class="icon" src="' . $pmaThemeImage . 'b_docs.png" width="16" height="16"'
.' alt="' . $strPmaDocumentation . '" /></a>' . "\n";
echo ' ' . PMA_showMySQLDocu('', '', TRUE) . "\n";
}
echo '</div>' . "\n";
 
/**
* Displays the MySQL servers choice form
*/
if ($GLOBALS['cfg']['LeftDisplayServers'] && (count($GLOBALS['cfg']['Servers']) > 1 || $server == 0 && count($GLOBALS['cfg']['Servers']) == 1)) {
include('./libraries/select_server.lib.php');
PMA_select_server(TRUE, TRUE);
} // end if LeftDisplayServers
?>
/Web/Maintenance/phpMyAdmin/libraries/mcrypt.lib.php
0,0 → 1,93
<?php
 
/* $Id: mcrypt.lib.php,v 2.3 2005/02/07 16:46:02 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Initialization
*/
 
// Store the initialization vector because it will be needed for
// further decryption. I don't think necessary to have one iv
// per server so I don't put the server number in the cookie name.
 
if (!isset($_COOKIE['pma_mcrypt_iv'])) {
srand((double) microtime() * 1000000);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CBC), MCRYPT_RAND);
setcookie('pma_mcrypt_iv',
base64_encode($iv),
time() + (60 * 60 * 24 * 30),
$GLOBALS['cookie_path'], '',
$GLOBALS['is_https']);
} else {
$iv = base64_decode($_COOKIE['pma_mcrypt_iv']);
}
 
/**
* String padding
*
* @param string input string
* @param integer length of the result
* @param string the filling string
* @param integer padding mode
*
* @return string the padded string
*
* @access public
*/
function full_str_pad($input, $pad_length, $pad_string = '', $pad_type = 0) {
$str = '';
$length = $pad_length - strlen($input);
if ($length > 0) { // str_repeat doesn't like negatives
if ($pad_type == STR_PAD_RIGHT) { // STR_PAD_RIGHT == 1
$str = $input.str_repeat($pad_string, $length);
} elseif ($pad_type == STR_PAD_BOTH) { // STR_PAD_BOTH == 2
$str = str_repeat($pad_string, floor($length/2));
$str .= $input;
$str .= str_repeat($pad_string, ceil($length/2));
} else { // defaults to STR_PAD_LEFT == 0
$str = str_repeat($pad_string, $length).$input;
}
} else { // if $length is negative or zero we don't need to do anything
$str = $input;
}
return $str;
}
/**
* Encryption using blowfish algorithm (mcrypt)
*
* @param string original data
* @param string the secret
*
* @return string the encrypted result
*
* @access public
*
* @author lem9
*/
function PMA_blowfish_encrypt($data, $secret) {
global $iv;
// Seems we don't need the padding. Anyway if we need it,
// we would have to replace 8 by the next 8-byte boundary.
//$data = full_str_pad($data, 8, "\0", STR_PAD_RIGHT);
return base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, $secret, $data, MCRYPT_MODE_CBC, $iv));
}
 
/**
* Decryption using blowfish algorithm (mcrypt)
*
* @param string encrypted data
* @param string the secret
*
* @return string original data
*
* @access public
*
* @author lem9
*/
function PMA_blowfish_decrypt($encdata, $secret) {
global $iv;
return trim(mcrypt_decrypt(MCRYPT_BLOWFISH, $secret, base64_decode($encdata), MCRYPT_MODE_CBC, $iv));
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/mult_submits.inc.php
0,0 → 1,432
<?php
/* $Id: mult_submits.inc.php,v 1.9.2.3 2006/02/09 19:14:37 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/**
* Prepares the work and runs some other scripts if required
*/
if (!empty($submit_mult)
&& ($submit_mult != $strWithChecked)
&& ( ( isset($selected_db) && (is_array($selected_db) || strlen($selected_db)))
|| ( isset($selected_tbl) && (is_array($selected_tbl) || strlen($selected_tbl)))
|| ( isset($selected_fld) && (is_array($selected_fld) || strlen($selected_fld)))
|| !empty($rows_to_delete)
)) {
 
if (isset($selected_db) && (is_array($selected_db) || strlen($selected_db))) {
$selected = $selected_db;
$what = 'drop_db';
} elseif (isset($selected_tbl) && (is_array($selected_tbl) || strlen($selected_tbl))) {
if ($submit_mult == $strPrintView) {
require('./tbl_printview.php');
} else {
$selected = $selected_tbl;
switch ($submit_mult) {
case 'drop_db':
$what = 'drop_db';
break;
case $strDrop:
$what = 'drop_tbl';
break;
case $strEmpty:
$what = 'empty_tbl';
break;
case $strCheckTable:
unset($submit_mult);
$query_type = 'check_tbl';
$mult_btn = $strYes;
break;
case $strOptimizeTable:
unset($submit_mult);
$query_type = 'optimize_tbl';
$mult_btn = $strYes;
break;
case $strRepairTable:
unset($submit_mult);
$query_type = 'repair_tbl';
$mult_btn = $strYes;
break;
case $strAnalyzeTable:
unset($submit_mult);
$query_type = 'analyze_tbl';
$mult_btn = $strYes;
break;
} // end switch
}
} elseif (isset($selected_fld) && (is_array($selected_fld) || strlen($selected_fld))) {
$selected = $selected_fld;
switch ($submit_mult) {
case $strDrop:
$what = 'drop_fld';
break;
case $strPrimary:
// Gets table primary key
PMA_DBI_select_db($db);
$result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
$primary = '';
while ($row = PMA_DBI_fetch_assoc($result)) {
// Backups the list of primary keys
if ($row['Key_name'] == 'PRIMARY') {
$primary .= $row['Column_name'] . ', ';
}
} // end while
PMA_DBI_free_result($result);
if (empty($primary)) {
// no primary key, so we can safely create new
unset($submit_mult);
$query_type = 'primary_fld';
$mult_btn = $strYes;
} else {
// primary key exists, so lets as user
$what = 'primary_fld';
}
break;
case $strIndex:
unset($submit_mult);
$query_type = 'index_fld';
$mult_btn = $strYes;
break;
case $strUnique:
unset($submit_mult);
$query_type = 'unique_fld';
$mult_btn = $strYes;
break;
case $strIdxFulltext:
unset($submit_mult);
$query_type = 'fulltext_fld';
$mult_btn = $strYes;
break;
case $strChange:
require('./tbl_alter.php');
break;
case $strBrowse:
$sql_query = '';
foreach ($selected AS $idx => $sval) {
if ($sql_query == '') {
$sql_query .= 'SELECT ' . PMA_backquote(urldecode($sval));
} else {
$sql_query .= ', ' . PMA_backquote(urldecode($sval));
}
}
$sql_query .= ' FROM ' . PMA_backquote(htmlspecialchars($table));
require('./sql.php');
break;
}
} else {
$what = 'row_delete';
$selected = $rows_to_delete;
}
} // end if
 
 
/**
* Displays the confirmation form if required
*/
if ( !empty($submit_mult) && !empty($what)) {
$js_to_run = 'functions.js';
unset($message);
if (isset($table) && strlen($table)) {
require('./libraries/tbl_properties_common.php');
$url_query .= '&amp;goto=tbl_properties.php&amp;back=tbl_properties.php';
require('./libraries/tbl_properties_table_info.inc.php');
} elseif (isset($db) && strlen($db)) {
require('./libraries/db_details_common.inc.php');
require('./libraries/db_details_db_info.inc.php');
}
// Builds the query
$full_query = '';
if ($what == 'drop_tbl') {
$full_query_views = '';
}
$selected_cnt = count($selected);
$i = 0;
foreach ($selected AS $idx => $sval) {
switch ($what) {
case 'row_delete':
$full_query .= htmlspecialchars(urldecode($sval))
. ';<br />';
break;
case 'drop_db':
$full_query .= 'DROP DATABASE '
. PMA_backquote(htmlspecialchars(urldecode($sval)))
. ';<br />';
$reload = 1;
break;
 
case 'drop_tbl':
$current = urldecode($sval);
if (!empty($views) && in_array($current, $views)) {
$full_query_views .= (empty($full_query_views) ? 'DROP VIEW ' : ', ')
. PMA_backquote(htmlspecialchars($current));
} else {
$full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ')
. PMA_backquote(htmlspecialchars($current));
}
break;
 
case 'empty_tbl':
if (PMA_MYSQL_INT_VERSION >= 40000) {
$full_query .= 'TRUNCATE ';
} else {
$full_query .= 'DELETE FROM ';
}
$full_query .= PMA_backquote(htmlspecialchars(urldecode($sval)))
. ';<br />';
break;
 
case 'primary_fld':
if ($full_query == '') {
$full_query .= 'ALTER TABLE '
. PMA_backquote(htmlspecialchars($table))
. '<br />&nbsp;&nbsp;DROP PRIMARY KEY,'
. '<br />&nbsp;&nbsp; ADD PRIMARY KEY('
. '<br />&nbsp;&nbsp;&nbsp;&nbsp; '
. PMA_backquote(htmlspecialchars(urldecode($sval)))
. ',';
} else {
$full_query .= '<br />&nbsp;&nbsp;&nbsp;&nbsp; '
. PMA_backquote(htmlspecialchars(urldecode($sval)))
. ',';
}
if ($i == $selected_cnt-1) {
$full_query = preg_replace('@,$@', ');<br />', $full_query);
}
break;
case 'drop_fld':
if ($full_query == '') {
$full_query .= 'ALTER TABLE '
. PMA_backquote(htmlspecialchars($table))
. '<br />&nbsp;&nbsp;DROP '
. PMA_backquote(htmlspecialchars(urldecode($sval)))
. ',';
} else {
$full_query .= '<br />&nbsp;&nbsp;DROP '
. PMA_backquote(htmlspecialchars(urldecode($sval)))
. ',';
}
if ($i == $selected_cnt-1) {
$full_query = preg_replace('@,$@', ';<br />', $full_query);
}
break;
} // end switch
$i++;
}
if ($what == 'drop_tbl') {
if (!empty($full_query)) {
$full_query .= ';<br />' . "\n";
}
if (!empty($full_query_views)) {
$full_query .= $full_query_views . ';<br />' . "\n";
}
unset($full_query_views);
}
 
// Displays the form
?>
<!-- Do it really ? -->
<form action="<?php echo $action; ?>" method="post">
<input type="hidden" name="query_type" value="<?php echo $what; ?>" />
<?php
if (strpos(' ' . $action, 'db_details') == 1) {
echo PMA_generate_common_hidden_inputs($db);
} elseif (strpos(' ' . $action, 'tbl_properties') == 1
|| $what == 'row_delete') {
echo PMA_generate_common_hidden_inputs($db, $table);
} else {
echo PMA_generate_common_hidden_inputs();
}
?>
<input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload) : 0; ?>" />
<?php
foreach ($selected AS $idx => $sval) {
echo '<input type="hidden" name="selected[]" value="' . htmlspecialchars($sval) . '" />' . "\n";
}
if ($what == 'drop_tbl' && !empty($views)) {
foreach ($views as $current) {
echo '<input type="hidden" name="views[]" value="' . htmlspecialchars($current) . '" />' . "\n";
}
}
if ($what == 'row_delete') {
echo '<input type="hidden" name="original_sql_query" value="' . htmlspecialchars($original_sql_query) . '" />' . "\n";
echo '<input type="hidden" name="original_pos" value="' . $original_pos . '" />' . "\n";
echo '<input type="hidden" name="original_url_query" value="' . htmlspecialchars($original_url_query) . '" />' . "\n";
echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
echo '<input type="hidden" name="pos" value="' . ( isset( $pos ) ? $pos : 0 ) . '" />' . "\n";
echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
}
?>
<fieldset class="confirmation">
<legend><?php echo ($what == 'drop_db' ? $strDropDatabaseStrongWarning . '&nbsp;' : '') . $strDoYouReally; ?>:</legend>
<tt><?php echo $full_query; ?></tt>
</fieldset>
<fieldset class="tblFooters">
<input type="submit" name="mult_btn" value="<?php echo $strYes; ?>" id="buttonYes" />
<input type="submit" name="mult_btn" value="<?php echo $strNo; ?>" id="buttonNo" />
</fieldset>
<?php
require_once('./libraries/footer.inc.php');
} // end if
 
 
/**
* Executes the query
*/
elseif ($mult_btn == $strYes) {
 
if ($query_type == 'drop_db' || $query_type == 'drop_tbl' || $query_type == 'drop_fld') {
require_once('./libraries/relation_cleanup.lib.php');
}
 
$sql_query = '';
if ($query_type == 'drop_tbl') {
$sql_query_views = '';
}
$selected_cnt = count($selected);
$run_parts = FALSE; // whether to run query after each pass
$use_sql = FALSE; // whether to include sql.php at the end (to display results)
 
if ($query_type == 'primary_fld') {
// Gets table primary key
PMA_DBI_select_db($db);
$result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
$primary = '';
while ($row = PMA_DBI_fetch_assoc($result)) {
// Backups the list of primary keys
if ($row['Key_name'] == 'PRIMARY') {
$primary .= $row['Column_name'] . ', ';
}
} // end while
PMA_DBI_free_result($result);
}
for ($i = 0; $i < $selected_cnt; $i++) {
switch ($query_type) {
case 'row_delete':
$a_query = urldecode($selected[$i]);
$run_parts = TRUE;
break;
 
case 'drop_db':
PMA_relationsCleanupDatabase($selected[$i]);
$a_query = 'DROP DATABASE '
. PMA_backquote(urldecode($selected[$i]));
$reload = 1;
$run_parts = TRUE;
break;
 
case 'drop_tbl':
PMA_relationsCleanupTable($db, $selected[$i]);
$current = urldecode($selected[$i]);
if (!empty($views) && in_array($current, $views)) {
$sql_query_views .= (empty($sql_query_views) ? 'DROP VIEW ' : ', ')
. PMA_backquote($current);
} else {
$sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ')
. PMA_backquote($current);
}
$reload = 1;
break;
 
case 'check_tbl':
$sql_query .= (empty($sql_query) ? 'CHECK TABLE ' : ', ')
. PMA_backquote(urldecode($selected[$i]));
$use_sql = TRUE;
break;
 
case 'optimize_tbl':
$sql_query .= (empty($sql_query) ? 'OPTIMIZE TABLE ' : ', ')
. PMA_backquote(urldecode($selected[$i]));
$use_sql = TRUE;
break;
 
case 'analyze_tbl':
$sql_query .= (empty($sql_query) ? 'ANALYZE TABLE ' : ', ')
. PMA_backquote(urldecode($selected[$i]));
$use_sql = TRUE;
break;
 
case 'repair_tbl':
$sql_query .= (empty($sql_query) ? 'REPAIR TABLE ' : ', ')
. PMA_backquote(urldecode($selected[$i]));
$use_sql = TRUE;
break;
 
case 'empty_tbl':
if (PMA_MYSQL_INT_VERSION >= 40000) {
$a_query = 'TRUNCATE ';
} else {
$a_query = 'DELETE FROM ';
}
$a_query .= PMA_backquote(htmlspecialchars(urldecode($selected[$i])));
$run_parts = TRUE;
break;
 
case 'drop_fld':
PMA_relationsCleanupColumn($db, $table, $selected[$i]);
$sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) : ',')
. ' DROP ' . PMA_backquote(urldecode($selected[$i]))
. (($i == $selected_cnt-1) ? ';' : '');
break;
 
case 'primary_fld':
$sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . ( empty($primary) ? '' : ' DROP PRIMARY KEY,') . ' ADD PRIMARY KEY( ' : ', ')
. PMA_backquote(urldecode($selected[$i]))
. (($i == $selected_cnt-1) ? ');' : '');
break;
 
case 'index_fld':
$sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX( ' : ', ')
. PMA_backquote(urldecode($selected[$i]))
. (($i == $selected_cnt-1) ? ');' : '');
break;
 
case 'unique_fld':
$sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE( ' : ', ')
. PMA_backquote(urldecode($selected[$i]))
. (($i == $selected_cnt-1) ? ');' : '');
break;
 
case 'fulltext_fld':
$sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT( ' : ', ')
. PMA_backquote(urldecode($selected[$i]))
. (($i == $selected_cnt-1) ? ');' : '');
break;
} // end switch
 
// All "DROP TABLE", "DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE"
// statements will be run at once below
if ($run_parts) {
$sql_query .= $a_query . ';' . "\n";
if ($query_type != 'drop_db') {
PMA_DBI_select_db($db);
}
$result = @PMA_DBI_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url);
} // end if
} // end for
 
if ($query_type == 'drop_tbl') {
if (!empty($sql_query)) {
$sql_query .= ';';
} elseif (!empty($sql_query_views)) {
$sql_query = $sql_query_views . ';';
unset($sql_query_views);
}
}
 
if ($use_sql) {
require('./sql.php');
} elseif (!$run_parts) {
PMA_DBI_select_db($db);
$result = PMA_DBI_query($sql_query);
if (!empty($sql_query_views)) {
$sql_query .= ' ' . $sql_query_views . ';';
PMA_DBI_query($sql_query_views);
unset($sql_query_views);
}
}
}
?>
/Web/Maintenance/phpMyAdmin/libraries/mysql_charsets.lib.php
0,0 → 1,386
<?php
/* $Id: mysql_charsets.lib.php,v 2.43 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
if (PMA_MYSQL_INT_VERSION >= 40100){
 
$res = PMA_DBI_query('SHOW CHARACTER SET;');
 
$mysql_charsets = array();
while ($row = PMA_DBI_fetch_assoc($res)) {
$mysql_charsets[] = $row['Charset'];
// never used
//$mysql_charsets_maxlen[$row['Charset']] = $row['Maxlen'];
$mysql_charsets_descriptions[$row['Charset']] = $row['Description'];
}
@PMA_DBI_free_result( $res );
 
$mysql_charsets_count = count($mysql_charsets);
sort($mysql_charsets, SORT_STRING);
 
$mysql_collations = array_flip($mysql_charsets);
$mysql_default_collations = $mysql_collations_flat = $mysql_charsets_available = $mysql_collations_available = array();
 
$res = PMA_DBI_query('SHOW COLLATION;');
while ($row = PMA_DBI_fetch_assoc($res)) {
if (!is_array($mysql_collations[$row['Charset']])) {
$mysql_collations[$row['Charset']] = array($row['Collation']);
} else {
$mysql_collations[$row['Charset']][] = $row['Collation'];
}
$mysql_collations_flat[] = $row['Collation'];
if ((isset($row['D']) && $row['D'] == 'Y') || (isset($row['Default']) && $row['Default'] == 'Yes')) {
$mysql_default_collations[$row['Charset']] = $row['Collation'];
}
//$mysql_collations_available[$row['Collation']] = !isset($row['Compiled']) || $row['Compiled'] == 'Yes';
$mysql_collations_available[$row['Collation']] = TRUE;
$mysql_charsets_available[$row['Charset']] = !empty($mysql_charsets_available[$row['Charset']]) || !empty($mysql_collations_available[$row['Collation']]);
}
@PMA_DBI_free_result( $res );
unset( $res, $row );
 
$mysql_collations_count = count($mysql_collations_flat);
sort($mysql_collations_flat, SORT_STRING);
foreach ($mysql_collations AS $key => $value) {
sort($mysql_collations[$key], SORT_STRING);
reset($mysql_collations[$key]);
}
unset( $key, $value );
 
define('PMA_CSDROPDOWN_COLLATION', 0);
define('PMA_CSDROPDOWN_CHARSET', 1);
 
function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION, $name = null, $id = null, $default = null, $label = TRUE, $indent = 0, $submitOnChange = FALSE, $displayUnavailable = FALSE) {
global $mysql_charsets, $mysql_charsets_descriptions, $mysql_charsets_available, $mysql_collations, $mysql_collations_available;
 
if (empty($name)) {
if ($type == PMA_CSDROPDOWN_COLLATION) {
$name = 'collation';
} else {
$name = 'character_set';
}
}
 
$spacer = '';
for ($i = 1; $i <= $indent; $i++) $spacer .= ' ';
 
$return_str = $spacer . '<select xml:lang="en" dir="ltr" name="' . htmlspecialchars($name) . '"' . (empty($id) ? '' : ' id="' . htmlspecialchars($id) . '"') . ($submitOnChange ? ' onchange="this.form.submit();"' : '') . '>' . "\n";
if ($label) {
$return_str .= $spacer . ' <option value="">' . ($type == PMA_CSDROPDOWN_COLLATION ? $GLOBALS['strCollation'] : $GLOBALS['strCharset']) . '</option>' . "\n";
}
$return_str .= $spacer . ' <option value=""></option>' . "\n";
foreach ($mysql_charsets as $current_charset) {
if (!$mysql_charsets_available[$current_charset]) {
continue;
}
$current_cs_descr = empty($mysql_charsets_descriptions[$current_charset]) ? $current_charset : $mysql_charsets_descriptions[$current_charset];
if ($type == PMA_CSDROPDOWN_COLLATION) {
$return_str .= $spacer . ' <optgroup label="' . $current_charset . '" title="' . $current_cs_descr . '">' . "\n";
foreach ($mysql_collations[$current_charset] as $current_collation) {
if (!$mysql_collations_available[$current_collation]) {
continue;
}
$return_str .= $spacer . ' <option value="' . $current_collation . '" title="' . PMA_getCollationDescr($current_collation) . '"' . ($default == $current_collation ? ' selected="selected"' : '') . '>' . $current_collation . '</option>' . "\n";
}
$return_str .= $spacer . ' </optgroup>' . "\n";
} else {
$return_str .= $spacer . ' <option value="' . $current_charset . '" title="' . $current_cs_descr . '"' . ($default == $current_charset ? ' selected="selected"' : '') . '>' . $current_charset . '</option>' . "\n";
}
}
$return_str .= $spacer . '</select>' . "\n";
 
return $return_str;
}
 
function PMA_generateCharsetQueryPart($collation) {
list($charset) = explode('_', $collation);
return ' CHARACTER SET ' . $charset . ($charset == $collation ? '' : ' COLLATE ' . $collation);
}
 
/**
* returns collation of given db
*
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_DBI_fetch_value()
* @uses PMA_DBI_select_db()
* @uses PMA_sqlAddSlashes()
* @uses $GLOBALS['db']
* @param string $db name of db
* @return string collation of $db
*/
function PMA_getDbCollation( $db ) {
if ( PMA_MYSQL_INT_VERSION >= 50000 && $db == 'information_schema' ) {
// We don't have to check the collation of the virtual
// information_schema database: We know it!
return 'utf8_general_ci';
}
if ( PMA_MYSQL_INT_VERSION >= 50006 ) {
// Since MySQL 5.0.6, we don't have to parse SHOW CREATE DATABASE anymore.
return PMA_DBI_fetch_value('SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = \'' . PMA_sqlAddSlashes($db) . '\' LIMIT 1;');
} elseif ( PMA_MYSQL_INT_VERSION >= 40101 ) {
// MySQL 4.1.0 does not support seperate charset settings
// for databases.
PMA_DBI_select_db( $db );
$return = PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE "collation_database"', 0, 1 );
if ( isset( $GLOBALS['db'] ) && $db !== $GLOBALS['db'] ) {
PMA_DBI_select_db( $GLOBALS['db'] );
}
return $return;
}
return '';
}
 
} else {
function PMA_getDbCollation( $db ) { return PMA_getServerCollation(); }
}
 
/**
* returns default server collation from show variables
*
* @uses PMA_DBI_fetch_value()
* @return string $server_collation
*/
function PMA_getServerCollation() {
return PMA_DBI_fetch_value(
'SHOW VARIABLES LIKE \'collation_server\'', 0, 1 );
}
 
/**
* returns description for given collation
*
* @uses is_array()
* @uses explode()
* @uses count()
* @uses $GLOBALS['str[Languages|Sorting]']
*
* @param string $collation MySQL collation string
* @return string collation description
*/
function PMA_getCollationDescr( $collation ) {
static $collation_cache;
 
if (!is_array($collation_cache)) {
$collation_cache = array();
} elseif (isset($collation_cache[$collation])) {
return $collation_cache[$collation];
}
 
if ($collation == 'binary') {
return $GLOBALS['strBinary'];
}
$parts = explode('_', $collation);
if (count($parts) == 1) {
$parts[1] = 'general';
} elseif ($parts[1] == 'ci' || $parts[1] == 'cs') {
$parts[2] = $parts[1];
$parts[1] = 'general';
}
$descr = '';
switch ($parts[1]) {
case 'bulgarian':
$descr = $GLOBALS['strBulgarian'];
break;
case 'chinese':
if ($parts[0] == 'gb2312' || $parts[0] == 'gbk') {
$descr = $GLOBALS['strSimplifiedChinese'];
} elseif ($parts[0] == 'big5') {
$descr = $GLOBALS['strTraditionalChinese'];
}
break;
case 'ci':
$descr = $GLOBALS['strCaseInsensitive'];
break;
case 'cs':
$descr = $GLOBALS['strCaseSensitive'];
break;
case 'croatian':
$descr = $GLOBALS['strCroatian'];
break;
case 'czech':
$descr = $GLOBALS['strCzech'];
break;
case 'danish':
$descr = $GLOBALS['strDanish'];
break;
case 'english':
$descr = $GLOBALS['strEnglish'];
break;
case 'esperanto':
$descr = $GLOBALS['strEsperanto'];
break;
case 'estonian':
$descr = $GLOBALS['strEstonian'];
break;
case 'german1':
$descr = $GLOBALS['strGerman'] . ' (' . $GLOBALS['strDictionary'] . ')';
break;
case 'german2':
$descr = $GLOBALS['strGerman'] . ' (' . $GLOBALS['strPhoneBook'] . ')';
break;
case 'hungarian':
$descr = $GLOBALS['strHungarian'];
break;
case 'icelandic':
$descr = $GLOBALS['strIcelandic'];
break;
case 'japanese':
$descr = $GLOBALS['strJapanese'];
break;
case 'latvian':
$descr = $GLOBALS['strLatvian'];
break;
case 'lithuanian':
$descr = $GLOBALS['strLithuanian'];
break;
case 'korean':
$descr = $GLOBALS['strKorean'];
break;
case 'persian':
$descr = $GLOBALS['strPersian'];
break;
case 'polish':
$descr = $GLOBALS['strPolish'];
break;
case 'roman':
$descr = $GLOBALS['strWestEuropean'];
break;
case 'romanian':
$descr = $GLOBALS['strRomanian'];
break;
case 'slovak':
$descr = $GLOBALS['strSlovak'];
break;
case 'slovenian':
$descr = $GLOBALS['strSlovenian'];
break;
case 'spanish':
$descr = $GLOBALS['strSpanish'];
break;
case 'spanish2':
$descr = $GLOBALS['strTraditionalSpanish'];
break;
case 'swedish':
$descr = $GLOBALS['strSwedish'];
break;
case 'thai':
$descr = $GLOBALS['strThai'];
break;
case 'turkish':
$descr = $GLOBALS['strTurkish'];
break;
case 'ukrainian':
$descr = $GLOBALS['strUkrainian'];
break;
case 'unicode':
$descr = $GLOBALS['strUnicode'] . ' (' . $GLOBALS['strMultilingual'] . ')';
break;
case 'bin':
$is_bin = TRUE;
case 'general':
switch ($parts[0]) {
// Unicode charsets
case 'ucs2':
case 'utf8':
$descr = $GLOBALS['strUnicode'] . ' (' . $GLOBALS['strMultilingual'] . ')';
break;
// West European charsets
case 'ascii':
case 'cp850':
case 'dec8':
case 'hp8':
case 'latin1':
case 'macroman':
$descr = $GLOBALS['strWestEuropean'] . ' (' . $GLOBALS['strMultilingual'] . ')';
break;
// Central European charsets
case 'cp1250':
case 'cp852':
case 'latin2':
case 'macce':
$descr = $GLOBALS['strCentralEuropean'] . ' (' . $GLOBALS['strMultilingual'] . ')';
break;
// Russian charsets
case 'cp866':
case 'koi8r':
$descr = $GLOBALS['strRussian'];
break;
// Simplified Chinese charsets
case 'gb2312':
case 'gbk':
$descr = $GLOBALS['strSimplifiedChinese'];
break;
// Japanese charsets
case 'sjis':
case 'ujis':
case 'cp932':
case 'eucjpms':
$descr = $GLOBALS['strJapanese'];
break;
// Baltic charsets
case 'cp1257':
case 'latin7':
$descr = $GLOBALS['strBaltic'] . ' (' . $GLOBALS['strMultilingual'] . ')';
break;
// Other
case 'armscii8':
case 'armscii':
$descr = $GLOBALS['strArmenian'];
break;
case 'big5':
$descr = $GLOBALS['strTraditionalChinese'];
break;
case 'cp1251':
$descr = $GLOBALS['strCyrillic'] . ' (' . $GLOBALS['strMultilingual'] . ')';
break;
case 'cp1256':
$descr = $GLOBALS['strArabic'];
break;
case 'euckr':
$descr = $GLOBALS['strKorean'];
break;
case 'hebrew':
$descr = $GLOBALS['strHebrew'];
break;
case 'geostd8':
$descr = $GLOBALS['strGeorgian'];
break;
case 'greek':
$descr = $GLOBALS['strGreek'];
break;
case 'keybcs2':
$descr = $GLOBALS['strCzechSlovak'];
break;
case 'koi8u':
$descr = $GLOBALS['strUkrainian'];
break;
case 'latin5':
$descr = $GLOBALS['strTurkish'];
break;
case 'swe7':
$descr = $GLOBALS['strSwedish'];
break;
case 'tis620':
$descr = $GLOBALS['strThai'];
break;
default:
$descr = $GLOBALS['strUnknown'];
break;
}
if (!empty($is_bin)) {
$descr .= ', ' . $GLOBALS['strBinary'];
}
break;
default: $descr = $GLOBALS['strUnknown'];
}
if (!empty($parts[2])) {
if ($parts[2] == 'ci') {
$descr .= ', ' . $GLOBALS['strCaseInsensitive'];
} elseif ($parts[2] == 'cs') {
$descr .= ', ' . $GLOBALS['strCaseSensitive'];
}
}
 
$collation_cache[$collation] = $descr;
return $descr;
}
?>
/Web/Maintenance/phpMyAdmin/libraries/ob.lib.php
0,0 → 1,130
<?php
/* $Id: ob.lib.php,v 2.2 2003/11/26 22:52:23 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/**
* Output buffer functions for phpMyAdmin
*
* Copyright 2001 Jeremy Brand <jeremy@nirvani.net>
* http://www.jeremybrand.com/Jeremy/Brand/Jeremy_Brand.html
*
* Check for all the needed functions for output buffering
* Make some wrappers for the top and bottoms of our files.
*/
 
/**
* This function be used eventually to support more modes. It is needed
* because both header and footer functions must know what each other is
* doing.
*
* @return integer the output buffer mode
*/
function PMA_outBufferModeGet()
{
if (@function_exists('ob_start')) {
$mode = 1;
} else {
$mode = 0;
}
 
// If a user sets the output_handler in php.ini to ob_gzhandler, then
// any right frame file in phpMyAdmin will not be handled properly by
// the browser. My fix was to check the ini file within the
// PMA_outBufferModeGet() function.
//
// (Patch by Garth Gillespie, modified by Marc Delisle)
if (@ini_get('output_handler') == 'ob_gzhandler') {
$mode = 0;
}
if (@get_cfg_var('output_handler') == 'ob_gzhandler') {
$mode = 0;
}
// End patch
 
// If output buffering is enabled in php.ini it's not possible to
// add the ob_gzhandler without a warning message from php 4.3.0.
// Being better safe than sorry, check for any existing output handler
// instead of just checking the 'output_buffering' setting.
//
if (@function_exists('ob_get_level')) {
if (ob_get_level() > 0) {
$mode = 0;
}
}
 
// Zero (0) is no mode or in other words output buffering is OFF.
// Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
// Usefull if we ever decide to combine modes. Then a bitmask field of
// the sum of all modes will be the natural choice.
 
header('X-ob_mode: ' . $mode);
 
return $mode;
} // end of the 'PMA_outBufferModeGet()' function
 
 
/**
* This function will need to run at the top of all pages if output
* output buffering is turned on. It also needs to be passed $mode from
* the PMA_outBufferModeGet() function or it will be useless.
*
* @param integer the output buffer mode
*
* @return boolean whether output buffering is enabled or not
*/
function PMA_outBufferPre($mode)
{
switch($mode)
{
case 1:
ob_start('ob_gzhandler');
$retval = TRUE;
break;
 
case 0:
$retval = FALSE;
break;
 
// loic1: php3 fix
default:
$retval = FALSE;
break;
} // end switch
 
return $retval;
} // end of the 'PMA_outBufferPre()' function
 
 
/**
* This function will need to run at the bottom of all pages if output
* buffering is turned on. It also needs to be passed $mode from the
* PMA_outBufferModeGet() function or it will be useless.
*
* @param integer the output buffer mode
*
* @return boolean whether data has been send from the buffer or not
*/
function PMA_outBufferPost($mode)
{
switch($mode)
{
case 1:
# This output buffer doesn't need a footer.
$retval = TRUE;
break;
 
case 0:
$retval = FALSE;
break;
 
// loic1: php3 fix
default:
$retval = FALSE;
break;
} // end switch
 
return $retval;
} // end of the 'PMA_outBufferPost()' function
 
?>
/Web/Maintenance/phpMyAdmin/libraries/plugin_interface.lib.php
0,0 → 1,287
<?php
/* $Id: plugin_interface.lib.php,v 1.3 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Generic plugin interface.
*/
 
/**
* array PMA_getPlugins(string $plugins_dir, mixed $plugin_param)
*
* Reads all plugin information from directory $plugins_dir.
*
* @uses ksort()
* @uses opendir()
* @uses readdir()
* @uses is_file()
* @uses eregi()
* @param string $plugins_dir directrory with plugins
* @param mixed $plugin_param parameter to plugin by which they can decide whether they can work
* @return array list of plugins
*/
function PMA_getPlugins($plugins_dir, $plugin_param)
{
/* Scan for plugins */
$plugin_list = array();
if ($handle = @opendir($plugins_dir)) {
$is_first = 0;
while ($file = @readdir($handle)) {
if (is_file($plugins_dir . $file) && eregi('\.php$', $file)) {
include $plugins_dir . $file;
}
}
}
ksort($plugin_list);
return $plugin_list;
}
 
/**
* string PMA_getString(string $name)
*
* returns locale string for $name or $name if no locale is found
*
* @uses $GLOBALS
* @param string $name for local string
* @return string locale string for $name
*/
function PMA_getString($name)
{
return isset($GLOBALS[$name]) ? $GLOBALS[$name] : $name;
}
 
/**
* string PMA_pluginCheckboxCheck(string $section, string $opt)
*
* returns html input tag option 'checked' if plugin $opt should be set by config or request
*
* @uses $_REQUEST
* @uses $GLOBALS['cfg']
* @uses $GLOBALS['timeout_passed']
* @param string $section name of config section in
* $GLOBALS['cfg'][$section] for plugin
* @param string $opt name of option
* @return string hmtl input tag option 'checked'
*/
function PMA_pluginCheckboxCheck($section, $opt)
{
if ((isset($GLOBALS['timeout_passed']) && $GLOBALS['timeout_passed'] && isset($_REQUEST[$opt])) ||
(isset($GLOBALS['cfg'][$section][$opt]) && $GLOBALS['cfg'][$section][$opt])) {
return ' checked="checked"';
}
return '';
}
 
/**
* string PMA_pluginGetDefault(string $section, string $opt)
*
* returns default value for option $opt
*
* @uses htmlspecialchars()
* @uses $_REQUEST
* @uses $GLOBALS['cfg']
* @uses $GLOBALS['timeout_passed']
* @param string $section name of config section in
* $GLOBALS['cfg'][$section] for plugin
* @param string $opt name of option
* @return string default value for option $opt
*/
function PMA_pluginGetDefault($section, $opt)
{
if (isset($GLOBALS['timeout_passed']) && $GLOBALS['timeout_passed'] && isset($_REQUEST[$opt])) {
return htmlspecialchars($_REQUEST[$opt]);
} elseif (isset($GLOBALS['cfg'][$section][$opt])) {
return htmlspecialchars($GLOBALS['cfg'][$section][$opt]);
}
return '';
}
 
/**
* string PMA_pluginIsActive(string $section, string $opt, string $val)
*
* returns html input tag option 'checked' if option $opt should be set by config or request
*
* @uses $_REQUEST
* @uses $GLOBALS['cfg']
* @uses $GLOBALS['timeout_passed']
* @param string $section name of config section in
* $GLOBALS['cfg'][$section] for plugin
* @param string $opt name of option
* @param string $val value of option to check against
* @return string html input tag option 'checked'
*/
function PMA_pluginIsActive($section, $opt, $val)
{
if ( ! empty($GLOBALS['timeout_passed']) && isset($_REQUEST[$opt])) {
if ($_REQUEST[$opt] == $val) {
return ' checked="checked"';
}
} elseif (isset($GLOBALS['cfg'][$section][$opt]) && $GLOBALS['cfg'][$section][$opt] == $val) {
return ' checked="checked"';
}
return '';
}
 
/**
* string PMA_pluginGetChoice(string $section, string $name, array &$list)
*
* returns html radio form element for plugin choice
*
* @uses PMA_pluginIsActive()
* @uses PMA_getString()
* @param string $section name of config section in
* $GLOBALS['cfg'][$section] for plugin
* @param string $name name of radio element
* @param array &$list array with plugin configuration defined in plugin file
* @return string html input radio tag
*/
function PMA_pluginGetChoice($section, $name, &$list)
{
$ret = '';
foreach ($list as $plugin_name => $val) {
$ret .= '<!-- ' . $plugin_name . ' -->' . "\n";
$ret .= '<input type="radio" name="' . $name . '" value="' . $plugin_name . '"'
. ' id="radio_plugin_' . $plugin_name . '"'
. ' onclick="if(this.checked) { hide_them_all();'
.' document.getElementById(\'' . $plugin_name . '_options\').style.display = \'block\'; };'
.' return true"'
. PMA_pluginIsActive($section, $name, $plugin_name) . '/>' . "\n";
$ret .= '<label for="radio_plugin_' . $plugin_name . '">'
. PMA_getString($val['text']) . '</label>' . "\n";
$ret .= '<br /><br />' . "\n";
}
return $ret;
}
 
/**
* string PMA_pluginGetOneOption(string $section, string $plugin_name, string $id, array &$opt)
*
* returns single option in a table row
*
* @uses PMA_getString()
* @uses PMA_pluginCheckboxCheck()
* @uses PMA_pluginGetDefault()
* @param string $section name of config section in
* $GLOBALS['cfg'][$section] for plugin
* @param string $plugin_name unique plugin name
* @param string $id option id
* @param array &$opt plugin option details
* @return string table row with option
*/
function PMA_pluginGetOneOption($section, $plugin_name, $id, &$opt)
{
$ret = '';
$ret .= '<tr>';
if ($opt['type'] == 'bool') {
$ret .= '<td colspan="2">';
$ret .= '<input type="checkbox" name="' . $plugin_name . '_' . $opt['name'] . '"'
. ' value="something" id="checkbox_' . $plugin_name . '_' . $opt['name'] . '"'
. ' ' . PMA_pluginCheckboxCheck($section, $plugin_name . '_' . $opt['name']) .' />';
$ret .= '<label for="checkbox_' . $plugin_name . '_' . $opt['name'] . '">'
. PMA_getString($opt['text']) . '</label>';
$ret .= '</td>';
} elseif ($opt['type'] == 'text') {
$ret .= '<td>';
$ret .= '<label for="text_' . $plugin_name . '_' . $opt['name'] . '">'
. PMA_getString($opt['text']) . '</label>';
$ret .= '</td><td>';
$ret .= '<input type="text" name="' . $plugin_name . '_' . $opt['name'] . '"'
. ' value="' . PMA_pluginGetDefault($section, $plugin_name . '_' . $opt['name']) . '"'
. ' id="text_' . $plugin_name . '_' . $opt['name'] . '"'
. (isset($opt['size']) ? ' size="' . $opt['size'] . '"' : '' )
. (isset($opt['len']) ? ' maxlength="' . $opt['len'] . '"' : '' ) . ' />';
$ret .= '</td>';
} else {
/* This should be seen only by plugin writers, so I do not thing this
* needs translation. */
$ret .= '<td colspan="2">';
$ret .= 'UNKNOWN OPTION IN IMPORT PLUGIN ' . $plugin_name . '!';
$ret .= '</td>';
}
$ret .= '</tr>';
return $ret;
}
 
/**
* string PMA_pluginGetOptions(string $section, array &$list)
*
* return html fieldset with editable options for plugin
*
* @uses PMA_getString()
* @uses PMA_pluginGetOneOption()
* @param string $section name of config section in $GLOBALS['cfg'][$section]
* @param array &$list array with plugin configuration defined in plugin file
* @return string html fieldset with plugin options
*/
function PMA_pluginGetOptions($section, &$list)
{
$ret = '';
// Options for plugins that support them
foreach ($list as $plugin_name => $val) {
$ret .= '<fieldset id="' . $plugin_name . '_options" class="options">';
$ret .= '<legend>' . PMA_getString($val['options_text']) . '</legend>';
if (isset($val['options'])) {
$ret .= '<table class="form">';
$ret .= '<tbody>';
foreach ($val['options'] as $id => $opt) {
$ret .= PMA_pluginGetOneOption($section, $plugin_name, $id, $opt);
}
$ret .= '</tbody>';
$ret .= '</table>';
} else {
$ret .= $GLOBALS['strNoOptions'];
}
$ret .= '</fieldset>';
}
return $ret;
}
 
function PMA_pluginGetJavascript(&$list) {
$ret = '
<script type="text/javascript" language="javascript">
//<![CDATA[
function hide_them_all() {
';
foreach ($list as $plugin_name => $val) {
$ret .= 'document.getElementById("' . $plugin_name . '_options").style.display = "none";' . "\n";
}
$ret .= '
}
 
function init_options() {
hide_them_all();
';
foreach ($list as $plugin_name => $val) {
$ret .= 'if (document.getElementById("radio_plugin_' . $plugin_name . '").checked) {' . "\n";
$ret .= 'document.getElementById("' . $plugin_name . '_options").style.display = "block";' . "\n";
$ret .= ' } else ' . "\n";
}
$ret .= '
{
;
}
}
 
function match_file(fname) {
farr = fname.toLowerCase().split(".");
if (farr.length != 0) {
len = farr.length
if (farr[len - 1] == "gz" || farr[len - 1] == "bz2" || farr[len -1] == "zip") len--;
switch (farr[len - 1]) {
';
foreach ($list as $plugin_name => $val) {
$ret .= 'case "' . $val['extension'] . '" :';
$ret .= 'document.getElementById("radio_plugin_' . $plugin_name . '").checked = true;';
$ret .= 'init_options();';
$ret .= 'break;' . "\n";
}
$ret .='
}
}
}
//]]>
</script>
';
return $ret;
}
?>
/Web/Maintenance/phpMyAdmin/libraries/read_dump.lib.php
0,0 → 1,205
<?php
/* $Id: read_dump.lib.php,v 2.11 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Removes comment lines and splits up large sql files into individual queries
*
* Last revision: September 23, 2001 - gandon
*
* @param array the splitted sql commands
* @param string the sql commands
* @param integer the MySQL release number (because certains php3 versions
* can't get the value of a constant from within a function)
*
* @return boolean always true
*
* @access public
*/
function PMA_splitSqlFile(&$ret, $sql, $release)
{
// do not trim, see bug #1030644
//$sql = trim($sql);
$sql = rtrim($sql, "\n\r");
$sql_len = strlen($sql);
$char = '';
$string_start = '';
$in_string = FALSE;
$nothing = TRUE;
$time0 = time();
 
for ($i = 0; $i < $sql_len; ++$i) {
$char = $sql[$i];
 
// We are in a string, check for not escaped end of strings except for
// backquotes that can't be escaped
if ($in_string) {
for (;;) {
$i = strpos($sql, $string_start, $i);
// No end of string found -> add the current substring to the
// returned array
if (!$i) {
$ret[] = array('query' => $sql, 'empty' => $nothing);
return TRUE;
}
// Backquotes or no backslashes before quotes: it's indeed the
// end of the string -> exit the loop
elseif ($string_start == '`' || $sql[$i-1] != '\\') {
$string_start = '';
$in_string = FALSE;
break;
}
// one or more Backslashes before the presumed end of string...
else {
// ... first checks for escaped backslashes
$j = 2;
$escaped_backslash = FALSE;
while ($i-$j > 0 && $sql[$i-$j] == '\\') {
$escaped_backslash = !$escaped_backslash;
$j++;
}
// ... if escaped backslashes: it's really the end of the
// string -> exit the loop
if ($escaped_backslash) {
$string_start = '';
$in_string = FALSE;
break;
}
// ... else loop
else {
$i++;
}
} // end if...elseif...else
} // end for
} // end if (in string)
 
// lets skip comments (/*, -- and #)
elseif (($char == '-' && $sql_len > $i + 2 && $sql[$i + 1] == '-' && $sql[$i + 2] <= ' ') || $char == '#' || ($char == '/' && $sql_len > $i + 1 && $sql[$i + 1] == '*')) {
$i = strpos($sql, $char == '/' ? '*/' : "\n", $i);
// didn't we hit end of string?
if ($i === FALSE) {
break;
}
if ($char == '/') {
$i++;
}
}
 
// We are not in a string, first check for delimiter...
elseif ($char == ';') {
// if delimiter found, add the parsed part to the returned array
$ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing);
$nothing = TRUE;
$sql = ltrim(substr($sql, min($i + 1, $sql_len)));
$sql_len = strlen($sql);
if ($sql_len) {
$i = -1;
} else {
// The submited statement(s) end(s) here
return TRUE;
}
} // end elseif (is delimiter)
 
// ... then check for start of a string,...
elseif (($char == '"') || ($char == '\'') || ($char == '`')) {
$in_string = TRUE;
$nothing = FALSE;
$string_start = $char;
} // end elseif (is start of string)
 
elseif ($nothing) {
$nothing = FALSE;
}
 
// loic1: send a fake header each 30 sec. to bypass browser timeout
$time1 = time();
if ($time1 >= $time0 + 30) {
$time0 = $time1;
header('X-pmaPing: Pong');
} // end if
} // end for
 
// add any rest to the returned array
if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) {
$ret[] = array('query' => $sql, 'empty' => $nothing);
}
 
return TRUE;
} // end of the 'PMA_splitSqlFile()' function
 
 
/**
* Reads (and decompresses) a (compressed) file into a string
*
* @param string the path to the file
* @param string the MIME type of the file, if empty MIME type is autodetected
*
* @global array the phpMyAdmin configuration
*
* @return string the content of the file or
* boolean FALSE in case of an error.
*/
function PMA_readFile($path, $mime = '') {
global $cfg;
 
if (!file_exists($path)) {
return FALSE;
}
switch ($mime) {
case '':
$file = @fopen($path, 'rb');
if (!$file) {
return FALSE;
}
$test = fread($file, 3);
fclose($file);
if ($test[0] == chr(31) && $test[1] == chr(139)) {
return PMA_readFile($path, 'application/x-gzip');
}
if ($test == 'BZh') {
return PMA_readFile($path, 'application/x-bzip');
}
return PMA_readFile($path, 'text/plain');
case 'text/plain':
$file = @fopen($path, 'rb');
if (!$file) {
return FALSE;
}
$content = fread($file, filesize($path));
fclose($file);
break;
case 'application/x-gzip':
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
$file = @gzopen($path, 'rb');
if (!$file) {
return FALSE;
}
$content = '';
while (!gzeof($file)) {
$content .= gzgetc($file);
}
gzclose($file);
} else {
return FALSE;
}
break;
case 'application/x-bzip':
if ($cfg['BZipDump'] && @function_exists('bzdecompress')) {
$file = @fopen($path, 'rb');
if (!$file) {
return FALSE;
}
$content = fread($file, filesize($path));
fclose($file);
$content = bzdecompress($content);
} else {
return FALSE;
}
break;
default:
return FALSE;
}
return $content;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/relation.lib.php
0,0 → 1,909
<?php
/* $Id: relation.lib.php,v 2.52.2.1 2006/02/24 20:28:13 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Set of functions used with the relation and pdf feature
*/
 
/**
* Executes a query as controluser if possible, otherwise as normal user
*
* @param string the query to execute
* @param boolean whether to display SQL error messages or not
*
* @return integer the result id
*
* @global string the URL of the page to show in case of error
* @global string the name of db to come back to
* @global resource the resource id of DB connect as controluser
* @global array configuration infos about the relations stuff
*
* @access public
*
* @author Mike Beck <mikebeck@users.sourceforge.net>
*/
function PMA_query_as_cu($sql, $show_error = TRUE, $options = 0) {
global $err_url_0, $db, $controllink, $cfgRelation;
 
// Comparing resource ids works on PHP 5 because, when no controluser
// is defined, connecting with the same user for controllink does
// not create a new connection. However a new connection is created
// on PHP 4, so we cannot directly compare resource ids.
 
if ($controllink == $GLOBALS['userlink'] || PMA_MYSQL_INT_VERSION < 50000) {
PMA_DBI_select_db($cfgRelation['db'], $controllink);
}
if ($show_error) {
$result = PMA_DBI_query($sql, $controllink, $options);
} else {
$result = @PMA_DBI_try_query($sql, $controllink, $options);
} // end if... else...
// It makes no sense to restore database on control user
if ($controllink == $GLOBALS['userlink'] || PMA_MYSQL_INT_VERSION < 50000) {
PMA_DBI_select_db($db, $controllink);
}
 
if ($result) {
return $result;
} else {
return FALSE;
}
} // end of the "PMA_query_as_cu()" function
 
 
/**
* Defines the relation parameters for the current user
* just a copy of the functions used for relations ;-)
* but added some stuff to check what will work
*
* @param boolean whether to check validity of settings or not
*
* @return array the relation parameters for the current user
*
* @global array the list of settings for servers
* @global integer the id of the current server
* @global string the URL of the page to show in case of error
* @global string the name of the current db
* @global string the name of the current table
* @global array configuration infos about the relations stuff
*
* @access public
*
* @author Mike Beck <mikebeck@users.sourceforge.net>
*/
function PMA_getRelationsParam($verbose = FALSE)
{
global $cfg, $server, $err_url_0, $db, $table, $controllink;
global $cfgRelation;
 
$cfgRelation = array();
$cfgRelation['relwork'] = FALSE;
$cfgRelation['displaywork'] = FALSE;
$cfgRelation['bookmarkwork']= FALSE;
$cfgRelation['pdfwork'] = FALSE;
$cfgRelation['commwork'] = FALSE;
$cfgRelation['mimework'] = FALSE;
$cfgRelation['historywork'] = FALSE;
$cfgRelation['allworks'] = FALSE;
 
// No server selected -> no bookmark table
// we return the array with the FALSEs in it,
// to avoid some 'Unitialized string offset' errors later
if ($server == 0
|| empty($cfg['Server'])
|| empty($cfg['Server']['pmadb'])) {
if ($verbose == TRUE) {
echo 'PMA Database ... '
. '<font color="red"><b>' . $GLOBALS['strNotOK'] . '</b></font>'
. '[ <a href="Documentation.html#pmadb">' . $GLOBALS['strDocu'] . '</a> ]<br />' . "\n"
. $GLOBALS['strGeneralRelationFeat']
. ' <font color="green">' . $GLOBALS['strDisabled'] . '</font>' . "\n";
}
return $cfgRelation;
}
 
$cfgRelation['user'] = $cfg['Server']['user'];
$cfgRelation['db'] = $cfg['Server']['pmadb'];
 
// Now I just check if all tables that i need are present so I can for
// example enable relations but not pdf...
// I was thinking of checking if they have all required columns but I
// fear it might be too slow
 
PMA_DBI_select_db($cfgRelation['db'], $controllink);
$tab_query = 'SHOW TABLES FROM ' . PMA_backquote($cfgRelation['db']);
$tab_rs = PMA_query_as_cu($tab_query, FALSE, PMA_DBI_QUERY_STORE);
 
if ($tab_rs) {
while ($curr_table = @PMA_DBI_fetch_row($tab_rs)) {
if ($curr_table[0] == $cfg['Server']['bookmarktable']) {
$cfgRelation['bookmark'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['relation']) {
$cfgRelation['relation'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['table_info']) {
$cfgRelation['table_info'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['table_coords']) {
$cfgRelation['table_coords'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['column_info']) {
$cfgRelation['column_info'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['pdf_pages']) {
$cfgRelation['pdf_pages'] = $curr_table[0];
} elseif ($curr_table[0] == $cfg['Server']['history']) {
$cfgRelation['history'] = $curr_table[0];
}
} // end while
}
 
if (isset($cfgRelation['relation'])) {
$cfgRelation['relwork'] = TRUE;
if (isset($cfgRelation['table_info'])) {
$cfgRelation['displaywork'] = TRUE;
}
}
if (isset($cfgRelation['table_coords']) && isset($cfgRelation['pdf_pages'])) {
$cfgRelation['pdfwork'] = TRUE;
}
if (isset($cfgRelation['column_info'])) {
$cfgRelation['commwork'] = TRUE;
 
if ($cfg['Server']['verbose_check']) {
$mime_query = 'SHOW FIELDS FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']);
$mime_rs = PMA_query_as_cu($mime_query, FALSE);
 
$mime_field_mimetype = FALSE;
$mime_field_transformation = FALSE;
$mime_field_transformation_options = FALSE;
while ($curr_mime_field = @PMA_DBI_fetch_row($mime_rs)) {
if ($curr_mime_field[0] == 'mimetype') {
$mime_field_mimetype = TRUE;
} elseif ($curr_mime_field[0] == 'transformation') {
$mime_field_transformation = TRUE;
} elseif ($curr_mime_field[0] == 'transformation_options') {
$mime_field_transformation_options = TRUE;
}
}
PMA_DBI_free_result($mime_rs);
 
if ($mime_field_mimetype == TRUE
&& $mime_field_transformation == TRUE
&& $mime_field_transformation_options == TRUE) {
$cfgRelation['mimework'] = TRUE;
}
} else {
$cfgRelation['mimework'] = TRUE;
}
}
 
if (isset($cfgRelation['history'])) {
$cfgRelation['historywork'] = TRUE;
}
 
if (isset($cfgRelation['bookmark'])) {
$cfgRelation['bookmarkwork'] = TRUE;
}
 
if ($cfgRelation['relwork'] == TRUE && $cfgRelation['displaywork'] == TRUE
&& $cfgRelation['pdfwork'] == TRUE && $cfgRelation['commwork'] == TRUE
&& $cfgRelation['mimework'] == TRUE && $cfgRelation['historywork'] == TRUE
&& $cfgRelation['bookmarkwork'] == TRUE) {
$cfgRelation['allworks'] = TRUE;
}
if ($tab_rs) {
PMA_DBI_free_result($tab_rs);
} else {
$cfg['Server']['pmadb'] = FALSE;
}
 
if ($verbose == TRUE) {
$shit = '<font color="red"><b>' . $GLOBALS['strNotOK'] . '</b></font> [ <a href="Documentation.html#%s">' . $GLOBALS['strDocu'] . '</a> ]';
$hit = '<font color="green"><b>' . $GLOBALS['strOK'] . '</b></font>';
$enabled = '<font color="green">' . $GLOBALS['strEnabled'] . '</font>';
$disabled = '<font color="red">' . $GLOBALS['strDisabled'] . '</font>';
 
echo '<table>' . "\n";
echo ' <tr><th align="left">$cfg[\'Servers\'][$i][\'pmadb\'] ... </th><td align="right">'
. (($cfg['Server']['pmadb'] == FALSE) ? sprintf($shit, 'pmadb') : $hit)
. '</td></tr>' . "\n";
echo ' <tr><td>&nbsp;</td></tr>' . "\n";
 
echo ' <tr><th align="left">$cfg[\'Servers\'][$i][\'relation\'] ... </th><td align="right">'
. ((isset($cfgRelation['relation'])) ? $hit : sprintf($shit, 'relation'))
. '</td></tr>' . "\n";
echo ' <tr><td colspan=2 align="center">'. $GLOBALS['strGeneralRelationFeat'] . ': '
. (($cfgRelation['relwork'] == TRUE) ? $enabled : $disabled)
. '</td></tr>' . "\n";
echo ' <tr><td>&nbsp;</td></tr>' . "\n";
 
echo ' <tr><th align="left">$cfg[\'Servers\'][$i][\'table_info\'] ... </th><td align="right">'
. (($cfgRelation['displaywork'] == FALSE) ? sprintf($shit, 'table_info') : $hit)
. '</td></tr>' . "\n";
echo ' <tr><td colspan=2 align="center">' . $GLOBALS['strDisplayFeat'] . ': '
. (($cfgRelation['displaywork'] == TRUE) ? $enabled : $disabled)
. '</td></tr>' . "\n";
echo ' <tr><td>&nbsp;</td></tr>' . "\n";
 
echo ' <tr><th align="left">$cfg[\'Servers\'][$i][\'table_coords\'] ... </th><td align="right">'
. ((isset($cfgRelation['table_coords'])) ? $hit : sprintf($shit, 'table_coords'))
. '</td></tr>' . "\n";
echo ' <tr><th align="left">$cfg[\'Servers\'][$i][\'pdf_pages\'] ... </th><td align="right">'
. ((isset($cfgRelation['pdf_pages'])) ? $hit : sprintf($shit, 'table_coords'))
. '</td></tr>' . "\n";
echo ' <tr><td colspan=2 align="center">' . $GLOBALS['strCreatePdfFeat'] . ': '
. (($cfgRelation['pdfwork'] == TRUE) ? $enabled : $disabled)
. '</td></tr>' . "\n";
echo ' <tr><td>&nbsp;</td></tr>' . "\n";
 
echo ' <tr><th align="left">$cfg[\'Servers\'][$i][\'column_info\'] ... </th><td align="right">'
. ((isset($cfgRelation['column_info'])) ? $hit : sprintf($shit, 'col_com'))
. '</td></tr>' . "\n";
echo ' <tr><td colspan=2 align="center">' . $GLOBALS['strColComFeat'] . ': '
. (($cfgRelation['commwork'] == TRUE) ? $enabled : $disabled)
. '</td></tr>' . "\n";
echo ' <tr><td colspan=2 align="center">' . $GLOBALS['strBookmarkQuery'] . ': '
. (($cfgRelation['bookmarkwork'] == TRUE) ? $enabled : $disabled)
. '</td></tr>' . "\n";
echo ' <tr><th align="left">MIME ...</th><td align="right">'
. (($cfgRelation['mimework'] == TRUE) ? $hit : sprintf($shit, 'col_com'))
. '</td></tr>' . "\n";
 
if (($cfgRelation['commwork'] == TRUE) && ($cfgRelation['mimework'] != TRUE)) {
echo '<tr><td colspan=2 align="left">' . $GLOBALS['strUpdComTab'] . '</td></tr>' . "\n";
}
 
echo ' <tr><th align="left">$cfg[\'Servers\'][$i][\'history\'] ... </th><td align="right">'
. ((isset($cfgRelation['history'])) ? $hit : sprintf($shit, 'history'))
. '</td></tr>' . "\n";
echo ' <tr><td colspan=2 align="center">' . $GLOBALS['strQuerySQLHistory'] . ': '
. (($cfgRelation['historywork'] == TRUE) ? $enabled : $disabled)
. '</td></tr>' . "\n";
 
echo '</table>' . "\n";
} // end if ($verbose == TRUE) {
 
return $cfgRelation;
} // end of the 'PMA_getRelationsParam()' function
 
 
/**
* Gets all Relations to foreign tables for a given table or
* optionally a given column in a table
*
* @param string the name of the db to check for
* @param string the name of the table to check for
* @param string the name of the column to check for
* @param string the source for foreign key information
*
* @return array db,table,column
*
* @global array the list of relations settings
* @global string the URL of the page to show in case of error
*
* @access public
*
* @author Mike Beck <mikebeck@users.sourceforge.net> and Marc Delisle
*/
function PMA_getForeigners($db, $table, $column = '', $source = 'both') {
global $cfgRelation, $err_url_0;
 
if ($cfgRelation['relwork'] && ($source == 'both' || $source == 'internal')) {
$rel_query = '
SELECT master_field,
foreign_db,
foreign_table,
foreign_field
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '
WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'
AND master_table = \'' . PMA_sqlAddslashes($table) . '\' ';
if (isset($column) && strlen($column)) {
$rel_query .= ' AND master_field = \'' . PMA_sqlAddslashes($column) . '\'';
}
$relations = PMA_query_as_cu($rel_query);
$i = 0;
while ($relrow = PMA_DBI_fetch_assoc($relations)) {
$field = $relrow['master_field'];
$foreign[$field]['foreign_db'] = $relrow['foreign_db'];
$foreign[$field]['foreign_table'] = $relrow['foreign_table'];
$foreign[$field]['foreign_field'] = $relrow['foreign_field'];
$i++;
} // end while
PMA_DBI_free_result($relations);
unset($relations);
}
 
if (($source == 'both' || $source == 'innodb') && isset($table) && strlen($table)) {
$show_create_table_query = 'SHOW CREATE TABLE '
. PMA_backquote($db) . '.' . PMA_backquote($table);
$show_create_table_res = PMA_DBI_query($show_create_table_query);
list(, $show_create_table) = PMA_DBI_fetch_row($show_create_table_res);
PMA_DBI_free_result($show_create_table_res);
unset($show_create_table_res, $show_create_table_query);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
 
foreach ($analyzed_sql[0]['foreign_keys'] AS $one_key) {
 
// the analyzer may return more than one column name in the
// index list or the ref_index_list
foreach ($one_key['index_list'] AS $i => $field) {
 
// If a foreign key is defined in the 'internal' source (pmadb)
// and in 'innodb', we won't get it twice if $source='both'
// because we use $field as key
 
// The parser looks for a CONSTRAINT clause just before
// the FOREIGN KEY clause. It finds it (as output from
// SHOW CREATE TABLE) in MySQL 4.0.13, but not in older
// versions like 3.23.58.
// In those cases, the FOREIGN KEY parsing will put numbers
// like -1, 0, 1... instead of the constraint number.
 
if (isset($one_key['constraint'])) {
$foreign[$field]['constraint'] = $one_key['constraint'];
}
 
if (isset($one_key['ref_db_name'])) {
$foreign[$field]['foreign_db'] = $one_key['ref_db_name'];
} else {
$foreign[$field]['foreign_db'] = $db;
}
$foreign[$field]['foreign_table'] = $one_key['ref_table_name'];
$foreign[$field]['foreign_field'] = $one_key['ref_index_list'][$i];
if (isset($one_key['on_delete'])) {
$foreign[$field]['on_delete'] = $one_key['on_delete'];
}
if (isset($one_key['on_update'])) {
$foreign[$field]['on_update'] = $one_key['on_update'];
}
}
}
}
 
/**
* Emulating relations for some information_schema tables
*/
if (PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema'
&& ($source == 'internal' || $source == 'both')) {
 
require_once('./libraries/information_schema_relations.lib.php');
 
if (!isset($foreign)) {
$foreign = array();
}
 
if (isset($GLOBALS['information_schema_relations'][$table])) {
foreach ($GLOBALS['information_schema_relations'][$table] as $field => $relations) {
if ( ( ! isset($column) || ! strlen($column) || $column == $field )
&& ( ! isset($foreign[$field]) || ! strlen($foreign[$field]) ) ) {
$foreign[$field] = $relations;
}
}
}
}
 
if (!empty($foreign) && is_array($foreign)) {
return $foreign;
} else {
return FALSE;
}
 
} // end of the 'PMA_getForeigners()' function
 
 
/**
* Gets the display field of a table
*
* @param string the name of the db to check for
* @param string the name of the table to check for
*
* @return string field name
*
* @global array the list of relations settings
*
* @access public
*
* @author Mike Beck <mikebeck@users.sourceforge.net>
*/
function PMA_getDisplayField($db, $table) {
global $cfgRelation;
 
/**
* Try to fetch the display field from DB.
*/
if (trim(@$cfgRelation['table_info']) != '') {
 
$disp_query = '
SELECT display_field
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . '
WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'
AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
 
$disp_res = PMA_query_as_cu($disp_query);
$row = ($disp_res ? PMA_DBI_fetch_assoc($disp_res) : '');
PMA_DBI_free_result($disp_res);
if (isset($row['display_field'])) {
return $row['display_field'];
}
 
}
 
/**
* Emulating the display field for some information_schema tables.
*/
if (PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema') {
switch ($table) {
case 'CHARACTER_SETS': return 'DESCRIPTION';
case 'TABLES': return 'TABLE_COMMENT';
}
}
 
/**
* No Luck...
*/
return FALSE;
 
} // end of the 'PMA_getDisplayField()' function
 
 
/**
* Gets the comments for all rows of a table
*
* @param string the name of the db to check for
* @param string the name of the table to check for
*
* @return array [field_name] = comment
*
* @global array the list of relations settings
*
* @access public
*
* @authors Mike Beck <mikebeck@users.sourceforge.net>
* and lem9
*/
function PMA_getComments($db, $table = '') {
global $cfgRelation;
 
if ($table != '') {
 
// MySQL 4.1.x native column comments
if (PMA_MYSQL_INT_VERSION >= 40100) {
$fields = PMA_DBI_get_fields($db, $table);
if ($fields) {
foreach ($fields as $key=>$field) {
$tmp_col = $field['Field'];
if (!empty($field['Comment'])) {
$native_comment[$tmp_col] = $field['Comment'];
}
}
if (isset($native_comment)) {
$comment = $native_comment;
}
}
}
 
// pmadb internal column comments
// (this function can be called even if $cfgRelation['commwork'] is
// FALSE, to get native column comments, so recheck here)
if ($cfgRelation['commwork']) {
$com_qry = '
SELECT column_name,
comment
FROM ' . PMA_backquote($cfgRelation['db']) . '.' .PMA_backquote($cfgRelation['column_info']) . '
WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'
AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$com_rs = PMA_query_as_cu($com_qry, TRUE, PMA_DBI_QUERY_STORE);
}
} else {
// pmadb internal db comments
$com_qry = '
SELECT ' . PMA_backquote('comment') . '
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'
AND table_name = \'\'
AND column_name = \'(db_comment)\'';
$com_rs = PMA_query_as_cu($com_qry, TRUE, PMA_DBI_QUERY_STORE);
}
 
 
if (isset($com_rs) && PMA_DBI_num_rows($com_rs) > 0) {
$i = 0;
while ($row = PMA_DBI_fetch_assoc($com_rs)) {
$i++;
$col = ($table != '' ? $row['column_name'] : $i);
 
if (strlen($row['comment']) > 0) {
$comment[$col] = $row['comment'];
// if this version supports native comments and this function
// was called with a table parameter
if (PMA_MYSQL_INT_VERSION >= 40100 && isset($table) && strlen($table)) {
// if native comment found, use it instead of pmadb
if (!empty($native_comment[$col])) {
$comment[$col] = $native_comment[$col];
} else {
// no native comment, so migrate pmadb-style to native
PMA_setComment($db, $table, $col, $comment[$col], '', 'native');
// and erase the pmadb-style comment
PMA_setComment($db, $table, $col, '', '', 'pmadb');
}
}
}
} // end while
 
PMA_DBI_free_result($com_rs);
unset($com_rs);
}
 
if (isset($comment) && is_array($comment)) {
return $comment;
} else {
return FALSE;
}
} // end of the 'PMA_getComments()' function
 
/**
* Adds/removes slashes if required
*
* @param string the string to slash
*
* @return string the slashed string
*
* @access public
*/
function PMA_handleSlashes($val) {
return PMA_sqlAddslashes($val);
} // end of the "PMA_handleSlashes()" function
 
/**
* Set a single comment to a certain value.
*
* @param string the name of the db
* @param string the name of the table (may be empty in case of a db comment)
* @param string the name of the column
* @param string the value of the column
* @param string (optional) if a column is renamed, this is the name of the former key which will get deleted
* @param string whether we set pmadb comments, native comments or both
*
* @return boolean true, if comment-query was made.
*
* @global array the list of relations settings
*
* @access public
*/
function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode='auto') {
global $cfgRelation;
 
if ($mode=='auto') {
if (PMA_MYSQL_INT_VERSION >= 40100) {
$mode='native';
} else {
$mode='pmadb';
}
}
 
// native mode is only for column comments so we need a table name
if ($mode == 'native' && isset($table) && strlen($table)) {
$query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE '
. PMA_generateAlterTable($col, $col, '', '', '', '', FALSE, '', FALSE, '', $comment, '', '');
PMA_DBI_try_query($query, null, PMA_DBI_QUERY_STORE);
return TRUE;
}
 
// $mode == 'pmadb' section:
 
$cols = array(
'db_name' => 'db_name ',
'table_name' => 'table_name ',
'column_name' => 'column_name'
);
 
if ($removekey != '' AND $removekey != $col) {
$remove_query = '
DELETE FROM
' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
WHERE ' . $cols['db_name'] . ' = \'' . PMA_sqlAddslashes($db) . '\'
AND ' . $cols['table_name'] . ' = \'' . PMA_sqlAddslashes($table) . '\'
AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddslashes($removekey) . '\'';
PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
$test_qry = '
SELECT ' . PMA_backquote('comment') . ',
mimetype,
transformation,
transformation_options
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
WHERE ' . $cols['db_name'] . ' = \'' . PMA_sqlAddslashes($db) . '\'
AND ' . $cols['table_name'] . ' = \'' . PMA_sqlAddslashes($table) . '\'
AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddslashes($col) . '\'';
$test_rs = PMA_query_as_cu($test_qry, TRUE, PMA_DBI_QUERY_STORE);
 
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
$row = PMA_DBI_fetch_assoc($test_rs);
PMA_DBI_free_result($test_rs);
 
if (strlen($comment) > 0 || strlen($row['mimetype']) > 0 || strlen($row['transformation']) > 0 || strlen($row['transformation_options']) > 0) {
$upd_query = '
UPDATE ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
SET ' . PMA_backquote('comment') . ' = \'' . PMA_sqlAddslashes($comment) . '\'
WHERE ' . $cols['db_name'] . ' = \'' . PMA_sqlAddslashes($db) . '\'
AND ' . $cols['table_name'] . ' = \'' . PMA_sqlAddslashes($table) . '\'
AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddSlashes($col) . '\'';
} else {
$upd_query = '
DELETE FROM
' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
WHERE ' . $cols['db_name'] . ' = \'' . PMA_sqlAddslashes($db) . '\'
AND ' . $cols['table_name'] . ' = \'' . PMA_sqlAddslashes($table) . '\'
AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddslashes($col) . '\'';
}
} elseif (strlen($comment) > 0) {
$upd_query = '
INSERT INTO
' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
(db_name, table_name, column_name, ' . PMA_backquote('comment') . ')
VALUES (
\'' . PMA_sqlAddslashes($db) . '\',
\'' . PMA_sqlAddslashes($table) . '\',
\'' . PMA_sqlAddslashes($col) . '\',
\'' . PMA_sqlAddslashes($comment) . '\')';
}
 
if (isset($upd_query)){
$upd_rs = PMA_query_as_cu($upd_query);
unset($upd_query);
return true;
} else {
return false;
}
} // end of 'PMA_setComment()' function
 
/**
* Set a SQL history entry
*
* @param string the name of the db
* @param string the name of the table
* @param string the username
* @param string the sql query
*
* @global array the list of relations settings
*
* @return boolean true
*
* @access public
*/
function PMA_setHistory($db, $table, $username, $sqlquery) {
global $cfgRelation;
 
$hist_rs = PMA_query_as_cu('
INSERT INTO
' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
( ' . PMA_backquote('username') . ',
' . PMA_backquote('db') . ',
' . PMA_backquote('table') . ',
' . PMA_backquote('timevalue') . ',
' . PMA_backquote('sqlquery') . ' )
VALUES
( \'' . PMA_sqlAddslashes($username) . '\',
\'' . PMA_sqlAddslashes($db) . '\',
\'' . PMA_sqlAddslashes($table) . '\',
NOW(),
\'' . PMA_sqlAddslashes($sqlquery) . '\' )');
return true;
} // end of 'PMA_setHistory()' function
 
/**
* Gets a SQL history entry
*
* @param string the username
*
* @global array the list of relations settings
*
* @return array list of history items
*
* @access public
*/
function PMA_getHistory($username) {
global $cfgRelation;
 
$hist_query = '
SELECT ' . PMA_backquote('db') . ',
' . PMA_backquote('table') . ',
' . PMA_backquote('sqlquery') . '
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
WHERE username = \'' . PMA_sqlAddslashes($username) . '\'
ORDER BY id DESC';
 
$hist_rs = PMA_query_as_cu($hist_query);
unset($hist_query);
 
$history = array();
 
while ($row = PMA_DBI_fetch_assoc($hist_rs)) {
$history[] = $row;
}
PMA_DBI_free_result($hist_rs);
 
return $history;
 
} // end of 'PMA_getHistory()' function
 
/**
* Set a SQL history entry
*
* @param string the name of the db
* @param string the name of the table
* @param string the username
* @param string the sql query
*
* @global array the list of relations settings
* @global array global phpMyAdmin configuration
*
* @return boolean true
*
* @access public
*/
function PMA_purgeHistory($username) {
global $cfgRelation, $cfg;
 
$purge_query = '
SELECT timevalue
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
WHERE username = \'' . PMA_sqlAddSlashes($username) . '\'
ORDER BY timevalue DESC LIMIT ' . $cfg['QueryHistoryMax'] . ', 1';
$purge_rs = PMA_query_as_cu($purge_query);
$i = 0;
$row = PMA_DBI_fetch_row($purge_rs);
PMA_DBI_free_result($purge_rs);
 
if (is_array($row) && isset($row[0]) && $row[0] > 0) {
$maxtime = $row[0];
// quotes added around $maxtime to prevent a difficult to
// reproduce problem
$remove_rs = PMA_query_as_cu('
DELETE FROM
' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
WHERE timevalue <= \'' . $maxtime . '\'');
}
 
return true;
} // end of 'PMA_purgeHistory()' function
 
 
/**
* Prepares the dropdown for one mode
*
* @param array the keys and values for foreigns
* @param string the current data of the dropdown
* @param string the needed mode
*
* @global array global phpMyAdmin configuration
*
* @return array the <option value=""><option>s
*
* @access private
*/
function PMA_foreignDropdownBuild($foreign, $data, $mode) {
global $cfg;
 
$reloptions = array();
 
foreach ($foreign as $key => $value) {
 
if (PMA_strlen($value) <= $cfg['LimitChars']) {
$vtitle = '';
$value = htmlspecialchars($value);
} else {
$vtitle = htmlspecialchars($value);
$value = htmlspecialchars(substr($value, 0, $cfg['LimitChars']) . '...');
}
 
$reloption = ' <option value="' . htmlspecialchars($key) . '"';
if ($vtitle != '') {
$reloption .= ' title="' . $vtitle . '"';
}
 
if ((string) $key == (string) $data) {
$reloption .= ' selected="selected"';
}
 
if ($mode == 'content-id') {
$reloptions[] = $reloption . '>' . $value . '&nbsp;-&nbsp;' . htmlspecialchars($key) . '</option>' . "\n";
} else {
$reloptions[] = $reloption . '>' . htmlspecialchars($key) . '&nbsp;-&nbsp;' . $value . '</option>' . "\n";
}
} // end foreach
 
return $reloptions;
} // end of 'PMA_foreignDropdownBuild' function
 
/**
* Outputs dropdown with values of foreign fields
*
* @param string the query of the foreign keys
* @param string the foreign field
* @param string the foreign field to display
* @param string the current data of the dropdown
*
* @global array global phpMyAdmin configuration
*
* @return string the <option value=""><option>s
*
* @access public
*/
function PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, $max) {
global $cfg;
 
$foreign = array();
 
// collect the data
foreach ($disp as $relrow) {
$key = $relrow[$foreign_field];
 
// if the display field has been defined for this foreign table
if ($foreign_display) {
$value = $relrow[$foreign_display];
} else {
$value = '';
} // end if ($foreign_display)
 
$foreign[$key] = $value;
} // end foreach
 
// beginning of dropdown
$ret = '<option value=""></option>' . "\n";
 
// master array for dropdowns
$reloptions = array('content-id' => array(), 'id-content' => array());
 
// sort for id-content
if ($cfg['NaturalOrder']) {
uksort($foreign, 'strnatcasecmp');
} else {
ksort($foreign);
}
 
// build id-content dropdown
$reloptions['id-content'] = PMA_foreignDropdownBuild($foreign, $data, 'id-content');
 
// sort for content-id
if ($cfg['NaturalOrder']) {
natcasesort($foreign);
} else {
asort($foreign);
}
 
// build content-id dropdown
$reloptions['content-id'] = PMA_foreignDropdownBuild($foreign, $data, 'content-id');
 
 
// put the dropdown sections in correct order
 
$c = count($cfg['ForeignKeyDropdownOrder']);
if ($c == 2) {
$top = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]];
$bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][1]];
} elseif ($c == 1) {
$bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]];
$top = null;
} else {
$top = $reloptions['id-content'];
$bot = $reloptions['content-id'];
}
$str_bot = implode('', $bot);
if ($top !== null) {
$str_top = implode('', $top);
$top_count = count($top);
if ($max == -1 || $top_count < $max) {
$ret .= $str_top;
if ($top_count > 0) {
$ret .= ' <option value=""></option>' . "\n";
$ret .= ' <option value=""></option>' . "\n";
}
}
}
$ret .= $str_bot;
 
return $ret;
} // end of 'PMA_foreignDropdown()' function
 
?>
/Web/Maintenance/phpMyAdmin/libraries/relation_cleanup.lib.php
0,0 → 1,141
<?php
/* $Id: relation_cleanup.lib.php,v 2.4 2005/12/17 17:36:58 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Set of functions used for cleaning up phpMyAdmin tables
*/
 
 
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
 
function PMA_relationsCleanupColumn($db, $table, $column) {
global $cfgRelation;
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND display_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND master_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
 
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND foreign_field = \'' . PMA_sqlAddslashes(urldecode($column)) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
}
 
function PMA_relationsCleanupTable($db, $table) {
global $cfgRelation;
 
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
if ($cfgRelation['pdfwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
 
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND foreign_table = \'' . PMA_sqlAddslashes($table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
}
 
function PMA_relationsCleanupDatabase($db) {
global $cfgRelation;
 
if ($cfgRelation['commwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
if ($cfgRelation['bookmarkwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['bookmark'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
if ($cfgRelation['displaywork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
if ($cfgRelation['pdfwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
 
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
if ($cfgRelation['relwork']) {
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
 
$remove_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/sanitizing.lib.php
0,0 → 1,40
<?php
/* $Id: sanitizing.lib.php,v 2.2 2005/11/17 13:12:58 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Sanitizes $message, taking into account our special codes
* for formatting
*
* @param string the message
*
* @return string the sanitized message
*
* @access public
*/
function PMA_sanitize($message)
{
$replace_pairs = array(
'<' => '&lt;',
'>' => '&gt;',
'[i]' => '<em>', // deprecated by em
'[/i]' => '</em>', // deprecated by em
'[em]' => '<em>',
'[/em]' => '</em>',
'[b]' => '<strong>', // deprecated by strong
'[/b]' => '</strong>', // deprecated by strong
'[strong]' => '<strong>',
'[/strong]' => '</strong>',
'[tt]' => '<code>', // deprecated by CODE or KBD
'[/tt]' => '</code>', // deprecated by CODE or KBD
'[code]' => '<code>',
'[/code]' => '</code>',
'[kbd]' => '<kbd>',
'[/kbd]' => '</kbd>',
'[br]' => '<br />',
'[/a]' => '</a>',
);
return preg_replace('/\[a@([^"@]*)@([^]"]*)\]/', '<a href="\1" target="\2">', strtr($message, $replace_pairs));
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/select_lang.lib.php
0,0 → 1,423
<?php
/* $Id: select_lang.lib.php,v 2.36.2.2 2006/05/02 09:28:57 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* phpMyAdmin Language Loading File
*/
 
/**
* trys to find the language to use
*
* @uses $GLOBALS['cfg']['lang']
* @uses $GLOBALS['cfg']['DefaultLang']
* @uses $GLOBALS['lang_failed_cfg']
* @uses $GLOBALS['lang_failed_cookie']
* @uses $GLOBALS['lang_failed_request']
* @uses $_REQUEST['lang']
* @uses $_COOKIE['pma_lang']
* @uses $_SERVER['HTTP_ACCEPT_LANGUAGE']
* @uses $_SERVER['HTTP_USER_AGENT']
* @uses PMA_langSet()
* @uses PMA_langDetect()
* @uses explode()
* @return bool success if valid lang is found, otherwise false
*/
function PMA_langCheck()
{
// check forced language
if (! empty($GLOBALS['cfg']['Lang'])) {
if (PMA_langSet($GLOBALS['cfg']['Lang'])) {
return true;
} else {
$GLOBALS['lang_failed_cfg'] = $GLOBALS['cfg']['Lang'];
}
}
 
// check user requested language
if (! empty($_REQUEST['lang'])) {
if (PMA_langSet($_REQUEST['lang'])) {
return true;
} else {
$GLOBALS['lang_failed_request'] = $_REQUEST['lang'];
}
}
 
// check previous set language
if (! empty($_COOKIE['pma_lang'])) {
if (PMA_langSet($_COOKIE['pma_lang'])) {
return true;
} else {
$GLOBALS['lang_failed_cookie'] = $_COOKIE['pma_lang'];
}
}
 
// try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE variable
if (PMA_getenv('HTTP_ACCEPT_LANGUAGE')) {
foreach (explode(',', PMA_getenv('HTTP_ACCEPT_LANGUAGE')) as $lang) {
if (PMA_langDetect($lang, 1)) {
return true;
}
}
}
 
// try to findout user's language by checking its HTTP_USER_AGENT variable
if (PMA_langDetect(PMA_getenv('HTTP_USER_AGENT'), 2)) {
return true;
}
 
// Didn't catch any valid lang : we use the default settings
if (PMA_langSet($GLOBALS['cfg']['DefaultLang'])) {
return true;
}
 
return false;
}
 
/**
* checks given lang and sets it if valid
* returns true on success, otherwise flase
*
* @uses $GLOBALS['available_languages'] to check $lang
* @uses $GLOBALS['lang'] to set it
* @param string $lang language to set
* @return bool success
*/
function PMA_langSet(&$lang)
{
if (empty($lang) || empty($GLOBALS['available_languages'][$lang])) {
return false;
}
$GLOBALS['lang'] = $lang;
return true;
}
 
/**
* Analyzes some PHP environment variables to find the most probable language
* that should be used
*
* @param string string to analyze
* @param integer type of the PHP environment variable which value is $str
*
* @return bool true on success, otherwise false
*
* @global $available_languages
*
* @access private
*/
function PMA_langDetect(&$str, $envType)
{
if (empty($str)) {
return false;
}
if (empty($GLOBALS['available_languages'])) {
return false;
}
 
foreach ($GLOBALS['available_languages'] as $lang => $value) {
// $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,
// 2 for the 'HTTP_USER_AGENT' one
$expr = $value[0];
if (strpos($expr, '[-_]') === FALSE) {
$expr = str_replace('|', '([-_][[:alpha:]]{2,3})?|', $expr);
}
if (($envType == 1 && eregi('^(' . $expr . ')(;q=[0-9]\\.[0-9])?$', $str))
|| ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $expr . ')(;|\]|\))', $str))) {
if (PMA_langSet($lang)) {
return true;
}
}
}
 
return false;
} // end of the 'PMA_langDetect()' function
 
/**
* @var string path to the translations directory
*/
$lang_path = './lang/';
 
/**
* first check for lang dir exists
*/
if (! is_dir($lang_path)) {
// language directory not found
trigger_error('phpMyAdmin-ERROR: path not found: '
. $lang_path . ', check your language directory.',
E_USER_WARNING);
// and tell the user
PMA_sendHeaderLocation('error.php?error='
. urlencode( 'path to languages is invalid: ' . $lang_path));
// stop execution
exit;
}
 
/**
* @var string interface language
*/
$GLOBALS['lang'] = '';
/**
* @var boolean wether loading lang from cfg failed
*/
$lang_failed_cfg = false;
/**
* @var boolean wether loading lang from cookie failed
*/
$lang_failed_cookie = false;
/**
* @var boolean wether loading lang from user request failed
*/
$lang_failed_request = false;
 
 
/**
* All the supported languages have to be listed in the array below.
* 1. The key must be the "official" ISO 639 language code and, if required,
* the dialect code. It can also contain some informations about the
* charset (see the Russian case).
* 2. The first of the values associated to the key is used in a regular
* expression to find some keywords corresponding to the language inside two
* environment variables.
* These values contains:
* - the "official" ISO language code and, if required, the dialect code
* also ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French
* dialects, 'zh[-_]tw' for Chinese traditional...), the dialect has to
* be specified as first;
* - the '|' character (it means 'OR');
* - the full language name.
* 3. The second values associated to the key is the name of the file to load
* without the 'inc.php' extension.
* 4. The third values associated to the key is the language code as defined by
* the RFC1766.
* 5. The fourth value is native name in html entities.
*
* Beware that the sorting order (first values associated to keys by
* alphabetical reverse order in the array) is important: 'zh-tw' (chinese
* traditional) must be detected before 'zh' (chinese simplified) for
* example.
*
* When there are more than one charset for a language, we put the -utf-8
* last because we need the default charset to be non-utf-8 to avoid
* problems on MySQL < 4.1.x if AllowAnywhereRecoding is FALSE.
*
* For Russian, we put 1251 first, because MSIE does not accept 866
* and users would not see anything.
*/
$available_languages = array(
'af-iso-8859-1' => array('af|afrikaans', 'afrikaans-iso-8859-1', 'af', ''),
'af-utf-8' => array('af|afrikaans', 'afrikaans-utf-8', 'af', ''),
'ar-win1256' => array('ar|arabic', 'arabic-windows-1256', 'ar', '&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;'),
'ar-utf-8' => array('ar|arabic', 'arabic-utf-8', 'ar', '&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;'),
'az-iso-8859-9' => array('az|azerbaijani', 'azerbaijani-iso-8859-9', 'az', 'Az&#601;rbaycanca'),
'az-utf-8' => array('az|azerbaijani', 'azerbaijani-utf-8', 'az', 'Az&#601;rbaycanca'),
 
'becyr-win1251' => array('be|belarusian', 'belarusian_cyrillic-windows-1251', 'be', '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103;'),
'becyr-utf-8' => array('be|belarusian', 'belarusian_cyrillic-utf-8', 'be', '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103;'),
'belat-utf-8' => array('be[-_]lat|belarusian latin', 'belarusian_latin-utf-8', 'be-lat', 'Byelorussian'),
'bg-win1251' => array('bg|bulgarian', 'bulgarian-windows-1251', 'bg', '&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;'),
'bg-koi8-r' => array('bg|bulgarian', 'bulgarian-koi8-r', 'bg', '&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;'),
'bg-utf-8' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg', '&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;'),
'bs-win1250' => array('bs|bosnian', 'bosnian-windows-1250', 'bs', 'Bosanski'),
'bs-utf-8' => array('bs|bosnian', 'bosnian-utf-8', 'bs', 'Bosanski'),
'ca-iso-8859-1' => array('ca|catalan', 'catalan-iso-8859-1', 'ca', 'Catal&agrave;'),
'ca-utf-8' => array('ca|catalan', 'catalan-utf-8', 'ca', 'Catal&agrave;'),
'cs-iso-8859-2' => array('cs|czech', 'czech-iso-8859-2', 'cs', '&#268;esky'),
'cs-win1250' => array('cs|czech', 'czech-windows-1250', 'cs', '&#268;esky'),
'cs-utf-8' => array('cs|czech', 'czech-utf-8', 'cs', '&#268;esky'),
'da-iso-8859-1' => array('da|danish', 'danish-iso-8859-1', 'da', 'Dansk'),
'da-utf-8' => array('da|danish', 'danish-utf-8', 'da', 'Dansk'),
'de-iso-8859-1' => array('de|german', 'german-iso-8859-1', 'de', 'Deutsch'),
'de-iso-8859-15' => array('de|german', 'german-iso-8859-15', 'de', 'Deutsch'),
'de-utf-8' => array('de|german', 'german-utf-8', 'de', 'Deutsch'),
'el-iso-8859-7' => array('el|greek', 'greek-iso-8859-7', 'el', '&Epsilon;&lambda;&lambda;&eta;&nu;&iota;&kappa;&#940;'),
'el-utf-8' => array('el|greek', 'greek-utf-8', 'el', '&Epsilon;&lambda;&lambda;&eta;&nu;&iota;&kappa;&#940;'),
'en-iso-8859-1' => array('en|english', 'english-iso-8859-1', 'en', ''),
'en-iso-8859-15' => array('en|english', 'english-iso-8859-15', 'en', ''),
'en-utf-8' => array('en|english', 'english-utf-8', 'en', ''),
'es-iso-8859-1' => array('es|spanish', 'spanish-iso-8859-1', 'es', 'Espa&ntilde;ol'),
'es-iso-8859-15' => array('es|spanish', 'spanish-iso-8859-15', 'es', 'Espa&ntilde;ol'),
'es-utf-8' => array('es|spanish', 'spanish-utf-8', 'es', 'Espa&ntilde;ol'),
'et-iso-8859-1' => array('et|estonian', 'estonian-iso-8859-1', 'et', 'Eesti'),
'et-utf-8' => array('et|estonian', 'estonian-utf-8', 'et', 'Eesti'),
'eu-iso-8859-1' => array('eu|basque', 'basque-iso-8859-1', 'eu', 'Euskara'),
'eu-utf-8' => array('eu|basque', 'basque-utf-8', 'eu', 'Euskara'),
'fa-win1256' => array('fa|persian', 'persian-windows-1256', 'fa', '&#1601;&#1575;&#1585;&#1587;&#1740;'),
'fa-utf-8' => array('fa|persian', 'persian-utf-8', 'fa', '&#1601;&#1575;&#1585;&#1587;&#1740;'),
'fi-iso-8859-1' => array('fi|finnish', 'finnish-iso-8859-1', 'fi', 'Suomi'),
'fi-iso-8859-15' => array('fi|finnish', 'finnish-iso-8859-15', 'fi', 'Suomi'),
'fi-utf-8' => array('fi|finnish', 'finnish-utf-8', 'fi', 'Suomi'),
'fr-iso-8859-1' => array('fr|french', 'french-iso-8859-1', 'fr', 'Fran&ccedil;ais'),
'fr-iso-8859-15' => array('fr|french', 'french-iso-8859-15', 'fr', 'Fran&ccedil;ais'),
'fr-utf-8' => array('fr|french', 'french-utf-8', 'fr', 'Fran&ccedil;ais'),
'gl-iso-8859-1' => array('gl|galician', 'galician-iso-8859-1', 'gl', 'Galego'),
'gl-utf-8' => array('gl|galician', 'galician-utf-8', 'gl', 'Galego'),
'he-iso-8859-8-i' => array('he|hebrew', 'hebrew-iso-8859-8-i', 'he', '&#1506;&#1489;&#1512;&#1497;&#1514;'),
'he-utf-8' => array('he|hebrew', 'hebrew-utf-8', 'he', '&#1506;&#1489;&#1512;&#1497;&#1514;'),
'hi-utf-8' => array('hi|hindi', 'hindi-utf-8', 'hi', '&#2361;&#2367;&#2344;&#2381;&#2342;&#2368;'),
'hr-win1250' => array('hr|croatian', 'croatian-windows-1250', 'hr', 'Hrvatski'),
'hr-iso-8859-2' => array('hr|croatian', 'croatian-iso-8859-2', 'hr', 'Hrvatski'),
'hr-utf-8' => array('hr|croatian', 'croatian-utf-8', 'hr', 'Hrvatski'),
'hu-iso-8859-2' => array('hu|hungarian', 'hungarian-iso-8859-2', 'hu', 'Magyar'),
'hu-utf-8' => array('hu|hungarian', 'hungarian-utf-8', 'hu', 'Magyar'),
'id-iso-8859-1' => array('id|indonesian', 'indonesian-iso-8859-1', 'id', 'Bahasa Indonesia'),
'id-utf-8' => array('id|indonesian', 'indonesian-utf-8', 'id', 'Bahasa Indonesia'),
'it-iso-8859-1' => array('it|italian', 'italian-iso-8859-1', 'it', 'Italiano'),
'it-iso-8859-15' => array('it|italian', 'italian-iso-8859-15', 'it', 'Italiano'),
'it-utf-8' => array('it|italian', 'italian-utf-8', 'it', 'Italiano'),
'ja-euc' => array('ja|japanese', 'japanese-euc', 'ja', '&#26085;&#26412;&#35486;'),
'ja-sjis' => array('ja|japanese', 'japanese-sjis', 'ja', '&#26085;&#26412;&#35486;'),
'ja-utf-8' => array('ja|japanese', 'japanese-utf-8', 'ja', '&#26085;&#26412;&#35486;'),
'ko-euc-kr' => array('ko|korean', 'korean-euc-kr', 'ko', '&#54620;&#44397;&#50612;'),
'ko-utf-8' => array('ko|korean', 'korean-utf-8', 'ko', '&#54620;&#44397;&#50612;'),
'ka-utf-8' => array('ka|georgian', 'georgian-utf-8', 'ka', '&#4325;&#4304;&#4320;&#4311;&#4323;&#4314;&#4312;'),
'lt-win1257' => array('lt|lithuanian', 'lithuanian-windows-1257', 'lt', 'Lietuvi&#371;'),
'lt-utf-8' => array('lt|lithuanian', 'lithuanian-utf-8', 'lt', 'Lietuvi&#371;'),
'lv-win1257' => array('lv|latvian', 'latvian-windows-1257', 'lv', 'Latvie&scaron;u'),
'lv-utf-8' => array('lv|latvian', 'latvian-utf-8', 'lv', 'Latvie&scaron;u'),
'mn-utf-8' => array('mn|mongolian', 'mongolian-utf-8', 'mn', '&#1052;&#1086;&#1085;&#1075;&#1086;&#1083;'),
'ms-iso-8859-1' => array('ms|malay', 'malay-iso-8859-1', 'ms', 'Bahasa Melayu'),
'ms-utf-8' => array('ms|malay', 'malay-utf-8', 'ms', 'Bahasa Melayu'),
'nl-iso-8859-1' => array('nl|dutch', 'dutch-iso-8859-1', 'nl', 'Nederlands'),
'nl-iso-8859-15' => array('nl|dutch', 'dutch-iso-8859-15', 'nl', 'Nederlands'),
'nl-utf-8' => array('nl|dutch', 'dutch-utf-8', 'nl', 'Nederlands'),
'no-iso-8859-1' => array('no|norwegian', 'norwegian-iso-8859-1', 'no', 'Norsk'),
'no-utf-8' => array('no|norwegian', 'norwegian-utf-8', 'no', 'Norsk'),
'pl-iso-8859-2' => array('pl|polish', 'polish-iso-8859-2', 'pl', 'Polski'),
'pl-win1250' => array('pl|polish', 'polish-windows-1250', 'pl', 'Polski'),
'pl-utf-8' => array('pl|polish', 'polish-utf-8', 'pl', 'Polski'),
'ptbr-iso-8859-1' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-iso-8859-1', 'pt-BR', 'Portugu&ecirc;s'),
'ptbr-utf-8' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-utf-8', 'pt-BR', 'Portugu&ecirc;s'),
'pt-iso-8859-1' => array('pt|portuguese', 'portuguese-iso-8859-1', 'pt', 'Portugu&ecirc;s'),
'pt-iso-8859-15' => array('pt|portuguese', 'portuguese-iso-8859-15', 'pt', 'Portugu&ecirc;s'),
'pt-utf-8' => array('pt|portuguese', 'portuguese-utf-8', 'pt', 'Portugu&ecirc;s'),
'ro-iso-8859-1' => array('ro|romanian', 'romanian-iso-8859-1', 'ro', 'Rom&acirc;n&#259;'),
'ro-utf-8' => array('ro|romanian', 'romanian-utf-8', 'ro', 'Rom&acirc;n&#259;'),
'ru-win1251' => array('ru|russian', 'russian-windows-1251', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
'ru-cp-866' => array('ru|russian', 'russian-cp-866', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
'ru-koi8-r' => array('ru|russian', 'russian-koi8-r', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
'ru-utf-8' => array('ru|russian', 'russian-utf-8', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
'sk-iso-8859-2' => array('sk|slovak', 'slovak-iso-8859-2', 'sk', 'Sloven&#269;ina'),
'sk-win1250' => array('sk|slovak', 'slovak-windows-1250', 'sk', 'Sloven&#269;ina'),
'sk-utf-8' => array('sk|slovak', 'slovak-utf-8', 'sk', 'Sloven&#269;ina'),
'sl-iso-8859-2' => array('sl|slovenian', 'slovenian-iso-8859-2', 'sl', 'Sloven&scaron;&#269;ina'),
'sl-win1250' => array('sl|slovenian', 'slovenian-windows-1250', 'sl', 'Sloven&scaron;&#269;ina'),
'sl-utf-8' => array('sl|slovenian', 'slovenian-utf-8', 'sl', 'Sloven&scaron;&#269;ina'),
'sq-iso-8859-1' => array('sq|albanian', 'albanian-iso-8859-1', 'sq', 'Shqip'),
'sq-utf-8' => array('sq|albanian', 'albanian-utf-8', 'sq', 'Shqip'),
'srlat-win1250' => array('sr[-_]lat|serbian latin', 'serbian_latin-windows-1250', 'sr-lat', 'Srpski'),
'srlat-utf-8' => array('sr[-_]lat|serbian latin', 'serbian_latin-utf-8', 'sr-lat', 'Srpski'),
'srcyr-win1251' => array('sr|serbian', 'serbian_cyrillic-windows-1251', 'sr', '&#1057;&#1088;&#1087;&#1089;&#1082;&#1080;'),
'srcyr-utf-8' => array('sr|serbian', 'serbian_cyrillic-utf-8', 'sr', '&#1057;&#1088;&#1087;&#1089;&#1082;&#1080;'),
'sv-iso-8859-1' => array('sv|swedish', 'swedish-iso-8859-1', 'sv', 'Svenska'),
'sv-utf-8' => array('sv|swedish', 'swedish-utf-8', 'sv', 'Svenska'),
'th-tis-620' => array('th|thai', 'thai-tis-620', 'th', '&#3616;&#3634;&#3625;&#3634;&#3652;&#3607;&#3618;'),
'th-utf-8' => array('th|thai', 'thai-utf-8', 'th', '&#3616;&#3634;&#3625;&#3634;&#3652;&#3607;&#3618;'),
'tr-iso-8859-9' => array('tr|turkish', 'turkish-iso-8859-9', 'tr', 'T&uuml;rk&ccedil;e'),
'tr-utf-8' => array('tr|turkish', 'turkish-utf-8', 'tr', 'T&uuml;rk&ccedil;e'),
'tt-iso-8859-9' => array('tt|tatarish', 'tatarish-iso-8859-9', 'tt', 'Tatar'),
'tt-utf-8' => array('tt|tatarish', 'tatarish-utf-8', 'tt', 'Tatar'),
'uk-win1251' => array('uk|ukrainian', 'ukrainian-windows-1251', 'uk', '&#1059;&#1082;&#1088;&#1072;&#1111;&#1085;&#1089;&#1100;&#1082;&#1072;'),
'uk-utf-8' => array('uk|ukrainian', 'ukrainian-utf-8', 'uk', '&#1059;&#1082;&#1088;&#1072;&#1111;&#1085;&#1089;&#1100;&#1082;&#1072;'),
'zhtw-big5' => array('zh[-_](tw|hk)|chinese traditional', 'chinese_traditional-big5', 'zh-TW', '&#20013;&#25991;'),
'zhtw-utf-8' => array('zh[-_](tw|hk)|chinese traditional', 'chinese_traditional-utf-8', 'zh-TW', '&#20013;&#25991;'),
'zh-gb2312' => array('zh|chinese simplified', 'chinese_simplified-gb2312', 'zh', '&#20013;&#25991;'),
'zh-utf-8' => array('zh|chinese simplified', 'chinese_simplified-utf-8', 'zh', '&#20013;&#25991;'),
);
 
// Language filtering support
if (! empty($GLOBALS['cfg']['FilterLanguages'])) {
$new_lang = array();
foreach ($available_languages as $key => $val) {
if (preg_match('@' . $GLOBALS['cfg']['FilterLanguages'] . '@', $key)) {
$new_lang[$key] = $val;
}
}
if (count($new_lang) > 0) {
$available_languages = $new_lang;
}
unset($key, $val, $new_lang);
}
 
/**
* check for language files
*/
foreach ($available_languages as $each_lang_key => $each_lang) {
if (! file_exists($lang_path . $each_lang[1] . '.inc.php')) {
unset($available_languages[$each_lang_key]);
}
}
unset($each_lang_key, $each_lang);
 
// MySQL charsets map
$mysql_charset_map = array(
'big5' => 'big5',
'cp-866' => 'cp866',
'euc-jp' => 'ujis',
'euc-kr' => 'euckr',
'gb2312' => 'gb2312',
'gbk' => 'gbk',
'iso-8859-1' => 'latin1',
'iso-8859-2' => 'latin2',
'iso-8859-7' => 'greek',
'iso-8859-8' => 'hebrew',
'iso-8859-8-i' => 'hebrew',
'iso-8859-9' => 'latin5',
'iso-8859-13' => 'latin7',
'iso-8859-15' => 'latin1',
'koi8-r' => 'koi8r',
'shift_jis' => 'sjis',
'tis-620' => 'tis620',
'utf-8' => 'utf8',
'windows-1250' => 'cp1250',
'windows-1251' => 'cp1251',
'windows-1252' => 'latin1',
'windows-1256' => 'cp1256',
'windows-1257' => 'cp1257',
);
 
/**
* Do the work!
*/
// Checks whether charset recoding should be allowed or not
$allow_recoding = FALSE; // Default fallback value
if (empty($convcharset)) {
if (isset($_COOKIE['pma_charset'])) {
$convcharset = $_COOKIE['pma_charset'];
} else {
$convcharset = $GLOBALS['cfg']['DefaultCharset'];
}
}
 
if (! PMA_langCheck()) {
// fallback language
$fall_back_lang = 'en-utf-8'; $line = __LINE__;
if (! PMA_langSet($fall_back_lang)) {
trigger_error('phpMyAdmin-ERROR: invalid lang code: '
. __FILE__ . '#' . $line . ', check hard coded fall back language.',
E_USER_WARNING);
// stop execution
// and tell the user that his choosen language is invalid
PMA_sendHeaderLocation('error.php?error='
. urlencode('Could not load any language, please check your language settings and folder'));
exit;
}
}
 
// Defines the associated filename and load the translation
$lang_file = $lang_path . $available_languages[$GLOBALS['lang']][1] . '.inc.php';
require_once($lang_file);
 
// now, that we have loaded the language strings we can send the errors
if ($lang_failed_cfg) {
$GLOBALS['PMA_errors'][] = sprintf($strLanguageUnknown, htmlspecialchars($lang_failed_cfg));
}
if ($lang_failed_cookie) {
$GLOBALS['PMA_errors'][] = sprintf($strLanguageUnknown, htmlspecialchars($lang_failed_cookie));
}
if ($lang_failed_request) {
$GLOBALS['PMA_errors'][] = sprintf($strLanguageUnknown, htmlspecialchars($lang_failed_request));
}
 
unset($lang_file, $lang_path, $strLanguageFileNotFound, $line, $fall_back_lang,
$lang_failed_cfg, $lang_failed_cookie, $lang_failed_request, $strLanguageUnknown);
?>
/Web/Maintenance/phpMyAdmin/libraries/select_server.lib.php
0,0 → 1,117
<?php
/*
* Code for displaying server selection written by nijel
* $Id: select_server.lib.php,v 2.10.2.3 2006/02/17 09:46:49 cybot_tm Exp $
*/
 
/**
* display server selection in list or selectbox form, or option tags only
*
* @todo make serverlist a real html-list
* @globals $lang
* @globals $convcharset
* @uses $GLOBALS['cfg']['DisplayServersList']
* @uses $GLOBALS['strServer']
* @uses $GLOBALS['cfg']['Servers']
* @uses $GLOBALS['strGo']
* @uses implode()
* @uses htmlspecialchars()
* @param boolean $not_only_options whether to include form tags or not
* @param boolean $ommit_fieldset whether to ommit fieldset tag or not
*/
function PMA_select_server($not_only_options, $ommit_fieldset)
{
global $lang, $convcharset;
 
// Show as list?
if ($not_only_options) {
$list = $GLOBALS['cfg']['DisplayServersList'];
$not_only_options =! $list;
} else {
$list = false;
}
 
if ($not_only_options) {
echo '<form method="post" action="index.php" target="_parent">';
 
if (! $ommit_fieldset) {
echo '<fieldset>';
}
echo '<label for="select_server">' . $GLOBALS['strServer'] . ':</label> ';
 
echo '<select name="server" id="select_server"'
. ' onchange="if (this.value != \'\') this.form.submit();">';
// TODO FIXME replace with $GLOBALS['strServers']
echo '<option value="">(' . $GLOBALS['strServer'] . ') ...</option>' . "\n";
} elseif ($list) {
echo $GLOBALS['strServer'] . ':<br />';
// TODO FIXME display server list as 'list'
// echo '<ol>';
}
 
foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
if (empty($server['host'])) {
continue;
}
 
if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
$selected = 1;
} else {
$selected = 0;
}
 
if (!empty($server['verbose'])) {
$label = $server['verbose'];
} else {
$label = $server['host'];
if (!empty($server['port'])) {
$label .= ':' . $server['port'];
}
}
// loic1: if 'only_db' is an array and there is more than one
// value, displaying such informations may not be a so good
// idea
if (!empty($server['only_db'])) {
// TODO FIXME this can become a really big/long/wide selectbox ...
$label .= ' - ' . (is_array($server['only_db']) ? implode(', ', $server['only_db']) : $server['only_db']);
}
if (!empty($server['user']) && $server['auth_type'] == 'config') {
$label .= ' (' . $server['user'] . ')';
}
 
if ($list) {
// TODO FIXME display server list as 'list'
// echo '<li>';
if ($selected && !$ommit_fieldset) {
echo '&raquo; <b>' . htmlspecialchars($label) . '</b><br />';
} else {
echo '&raquo; <a class="item" href="index.php?server=' . $key . '&amp;lang=' . $lang . '&amp;convcharset=' . $convcharset . '" target="_top">' . htmlspecialchars($label) . '</a><br />';
}
// echo '</li>';
} else {
echo ' <option value="' . $key . '" ' . ($selected ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>' . "\n";
}
} // end while
 
if ($not_only_options) {
echo '</select>';
if ($ommit_fieldset) {
echo '<hr />';
} else {
echo '</fieldset>';
}
?>
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
<?php
// Show submit button if we have just one server (this happens with no default)
echo '<noscript>';
echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
echo '</noscript>';
echo '</form>';
} elseif ($list) {
// TODO FIXME display server list as 'list'
// echo '</ol>';
}
}
?>
/Web/Maintenance/phpMyAdmin/libraries/server_common.inc.php
0,0 → 1,66
<?php
/* $Id: server_common.inc.php,v 1.4 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Gets some core libraries
*/
require_once('./libraries/common.lib.php');
 
/**
* Handles some variables that may have been sent by the calling script
* Note: this can be called also from the db panel to get the privileges of
* a db, in which case we want to keep displaying the tabs of
* the Database panel
*/
if (empty($viewing_mode)) {
unset($db, $table);
}
 
/**
* Set parameters for links
*/
$url_query = PMA_generate_common_url((isset($db) ? $db : ''));
 
/**
* Defines the urls to return to in case of error in a sql statement
*/
$err_url = 'main.php' . $url_query;
 
/**
* Displays the headers
*/
require_once('./libraries/header.inc.php');
 
/**
* Checks for superuser privileges
*/
// We were checking privileges with 'USE mysql' but users with the global
// priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
// (even if they cannot see the tables)
 
$is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user');
 
// now, select the mysql db
if ($is_superuser) {
PMA_DBI_free_result($is_superuser);
PMA_DBI_select_db('mysql', $userlink);
$is_superuser = TRUE;
} else {
$is_superuser = FALSE;
}
 
$has_binlogs = FALSE;
$binlogs = PMA_DBI_try_query('SHOW MASTER LOGS', null, PMA_DBI_QUERY_STORE);
if ($binlogs) {
if (PMA_DBI_num_rows($binlogs) > 0) {
$binary_logs = array();
while ($row = PMA_DBI_fetch_array($binlogs)) {
$binary_logs[] = $row[0];
}
$has_binlogs = TRUE;
}
PMA_DBI_free_result($binlogs);
}
unset($binlogs);
?>
/Web/Maintenance/phpMyAdmin/libraries/server_links.inc.php
0,0 → 1,92
<?php
/* $Id: server_links.inc.php,v 1.1 2005/11/24 08:29:44 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// Check parameters
 
require_once('./libraries/common.lib.php');
require_once('./libraries/server_common.inc.php');
 
PMA_checkParameters(array('is_superuser', 'url_query'), TRUE, FALSE);
 
/**
* Counts amount of navigation tabs
*/
$server_links_count_tabs = 0;
 
 
/**
* Put something in $sub_part
*/
if (!isset($sub_part)) {
$sub_part = '';
}
 
 
/**
* Displays tab links
*/
$tabs = array();
 
$tabs['databases']['icon'] = 's_db.png';
$tabs['databases']['link'] = 'server_databases.php';
$tabs['databases']['text'] = $strDatabases;
 
$tabs['sql']['icon'] = 'b_sql.png';
$tabs['sql']['link'] = 'server_sql.php';
$tabs['sql']['text'] = $strSQL;
 
$tabs['status']['icon'] = 's_status.png';
$tabs['status']['link'] = 'server_status.php';
$tabs['status']['text'] = $strStatus;
 
$tabs['vars']['icon'] = 's_vars.png';
$tabs['vars']['link'] = 'server_variables.php';
$tabs['vars']['text'] = $strServerTabVariables;
 
if (PMA_MYSQL_INT_VERSION >= 40100) {
$tabs['charset']['icon'] = 's_asci.png';
$tabs['charset']['link'] = 'server_collations.php';
$tabs['charset']['text'] = $strCharsets;
}
 
$tabs['engine']['icon'] = 'b_engine.png';
$tabs['engine']['link'] = 'server_engines.php';
$tabs['engine']['text'] = $strEngines;
 
if ($is_superuser) {
$tabs['rights']['icon'] = 's_rights.png';
$tabs['rights']['link'] = 'server_privileges.php';
$tabs['rights']['text'] = $strPrivileges;
}
if ($has_binlogs) {
$tabs['binlog']['icon'] = 's_tbl.png';
$tabs['binlog']['link'] = 'server_binlog.php';
$tabs['binlog']['text'] = $strBinaryLog;
}
$tabs['process']['icon'] = 's_process.png';
$tabs['process']['link'] = 'server_processlist.php';
$tabs['process']['text'] = $strServerTabProcesslist;
 
$tabs['export']['icon'] = 'b_export.png';
$tabs['export']['link'] = 'server_export.php';
$tabs['export']['text'] = $strExport;
 
$tabs['import']['icon'] = 'b_import.png';
$tabs['import']['link'] = 'server_import.php';
$tabs['import']['text'] = $strImport;
 
echo PMA_getTabs( $tabs );
unset( $tabs );
 
 
/**
* Displays a message
*/
if (!empty($message)) {
PMA_showMessage($message);
unset($message);
}
 
?>
<br />
/Web/Maintenance/phpMyAdmin/libraries/session.inc.php
0,0 → 1,129
<?php
/* $Id: session.inc.php,v 2.8.2.4 2006/05/12 15:26:16 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* session handling
*
* @TODO add failover or warn if sessions are not configured properly
* @TODO add an option to use mm-module for session handler
* @see http://www.php.net/session
* @uses session_name()
* @uses session_start()
* @uses ini_set()
* @uses version_compare()
* @uses PHP_VERSION
*/
 
// verify if PHP supports session, die if it does not
 
if (!@function_exists('session_name')) {
$cfg = array('DefaultLang' => 'en-iso-8859-1',
'AllowAnywhereRecoding' => false);
// Loads the language file
require_once('./libraries/select_lang.lib.php');
// Displays the error message
// (do not use &amp; for parameters sent by header)
header('Location: error.php'
. '?lang=' . urlencode($available_languages[$lang][2])
. '&char=' . urlencode($charset)
. '&dir=' . urlencode($text_dir)
. '&type=' . urlencode($strError)
. '&error=' . urlencode(sprintf($strCantLoad, 'session')));
exit();
} elseif (ini_get('session.auto_start') == true && session_name() != 'phpMyAdmin') {
/* $cfg = array('DefaultLang' => 'en-iso-8859-1',
'AllowAnywhereRecoding' => false);
// Loads the language file
require_once('./libraries/select_lang.lib.php');
// Displays the error message
// (do not use &amp; for parameters sent by header)
// TODO FIXME replace with locale string
$strSessionAutostartError = 'phpMyAdmin cannot run with'
. ' [a@http://php.net/session#ini.session.auto-start@php]session.auto_start[/a]'
. ' enabled. Check your php configuration.';
header('Location: error.php'
. '?lang=' . urlencode('en') //($available_languages[$lang][2])
. '&char=' . urlencode($charset)
. '&dir=' . urlencode('ltr') //($text_dir)
. '&type=' . urlencode('Error') //($strError)
. '&error=' . urlencode($strSessionAutostartError));
exit();
*/
$_SESSION = array();
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
session_unset();
@session_destroy();
}
 
// disable starting of sessions before all settings are done
// does not work, besides how it is written in php manual
//ini_set('session.auto_start', 0);
 
// session cookie settings
session_set_cookie_params(0, PMA_Config::getCookiePath(),
'', PMA_Config::isHttps());
 
// cookies are safer
ini_set('session.use_cookies', true);
 
// but not all user allow cookies
ini_set('session.use_only_cookies', false);
ini_set('session.use_trans_sid', true);
ini_set('url_rewriter.tags',
'a=href,frame=src,input=src,form=fakeentry,fieldset=');
//ini_set('arg_separator.output', '&amp;');
 
// delete session/cookies when browser is closed
ini_set('session.cookie_lifetime', 0);
 
// warn but dont work with bug
ini_set('session.bug_compat_42', false);
ini_set('session.bug_compat_warn', true);
 
// use more secure session ids (with PHP 5)
if (version_compare(PHP_VERSION, '5.0.0', 'ge')
&& substr(PHP_OS, 0, 3) != 'WIN') {
ini_set('session.hash_function', 1);
ini_set('session.hash_bits_per_character', 6);
}
 
// start the session
// on some servers (for example, sourceforge.net), we get a permission error
// on the session data directory, so I add some "@"
 
// [2006-01-25] Nicola Asuni - www.tecnick.com: maybe the PHP directive
// session.save_handler is set to another value like "user"
ini_set('session.save_handler', 'files');
 
@session_name('phpMyAdmin');
@session_start();
 
/**
* Token which is used for authenticating access queries.
*/
if (!isset($_SESSION['PMA_token'])) {
$_SESSION['PMA_token'] = md5(uniqid(rand(), true));
}
 
/**
* trys to secure session from hijacking and fixation
* should be called before login and after successfull login
* (only required if sensitive information stored in session)
*
* @uses session_regenerate_id() to secure session from fixation
* @uses session_id() to set new session id
* @uses strip_tags() to prevent XSS attacks in SID
* @uses function_exists() for session_regenerate_id()
*/
function PMA_secureSession()
{
// prevent session fixation and XSS
if (function_exists('session_regenerate_id')) {
session_regenerate_id(true);
} else {
session_id(strip_tags(session_id()));
}
}
?>
/Web/Maintenance/phpMyAdmin/libraries/sql_query_form.lib.php
0,0 → 1,543
<?php
/* $Id: sql_query_form.lib.php,v 1.29.2.1 2006/02/18 13:54:37 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* functions for displaying the sql query form
*
* @usedby server_sql.php
* @usedby db_details.php
* @usedby tbl_properties.php
* @usedby tbl_properties_structure.php
* @usedby querywindow.php
*/
 
require_once './libraries/file_listing.php'; // used for file listing
require_once './libraries/bookmark.lib.php'; // used for file listing
 
/**
* prints the sql query boxes
*
* @usedby server_sql.php
* @usedby db_details.php
* @usedby tbl_properties.php
* @usedby tbl_properties_structure.php
* @usedby querywindow.php
* @uses $GLOBALS['table']
* @uses $GLOBALS['db']
* @uses $GLOBALS['server']
* @uses $GLOBALS['goto']
* @uses $GLOBALS['is_upload'] from common.lib.php
* @uses $GLOBALS['sql_query'] from grab_globals.lib.php
* @uses $GLOBALS['cfg']['DefaultQueryTable']
* @uses $GLOBALS['cfg']['DefaultQueryDatabase']
* @uses $GLOBALS['cfg']['Servers']
* @uses $GLOBALS['cfg']['DefaultTabDatabase']
* @uses $GLOBALS['cfg']['DefaultQueryDatabase']
* @uses $GLOBALS['cfg']['DefaultQueryTable']
* @uses $GLOBALS['cfg']['Bookmark']['db']
* @uses $GLOBALS['cfg']['Bookmark']['table']
* @uses $GLOBALS['strSuccess']
* @uses PMA_generate_common_url()
* @uses PMA_backquote()
* @uses PMA_DBI_fetch_result()
* @uses PMA_showMySQLDocu()
* @uses PMA_generate_common_hidden_inputs()
* @uses PMA_sqlQueryFormBookmark()
* @uses PMA_sqlQueryFormInsert()
* @uses PMA_sqlQueryFormUpload()
* @uses PMA_DBI_QUERY_STORE
* @uses PMA_set_enc_form()
* @uses sprintf()
* @uses htmlspecialchars()
* @uses str_replace()
* @uses md5()
* @uses function_exists()
* @param boolean|string $query query to display in the textarea
* or true to display last executed
* @param boolean|string $display_tab sql|files|history|full|FALSE
* what part to display
* false if not inside querywindow
*/
function PMA_sqlQueryForm($query = true, $display_tab = false)
{
// check tab to display if inside querywindow
if (! $display_tab) {
$display_tab = 'full';
$is_querywindow = false;
} else {
$is_querywindow = true;
}
 
// query to show
if (true === $query) {
$query = empty($GLOBALS['sql_query']) ? '' : $GLOBALS['sql_query'];
}
 
// set enctype to multipart for file uploads
if ($GLOBALS['is_upload']) {
$enctype = ' enctype="multipart/form-data"';
} else {
$enctype = '';
}
 
$table = '';
$db = '';
if (! isset($GLOBALS['db']) || ! strlen($GLOBALS['db'])) {
// prepare for server related
$goto = empty($GLOBALS['goto']) ?
'server_sql.php' : $GLOBALS['goto'];
} elseif (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) {
// prepare for db related
$db = $GLOBALS['db'];
$goto = empty($GLOBALS['goto']) ?
'db_details.php' : $GLOBALS['goto'];
} else {
$table = $GLOBALS['table'];
$db = $GLOBALS['db'];
$goto = empty($GLOBALS['goto']) ?
'tbl_properties.php' : $GLOBALS['goto'];
}
 
 
// start output
if ($is_querywindow) {
?>
<form method="post" id="sqlqueryform" target="frame_content"
action="import.php"<?php echo $enctype; ?> name="sqlform"
onsubmit="var save_name = window.opener.parent.frames[1].name;
window.opener.parent.frames[1].name = save_name + '<?php echo time(); ?>';
this.target = window.opener.parent.frames[1].name;
return checkSqlQuery( this );" >
<?php
} else {
echo '<form method="post" action="import.php" ' . $enctype . ' id="sqlqueryform"'
.' onsubmit="return checkSqlQuery(this)" name="sqlform">' . "\n";
}
 
if ($is_querywindow) {
echo '<input type="hidden" name="focus_querywindow" value="true" />'
."\n";
if ($display_tab != 'sql' && $display_tab != 'full') {
echo '<input type="hidden" name="sql_query" value="" />' . "\n";
echo '<input type="hidden" name="show_query" value="1" />' . "\n";
}
}
echo '<input type="hidden" name="is_js_confirmed" value="0" />' . "\n"
.PMA_generate_common_hidden_inputs($db, $table) . "\n"
.'<input type="hidden" name="pos" value="0" />' . "\n"
.'<input type="hidden" name="goto" value="'
.htmlspecialchars($goto) . '" />' . "\n"
.'<input type="hidden" name="zero_rows" value="'
. htmlspecialchars($GLOBALS['strSuccess']) . '" />' . "\n"
.'<input type="hidden" name="prev_sql_query" value="'
. htmlspecialchars($query) . '" />' . "\n";
 
// display querybox
if ($display_tab === 'full' || $display_tab === 'sql') {
PMA_sqlQueryFormInsert($query, $is_querywindow);
}
 
// display uploads
if ($display_tab === 'files' && $GLOBALS['is_upload']) {
PMA_sqlQueryFormUpload();
}
 
// Bookmark Support
if ($display_tab === 'full' || $display_tab === 'history') {
if (! empty( $GLOBALS['cfg']['Bookmark'])
&& $GLOBALS['cfg']['Bookmark']['db']
&& $GLOBALS['cfg']['Bookmark']['table']) {
PMA_sqlQueryFormBookmark();
}
}
 
// Encoding setting form appended by Y.Kawada
if (function_exists('PMA_set_enc_form')) {
echo PMA_set_enc_form(' ');
}
 
echo '</form>' . "\n";
}
 
/**
* prints querybox fieldset
*
* @usedby PMA_sqlQueryForm()
* @uses $GLOBALS['text_dir']
* @uses $GLOBALS['cfg']['TextareaAutoSelect']
* @uses $GLOBALS['cfg']['TextareaCols']
* @uses $GLOBALS['cfg']['TextareaRows']
* @uses $GLOBALS['strShowThisQuery']
* @uses $GLOBALS['strGo']
* @uses PMA_availableDatabases()
* @uses PMA_USR_OS
* @uses PMA_USR_BROWSER_AGENT
* @uses PMA_USR_BROWSER_VER
* @uses PMA_availableDatabases()
* @uses htmlspecialchars()
* @param string $query query to display in the textarea
* @param boolean $is_querywindow if inside querywindow or not
*/
function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false)
{
 
// enable auto select text in textarea
if ($GLOBALS['cfg']['TextareaAutoSelect']) {
$auto_sel = ' onfocus="selectContent( this, sql_box_locked, true )"';
} else {
$auto_sel = '';
}
 
// enable locking if inside query window
if ($is_querywindow) {
$locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].'
.'checked = true;"';
} else {
$locking = '';
}
 
$table = '';
$db = '';
$fields_list = array();
if (! isset($GLOBALS['db']) || ! strlen($GLOBALS['db'])) {
// prepare for server related
$legend = sprintf($GLOBALS['strRunSQLQueryOnServer'],
htmlspecialchars(
$GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']));
} elseif (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) {
// prepare for db related
$db = $GLOBALS['db'];
// if you want navigation:
$strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
. '?' . PMA_generate_common_url($db) . '"';
if ($is_querywindow) {
$strDBLink .= ' target="_self"'
. ' onclick="this.target=window.opener.frames[1].name"';
}
$strDBLink .= '>'
. htmlspecialchars($db) . '</a>';
// else use
// $strDBLink = htmlspecialchars($db);
$legend = sprintf($GLOBALS['strRunSQLQuery'], $strDBLink);
if (empty($query)) {
$query = str_replace('%d',
PMA_backquote($db), $GLOBALS['cfg']['DefaultQueryDatabase']);
}
} else {
$table = $GLOBALS['table'];
$db = $GLOBALS['db'];
// Get the list and number of fields
// we do a try_query here, because we could be in the query window,
// trying to synchonize and the table has not yet been created
$fields_list = PMA_DBI_fetch_result(
'SHOW FULL COLUMNS FROM ' . PMA_backquote($db)
. '.' . PMA_backquote($GLOBALS['table']));
 
$strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
. '?' . PMA_generate_common_url($db) . '"';
if ($is_querywindow) {
$strDBLink .= ' target="_self"'
. ' onclick="this.target=window.opener.frames[1].name"';
}
$strDBLink .= '>'
. htmlspecialchars($db) . '</a>';
// else use
// $strDBLink = htmlspecialchars($db);
$legend = sprintf($GLOBALS['strRunSQLQuery'], $strDBLink);
if (empty($query) && count($fields_list)) {
$field_names = array();
foreach ($fields_list as $field) {
$field_names[] = PMA_backquote($field['Field']);
}
$query =
str_replace('%d', PMA_backquote($db),
str_replace('%t', PMA_backquote($table),
str_replace('%f',
implode(', ', $field_names ),
$GLOBALS['cfg']['DefaultQueryTable'])));
unset($field_names);
}
}
$legend .= ': ' . PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
 
if (count($fields_list)) {
$sqlquerycontainer_id = 'sqlquerycontainer';
} else {
$sqlquerycontainer_id = 'sqlquerycontainerfull';
}
 
echo '<a name="querybox"></a>' . "\n"
.'<div id="queryboxcontainer">' . "\n"
.'<fieldset id="querybox">' . "\n";
echo '<legend>' . $legend . '</legend>' . "\n";
echo '<div id="queryfieldscontainer">' . "\n";
echo '<div id="' . $sqlquerycontainer_id . '">' . "\n"
.'<textarea name="sql_query" id="sqlquery"'
.' cols="' . $GLOBALS['cfg']['TextareaCols'] . '"'
.' rows="' . $GLOBALS['cfg']['TextareaRows'] . '"'
.' dir="' . $GLOBALS['text_dir'] . '"'
.$auto_sel . $locking . '>' . htmlspecialchars($query) . '</textarea>' . "\n";
echo '</div>' . "\n";
 
if (count($fields_list)) {
echo '<div id="tablefieldscontainer">' . "\n"
.'<label>' . $GLOBALS['strFields'] . '</label>' . "\n"
.'<select id="tablefields" name="dummy" '
.'size="' . ($GLOBALS['cfg']['TextareaRows'] - 2) . '" '
.'multiple="multiple" ondblclick="insertValueQuery()">' . "\n";
foreach ($fields_list as $field) {
echo '<option value="'
.PMA_backquote(htmlspecialchars($field['Field'])) . '"';
if (isset($field['Field']) && strlen($field['Field']) && isset($field['Comment'])) {
echo ' title="' . htmlspecialchars($field['Comment']) . '"';
}
echo '>' . htmlspecialchars( $field['Field'] ) . '</option>' . "\n";
}
echo '</select>' . "\n"
.'<div id="tablefieldinsertbuttoncontainer">' . "\n";
if ( $GLOBALS['cfg']['PropertiesIconic'] ) {
echo '<input type="button" name="insert" value="&lt;&lt;"'
.' onclick="insertValueQuery()"'
.' title="' . $GLOBALS['strInsert'] . '" />' . "\n";
} else {
echo '<input type="button" name="insert"'
.' value="' . $GLOBALS['strInsert'] . '"'
.' onclick="insertValueQuery()" />' . "\n";
}
echo '</div>' . "\n"
.'</div>' . "\n";
}
 
echo '<div class="clearfloat"></div>' . "\n";
echo '</div>' . "\n";
 
if (! empty($GLOBALS['cfg']['Bookmark'])
&& $GLOBALS['cfg']['Bookmark']['db']
&& $GLOBALS['cfg']['Bookmark']['table']) {
?>
<div id="bookmarkoptions">
<div class="formelement">
<label for="bkm_label">
<?php echo $GLOBALS['strBookmarkThis']; ?>:</label>
<input type="text" name="bkm_label" id="bkm_label" value="" />
</div>
<div class="formelement">
<input type="checkbox" name="bkm_all_users" id="id_bkm_all_users"
value="true" />
<label for="id_bkm_all_users">
<?php echo $GLOBALS['strBookmarkAllUsers']; ?></label>
</div>
<div class="formelement">
<input type="checkbox" name="bkm_replace" id="id_bkm_replace"
value="true" />
<label for="id_bkm_replace">
<?php echo $GLOBALS['strBookmarkReplace']; ?></label>
</div>
</div>
<?php
}
 
echo '<div class="clearfloat"></div>' . "\n";
echo '</fieldset>' . "\n"
.'</div>' . "\n";
 
echo '<fieldset id="queryboxfooter" class="tblFooters">' . "\n";
echo '<div class="formelement">' . "\n";
if ($is_querywindow) {
?>
<script type="text/javascript" language="javascript">
//<![CDATA[
document.writeln(' <input type="checkbox" name="LockFromUpdate" value="1" id="checkbox_lock" /> <label for="checkbox_lock"><?php echo $GLOBALS['strQueryWindowLock']; ?></label> ');
//]]>
</script>
<?php
}
echo '</div>' . "\n";
echo '<div class="formelement">' . "\n";
echo '<input type="checkbox" name="show_query" value="1" '
.'id="checkbox_show_query" checked="checked" />' . "\n"
.'<label for="checkbox_show_query">' . $GLOBALS['strShowThisQuery']
.'</label>' . "\n";
echo '</div>' . "\n";
echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo'] . '" />'
."\n";
echo '<div class="clearfloat"></div>' . "\n";
echo '</fieldset>' . "\n";
}
 
/**
* prints bookmark fieldset
*
* @usedby PMA_sqlQueryForm()
* @uses PMA_listBookmarks()
* @uses $GLOBALS['db']
* @uses $GLOBALS['pmaThemeImage']
* @uses $GLOBALS['cfg']['Bookmark']
* @uses $GLOBALS['cfg']['ReplaceHelpImg']
* @uses $GLOBALS['strBookmarkQuery']
* @uses $GLOBALS['strBookmarkView']
* @uses $GLOBALS['strDelete']
* @uses $GLOBALS['strDocu']
* @uses $GLOBALS['strGo']
* @uses $GLOBALS['strSubmit']
* @uses $GLOBALS['strVar']
* @uses count()
* @uses htmlspecialchars()
*/
function PMA_sqlQueryFormBookmark()
{
$bookmark_list = PMA_listBookmarks(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', $GLOBALS['cfg']['Bookmark'] );
if (! $bookmark_list || count($bookmark_list) < 1) {
return;
}
 
echo '<fieldset id="bookmarkoptions">';
echo '<legend>';
echo $GLOBALS['strBookmarkQuery'] . '</legend>' . "\n";
echo '<div class="formelement">';
echo '<select name="id_bookmark">' . "\n";
echo '<option value=""></option>' . "\n";
foreach ($bookmark_list as $key => $value) {
echo '<option value="' . htmlspecialchars($key) . '">'
.htmlspecialchars($value) . '</option>' . "\n";
}
// &nbsp; is required for correct display with styles/line height
echo '</select>&nbsp;' . "\n";
echo '</div>' . "\n";
echo '<div class="formelement">' . "\n";
echo $GLOBALS['strVar'];
if ($GLOBALS['cfg']['ReplaceHelpImg']) {
echo ' <a href="./Documentation.html#faqbookmark"'
.' target="documentation">'
.'<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png"'
.' border="0" width="11" height="11" align="middle"'
.' alt="' . $GLOBALS['strDocu'] . '" /></a> ';
} else {
echo ' (<a href="./Documentation.html#faqbookmark"'
.' target="documentation">' . $GLOBALS['strDocu'] . '</a>): ';
}
echo '<input type="text" name="bookmark_variable" class="textfield"'
.' size="10" />' . "\n";
echo '</div>' . "\n";
echo '<div class="formelement">' . "\n";
echo '<input type="radio" name="action_bookmark" value="0"'
.' id="radio_bookmark_exe" checked="checked" />'
.'<label for="radio_bookmark_exe">' . $GLOBALS['strSubmit']
.'</label>' . "\n";
echo '<input type="radio" name="action_bookmark" value="1"'
.' id="radio_bookmark_view" />'
.'<label for="radio_bookmark_view">' . $GLOBALS['strBookmarkView']
.'</label>' . "\n";
echo '<input type="radio" name="action_bookmark" value="2"'
.' id="radio_bookmark_del" />'
.'<label for="radio_bookmark_del">' . $GLOBALS['strDelete']
.'</label>' . "\n";
echo '</div>' . "\n";
echo '<div class="clearfloat"></div>' . "\n";
echo '</fieldset>' . "\n";
 
echo '<fieldset id="bookmarkoptionsfooter" class="tblFooters">' . "\n";
echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo'] . '" />';
echo '<div class="clearfloat"></div>' . "\n";
echo '</fieldset>' . "\n";
}
 
/**
* prints bookmark fieldset
*
* @usedby PMA_sqlQueryForm()
* @uses $GLOBALS['cfg']['GZipDump']
* @uses $GLOBALS['cfg']['BZipDump']
* @uses $GLOBALS['cfg']['UploadDir']
* @uses $GLOBALS['cfg']['AvailableCharsets']
* @uses $GLOBALS['cfg']['AllowAnywhereRecoding']
* @uses $GLOBALS['strAutodetect']
* @uses $GLOBALS['strBzip']
* @uses $GLOBALS['strCharsetOfFile']
* @uses $GLOBALS['strCompression']
* @uses $GLOBALS['strError']
* @uses $GLOBALS['strGo']
* @uses $GLOBALS['strGzip']
* @uses $GLOBALS['strLocationTextfile']
* @uses $GLOBALS['strWebServerUploadDirectory']
* @uses $GLOBALS['strWebServerUploadDirectoryError']
* @uses $GLOBALS['allow_recoding']
* @uses $GLOBALS['charset']
* @uses $GLOBALS['max_upload_size']
* @uses PMA_supportedDecompressions()
* @uses PMA_getFileSelectOptions()
* @uses PMA_displayMaximumUploadSize()
* @uses PMA_generateCharsetDropdownBox()
* @uses PMA_generateHiddenMaxFileSize()
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_CSDROPDOWN_CHARSET
* @uses empty()
*/
function PMA_sqlQueryFormUpload(){
$errors = array ();
 
$matcher = '@\.sql(\.(' . PMA_supportedDecompressions() . '))?$@'; // we allow only SQL here
 
if (!empty($GLOBALS['cfg']['UploadDir'])) {
$files = PMA_getFileSelectOptions(PMA_userDir($GLOBALS['cfg']['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : '');
} else {
$files = '';
}
 
// start output
echo '<fieldset id="">';
echo '<legend>';
echo $GLOBALS['strLocationTextfile'] . '</legend>';
echo '<div class="formelement">';
echo '<input type="file" name="sql_file" class="textfield" /> ';
echo PMA_displayMaximumUploadSize($GLOBALS['max_upload_size']);
// some browsers should respect this :)
echo PMA_generateHiddenMaxFileSize($GLOBALS['max_upload_size']) . "\n";
echo '</div>';
 
if ($files === FALSE) {
$errors[$GLOBALS['strError']] = $GLOBALS['strWebServerUploadDirectoryError'];
} elseif (!empty($files)) {
echo '<div class="formelement">';
echo '<strong>' . $GLOBALS['strWebServerUploadDirectory'] .':</strong>' . "\n";
echo '<select size="1" name="sql_localfile">' . "\n";
echo '<option value="" selected="selected"></option>' . "\n";
echo $files;
echo '</select>' . "\n";
echo '</div>';
}
 
echo '<div class="clearfloat"></div>' . "\n";
echo '</fieldset>';
 
 
echo '<fieldset id="" class="tblFooters">';
if ( PMA_MYSQL_INT_VERSION < 40100
&& $GLOBALS['cfg']['AllowAnywhereRecoding']
&& $GLOBALS['allow_recoding'] ) {
echo $GLOBALS['strCharsetOfFile'] . "\n"
. '<select name="charset_of_file" size="1">' . "\n";
foreach ($GLOBALS['cfg']['AvailableCharsets'] as $temp_charset) {
echo '<option value="' . $temp_charset . '"';
if ($temp_charset == $GLOBALS['charset']) {
echo ' selected="selected"';
}
echo '>' . $temp_charset . '</option>' . "\n";
}
echo '</select>' . "\n";
} elseif (PMA_MYSQL_INT_VERSION >= 40100) {
echo $GLOBALS['strCharsetOfFile'] . "\n";
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET,
'charset_of_file', null, 'utf8', FALSE);
} // end if (recoding)
echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo']
.'" />' . "\n";
echo '<div class="clearfloat"></div>' . "\n";
echo '</fieldset>';
 
foreach ( $errors as $error => $message ) {
echo '<div>' . $error . '</div>';
echo '<div>' . $message . '</div>';
}
}
?>
/Web/Maintenance/phpMyAdmin/libraries/sqlparser.data.php
0,0 → 1,1112
<?php
/* $Id: sqlparser.data.php,v 2.23.4.1 2006/03/26 11:54:14 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/** SQL Parser Matching Data
*
* Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
* http://www.orbis-terrarum.net/?l=people.robbat2
*
* This data is used by the SQL Parser to recognize keywords
*
* It has been extracted from the lex.h file in the MySQL BK tree
* (around 4.0.2) as well as the MySQL documentation.
*
* Note: before adding a value in the arrays, ensure that you respect
* proper sorting, especially with underscores. And don't forget to
* update the _cnt variable at the end of each array.
*/
 
$PMA_SQPdata_function_name = array (
'ABS',
'ACOS',
'ADDDATE',
'ADDTIME',
'AES_DECRYPT',
'AES_ENCRYPT',
'Area', // polygon-property-functions.html
'ASCII',
'ASIN',
'ATAN',
'ATAN2',
'AVG',
'BENCHMARK',
'BIN',
'BIT_AND',
'BIT_COUNT',
'BIT_LENGTH',
'BIT_OR',
'BIT_XOR', // group-by-functions.html
'Boundary', // general-geometry-property-functions.html
'CAST',
'CEIL',
'CEILING',
'Centroid', // multipolygon-property-functions.html
'CHAR', // string-functions.html
'CHARACTER_LENGTH',
'CHARSET', // information-functions.html
'CHAR_LENGTH',
'COALESCE',
'COERCIBILITY', // information-functions.html
'COLLATION', // information-functions.html
'COMPRESS', // string-functions.html
'CONCAT',
'CONCAT_WS',
'CONNECTION_ID',
'CONV',
'CONVERT',
'CONVERT_TZ',
'COS',
'COT',
'COUNT',
'CRC32', // mathematical-functions.html
'CURDATE',
'CURRENT_DATE',
'CURRENT_TIME',
'CURRENT_TIMESTAMP',
'CURRENT_USER',
'CURTIME',
'DATABASE',
'DATE', // date-and-time-functions.html
'DATEDIFF', // date-and-time-functions.html
'DATE_ADD',
'DATE_DIFF',
'DATE_FORMAT',
'DATE_SUB',
'DAY',
'DAYNAME',
'DAYOFMONTH',
'DAYOFWEEK',
'DAYOFYEAR',
'DECODE',
'DEFAULT', // miscellaneous-functions.html
'DEGREES',
'DES_DECRYPT',
'DES_ENCRYPT',
'Dimension', // general-geometry-property-functions.html
'ELT',
'ENCODE',
'ENCRYPT',
'EndPoint', // linestring-property-functions.html
'Envelope', // general-geometry-property-functions.html
'EXP',
'EXPORT_SET',
'ExteriorRing', // polygon-property-functions.html
'EXTRACT',
'FIELD',
'FIND_IN_SET',
'FLOOR',
'FORMAT',
'FOUND_ROWS',
'FROM_DAYS',
'FROM_UNIXTIME',
'GeometryN', // geometrycollection-property-functions.html
'GeometryType', // general-geometry-property-functions.html
'GET_FORMAT',
'GET_LOCK',
'GLength', // linestring-property-functions.html
'GREATEST',
'GROUP_CONCAT',
'GROUP_UNIQUE_USERS',
'HEX',
'HOUR',
'IF', //control-flow-functions.html
'IFNULL',
'INET_ATON',
'INET_NTOA',
'INSERT', // string-functions.html
'INSTR',
'InteriorRingN', // polygon-property-functions.html
'INTERVAL',
'ISNULL',
'IsClosed', // multilinestring-property-functions.html
'IsEmpty', // general-geometry-property-functions.html
'IsRing', // linestring-property-functions.html
'IsSimple', // general-geometry-property-functions.html
'IS_FREE_LOCK',
'IS_USED_LOCK', // miscellaneous-functions.html
'LAST_DAY',
'LAST_INSERT_ID',
'LCASE',
'LEAST',
'LEFT',
'LENGTH',
'LN',
'LOAD_FILE',
'LOCALTIME',
'LOCALTIMESTAMP',
'LOCATE',
'LOG',
'LOG10',
'LOG2',
'LOWER',
'LPAD',
'LTRIM',
'MAKEDATE',
'MAKETIME',
'MAKE_SET',
'MASTER_POS_WAIT',
'MAX',
'MD5',
'MICROSECOND',
'MID',
'MIN',
'MINUTE',
'MOD',
'MONTH',
'MONTHNAME',
'NOW',
'NULLIF',
'NumGeometries', // geometrycollection-property-functions.html
'NumInteriorRings', // polygon-property-functions.html
'NumPoints', // linestring-property-functions.html
'OCT',
'OCTET_LENGTH',
'OLD_PASSWORD',
'ORD',
'PASSWORD',
'PERIOD_ADD',
'PERIOD_DIFF',
'PI',
'PointN', // linestring-property-functions.html
'PointOnSurface', // multipolygon-property-functions.html
'POSITION',
'POW',
'POWER',
'QUARTER',
'QUOTE',
'RADIANS',
'RAND',
'RELEASE_LOCK',
'REPEAT',
'REPLACE', // string-functions.html
'REVERSE',
'RIGHT',
'ROUND',
'ROW_COUNT', // information-functions.html
'RPAD',
'RTRIM',
'SCHEMA', // information-functions.html
'SECOND',
'SEC_TO_TIME',
'SESSION_USER',
'SHA',
'SHA1',
'SIGN',
'SIN',
'SLEEP', // miscellaneous-functions.html
'SOUNDEX',
'SPACE',
'SQRT',
'SRID', // general-geometry-property-functions.html
'StartPoint', // linestring-property-functions.html
'STD',
'STDDEV',
'STDDEV_POP', // group-by-functions.html
'STDDEV_SAMP', // group-by-functions.html
'STRCMP',
'STR_TO_DATE',
'SUBDATE',
'SUBSTRING',
'SUBSTRING_INDEX',
'SUBTIME',
'SUM',
'SYSDATE',
'SYSTEM_USER',
'TAN',
'TIME',
'TIMEDIFF',
'TIMESTAMP',
'TIMESTAMPADD',
'TIMESTAMPDIFF',
'TIME_FORMAT',
'TIME_TO_SEC',
'TO_DAYS',
'TRIM',
'TRUNCATE', // mathematical-functions.html
'UCASE',
'UNCOMPRESS', // string-functions.html
'UNCOMPRESSED_LENGTH', // string-functions.html
'UNHEX', // string-functions.html
'UNIQUE_USERS',
'UNIX_TIMESTAMP',
'UPPER',
'USER',
'UTC_DATE',
'UTC_TIME',
'UTC_TIMESTAMP',
'UUID', // miscellaneous-functions.html
'VARIANCE', // group-by-functions.html
'VAR_POP', // group-by-functions.html
'VAR_SAMP', // group-by-functions.html
'VERSION',
'WEEK',
'WEEKDAY',
'WEEKOFYEAR',
'X', // point-property-functions.html
'Y', // point-property-functions.html
'YEAR',
'YEARWEEK'
);
//$PMA_SQPdata_function_name_cnt = count($PMA_SQPdata_function_name);
$PMA_SQPdata_function_name_cnt = 229;
 
$PMA_SQPdata_column_attrib = array (
'ARCHIVE', // Engine
'ASCII',
'AUTO_INCREMENT',
'BDB', // Engine
'BERKELEYDB', // Engine alias BDB
'BINARY',
'BLACKHOLE', // Engine
'CSV', // Engine
'DEFAULT',
'EXAMPLE', // Engine
'FEDERATED', // Engine
'HEAP', // Engine
'INNOBASE', // Engine alias InnoDB
'INNODB', // Engine InnoDB
'ISAM', // Engine
'MEMORY', // Engine alias HEAP, but preferred
'MERGE', // Engine
'MRG_ISAM', // Engine
'MRG_MYISAM', // Engine alias MERGE
'MYISAM', // Engine MyISAM
'NATIONAL',
'NDB', // Engine alias NDBCLUSTER
'NDBCLUSTER', // Engine
'PRECISION',
'UNDEFINED',
'UNICODE',
'UNSIGNED',
'VARYING',
'ZEROFILL'
);
//$PMA_SQPdata_column_attrib_cnt = count($PMA_SQPdata_column_attrib);
$PMA_SQPdata_column_attrib_cnt = 29;
 
$PMA_SQPdata_reserved_word = array (
'ACTION',
'ADD',
'AFTER',
'AGAINST',
'AGGREGATE',
'ALGORITHM',
'ALL',
'ALTER',
'ANALYSE',
'ANALYZE',
'AND',
'AS',
'ASC',
'AUTOCOMMIT',
'AUTO_INCREMENT',
'AVG_ROW_LENGTH',
'BACKUP',
'BEGIN',
'BETWEEN',
'BINLOG',
'BOTH',
'BY',
'CASCADE',
'CASE',
'CHANGE',
'CHANGED',
'CHARSET',
'CHECK',
'CHECKSUM',
'CLIENT',
'COLLATE',
'COLLATION',
'COLUMN',
'COLUMNS',
'COMMENT',
'COMMIT',
'COMMITTED',
'COMPRESSED',
'CONCURRENT',
'CONSTRAINT',
'CONVERT',
'CREATE',
'CROSS',
'CURRENT_TIMESTAMP',
'DATA',
'DATABASE',
'DATABASES',
'DAY',
'DAY_HOUR',
'DAY_MINUTE',
'DAY_SECOND',
'DELAYED',
'DELAY_KEY_WRITE',
'DELETE',
'DESC',
'DESCRIBE',
'DISTINCT',
'DISTINCTROW',
'DIV',
'DO',
'DROP',
'DUMPFILE',
'DYNAMIC',
'ELSE',
'ENCLOSED',
'END',
'ENGINE',
'ENGINES',
'ESCAPE',
'ESCAPED',
'EVENTS',
'EXECUTE',
'EXISTS',
'EXPLAIN',
'EXTENDED',
'FAST',
'FIELDS',
'FILE',
'FIRST',
'FIXED',
'FLUSH',
'FOR',
'FORCE',
'FOREIGN',
'FROM',
'FULL',
'FULLTEXT',
'FUNCTION',
'GEMINI',
'GEMINI_SPIN_RETRIES',
'GLOBAL',
'GRANT',
'GRANTS',
'GROUP',
'HAVING',
'HEAP',
'HIGH_PRIORITY',
'HOSTS',
'HOUR',
'HOUR_MINUTE',
'HOUR_SECOND',
'IDENTIFIED',
'IF',
'IGNORE',
'IN',
'INDEX',
'INDEXES',
'INFILE',
'INNER',
'INSERT',
'INSERT_ID',
'INSERT_METHOD',
'INTERVAL',
'INTO',
'IS',
'ISOLATION',
'JOIN',
'KEY',
'KEYS',
'KILL',
'LAST_INSERT_ID',
'LEADING',
'LEFT',
'LEVEL',
'LIKE',
'LIMIT',
'LINES',
'LOAD',
'LOCAL',
'LOCK',
'LOCKS',
'LOGS',
'LOW_PRIORITY',
'MASTER',
'MASTER_CONNECT_RETRY',
'MASTER_HOST',
'MASTER_LOG_FILE',
'MASTER_LOG_POS',
'MASTER_PASSWORD',
'MASTER_PORT',
'MASTER_USER',
'MATCH',
'MAX_CONNECTIONS_PER_HOUR',
'MAX_QUERIES_PER_HOUR',
'MAX_ROWS',
'MAX_UPDATES_PER_HOUR',
'MAX_USER_CONNECTIONS',
'MEDIUM',
'MERGE',
'MIN_ROWS',
'MINUTE',
'MINUTE_SECOND',
'MODE',
'MODIFY',
'MONTH',
'MRG_MYISAM',
'MYISAM',
'NAMES',
'NATURAL',
// 'NO' is not allowed in SQL-99 but is allowed in MySQL
//'NO',
'NOT',
'NULL',
'OFFSET',
'ON',
'OPEN',
'OPTIMIZE',
'OPTION',
'OPTIONALLY',
'OR',
'ORDER',
'OUTER',
'OUTFILE',
'PACK_KEYS',
'PARTIAL',
'PASSWORD',
'PRIMARY',
'PRIVILEGES',
'PROCEDURE',
'PROCESS',
'PROCESSLIST',
'PURGE',
'QUICK',
'RAID0',
'RAID_CHUNKS',
'RAID_CHUNKSIZE',
'RAID_TYPE',
'READ',
'REFERENCES',
'REGEXP',
'RELOAD',
'RENAME',
'REPAIR',
'REPEATABLE',
'REPLACE',
'REPLICATION',
'RESET',
'RESTORE',
'RESTRICT',
'RETURN',
'RETURNS',
'REVOKE',
'RIGHT',
'RLIKE',
'ROLLBACK',
'ROW',
'ROW_FORMAT',
'ROWS',
'SECOND',
'SELECT',
'SEPARATOR',
'SERIALIZABLE',
'SESSION',
'SHARE',
'SHOW',
'SHUTDOWN',
'SLAVE',
'SONAME',
'SOUNDS', // string-functions.html
'SQL_AUTO_IS_NULL',
'SQL_BIG_RESULT',
'SQL_BIG_SELECTS',
'SQL_BIG_TABLES',
'SQL_BUFFER_RESULT',
'SQL_CACHE',
'SQL_CALC_FOUND_ROWS',
'SQL_LOG_BIN',
'SQL_LOG_OFF',
'SQL_LOG_UPDATE',
'SQL_LOW_PRIORITY_UPDATES',
'SQL_MAX_JOIN_SIZE',
'SQL_NO_CACHE',
'SQL_QUOTE_SHOW_CREATE',
'SQL_SAFE_UPDATES',
'SQL_SELECT_LIMIT',
'SQL_SLAVE_SKIP_COUNTER',
'SQL_SMALL_RESULT',
'SQL_WARNINGS',
'START',
'STARTING',
'STATUS',
'STOP',
'STORAGE',
'STRAIGHT_JOIN',
'STRING',
'STRIPED',
'SUPER',
'TABLE',
'TABLES',
'TEMPORARY',
'TERMINATED',
'THEN',
'TO',
'TRAILING',
'TRUNCATE',
'TYPE',
'TYPES',
'UNCOMMITTED',
'UNION',
'UNIQUE',
'UNLOCK',
'UPDATE',
'USAGE',
'USE',
'USING',
'VALUES',
'VARIABLES',
'VIEW',
'WHEN',
'WHERE',
'WITH',
'WORK',
'WRITE',
'XOR',
'YEAR_MONTH'
);
//$PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word);
$PMA_SQPdata_reserved_word_cnt = 273;
 
// words forbidden to be used as column or table name,
// as seen in http://dev.mysql.com/doc/mysql/en/reserved-words.html
$PMA_SQPdata_forbidden_word = array (
'ACTION',
'ADD',
'AFTER',
'AGAINST',
'AGGREGATE',
'ALGORITHM',
'ALL',
'ALTER',
'ANALYZE',
'AND',
'ANY',
'AS',
'ASC',
'ASCII',
'ASENSITIVE',
'AUTO_INCREMENT',
'AVG',
'AVG_ROW_LENGTH',
'BACKUP',
'BDB',
'BEFORE',
'BEGIN',
'BERKELEYDB',
'BETWEEN',
'BIGINT',
'BINARY',
'BINLOG',
'BIT',
'BLOB',
'BOOL',
'BOOLEAN',
'BOTH',
'BTREE',
'BY',
'BYTE',
'CACHE',
'CALL',
'CASCADE',
'CASCADED',
'CASE',
'CHAIN',
'CHANGE',
'CHANGED',
'CHAR',
'CHARACTER',
'CHARSET',
'CHECK',
'CHECKSUM',
'CIPHER',
'CLIENT',
'CLOSE',
'COLLATE',
'COLLATION',
'COLUMN',
'COLUMNS',
'COMMENT',
'COMMIT',
'COMMITTED',
'COMPACT',
'COMPRESSED',
'CONCURRENT',
'CONDITION',
'CONNECTION',
'CONSISTENT',
'CONSTRAINT',
'CONTAINS',
'CONTINUE',
'CONVERT',
'CREATE',
'CROSS',
'CUBE',
'CURRENT_DATE',
'CURRENT_TIME',
'CURRENT_TIMESTAMP',
'CURRENT_USER',
'CURSOR',
'DATA',
'DATABASE',
'DATABASES',
'DATE',
'DATETIME',
'DAY',
'DAY_HOUR',
'DAY_MICROSECOND',
'DAY_MINUTE',
'DAY_SECOND',
'DEALLOCATE',
'DEC',
'DECIMAL',
'DECLARE',
'DEFAULT',
'DEFINER',
'DELAYED',
'DELAY_KEY_WRITE',
'DELETE',
'DESC',
'DESCRIBE',
'DES_KEY_FILE',
'DETERMINISTIC',
'DIRECTORY',
'DISABLE',
'DISCARD',
'DISTINCT',
'DISTINCTROW',
'DIV',
'DO',
'DOUBLE',
'DROP',
'DUAL',
'DUMPFILE',
'DUPLICATE',
'DYNAMIC',
'EACH',
'ELSE',
'ELSEIF',
'ENABLE',
'ENCLOSED',
'END',
'ENGINE',
'ENGINES',
'ENUM',
'ERRORS',
'ESCAPE',
'ESCAPED',
'EVENTS',
'EXECUTE',
'EXISTS',
'EXIT',
'EXPANSION',
'EXPLAIN',
'EXTENDED',
'FALSE',
'FAST',
'FETCH',
'FIELDS',
'FILE',
'FIRST',
'FIXED',
'FLOAT',
'FLOAT4',
'FLOAT8',
'FLUSH',
'FOR',
'FORCE',
'FOREIGN',
'FOUND',
'FRAC_SECOND',
'FROM',
'FULL',
'FULLTEXT',
'FUNCTION',
'GEOMETRY',
'GEOMETRYCOLLECTION',
'GET_FORMAT',
'GLOBAL',
'GOTO',
'GRANT',
'GRANTS',
'GROUP',
'HANDLER',
'HASH',
'HAVING',
'HELP',
'HIGH_PRIORITY',
'HOSTS',
'HOUR',
'HOUR_MICROSECOND',
'HOUR_MINUTE',
'HOUR_SECOND',
'IDENTIFIED',
'IF',
'IGNORE',
'IMPORT',
'IN',
'INDEX',
'INDEXES',
'INFILE',
'INNER',
'INNOBASE',
'INNODB',
'INOUT',
'INSENSITIVE',
'INSERT',
'INSERT_METHOD',
'INT',
'INT1',
'INT2',
'INT3',
'INT4',
'INT8',
'INTEGER',
'INTERVAL',
'INTO',
'INVOKER',
'IO_THREAD',
'IS',
'ISOLATION',
'ISSUER',
'ITERATE',
'JOIN',
'KEY',
'KEYS',
'KILL',
'LABEL',
'LANGUAGE',
'LAST',
'LEADING',
'LEAVE',
'LEAVES',
'LEFT',
'LEVEL',
'LIKE',
'LIMIT',
'LINES',
'LINESTRING',
'LOAD',
'LOCAL',
'LOCALTIME',
'LOCALTIMESTAMP',
'LOCK',
'LOCKS',
'LOGS',
'LONG',
'LONGBLOB',
'LONGTEXT',
'LOOP',
'LOW_PRIORITY',
'MASTER',
'MASTER_CONNECT_RETRY',
'MASTER_HOST',
'MASTER_LOG_FILE',
'MASTER_LOG_POS',
'MASTER_PASSWORD',
'MASTER_PORT',
'MASTER_SERVER_ID',
'MASTER_SSL',
'MASTER_SSL_CA',
'MASTER_SSL_CAPATH',
'MASTER_SSL_CERT',
'MASTER_SSL_CIPHER',
'MASTER_SSL_KEY',
'MASTER_USER',
'MATCH',
'MAX_CONNECTIONS_PER_HOUR',
'MAX_QUERIES_PER_HOUR',
'MAX_ROWS',
'MAX_UPDATES_PER_HOUR',
'MAX_USER_CONNECTIONS',
'MEDIUM',
'MEDIUMBLOB',
'MEDIUMINT',
'MEDIUMTEXT',
'MERGE',
'MICROSECOND',
'MIDDLEINT',
'MIGRATE',
'MINUTE',
'MINUTE_MICROSECOND',
'MINUTE_SECOND',
'MIN_ROWS',
'MOD',
'MODE',
'MODIFIES',
'MODIFY',
'MONTH',
'MULTILINESTRING',
'MULTIPOINT',
'MULTIPOLYGON',
'MUTEX',
'NAME',
'NAMES',
'NATIONAL',
'NATURAL',
'NCHAR',
'NDB',
'NDBCLUSTER',
'NEW',
'NEXT',
'NO',
'NONE',
'NOT',
'NO_WRITE_TO_BINLOG',
'NULL',
'NUMERIC',
'NVARCHAR',
'OFFSET',
'OLD_PASSWORD',
'ON',
'ONE',
'ONE_SHOT',
'OPEN',
'OPTIMIZE',
'OPTION',
'OPTIONALLY',
'OR',
'ORDER',
'OUT',
'OUTER',
'OUTFILE',
'PACK_KEYS',
'PARTIAL',
'PASSWORD',
'PHASE',
'POINT',
'POLYGON',
'PRECISION',
'PREPARE',
'PREV',
'PRIMARY',
'PRIVILEGES',
'PROCEDURE',
'PROCESSLIST',
'PURGE',
'QUARTER',
'QUERY',
'QUICK',
'RAID0',
'RAID_CHUNKS',
'RAID_CHUNKSIZE',
'RAID_TYPE',
'READ',
'READS',
'REAL',
'RECOVER',
'REDUNDANT',
'REFERENCES',
'REGEXP',
'RELAY_LOG_FILE',
'RELAY_LOG_POS',
'RELAY_THREAD',
'RELEASE',
'RELOAD',
'RENAME',
'REPAIR',
'REPEAT',
'REPEATABLE',
'REPLACE',
'REPLICATION',
'REQUIRE',
'RESET',
'RESTORE',
'RESTRICT',
'RESUME',
'RETURN',
'RETURNS',
'REVOKE',
'RIGHT',
'RLIKE',
'ROLLBACK',
'ROLLUP',
'ROUTINE',
'ROW',
'ROWS',
'ROW_FORMAT',
'RTREE',
'SAVEPOINT',
'SCHEMA',
'SCHEMAS',
'SECOND',
'SECOND_MICROSECOND',
'SECURITY',
'SELECT',
'SENSITIVE',
'SEPARATOR',
'SERIAL',
'SERIALIZABLE',
'SESSION',
'SET',
'SHARE',
'SHOW',
'SHUTDOWN',
'SIGNED',
'SIMPLE',
'SLAVE',
'SMALLINT',
'SNAPSHOT',
'SOME',
'SONAME',
'SOUNDS',
'SPATIAL',
'SPECIFIC',
'SQL',
'SQLEXCEPTION',
'SQLSTATE',
'SQLWARNING',
'SQL_BIG_RESULT',
'SQL_BUFFER_RESULT',
'SQL_CACHE',
'SQL_CALC_FOUND_ROWS',
'SQL_NO_CACHE',
'SQL_SMALL_RESULT',
'SQL_THREAD',
'SQL_TSI_DAY',
'SQL_TSI_FRAC_SECOND',
'SQL_TSI_HOUR',
'SQL_TSI_MINUTE',
'SQL_TSI_MONTH',
'SQL_TSI_QUARTER',
'SQL_TSI_SECOND',
'SQL_TSI_WEEK',
'SQL_TSI_YEAR',
'SSL',
'START',
'STARTING',
'STATUS',
'STOP',
'STORAGE',
'STRAIGHT_JOIN',
'STRING',
'STRIPED',
'SUBJECT',
'SUPER',
'SUSPEND',
'TABLE',
'TABLES',
'TABLESPACE',
'TEMPORARY',
'TEMPTABLE',
'TERMINATED',
'TEXT',
'THEN',
'TIME',
'TIMESTAMP',
'TIMESTAMPADD',
'TIMESTAMPDIFF',
'TINYBLOB',
'TINYINT',
'TINYTEXT',
'TO',
'TRAILING',
'TRANSACTION',
'TRIGGER',
'TRIGGERS',
'TRUE',
'TRUNCATE',
'TYPE',
'TYPES',
'UNCOMMITTED',
'UNDEFINED',
'UNDO',
'UNICODE',
'UNION',
'UNIQUE',
'UNKNOWN',
'UNLOCK',
'UNSIGNED',
'UNTIL',
'UPDATE',
'USAGE',
'USE',
'USER',
'USER_RESOURCES',
'USE_FRM',
'USING',
'UTC_DATE',
'UTC_TIME',
'UTC_TIMESTAMP',
'VALUE',
'VALUES',
'VARBINARY',
'VARCHAR',
'VARCHARACTER',
'VARIABLES',
'VARYING',
'VIEW',
'WARNINGS',
'WEEK',
'WHEN',
'WHERE',
'WHILE',
'WITH',
'WORK',
'WRITE',
'X509',
'XA',
'XOR',
'YEAR',
'YEAR_MONTH',
'ZEROFILL'
);
// echo count($PMA_SQPdata_forbidden_word);
$PMA_SQPdata_forbidden_word_cnt = 479;
 
$PMA_SQPdata_column_type = array (
'BIGINT',
'BINARY',
'BIT',
'BLOB',
'BOOL',
'BOOLEAN', // numeric-type-overview.html
'CHAR',
'CHARACTER',
'DATE',
'DATETIME',
'DEC',
'DECIMAL',
'DOUBLE',
'ENUM',
'FLOAT',
'FLOAT4',
'FLOAT8',
'INT',
'INT1',
'INT2',
'INT3',
'INT4',
'INT8',
'INTEGER',
'LONG',
'LONGBLOB',
'LONGTEXT',
'MEDIUMBLOB',
'MEDIUMINT',
'MEDIUMTEXT',
'MIDDLEINT',
'NCHAR',
'NUMERIC',
'REAL',
'SERIAL', //BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE
'SET',
'SMALLINT',
'TEXT',
'TIME',
'TIMESTAMP',
'TINYBLOB',
'TINYINT',
'TINYTEXT',
'VARBINARY',
'VARCHAR',
'YEAR'
);
//$PMA_SQPdata_column_type_cnt = count($PMA_SQPdata_column_type);
$PMA_SQPdata_column_type_cnt = 46;
 
// check counts
/*
foreach ( $GLOBALS as $n => $a ) {
echo is_array( $a ) ? $n . ': ' . count( $a ) . '<br />' : '';
}
*/
?>
/Web/Maintenance/phpMyAdmin/libraries/sqlparser.lib.php
0,0 → 1,2348
<?php
/* $Id: sqlparser.lib.php,v 2.47 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/** SQL Parser Functions for phpMyAdmin
*
* Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
* http://www.orbis-terrarum.net/?l=people.robbat2
*
* These functions define an SQL parser system, capable of understanding and
* extracting data from a MySQL type SQL query.
*
* The basic procedure for using the new SQL parser:
* On any page that needs to extract data from a query or to pretty-print a
* query, you need code like this up at the top:
*
* ($sql contains the query)
* $parsed_sql = PMA_SQP_parse($sql);
*
* If you want to extract data from it then, you just need to run
* $sql_info = PMA_SQP_analyze($parsed_sql);
*
* lem9: See comments in PMA_SQP_analyze for the returned info
* from the analyzer.
*
* If you want a pretty-printed version of the query, do:
* $string = PMA_SQP_formatHtml($parsed_sql);
* (note that that you need to have syntax.css.php included somehow in your
* page for it to work, I recommend '<link rel="stylesheet" type="text/css"
* href="syntax.css.php" />' at the moment.)
*/
 
 
/**
* Minimum inclusion? (i.e. for the stylesheet builder)
*/
if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
/**
* Include the string library as we use it heavily
*/
require_once('./libraries/string.lib.php');
 
/**
* Include data for the SQL Parser
*/
require_once('./libraries/sqlparser.data.php');
require_once('./libraries/mysql_charsets.lib.php');
if (!isset($mysql_charsets)) {
$mysql_charsets = array();
$mysql_charsets_count = 0;
$mysql_collations_flat = array();
$mysql_collations_count = 0;
}
 
if (!defined('DEBUG_TIMING')) {
function PMA_SQP_arrayAdd(&$arr, $type, $data, &$arrsize)
{
$arr[] = array('type' => $type, 'data' => $data);
$arrsize++;
} // end of the "PMA_SQP_arrayAdd()" function
} else {
function PMA_SQP_arrayAdd(&$arr, $type, $data, &$arrsize)
{
global $timer;
 
$t = $timer;
$arr[] = array('type' => $type, 'data' => $data, 'time' => $t);
$timer = microtime();
$arrsize++;
} // end of the "PMA_SQP_arrayAdd()" function
} // end if... else...
 
 
/**
* Reset the error variable for the SQL parser
*
* @access public
*/
// Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_resetError()
{
global $SQP_errorString;
$SQP_errorString = '';
unset($SQP_errorString);
}
 
/**
* Get the contents of the error variable for the SQL parser
*
* @return string Error string from SQL parser
*
* @access public
*/
// Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_getErrorString()
{
global $SQP_errorString;
return isset($SQP_errorString) ? $SQP_errorString : '';
}
 
/**
* Check if the SQL parser hit an error
*
* @return boolean error state
*
* @access public
*/
// Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_isError()
{
global $SQP_errorString;
return isset($SQP_errorString) && !empty($SQP_errorString);
}
 
/**
* Set an error message for the system
*
* @param string The error message
* @param string The failing SQL query
*
* @access private
* @scope SQL Parser internal
*/
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_throwError($message, $sql)
{
 
global $SQP_errorString;
$SQP_errorString = '<p>'.$GLOBALS['strSQLParserUserError'] . '</p>' . "\n"
. '<pre>' . "\n"
. 'ERROR: ' . $message . "\n"
. 'SQL: ' . htmlspecialchars($sql) . "\n"
. '</pre>' . "\n";
 
} // end of the "PMA_SQP_throwError()" function
 
 
/**
* Do display the bug report
*
* @param string The error message
* @param string The failing SQL query
*
* @access public
*/
function PMA_SQP_bug($message, $sql)
{
global $SQP_errorString;
$debugstr = 'ERROR: ' . $message . "\n";
$debugstr .= 'CVS: $Id: sqlparser.lib.php,v 2.47 2006/01/17 17:02:30 cybot_tm Exp $' . "\n";
$debugstr .= 'MySQL: '.PMA_MYSQL_STR_VERSION . "\n";
$debugstr .= 'USR OS, AGENT, VER: ' . PMA_USR_OS . ' ' . PMA_USR_BROWSER_AGENT . ' ' . PMA_USR_BROWSER_VER . "\n";
$debugstr .= 'PMA: ' . PMA_VERSION . "\n";
$debugstr .= 'PHP VER,OS: ' . PMA_PHP_STR_VERSION . ' ' . PHP_OS . "\n";
$debugstr .= 'LANG: ' . $GLOBALS['lang'] . "\n";
$debugstr .= 'SQL: ' . htmlspecialchars($sql);
 
$encodedstr = $debugstr;
if (@function_exists('gzcompress')) {
$encodedstr = gzcompress($debugstr, 9);
}
$encodedstr = preg_replace("/(\015\012)|(\015)|(\012)/", '<br />' . "\n", chunk_split(base64_encode($encodedstr)));
 
$SQP_errorString .= $GLOBALS['strSQLParserBugMessage'] . '<br />' . "\n"
. '----' . $GLOBALS['strBeginCut'] . '----' . '<br />' . "\n"
. $encodedstr . "\n"
. '----' . $GLOBALS['strEndCut'] . '----' . '<br />' . "\n";
 
$SQP_errorString .= '----' . $GLOBALS['strBeginRaw'] . '----<br />' . "\n"
. '<pre>' . "\n"
. $debugstr
. '</pre>' . "\n"
. '----' . $GLOBALS['strEndRaw'] . '----<br />' . "\n";
 
} // end of the "PMA_SQP_bug()" function
 
 
/**
* Parses the SQL queries
*
* @param string The SQL query list
*
* @return mixed Most of times, nothing...
*
* @global array The current PMA configuration
* @global array MySQL column attributes
* @global array MySQL reserved words
* @global array MySQL column types
* @global array MySQL function names
* @global integer MySQL column attributes count
* @global integer MySQL reserved words count
* @global integer MySQL column types count
* @global integer MySQL function names count
* @global array List of available character sets
* @global array List of available collations
* @global integer Character sets count
* @global integer Collations count
*
* @access public
*/
function PMA_SQP_parse($sql)
{
global $cfg;
global $PMA_SQPdata_column_attrib, $PMA_SQPdata_reserved_word, $PMA_SQPdata_column_type, $PMA_SQPdata_function_name,
$PMA_SQPdata_column_attrib_cnt, $PMA_SQPdata_reserved_word_cnt, $PMA_SQPdata_column_type_cnt, $PMA_SQPdata_function_name_cnt;
global $mysql_charsets, $mysql_collations_flat, $mysql_charsets_count, $mysql_collations_count;
global $PMA_SQPdata_forbidden_word, $PMA_SQPdata_forbidden_word_cnt;
 
// rabus: Convert all line feeds to Unix style
$sql = str_replace("\r\n", "\n", $sql);
$sql = str_replace("\r", "\n", $sql);
 
$len = PMA_strlen($sql);
if ($len == 0) {
return array();
}
 
$sql_array = array();
$sql_array['raw'] = $sql;
$count1 = 0;
$count2 = 0;
$punct_queryend = ';';
$punct_qualifier = '.';
$punct_listsep = ',';
$punct_level_plus = '(';
$punct_level_minus = ')';
$digit_floatdecimal = '.';
$digit_hexset = 'x';
$bracket_list = '()[]{}';
$allpunct_list = '-,;:!?/.^~\*&%+<=>|';
$allpunct_list_pair = array (
0 => '!=',
1 => '&&',
2 => ':=',
3 => '<<',
4 => '<=',
5 => '<=>',
6 => '<>',
7 => '>=',
8 => '>>',
9 => '||'
);
$allpunct_list_pair_size = 10; //count($allpunct_list_pair);
$quote_list = '\'"`';
$arraysize = 0;
 
while ($count2 < $len) {
$c = PMA_substr($sql, $count2, 1);
$count1 = $count2;
 
if (($c == "\n")) {
$count2++;
PMA_SQP_arrayAdd($sql_array, 'white_newline', '', $arraysize);
continue;
}
 
// Checks for white space
if (PMA_STR_isSpace($c)) {
$count2++;
continue;
}
 
// Checks for comment lines.
// MySQL style #
// C style /* */
// ANSI style --
if (($c == '#')
|| (($count2 + 1 < $len) && ($c == '/') && (PMA_substr($sql, $count2 + 1, 1) == '*'))
|| (($count2 + 2 == $len) && ($c == '-') && (PMA_substr($sql, $count2 + 1, 1) == '-'))
|| (($count2 + 2 < $len) && ($c == '-') && (PMA_substr($sql, $count2 + 1, 1) == '-') && ((PMA_substr($sql, $count2 + 2, 1) <= ' ')))) {
$count2++;
$pos = 0;
$type = 'bad';
switch ($c) {
case '#':
$type = 'mysql';
case '-':
$type = 'ansi';
$pos = $GLOBALS['PMA_strpos']($sql, "\n", $count2);
break;
case '/':
$type = 'c';
$pos = $GLOBALS['PMA_strpos']($sql, '*/', $count2);
$pos += 2;
break;
default:
break;
} // end switch
$count2 = ($pos < $count2) ? $len : $pos;
$str = PMA_substr($sql, $count1, $count2 - $count1);
PMA_SQP_arrayAdd($sql_array, 'comment_' . $type, $str, $arraysize);
continue;
} // end if
 
// Checks for something inside quotation marks
if (PMA_STR_strInStr($c, $quote_list)) {
$startquotepos = $count2;
$quotetype = $c;
$count2++;
$escaped = FALSE;
$escaped_escaped = FALSE;
$pos = $count2;
$oldpos = 0;
do {
$oldpos = $pos;
$pos = $GLOBALS['PMA_strpos'](' ' . $sql, $quotetype, $oldpos + 1) - 1;
// ($pos === FALSE)
if ($pos < 0) {
$debugstr = $GLOBALS['strSQPBugUnclosedQuote'] . ' @ ' . $startquotepos. "\n"
. 'STR: ' . htmlspecialchars($quotetype);
PMA_SQP_throwError($debugstr, $sql);
return $sql;
}
 
// If the quote is the first character, it can't be
// escaped, so don't do the rest of the code
if ($pos == 0) {
break;
}
 
// Checks for MySQL escaping using a \
// And checks for ANSI escaping using the $quotetype character
if (($pos < $len) && PMA_STR_charIsEscaped($sql, $pos)) {
$pos ++;
continue;
} elseif (($pos + 1 < $len) && (PMA_substr($sql, $pos, 1) == $quotetype) && (PMA_substr($sql, $pos + 1, 1) == $quotetype)) {
$pos = $pos + 2;
continue;
} else {
break;
}
} while ($len > $pos); // end do
 
$count2 = $pos;
$count2++;
$type = 'quote_';
switch ($quotetype) {
case '\'':
$type .= 'single';
break;
case '"':
$type .= 'double';
break;
case '`':
$type .= 'backtick';
break;
default:
break;
} // end switch
$data = PMA_substr($sql, $count1, $count2 - $count1);
PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize);
continue;
}
 
// Checks for brackets
if (PMA_STR_strInStr($c, $bracket_list)) {
// All bracket tokens are only one item long
$count2++;
$type_type = '';
if (PMA_STR_strInStr($c, '([{')) {
$type_type = 'open';
} else {
$type_type = 'close';
}
 
$type_style = '';
if (PMA_STR_strInStr($c, '()')) {
$type_style = 'round';
} elseif (PMA_STR_strInStr($c, '[]')) {
$type_style = 'square';
} else {
$type_style = 'curly';
}
 
$type = 'punct_bracket_' . $type_type . '_' . $type_style;
PMA_SQP_arrayAdd($sql_array, $type, $c, $arraysize);
continue;
}
 
// Checks for identifier (alpha or numeric)
if (PMA_STR_isSqlIdentifier($c, FALSE) || ($c == '@') || ($c == '.' && PMA_STR_isDigit(PMA_substr($sql, $count2 + 1, 1)))) {
$count2 ++;
 
//TODO: a @ can also be present in expressions like
// FROM 'user'@'%'
// or TO 'user'@'%'
// in this case, the @ is wrongly marked as alpha_variable
 
$is_sql_variable = ($c == '@');
$is_digit = (!$is_sql_variable) && PMA_STR_isDigit($c);
$is_hex_digit = ($is_digit) && ($c == '.') && ($c == '0') && ($count2 < $len) && (PMA_substr($sql, $count2, 1) == 'x');
$is_float_digit = $c == '.';
$is_float_digit_exponent = FALSE;
 
// Nijel: Fast skip is especially needed for huge BLOB data, requires PHP at least 4.3.0:
if (PMA_PHP_INT_VERSION >= 40300) {
if ($is_hex_digit) {
$count2++;
$pos = strspn($sql, '0123456789abcdefABCDEF', $count2);
if ($pos > $count2) {
$count2 = $pos;
}
unset($pos);
} elseif ($is_digit) {
$pos = strspn($sql, '0123456789', $count2);
if ($pos > $count2) {
$count2 = $pos;
}
unset($pos);
}
}
 
while (($count2 < $len) && PMA_STR_isSqlIdentifier(PMA_substr($sql, $count2, 1), ($is_sql_variable || $is_digit))) {
$c2 = PMA_substr($sql, $count2, 1);
if ($is_sql_variable && ($c2 == '.')) {
$count2++;
continue;
}
if ($is_digit && (!$is_hex_digit) && ($c2 == '.')) {
$count2++;
if (!$is_float_digit) {
$is_float_digit = TRUE;
continue;
} else {
$debugstr = $GLOBALS['strSQPBugInvalidIdentifer'] . ' @ ' . ($count1+1) . "\n"
. 'STR: ' . htmlspecialchars(PMA_substr($sql, $count1, $count2 - $count1));
PMA_SQP_throwError($debugstr, $sql);
return $sql;
}
}
if ($is_digit && (!$is_hex_digit) && (($c2 == 'e') || ($c2 == 'E'))) {
if (!$is_float_digit_exponent) {
$is_float_digit_exponent = TRUE;
$is_float_digit = TRUE;
$count2++;
continue;
} else {
$is_digit = FALSE;
$is_float_digit = FALSE;
}
}
if (($is_hex_digit && PMA_STR_isHexDigit($c2)) || ($is_digit && PMA_STR_isDigit($c2))) {
$count2++;
continue;
} else {
$is_digit = FALSE;
$is_hex_digit = FALSE;
}
 
$count2++;
} // end while
 
$l = $count2 - $count1;
$str = PMA_substr($sql, $count1, $l);
 
$type = '';
if ($is_digit) {
$type = 'digit';
if ($is_float_digit) {
$type .= '_float';
} elseif ($is_hex_digit) {
$type .= '_hex';
} else {
$type .= '_integer';
}
} else {
if ($is_sql_variable != FALSE) {
$type = 'alpha_variable';
} else {
$type = 'alpha';
}
} // end if... else....
PMA_SQP_arrayAdd($sql_array, $type, $str, $arraysize);
 
continue;
}
 
// Checks for punct
if (PMA_STR_strInStr($c, $allpunct_list)) {
while (($count2 < $len) && PMA_STR_strInStr(PMA_substr($sql, $count2, 1), $allpunct_list)) {
$count2++;
}
$l = $count2 - $count1;
if ($l == 1) {
$punct_data = $c;
} else {
$punct_data = PMA_substr($sql, $count1, $l);
}
 
// Special case, sometimes, althought two characters are
// adjectent directly, they ACTUALLY need to be seperate
if ($l == 1) {
$t_suffix = '';
switch ($punct_data) {
case $punct_queryend:
$t_suffix = '_queryend';
break;
case $punct_qualifier:
$t_suffix = '_qualifier';
break;
case $punct_listsep:
$t_suffix = '_listsep';
break;
default:
break;
}
PMA_SQP_arrayAdd($sql_array, 'punct' . $t_suffix, $punct_data, $arraysize);
} elseif (PMA_STR_binarySearchInArr($punct_data, $allpunct_list_pair, $allpunct_list_pair_size)) {
// Ok, we have one of the valid combined punct expressions
PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize);
} else {
// Bad luck, lets split it up more
$first = $punct_data[0];
$first2 = $punct_data[0] . $punct_data[1];
$last2 = $punct_data[$l - 2] . $punct_data[$l - 1];
$last = $punct_data[$l - 1];
if (($first == ',') || ($first == ';') || ($first == '.') || ($first == '*')) {
$count2 = $count1 + 1;
$punct_data = $first;
} elseif (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || PMA_substr($sql, $count2, 1) <= ' ') )) {
$count2 -= 2;
$punct_data = PMA_substr($sql, $count1, $count2 - $count1);
} elseif (($last == '-') || ($last == '+') || ($last == '!')) {
$count2--;
$punct_data = PMA_substr($sql, $count1, $count2 - $count1);
// TODO: for negation operator, split in 2 tokens ?
// "select x&~1 from t"
// becomes "select x & ~ 1 from t" ?
 
} elseif ($last != '~') {
$debugstr = $GLOBALS['strSQPBugUnknownPunctuation'] . ' @ ' . ($count1+1) . "\n"
. 'STR: ' . htmlspecialchars($punct_data);
PMA_SQP_throwError($debugstr, $sql);
return $sql;
}
PMA_SQP_arrayAdd($sql_array, 'punct', $punct_data, $arraysize);
continue;
} // end if... elseif... else
continue;
}
 
// DEBUG
$count2++;
 
$debugstr = 'C1 C2 LEN: ' . $count1 . ' ' . $count2 . ' ' . $len . "\n"
. 'STR: ' . PMA_substr($sql, $count1, $count2 - $count1) . "\n";
PMA_SQP_bug($debugstr, $sql);
return $sql;
 
} // end while ($count2 < $len)
 
 
if ($arraysize > 0) {
$t_next = $sql_array[0]['type'];
$t_prev = '';
$t_bef_prev = '';
$t_cur = '';
$d_next = $sql_array[0]['data'];
$d_prev = '';
$d_bef_prev = '';
$d_cur = '';
$d_next_upper = $t_next == 'alpha' ? strtoupper($d_next) : $d_next;
$d_prev_upper = '';
$d_bef_prev_upper = '';
$d_cur_upper = '';
}
 
for ($i = 0; $i < $arraysize; $i++) {
$t_bef_prev = $t_prev;
$t_prev = $t_cur;
$t_cur = $t_next;
$d_bef_prev = $d_prev;
$d_prev = $d_cur;
$d_cur = $d_next;
$d_bef_prev_upper = $d_prev_upper;
$d_prev_upper = $d_cur_upper;
$d_cur_upper = $d_next_upper;
if (($i + 1) < $arraysize) {
$t_next = $sql_array[$i + 1]['type'];
$d_next = $sql_array[$i + 1]['data'];
$d_next_upper = $t_next == 'alpha' ? strtoupper($d_next) : $d_next;
} else {
$t_next = '';
$d_next = '';
$d_next_upper = '';
}
 
//DEBUG echo "[prev: <b>".$d_prev."</b> ".$t_prev."][cur: <b>".$d_cur."</b> ".$t_cur."][next: <b>".$d_next."</b> ".$t_next."]<br />";
 
if ($t_cur == 'alpha') {
$t_suffix = '_identifier';
if (($t_next == 'punct_qualifier') || ($t_prev == 'punct_qualifier')) {
$t_suffix = '_identifier';
} elseif (($t_next == 'punct_bracket_open_round')
&& PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_function_name, $PMA_SQPdata_function_name_cnt)) {
// FIXME-2005-10-16: in the case of a CREATE TABLE containing a TIMESTAMP,
// since TIMESTAMP() is also a function, it's found here and
// the token is wrongly marked as alpha_functionName. But we
// compensate for this when analysing for timestamp_not_null
// later in this script.
$t_suffix = '_functionName';
} elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_type, $PMA_SQPdata_column_type_cnt)) {
$t_suffix = '_columnType';
// Temporary fix for BUG #621357
//TODO FIX PROPERLY NEEDS OVERHAUL OF SQL TOKENIZER
if ($d_cur_upper == 'SET' && $t_next != 'punct_bracket_open_round') {
$t_suffix = '_reservedWord';
}
//END OF TEMPORARY FIX
// CHARACTER is a synonym for CHAR, but can also be meant as
// CHARACTER SET. In this case, we have a reserved word.
if ($d_cur_upper == 'CHARACTER' && $d_next_upper == 'SET') {
$t_suffix = '_reservedWord';
}
// experimental
// current is a column type, so previous must not be
// a reserved word but an identifier
// CREATE TABLE SG_Persons (first varchar(64))
//if ($sql_array[$i-1]['type'] =='alpha_reservedWord') {
// $sql_array[$i-1]['type'] = 'alpha_identifier';
//}
} elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_reserved_word, $PMA_SQPdata_reserved_word_cnt)) {
$t_suffix = '_reservedWord';
} elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_attrib, $PMA_SQPdata_column_attrib_cnt)) {
$t_suffix = '_columnAttrib';
// INNODB is a MySQL table type, but in "SHOW INNODB STATUS",
// it should be regarded as a reserved word.
if ($d_cur_upper == 'INNODB' && $d_prev_upper == 'SHOW' && $d_next_upper == 'STATUS') {
$t_suffix = '_reservedWord';
}
if ($d_cur_upper == 'DEFAULT' && $d_next_upper == 'CHARACTER') {
$t_suffix = '_reservedWord';
}
// Binary as character set
if ($d_cur_upper == 'BINARY' && (
($d_bef_prev_upper == 'CHARACTER' && $d_prev_upper == 'SET')
|| ($d_bef_prev_upper == 'SET' && $d_prev_upper == '=')
|| ($d_bef_prev_upper == 'CHARSET' && $d_prev_upper == '=')
|| $d_prev_upper == 'CHARSET'
) && PMA_STR_binarySearchInArr($d_cur, $mysql_charsets, count($mysql_charsets))) {
$t_suffix = '_charset';
}
} elseif (PMA_STR_binarySearchInArr($d_cur, $mysql_charsets, $mysql_charsets_count)
|| PMA_STR_binarySearchInArr($d_cur, $mysql_collations_flat, $mysql_collations_count)
|| ($d_cur{0} == '_' && PMA_STR_binarySearchInArr(substr($d_cur, 1), $mysql_charsets, $mysql_charsets_count))) {
$t_suffix = '_charset';
} else {
// Do nothing
}
// check if present in the list of forbidden words
if ($t_suffix == '_reservedWord' && PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_forbidden_word, $PMA_SQPdata_forbidden_word_cnt)) {
$sql_array[$i]['forbidden'] = TRUE;
} else {
$sql_array[$i]['forbidden'] = FALSE;
}
$sql_array[$i]['type'] .= $t_suffix;
}
} // end for
 
// Stores the size of the array inside the array, as count() is a slow
// operation.
$sql_array['len'] = $arraysize;
 
// Sends the data back
return $sql_array;
} // end of the "PMA_SQP_parse()" function
 
/**
* Checks for token types being what we want...
*
* @param string String of type that we have
* @param string String of type that we want
*
* @return boolean result of check
*
* @access private
*/
function PMA_SQP_typeCheck($toCheck, $whatWeWant)
{
$typeSeperator = '_';
if (strcmp($whatWeWant, $toCheck) == 0) {
return TRUE;
} else {
if (strpos($whatWeWant, $typeSeperator) === FALSE) {
return strncmp($whatWeWant, $toCheck, strpos($toCheck, $typeSeperator)) == 0;
} else {
return FALSE;
}
}
}
 
 
/**
* Analyzes SQL queries
*
* @param array The SQL queries
*
* @return array The analyzed SQL queries
*
* @access public
*/
function PMA_SQP_analyze($arr)
{
if ($arr == array()) {
return array();
}
$result = array();
$size = $arr['len'];
$subresult = array(
'querytype' => '',
'select_expr_clause'=> '', // the whole stuff between SELECT and FROM , except DISTINCT
'position_of_first_select' => '', // the array index
'from_clause'=> '',
'group_by_clause'=> '',
'order_by_clause'=> '',
'having_clause' => '',
'where_clause' => '',
'where_clause_identifiers' => array(),
'unsorted_query' => '',
'queryflags' => array(),
'select_expr' => array(),
'table_ref' => array(),
'foreign_keys' => array(),
'create_table_fields' => array()
);
$subresult_empty = $subresult;
$seek_queryend = FALSE;
$seen_end_of_table_ref = FALSE;
$number_of_brackets_in_extract = 0;
$number_of_brackets_in_group_concat = 0;
 
// for SELECT EXTRACT(YEAR_MONTH FROM CURDATE())
// we must not use CURDATE as a table_ref
// so we track wether we are in the EXTRACT()
$in_extract = FALSE;
 
// for GROUP_CONCAT( ... )
$in_group_concat = FALSE;
 
/* Description of analyzer results by lem9
*
* db, table, column, alias
* ------------------------
*
* Inside the $subresult array, we create ['select_expr'] and ['table_ref'] arrays.
*
* The SELECT syntax (simplified) is
*
* SELECT
* select_expression,...
* [FROM [table_references]
*
*
* ['select_expr'] is filled with each expression, the key represents the
* expression position in the list (0-based) (so we don't lose track of
* multiple occurences of the same column).
*
* ['table_ref'] is filled with each table ref, same thing for the key.
*
* I create all sub-values empty, even if they are
* not present (for example no select_expression alias).
*
* There is a debug section at the end of loop #1, if you want to
* see the exact contents of select_expr and table_ref
*
* queryflags
* ----------
*
* In $subresult, array 'queryflags' is filled, according to what we
* find in the query.
*
* Currently, those are generated:
*
* ['queryflags']['need_confirm'] = 1; if the query needs confirmation
* ['queryflags']['select_from'] = 1; if this is a real SELECT...FROM
* ['queryflags']['distinct'] = 1; for a DISTINCT
* ['queryflags']['union'] = 1; for a UNION
* ['queryflags']['join'] = 1; for a JOIN
* ['queryflags']['offset'] = 1; for the presence of OFFSET
*
* query clauses
* -------------
*
* The select is splitted in those clauses:
* ['select_expr_clause']
* ['from_clause']
* ['group_by_clause']
* ['order_by_clause']
* ['having_clause']
* ['where_clause']
*
* The identifiers of the WHERE clause are put into the array
* ['where_clause_identifier']
*
* For a SELECT, the whole query without the ORDER BY clause is put into
* ['unsorted_query']
*
* foreign keys
* ------------
* The CREATE TABLE may contain FOREIGN KEY clauses, so they get
* analyzed and ['foreign_keys'] is an array filled with
* the constraint name, the index list,
* the REFERENCES table name and REFERENCES index list,
* and ON UPDATE | ON DELETE clauses
*
* position_of_first_select
* ------------------------
*
* The array index of the first SELECT we find. Will be used to
* insert a SQL_CALC_FOUND_ROWS.
*
* create_table_fields
* -------------------
*
* For now, mostly used to detect the DEFAULT CURRENT_TIMESTAMP and
* ON UPDATE CURRENT_TIMESTAMP clauses of the CREATE TABLE query.
* An array, each element is the identifier name.
* Note that for now, the timestamp_not_null element is created
* even for non-TIMESTAMP fields.
*
* Sub-elements: ['type'] which contains the column type
* optional (currently they are never false but can be absent):
* ['default_current_timestamp'] boolean
* ['on_update_current_timestamp'] boolean
* ['timestamp_not_null'] boolean
*
* section_before_limit, section_after_limit
* -----------------------------------------
*
* Marks the point of the query where we can insert a LIMIT clause;
* so the section_before_limit will contain the left part before
* a possible LIMIT clause
*
*
* End of description of analyzer results
*/
 
// must be sorted
// TODO: current logic checks for only one word, so I put only the
// first word of the reserved expressions that end a table ref;
// maybe this is not ok (the first word might mean something else)
// $words_ending_table_ref = array(
// 'FOR UPDATE',
// 'GROUP BY',
// 'HAVING',
// 'LIMIT',
// 'LOCK IN SHARE MODE',
// 'ORDER BY',
// 'PROCEDURE',
// 'UNION',
// 'WHERE'
// );
$words_ending_table_ref = array(
'FOR',
'GROUP',
'HAVING',
'LIMIT',
'LOCK',
'ORDER',
'PROCEDURE',
'UNION',
'WHERE'
);
$words_ending_table_ref_cnt = 9; //count($words_ending_table_ref);
 
$words_ending_clauses = array(
'FOR',
'LIMIT',
'LOCK',
'PROCEDURE',
'UNION'
);
$words_ending_clauses_cnt = 5; //count($words_ending_clauses);
 
 
 
 
// must be sorted
$supported_query_types = array(
'SELECT'
/*
// Support for these additional query types will come later on.
'DELETE',
'INSERT',
'REPLACE',
'TRUNCATE',
'UPDATE'
'EXPLAIN',
'DESCRIBE',
'SHOW',
'CREATE',
'SET',
'ALTER'
*/
);
$supported_query_types_cnt = count($supported_query_types);
 
// loop #1 for each token: select_expr, table_ref for SELECT
 
for ($i = 0; $i < $size; $i++) {
//DEBUG echo "trace loop1 <b>" . $arr[$i]['data'] . "</b> (" . $arr[$i]['type'] . ")<br />";
 
// High speed seek for locating the end of the current query
if ($seek_queryend == TRUE) {
if ($arr[$i]['type'] == 'punct_queryend') {
$seek_queryend = FALSE;
} else {
continue;
} // end if (type == punct_queryend)
} // end if ($seek_queryend)
 
// TODO: when we find a UNION, should we split
// in another subresult?
// Note: do not split if this is a punct_queryend for the
// first and only query
if ($arr[$i]['type'] == 'punct_queryend' && ($i + 1 != $size)) {
$result[] = $subresult;
$subresult = $subresult_empty;
continue;
} // end if (type == punct_queryend)
 
// ==============================================================
if ($arr[$i]['type'] == 'punct_bracket_open_round') {
if ($in_extract) {
$number_of_brackets_in_extract++;
}
if ($in_group_concat) {
$number_of_brackets_in_group_concat++;
}
}
// ==============================================================
if ($arr[$i]['type'] == 'punct_bracket_close_round') {
if ($in_extract) {
$number_of_brackets_in_extract--;
if ($number_of_brackets_in_extract == 0) {
$in_extract = FALSE;
}
}
if ($in_group_concat) {
$number_of_brackets_in_group_concat--;
if ($number_of_brackets_in_group_concat == 0) {
$in_group_concat = FALSE;
}
}
}
// ==============================================================
if ($arr[$i]['type'] == 'alpha_functionName') {
$upper_data = strtoupper($arr[$i]['data']);
if ($upper_data =='EXTRACT') {
$in_extract = TRUE;
$number_of_brackets_in_extract = 0;
}
if ($upper_data =='GROUP_CONCAT') {
$in_group_concat = TRUE;
$number_of_brackets_in_group_concat = 0;
}
}
 
// ==============================================================
if ($arr[$i]['type'] == 'alpha_reservedWord'
// && $arr[$i]['forbidden'] == FALSE) {
) {
// We don't know what type of query yet, so run this
if ($subresult['querytype'] == '') {
$subresult['querytype'] = strtoupper($arr[$i]['data']);
} // end if (querytype was empty)
 
// Check if we support this type of query
if (!PMA_STR_binarySearchInArr($subresult['querytype'], $supported_query_types, $supported_query_types_cnt)) {
// Skip ahead to the next one if we don't
$seek_queryend = TRUE;
continue;
} // end if (query not supported)
 
// upper once
$upper_data = strtoupper($arr[$i]['data']);
//TODO: reset for each query?
 
if ($upper_data == 'SELECT') {
$seen_from = FALSE;
$previous_was_identifier = FALSE;
$current_select_expr = -1;
$seen_end_of_table_ref = FALSE;
} // end if ( data == SELECT)
 
if ($upper_data =='FROM' && !$in_extract) {
$current_table_ref = -1;
$seen_from = TRUE;
$previous_was_identifier = FALSE;
$save_table_ref = TRUE;
} // end if (data == FROM)
 
// here, do not 'continue' the loop, as we have more work for
// reserved words below
} // end if (type == alpha_reservedWord)
 
// ==============================
if ($arr[$i]['type'] == 'quote_backtick'
|| $arr[$i]['type'] == 'quote_double'
|| $arr[$i]['type'] == 'quote_single'
|| $arr[$i]['type'] == 'alpha_identifier'
|| ($arr[$i]['type'] == 'alpha_reservedWord'
&& $arr[$i]['forbidden'] == FALSE)) {
 
switch ($arr[$i]['type']) {
case 'alpha_identifier':
case 'alpha_reservedWord':
// this is not a real reservedWord, because
// it's not present in the list of forbidden words,
// for example "storage" which can be used as
// an identifier
//
// TODO: avoid the pretty printing in color
// in this case
 
$identifier = $arr[$i]['data'];
break;
 
//TODO: check embedded double quotes or backticks?
// and/or remove just the first and last character?
case 'quote_backtick':
$identifier = str_replace('`', '', $arr[$i]['data']);
break;
case 'quote_double':
$identifier = str_replace('"', '', $arr[$i]['data']);
break;
case 'quote_single':
$identifier = str_replace("'", "", $arr[$i]['data']);
break;
} // end switch
 
if ($subresult['querytype'] == 'SELECT' && !$in_group_concat) {
if (!$seen_from) {
if ($previous_was_identifier && isset($chain)) {
// found alias for this select_expr, save it
// but only if we got something in $chain
// (for example, SELECT COUNT(*) AS cnt
// puts nothing in $chain, so we avoid
// setting the alias)
$alias_for_select_expr = $identifier;
} else {
$chain[] = $identifier;
$previous_was_identifier = TRUE;
 
} // end if !$previous_was_identifier
} else {
// ($seen_from)
if ($save_table_ref && !$seen_end_of_table_ref) {
if ($previous_was_identifier) {
// found alias for table ref
// save it for later
$alias_for_table_ref = $identifier;
} else {
$chain[] = $identifier;
$previous_was_identifier = TRUE;
 
} // end if ($previous_was_identifier)
} // end if ($save_table_ref &&!$seen_end_of_table_ref)
} // end if (!$seen_from)
} // end if (querytype SELECT)
} // end if ( quote_backtick or double quote or alpha_identifier)
 
// ===================================
if ($arr[$i]['type'] == 'punct_qualifier') {
// to be able to detect an identifier following another
$previous_was_identifier = FALSE;
continue;
} // end if (punct_qualifier)
 
// TODO: check if 3 identifiers following one another -> error
 
// s a v e a s e l e c t e x p r
// finding a list separator or FROM
// means that we must save the current chain of identifiers
// into a select expression
 
// for now, we only save a select expression if it contains
// at least one identifier, as we are interested in checking
// the columns and table names, so in "select * from persons",
// the "*" is not saved
 
if (isset($chain) && !$seen_end_of_table_ref
&& ( (!$seen_from
&& $arr[$i]['type'] == 'punct_listsep')
|| ($arr[$i]['type'] == 'alpha_reservedWord' && $upper_data == 'FROM')) ) {
$size_chain = count($chain);
$current_select_expr++;
$subresult['select_expr'][$current_select_expr] = array(
'expr' => '',
'alias' => '',
'db' => '',
'table_name' => '',
'table_true_name' => '',
'column' => ''
);
 
if (isset($alias_for_select_expr) && strlen($alias_for_select_expr)) {
// we had found an alias for this select expression
$subresult['select_expr'][$current_select_expr]['alias'] = $alias_for_select_expr;
unset($alias_for_select_expr);
}
// there is at least a column
$subresult['select_expr'][$current_select_expr]['column'] = $chain[$size_chain - 1];
$subresult['select_expr'][$current_select_expr]['expr'] = $chain[$size_chain - 1];
 
// maybe a table
if ($size_chain > 1) {
$subresult['select_expr'][$current_select_expr]['table_name'] = $chain[$size_chain - 2];
// we assume for now that this is also the true name
$subresult['select_expr'][$current_select_expr]['table_true_name'] = $chain[$size_chain - 2];
$subresult['select_expr'][$current_select_expr]['expr']
= $subresult['select_expr'][$current_select_expr]['table_name']
. '.' . $subresult['select_expr'][$current_select_expr]['expr'];
} // end if ($size_chain > 1)
 
// maybe a db
if ($size_chain > 2) {
$subresult['select_expr'][$current_select_expr]['db'] = $chain[$size_chain - 3];
$subresult['select_expr'][$current_select_expr]['expr']
= $subresult['select_expr'][$current_select_expr]['db']
. '.' . $subresult['select_expr'][$current_select_expr]['expr'];
} // end if ($size_chain > 2)
unset($chain);
 
// TODO: explain this:
if (($arr[$i]['type'] == 'alpha_reservedWord')
&& ($upper_data != 'FROM')) {
$previous_was_identifier = TRUE;
}
 
} // end if (save a select expr)
 
 
//======================================
// s a v e a t a b l e r e f
//======================================
 
// maybe we just saw the end of table refs
// but the last table ref has to be saved
// or we are at the last token (TODO: there could be another
// query after this one)
// or we just got a reserved word
 
if (isset($chain) && $seen_from && $save_table_ref
&& ($arr[$i]['type'] == 'punct_listsep'
|| ($arr[$i]['type'] == 'alpha_reservedWord' && $upper_data!="AS")
|| $seen_end_of_table_ref
|| $i==$size-1 )) {
 
$size_chain = count($chain);
$current_table_ref++;
$subresult['table_ref'][$current_table_ref] = array(
'expr' => '',
'db' => '',
'table_name' => '',
'table_alias' => '',
'table_true_name' => ''
);
if (isset($alias_for_table_ref) && strlen($alias_for_table_ref)) {
$subresult['table_ref'][$current_table_ref]['table_alias'] = $alias_for_table_ref;
unset($alias_for_table_ref);
}
$subresult['table_ref'][$current_table_ref]['table_name'] = $chain[$size_chain - 1];
// we assume for now that this is also the true name
$subresult['table_ref'][$current_table_ref]['table_true_name'] = $chain[$size_chain - 1];
$subresult['table_ref'][$current_table_ref]['expr']
= $subresult['table_ref'][$current_table_ref]['table_name'];
// maybe a db
if ($size_chain > 1) {
$subresult['table_ref'][$current_table_ref]['db'] = $chain[$size_chain - 2];
$subresult['table_ref'][$current_table_ref]['expr']
= $subresult['table_ref'][$current_table_ref]['db']
. '.' . $subresult['table_ref'][$current_table_ref]['expr'];
} // end if ($size_chain > 1)
 
// add the table alias into the whole expression
$subresult['table_ref'][$current_table_ref]['expr']
.= ' ' . $subresult['table_ref'][$current_table_ref]['table_alias'];
 
unset($chain);
$previous_was_identifier = TRUE;
//continue;
 
} // end if (save a table ref)
 
 
// when we have found all table refs,
// for each table_ref alias, put the true name of the table
// in the corresponding select expressions
 
if (isset($current_table_ref) && ($seen_end_of_table_ref || $i == $size-1) && $subresult != $subresult_empty) {
for ($tr=0; $tr <= $current_table_ref; $tr++) {
$alias = $subresult['table_ref'][$tr]['table_alias'];
$truename = $subresult['table_ref'][$tr]['table_true_name'];
for ($se=0; $se <= $current_select_expr; $se++) {
if (isset($alias) && strlen($alias) && $subresult['select_expr'][$se]['table_true_name']
== $alias) {
$subresult['select_expr'][$se]['table_true_name']
= $truename;
} // end if (found the alias)
} // end for (select expressions)
 
} // end for (table refs)
} // end if (set the true names)
 
 
// e n d i n g l o o p #1
// set the $previous_was_identifier to FALSE if the current
// token is not an identifier
if (($arr[$i]['type'] != 'alpha_identifier')
&& ($arr[$i]['type'] != 'quote_double')
&& ($arr[$i]['type'] != 'quote_single')
&& ($arr[$i]['type'] != 'quote_backtick')) {
$previous_was_identifier = FALSE;
} // end if
 
// however, if we are on AS, we must keep the $previous_was_identifier
if (($arr[$i]['type'] == 'alpha_reservedWord')
&& ($upper_data == 'AS')) {
$previous_was_identifier = TRUE;
}
 
if (($arr[$i]['type'] == 'alpha_reservedWord')
&& ($upper_data =='ON' || $upper_data =='USING')) {
$save_table_ref = FALSE;
} // end if (data == ON)
 
if (($arr[$i]['type'] == 'alpha_reservedWord')
&& ($upper_data =='JOIN' || $upper_data =='FROM')) {
$save_table_ref = TRUE;
} // end if (data == JOIN)
 
// no need to check the end of table ref if we already did
// TODO: maybe add "&& $seen_from"
if (!$seen_end_of_table_ref) {
// if this is the last token, it implies that we have
// seen the end of table references
// Check for the end of table references
//
// Note: if we are analyzing a GROUP_CONCAT clause,
// we might find a word that seems to indicate that
// we have found the end of table refs (like ORDER)
// but it's a modifier of the GROUP_CONCAT so
// it's not the real end of table refs
if (($i == $size-1)
|| ($arr[$i]['type'] == 'alpha_reservedWord'
&& !$in_group_concat
&& PMA_STR_binarySearchInArr($upper_data, $words_ending_table_ref, $words_ending_table_ref_cnt))) {
$seen_end_of_table_ref = TRUE;
// to be able to save the last table ref, but do not
// set it true if we found a word like "ON" that has
// already set it to false
if (isset($save_table_ref) && $save_table_ref != FALSE) {
$save_table_ref = TRUE;
} //end if
 
} // end if (check for end of table ref)
} //end if (!$seen_end_of_table_ref)
 
if ($seen_end_of_table_ref) {
$save_table_ref = FALSE;
} // end if
 
} // end for $i (loop #1)
 
// -------------------------------------------------------
// This is a big hunk of debugging code by Marc for this.
// -------------------------------------------------------
/*
if (isset($current_select_expr)) {
for ($trace=0; $trace<=$current_select_expr; $trace++) {
echo "<br />";
reset ($subresult['select_expr'][$trace]);
while (list ($key, $val) = each ($subresult['select_expr'][$trace]))
echo "sel expr $trace $key => $val<br />\n";
}
}
 
if (isset($current_table_ref)) {
echo "current_table_ref = " . $current_table_ref . "<br>";
for ($trace=0; $trace<=$current_table_ref; $trace++) {
 
echo "<br />";
reset ($subresult['table_ref'][$trace]);
while (list ($key, $val) = each ($subresult['table_ref'][$trace]))
echo "table ref $trace $key => $val<br />\n";
}
}
*/
// -------------------------------------------------------
 
 
// loop #2: - queryflags
// - querytype (for queries != 'SELECT')
// - section_before_limit, section_after_limit
//
// we will also need this queryflag in loop 2
// so set it here
if (isset($current_table_ref) && $current_table_ref > -1) {
$subresult['queryflags']['select_from'] = 1;
}
 
$collect_section_before_limit = TRUE;
$section_before_limit = '';
$section_after_limit = '';
$seen_reserved_word = FALSE;
$seen_group = FALSE;
$seen_order = FALSE;
$in_group_by = FALSE; // true when we are inside the GROUP BY clause
$in_order_by = FALSE; // true when we are inside the ORDER BY clause
$in_having = FALSE; // true when we are inside the HAVING clause
$in_select_expr = FALSE; // true when we are inside the select expr clause
$in_where = FALSE; // true when we are inside the WHERE clause
$in_from = FALSE;
$in_group_concat = FALSE;
$unsorted_query = '';
$first_reserved_word = '';
$current_identifier = '';
 
for ($i = 0; $i < $size; $i++) {
//DEBUG echo "trace loop2 <b>" . $arr[$i]['data'] . "</b> (" . $arr[$i]['type'] . ")<br />";
 
// need_confirm
//
// check for reserved words that will have to generate
// a confirmation request later in sql.php
// the cases are:
// DROP TABLE
// DROP DATABASE
// ALTER TABLE... DROP
// DELETE FROM...
//
// this code is not used for confirmations coming from functions.js
 
// TODO: check for punct_queryend
 
 
// TODO: verify C-style comments?
if ($arr[$i]['type'] == 'comment_ansi') {
$collect_section_before_limit = FALSE;
}
 
if ($arr[$i]['type'] == 'alpha_reservedWord') {
$upper_data = strtoupper($arr[$i]['data']);
if (!$seen_reserved_word) {
$first_reserved_word = $upper_data;
$subresult['querytype'] = $upper_data;
$seen_reserved_word = TRUE;
 
// if the first reserved word is DROP or DELETE,
// we know this is a query that needs to be confirmed
if ($first_reserved_word=='DROP'
|| $first_reserved_word == 'DELETE'
|| $first_reserved_word == 'TRUNCATE') {
$subresult['queryflags']['need_confirm'] = 1;
}
 
if ($first_reserved_word=='SELECT'){
$position_of_first_select = $i;
}
 
} else {
if ($upper_data=='DROP' && $first_reserved_word=='ALTER') {
$subresult['queryflags']['need_confirm'] = 1;
}
}
 
if ($upper_data == 'PROCEDURE') {
$collect_section_before_limit = FALSE;
}
// TODO: set also to FALSE if we find
// FOR UPDATE
// LOCK IN SHARE MODE
 
if ($upper_data == 'SELECT') {
$in_select_expr = TRUE;
$select_expr_clause = '';
}
if ($upper_data == 'DISTINCT' && !$in_group_concat) {
$subresult['queryflags']['distinct'] = 1;
}
 
if ($upper_data == 'UNION') {
$subresult['queryflags']['union'] = 1;
}
 
if ($upper_data == 'JOIN') {
$subresult['queryflags']['join'] = 1;
}
 
if ($upper_data == 'OFFSET') {
$subresult['queryflags']['offset'] = 1;
}
 
// if this is a real SELECT...FROM
if ($upper_data == 'FROM' && isset($subresult['queryflags']['select_from']) && $subresult['queryflags']['select_from'] == 1) {
$in_from = TRUE;
$from_clause = '';
$in_select_expr = FALSE;
}
 
 
// (we could have less resetting of variables to FALSE
// if we trust that the query respects the standard
// MySQL order for clauses)
 
// we use $seen_group and $seen_order because we are looking
// for the BY
if ($upper_data == 'GROUP') {
$seen_group = TRUE;
$seen_order = FALSE;
$in_having = FALSE;
$in_order_by = FALSE;
$in_where = FALSE;
$in_select_expr = FALSE;
$in_from = FALSE;
}
if ($upper_data == 'ORDER' && !$in_group_concat) {
$seen_order = TRUE;
$seen_group = FALSE;
$in_having = FALSE;
$in_group_by = FALSE;
$in_where = FALSE;
$in_select_expr = FALSE;
$in_from = FALSE;
}
if ($upper_data == 'HAVING') {
$in_having = TRUE;
$having_clause = '';
$seen_group = FALSE;
$seen_order = FALSE;
$in_group_by = FALSE;
$in_order_by = FALSE;
$in_where = FALSE;
$in_select_expr = FALSE;
$in_from = FALSE;
}
 
if ($upper_data == 'WHERE') {
$in_where = TRUE;
$where_clause = '';
$where_clause_identifiers = array();
$seen_group = FALSE;
$seen_order = FALSE;
$in_group_by = FALSE;
$in_order_by = FALSE;
$in_having = FALSE;
$in_select_expr = FALSE;
$in_from = FALSE;
}
 
if ($upper_data == 'BY') {
if ($seen_group) {
$in_group_by = TRUE;
$group_by_clause = '';
}
if ($seen_order) {
$in_order_by = TRUE;
$order_by_clause = '';
}
}
 
// if we find one of the words that could end the clause
if (PMA_STR_binarySearchInArr($upper_data, $words_ending_clauses, $words_ending_clauses_cnt)) {
 
$in_group_by = FALSE;
$in_order_by = FALSE;
$in_having = FALSE;
$in_where = FALSE;
$in_select_expr = FALSE;
$in_from = FALSE;
}
 
} // endif (reservedWord)
 
 
// do not add a blank after a function name
// TODO: can we combine loop 2 and loop 1?
// some code is repeated here...
 
$sep=' ';
if ($arr[$i]['type'] == 'alpha_functionName') {
$sep='';
$upper_data = strtoupper($arr[$i]['data']);
if ($upper_data =='GROUP_CONCAT') {
$in_group_concat = TRUE;
$number_of_brackets_in_group_concat = 0;
}
}
 
if ($arr[$i]['type'] == 'punct_bracket_open_round') {
if ($in_group_concat) {
$number_of_brackets_in_group_concat++;
}
}
if ($arr[$i]['type'] == 'punct_bracket_close_round') {
if ($in_group_concat) {
$number_of_brackets_in_group_concat--;
if ($number_of_brackets_in_group_concat == 0) {
$in_group_concat = FALSE;
}
}
}
 
if ($in_select_expr && $upper_data != 'SELECT' && $upper_data != 'DISTINCT') {
$select_expr_clause .= $arr[$i]['data'] . $sep;
}
if ($in_from && $upper_data != 'FROM') {
$from_clause .= $arr[$i]['data'] . $sep;
}
if ($in_group_by && $upper_data != 'GROUP' && $upper_data != 'BY') {
$group_by_clause .= $arr[$i]['data'] . $sep;
}
if ($in_order_by && $upper_data != 'ORDER' && $upper_data != 'BY') {
$order_by_clause .= $arr[$i]['data'] . $sep;
}
if ($in_having && $upper_data != 'HAVING') {
$having_clause .= $arr[$i]['data'] . $sep;
}
if ($in_where && $upper_data != 'WHERE') {
$where_clause .= $arr[$i]['data'] . $sep;
 
if (($arr[$i]['type'] == 'quote_backtick')
|| ($arr[$i]['type'] == 'alpha_identifier')) {
$where_clause_identifiers[] = $arr[$i]['data'];
}
}
 
if (isset($subresult['queryflags']['select_from'])
&& $subresult['queryflags']['select_from'] == 1
&& !$seen_order) {
$unsorted_query .= $arr[$i]['data'];
 
if ($arr[$i]['type'] != 'punct_bracket_open_round'
&& $arr[$i]['type'] != 'punct_bracket_close_round'
&& $arr[$i]['type'] != 'punct') {
$unsorted_query .= $sep;
}
}
 
// clear $upper_data for next iteration
$upper_data='';
 
if ($collect_section_before_limit && $arr[$i]['type'] != 'punct_queryend') {
$section_before_limit .= $arr[$i]['data'] . $sep;
} else {
$section_after_limit .= $arr[$i]['data'] . $sep;
}
 
 
} // end for $i (loop #2)
 
 
// -----------------------------------------------------
// loop #3: foreign keys and MySQL 4.1.2+ TIMESTAMP options
// (for now, check only the first query)
// (for now, identifiers are assumed to be backquoted)
 
// If we find that we are dealing with a CREATE TABLE query,
// we look for the next punct_bracket_open_round, which
// introduces the fields list. Then, when we find a
// quote_backtick, it must be a field, so we put it into
// the create_table_fields array. Even if this field is
// not a timestamp, it will be useful when logic has been
// added for complete field attributes analysis.
 
$seen_foreign = FALSE;
$seen_references = FALSE;
$seen_constraint = FALSE;
$foreign_key_number = -1;
$seen_create_table = FALSE;
$seen_create = FALSE;
$in_create_table_fields = FALSE;
$brackets_level = 0;
$in_timestamp_options = FALSE;
$seen_default = FALSE;
 
for ($i = 0; $i < $size; $i++) {
// DEBUG echo "<b>" . $arr[$i]['data'] . "</b> " . $arr[$i]['type'] . "<br />";
 
if ($arr[$i]['type'] == 'alpha_reservedWord') {
$upper_data = strtoupper($arr[$i]['data']);
 
if ($upper_data == 'NOT' && $in_timestamp_options) {
$create_table_fields[$current_identifier]['timestamp_not_null'] = TRUE;
 
}
 
if ($upper_data == 'CREATE') {
$seen_create = TRUE;
}
 
if ($upper_data == 'TABLE' && $seen_create) {
$seen_create_table = TRUE;
$create_table_fields = array();
}
 
if ($upper_data == 'CURRENT_TIMESTAMP') {
if ($in_timestamp_options) {
if ($seen_default) {
$create_table_fields[$current_identifier]['default_current_timestamp'] = TRUE;
}
}
}
 
if ($upper_data == 'CONSTRAINT') {
$foreign_key_number++;
$seen_foreign = FALSE;
$seen_references = FALSE;
$seen_constraint = TRUE;
}
if ($upper_data == 'FOREIGN') {
$seen_foreign = TRUE;
$seen_references = FALSE;
$seen_constraint = FALSE;
}
if ($upper_data == 'REFERENCES') {
$seen_foreign = FALSE;
$seen_references = TRUE;
$seen_constraint = FALSE;
}
 
 
// Cases covered:
 
// [ON DELETE {CASCADE | SET NULL | NO ACTION | RESTRICT}]
// [ON UPDATE {CASCADE | SET NULL | NO ACTION | RESTRICT}]
 
// but we set ['on_delete'] or ['on_cascade'] to
// CASCADE | SET_NULL | NO_ACTION | RESTRICT
 
// ON UPDATE CURRENT_TIMESTAMP
 
if ($upper_data == 'ON') {
if ($arr[$i+1]['type'] == 'alpha_reservedWord') {
$second_upper_data = strtoupper($arr[$i+1]['data']);
if ($second_upper_data == 'DELETE') {
$clause = 'on_delete';
}
if ($second_upper_data == 'UPDATE') {
$clause = 'on_update';
}
if (isset($clause)
&& ($arr[$i+2]['type'] == 'alpha_reservedWord'
 
// ugly workaround because currently, NO is not
// in the list of reserved words in sqlparser.data
// (we got a bug report about not being able to use
// 'no' as an identifier)
|| ($arr[$i+2]['type'] == 'alpha_identifier'
&& strtoupper($arr[$i+2]['data'])=='NO') )
) {
$third_upper_data = strtoupper($arr[$i+2]['data']);
if ($third_upper_data == 'CASCADE'
|| $third_upper_data == 'RESTRICT') {
$value = $third_upper_data;
} elseif ($third_upper_data == 'SET'
|| $third_upper_data == 'NO') {
if ($arr[$i+3]['type'] == 'alpha_reservedWord') {
$value = $third_upper_data . '_' . strtoupper($arr[$i+3]['data']);
}
} elseif ($third_upper_data == 'CURRENT_TIMESTAMP') {
if ($clause == 'on_update'
&& $in_timestamp_options) {
$create_table_fields[$current_identifier]['on_update_current_timestamp'] = TRUE;
$seen_default = FALSE;
}
 
} else {
$value = '';
}
if (!empty($value)) {
$foreign[$foreign_key_number][$clause] = $value;
}
unset($clause);
} // endif (isset($clause))
}
}
 
} // end of reserved words analysis
 
 
if ($arr[$i]['type'] == 'punct_bracket_open_round') {
$brackets_level++;
if ($seen_create_table && $brackets_level == 1) {
$in_create_table_fields = TRUE;
}
}
 
 
if ($arr[$i]['type'] == 'punct_bracket_close_round') {
$brackets_level--;
if ($seen_references) {
$seen_references = FALSE;
}
if ($seen_create_table && $brackets_level == 0) {
$in_create_table_fields = FALSE;
}
}
 
if (($arr[$i]['type'] == 'alpha_columnAttrib')) {
$upper_data = strtoupper($arr[$i]['data']);
if ($seen_create_table && $in_create_table_fields) {
if ($upper_data == 'DEFAULT') {
$seen_default = TRUE;
}
}
}
 
// note: the "or" part here is a workaround for a bug
// (see FIXME-2005-10-16)
if (($arr[$i]['type'] == 'alpha_columnType') || ($arr[$i]['type'] == 'alpha_functionName' && $seen_create_table)) {
$upper_data = strtoupper($arr[$i]['data']);
if ($seen_create_table && $in_create_table_fields && isset($current_identifier)) {
$create_table_fields[$current_identifier]['type'] = $upper_data;
if ($upper_data == 'TIMESTAMP') {
$in_timestamp_options = TRUE;
} else {
$in_timestamp_options = FALSE;
}
}
}
 
 
if ($arr[$i]['type'] == 'quote_backtick' || $arr[$i]['type'] == 'alpha_identifier') {
 
if ($arr[$i]['type'] == 'quote_backtick') {
// remove backquotes
$identifier = str_replace('`', '', $arr[$i]['data']);
} else {
$identifier = $arr[$i]['data'];
}
 
if ($seen_create_table && $in_create_table_fields) {
$current_identifier = $identifier;
// warning: we set this one even for non TIMESTAMP type
$create_table_fields[$current_identifier]['timestamp_not_null'] = FALSE;
}
 
if ($seen_constraint) {
$foreign[$foreign_key_number]['constraint'] = $identifier;
}
 
if ($seen_foreign && $brackets_level > 0) {
$foreign[$foreign_key_number]['index_list'][] = $identifier;
}
 
if ($seen_references) {
// here, the first bracket level corresponds to the
// bracket of CREATE TABLE
// so if we are on level 2, it must be the index list
// of the foreign key REFERENCES
if ($brackets_level > 1) {
$foreign[$foreign_key_number]['ref_index_list'][] = $identifier;
} else {
// for MySQL 4.0.18, identifier is
// `table` or `db`.`table`
// the first pass will pick the db name
// the next pass will execute the else and pick the
// db name in $db_table[0]
if ($arr[$i+1]['type'] == 'punct_qualifier') {
$foreign[$foreign_key_number]['ref_db_name'] = $identifier;
} else {
// for MySQL 4.0.16, identifier is
// `table` or `db.table`
$db_table = explode('.', $identifier);
if (isset($db_table[1])) {
$foreign[$foreign_key_number]['ref_db_name'] = $db_table[0];
$foreign[$foreign_key_number]['ref_table_name'] = $db_table[1];
} else {
$foreign[$foreign_key_number]['ref_table_name'] = $db_table[0];
}
}
}
}
}
} // end for $i (loop #3)
 
 
// Fill the $subresult array
 
if (isset($create_table_fields)) {
$subresult['create_table_fields'] = $create_table_fields;
}
 
if (isset($foreign)) {
$subresult['foreign_keys'] = $foreign;
}
 
if (isset($select_expr_clause)) {
$subresult['select_expr_clause'] = $select_expr_clause;
}
if (isset($from_clause)) {
$subresult['from_clause'] = $from_clause;
}
if (isset($group_by_clause)) {
$subresult['group_by_clause'] = $group_by_clause;
}
if (isset($order_by_clause)) {
$subresult['order_by_clause'] = $order_by_clause;
}
if (isset($having_clause)) {
$subresult['having_clause'] = $having_clause;
}
if (isset($where_clause)) {
$subresult['where_clause'] = $where_clause;
}
if (isset($unsorted_query) && !empty($unsorted_query)) {
$subresult['unsorted_query'] = $unsorted_query;
}
if (isset($where_clause_identifiers)) {
$subresult['where_clause_identifiers'] = $where_clause_identifiers;
}
 
if (isset($position_of_first_select)) {
$subresult['position_of_first_select'] = $position_of_first_select;
$subresult['section_before_limit'] = $section_before_limit;
$subresult['section_after_limit'] = $section_after_limit;
}
 
// They are naughty and didn't have a trailing semi-colon,
// then still handle it properly
if ($subresult['querytype'] != '') {
$result[] = $subresult;
}
return $result;
} // end of the "PMA_SQP_analyze()" function
 
 
/**
* Colorizes SQL queries html formatted
*
* @param array The SQL queries html formatted
*
* @return array The colorized SQL queries
*
* @access public
*/
function PMA_SQP_formatHtml_colorize($arr)
{
$i = $GLOBALS['PMA_strpos']($arr['type'], '_');
$class = '';
if ($i > 0) {
$class = 'syntax_' . PMA_substr($arr['type'], 0, $i) . ' ';
}
 
$class .= 'syntax_' . $arr['type'];
 
//TODO: check why adding a "\n" after the </span> would cause extra
// blanks to be displayed:
// SELECT p . person_name
 
return '<span class="' . $class . '">' . htmlspecialchars($arr['data']) . '</span>';
} // end of the "PMA_SQP_formatHtml_colorize()" function
 
 
/**
* Formats SQL queries to html
*
* @param array The SQL queries
* @param string mode
* @param integer starting token
* @param integer number of tokens to format, -1 = all
*
* @return string The formatted SQL queries
*
* @access public
*/
function PMA_SQP_formatHtml($arr, $mode='color', $start_token=0,
$number_of_tokens=-1)
{
// then check for an array
if (!is_array($arr)) {
return htmlspecialchars($arr);
}
// first check for the SQL parser having hit an error
if (PMA_SQP_isError()) {
return htmlspecialchars($arr['raw']);
}
// else do it properly
switch ($mode) {
case 'color':
$str = '<span class="syntax">';
$html_line_break = '<br />';
break;
case 'query_only':
$str = '';
$html_line_break = "\n";
break;
case 'text':
$str = '';
$html_line_break = '<br />';
break;
} // end switch
$indent = 0;
$bracketlevel = 0;
$functionlevel = 0;
$infunction = FALSE;
$space_punct_listsep = ' ';
$space_punct_listsep_function_name = ' ';
// $space_alpha_reserved_word = '<br />'."\n";
$space_alpha_reserved_word = ' ';
 
$keywords_with_brackets_1before = array(
'INDEX',
'KEY',
'ON',
'USING'
);
$keywords_with_brackets_1before_cnt = 4;
 
$keywords_with_brackets_2before = array(
'IGNORE',
'INDEX',
'INTO',
'KEY',
'PRIMARY',
'PROCEDURE',
'REFERENCES',
'UNIQUE',
'USE'
);
// $keywords_with_brackets_2before_cnt = count($keywords_with_brackets_2before);
$keywords_with_brackets_2before_cnt = 9;
 
// These reserved words do NOT get a newline placed near them.
$keywords_no_newline = array(
'AS',
'ASC',
'DESC',
'DISTINCT',
'HOUR',
'INTERVAL',
'IS',
'LIKE',
'NOT',
'NULL',
'ON',
'REGEXP'
);
$keywords_no_newline_cnt = 12;
 
// These reserved words introduce a privilege list
$keywords_priv_list = array(
'GRANT',
'REVOKE'
);
$keywords_priv_list_cnt = 2;
 
if ($number_of_tokens == -1) {
$arraysize = $arr['len'];
} else {
$arraysize = $number_of_tokens;
}
$typearr = array();
if ($arraysize >= 0) {
$typearr[0] = '';
$typearr[1] = '';
$typearr[2] = '';
//$typearr[3] = $arr[0]['type'];
$typearr[3] = $arr[$start_token]['type'];
}
 
$in_priv_list = FALSE;
for ($i = $start_token; $i < $arraysize; $i++) {
// DEBUG echo "<b>" . $arr[$i]['data'] . "</b> " . $arr[$i]['type'] . "<br />";
$before = '';
$after = '';
$indent = 0;
// array_shift($typearr);
/*
0 prev2
1 prev
2 current
3 next
*/
if (($i + 1) < $arraysize) {
// array_push($typearr, $arr[$i + 1]['type']);
$typearr[4] = $arr[$i + 1]['type'];
} else {
//array_push($typearr, null);
$typearr[4] = '';
}
 
for ($j=0; $j<4; $j++) {
$typearr[$j] = $typearr[$j + 1];
}
 
switch ($typearr[2]) {
case 'white_newline':
$before = '';
break;
case 'punct_bracket_open_round':
$bracketlevel++;
$infunction = FALSE;
// Make sure this array is sorted!
if (($typearr[1] == 'alpha_functionName') || ($typearr[1] == 'alpha_columnType') || ($typearr[1] == 'punct')
|| ($typearr[3] == 'digit_integer') || ($typearr[3] == 'digit_hex') || ($typearr[3] == 'digit_float')
|| (($typearr[0] == 'alpha_reservedWord')
&& PMA_STR_binarySearchInArr(strtoupper($arr[$i - 2]['data']), $keywords_with_brackets_2before, $keywords_with_brackets_2before_cnt))
|| (($typearr[1] == 'alpha_reservedWord')
&& PMA_STR_binarySearchInArr(strtoupper($arr[$i - 1]['data']), $keywords_with_brackets_1before, $keywords_with_brackets_1before_cnt))
) {
$functionlevel++;
$infunction = TRUE;
$after .= ' ';
} else {
$indent++;
$after .= ($mode != 'query_only' ? '<div class="syntax_indent' . $indent . '">' : ' ');
}
break;
case 'alpha_identifier':
if (($typearr[1] == 'punct_qualifier') || ($typearr[3] == 'punct_qualifier')) {
$after = '';
$before = '';
}
if (($typearr[3] == 'alpha_columnType') || ($typearr[3] == 'alpha_identifier')) {
$after .= ' ';
}
break;
case 'punct_qualifier':
$before = '';
$after = '';
break;
case 'punct_listsep':
if ($infunction == TRUE) {
$after .= $space_punct_listsep_function_name;
} else {
$after .= $space_punct_listsep;
}
break;
case 'punct_queryend':
if (($typearr[3] != 'comment_mysql') && ($typearr[3] != 'comment_ansi') && $typearr[3] != 'comment_c') {
$after .= $html_line_break;
$after .= $html_line_break;
}
$space_punct_listsep = ' ';
$space_punct_listsep_function_name = ' ';
$space_alpha_reserved_word = ' ';
$in_priv_list = FALSE;
break;
case 'comment_mysql':
case 'comment_ansi':
$after .= $html_line_break;
break;
case 'punct':
$before .= ' ';
// workaround for
// select * from mytable limit 0,-1
// (a side effect of this workaround is that
// select 20 - 9
// becomes
// select 20 -9
// )
if ($typearr[3] != 'digit_integer') {
$after .= ' ';
}
break;
case 'punct_bracket_close_round':
$bracketlevel--;
if ($infunction == TRUE) {
$functionlevel--;
$after .= ' ';
$before .= ' ';
} else {
$indent--;
$before .= ($mode != 'query_only' ? '</div>' : ' ');
}
$infunction = ($functionlevel > 0) ? TRUE : FALSE;
break;
case 'alpha_columnType':
if ($typearr[3] == 'alpha_columnAttrib') {
$after .= ' ';
}
if ($typearr[1] == 'alpha_columnType') {
$before .= ' ';
}
break;
case 'alpha_columnAttrib':
 
// ALTER TABLE tbl_name AUTO_INCREMENT = 1
// COLLATE LATIN1_GENERAL_CI DEFAULT
if ($typearr[1] == 'alpha_identifier' || $typearr[1] == 'alpha_charset') {
$before .= ' ';
}
if (($typearr[3] == 'alpha_columnAttrib') || ($typearr[3] == 'quote_single') || ($typearr[3] == 'digit_integer')) {
$after .= ' ';
}
// workaround for
// select * from mysql.user where binary user="root"
// binary is marked as alpha_columnAttrib
// but should be marked as a reserved word
if (strtoupper($arr[$i]['data']) == 'BINARY'
&& $typearr[3] == 'alpha_identifier') {
$after .= ' ';
}
break;
case 'alpha_reservedWord':
// do not uppercase the reserved word if we are calling
// this function in query_only mode, because we need
// the original query (otherwise we get problems with
// semi-reserved words like "storage" which is legal
// as an identifier name)
 
if ($mode != 'query_only') {
$arr[$i]['data'] = strtoupper($arr[$i]['data']);
}
 
if ((($typearr[1] != 'alpha_reservedWord')
|| (($typearr[1] == 'alpha_reservedWord')
&& PMA_STR_binarySearchInArr(strtoupper($arr[$i - 1]['data']), $keywords_no_newline, $keywords_no_newline_cnt)))
&& ($typearr[1] != 'punct_level_plus')
&& (!PMA_STR_binarySearchInArr($arr[$i]['data'], $keywords_no_newline, $keywords_no_newline_cnt))) {
// do not put a space before the first token, because
// we use a lot of eregi() checking for the first
// reserved word at beginning of query
// so do not put a newline before
//
// also we must not be inside a privilege list
if ($i > 0) {
// the alpha_identifier exception is there to
// catch cases like
// GRANT SELECT ON mydb.mytable TO myuser@localhost
// (else, we get mydb.mytableTO )
//
// the quote_single exception is there to
// catch cases like
// GRANT ... TO 'marc'@'domain.com' IDENTIFIED...
//
// TODO: fix all cases and find why this happens
 
if (!$in_priv_list || $typearr[1] == 'alpha_identifier' || $typearr[1] == 'quote_single' || $typearr[1] == 'white_newline') {
$before .= $space_alpha_reserved_word;
}
} else {
// on first keyword, check if it introduces a
// privilege list
if (PMA_STR_binarySearchInArr($arr[$i]['data'], $keywords_priv_list, $keywords_priv_list_cnt)) {
$in_priv_list = TRUE;
}
}
} else {
$before .= ' ';
}
 
switch ($arr[$i]['data']) {
case 'CREATE':
if (!$in_priv_list) {
$space_punct_listsep = $html_line_break;
$space_alpha_reserved_word = ' ';
}
break;
case 'EXPLAIN':
case 'DESCRIBE':
case 'SET':
case 'ALTER':
case 'DELETE':
case 'SHOW':
case 'DROP':
case 'UPDATE':
case 'TRUNCATE':
case 'ANALYZE':
case 'ANALYSE':
if (!$in_priv_list) {
$space_punct_listsep = $html_line_break;
$space_alpha_reserved_word = ' ';
}
break;
case 'INSERT':
case 'REPLACE':
if (!$in_priv_list) {
$space_punct_listsep = $html_line_break;
$space_alpha_reserved_word = $html_line_break;
}
break;
case 'VALUES':
$space_punct_listsep = ' ';
$space_alpha_reserved_word = $html_line_break;
break;
case 'SELECT':
$space_punct_listsep = ' ';
$space_alpha_reserved_word = $html_line_break;
break;
default:
break;
} // end switch ($arr[$i]['data'])
 
$after .= ' ';
break;
case 'digit_integer':
case 'digit_float':
case 'digit_hex':
//TODO: could there be other types preceding a digit?
if ($typearr[1] == 'alpha_reservedWord') {
$after .= ' ';
}
if ($infunction && $typearr[3] == 'punct_bracket_close_round') {
$after .= ' ';
}
if ($typearr[1] == 'alpha_columnAttrib') {
$before .= ' ';
}
break;
case 'alpha_variable':
// other workaround for a problem similar to the one
// explained below for quote_single
if (!$in_priv_list) {
$after = ' ';
}
break;
case 'quote_double':
case 'quote_single':
// workaround: for the query
// REVOKE SELECT ON `base2\_db`.* FROM 'user'@'%'
// the @ is incorrectly marked as alpha_variable
// in the parser, and here, the '%' gets a blank before,
// which is a syntax error
if ($typearr[1] !='alpha_variable') {
$before .= ' ';
}
if ($infunction && $typearr[3] == 'punct_bracket_close_round') {
$after .= ' ';
}
break;
case 'quote_backtick':
if ($typearr[3] != 'punct_qualifier') {
$after .= ' ';
}
if ($typearr[1] != 'punct_qualifier') {
$before .= ' ';
}
break;
default:
break;
} // end switch ($typearr[2])
 
/*
if ($typearr[3] != 'punct_qualifier') {
$after .= ' ';
}
$after .= "\n";
*/
$str .= $before . ($mode=='color' ? PMA_SQP_formatHTML_colorize($arr[$i]) : $arr[$i]['data']). $after;
} // end for
if ($mode=='color') {
$str .= '</span>';
}
 
return $str;
} // end of the "PMA_SQP_formatHtml()" function
}
 
/**
* Builds a CSS rule used for html formatted SQL queries
*
* @param string The class name
* @param string The property name
* @param string The property value
*
* @return string The CSS rule
*
* @access public
*
* @see PMA_SQP_buildCssData()
*/
function PMA_SQP_buildCssRule($classname, $property, $value)
{
$str = '.' . $classname . ' {';
if ($value != '') {
$str .= $property . ': ' . $value . ';';
}
$str .= '}' . "\n";
 
return $str;
} // end of the "PMA_SQP_buildCssRule()" function
 
 
/**
* Builds CSS rules used for html formatted SQL queries
*
* @return string The CSS rules set
*
* @access public
*
* @global array The current PMA configuration
*
* @see PMA_SQP_buildCssRule()
*/
function PMA_SQP_buildCssData()
{
global $cfg;
 
$css_string = '';
foreach ($cfg['SQP']['fmtColor'] AS $key => $col) {
$css_string .= PMA_SQP_buildCssRule('syntax_' . $key, 'color', $col);
}
 
for ($i = 0; $i < 8; $i++) {
$css_string .= PMA_SQP_buildCssRule('syntax_indent' . $i, 'margin-left', ($i * $cfg['SQP']['fmtInd']) . $cfg['SQP']['fmtIndUnit']);
}
 
return $css_string;
} // end of the "PMA_SQP_buildCssData()" function
 
if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
/**
* Gets SQL queries with no format
*
* @param array The SQL queries list
*
* @return string The SQL queries with no format
*
* @access public
*/
function PMA_SQP_formatNone($arr)
{
$formatted_sql = htmlspecialchars($arr['raw']);
$formatted_sql = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $formatted_sql);
 
return $formatted_sql;
} // end of the "PMA_SQP_formatNone()" function
 
 
/**
* Gets SQL queries in text format
*
* @param array The SQL queries list
*
* @return string The SQL queries in text format
*
* @access public
*/
function PMA_SQP_formatText($arr)
{
/**
* TODO WRITE THIS!
*/
return PMA_SQP_formatNone($arr);
} // end of the "PMA_SQP_formatText()" function
} // end if: minimal common.lib needed?
 
?>
/Web/Maintenance/phpMyAdmin/libraries/sqlvalidator.class.php
0,0 → 1,411
<?php
/* $Id: sqlvalidator.class.php,v 2.3 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* PHP interface to MimerSQL Validator
*
* Copyright 2002, 2003 Robin Johnson <robbat2@users.sourceforge.net>
* http://www.orbis-terrarum.net/?l=people.robbat2
*
* All data is transported over HTTP-SOAP
* And uses the PEAR SOAP Module
*
* Install instructions for PEAR SOAP
* Make sure you have a really recent PHP with PEAR support
* run this: "pear install Mail_Mime Net_DIME SOAP"
*
* If you got this file from somewhere other than phpMyAdmin
* please be aware that the latest copy will always be in the
* phpMyAdmin CVS tree as
* $Source: /cvsroot/phpmyadmin/phpMyAdmin/libraries/sqlvalidator.class.php,v $
*
* This code that also used to depend on the PHP overload module, but that has been
* removed now.
*
* @access public
*
* @author Robin Johnson <robbat2@users.sourceforge.net>
*
* @version $Id: sqlvalidator.class.php,v 2.3 2006/01/17 17:02:30 cybot_tm Exp $
*/
 
@include_once('SOAP/Client.php');
 
if (!function_exists('class_exists') || !class_exists('SOAP_Client')) {
$GLOBALS['sqlvalidator_error'] = TRUE;
} else {
// Ok, we have SOAP Support, so let's use it!
 
class PMA_SQLValidator {
 
var $url;
var $service_name;
var $wsdl;
var $output_type;
 
var $username;
var $password;
var $calling_program;
var $calling_program_version;
var $target_dbms;
var $target_dbms_version;
var $connectionTechnology;
var $connection_technology_version;
var $interactive;
 
var $service_link = null;
var $session_data = null;
 
 
/**
* Private functions - You don't need to mess with these
*/
 
/**
* Service opening
*
* @param string URL of Mimer SQL Validator WSDL file
*
* @return object Object to use
*
* @access private
*/
function _openService($url)
{
$obj = new SOAP_Client($url, TRUE);
return $obj;
} // end of the "openService()" function
 
 
/**
* Service initializer to connect to server
*
* @param object Service object
* @param string Username
* @param string Password
* @param string Name of calling program
* @param string Version of calling program
* @param string Target DBMS
* @param string Version of target DBMS
* @param string Connection Technology
* @param string version of Connection Technology
* @param integer boolean of 1/0 to specify if we are an interactive system
*
* @return object stdClass return object with data
*
* @access private
*/
function _openSession($obj, $username, $password,
$calling_program, $calling_program_version,
$target_dbms, $target_dbms_version,
$connection_technology, $connection_technology_version,
$interactive)
{
$use_array = array( "a_userName" => $username, "a_password" => $password, "a_callingProgram" => $calling_program, "a_callingProgramVersion" => $calling_program_version, "a_targetDbms" => $target_dbms, "a_targetDbmsVersion" => $target_dbms_version, "a_connectionTechnology" => $connection_technology, "a_connectionTechnologyVersion" => $connection_technology_version, "a_interactive" => $interactive);
$ret = $obj->call("openSession", $use_array);
 
// This is the old version that needed the overload extension
/* $ret = $obj->openSession($username, $password,
$calling_program, $calling_program_version,
$target_dbms, $target_dbms_version,
$connection_technology, $connection_technology_version,
$interactive); */
 
return $ret;
} // end of the "_openSession()" function
 
 
/**
* Validator sytem call
*
* @param object Service object
* @param object Session object
* @param string SQL Query to validate
* @param string Data return type
*
* @return object stClass return with data
*
* @access private
*/
function _validateSQL($obj, $session, $sql, $method)
{
$use_array = array("a_sessionId" => $session->sessionId, "a_sessionKey" => $session->sessionKey, "a_SQL" => $sql, "a_resultType" => $this->output_type);
$res = $obj->call("validateSQL", $use_array);
 
// This is the old version that needed the overload extension
// $res = $obj->validateSQL($session->sessionId, $session->sessionKey, $sql, $this->output_type);
return $res;
} // end of the "validateSQL()" function
 
 
/**
* Validator sytem call
*
* @param string SQL Query to validate
*
* @return object stdClass return with data
*
* @access private
*
* @see validateSQL()
*/
function _validate($sql)
{
$ret = $this->_validateSQL($this->service_link, $this->session_data,
$sql, $this->output_type);
return $ret;
} // end of the "validate()" function
 
 
/**
* Public functions
*/
 
/**
* Constructor
*
* @access public
*/
function PMA_SQLValidator()
{
$this->url = 'http://sqlvalidator.mimer.com/v1/services';
$this->service_name = 'SQL99Validator';
$this->wsdl = '?wsdl';
 
$this->output_type = 'html';
 
$this->username = 'anonymous';
$this->password = '';
$this->calling_program = 'PHP_SQLValidator';
$this->calling_program_version = '$Revision: 2.3 $';
$this->target_dbms = 'N/A';
$this->target_dbms_version = 'N/A';
$this->connection_technology = 'PHP';
$this->connection_technology_version = phpversion();
$this->interactive = 1;
 
$this->service_link = null;
$this->session_data = null;
} // end of the "PMA_SQLValidator()" function
 
 
/**
* Sets credentials
*
* @param string the username
* @param string the password
*
* @access public
*/
function setCredentials($username, $password)
{
$this->username = $username;
$this->password = $password;
} // end of the "setCredentials()" function
 
 
/**
* Sets the calling program
*
* @param string the calling program name
* @param string the calling program revision
*
* @access public
*/
function setCallingProgram($calling_program, $calling_program_version)
{
$this->calling_program = $calling_program;
$this->calling_program_version = $calling_program_version;
} // end of the "setCallingProgram()" function
 
 
/**
* Appends the calling program
*
* @param string the calling program name
* @param string the calling program revision
*
* @access public
*/
function appendCallingProgram($calling_program, $calling_program_version)
{
$this->calling_program .= ' - ' . $calling_program;
$this->calling_program_version .= ' - ' . $calling_program_version;
} // end of the "appendCallingProgram()" function
 
 
/**
* Sets the target DBMS
*
* @param string the target DBMS name
* @param string the target DBMS revision
*
* @access public
*/
function setTargetDbms($target_dbms, $target_dbms_version)
{
$this->target_dbms = $target_dbms;
$this->target_dbms_version = $target_dbms_version;
} // end of the "setTargetDbms()" function
 
 
/**
* Appends the target DBMS
*
* @param string the target DBMS name
* @param string the target DBMS revision
*
* @access public
*/
function appendTargetDbms($target_dbms, $target_dbms_version)
{
$this->target_dbms .= ' - ' . $target_dbms;
$this->target_dbms_version .= ' - ' . $target_dbms_version;
} // end of the "appendTargetDbms()" function
 
 
/**
* Sets the connection technology used
*
* @param string the connection technology name
* @param string the connection technology revision
*
* @access public
*/
function setConnectionTechnology($connection_technology, $connection_technology_version)
{
$this->connection_technology = $connection_technology;
$this->connection_technology_version = $connection_technology_version;
} // end of the "setConnectionTechnology()" function
 
 
/**
* Appends the connection technology used
*
* @param string the connection technology name
* @param string the connection technology revision
*
* @access public
*/
function appendConnectionTechnology($connection_technology, $connection_technology_version)
{
$this->connection_technology .= ' - ' . $connection_technology;
$this->connection_technology_version .= ' - ' . $connection_technology_version;
} // end of the "appendConnectionTechnology()" function
 
 
/**
* Sets whether interactive mode should be used or not
*
* @param integer whether interactive mode should be used or not
*
* @access public
*/
function setInteractive($interactive)
{
$this->interactive = $interactive;
} // end of the "setInteractive()" function
 
 
/**
* Sets the output type to use
*
* @param string the output type to use
*
* @access public
*/
function setOutputType($output_type)
{
$this->output_type = $output_type;
} // end of the "setOutputType()" function
 
 
/**
* Starts service
*
* @access public
*/
function startService()
{
 
$this->service_link = $this->_openService($this->url . '/' . $this->service_name . $this->wsdl);
 
} // end of the "startService()" function
 
 
/**
* Starts session
*
* @access public
*/
function startSession()
{
$this->session_data = $this->_openSession($this->service_link, $this->username, $this->password,
$this->calling_program, $this->calling_program_version,
$this->target_dbms, $this->target_dbms_version,
$this->connection_technology, $this->connection_technology_version,
$this->interactive);
 
if (isset($this->session_data) && ($this->session_data != null)
&& ($this->session_data->target != $this->url)) {
// Reopens the service on the new URL that was provided
$url = $this->session_data->target;
$this->startService();
}
} // end of the "startSession()" function
 
 
/**
* Do start service and session
*
* @access public
*/
function start()
{
$this->startService();
$this->startSession();
} // end of the "start()" function
 
 
/**
* Call to determine just if a query is valid or not.
*
* @param string SQL statement to validate
*
* @return string Validator string from Mimer
*
* @see _validate
*/
function isValid($sql)
{
$res = $this->_validate($sql);
return $res->standard;
} // end of the "isValid()" function
 
 
/**
* Call for complete validator response
*
* @param string SQL statement to validate
*
* @return string Validator string from Mimer
*
* @see _validate
*/
function validationString($sql)
{
$res = $this->_validate($sql);
return $res->data;
 
} // end of the "validationString()" function
} // end class PMA_SQLValidator
 
//add an extra check to ensure that the class was defined without errors
if (!class_exists('PMA_SQLValidator')) {
$GLOBALS['sqlvalidator_error'] = TRUE;
}
 
} // end else
 
?>
/Web/Maintenance/phpMyAdmin/libraries/sqlvalidator.lib.php
0,0 → 1,95
<?php
/* $Id: sqlvalidator.lib.php,v 2.3 2005/10/08 15:17:42 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/**
* SQL Validator interface for phpMyAdmin
*
* Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
* http://www.orbis-terrarum.net/?l=people.robbat2
*
* This function uses the Mimer SQL Validator service
* <http://developer.mimer.com/validator/index.htm> from phpMyAdmin
*
* Copyright for Server side validator systems:
* "All SQL statements are stored anonymously for statistical purposes.
* Mimer SQL Validator, Copyright 2002 Upright Database Technology.
* All rights reserved."
*
* All data is transported over HTTP-SOAP
* And uses the PEAR SOAP Module
*
* Install instructions for PEAR SOAP
* Make sure you have a really recent PHP with PEAR support
* run this: "pear install Mail_Mime Net_DIME SOAP"
*
* Enable the SQL Validator options in the configuration file
* $cfg['SQLQuery']['Validate'] = TRUE;
* $cfg['SQLValidator']['use'] = FALSE;
*
* Also set a username and password if you have a private one
*/
 
 
// We need the PEAR libraries, so do a minimum version check first
// I'm not sure if PEAR was available before this point
// For now we actually use a configuration flag
if ($cfg['SQLValidator']['use'] == TRUE) {
require_once('./libraries/sqlvalidator.class.php');
} // if ($cfg['SQLValidator']['use'] == TRUE)
 
 
/**
* This function utilizes the Mimer SQL Validator service
* to validate an SQL query
*
* <http://developer.mimer.com/validator/index.htm>
*
* @param string SQL query to validate
*
* @return string Validator result string
*
* @global array The PMA configuration array
*/
function PMA_validateSQL($sql)
{
global $cfg;
 
$str = '';
 
if ($cfg['SQLValidator']['use']) {
if (isset($GLOBALS['sqlvalidator_error'])
&& $GLOBALS['sqlvalidator_error']) {
$str = sprintf($GLOBALS['strValidatorError'], '<a href="./Documentation.html#faqsqlvalidator" target="documentation">', '</a>');
} else {
// create new class instance
$srv = new PMA_SQLValidator();
 
// Checks for username settings
// The class defaults to anonymous with an empty password
// automatically
if ($cfg['SQLValidator']['username'] != '') {
$srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']);
}
 
// Identify ourselves to the server properly...
$srv->appendCallingProgram('phpMyAdmin', PMA_VERSION);
 
// ... and specify what database system we are using
$srv->setTargetDbms('MySQL', PMA_MYSQL_STR_VERSION);
 
// Log on to service
$srv->start();
 
// Do service validation
$str = $srv->validationString($sql);
}
 
} // end if
 
// Gives string back to caller
return $str;
} // end of the "PMA_validateSQL()" function
 
?>
/Web/Maintenance/phpMyAdmin/libraries/storage_engines.lib.php
0,0 → 1,339
<?php
/* $Id: storage_engines.lib.php,v 2.8.2.1 2006/02/19 15:34:39 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Library for extracting information about the available storage engines
*/
 
$GLOBALS['mysql_storage_engines'] = array();
 
if (PMA_MYSQL_INT_VERSION >= 40102) {
/**
* For MySQL >= 4.1.2, the job is easy...
*/
$res = PMA_DBI_query('SHOW STORAGE ENGINES');
while ($row = PMA_DBI_fetch_assoc($res)) {
$GLOBALS['mysql_storage_engines'][strtolower($row['Engine'])] = $row;
}
PMA_DBI_free_result($res);
unset($res, $row);
} else {
/**
* Emulating SHOW STORAGE ENGINES...
*/
$GLOBALS['mysql_storage_engines'] = array(
'myisam' => array(
'Engine' => 'MyISAM',
'Support' => 'DEFAULT'
),
'merge' => array(
'Engine' => 'MERGE',
'Support' => 'YES'
),
'heap' => array(
'Engine' => 'HEAP',
'Support' => 'YES'
),
'memory' => array(
'Engine' => 'MEMORY',
'Support' => 'YES'
)
);
$known_engines = array(
'archive' => 'ARCHIVE',
'bdb' => 'BDB',
'csv' => 'CSV',
'innodb' => 'InnoDB',
'isam' => 'ISAM',
'gemini' => 'Gemini'
);
$res = PMA_DBI_query('SHOW VARIABLES LIKE \'have\\_%\';');
while ($row = PMA_DBI_fetch_row($res)) {
$current = substr($row[0], 5);
if (!empty($known_engines[$current])) {
$GLOBALS['mysql_storage_engines'][$current] = array(
'Engine' => $known_engines[$current],
'Support' => $row[1]
);
}
}
PMA_DBI_free_result($res);
unset($known_engines, $res, $row);
}
 
/**
* Function for generating the storage engine selection
*
* @author rabus
* @uses $GLOBALS['mysql_storage_engines']
* @param string $name The name of the select form element
* @param string $id The ID of the form field
* @param boolean $offerUnavailableEngines
* Should unavailable storage engines be offered?
* @param string $selected The selected engine
* @param int $indent The indentation level
* @return string html selectbox
*/
function PMA_generateEnginesDropdown($name = 'engine', $id = null,
$offerUnavailableEngines = false, $selected = null, $indent = 0)
{
$selected = strtolower($selected);
$spaces = str_repeat( ' ', $indent );
$output = $spaces . '<select name="' . $name . '"'
. (empty($id) ? '' : ' id="' . $id . '"') . '>' . "\n";
 
foreach ($GLOBALS['mysql_storage_engines'] as $key => $details) {
if (!$offerUnavailableEngines
&& ($details['Support'] == 'NO' || $details['Support'] == 'DISABLED')) {
continue;
}
$output .= $spaces . ' <option value="' . htmlspecialchars($key). '"'
. (empty($details['Comment'])
? '' : ' title="' . htmlspecialchars($details['Comment']) . '"')
. ($key == $selected || (empty($selected) && $details['Support'] == 'DEFAULT')
? ' selected="selected"' : '') . '>' . "\n"
. $spaces . ' ' . htmlspecialchars($details['Engine']) . "\n"
. $spaces . ' </option>' . "\n";
}
$output .= $spaces . '</select>' . "\n";
return $output;
}
 
/**
* defines
*/
define('PMA_ENGINE_SUPPORT_NO', 0);
define('PMA_ENGINE_SUPPORT_DISABLED', 1);
define('PMA_ENGINE_SUPPORT_YES', 2);
define('PMA_ENGINE_SUPPORT_DEFAULT', 3);
 
/**
* Abstract Storage Engine Class
*/
class PMA_StorageEngine
{
/**
* @var string engine name
*/
var $engine = 'dummy';
 
/**
* @var string engine title/description
*/
var $title = 'PMA Dummy Engine Class';
 
/**
* @var string engine lang description
*/
var $comment = 'If you read this text inside phpMyAdmin, something went wrong...';
 
/**
* @var integer engine supported by current server
*/
var $support = PMA_ENGINE_SUPPORT_NO;
 
/**
* public static final PMA_StorageEngine getEngine()
*
* Loads the corresponding engine plugin, if available.
*
* @uses str_replace()
* @uses file_exists()
* @uses PMA_StorageEngine
* @param string $engine The engine ID
* @return object The engine plugin
*/
function getEngine($engine)
{
$engine = str_replace('/', '', str_replace('.', '', $engine));
if (file_exists('./libraries/engines/' . $engine . '.lib.php')
&& include_once('./libraries/engines/' . $engine . '.lib.php')) {
$class_name = 'PMA_StorageEngine_' . $engine;
$engine_object = new $class_name($engine);
} else {
$engine_object = new PMA_StorageEngine($engine);
}
return $engine_object;
}
 
/**
* Constructor
*
* @uses $GLOBALS['mysql_storage_engines']
* @uses PMA_ENGINE_SUPPORT_DEFAULT
* @uses PMA_ENGINE_SUPPORT_YES
* @uses PMA_ENGINE_SUPPORT_DISABLED
* @uses PMA_ENGINE_SUPPORT_NO
* @uses $this->engine
* @uses $this->title
* @uses $this->comment
* @uses $this->support
* @param string $engine The engine ID
*/
function __construct($engine)
{
if (!empty($GLOBALS['mysql_storage_engines'][$engine])) {
$this->engine = $engine;
$this->title = $GLOBALS['mysql_storage_engines'][$engine]['Engine'];
$this->comment =
(isset($GLOBALS['mysql_storage_engines'][$engine]['Comment'])
? $GLOBALS['mysql_storage_engines'][$engine]['Comment']
: '');
switch ($GLOBALS['mysql_storage_engines'][$engine]['Support']) {
case 'DEFAULT':
$this->support = PMA_ENGINE_SUPPORT_DEFAULT;
break;
case 'YES':
$this->support = PMA_ENGINE_SUPPORT_YES;
break;
case 'DISABLED':
$this->support = PMA_ENGINE_SUPPORT_DISABLED;
break;
case 'NO':
default:
$this->support = PMA_ENGINE_SUPPORT_NO;
}
}
}
 
/**
* old PHP 4 style constructor
* @deprecated
* @see PMA_StorageEngine::__construct()
* @uses PMA_StorageEngine::__construct()
* @param string $engine engine name
*/
function PMA_StorageEngine($engine)
{
$this->__construct($engine);
}
 
/**
* public String getTitle()
*
* Reveals the engine's title
* @uses $this->title
* @return string The title
*/
function getTitle()
{
return $this->title;
}
 
/**
* public String getComment()
*
* Fetches the server's comment about this engine
* @uses $this->comment
* @return string The comment
*/
function getComment()
{
return $this->comment;
}
 
/**
* public String getSupportInformationMessage()
*
* @uses $GLOBALS['strDefaultEngine']
* @uses $GLOBALS['strEngineAvailable']
* @uses $GLOBALS['strEngineDisabled']
* @uses $GLOBALS['strEngineUnsupported']
* @uses $GLOBALS['strEngineUnsupported']
* @uses PMA_ENGINE_SUPPORT_DEFAULT
* @uses PMA_ENGINE_SUPPORT_YES
* @uses PMA_ENGINE_SUPPORT_DISABLED
* @uses PMA_ENGINE_SUPPORT_NO
* @uses $this->support
* @uses $this->title
* @uses sprintf
* @return string The localized message.
*/
function getSupportInformationMessage()
{
switch ($this->support) {
case PMA_ENGINE_SUPPORT_DEFAULT:
$message = $GLOBALS['strDefaultEngine'];
break;
case PMA_ENGINE_SUPPORT_YES:
$message = $GLOBALS['strEngineAvailable'];
break;
case PMA_ENGINE_SUPPORT_DISABLED:
$message = $GLOBALS['strEngineDisabled'];
break;
case PMA_ENGINE_SUPPORT_NO:
default:
$message = $GLOBALS['strEngineUnsupported'];
}
return sprintf($message, htmlspecialchars($this->title));
}
 
/**
* public string[][] getVariables()
*
* Generates a list of MySQL variables that provide information about this
* engine. This function should be overridden when extending this class
* for a particular engine.
*
* @abstract
* @return Array The list of variables.
*/
function getVariables()
{
return array();
}
 
/**
* returns string with filename for the MySQL helppage
* about this storage engne
*
* @return string mysql helppage filename
*/
function getMysqlHelpPage()
{
return $this->engine . '-storage-engine';
}
 
/**
* public string getVariablesLikePattern()
*
* @abstract
* @return string SQL query LIKE pattern
*/
function getVariablesLikePattern()
{
return false;
}
 
/**
* public String[] getInfoPages()
*
* Returns a list of available information pages with labels
*
* @abstract
* @return array The list
*/
function getInfoPages()
{
return array();
}
 
/**
* public String getPage()
*
* Generates the requested information page
*
* @abstract
* @param string $id The page ID
*
* @return string The page
* boolean or false on error.
*/
function getPage($id)
{
return false;
}
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/string.lib.php
0,0 → 1,384
<?php
/* $Id: string.lib.php,v 2.14 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/** Specialized String Functions for phpMyAdmin
*
* Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
* http://www.orbis-terrarum.net/?l=people.robbat2
*
* Defines a set of function callbacks that have a pure C version available if
* the "ctype" extension is available, but otherwise have PHP versions to use
* (that are slower).
*
* The SQL Parser code relies heavily on these functions.
*/
 
/* Try to load mbstring, unless we're using buggy php version */
if (PMA_PHP_INT_VERSION != 40203) {
if (!@extension_loaded('mbstring')) {
PMA_dl('mbstring');
}
}
 
/* windows-* and tis-620 are not supported and are not multibyte,
* others can be ignored as they're not multibyte */
$GLOBALS['using_mb_charset'] =
substr($GLOBALS['charset'], 0, 8) != 'windows-' &&
substr($GLOBALS['charset'], 0, 9) != 'iso-8859-' &&
substr($GLOBALS['charset'], 0, 3) != 'cp-' &&
$GLOBALS['charset'] != 'koi8-r' &&
$GLOBALS['charset'] != 'tis-620';
 
$GLOBALS['PMA_allow_mbstr'] = @function_exists('mb_strlen') && $GLOBALS['using_mb_charset'];
 
if ($GLOBALS['PMA_allow_mbstr']) {
// the hebrew lang file uses iso-8859-8-i, encoded RTL,
// but mb_internal_encoding only supports iso-8859-8
if ($GLOBALS['charset'] == 'iso-8859-8-i'){
mb_internal_encoding('iso-8859-8');
} else {
mb_internal_encoding($GLOBALS['charset']);
}
}
 
// This is for handling input better
if (defined('PMA_MULTIBYTE_ENCODING') || $GLOBALS['PMA_allow_mbstr']) {
$GLOBALS['PMA_strpos'] = 'mb_strpos';
$GLOBALS['PMA_strrpos'] = 'mb_strrpos';
} else {
$GLOBALS['PMA_strpos'] = 'strpos';
$GLOBALS['PMA_strrpos'] = 'strrpos';
}
 
/**
* Returns length of string depending on current charset.
*
* @param string string to count
*
* @return int string length
*
* @access public
*
* @author nijel
*/
function PMA_strlen($string)
{
// windows-* charsets are not multibyte and not supported by mb_*
if (defined('PMA_MULTIBYTE_ENCODING') || $GLOBALS['PMA_allow_mbstr']) {
return mb_strlen($string);
} else {
return strlen($string);
}
}
 
/**
* Returns substring from string, works depending on current charset.
*
* @param string string to count
* @param int start of substring
* @param int length of substring
*
* @return int substring
*
* @access public
*
* @author nijel
*/
function PMA_substr($string, $start, $length = 2147483647)
{
if (defined('PMA_MULTIBYTE_ENCODING') || $GLOBALS['PMA_allow_mbstr']) {
return mb_substr($string, $start, $length);
} else {
return substr($string, $start, $length);
}
}
 
 
/**
* This checks if a string actually exists inside another string
* We try to do it in a PHP3-portable way.
* We don't care about the position it is in.
*
* @param string string to search for
* @param string string to search in
*
* @return boolean whether the needle is in the haystack or not
*/
function PMA_STR_strInStr($needle, $haystack)
{
// $GLOBALS['PMA_strpos']($haystack, $needle) !== FALSE
// return (is_integer($GLOBALS['PMA_strpos']($haystack, $needle)));
return $GLOBALS['PMA_strpos'](' ' . $haystack, $needle);
} // end of the "PMA_STR_strInStr()" function
 
 
/**
* Checks if a given character position in the string is escaped or not
*
* @param string string to check for
* @param integer the character to check for
* @param integer starting position in the string
*
* @return boolean whether the character is escaped or not
*/
function PMA_STR_charIsEscaped($string, $pos, $start = 0)
{
$len = PMA_strlen($string);
// Base case:
// Check for string length or invalid input or special case of input
// (pos == $start)
if (($pos == $start) || ($len <= $pos)) {
return FALSE;
}
 
$p = $pos - 1;
$escaped = FALSE;
while (($p >= $start) && (PMA_substr($string, $p, 1) == '\\')) {
$escaped = !$escaped;
$p--;
} // end while
 
if ($pos < $start) {
// throw error about strings
}
 
return $escaped;
} // end of the "PMA_STR_charIsEscaped()" function
 
 
/**
* Checks if a number is in a range
*
* @param integer number to check for
* @param integer lower bound
* @param integer upper bound
*
* @return boolean whether the number is in the range or not
*/
function PMA_STR_numberInRangeInclusive($num, $lower, $upper)
{
return (($num >= $lower) && ($num <= $upper));
} // end of the "PMA_STR_numberInRangeInclusive()" function
 
 
/**
* Checks if a character is a digit
*
* @param string character to check for
*
* @return boolean whether the character is a digit or not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isDigit($c)
{
$ord_zero = 48; //ord('0');
$ord_nine = 57; //ord('9');
$ord_c = ord($c);
 
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "PMA_STR_isDigit()" function
 
 
/**
* Checks if a character is an hexadecimal digit
*
* @param string character to check for
*
* @return boolean whether the character is an hexadecimal digit or not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isHexDigit($c)
{
$ord_Aupper = 65; //ord('A');
$ord_Fupper = 70; //ord('F');
$ord_Alower = 97; //ord('a');
$ord_Flower = 102; //ord('f');
$ord_zero = 48; //ord('0');
$ord_nine = 57; //ord('9');
$ord_c = ord($c);
 
return (PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
} // end of the "PMA_STR_isHexDigit()" function
 
 
/**
* Checks if a character is an upper alphabetic one
*
* @param string character to check for
*
* @return boolean whether the character is an upper alphabetic one or
* not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isUpper($c)
{
$ord_zero = 65; //ord('A');
$ord_nine = 90; //ord('Z');
$ord_c = ord($c);
 
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "PMA_STR_isUpper()" function
 
 
/**
* Checks if a character is a lower alphabetic one
*
* @param string character to check for
*
* @return boolean whether the character is a lower alphabetic one or
* not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isLower($c)
{
$ord_zero = 97; //ord('a');
$ord_nine = 122; //ord('z');
$ord_c = ord($c);
 
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "PMA_STR_isLower()" function
 
 
/**
* Checks if a character is an alphabetic one
*
* @param string character to check for
*
* @return boolean whether the character is an alphabetic one or not
*
* @see PMA_STR_isUpper()
* @see PMA_STR_isLower()
*/
function PMA_STR_isAlpha($c)
{
return (PMA_STR_isUpper($c) || PMA_STR_isLower($c));
} // end of the "PMA_STR_isAlpha()" function
 
 
/**
* Checks if a character is an alphanumeric one
*
* @param string character to check for
*
* @return boolean whether the character is an alphanumeric one or not
*
* @see PMA_STR_isUpper()
* @see PMA_STR_isLower()
* @see PMA_STR_isDigit()
*/
function PMA_STR_isAlnum($c)
{
return (PMA_STR_isUpper($c) || PMA_STR_isLower($c) || PMA_STR_isDigit($c));
} // end of the "PMA_STR_isAlnum()" function
 
 
/**
* Checks if a character is a space one
*
* @param string character to check for
*
* @return boolean whether the character is a space one or not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isSpace($c)
{
$ord_space = 32; //ord(' ')
$ord_tab = 9; //ord('\t')
$ord_CR = 13; //ord('\n')
$ord_NOBR = 160; //ord('U+00A0);
$ord_c = ord($c);
 
return (($ord_c == $ord_space)
|| ($ord_c == $ord_NOBR)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
} // end of the "PMA_STR_isSpace()" function
 
 
/**
* Checks if a character is an accented character
*
* @note Presently this only works for some character sets. More work
* may be needed to fix it.
*
* @param string character to check for
*
* @return boolean whether the character is an accented one or not
*
* @see PMA_STR_numberInRangeInclusive()
*/
function PMA_STR_isAccented($c)
{
$ord_min1 = 192; //ord('A');
$ord_max1 = 214; //ord('Z');
$ord_min2 = 216; //ord('A');
$ord_max2 = 246; //ord('Z');
$ord_min3 = 248; //ord('A');
$ord_max3 = 255; //ord('Z');
 
$ord_c = ord($c);
 
return PMA_STR_numberInRangeInclusive($ord_c, $ord_min1, $ord_max1)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_min2, $ord_max2)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_min2, $ord_max2);
} // end of the "PMA_STR_isAccented()" function
 
 
/**
* Checks if a character is an SQL identifier
*
* @param string character to check for
* @param boolean whether the dot character is valid or not
*
* @return boolean whether the character is an SQL identifier or not
*
* @see PMA_STR_isAlnum()
*/
function PMA_STR_isSqlIdentifier($c, $dot_is_valid = FALSE)
{
return (PMA_STR_isAlnum($c)
|| PMA_STR_isAccented($c)
|| ($c == '_') || ($c == '$')
|| (($dot_is_valid != FALSE) && ($c == '.')));
} // end of the "PMA_STR_isSqlIdentifier()" function
 
 
/**
* Binary search of a value in a sorted array
*
* @param string string to search for
* @param array sorted array to search into
* @param integer size of sorted array to search into
*
* @return boolean whether the string has been found or not
*/
function PMA_STR_binarySearchInArr($str, $arr, $arrsize)
{
// $arr MUST be sorted, due to binary search
$top = $arrsize - 1;
$bottom = 0;
$found = FALSE;
 
while (($top >= $bottom) && ($found == FALSE)) {
$mid = intval(($top + $bottom) / 2);
$res = strcmp($str, $arr[$mid]);
if ($res == 0) {
$found = TRUE;
} elseif ($res < 0) {
$top = $mid - 1;
} else {
$bottom = $mid + 1;
}
} // end while
 
return $found;
} // end of the "PMA_STR_binarySearchInArr()" function
 
?>
/Web/Maintenance/phpMyAdmin/libraries/tbl_indexes.lib.php
0,0 → 1,258
<?php
/* $Id: tbl_indexes.lib.php,v 2.5 2006/01/17 17:02:31 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* function library for handling table indexes
*/
 
/**
* Return a list of all index types
*
* @access public
* @return array Index types
* @author Garvin Hicking (pma@supergarv.de)
*/
function PMA_get_indextypes() {
return array(
'PRIMARY',
'INDEX',
'UNIQUE',
'FULLTEXT'
);
}
 
/**
* Function to get all index information from a certain table
*
* @param string Table name
* @param string Error URL
*
* @access public
* @return array Index keys
*/
function PMA_get_indexes($tbl_name, $err_url_0 = '') {
$tbl_local_query = 'SHOW KEYS FROM ' . PMA_backquote($tbl_name);
$tbl_result = PMA_DBI_query($tbl_local_query) or PMA_mysqlDie('', $tbl_local_query, '', $err_url_0);
$tbl_ret_keys = array();
while ($tbl_row = PMA_DBI_fetch_assoc($tbl_result)) {
$tbl_ret_keys[] = $tbl_row;
}
PMA_DBI_free_result($tbl_result);
 
return $tbl_ret_keys;
}
 
/**
* Function to check over array of indexes and look for common problems
*
* @param array Array of indexes
* @param boolean Whether to output HTML in table layout
*
* @access public
* @return string Output HTML
* @author Garvin Hicking (pma@supergarv.de)
*/
function PMA_check_indexes($idx_collection, $table = true) {
$index_types = PMA_get_indextypes();
$output = '';
 
if ( ! is_array($idx_collection) || empty($idx_collection['ALL'])) {
return $output;
}
 
foreach ($idx_collection['ALL'] AS $w_keyname => $w_count) {
if (isset($idx_collection['PRIMARY'][$w_keyname]) && (isset($idx_collection['INDEX'][$w_keyname]) || isset($idx_collection['UNIQUE'][$w_keyname]))) {
$output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningPrimary'], htmlspecialchars($w_keyname)), $table);
} elseif (isset($idx_collection['UNIQUE'][$w_keyname]) && isset($idx_collection['INDEX'][$w_keyname])) {
$output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningUnique'], htmlspecialchars($w_keyname)), $table);
}
 
foreach ($index_types AS $index_type) {
if (isset($idx_collection[$index_type][$w_keyname]) && $idx_collection[$index_type][$w_keyname] > 1) {
$output .= PMA_index_warning(sprintf($GLOBALS['strIndexWarningMultiple'], $index_type, htmlspecialchars($w_keyname)), $table);
}
}
}
 
return $output;
}
 
/**
* Loop array of returned index keys and extract key information to
* seperate arrays. Those arrays are passed by reference.
*
* @param array Referenced Array of indexes
* @param array Referenced return array
* @param array Referenced return array
* @param array Referenced return array
*
* @access public
* @return boolean void
* @author Garvin Hicking (pma@supergarv.de)
*/
function PMA_extract_indexes(&$ret_keys, &$indexes, &$indexes_info, &$indexes_data) {
if (!is_array($ret_keys)) {
return false;
}
 
$prev_index = '';
foreach ($ret_keys as $row) {
if ($row['Key_name'] != $prev_index ){
$indexes[] = $row['Key_name'];
$prev_index = $row['Key_name'];
}
 
$indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
$indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
 
if (isset($row['Cardinality'])) {
$indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
}
 
// I don't know what does following column mean....
// $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
$indexes_info[$row['Key_name']]['Comment'] = (isset($row['Comment']))
? $row['Comment']
: '';
$indexes_info[$row['Key_name']]['Index_type'] = (isset($row['Index_type']))
? $row['Index_type']
: '';
 
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
if (isset($row['Sub_part'])) {
$indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
}
} // end while
 
return true;
}
 
/**
* Show index data and prepare returned collection array for index
* key checks.
*
* @param string $table The tablename
* @param array $indexes Referenced Array of indexes
* @param array $indexes_info Referenced info array
* @param array $indexes_data Referenced data array
* @param boolean $display_html Output HTML code, or just return collection array?
* @param boolean $print_mode
* @access public
* @return array Index collection array
* @author Garvin Hicking (pma@supergarv.de)
*/
function PMA_show_indexes($table, &$indexes, &$indexes_info, &$indexes_data, $display_html = true, $print_mode = false) {
$idx_collection = array();
$odd_row = true;
foreach ($indexes as $index_name) {
if ($display_html) {
$row_span = ' rowspan="' . count($indexes_info[$index_name]['Sequences']) . '" ';
 
echo ' <tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n";
echo ' <th ' . $row_span . '>' . "\n"
. ' ' . htmlspecialchars($index_name) . "\n"
. ' </th>' . "\n";
}
 
if ((PMA_MYSQL_INT_VERSION < 40002 && $indexes_info[$index_name]['Comment'] == 'FULLTEXT')
|| (PMA_MYSQL_INT_VERSION >= 40002 && $indexes_info[$index_name]['Index_type'] == 'FULLTEXT')) {
$index_type = 'FULLTEXT';
} elseif ($index_name == 'PRIMARY') {
$index_type = 'PRIMARY';
} elseif ($indexes_info[$index_name]['Non_unique'] == '0') {
$index_type = 'UNIQUE';
} else {
$index_type = 'INDEX';
}
 
if ($display_html) {
echo ' <td ' . $row_span . '>' . "\n"
. ' ' . $index_type . '</td>' . "\n";
 
echo ' <td ' . $row_span . ' align="right">' . "\n"
. ' ' . (isset($indexes_info[$index_name]['Cardinality']) ? $indexes_info[$index_name]['Cardinality'] : $GLOBALS['strNone']) . '&nbsp;' . "\n"
. ' </td>' . "\n";
 
if (!$print_mode) {
echo ' <td ' . $row_span . '>' . "\n"
. ' <a href="tbl_indexes.php?' . $GLOBALS['url_query'] . '&amp;index=' . urlencode($index_name) . '">' . $GLOBALS['edit_link_text'] . '</a>' . "\n"
. ' </td>' . "\n";
 
if ($index_name == 'PRIMARY') {
$local_query = urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY');
$js_msg = 'ALTER TABLE ' . PMA_jsFormat($table) . ' DROP PRIMARY KEY';
$zero_rows = urlencode($GLOBALS['strPrimaryKeyHasBeenDropped']);
} else {
$local_query = urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP INDEX ' . PMA_backquote($index_name));
$js_msg = 'ALTER TABLE ' . PMA_jsFormat($table) . ' DROP INDEX ' . PMA_jsFormat($index_name);
$zero_rows = urlencode(sprintf($GLOBALS['strIndexHasBeenDropped'], htmlspecialchars($index_name)));
}
 
echo ' <td ' . $row_span . '>' . "\n"
. ' <a href="sql.php?' . $GLOBALS['url_query'] . '&amp;sql_query=' . $local_query . '&amp;zero_rows=' . $zero_rows . '" onclick="return confirmLink(this, \'' . $js_msg . '\')">' . $GLOBALS['drop_link_text'] . '</a>' . "\n"
. ' </td>' . "\n";
}
}
 
foreach ($indexes_info[$index_name]['Sequences'] AS $row_no => $seq_index) {
$col_name = $indexes_data[$index_name][$seq_index]['Column_name'];
if ($row_no == 0) {
if (isset($idx_collection[$index_type][$col_name])) {
$idx_collection[$index_type][$col_name]++;
} else {
$idx_collection[$index_type][$col_name] = 1;
}
 
if (isset($idx_collection['ALL'][$col_name])) {
$idx_collection['ALL'][$col_name]++;
} else {
$idx_collection['ALL'][$col_name] = 1;
}
}
 
if ($display_html) {
if ($row_no > 0) {
echo ' <tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n";
}
 
if ( isset($indexes_data[$index_name][$seq_index]['Sub_part'])
&& strlen($indexes_data[$index_name][$seq_index]['Sub_part']) ) {
echo ' <td>' . $col_name . '</td>' . "\n";
echo ' <td align="right">' . "\n"
. ' ' . $indexes_data[$index_name][$seq_index]['Sub_part'] . "\n"
. ' </td>' . "\n";
echo ' </tr>' . "\n";
} else {
echo ' <td colspan="2">' . "\n"
. ' ' . htmlspecialchars($col_name) . "\n"
. ' </td>' . "\n";
echo ' </tr>' . "\n";
}
}
} // end foreach $indexes_info[$index_name]['Sequences']
 
$odd_row = ! $odd_row;
} // end while
 
return $idx_collection;
}
 
/**
* Function to emit a index warning
*
* @author Garvin Hicking (pma@supergarv.de)
* @access public
* @param string $string Message string
* @param boolean $table Whether to output HTML in table layout
* @return string Output HTML
*/
function PMA_index_warning($string, $table = true) {
$output = '<div class="warning">' . $string . '</div>';
 
if ( $table ) {
$output = '<tr><td colspan=7">' . $output . '</td></tr>';
}
 
return $output . "\n";
}
?>
/Web/Maintenance/phpMyAdmin/libraries/tbl_move_copy.php
0,0 → 1,449
<?php
/* $Id: tbl_move_copy.php,v 1.12 2006/01/17 17:02:31 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Inserts existing entries in a PMA_* table by reading a value from an old entry
*
* @param string The array index, which Relation feature to check
* ('relwork', 'commwork', ...)
* @param string The array index, which PMA-table to update
* ('bookmark', 'relation', ...)
* @param array Which fields will be SELECT'ed from the old entry
* @param array Which fields will be used for the WHERE query
* (array('FIELDNAME' => 'FIELDVALUE'))
* @param array Which fields will be used as new VALUES. These are the important
* keys which differ from the old entry.
* (array('FIELDNAME' => 'NEW FIELDVALUE'))
 
* @global string relation variable
*
* @author Garvin Hicking <me@supergarv.de>
*/
function PMA_duplicate_table_info($work, $pma_table, $get_fields, $where_fields, $new_fields) {
global $cfgRelation;
 
$last_id = -1;
 
if ($cfgRelation[$work]) {
$select_parts = array();
$row_fields = array();
foreach ($get_fields AS $nr => $get_field) {
$select_parts[] = PMA_backquote($get_field);
$row_fields[$get_field] = 'cc';
}
 
$where_parts = array();
foreach ($where_fields AS $_where => $_value) {
$where_parts[] = PMA_backquote($_where) . ' = \'' . PMA_sqlAddslashes($_value) . '\'';
}
 
$new_parts = array();
$new_value_parts = array();
foreach ($new_fields AS $_where => $_value) {
$new_parts[] = PMA_backquote($_where);
$new_value_parts[] = PMA_sqlAddslashes($_value);
}
 
$table_copy_query = 'SELECT ' . implode(', ', $select_parts)
. ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation[$pma_table])
. ' WHERE ' . implode(' AND ', $where_parts);
 
// must use PMA_DBI_QUERY_STORE here, since we execute another
// query inside the loop
$table_copy_rs = PMA_query_as_cu($table_copy_query, TRUE, PMA_DBI_QUERY_STORE);
 
while ($table_copy_row = @PMA_DBI_fetch_assoc($table_copy_rs)) {
$value_parts = array();
foreach ($table_copy_row AS $_key => $_val) {
if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') {
$value_parts[] = PMA_sqlAddslashes($_val);
}
}
 
$new_table_query = 'INSERT IGNORE INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation[$pma_table])
. ' (' . implode(', ', $select_parts) . ', ' . implode(', ', $new_parts) . ')'
. ' VALUES '
. ' (\'' . implode('\', \'', $value_parts) . '\', \'' . implode('\', \'', $new_value_parts) . '\')';
 
$new_table_rs = PMA_query_as_cu($new_table_query);
$last_id = PMA_DBI_insert_id();
} // end while
 
return $last_id;
}
 
return true;
} // end of 'PMA_duplicate_table_info()' function
 
 
/**
* Copies or renames table
* FIXME: use RENAME
*
* @author Michal Čihař <michal@cihar.com>
*/
function PMA_table_move_copy($source_db, $source_table, $target_db, $target_table, $what, $move) {
global $cfgRelation, $dblist, $err_url, $sql_query;
 
// set export settings we need
$GLOBALS['use_backquotes'] = 1;
$GLOBALS['asfile'] = 1;
 
// Ensure the target is valid
if ( count($dblist) > 0 &&
( ! in_array($source_db, $dblist) || ! in_array($target_db, $dblist) )) {
exit();
}
 
$source = PMA_backquote($source_db) . '.' . PMA_backquote($source_table);
if ( ! isset($target_db) || ! strlen($target_db) ) {
$target_db = $source_db;
}
 
// Doing a select_db could avoid some problems with replicated databases,
// when moving table from replicated one to not replicated one
PMA_DBI_select_db($target_db);
 
$target = PMA_backquote($target_db) . '.' . PMA_backquote($target_table);
 
// do not create the table if dataonly
if ($what != 'dataonly') {
require_once('./libraries/export/sql.php');
 
$no_constraints_comments = true;
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url);
unset($no_constraints_comments);
 
$parsed_sql = PMA_SQP_parse($sql_structure);
 
/* nijel: Find table name in query and replace it */
$i = 0;
while ($parsed_sql[$i]['type'] != 'quote_backtick') $i++;
 
/* no need to PMA_backquote() */
$parsed_sql[$i]['data'] = $target;
 
/* Generate query back */
$sql_structure = PMA_SQP_formatHtml($parsed_sql, 'query_only');
// If table exists, and 'add drop table' is selected: Drop it!
$drop_query = '';
if (isset($GLOBALS['drop_if_exists']) && $GLOBALS['drop_if_exists'] == 'true') {
$drop_query = 'DROP TABLE IF EXISTS ' . PMA_backquote($target_db) . '.' . PMA_backquote($target_table);
$result = PMA_DBI_query($drop_query);
 
if (isset($sql_query)) {
$sql_query .= "\n" . $drop_query . ';';
} else {
$sql_query = $drop_query . ';';
}
 
// garvin: If an existing table gets deleted, maintain any entries
// for the PMA_* tables
$maintain_relations = TRUE;
}
 
$result = @PMA_DBI_query($sql_structure);
if (isset($sql_query)) {
$sql_query .= "\n" . $sql_structure . ';';
} else {
$sql_query = $sql_structure . ';';
}
 
if (($move || isset($GLOBALS['constraints'])) && isset($GLOBALS['sql_constraints'])) {
$parsed_sql = PMA_SQP_parse($GLOBALS['sql_constraints']);
$i = 0;
 
// find the first quote_backtick, it must be the source table name
while ($parsed_sql[$i]['type'] != 'quote_backtick') {
$i++;
}
 
// replace it by the target table name, no need to PMA_backquote()
$parsed_sql[$i]['data'] = $target;
 
// now we must remove all quote_backtick that follow a CONSTRAINT
// keyword, because a constraint name must be unique in a db
 
$cnt = $parsed_sql['len'] - 1;
 
for ($j = $i; $j < $cnt; $j++) {
if ($parsed_sql[$j]['type'] == 'alpha_reservedWord'
&& strtoupper($parsed_sql[$j]['data']) == 'CONSTRAINT') {
if ($parsed_sql[$j+1]['type'] == 'quote_backtick') {
$parsed_sql[$j+1]['data'] = '';
}
}
}
 
 
// Generate query back
$GLOBALS['sql_constraints'] = PMA_SQP_formatHtml($parsed_sql, 'query_only');
$result = PMA_DBI_query($GLOBALS['sql_constraints']);
if (isset($sql_query)) {
$sql_query .= "\n" . $GLOBALS['sql_constraints'];
} else {
$sql_query = $GLOBALS['sql_constraints'];
}
 
unset($GLOBALS['sql_constraints']);
}
 
} else {
$sql_query='';
}
 
// Copy the data
//if ($result != FALSE && ($what == 'data' || $what == 'dataonly')) {
if ($what == 'data' || $what == 'dataonly') {
$sql_insert_data = 'INSERT INTO ' . $target . ' SELECT * FROM ' . $source;
PMA_DBI_query($sql_insert_data);
$sql_query .= "\n\n" . $sql_insert_data . ';';
}
 
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
 
// Drops old table if the user has requested to move it
if ($move) {
 
// This could avoid some problems with replicated databases, when
// moving table from replicated one to not replicated one
PMA_DBI_select_db($source_db);
 
$sql_drop_table = 'DROP TABLE ' . $source;
PMA_DBI_query($sql_drop_table);
 
// garvin: Move old entries from PMA-DBs to new table
if ($cfgRelation['commwork']) {
$remove_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' SET table_name = \'' . PMA_sqlAddslashes($target_table) . '\', '
. ' db_name = \'' . PMA_sqlAddslashes($target_db) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($source_db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($source_table) . '\'';
$rmv_rs = PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
// garvin: updating bookmarks is not possible since only a single table is moved,
// and not the whole DB.
// if ($cfgRelation['bookmarkwork']) {
// $remove_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['bookmark'])
// . ' SET dbase = \'' . PMA_sqlAddslashes($target_db) . '\''
// . ' WHERE dbase = \'' . PMA_sqlAddslashes($source_db) . '\'';
// $rmv_rs = PMA_query_as_cu($remove_query);
// unset($rmv_query);
// }
 
if ($cfgRelation['displaywork']) {
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
. ' SET db_name = \'' . PMA_sqlAddslashes($target_db) . '\', '
. ' table_name = \'' . PMA_sqlAddslashes($target_table) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($source_db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($source_table) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
}
 
if ($cfgRelation['relwork']) {
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' SET foreign_table = \'' . PMA_sqlAddslashes($target_table) . '\','
. ' foreign_db = \'' . PMA_sqlAddslashes($target_db) . '\''
. ' WHERE foreign_db = \'' . PMA_sqlAddslashes($source_db) . '\''
. ' AND foreign_table = \'' . PMA_sqlAddslashes($source_table) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
 
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' SET master_table = \'' . PMA_sqlAddslashes($target_table) . '\','
. ' master_db = \'' . PMA_sqlAddslashes($target_db) . '\''
. ' WHERE master_db = \'' . PMA_sqlAddslashes($source_db) . '\''
. ' AND master_table = \'' . PMA_sqlAddslashes($source_table) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
}
 
// garvin: [TODO] Can't get moving PDFs the right way. The page numbers always
// get screwed up independently from duplication because the numbers do not
// seem to be stored on a per-database basis. Would the author of pdf support
// please have a look at it?
 
if ($cfgRelation['pdfwork']) {
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
. ' SET table_name = \'' . PMA_sqlAddslashes($target_table) . '\','
. ' db_name = \'' . PMA_sqlAddslashes($target_db) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($source_db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($source_table) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
/*
$pdf_query = 'SELECT pdf_page_number '
. ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($target_db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($target_table) . '\'';
$pdf_rs = PMA_query_as_cu($pdf_query);
 
while ($pdf_copy_row = PMA_DBI_fetch_assoc($pdf_rs)) {
$table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
. ' SET db_name = \'' . PMA_sqlAddslashes($target_db) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($source_db) . '\''
. ' AND page_nr = \'' . PMA_sqlAddslashes($pdf_copy_row['pdf_page_number']) . '\'';
$tb_rs = PMA_query_as_cu($table_query);
unset($table_query);
unset($tb_rs);
}
*/
}
 
$sql_query .= "\n\n" . $sql_drop_table . ';';
} else {
// garvin: Create new entries as duplicates from old PMA DBs
if ($what != 'dataonly' && !isset($maintain_relations)) {
if ($cfgRelation['commwork']) {
// Get all comments and MIME-Types for current table
$comments_copy_query = 'SELECT
column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . '
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
WHERE
db_name = \'' . PMA_sqlAddslashes($source_db) . '\' AND
table_name = \'' . PMA_sqlAddslashes($source_table) . '\'';
$comments_copy_rs = PMA_query_as_cu($comments_copy_query);
 
// Write every comment as new copied entry. [MIME]
while ($comments_copy_row = PMA_DBI_fetch_assoc($comments_copy_rs)) {
$new_comment_query = 'REPLACE INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') '
. ' VALUES('
. '\'' . PMA_sqlAddslashes($target_db) . '\','
. '\'' . PMA_sqlAddslashes($target_table) . '\','
. '\'' . PMA_sqlAddslashes($comments_copy_row['column_name']) . '\''
. ($cfgRelation['mimework'] ? ',\'' . PMA_sqlAddslashes($comments_copy_row['comment']) . '\','
. '\'' . PMA_sqlAddslashes($comments_copy_row['mimetype']) . '\','
. '\'' . PMA_sqlAddslashes($comments_copy_row['transformation']) . '\','
. '\'' . PMA_sqlAddslashes($comments_copy_row['transformation_options']) . '\'' : '')
. ')';
$new_comment_rs = PMA_query_as_cu($new_comment_query);
} // end while
}
 
// duplicating the bookmarks must not be done here, but
// just once per db
 
$get_fields = array('display_field');
$where_fields = array('db_name' => $source_db, 'table_name' => $source_table);
$new_fields = array('db_name' => $target_db, 'table_name' => $target_table);
PMA_duplicate_table_info('displaywork', 'table_info', $get_fields, $where_fields, $new_fields);
 
$get_fields = array('master_field', 'foreign_db', 'foreign_table', 'foreign_field');
$where_fields = array('master_db' => $source_db, 'master_table' => $source_table);
$new_fields = array('master_db' => $target_db, 'master_table' => $target_table);
PMA_duplicate_table_info('relwork', 'relation', $get_fields, $where_fields, $new_fields);
 
$get_fields = array('foreign_field', 'master_db', 'master_table', 'master_field');
$where_fields = array('foreign_db' => $source_db, 'foreign_table' => $source_table);
$new_fields = array('foreign_db' => $target_db, 'foreign_table' => $target_table);
PMA_duplicate_table_info('relwork', 'relation', $get_fields, $where_fields, $new_fields);
 
// garvin: [TODO] Can't get duplicating PDFs the right way. The page numbers always
// get screwed up independently from duplication because the numbers do not
// seem to be stored on a per-database basis. Would the author of pdf support
// please have a look at it?
/*
$get_fields = array('page_descr');
$where_fields = array('db_name' => $source_db);
$new_fields = array('db_name' => $target_db);
$last_id = PMA_duplicate_table_info('pdfwork', 'pdf_pages', $get_fields, $where_fields, $new_fields);
 
if (isset($last_id) && $last_id >= 0) {
$get_fields = array('x', 'y');
$where_fields = array('db_name' => $source_db, 'table_name' => $source_table);
$new_fields = array('db_name' => $target_db, 'table_name' => $target_table, 'pdf_page_number' => $last_id);
PMA_duplicate_table_info('pdfwork', 'table_coords', $get_fields, $where_fields, $new_fields);
}
*/
}
}
 
}
 
/**
* renames table
*
* @param string old tbale name
* @param string new table name
* @return boolean success
*/
function PMA_table_rename( $old_name, $new_name )
{
// Ensure the target is valid
if ( count($GLOBALS['dblist']) > 0
&& ! in_array($GLOBALS['db'], $GLOBALS['dblist']) ) {
return false;
}
 
PMA_DBI_select_db($GLOBALS['db']);
 
$sql_query = '
ALTER TABLE ' . PMA_backquote($old_name) . '
RENAME ' . PMA_backquote($new_name) . ';';
if ( ! PMA_DBI_query($sql_query) ) {
return false;
}
 
// garvin: Move old entries from comments to new table
require_once('./libraries/relation.lib.php');
$cfgRelation = PMA_getRelationsParam();
if ( $cfgRelation['commwork'] ) {
$remove_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE db_name = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'
AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($remove_query);
unset($remove_query);
}
 
if ( $cfgRelation['displaywork'] ) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . '
SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE db_name = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'
AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
unset($table_query);
}
 
if ( $cfgRelation['relwork'] ) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '
SET foreign_table = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE foreign_db = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'
AND foreign_table = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
 
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '
SET master_table = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE master_db = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'
AND master_table = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
unset($table_query);
}
 
if ( $cfgRelation['pdfwork'] ) {
$table_query = '
UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . '
SET table_name = \'' . PMA_sqlAddslashes($new_name) . '\'
WHERE db_name = \'' . PMA_sqlAddslashes($GLOBALS['db']) . '\'
AND table_name = \'' . PMA_sqlAddslashes($old_name) . '\'';
PMA_query_as_cu($table_query);
unset($table_query);
}
 
return true;
}
?>
/Web/Maintenance/phpMyAdmin/libraries/tbl_properties.inc.php
0,0 → 1,707
<?php
/* $Id: tbl_properties.inc.php,v 1.5.2.1 2006/03/26 11:09:13 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
// Check parameters
 
require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
 
 
// Get available character sets and storage engines
require_once('./libraries/mysql_charsets.lib.php');
require_once('./libraries/storage_engines.lib.php');
 
if ($cfg['CtrlArrowsMoving']) {
?>
<script src="./js/keyhandler.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript">
<!--
var switch_movement = <?php echo $cfg['DefaultPropDisplay'] == 'horizontal' ? '0' : '1'; ?>;
document.onkeydown = onKeyDownArrowsHandler;
// -->
</script>
<?php
}
// here, the div_x_7 represents a div id which contains
// the default CURRENT TIMESTAMP checkbox and label
// and, field_x_7a represents the checkbox itself
 
if (PMA_MYSQL_INT_VERSION >= 40102) {
?>
<script type="text/javascript" language="javascript">
<!--
function display_field_options(field_type, i) {
if (field_type == 'TIMESTAMP') {
getElement('div_' + i + '_7').style.display = 'block';
} else {
getElement('div_' + i + '_7').style.display = 'none';
getElement('field_' + i + '_7a').checked = false;
}
return true;
}
// -->
</script>
<?php } ?>
 
<form method="post" action="<?php echo $action; ?>" onsubmit="return checkTableEditForm(this, <?php echo $num_fields; ?>)" >
<?php
echo PMA_generate_common_hidden_inputs($db, $table);
if ($action == 'tbl_create.php') {
?>
<input type="hidden" name="reload" value="1" />
<?php
} elseif ($action == 'tbl_addfield.php') {
?>
<input type="hidden" name="field_where" value="<?php echo $field_where; ?>" />
<input type="hidden" name="after_field" value="<?php echo $after_field; ?>" />
<?php
}
 
if (isset($num_fields)) {
?>
<input type="hidden" name="orig_num_fields" value="<?php echo $num_fields; ?>" />
<?php
}
 
if (isset($field_where)) {
?>
<input type="hidden" name="orig_field_where" value="<?php echo $field_where; ?>" />
<?php
}
 
if (isset($after_field)) {
?>
<input type="hidden" name="orig_after_field" value="<?php echo $after_field; ?>" />
<?php
}
 
if (isset($selected) && is_array($selected)) {
foreach ($selected AS $o_fld_nr => $o_fld_val) {
?>
<input type="hidden" name="selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
<?php
if (!isset($true_selected)) {
?>
<input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
<?php
}
 
}
 
if (isset($true_selected) && is_array($true_selected)) {
foreach ($true_selected AS $o_fld_nr => $o_fld_val) {
?>
<input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
<?php
}
}
 
} elseif (isset($field)) {
?>
<input type="hidden" name="orig_field" value="<?php echo urlencode($field); ?>" />
<input type="hidden" name="true_selected[] value="<?php echo (isset($orig_field) ? $orig_field : urlencode($field)); ?>" />
<?php
}
 
$is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
 
$header_cells = array();
$content_cells = array();
 
$header_cells[] = $strField;
$header_cells[] = $strType . ($GLOBALS['cfg']['ReplaceHelpImg'] ? PMA_showMySQLDocu('SQL-Syntax', 'Column_types') : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'Column_types') . '</span>');
$header_cells[] = $strLengthSet . '<sup>1</sup>';
if (PMA_MYSQL_INT_VERSION >= 40100) {
$header_cells[] = $strCollation;
}
$header_cells[] = $strAttr;
$header_cells[] = $strNull;
$header_cells[] = $strDefault . '<sup>2</sup>';
$header_cells[] = $strExtra;
 
 
 
// lem9: We could remove this 'if' and let the key information be shown and
// editable. However, for this to work, tbl_alter must be modified to use the
// key fields, as tbl_addfield does.
 
if (!$is_backup) {
$header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_primary.png" width="16" height="16" alt="' . $strPrimary . '" title="' . $strPrimary . '" />' : $strPrimary;
$header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_index.png" width="16" height="16" alt="' . $strIndex . '" title="' . $strIndex . '" />' : $strIndex;
$header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_unique.png" width="16" height="16" alt="' . $strUnique . '" title="' . $strUnique . '" />' : $strUnique;
$header_cells[] = '---';
$header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_ftext.png" width="16" height="16" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' : $strIdxFulltext;
}
 
require_once('./libraries/relation.lib.php');
require_once('./libraries/transformations.lib.php');
$cfgRelation = PMA_getRelationsParam();
 
$comments_map = array();
$mime_map = array();
$available_mime = array();
 
if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
$comments_map = PMA_getComments($db, $table);
$header_cells[] = $strComments;
 
if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
$mime_map = PMA_getMIME($db, $table);
$available_mime = PMA_getAvailableMIMEtypes();
 
$header_cells[] = $strMIME_MIMEtype;
$header_cells[] = $strMIME_transformation;
$header_cells[] = $strMIME_transformation_options . '<sup>3</sup>';
}
}
 
// garvin: workaround for field_fulltext, because its submitted indizes contain
// the index as a value, not a key. Inserted here for easier maintaineance
// and less code to change in existing files.
if (isset($field_fulltext) && is_array($field_fulltext)) {
foreach ($field_fulltext AS $fulltext_nr => $fulltext_indexkey) {
$submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
}
}
 
for ( $i = 0 ; $i <= $num_fields; $i++ ) {
$submit_null = FALSE;
if (isset($regenerate) && $regenerate == TRUE) {
// An error happened with previous inputs, so we will restore the data
// to embed it once again in this form.
 
$row['Field'] = (isset($field_name) && isset($field_name[$i]) ? $field_name[$i] : FALSE);
$row['Type'] = (isset($field_type) && isset($field_type[$i]) ? $field_type[$i] : FALSE);
if (PMA_MYSQL_INT_VERSION >= 40100) {
$row['Collation'] = (isset($field_collation) && isset($field_collation[$i]) ? $field_collation[$i] : '');
}
$row['Null'] = (isset($field_null) && isset($field_null[$i]) ? $field_null[$i] : '');
if (isset($field_type[$i]) && $row['Null'] == '') {
$submit_null = TRUE;
}
 
if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
$row['Key'] = 'PRI';
} elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
$row['Key'] = 'MUL';
} elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
$row['Key'] = 'UNI';
} else {
$row['Key'] = '';
}
 
$row['Default'] = (isset($field_default) && isset($field_default[$i]) ? $field_default[$i] : FALSE);
$row['Extra'] = (isset($field_extra) && isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
$row['Comment'] = (isset($submit_fulltext) && isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
 
$submit_length = (isset($field_length) && isset($field_length[$i]) ? $field_length[$i] : FALSE);
$submit_attribute = (isset($field_attribute) && isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
 
$submit_default_current_timestamp = (isset($field_default_current_timestamp) && isset($field_default_current_timestamp[$i]) ? TRUE : FALSE);
 
if (isset($field_comments) && isset($field_comments[$i])) {
$comments_map[$row['Field']] = $field_comments[$i];
}
 
if (isset($field_mimetype) && isset($field_mimetype[$i])) {
$mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
}
 
if (isset($field_transformation) && isset($field_transformation[$i])) {
$mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
}
 
if (isset($field_transformation_options) && isset($field_transformation_options[$i])) {
$mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
}
 
} elseif (isset($fields_meta) && isset($fields_meta[$i])) {
$row = $fields_meta[$i];
}
 
// Cell index: If certain fields get left out, the counter shouldn't chage.
$ci = 0;
// Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
// has to be incremented ($ci_offset++)
$ci_offset = -1;
 
if ($is_backup) {
$backup_field = (isset($true_selected) && isset($true_selected[$i]) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : ''));
$content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_orig[]" value="' . $backup_field . '" />' . "\n";
} else {
$content_cells[$i][$ci] = '';
}
 
$content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_name[]" size="10" maxlength="64" value="' . (isset($row) && isset($row['Field']) ? str_replace('"', '&quot;', $row['Field']) : '') . '" class="textfield" title="' . $strField . '" />';
$ci++;
$content_cells[$i][$ci] = '<select name="field_type[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '" ';
if (PMA_MYSQL_INT_VERSION >= 40102) {
$content_cells[$i][$ci] .= 'onchange="display_field_options(this.options[this.selectedIndex].value,' . $i .')" ';
}
$content_cells[$i][$ci] .= '>' . "\n";
 
if (empty($row['Type'])) {
$row['Type'] = '';
$type = '';
} else {
$type = $row['Type'];
}
// set or enum types: slashes single quotes inside options
if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
$type = $tmp[1];
$length = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
} else {
// strip the "BINARY" attribute, except if we find "BINARY(" because
// this would be a BINARY or VARBINARY field type
$type = preg_replace('@BINARY([^\(])@i', '', $type);
$type = preg_replace('@ZEROFILL@i', '', $type);
$type = preg_replace('@UNSIGNED@i', '', $type);
 
if (strpos($type, '(')) {
$length = chop(substr($type, (strpos($type, '(') + 1), (strpos($type, ')') - strpos($type, '(') - 1)));
$type = chop(substr($type, 0, strpos($type, '(')));
} else {
$length = '';
}
} // end if else
 
// some types, for example longtext, are reported as
// "longtext character set latin7" when their charset and / or collation
// differs from the ones of the corresponding database.
if (PMA_MYSQL_INT_VERSION >= 40100) {
$tmp = strpos($type, 'character set');
if ($tmp) {
$type = substr($type, 0, $tmp-1);
}
}
 
if (isset($submit_length) && $submit_length != FALSE) {
$length = $submit_length;
}
 
// rtrim the type, for cases like "float unsigned"
$type = rtrim($type);
$type_upper = strtoupper($type);
 
$cnt_column_types = count($cfg['ColumnTypes']);
for ($j = 0; $j < $cnt_column_types; $j++) {
$content_cells[$i][$ci] .= ' <option value="'. $cfg['ColumnTypes'][$j] . '"';
if ($type_upper == strtoupper($cfg['ColumnTypes'][$j])) {
$content_cells[$i][$ci] .= ' selected="selected"';
}
$content_cells[$i][$ci] .= '>' . $cfg['ColumnTypes'][$j] . '</option>' . "\n";
} // end for
 
$content_cells[$i][$ci] .= ' </select>';
$ci++;
 
if ($is_backup) {
$content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_length_orig[]" value="' . urlencode($length) . '" />';
} else {
$content_cells[$i][$ci] = '';
}
 
if (preg_match('@^(set|enum)$@i', $type)) {
$binary = 0;
$unsigned = 0;
$zerofill = 0;
$length_to_display = htmlspecialchars($length);
} else {
$length_to_display = $length;
if (!preg_match('@BINARY[\(]@i', $row['Type']) && PMA_MYSQL_INT_VERSION < 40100) {
$binary = stristr($row['Type'], 'binary');
} else {
$binary = FALSE;
}
$unsigned = stristr($row['Type'], 'unsigned');
$zerofill = stristr($row['Type'], 'zerofill');
}
 
$content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_length[]" size="8" value="' . str_replace('"', '&quot;', $length_to_display) . '" class="textfield" />' . "\n";
$ci++;
 
if (PMA_MYSQL_INT_VERSION >= 40100) {
$tmp_collation = empty($row['Collation']) ? null : $row['Collation'];
$content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[]', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE);
unset($tmp_collation);
$ci++;
}
 
$content_cells[$i][$ci] = '<select style="font-size: 70%;" name="field_attribute[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">' . "\n";
 
$attribute = '';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
 
if (isset($submit_attribute) && $submit_attribute != FALSE) {
$attribute = $submit_attribute;
}
 
// here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
// NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
// the latter.
if (isset($row['Field'])
&& isset($analyzed_sql[0])
&& isset($analyzed_sql[0]['create_table_fields'])
&& isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
&& $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
&& $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
$row['Null'] = '';
}
 
 
// MySQL 4.1.2+ TIMESTAMP options
// (if on_update_current_timestamp is set, then it's TRUE)
if (isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
$attribute = 'ON UPDATE CURRENT_TIMESTAMP';
}
if ((isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
|| (isset($submit_default_current_timestamp) && $submit_default_current_timestamp) ) {
$default_current_timestamp = TRUE;
} else {
$default_current_timestamp = FALSE;
}
 
// Dynamically add ON UPDATE CURRENT_TIMESTAMP to the possible attributes
if (PMA_MYSQL_INT_VERSION >= 40102 && !in_array('ON UPDATE CURRENT_TIMESTAMP', $cfg['AttributeTypes'])) {
$cfg['AttributeTypes'][] = 'ON UPDATE CURRENT_TIMESTAMP';
}
 
 
$cnt_attribute_types = count($cfg['AttributeTypes']);
for ($j = 0;$j < $cnt_attribute_types; $j++) {
if (PMA_MYSQL_INT_VERSION >= 40100 && $cfg['AttributeTypes'][$j] == 'BINARY') {
continue;
}
$content_cells[$i][$ci] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
$content_cells[$i][$ci] .= ' selected="selected"';
}
$content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
}
 
$content_cells[$i][$ci] .= '</select>';
$ci++;
 
$content_cells[$i][$ci] = '<select name="field_null[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
 
if ((!isset($row) || empty($row['Null']) || $row['Null'] == 'NO' || $row['Null'] == 'NOT NULL') && $submit_null == FALSE) {
$content_cells[$i][$ci] .= "\n";
$content_cells[$i][$ci] .= ' <option value="NOT NULL" selected="selected" >not null</option>' . "\n";
$content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n";
} else {
$content_cells[$i][$ci] .= "\n";
$content_cells[$i][$ci] .= ' <option value="" selected="selected" >null</option>' . "\n";
$content_cells[$i][$ci] .= ' <option value="NOT NULL">not null</option>' . "\n";
}
 
$content_cells[$i][$ci] .= "\n" . '</select>';
$ci++;
 
if (isset($row)
&& !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
$row['Default'] = 'NULL';
}
 
if ($is_backup) {
$content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_default_orig[]" size="8" value="' . (isset($row) && isset($row['Default']) ? urlencode($row['Default']) : '') . '" />';
} else {
$content_cells[$i][$ci] = "\n";
}
 
// for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
if (PMA_MYSQL_INT_VERSION >= 40102
&& $type_upper == 'TIMESTAMP'
&& $default_current_timestamp
&& isset($row)
&& isset($row['Default'])) {
$row['Default'] = '';
}
 
$content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_default[]" size="12" value="' . (isset($row) && isset($row['Default']) ? str_replace('"', '&quot;', $row['Default']) : '') . '" class="textfield" />';
if (PMA_MYSQL_INT_VERSION >= 40102) {
if ($type_upper == 'TIMESTAMP') {
$tmp_display_type = 'block';
} else {
$tmp_display_type = 'none';
$default_current_timestamp = FALSE;
}
$content_cells[$i][$ci] .= '<br /><div id="div_' . $i . '_' . ($ci - $ci_offset) . '" style="white-space: nowrap; display: ' . $tmp_display_type . '"><input id="field_' . $i . '_' . ($ci - $ci_offset) . 'a" type="checkbox" name="field_default_current_timestamp[' . $i . ']"';
if ($default_current_timestamp) {
$content_cells[$i][$ci] .= ' checked="checked" ';
}
$content_cells[$i][$ci] .= ' /><label for="field_' . $i . '_' . ($ci - $ci_offset) . 'a" style="font-size: 70%;">CURRENT_TIMESTAMP</label></div>';
}
$ci++;
 
$content_cells[$i][$ci] = '<select name="field_extra[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
 
if (!isset($row) || empty($row['Extra'])) {
$content_cells[$i][$ci] .= "\n";
$content_cells[$i][$ci] .= '<option value=""></option>' . "\n";
$content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
} else {
$content_cells[$i][$ci] .= "\n";
$content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
$content_cells[$i][$ci] .= '<option value=""></option>' . "\n";
}
 
$content_cells[$i][$ci] .= "\n" . '</select>';
$ci++;
 
 
// lem9: See my other comment about removing this 'if'.
if (!$is_backup) {
if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
$checked_primary = ' checked="checked"';
} else {
$checked_primary = '';
}
if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
$checked_index = ' checked="checked"';
} else {
$checked_index = '';
}
if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
$checked_unique = ' checked="checked"';
} else {
$checked_unique = '';
}
if (empty($checked_primary)
&& empty($checked_index)
&& empty($checked_unique)) {
$checked_none = ' checked="checked"';
} else {
$checked_none = '';
}
 
if ((isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
$checked_fulltext = ' checked="checked"';
} else {
$checked_fulltext = '';
}
 
$content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="primary_' . $i . '"' . $checked_primary . ' title="' . $strPrimary . '" />';
$ci++;
 
$content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="index_' . $i . '"' . $checked_index . ' title="' . $strIndex . '" />';
$ci++;
 
$content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="unique_' . $i . '"' . $checked_unique . ' title="' . $strUnique . '" />';
$ci++;
 
$content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="none_' . $i . '"' . $checked_none . ' title="---" />';
$ci++;
 
$content_cells[$i][$ci] = '<input type="checkbox" name="field_fulltext[]" value="' . $i . '"' . $checked_fulltext . ' title="' . $strIdxFulltext . '" />';
$ci++;
} // end if ($action ==...)
 
// garvin: comments
if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_comments[]" size="12" value="' . (isset($row) && isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '" class="textfield" />';
$ci++;
}
 
// garvin: MIME-types
if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
$content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[]">' . "\n";
$content_cells[$i][$ci] .= ' <option value=""></option>' . "\n";
$content_cells[$i][$ci] .= ' <option value="auto">auto-detect</option>' . "\n";
 
if (is_array($available_mime['mimetype'])) {
foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
$checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
$content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
}
}
 
$content_cells[$i][$ci] .= '</select>';
$ci++;
 
$content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[]">' . "\n";
$content_cells[$i][$ci] .= ' <option value="" title="' . $strNone . '"></option>' . "\n";
if (is_array($available_mime['transformation'])) {
foreach ($available_mime['transformation'] AS $mimekey => $transform) {
$checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation']) && (preg_match('@' . preg_quote($available_mime['transformation_file'][$mimekey]) . '3?@i', $mime_map[$row['Field']]['transformation'])) ? 'selected ' : '');
$tooltip = 'strTransformation_' . strtolower(preg_replace('@(\.inc\.php3?)$@', '', $available_mime['transformation_file'][$mimekey]));
$tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
$content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>' . "\n";
}
}
 
$content_cells[$i][$ci] .= '</select>';
$ci++;
 
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_transformation_options[]" size="16" value="' . (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '" class="textfield" />';
//$ci++;
}
} // end for
 
if ( is_array( $content_cells ) && is_array( $header_cells ) ) {
// last row is for javascript insert
$empty_row = array_pop( $content_cells );
 
echo '<table id="table_columns">';
if ( $cfg['DefaultPropDisplay'] == 'horizontal' ) {
?>
<tr>
<?php foreach ( $header_cells as $header_val ) { ?>
<th><?php echo $header_val; ?></th>
<?php } ?>
</tr>
<?php
 
$odd_row = true;
foreach ( $content_cells as $content_row ) {
echo '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . ' noclick">';
$odd_row = ! $odd_row;
 
if ( is_array( $content_row ) ) {
foreach ($content_row as $content_row_val) {
?>
<td align="center"><?php echo $content_row_val; ?></td>
<?php
}
}
echo '</tr>';
}
} else {
$i = 0;
$odd_row = true;
foreach ( $header_cells as $header_val ) {
echo '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . ' noclick">';
$odd_row = ! $odd_row;
?>
<th><?php echo $header_val; ?></th>
<?php
foreach ( $content_cells as $content_cell ) {
if ( isset( $content_cell[$i] ) && $content_cell[$i] != '' ) {
?>
<td><?php echo $content_cell[$i]; ?></td>
<?php
}
}
echo '</tr>';
$i++;
}
}
?>
</table>
<br />
<?php
}
 
/**
* needs to be finished
*
*
if ( $cfg['DefaultPropDisplay'] == 'horizontal' ) {
$new_field = '';
foreach ( $empty_row as $content_row_val ) {
$new_field .= '<td align="center">' . $content_row_val . '</td>';
}
?>
<script type="text/javascript" language="javascript">
<!--
var odd_row = <?php echo $odd_row; ?>;
 
function addField() {
var new_fields = document.getElementById('added_fields').value;
var new_field_container = document.getElementById('table_columns');
var new_field = '<?php echo preg_replace( '�\s+�', ' ', preg_replace( '�\'�', '\\\'', $new_field ) ); ?>';
var i = 0;
for ( i = 0; i < new_fields; i++ ) {
if ( odd_row ) {
new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
} else {
new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
}
odd_row = ! odd_row;
}
 
return true;
}
// -->
</script>
<?php
}
*/
 
if ($action == 'tbl_create.php') {
?>
<table>
<tr valign="top">
<th><?php echo $strTableComments; ?>:&nbsp;</th>
<td width="25">&nbsp;</td>
<th><?php echo $strStorageEngine; ?>:&nbsp;<?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
</th>
<?php
if ( PMA_MYSQL_INT_VERSION >= 40100 ) {
echo ' <td width="25">&nbsp;</td>' . "\n"
. ' <th>' . $strCollation . ':&nbsp;</th>' . "\n";
}
?>
</tr>
<tr><td><input type="text" name="comment" size="40" maxlength="80"
value="<?php echo (isset($comment) ? $comment : ''); ?>"
class="textfield" />
</td>
<td width="25">&nbsp;</td>
<td>
<?php echo PMA_generateEnginesDropdown('tbl_type', null, FALSE, (isset($GLOBALS['tbl_type']) ? $GLOBALS['tbl_type'] : null), 3); ?>
</td>
<?php
if ( PMA_MYSQL_INT_VERSION >= 40100 ) {
echo ' <td width="25">&nbsp;</td>' . "\n"
. ' <td>' . "\n"
. PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, (isset($tbl_collation) ? $tbl_collation : null), FALSE, 3)
. ' </td>' . "\n";
}
?>
</tr>
</table>
<br />
<?php
} // end if ($action == 'tbl_create.php')
?>
 
<fieldset class="tblFooters">
<input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" />
<?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
<?php echo $GLOBALS['strOr']; ?>
<?php echo sprintf( $strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />' ); ?>
<input type="submit" name="submit_num_fields"
value="<?php echo $GLOBALS['strGo']; ?>"
<?php /* onclick="if ( addField() ) return false;" */ ?>
onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"
/>
<?php } ?>
</fieldset>
 
</form>
 
<div class="notice">
<p> <a name="footnoote_setenumval"><sup>1</sup></a> <?php echo $strSetEnumVal; ?></p>
<p> <a name="footnoote_defaultvalue"><sup>2</sup></a> <?php echo $strDefaultValueHelp; ?></p>
<?php
if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
echo '<p> <a name="footnoote_mime"><sup>3</sup></a> ' . $strMIME_transformation_options_note . '</p>';
echo '<p> ';
printf( $strMIME_transformation_note,
'<a href="transformation_overview.php?'
. PMA_generate_common_url($db, $table) . '" target="_blank">',
'</a>' );
echo '</p>';
}
?>
</div>
 
<center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>
/Web/Maintenance/phpMyAdmin/libraries/tbl_properties_common.php
0,0 → 1,42
<?php
/* $Id: tbl_properties_common.php,v 1.3 2006/01/17 17:02:31 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/**
* Gets some core libraries
*/
require_once('./libraries/common.lib.php');
require_once('./libraries/bookmark.lib.php');
 
// Check parameters
PMA_checkParameters(array('db', 'table'));
 
if ( PMA_MYSQL_INT_VERSION >= 50002 && $db === 'information_schema' ) {
$db_is_information_schema = true;
} else {
$db_is_information_schema = false;
}
 
/**
* Set parameters for links
* @deprecated
*/
$url_query = PMA_generate_common_url($db, $table);
 
$url_params['db'] = $db;
$url_params['table'] = $table;
 
/**
* Defines the urls to return to in case of error in a sql statement
*/
$err_url_0 = $cfg['DefaultTabDatabase'] . PMA_generate_common_url( array( 'db' => $db, ) );
$err_url = $cfg['DefaultTabTable'] . PMA_generate_common_url( $url_params );
 
 
/**
* Ensures the database and the table exist (else move to the "parent" script)
*/
require_once('./libraries/db_table_exists.lib.php');
 
?>
/Web/Maintenance/phpMyAdmin/libraries/tbl_properties_links.inc.php
0,0 → 1,131
<?php
/* $Id: tbl_properties_links.inc.php,v 1.6 2006/01/17 17:02:31 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// Check parameters
 
require_once('./libraries/common.lib.php');
 
PMA_checkParameters(array('db', 'table'));
 
/**
* Prepares links
*/
require_once('./libraries/bookmark.lib.php');
 
 
/**
* Set parameters for links
*/
if (empty($url_query)) {
$url_query = PMA_generate_common_url($db, $table);
}
$url_params['db'] = $db;
$url_params['table'] = $table;
 
/**
* Defines the urls to return to in case of error in a sql statement
*/
$err_url_0 = $cfg['DefaultTabDatabase'] . PMA_generate_common_url( array( 'db' => $db, ) );
$err_url = $cfg['DefaultTabTable'] . PMA_generate_common_url( $url_params );
 
/**
* Displays headers
*/
$js_to_run = 'functions.js';
require_once('./libraries/header.inc.php');
 
/**
* Displays links
*/
$tabs = array();
 
$tabs['browse']['icon'] = 'b_browse.png';
$tabs['browse']['text'] = $strBrowse;
 
$tabs['structure']['icon'] = 'b_props.png';
$tabs['structure']['link'] = 'tbl_properties_structure.php';
$tabs['structure']['text'] = $strStructure;
 
$tabs['sql']['icon'] = 'b_sql.png';
$tabs['sql']['link'] = 'tbl_properties.php';
$tabs['sql']['text'] = $strSQL;
 
$tabs['search']['icon'] = 'b_search.png';
$tabs['search']['text'] = $strSearch;
 
if ( ! (isset($db_is_information_schema) && $db_is_information_schema) ) {
$tabs['insert']['icon'] = 'b_insrow.png';
$tabs['insert']['link'] = 'tbl_change.php';
$tabs['insert']['text'] = $strInsert;
}
 
$tabs['export']['icon'] = 'b_tblexport.png';
$tabs['export']['link'] = 'tbl_properties_export.php';
$tabs['export']['args']['single_table'] = 'true';
$tabs['export']['text'] = $strExport;
 
/**
* Don't display "Import", "Operations" and "Empty"
* for views and information_schema
*/
if ( ! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema )) {
$tabs['import']['icon'] = 'b_tblimport.png';
$tabs['import']['link'] = 'tbl_import.php';
$tabs['import']['text'] = $strImport;
 
$tabs['operation']['icon'] = 'b_tblops.png';
$tabs['operation']['link'] = 'tbl_properties_operations.php';
$tabs['operation']['text'] = $strOperations;
 
if ($table_info_num_rows > 0) {
$ln8_stt = (PMA_MYSQL_INT_VERSION >= 40000)
? 'TRUNCATE TABLE '
: 'DELETE FROM ';
$tabs['empty']['link'] = 'sql.php';
$tabs['empty']['args']['sql_query'] = $ln8_stt . PMA_backquote($table);
$tabs['empty']['args']['zero_rows'] = sprintf($strTableHasBeenEmptied, htmlspecialchars($table));
$tabs['empty']['attr'] = 'onclick="return confirmLink(this, \'' . $ln8_stt . PMA_jsFormat($table) . '\')"';
$tabs['empty']['args']['goto'] = 'tbl_properties_structure.php';
$tabs['empty']['class'] = 'caution';
}
$tabs['empty']['icon'] = 'b_empty.png';
$tabs['empty']['text'] = $strEmpty;
}
 
/**
* no drop in information_schema
*/
if ( ! (isset($db_is_information_schema) && $db_is_information_schema) ) {
$tabs['drop']['icon'] = 'b_deltbl.png';
$tabs['drop']['link'] = 'sql.php';
$tabs['drop']['text'] = $strDrop;
$tabs['drop']['args']['reload'] = 1;
$tabs['drop']['args']['purge'] = 1;
$drop_command = 'DROP ' . ($tbl_is_view ? 'VIEW' : 'TABLE');
$tabs['drop']['args']['sql_query'] = $drop_command . ' ' . PMA_backquote($table);
$tabs['drop']['args']['goto'] = 'db_details_structure.php';
$tabs['drop']['args']['zero_rows'] = sprintf(($tbl_is_view ? $strViewHasBeenDropped : $strTableHasBeenDropped), htmlspecialchars($table));
$tabs['drop']['attr'] = 'onclick="return confirmLink(this, \'' . $drop_command . ' ' . PMA_jsFormat($table) . '\')"';
unset($drop_command);
$tabs['drop']['class'] = 'caution';
}
 
if ($table_info_num_rows > 0 || $tbl_is_view) {
$tabs['browse']['link'] = 'sql.php';
$tabs['browse']['args']['pos'] = 0;
$tabs['search']['link'] = 'tbl_select.php';
}
 
echo PMA_getTabs( $tabs );
unset( $tabs );
 
/**
* Displays a message
*/
if (!empty($message)) {
PMA_showMessage($message);
unset($message);
}
 
?><br />
/Web/Maintenance/phpMyAdmin/libraries/tbl_properties_table_info.inc.php
0,0 → 1,100
<?php
/* $Id: tbl_properties_table_info.inc.php,v 1.3 2005/12/08 12:14:34 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* extracts table properties from create statement
*
* @TODO this should be recoded as functions,
* to avoid messing with global variables
*/
 
/**
* requirements
*/
require_once('./libraries/common.lib.php');
 
// Check parameters
PMA_checkParameters(array('db', 'table'));
 
/**
* Defining global variables, in case this script is included by a function.
* This is necessary because this script can be included by libraries/header.inc.php.
*/
global $showtable, $tbl_is_view, $tbl_type, $show_comment, $tbl_collation,
$table_info_num_rows, $auto_increment;
 
/**
* Gets table informations
*/
// Seems we need to do this in MySQL 5.0.2,
// otherwise error #1046, no database selected
PMA_DBI_select_db($GLOBALS['db']);
 
// The 'show table' statement works correct since 3.23.03
$table_info_result = PMA_DBI_query(
'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\';',
null, PMA_DBI_QUERY_STORE);
 
// need this test because when we are creating a table, we get 0 rows
// from the SHOW TABLE query
// and we don't want to mess up the $tbl_type coming from the form
 
if ($table_info_result && PMA_DBI_num_rows($table_info_result) > 0) {
$showtable = PMA_DBI_fetch_assoc($table_info_result);
PMA_DBI_free_result($table_info_result);
unset( $table_info_result );
 
if (!isset($showtable['Type']) && isset($showtable['Engine'])) {
$showtable['Type'] =& $showtable['Engine'];
}
// MySQL < 5.0.13 returns "view", >= 5.0.13 returns "VIEW"
if ( PMA_MYSQL_INT_VERSION >= 50000 && !isset($showtable['Type'])
&& isset($showtable['Comment'])
&& strtoupper($showtable['Comment']) == 'VIEW' ) {
$tbl_is_view = true;
$tbl_type = $GLOBALS['strView'];
$show_comment = null;
} else {
$tbl_is_view = false;
$tbl_type = isset($showtable['Type'])
? strtoupper($showtable['Type'])
: '';
// a new comment could be coming from tbl_properties_operations.php
// and we want to show it in the header
if (isset($submitcomment) && isset($comment)) {
$show_comment = $comment;
} else {
$show_comment = isset($showtable['Comment'])
? $showtable['Comment']
: '';
}
}
$tbl_collation = empty($showtable['Collation'])
? ''
: $showtable['Collation'];
 
if ( null === $showtable['Rows'] ) {
$showtable['Rows'] = PMA_countRecords( $GLOBALS['db'],
$showtable['Name'], true, true );
}
$table_info_num_rows = isset($showtable['Rows']) ? $showtable['Rows'] : 0;
$auto_increment = isset($showtable['Auto_increment'])
? $showtable['Auto_increment']
: '';
 
$create_options = isset($showtable['Create_options'])
? explode(' ', $showtable['Create_options'])
: array();
 
// export create options by its name as variables into gloabel namespace
// f.e. pack_keys=1 becomes available as $pack_keys with value of '1'
foreach ( $create_options as $each_create_option ) {
$each_create_option = explode('=', $each_create_option);
if ( isset( $each_create_option[1] ) ) {
$$each_create_option[0] = $each_create_option[1];
}
}
unset( $create_options, $each_create_option );
} // end if
?>
/Web/Maintenance/phpMyAdmin/libraries/tbl_replace_fields.inc.php
0,0 → 1,226
<?php
/* $Id: tbl_replace_fields.inc.php,v 1.5 2006/01/17 17:02:31 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
// note: grab_globals has extracted the fields from _FILES
// or HTTP_POST_FILES
 
// Check parameters
 
require_once('./libraries/common.lib.php');
 
PMA_checkParameters(array('db', 'encoded_key'));
 
 
// f i e l d u p l o a d e d f r o m a f i l e
 
// garvin: original if-clause checked, whether input was stored in a possible fields_upload_XX var.
// Now check, if the field is set. If it is empty or a malicious file, do not alter fields contents.
// If an empty or invalid file is specified, the binary data gets deleter. Maybe a nice
// new text-variable is appropriate to document this behaviour.
 
// garvin: security cautions! You could trick the form and submit any file the webserver has access to
// for upload to a binary field. Shouldn't be that easy! ;)
 
// garvin: default is to advance to the field-value parsing. Will only be set to true when a
// binary file is uploaded, thus bypassing further manipulation of $val.
 
$check_stop = false;
 
// Check if a multi-edit row was found
${'me_fields_upload_' . $encoded_key} = (isset($enc_primary_key) && isset(${'fields_upload_' . $encoded_key}['multi_edit']) ? ${'fields_upload_' . $encoded_key}['multi_edit'][$enc_primary_key] : (isset(${'fields_upload_' . $encoded_key}) ? ${'fields_upload_' . $encoded_key} : null));
${'me_fields_uploadlocal_' . $encoded_key} = (isset($enc_primary_key) && isset(${'fields_uploadlocal_' . $encoded_key}['multi_edit']) ? ${'fields_uploadlocal_' . $encoded_key}['multi_edit'][$enc_primary_key] : (isset(${'fields_uploadlocal_' . $encoded_key}) ? ${'fields_uploadlocal_' . $encoded_key} : null));
 
if (isset(${'me_fields_upload_' . $encoded_key}) && ${'me_fields_upload_' . $encoded_key} != 'none'){
// garvin: This fields content is a blob-file upload.
 
if (!empty(${'me_fields_upload_' . $encoded_key})) {
// garvin: The blob-field is not empty. Check what we have there.
 
$data_file = ${'me_fields_upload_' . $encoded_key};
 
if (is_uploaded_file($data_file)) {
// garvin: A valid uploaded file is found. Look into the file...
 
$val = fread(fopen($data_file, 'rb'), filesize($data_file));
// nijel: This is probably the best way how to put binary data
// into MySQL and it also allow not to care about charset
// conversion that would otherwise corrupt the data.
 
if (!empty($val)) {
// garvin: The upload was valid. Check in new blob-field's contents.
$val = '0x' . bin2hex($val);
$seen_binary = TRUE;
$check_stop = TRUE;
}
// garvin: ELSE: an empty file was uploaded. Remove blob-field's contents.
// Blob-fields are preserved, see below. ($protected$)
 
} else {
// garvin: Danger, will robinson. File is malicious. Blob-fields are preserved, see below. ($protected$)
// void
}
 
} elseif (!empty(${'me_fields_uploadlocal_' . $encoded_key})) {
$file_to_upload = PMA_userDir($cfg['UploadDir']) . preg_replace('@\.\.*@', '.', ${'me_fields_uploadlocal_' . $encoded_key});
 
// A local file will be uploaded.
$open_basedir = @ini_get('open_basedir');
 
// If we are on a server with open_basedir, we must move the file
// before opening it. The doc explains how to create the "./tmp"
// directory
 
$unlink = false;
if (!empty($open_basedir)) {
 
$tmp_subdir = (PMA_IS_WINDOWS ? '.\\tmp\\' : './tmp/');
 
// function is_writeable() is valid on PHP3 and 4
if (!is_writeable($tmp_subdir)) {
// if we cannot move the file don't change blob fields
$file_to_upload = '';
} else {
$new_file_to_upload = $tmp_subdir . basename($file_to_upload);
move_uploaded_file($file_to_upload, $new_file_to_upload);
 
$file_to_upload = $new_file_to_upload;
$unlink = true;
}
}
 
if ($file_to_upload != '') {
 
$val = fread(fopen($file_to_upload, 'rb'), filesize($file_to_upload));
if (!empty($val)) {
$val = '0x' . bin2hex($val);
$seen_binary = TRUE;
$check_stop = TRUE;
}
 
if ($unlink == TRUE) {
unlink($file_to_upload);
}
}
 
}
// garvin: else: Post-field contains no data. Blob-fields are preserved, see below. ($protected$)
 
}
 
if (!$check_stop) {
 
// f i e l d v a l u e i n t h e f o r m
 
if (isset($me_fields_type[$encoded_key])) {
$type = $me_fields_type[$encoded_key];
} else {
$type = '';
}
 
$f = 'field_' . md5($key);
$t_fval = (isset($$f) ? $$f : null);
if (isset($t_fval['multi_edit']) && isset($t_fval['multi_edit'][$enc_primary_key])) {
$fval = &$t_fval['multi_edit'][$enc_primary_key];
} else {
$fval = null;
}
switch (strtolower($val)) {
// let users type NULL or null to input this string and not a NULL value
//case 'null':
// break;
case '':
switch ($type) {
case 'enum':
// if we have an enum, then construct the value
if (!empty($fval)) {
$val = implode(',', $fval);
if ($val == 'null') {
// void
} else {
// the data here is urlencoded
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
}
} else {
$val = "''";
}
break;
case 'set':
// if we have a set, then construct the value
if (!empty($fval)) {
$val = implode(',', $fval);
// the data here is urlencoded
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
} else {
$val = "''";
}
break;
case 'foreign':
// if we have a foreign key, then construct the value
if (!empty($fval)) {
$val = implode(',', $fval);
if ($val == 'null') {
// void
} else {
// the data here is not urlencoded!
//$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
$val = "'" . PMA_sqlAddslashes($val) . "'";
}
} else {
$val = "''";
}
break;
case 'protected':
// here we are in protected mode (asked in the config)
// so tbl_change has put this special value in the
// fields array, so we do not change the field value
// but we can still handle field upload
 
// garvin: when in UPDATE mode, do not alter field's contents. When in INSERT
// mode, insert empty field because no values were submitted. If protected
// blobs where set, insert original fields content.
if (isset($fieldlist)) {
if (isset($prot_row) && isset($prot_row[$key]) && !empty($prot_row[$key])) {
$val = '0x' . bin2hex($prot_row[$key]);
$seen_binary = TRUE;
} else {
$val = "''";
}
} else {
unset($val);
}
 
break;
default:
// best way to avoid problems in strict mode (works also in non-strict mode)
if (isset($me_auto_increment) && isset($me_auto_increment[$encoded_key])) {
$val = 'NULL';
} else {
$val = "'" . PMA_sqlAddslashes($val) . "'";
}
break;
}
break;
default:
if (!($type == 'timestamp' && $val == 'CURRENT_TIMESTAMP')) {
$val = "'" . PMA_sqlAddslashes($val) . "'";
}
break;
} // end switch
 
// Was the Null checkbox checked for this field?
// (if there is a value, we ignore the Null checkbox: this could
// be possible if Javascript is disabled in the browser)
if (isset($me_fields_null) && isset($me_fields_null[$encoded_key])
&& $val=="''") {
$val = 'NULL';
}
 
// The Null checkbox was unchecked for this field
if (empty($val) && isset($me_fields_null_prev) && isset($me_fields_null_prev[$encoded_key]) && !isset($me_fields_null[$encoded_key])) {
$val = "''";
}
} // end else (field value in the form)
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/README
0,0 → 1,4
TRANSFORMATION USAGE (Garvin Hicking, <me@supergarv.de>)
====================
 
See the Documentation.html for complete instructions on how to use transformation plugins.
/Web/Maintenance/phpMyAdmin/libraries/transformations/TEMPLATE
0,0 → 1,28
<?php
/* $Id: TEMPLATE,v 2.1 2003/11/26 22:52:24 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Plugin function TEMPLATE (Garvin Hicking).
* -----------------------------------------
*
* For instructions, read the /Documentation.html file.
*
* The string [ENTER_FILENAME_HERE] shall be substituted with the filename without the '.inc.php'
* extension. For further information regarding naming conventions see the /Documentation.html file.
*/
 
function PMA_transformation_[ENTER_FILENAME_HERE]($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
 
// further operations on $buffer using the $options[] array.
 
// You can evaluate the propagated $meta Object. It's contained fields are described in http://www.php.net/mysql_fetch_field.
// This stored information can be used to get the field information about the transformed field.
// $meta->mimetype contains the original MimeType of the field (i.e. 'text/plain', 'image/jpeg' etc.)
 
return $buffer;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/TEMPLATE_MIMETYPE
0,0 → 1,13
<?php
/* $Id: TEMPLATE_MIMETYPE,v 2.1 2003/11/26 22:52:24 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* MIME-Init function TEMPLATE (Garvin Hicking).
* -----------------------------------------
*
* This files serves no function. It's only kept here to add a mimetype value for selection.
* You can still use global or other mimetype's transforms with this mimetype.
*/
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/application_octetstream__download.inc.php
0,0 → 1,29
<?php
/* $Id: application_octetstream__download.inc.php,v 2.0 2003/12/29 17:48:40 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_application_octetstream__download(&$buffer, $options = array(), $meta = '') {
global $row;
 
if (isset($options[0]) && !empty($options[0])) {
$cn = $options[0]; // filename
} else {
if (isset($options[1]) && !empty($options[1]) && isset($row[$options[1]])) {
$cn = $row[$options[1]];
} else {
$cn = 'binary_file.dat';
}
}
 
return
sprintf(
'<a href="transformation_wrapper.php%s&amp;ct=application/octet-stream&amp;cn=%s" title="%s">%s</a>',
 
$options['wrapper_link'],
urlencode($cn),
htmlspecialchars($cn),
htmlspecialchars($cn)
);
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/application_octetstream__hex.inc.php
0,0 → 1,12
<?php
/* $Id: application_octetstream__hex.inc.php,v 1.1 2005/06/24 14:28:00 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_application_octetstream__hex($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
 
return chunk_split(bin2hex($buffer), 2, ' ');
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/generator.sh
0,0 → 1,33
#!/bin/bash
# $Id: generator.sh,v 2.0 2003/11/18 15:20:44 nijel Exp $
#
# Shell script that adds a new function file using a template. Should not be called directly
# but instead by template_Generator.sh and template_generator_mimetype.sh
#
#
# $1: Template
# $2: Filename
# $3: (optional) Description
 
if [ $# == 0 ]
then
echo "Please call template_generator.sh or template_generator_mimetype.sh instead"
echo ""
exit 65
fi
functionupper="`echo $2 | tr [:lower:] [:upper:]`"
functionlower="`echo $2 | tr [:upper:] [:lower:]`"
 
cat $1 | sed "s/\[ENTER_FILENAME_HERE\]/$functionupper/" | sed "s/\[enter_filename_here\]/$functionlower/" >> $2.inc.php
 
if [ "$3" ]
then
echo ""
echo "To do later:"
echo "cd ../../lang"
echo "./add_message.sh '\$strTransformation_${functionlower}' '$3'"
echo ""
fi
 
echo "Created $2.inc.php"
echo ""
/Web/Maintenance/phpMyAdmin/libraries/transformations/global.inc.php
0,0 → 1,48
<?php
/* $Id: global.inc.php,v 2.3 2003/11/26 22:52:24 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* GLOBAL Plugin function (Garvin Hicking).
* ---------------
*
* THIS FILE PROVIDES BASIC FUNCTIONS TO USE IN OTHER PLUGINS!
*
* The basic filename usage for any plugin, residing in the libraries/transformations directory is:
*
* -- <mime_type>_<mime_subtype>__<transformation_name>.inc.php
*
* The function name has to be the like above filename:
*
* -- function PMA_transformation_<mime_type>_<mime_subtype>__<transformation_name>.inc.php
*
* Please use short and expressive names. For now, special characters which aren't allowed in
* filenames or functions should not be used.
*
* Please provide a comment for your function, what it does and what parameters are available.
*
*/
 
function PMA_transformation_global_plain($buffer, $options = array(), $meta = '') {
return htmlspecialchars($buffer);
}
 
function PMA_transformation_global_html($buffer, $options = array(), $meta = '') {
return $buffer;
}
 
function PMA_transformation_global_html_replace($buffer, $options = array(), $meta = '') {
if (!isset($options['string'])) {
$options['string'] = '';
}
 
if (isset($options['regex']) && isset($options['regex_replace'])) {
$buffer = preg_replace('@' . str_replace('@', '\@', $options['regex']) . '@si', $options['regex_replace'], $buffer);
}
 
// Replace occurences of [__BUFFER__] with actual text
$return = str_replace("[__BUFFER__]", $buffer, $options['string']);
return $return;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/image_jpeg__inline.inc.php
0,0 → 1,18
<?php
/* $Id: image_jpeg__inline.inc.php,v 2.3 2005/05/22 17:09:27 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_image_jpeg__inline($buffer, $options = array(), $meta = '') {
require_once('./libraries/transformations/global.inc.php');
 
if (PMA_IS_GD2) {
$transform_options = array ('string' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" target="_blank"><img src="transformation_wrapper.php' . $options['wrapper_link'] . '&amp;resize=jpeg&amp;newWidth=' . (isset($options[0]) ? $options[0] : '100') . '&amp;newHeight=' . (isset($options[1]) ? $options[1] : 100) . '" alt="[__BUFFER__]" border="0" /></a>');
} else {
$transform_options = array ('string' => '<img src="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]" width="320" height="240" />');
}
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
 
return $buffer;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/image_jpeg__link.inc.php
0,0 → 1,14
<?php
/* $Id: image_jpeg__link.inc.php,v 2.2 2003/12/02 15:49:21 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_image_jpeg__link($buffer, $options = array(), $meta = '') {
require_once('./libraries/transformations/global.inc.php');
 
$transform_options = array ('string' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]">[BLOB]</a>');
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
 
return $buffer;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/image_png__inline.inc.php
0,0 → 1,18
<?php
/* $Id: image_png__inline.inc.php,v 2.3 2005/05/22 17:09:27 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_image_png__inline($buffer, $options = array(), $meta = '') {
require_once('./libraries/transformations/global.inc.php');
 
if (PMA_IS_GD2) {
$transform_options = array ('string' => '<a href="transformation_wrapper.php' . $options['wrapper_link'] . '" target="_blank"><img src="transformation_wrapper.php' . $options['wrapper_link'] . '&amp;resize=png&amp;newWidth=' . (isset($options[0]) ? $options[0] : '100') . '&amp;newHeight=' . (isset($options[1]) ? $options[1] : 100) . '" alt="[__BUFFER__]" border="0" /></a>');
} else {
$transform_options = array ('string' => '<img src="transformation_wrapper.php' . $options['wrapper_link'] . '" alt="[__BUFFER__]" width="320" height="240" />');
}
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
 
return $buffer;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/template_generator.sh
0,0 → 1,25
#!/bin/bash
# $Id: template_generator.sh,v 2.0 2003/11/18 15:20:45 nijel Exp $
#
# Shell script that adds a new mimetype with transform function.
#
# The filename should contain either 'mimetype_subtype' or 'mimetype'.
# The suffix '.inc.php' is appended automatically!
#
# The 'description' parameter will add a new entry in the language file. Watch out for
# special escaping.
#
# Example: template_generator.sh 'filename' 'description'
#
if [ $# == 0 ]
then
echo "Usage: template_generator.sh 'filename' 'description'"
echo ""
exit 65
fi
 
 
 
./generator.sh 'TEMPLATE' "$1" "$2"
echo " "
echo "New TRANSFORM FUNCTION $1.inc.php added."
/Web/Maintenance/phpMyAdmin/libraries/transformations/template_generator_mimetype.sh
0,0 → 1,20
#!/bin/bash
# $Id: template_generator_mimetype.sh,v 2.0 2003/11/18 15:20:45 nijel Exp $
#
# Shell script that adds a new mimetype without transform function.
#
# The filename should contain either 'mimetype_subtype' or 'mimetype'.
# The suffix '.inc.php' is appended automatically!
#
# Example: template_generator_mimetype.sh 'filename'
#
if [ $# == 0 ]
then
echo "Usage: template_generator_mimetype.sh 'filename'"
echo ""
exit 65
fi
 
./generator.sh 'TEMPLATE_MIMETYPE' "$1"
echo " "
echo "New MIMETYPE $1.inc.php added."
/Web/Maintenance/phpMyAdmin/libraries/transformations/text_plain__dateformat.inc.php
0,0 → 1,61
<?php
/* $Id: text_plain__dateformat.inc.php,v 2.3 2003/12/05 11:02:14 garvinhicking Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_text_plain__dateformat($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
 
// further operations on $buffer using the $options[] array.
if (!isset($options[0]) || $options[0] == '') {
$options[0] = 0;
}
 
if (!isset($options[1]) || $options[1] == '') {
$options[1] = $GLOBALS['datefmt'];
 
}
 
$timestamp = -1;
 
// Detect TIMESTAMP(6 | 8 | 10 | 12 | 14), (2 | 4) not supported here.
if (preg_match('/^(\d{2}){3,7}$/', $buffer)) {
 
if (strlen($buffer) == 14 || strlen($buffer) == 8) {
$offset = 4;
} else {
$offset = 2;
}
 
$d = array();
$d['year'] = substr($buffer, 0, $offset);
$d['month'] = substr($buffer, $offset, 2);
$d['day'] = substr($buffer, $offset + 2, 2);
$d['hour'] = substr($buffer, $offset + 4, 2);
$d['minute'] = substr($buffer, $offset + 6, 2);
$d['second'] = substr($buffer, $offset + 8, 2);
 
if (checkdate($d['month'], $d['day'], $d['year'])) {
$timestamp = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'], $d['year']);
}
// If all fails, assume one of the dozens of valid strtime() syntaxes (http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html)
} else {
$timestamp = strtotime($buffer);
}
 
// If all above failed, maybe it's a Unix timestamp already?
if ($timestamp < 0 && preg_match('/^[1-9]\d{1,9}$/', $buffer)) {
$timestamp = $buffer;
}
 
// Reformat a valid timestamp
if ($timestamp >= 0) {
$timestamp -= $options[0] * 60 * 60;
$source = $buffer;
$buffer = '<dfn onclick="alert(\'' . $source . '\');" title="' . $source . '">' . PMA_localisedDate($timestamp, $options[1]) . '</dfn>';
}
 
return $buffer;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/text_plain__external.inc.php
0,0 → 1,91
<?php
/* $Id: text_plain__external.inc.php,v 2.8 2006/01/19 15:39:29 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_text_plain__external_nowrap($options = array()) {
if (!isset($options[3]) || $options[3] == '') {
$nowrap = true;
} elseif ($options[3] == '1' || $options[3] == 1) {
$nowrap = true;
} else {
$nowrap = false;
}
 
return $nowrap;
}
 
function PMA_transformation_text_plain__external($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
 
// further operations on $buffer using the $options[] array.
 
$allowed_programs = array();
 
//
// WARNING:
//
// It's up to administrator to allow anything here. Note that users may
// specify any parameters, so when programs allow output redirection or
// any other possibly dangerous operations, you should write wrapper
// script that will publish only functions you really want.
//
// Add here program definitions like (note that these are NOT safe
// programs):
//
//$allowed_programs[0] = '/usr/local/bin/tidy';
//$allowed_programs[1] = '/usr/local/bin/validate';
 
// no-op when no allowed programs
if (count($allowed_programs) == 0) {
return $buffer;
}
 
if (!isset($options[0]) || $options[0] == '' || !isset($allowed_programs[$options[0]])) {
$program = $allowed_programs[0];
} else {
$program = $allowed_programs[$options[0]];
}
 
if (!isset($options[1]) || $options[1] == '') {
$poptions = '-f /dev/null -i -wrap -q';
} else {
$poptions = $options[1];
}
 
if (!isset($options[2]) || $options[2] == '') {
$options[2] = 1;
}
 
if (!isset($options[3]) || $options[3] == '') {
$options[3] = 1;
}
 
// needs PHP >= 4.3.0
$newstring = '';
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w")
);
$process = proc_open($program . ' ' . $poptions, $descriptorspec, $pipes);
if (is_resource($process)) {
fwrite($pipes[0], $buffer);
fclose($pipes[0]);
 
while (!feof($pipes[1])) {
$newstring .= fgets($pipes[1], 1024);
}
fclose($pipes[1]);
// we don't currently use the return value
$return_value = proc_close($process);
}
 
if ($options[2] == 1 || $options[2] == '2') {
$retstring = htmlspecialchars($newstring);
} else {
$retstring = $newstring;
}
 
return $retstring;
}
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/text_plain__formatted.inc.php
0,0 → 1,9
<?php
/* $Id: text_plain__formatted.inc.php,v 2.1 2003/11/26 22:52:24 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_text_plain__formatted($buffer, $options = array(), $meta = '') {
return $buffer;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/text_plain__imagelink.inc.php
0,0 → 1,13
<?php
/* $Id: text_plain__imagelink.inc.php,v 2.3 2005/05/22 17:09:27 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_text_plain__imagelink($buffer, $options = array(), $meta = '') {
require_once('./libraries/transformations/global.inc.php');
 
$transform_options = array ('string' => '<a href="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" target="_blank"><img src="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" border="0" width="' . (isset($options[1]) ? $options[1] : 100) . '" height="' . (isset($options[2]) ? $options[2] : 50) . '" />' . $buffer . '</a>');
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
return $buffer;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/text_plain__link.inc.php
0,0 → 1,18
<?php
/* $Id: text_plain__link.inc.php,v 2.1 2003/11/26 22:52:24 rabus Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_text_plain__link($buffer, $options = array(), $meta = '') {
require_once('./libraries/transformations/global.inc.php');
 
// $transform_options = array ('string' => '<a href="' . (isset($options[0]) ? $options[0] : '') . '%1$s" title="' . (isset($options[1]) ? $options[1] : '%1$s') . '">' . (isset($options[1]) ? $options[1] : '%1$s') . '</a>');
 
$transform_options = array ('string' => '<a href="' . (isset($options[0]) ? $options[0] : '') . $buffer . '" title="' . (isset($options[1]) ? $options[1] : '') . '">' . (isset($options[1]) ? $options[1] : $buffer) . '</a>');
 
$buffer = PMA_transformation_global_html_replace($buffer, $transform_options);
 
return $buffer;
 
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/text_plain__sql.inc.php
0,0 → 1,12
<?php
/* $Id: text_plain__sql.inc.php,v 1.1 2005/10/16 16:16:36 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_text_plain__sql($buffer, $options = array(), $meta = '') {
$result = PMA_SQP_formatHtml(PMA_SQP_parse($buffer));
// Need to clear error state not to break subsequent queries display.
PMA_SQP_resetError();
return $result;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations/text_plain__substr.inc.php
0,0 → 1,44
<?php
/* $Id: text_plain__substr.inc.php,v 2.3 2004/03/09 15:02:28 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
function PMA_transformation_text_plain__substr($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');
 
// further operations on $buffer using the $options[] array.
if (!isset($options[0]) || $options[0] == '') {
$options[0] = 0;
}
 
if (!isset($options[1]) || $options[1] == '') {
$options[1] = 'all';
}
 
if (!isset($options[2]) || $options[2] == '') {
$options[2] = '...';
}
 
$newtext = '';
if ($options[1] != 'all') {
$newtext = PMA_substr($buffer, $options[0], $options[1]);
} else {
$newtext = PMA_substr($buffer, $options[0]);
}
 
$length = strlen($newtext);
$baselength = strlen($buffer);
if ($length != $baselength) {
if ($options[0] != 0) {
$newtext = $options[2] . $newtext;
}
 
if (($length + $options[0]) != $baselength) {
$newtext .= $options[2];
}
}
 
return $newtext;
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/transformations.lib.php
0,0 → 1,209
<?php
/* $Id: transformations.lib.php,v 2.14 2006/01/19 15:39:29 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
/**
* Set of functions used with the relation and pdf feature
*/
 
function PMA_transformation_getOptions($string) {
$transform_options = array();
 
if ($string != '') {
if ($string{0} == "'" && $string{strlen($string)-1} == "'") {
$transform_options = explode('\',\'', substr($string, 1, strlen($string)-2));
} else {
$transform_options = array(0 => $string);
}
}
 
// strip possible slashes to behave like documentation says
$result = array();
foreach ($transform_options as $val) {
$result[] = stripslashes($val);
}
return $result;
}
 
/**
* Gets all available MIME-types
*
* @return array array[mimetype], array[transformation]
*
* @access public
*
* @author Garvin Hicking <me@supergarv.de>
*/
function PMA_getAvailableMIMEtypes() {
$handle = opendir('./libraries/transformations');
 
$stack = array();
$filestack = array();
 
while (($file = readdir($handle)) != false) {
$filestack[$file] = $file;
}
 
closedir($handle);
 
if (is_array($filestack)) {
@ksort($filestack);
foreach ($filestack AS $key => $file) {
 
if (preg_match('|^.*__.*\.inc\.php$|', trim($file))) {
// File contains transformation functions.
$base = explode('__', str_replace('.inc.php', '', $file));
$mimetype = str_replace('_', '/', $base[0]);
$stack['mimetype'][$mimetype] = $mimetype;
 
$stack['transformation'][] = $mimetype . ': ' . $base[1];
$stack['transformation_file'][] = $file;
 
} elseif (preg_match('|^.*\.inc\.php$|', trim($file))) {
// File is a plain mimetype, no functions.
$base = str_replace('.inc.php', '', $file);
 
if ($base != 'global') {
$mimetype = str_replace('_', '/', $base);
$stack['mimetype'][$mimetype] = $mimetype;
$stack['empty_mimetype'][$mimetype] = $mimetype;
}
}
 
}
}
 
return $stack;
}
 
/**
* Gets the mimetypes for all rows of a table
*
* @param string the name of the db to check for
* @param string the name of the table to check for
* @param string whether to include only results having a mimetype set
*
* @return array [field_name][field_key] = field_value
*
* @global array the list of relations settings
*
* @access public
*
* @author Mike Beck <mikebeck@users.sourceforge.net> / Garvin Hicking <me@supergarv.de>
*/
function PMA_getMIME($db, $table, $strict = false) {
global $cfgRelation;
 
$com_qry = 'SELECT column_name, mimetype, transformation, transformation_options FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND (mimetype != \'\'' . (!$strict ? ' OR transformation != \'\' OR transformation_options != \'\'' : '') . ')';
$com_rs = PMA_query_as_cu($com_qry);
 
while ($row = @PMA_DBI_fetch_assoc($com_rs)) {
$col = $row['column_name'];
$mime[$col]['mimetype'] = $row['mimetype'];
$mime[$col]['transformation'] = $row['transformation'];
$mime[$col]['transformation_options'] = $row['transformation_options'];
} // end while
PMA_DBI_free_result($com_rs);
unset($com_rs);
 
if (isset($mime) && is_array($mime)) {
return $mime;
} else {
return FALSE;
}
} // end of the 'PMA_getMIME()' function
 
/**
* Set a single mimetype to a certain value.
*
* @param string the name of the db
* @param string the name of the table
* @param string the name of the column
* @param string the mimetype of the column
* @param string the transformation of the column
* @param string the transformation options of the column
* @param string (optional) force delete, will erase any existing comments for this column
*
* @return boolean true, if comment-query was made.
*
* @global array the list of relations settings
*
* @access public
*/
function PMA_setMIME($db, $table, $key, $mimetype, $transformation, $transformation_options, $forcedelete = false) {
global $cfgRelation;
 
$test_qry = 'SELECT mimetype, ' . PMA_backquote('comment') . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
$test_rs = PMA_query_as_cu($test_qry, TRUE, PMA_DBI_QUERY_STORE);
 
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
$row = @PMA_DBI_fetch_assoc($test_rs);
PMA_DBI_free_result($test_rs);
unset($test_rs);
 
if (!$forcedelete && (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0 || strlen($row['comment']) > 0)) {
$upd_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' SET mimetype = \'' . PMA_sqlAddslashes($mimetype) . '\','
. ' transformation = \'' . PMA_sqlAddslashes($transformation) . '\','
. ' transformation_options = \'' . PMA_sqlAddslashes($transformation_options) . '\''
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
} else {
$upd_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
. ' AND column_name = \'' . PMA_sqlAddslashes($key) . '\'';
}
} elseif (strlen($mimetype) > 0 || strlen($transformation) > 0 || strlen($transformation_options) > 0) {
$upd_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
. ' (db_name, table_name, column_name, mimetype, transformation, transformation_options) '
. ' VALUES('
. '\'' . PMA_sqlAddslashes($db) . '\','
. '\'' . PMA_sqlAddslashes($table) . '\','
. '\'' . PMA_sqlAddslashes($key) . '\','
. '\'' . PMA_sqlAddslashes($mimetype) . '\','
. '\'' . PMA_sqlAddslashes($transformation) . '\','
. '\'' . PMA_sqlAddslashes($transformation_options) . '\')';
}
 
if (isset($upd_query)){
$upd_rs = PMA_query_as_cu($upd_query);
PMA_DBI_free_result($upd_rs);
unset($upd_rs);
return true;
} else {
return false;
}
} // end of 'PMA_setMIME()' function
 
/**
* Returns the real filename of a configured transformation
*
* @param string the current filename
*
* @return string the new filename
*
* @access public
*/
function PMA_sanitizeTransformationFile(&$filename) {
// garvin: for security, never allow to break out from transformations directory
 
$include_file = PMA_securePath($filename);
 
// This value can also contain a 'php3' value, in which case we map this filename to our new 'php' variant
$testfile = preg_replace('@\.inc\.php3$@', '.inc.php', $include_file);
if ($include_file{strlen($include_file)-1} == '3' && file_exists('./libraries/transformations/' . $testfile)) {
$include_file = $testfile;
$filename = $testfile; // Corrects the referenced variable for further actions on the filename;
}
 
return $include_file;
} // end of 'PMA_sanitizeTransformationFile()' function
?>
/Web/Maintenance/phpMyAdmin/libraries/unzip.lib.php
0,0 → 1,492
<?PHP
/* $Id: unzip.lib.php,v 1.2 2006/01/17 17:02:31 cybot_tm Exp $ */
 
/**
* ZIP file unpack classes. Contributed to the phpMyAdmin project.
*
* @category phpPublic
* @package File-Formats-ZIP
* @subpackage Unzip
* @filesource unzip.lib.php
* @version 1.0.1
*
* @author Holger Boskugel <vbwebprofi@gmx.de>
* @copyright Copyright © 2003, Holger Boskugel, Berlin, Germany
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @history
* 2003-12-02 - HB : Patched : naming bug : Time/Size of file
* Added : ZIP file comment
* Added : Check BZIP2 support of PHP
* 2003-11-29 - HB * Initial version
*/
 
/**
* Unzip class, which retrieves entries from ZIP files.
*
* Supports only the compression modes
* - 0 : Stored,
* - 8 : Deflated and
* - 12 : BZIP2
*
* Based on :<BR>
* <BR>
* {@link http://www.pkware.com/products/enterprise/white_papers/appnote.html
* * Official ZIP file format}<BR>
* {@link http://msdn.microsoft.com/library/en-us/w98ddk/hh/w98ddk/storage_5l4m.asp
* * Microsoft DOS date/time format}
*
* @category phpPublic
* @package File-Formats-ZIP
* @subpackage Unzip
* @version 1.0.1
* @author Holger Boskugel <vbwebprofi@gmx.de>
* @uses SimpleUnzipEntry
* @example example.unzip.php Two examples
*/
class SimpleUnzip {
// 2003-12-02 - HB >
/**
* Array to store file entries
*
* @var string
* @access public
* @see ReadFile()
* @since 1.0.1
*/
var $Comment = '';
// 2003-12-02 - HB <
 
/**
* Array to store file entries
*
* @var array
* @access public
* @see ReadFile()
* @since 1.0
*/
var $Entries = array();
 
/**
* Name of the ZIP file
*
* @var string
* @access public
* @see ReadFile()
* @since 1.0
*/
var $Name = '';
 
/**
* Size of the ZIP file
*
* @var integer
* @access public
* @see ReadFile()
* @since 1.0
*/
var $Size = 0;
 
/**
* Time of the ZIP file (unix timestamp)
*
* @var integer
* @access public
* @see ReadFile()
* @since 1.0
*/
var $Time = 0;
 
/**
* Contructor of the class
*
* @param string File name
* @return SimpleUnzip Instanced class
* @access public
* @uses SimpleUnzip::ReadFile() Opens file on new if specified
* @since 1.0
*/
function SimpleUnzip($in_FileName = '')
{
if ($in_FileName !== '') {
SimpleUnzip::ReadFile($in_FileName);
}
} // end of the 'SimpleUnzip' constructor
 
/**
* Counts the entries
*
* @return integer Count of ZIP entries
* @access public
* @uses $Entries
* @since 1.0
*/
function Count()
{
return count($this->Entries);
} // end of the 'Count()' method
 
/**
* Gets data of the specified ZIP entry
*
* @param integer Index of the ZIP entry
* @return mixed Data for the ZIP entry
* @uses SimpleUnzipEntry::$Data
* @access public
* @since 1.0
*/
function GetData($in_Index)
{
return $this->Entries[$in_Index]->Data;
} // end of the 'GetData()' method
 
/**
* Gets an entry of the ZIP file
*
* @param integer Index of the ZIP entry
* @return SimpleUnzipEntry Entry of the ZIP file
* @uses $Entries
* @access public
* @since 1.0
*/
function GetEntry($in_Index)
{
return $this->Entries[$in_Index];
} // end of the 'GetEntry()' method
 
/**
* Gets error code for the specified ZIP entry
*
* @param integer Index of the ZIP entry
* @return integer Error code for the ZIP entry
* @uses SimpleUnzipEntry::$Error
* @access public
* @since 1.0
*/
function GetError($in_Index)
{
return $this->Entries[$in_Index]->Error;
} // end of the 'GetError()' method
 
/**
* Gets error message for the specified ZIP entry
*
* @param integer Index of the ZIP entry
* @return string Error message for the ZIP entry
* @uses SimpleUnzipEntry::$ErrorMsg
* @access public
* @since 1.0
*/
function GetErrorMsg($in_Index)
{
return $this->Entries[$in_Index]->ErrorMsg;
} // end of the 'GetErrorMsg()' method
 
/**
* Gets file name for the specified ZIP entry
*
* @param integer Index of the ZIP entry
* @return string File name for the ZIP entry
* @uses SimpleUnzipEntry::$Name
* @access public
* @since 1.0
*/
function GetName($in_Index)
{
return $this->Entries[$in_Index]->Name;
} // end of the 'GetName()' method
 
/**
* Gets path of the file for the specified ZIP entry
*
* @param integer Index of the ZIP entry
* @return string Path of the file for the ZIP entry
* @uses SimpleUnzipEntry::$Path
* @access public
* @since 1.0
*/
function GetPath($in_Index)
{
return $this->Entries[$in_Index]->Path;
} // end of the 'GetPath()' method
 
/**
* Gets file time for the specified ZIP entry
*
* @param integer Index of the ZIP entry
* @return integer File time for the ZIP entry (unix timestamp)
* @uses SimpleUnzipEntry::$Time
* @access public
* @since 1.0
*/
function GetTime($in_Index)
{
return $this->Entries[$in_Index]->Time;
} // end of the 'GetTime()' method
 
/**
* Reads ZIP file and extracts the entries
*
* @param string File name of the ZIP archive
* @return array ZIP entry list (see also class variable {@link $Entries $Entries})
* @uses SimpleUnzipEntry For the entries
* @access public
* @since 1.0
*/
function ReadFile($in_FileName)
{
$this->Entries = array();
 
// Get file parameters
$this->Name = $in_FileName;
$this->Time = filemtime($in_FileName);
$this->Size = filesize($in_FileName);
 
// Read file
$oF = fopen($in_FileName, 'rb');
$vZ = fread($oF, $this->Size);
fclose($oF);
 
// 2003-12-02 - HB >
// Cut end of central directory
$aE = explode("\x50\x4b\x05\x06", $vZ);
 
// Easiest way, but not sure if format changes
//$this->Comment = substr($aE[1], 18);
 
// Normal way
$aP = unpack('x16/v1CL', $aE[1]);
$this->Comment = substr($aE[1], 18, $aP['CL']);
 
// Translates end of line from other operating systems
$this->Comment = strtr($this->Comment, array("\r\n" => "\n",
"\r" => "\n"));
// 2003-12-02 - HB <
 
// Cut the entries from the central directory
$aE = explode("\x50\x4b\x01\x02", $vZ);
// Explode to each part
$aE = explode("\x50\x4b\x03\x04", $aE[0]);
// Shift out spanning signature or empty entry
array_shift($aE);
 
// Loop through the entries
foreach ($aE as $vZ) {
$aI = array();
$aI['E'] = 0;
$aI['EM'] = '';
// Retrieving local file header information
$aP = unpack('v1VN/v1GPF/v1CM/v1FT/v1FD/V1CRC/V1CS/V1UCS/v1FNL', $vZ);
// Check if data is encrypted
$bE = ($aP['GPF'] && 0x0001) ? TRUE : FALSE;
$nF = $aP['FNL'];
 
// Special case : value block after the compressed data
if ($aP['GPF'] & 0x0008) {
$aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12));
 
$aP['CRC'] = $aP1['CRC'];
$aP['CS'] = $aP1['CS'];
$aP['UCS'] = $aP1['UCS'];
 
$vZ = substr($vZ, 0, -12);
}
 
// Getting stored filename
$aI['N'] = substr($vZ, 26, $nF);
 
if (substr($aI['N'], -1) == '/') {
// is a directory entry - will be skipped
continue;
}
 
// Truncate full filename in path and filename
$aI['P'] = dirname($aI['N']);
$aI['P'] = $aI['P'] == '.' ? '' : $aI['P'];
$aI['N'] = basename($aI['N']);
 
$vZ = substr($vZ, 26 + $nF);
 
if (strlen($vZ) != $aP['CS']) {
$aI['E'] = 1;
$aI['EM'] = 'Compressed size is not equal with the value in header information.';
} else {
if ($bE) {
$aI['E'] = 5;
$aI['EM'] = 'File is encrypted, which is not supported from this class.';
} else {
switch($aP['CM']) {
case 0: // Stored
// Here is nothing to do, the file ist flat.
break;
 
case 8: // Deflated
$vZ = gzinflate($vZ);
break;
 
case 12: // BZIP2
// 2003-12-02 - HB >
if (! extension_loaded('bz2')) {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
@dl('php_bz2.dll');
} else {
@dl('bz2.so');
}
}
 
if (extension_loaded('bz2')) {
// 2003-12-02 - HB <
$vZ = bzdecompress($vZ);
// 2003-12-02 - HB >
} else {
$aI['E'] = 7;
$aI['EM'] = "PHP BZIP2 extension not available.";
}
// 2003-12-02 - HB <
 
break;
 
default:
$aI['E'] = 6;
$aI['EM'] = "De-/Compression method {$aP['CM']} is not supported.";
}
 
// 2003-12-02 - HB >
if (! $aI['E']) {
// 2003-12-02 - HB <
if ($vZ === FALSE) {
$aI['E'] = 2;
$aI['EM'] = 'Decompression of data failed.';
} else {
if (strlen($vZ) != $aP['UCS']) {
$aI['E'] = 3;
$aI['EM'] = 'Uncompressed size is not equal with the value in header information.';
} else {
if (crc32($vZ) != $aP['CRC']) {
$aI['E'] = 4;
$aI['EM'] = 'CRC32 checksum is not equal with the value in header information.';
}
}
}
// 2003-12-02 - HB >
}
// 2003-12-02 - HB <
}
}
 
$aI['D'] = $vZ;
 
// DOS to UNIX timestamp
$aI['T'] = mktime(($aP['FT'] & 0xf800) >> 11,
($aP['FT'] & 0x07e0) >> 5,
($aP['FT'] & 0x001f) << 1,
($aP['FD'] & 0x01e0) >> 5,
($aP['FD'] & 0x001f),
(($aP['FD'] & 0xfe00) >> 9) + 1980);
 
$this->Entries[] = &new SimpleUnzipEntry($aI);
} // end for each entries
 
return $this->Entries;
} // end of the 'ReadFile()' method
} // end of the 'SimpleUnzip' class
 
/**
* Entry of the ZIP file.
*
* @category phpPublic
* @package File-Formats-ZIP
* @subpackage Unzip
* @version 1.0
* @author Holger Boskugel <vbwebprofi@gmx.de>
* @example example.unzip.php Two examples
*/
class SimpleUnzipEntry {
/**
* Data of the file entry
*
* @var mixed
* @access public
* @see SimpleUnzipEntry()
* @since 1.0
*/
var $Data = '';
 
/**
* Error of the file entry
*
* - 0 : No error raised.<BR>
* - 1 : Compressed size is not equal with the value in header information.<BR>
* - 2 : Decompression of data failed.<BR>
* - 3 : Uncompressed size is not equal with the value in header information.<BR>
* - 4 : CRC32 checksum is not equal with the value in header information.<BR>
* - 5 : File is encrypted, which is not supported from this class.<BR>
* - 6 : De-/Compression method ... is not supported.<BR>
* - 7 : PHP BZIP2 extension not available.
*
* @var integer
* @access public
* @see SimpleUnzipEntry()
* @since 1.0
*/
var $Error = 0;
 
/**
* Error message of the file entry
*
* @var string
* @access public
* @see SimpleUnzipEntry()
* @since 1.0
*/
var $ErrorMsg = '';
 
/**
* File name of the file entry
*
* @var string
* @access public
* @see SimpleUnzipEntry()
* @since 1.0
*/
var $Name = '';
 
/**
* File path of the file entry
*
* @var string
* @access public
* @see SimpleUnzipEntry()
* @since 1.0
*/
var $Path = '';
 
/**
* File time of the file entry (unix timestamp)
*
* @var integer
* @access public
* @see SimpleUnzipEntry()
* @since 1.0
*/
var $Time = 0;
 
/**
* Contructor of the class
*
* @param array Entry datas
* @return SimpleUnzipEntry Instanced class
* @access public
* @since 1.0
*/
function SimpleUnzipEntry($in_Entry)
{
$this->Data = $in_Entry['D'];
$this->Error = $in_Entry['E'];
$this->ErrorMsg = $in_Entry['EM'];
$this->Name = $in_Entry['N'];
$this->Path = $in_Entry['P'];
$this->Time = $in_Entry['T'];
} // end of the 'SimpleUnzipEntry' constructor
} // end of the 'SimpleUnzipEntry' class
?>
/Web/Maintenance/phpMyAdmin/libraries/url_generating.lib.php
0,0 → 1,206
<?php
/* $Id: url_generating.lib.php,v 2.10.2.1 2006/05/12 15:26:16 nijel Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/**
* URL/hidden inputs generating.
*/
 
 
/**
* Generates text with hidden inputs.
*
* @see PMA_generate_common_url()
* @param string optional database name
* @param string optional table name
* @param int indenting level
*
* @return string string with input fields
*
* @global string the current language
* @global string the current conversion charset
* @global string the current connection collation
* @global string the current server
* @global array the configuration array
* @global boolean whether recoding is allowed or not
*
* @access public
*
* @author nijel
*/
function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $skip = array())
{
if (is_array($db)) {
$params =& $db;
$_indent = empty($table) ? $indent : $table;
$_skip = empty($indent) ? $skip : $indent;
$indent =& $_indent;
$skip =& $_skip;
} else {
$params = array();
if (isset($db) && strlen($db)) {
$params['db'] = $db;
}
if (isset($table) && strlen($table)) {
$params['table'] = $table;
}
}
 
if (! empty($GLOBALS['server'])
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']) {
$params['server'] = $GLOBALS['server'];
}
if (empty($_COOKIE['pma_lang'])
&& ! empty($GLOBALS['lang'])) {
$params['lang'] = $GLOBALS['lang'];
}
if (empty($_COOKIE['pma_charset'])
&& ! empty($GLOBALS['convcharset'])) {
$params['convcharset'] = $GLOBALS['convcharset'];
}
if (empty($_COOKIE['pma_collation_connection'])
&& ! empty($GLOBALS['collation_connection'])) {
$params['collation_connection'] = $GLOBALS['collation_connection'];
}
 
$params['token'] = $_SESSION['PMA_token'];
 
if (! is_array($skip)) {
if (isset($params[$skip])) {
unset($params[$skip]);
}
} else {
foreach ($skip as $skipping) {
if (isset($params[$skipping])) {
unset($params[$skipping]);
}
}
}
 
$spaces = str_repeat(' ', $indent);
 
$return = '';
foreach ($params as $key => $val) {
$return .= $spaces . '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($val) . '" />' . "\n";
}
 
return $return;
}
 
/**
* Generates text with URL parameters.
*
* <code>
* // note the ?
* echo 'script.php?' . PMA_generate_common_url('mysql', 'rights');
* // produces with cookies enabled:
* // script.php?db=mysql&amp;table=rights
* // with cookies disabled:
* // script.php?server=1&amp;lang=en-utf-8&amp;db=mysql&amp;table=rights
*
* $params['myparam'] = 'myvalue';
* $params['db'] = 'mysql';
* $params['table'] = 'rights';
* // note the missing ?
* echo 'script.php' . PMA_generate_common_url($params);
* // produces with cookies enabled:
* // script.php?myparam=myvalue&amp;db=mysql&amp;table=rights
* // with cookies disabled:
* // script.php?server=1&amp;lang=en-utf-8&amp;myparam=myvalue&amp;db=mysql&amp;table=rights
*
* // note the missing ?
* echo 'script.php' . PMA_generate_common_url();
* // produces with cookies enabled:
* // script.php
* // with cookies disabled:
* // script.php?server=1&amp;lang=en-utf-8
* </code>
*
* @param mixed assoc. array with url params or optional string with database name
* if first param is an array there is also an ? prefixed to the url
* @param string optional table name only if first param is array
* @param string character to use instead of '&amp;' for deviding
* multiple URL parameters from each other
*
* @return string string with URL parameters
*
* @global string the current language
* @global string the current conversion charset
* @global string the current connection collation
* @global string the current server
* @global array the configuration array
* @global boolean whether recoding is allowed or not
*
* @access public
*
* @author nijel
*/
function PMA_generate_common_url ($db = '', $table = '', $delim = '&amp;')
{
if (is_array($db)) {
$params =& $db;
$delim = empty($table) ? $delim : $table;
$questionmark = '?';
} else {
$params = array();
if (isset($db) && strlen($db)) {
$params['db'] = $db;
}
if (isset($table) && strlen($table)) {
$params['table'] = $table;
}
$questionmark = '';
}
 
// use seperators defined by php, but prefer ';'
// as recommended by W3C
$php_arg_separator_input = ini_get('arg_separator.input');
if (strpos($php_arg_separator_input, ';') !== false) {
$separator = ';';
} elseif (strlen($php_arg_separator_input) > 0) {
$separator = $php_arg_separator_input{0};
} else {
$separator = '&';
}
 
// check wether to htmlentity the separator or not
if ($delim === '&amp;') {
$delim = htmlentities($separator);
} else {
$delim = $separator;
}
 
if (isset($GLOBALS['server'])
&& $GLOBALS['server'] != $GLOBALS['cfg']['ServerDefault']) {
$params['server'] = $GLOBALS['server'];
}
 
if (empty($_COOKIE['pma_lang'])
&& ! empty($GLOBALS['lang'])) {
$params['lang'] = $GLOBALS['lang'];
}
if (empty($_COOKIE['pma_charset'])
&& ! empty($GLOBALS['convcharset'])) {
$params['convcharset'] = $GLOBALS['convcharset'];
}
if (empty($_COOKIE['pma_collation_connection'])
&& ! empty($GLOBALS['collation_connection'])) {
$params['collation_connection'] = $GLOBALS['collation_connection'];
}
 
$params['token'] = $_SESSION['PMA_token'];
 
$param_strings = array();
foreach ($params as $key => $val) {
$param_strings[] = urlencode($key) . '=' . urlencode($val);
}
 
if (empty($param_strings)) {
return '';
}
 
return $questionmark . implode($delim, $param_strings);
}
 
?>
/Web/Maintenance/phpMyAdmin/libraries/zip.lib.php
0,0 → 1,188
<?php
/* $Id: zip.lib.php,v 2.4 2004/11/03 13:56:52 garvinhicking Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
 
 
/**
* Zip file creation class.
* Makes zip files.
*
* Based on :
*
* http://www.zend.com/codex.php?id=535&single=1
* By Eric Mueller <eric@themepark.com>
*
* http://www.zend.com/codex.php?id=470&single=1
* by Denis125 <webmaster@atlant.ru>
*
* a patch from Peter Listiak <mlady@users.sourceforge.net> for last modified
* date and time of the compressed file
*
* Official ZIP file format: http://www.pkware.com/appnote.txt
*
* @access public
*/
class zipfile
{
/**
* Array to store compressed data
*
* @var array $datasec
*/
var $datasec = array();
 
/**
* Central directory
*
* @var array $ctrl_dir
*/
var $ctrl_dir = array();
 
/**
* End of central directory record
*
* @var string $eof_ctrl_dir
*/
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
 
/**
* Last offset position
*
* @var integer $old_offset
*/
var $old_offset = 0;
 
 
/**
* Converts an Unix timestamp to a four byte DOS date and time format (date
* in high two bytes, time in low two bytes allowing magnitude comparison).
*
* @param integer the current Unix timestamp
*
* @return integer the current date in a four byte DOS format
*
* @access private
*/
function unix2DosTime($unixtime = 0) {
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
 
if ($timearray['year'] < 1980) {
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
} // end if
 
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
} // end of the 'unix2DosTime()' method
 
 
/**
* Adds "file" to archive
*
* @param string file contents
* @param string name of the file in the archive (may contains the path)
* @param integer the current timestamp
*
* @access public
*/
function addFile($data, $name, $time = 0)
{
$name = str_replace('\\', '/', $name);
 
$dtime = dechex($this->unix2DosTime($time));
$hexdtime = '\x' . $dtime[6] . $dtime[7]
. '\x' . $dtime[4] . $dtime[5]
. '\x' . $dtime[2] . $dtime[3]
. '\x' . $dtime[0] . $dtime[1];
eval('$hexdtime = "' . $hexdtime . '";');
 
$fr = "\x50\x4b\x03\x04";
$fr .= "\x14\x00"; // ver needed to extract
$fr .= "\x00\x00"; // gen purpose bit flag
$fr .= "\x08\x00"; // compression method
$fr .= $hexdtime; // last mod time and date
 
// "local file header" segment
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$c_len = strlen($zdata);
$fr .= pack('V', $crc); // crc32
$fr .= pack('V', $c_len); // compressed filesize
$fr .= pack('V', $unc_len); // uncompressed filesize
$fr .= pack('v', strlen($name)); // length of filename
$fr .= pack('v', 0); // extra field length
$fr .= $name;
 
// "file data" segment
$fr .= $zdata;
 
// "data descriptor" segment (optional but necessary if archive is not
// served as file)
// nijel(2004-10-19): this seems not to be needed at all and causes
// problems in some cases (bug #1037737)
//$fr .= pack('V', $crc); // crc32
//$fr .= pack('V', $c_len); // compressed filesize
//$fr .= pack('V', $unc_len); // uncompressed filesize
 
// add this entry to array
$this -> datasec[] = $fr;
 
// now add to central directory record
$cdrec = "\x50\x4b\x01\x02";
$cdrec .= "\x00\x00"; // version made by
$cdrec .= "\x14\x00"; // version needed to extract
$cdrec .= "\x00\x00"; // gen purpose bit flag
$cdrec .= "\x08\x00"; // compression method
$cdrec .= $hexdtime; // last mod time & date
$cdrec .= pack('V', $crc); // crc32
$cdrec .= pack('V', $c_len); // compressed filesize
$cdrec .= pack('V', $unc_len); // uncompressed filesize
$cdrec .= pack('v', strlen($name) ); // length of filename
$cdrec .= pack('v', 0 ); // extra field length
$cdrec .= pack('v', 0 ); // file comment length
$cdrec .= pack('v', 0 ); // disk number start
$cdrec .= pack('v', 0 ); // internal file attributes
$cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
 
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header
$this -> old_offset += strlen($fr);
 
$cdrec .= $name;
 
// optional extra field, file comment goes here
// save to central directory
$this -> ctrl_dir[] = $cdrec;
} // end of the 'addFile()' method
 
 
/**
* Dumps out file
*
* @return string the zipped file
*
* @access public
*/
function file()
{
$data = implode('', $this -> datasec);
$ctrldir = implode('', $this -> ctrl_dir);
 
return
$data .
$ctrldir .
$this -> eof_ctrl_dir .
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk"
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall
pack('V', strlen($ctrldir)) . // size of central dir
pack('V', strlen($data)) . // offset to start of central dir
"\x00\x00"; // .zip file comment length
} // end of the 'file()' method
 
} // end of the 'zipfile' class
?>