2 /* vim: set expandtab sw=4 ts=4 sts=4: */
11 * Load vendor configuration.
13 require_once('./libraries/vendor_config.php');
23 * @var string default config source
25 var $default_source = './libraries/config.default.php';
28 * @var array configuration settings
30 var $settings = array();
33 * @var string config source
38 * @var int source modification time
40 var $source_mtime = 0;
41 var $default_source_mtime = 0;
47 var $error_config_file = false;
52 var $error_config_default_file = false;
57 var $error_pma_uri = false;
62 var $default_server = array();
65 * @var boolean whether init is done or not
66 * set this to false to force some initial checks
67 * like checking for required functions
74 * @param string source to read config from
76 function __construct($source = null)
78 $this->settings
= array();
80 // functions need to refresh in case of config file changed goes in
84 // other settings, independent from config file, comes in
87 $this->checkIsHttps();
91 * sets system and application settings
93 function checkSystem()
95 $this->set('PMA_VERSION', '3.3.5-rc1');
99 $this->set('PMA_THEME_VERSION', 2);
103 $this->set('PMA_THEME_GENERATION', 2);
105 $this->checkPhpVersion();
106 $this->checkWebServerOs();
107 $this->checkWebServer();
109 $this->checkClient();
110 $this->checkUpload();
111 $this->checkUploadSize();
112 $this->checkOutputCompression();
116 * whether to use gzip output compression or not
118 function checkOutputCompression()
120 // If zlib output compression is set in the php configuration file, no
121 // output buffering should be run
122 if (@ini_get
('zlib.output_compression')) {
123 $this->set('OBGzip', false);
126 // disable output-buffering (if set to 'auto') for IE6, else enable it.
127 if (strtolower($this->get('OBGzip')) == 'auto') {
128 if ($this->get('PMA_USR_BROWSER_AGENT') == 'IE'
129 && $this->get('PMA_USR_BROWSER_VER') >= 6
130 && $this->get('PMA_USR_BROWSER_VER') < 7) {
131 $this->set('OBGzip', false);
133 $this->set('OBGzip', true);
139 * Determines platform (OS), browser and version of the user
140 * Based on a phpBuilder article:
141 * @see http://www.phpbuilder.net/columns/tim20000821.php
143 function checkClient()
145 if (PMA_getenv('HTTP_USER_AGENT')) {
146 $HTTP_USER_AGENT = PMA_getenv('HTTP_USER_AGENT');
147 } elseif (!isset($HTTP_USER_AGENT)) {
148 $HTTP_USER_AGENT = '';
152 if (strstr($HTTP_USER_AGENT, 'Win')) {
153 $this->set('PMA_USR_OS', 'Win');
154 } elseif (strstr($HTTP_USER_AGENT, 'Mac')) {
155 $this->set('PMA_USR_OS', 'Mac');
156 } elseif (strstr($HTTP_USER_AGENT, 'Linux')) {
157 $this->set('PMA_USR_OS', 'Linux');
158 } elseif (strstr($HTTP_USER_AGENT, 'Unix')) {
159 $this->set('PMA_USR_OS', 'Unix');
160 } elseif (strstr($HTTP_USER_AGENT, 'OS/2')) {
161 $this->set('PMA_USR_OS', 'OS/2');
163 $this->set('PMA_USR_OS', 'Other');
166 // 2. browser and version
167 // (must check everything else before Mozilla)
169 if (preg_match('@Opera(/| )([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
170 $this->set('PMA_USR_BROWSER_VER', $log_version[2]);
171 $this->set('PMA_USR_BROWSER_AGENT', 'OPERA');
172 } elseif (preg_match('@MSIE ([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
173 $this->set('PMA_USR_BROWSER_VER', $log_version[1]);
174 $this->set('PMA_USR_BROWSER_AGENT', 'IE');
175 } elseif (preg_match('@OmniWeb/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
176 $this->set('PMA_USR_BROWSER_VER', $log_version[1]);
177 $this->set('PMA_USR_BROWSER_AGENT', 'OMNIWEB');
178 // Konqueror 2.2.2 says Konqueror/2.2.2
179 // Konqueror 3.0.3 says Konqueror/3
180 } elseif (preg_match('@(Konqueror/)(.*)(;)@', $HTTP_USER_AGENT, $log_version)) {
181 $this->set('PMA_USR_BROWSER_VER', $log_version[2]);
182 $this->set('PMA_USR_BROWSER_AGENT', 'KONQUEROR');
183 } elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)
184 && preg_match('@Safari/([0-9]*)@', $HTTP_USER_AGENT, $log_version2)) {
185 $this->set('PMA_USR_BROWSER_VER', $log_version[1] . '.' . $log_version2[1]);
186 $this->set('PMA_USR_BROWSER_AGENT', 'SAFARI');
187 } elseif (preg_match('@rv:1.9(.*)Gecko@', $HTTP_USER_AGENT)) {
188 $this->set('PMA_USR_BROWSER_VER', '1.9');
189 $this->set('PMA_USR_BROWSER_AGENT', 'GECKO');
190 } elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
191 $this->set('PMA_USR_BROWSER_VER', $log_version[1]);
192 $this->set('PMA_USR_BROWSER_AGENT', 'MOZILLA');
194 $this->set('PMA_USR_BROWSER_VER', 0);
195 $this->set('PMA_USR_BROWSER_AGENT', 'OTHER');
200 * Whether GD2 is present
204 if ($this->get('GD2Available') == 'yes') {
205 $this->set('PMA_IS_GD2', 1);
206 } elseif ($this->get('GD2Available') == 'no') {
207 $this->set('PMA_IS_GD2', 0);
209 if (!@function_exists
('imagecreatetruecolor')) {
210 $this->set('PMA_IS_GD2', 0);
212 if (@function_exists
('gd_info')) {
214 if (strstr($gd_nfo["GD Version"], '2.')) {
215 $this->set('PMA_IS_GD2', 1);
217 $this->set('PMA_IS_GD2', 0);
220 /* We must do hard way... but almost no chance to execute this */
222 phpinfo(INFO_MODULES
); /* Only modules */
223 $a = strip_tags(ob_get_contents());
225 /* Get GD version string from phpinfo output */
226 if (preg_match('@GD Version[[:space:]]*\(.*\)@', $a, $v)) {
227 if (strstr($v, '2.')) {
228 $this->set('PMA_IS_GD2', 1);
230 $this->set('PMA_IS_GD2', 0);
233 $this->set('PMA_IS_GD2', 0);
241 * Whether the Web server php is running on is IIS
243 function checkWebServer()
245 if (PMA_getenv('SERVER_SOFTWARE')
246 // some versions return Microsoft-IIS, some Microsoft/IIS
247 // we could use a preg_match() but it's slower
248 && stristr(PMA_getenv('SERVER_SOFTWARE'), 'Microsoft')
249 && stristr(PMA_getenv('SERVER_SOFTWARE'), 'IIS')) {
250 $this->set('PMA_IS_IIS', 1);
252 $this->set('PMA_IS_IIS', 0);
257 * Whether the os php is running on is windows or not
259 function checkWebServerOs()
261 // Default to Unix or Equiv
262 $this->set('PMA_IS_WINDOWS', 0);
263 // If PHP_OS is defined then continue
264 if (defined('PHP_OS')) {
265 if (stristr(PHP_OS
, 'win')) {
266 // Is it some version of Windows
267 $this->set('PMA_IS_WINDOWS', 1);
268 } elseif (stristr(PHP_OS
, 'OS/2')) {
269 // Is it OS/2 (No file permissions like Windows)
270 $this->set('PMA_IS_WINDOWS', 1);
276 * detects PHP version
278 function checkPhpVersion()
281 if (! preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@',
282 phpversion(), $match)) {
283 $result = preg_match('@([0-9]{1,2}).([0-9]{1,2})@',
284 phpversion(), $match);
286 if (isset($match) && ! empty($match[1])) {
287 if (! isset($match[2])) {
290 if (! isset($match[3])) {
293 $this->set('PMA_PHP_INT_VERSION',
294 (int) sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));
296 $this->set('PMA_PHP_INT_VERSION', 0);
298 $this->set('PMA_PHP_STR_VERSION', phpversion());
302 * re-init object after loading from session file
303 * checks config file for changes and relaods if neccessary
307 if (SKIP_MTIME_CONFIG_CHECK
308 ||
! $this->checkConfigSource()
309 ||
$this->source_mtime
!== filemtime($this->getSource())
310 ||
$this->default_source_mtime
!== filemtime($this->default_source
)
311 ||
$this->error_config_file
312 ||
$this->error_config_default_file
) {
313 $this->settings
= array();
315 $this->checkSystem();
318 // check for https needs to be done everytime,
319 // as https and http uses same session so this info can not be stored
321 $this->checkIsHttps();
323 $this->checkCollationConnection();
324 $this->checkFontsize();
328 * loads default values from default source
330 * @uses file_exists()
331 * @uses $this->default_source
332 * @uses $this->error_config_default_file
333 * @uses $this->settings
334 * @return boolean success
336 function loadDefaults()
339 if (! file_exists($this->default_source
)) {
340 $this->error_config_default_file
= true;
343 include $this->default_source
;
345 $this->default_source_mtime
= filemtime($this->default_source
);
347 $this->default_server
= $cfg['Servers'][1];
348 unset($cfg['Servers']);
350 $this->settings
= PMA_array_merge_recursive($this->settings
, $cfg);
352 $this->error_config_default_file
= false;
358 * loads configuration from $source, usally the config file
359 * should be called on object creation and from __wakeup if config file
362 * @param string $source config file
364 function load($source = null)
366 $this->loadDefaults();
368 if (null !== $source) {
369 $this->setSource($source);
372 if (! $this->checkConfigSource()) {
379 * Parses the configuration file
381 $old_error_reporting = error_reporting(0);
382 if (function_exists('file_get_contents')) {
384 eval('?>' . trim(file_get_contents($this->getSource())));
387 eval('?>' . trim(implode("\n", file($this->getSource()))));
389 error_reporting($old_error_reporting);
391 if ($eval_result === false) {
392 $this->error_config_file
= true;
394 $this->error_config_file
= false;
395 $this->source_mtime
= filemtime($this->getSource());
399 * Backward compatibility code
401 if (!empty($cfg['DefaultTabTable'])) {
402 $cfg['DefaultTabTable'] = str_replace('_properties', '', str_replace('tbl_properties.php', 'tbl_sql.php', $cfg['DefaultTabTable']));
404 if (!empty($cfg['DefaultTabDatabase'])) {
405 $cfg['DefaultTabDatabase'] = str_replace('_details', '', str_replace('db_details.php', 'db_sql.php', $cfg['DefaultTabDatabase']));
408 $this->checkFontsize();
409 //$this->checkPmaAbsoluteUri();
410 $this->settings
= PMA_array_merge_recursive($this->settings
, $cfg);
412 $this->checkPermissions();
414 // Handling of the collation must be done after merging of $cfg
415 // (from config.inc.php) so that $cfg['DefaultConnectionCollation']
416 // can have an effect. Note that the presence of collation
417 // information in a cookie has priority over what is defined
418 // in the default or user's config files.
420 * @todo check validity of $_COOKIE['pma_collation_connection']
422 if (! empty($_COOKIE['pma_collation_connection'])) {
423 $this->set('collation_connection',
424 strip_tags($_COOKIE['pma_collation_connection']));
426 $this->set('collation_connection',
427 $this->get('DefaultConnectionCollation'));
429 // Now, a collation information could come from REQUEST
430 // (an example of this: the collation selector in main.php)
431 // so the following handles the setting of collation_connection
432 // and later, in common.inc.php, the cookie will be set
433 // according to this.
434 $this->checkCollationConnection();
441 * @param string $source
443 function setSource($source)
445 $this->source
= trim($source);
449 * checks if the config folder still exists and terminates app if true
451 function checkConfigFolder()
453 // Refuse to work while there still might be some world writable dir:
454 if (is_dir('./config')) {
455 die('Remove "./config" directory before using phpMyAdmin!');
460 * check config source
462 * @return boolean whether source is valid or not
464 function checkConfigSource()
466 if (! $this->getSource()) {
467 // no configuration file set at all
471 if (! file_exists($this->getSource())) {
472 // do not trigger error here
473 // https://sf.net/tracker/?func=detail&aid=1370269&group_id=23067&atid=377408
476 'phpMyAdmin-ERROR: unkown configuration source: ' . $source,
479 $this->source_mtime
= 0;
483 if (! is_readable($this->getSource())) {
484 $this->source_mtime
= 0;
485 die('Existing configuration file (' . $this->getSource() . ') is not readable.');
492 * verifies the permissions on config file (if asked by configuration)
493 * (must be called after config.inc.php has been merged)
495 function checkPermissions()
497 // Check for permissions (on platforms that support it):
498 if ($this->get('CheckConfigurationPermissions')) {
499 $perms = @fileperms
($this->getSource());
500 if (!($perms === false) && ($perms & 2)) {
501 // This check is normally done after loading configuration
502 $this->checkWebServerOs();
503 if ($this->get('PMA_IS_WINDOWS') == 0) {
504 $this->source_mtime
= 0;
505 die('Wrong permissions on configuration file, should not be world writable!');
512 * returns specific config setting
513 * @param string $setting
514 * @return mixed value
516 function get($setting)
518 if (isset($this->settings
[$setting])) {
519 return $this->settings
[$setting];
525 * sets configuration variable
527 * @uses $this->settings
528 * @param string $setting configuration option
529 * @param string $value new value for configuration option
531 function set($setting, $value)
533 if (!isset($this->settings
[$setting]) ||
$this->settings
[$setting] != $value) {
534 $this->settings
[$setting] = $value;
535 $this->set_mtime
= time();
540 * returns source for current config
541 * @return string config source
545 return $this->source
;
549 * returns a unique value to force a CSS reload if either the config
550 * or the theme changes
551 * must also check the pma_fontsize cookie in case there is no
553 * @return int Unix timestamp
555 function getThemeUniqueValue()
557 return intval((null !== $_SESSION['PMA_Config']->get('fontsize') ?
$_SESSION['PMA_Config']->get('fontsize') : (isset($_COOKIE['pma_fontsize']) ?
$_COOKIE['pma_fontsize'] : 0))) +
($this->source_mtime +
$this->default_source_mtime +
$_SESSION['PMA_Theme']->mtime_info +
$_SESSION['PMA_Theme']->filesize_info
) . (isset($_SESSION['tmp_user_values']['custom_color']) ?
substr($_SESSION['tmp_user_values']['custom_color'],1,6) : '');
561 * $cfg['PmaAbsoluteUri'] is a required directive else cookies won't be
562 * set properly and, depending on browsers, inserting or updating a
565 function checkPmaAbsoluteUri()
567 // Setup a default value to let the people and lazy sysadmins work anyway,
568 // they'll get an error if the autodetect code doesn't work
569 $pma_absolute_uri = $this->get('PmaAbsoluteUri');
570 $is_https = $this->get('is_https');
572 if (strlen($pma_absolute_uri) < 5
573 // needed to catch http/https switch
574 ||
($is_https && substr($pma_absolute_uri, 0, 6) != 'https:')
575 ||
(!$is_https && substr($pma_absolute_uri, 0, 5) != 'http:')
579 // At first we try to parse REQUEST_URI, it might contain full URL
581 * REQUEST_URI contains PATH_INFO too, this is not what we want
582 * script-php/pathinfo/
583 if (PMA_getenv('REQUEST_URI')) {
584 $url = @parse_url(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
585 if ($url === false) {
586 $url = array('path' => $_SERVER['REQUEST_URI']);
591 // If we don't have scheme, we didn't have full URL so we need to
593 if (empty($url['scheme'])) {
595 if (PMA_getenv('HTTP_SCHEME')) {
596 $url['scheme'] = PMA_getenv('HTTP_SCHEME');
599 PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
605 if (PMA_getenv('HTTP_HOST')) {
606 // Prepend the scheme before using parse_url() since this is not part of the RFC2616 Host request-header
607 $parsed_url = parse_url($url['scheme'] . '://' . PMA_getenv('HTTP_HOST'));
608 if (!empty($parsed_url['host'])) {
611 $url['host'] = PMA_getenv('HTTP_HOST');
613 } elseif (PMA_getenv('SERVER_NAME')) {
614 $url['host'] = PMA_getenv('SERVER_NAME');
616 $this->error_pma_uri
= true;
620 // If we didn't set port yet...
621 if (empty($url['port']) && PMA_getenv('SERVER_PORT')) {
622 $url['port'] = PMA_getenv('SERVER_PORT');
625 // And finally the path could be already set from REQUEST_URI
626 if (empty($url['path'])) {
628 * REQUEST_URI contains PATH_INFO too, this is not what we want
629 * script-php/pathinfo/
630 if (PMA_getenv('PATH_INFO')) {
631 $path = parse_url(PMA_getenv('PATH_INFO'));
633 // PHP_SELF in CGI often points to cgi executable, so use it
636 $path = parse_url($GLOBALS['PMA_PHP_SELF']);
638 $url['path'] = $path['path'];
642 // Make url from parts we have
643 $pma_absolute_uri = $url['scheme'] . '://';
644 // Was there user information?
645 if (!empty($url['user'])) {
646 $pma_absolute_uri .= $url['user'];
647 if (!empty($url['pass'])) {
648 $pma_absolute_uri .= ':' . $url['pass'];
650 $pma_absolute_uri .= '@';
653 $pma_absolute_uri .= $url['host'];
654 // Add port, if it not the default one
655 if (! empty($url['port'])
656 && (($url['scheme'] == 'http' && $url['port'] != 80)
657 ||
($url['scheme'] == 'https' && $url['port'] != 443))) {
658 $pma_absolute_uri .= ':' . $url['port'];
660 // And finally path, without script name, the 'a' is there not to
661 // strip our directory, when path is only /pmadir/ without filename.
662 // Backslashes returned by Windows have to be changed.
663 // Only replace backslashes by forward slashes if on Windows,
664 // as the backslash could be valid on a non-Windows system.
665 $this->checkWebServerOs();
666 if ($this->get('PMA_IS_WINDOWS') == 1) {
667 $path = str_replace("\\", "/", dirname($url['path'] . 'a'));
669 $path = dirname($url['path'] . 'a');
672 // To work correctly within transformations overview:
673 if (defined('PMA_PATH_TO_BASEDIR') && PMA_PATH_TO_BASEDIR
== '../../') {
674 if ($this->get('PMA_IS_WINDOWS') == 1) {
675 $path = str_replace("\\", "/", dirname(dirname($path)));
677 $path = dirname(dirname($path));
681 // PHP's dirname function would have returned a dot when $path contains no slash
685 // in vhost situations, there could be already an ending slash
686 if (substr($path, -1) != '/') {
689 $pma_absolute_uri .= $path;
691 // We used to display a warning if PmaAbsoluteUri wasn't set, but now
692 // the autodetect code works well enough that we don't display the
693 // warning at all. The user can still set PmaAbsoluteUri manually.
695 // http://sf.net/tracker/?func=detail&aid=1257134&group_id=23067&atid=377411
698 // The URI is specified, however users do often specify this
699 // wrongly, so we try to fix this.
701 // Adds a trailing slash et the end of the phpMyAdmin uri if it
703 if (substr($pma_absolute_uri, -1) != '/') {
704 $pma_absolute_uri .= '/';
707 // If URI doesn't start with http:// or https://, we will add
709 if (substr($pma_absolute_uri, 0, 7) != 'http://'
710 && substr($pma_absolute_uri, 0, 8) != 'https://') {
712 (PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
715 . ':' . (substr($pma_absolute_uri, 0, 2) == '//' ?
'' : '//')
719 $this->set('PmaAbsoluteUri', $pma_absolute_uri);
723 * check selected collation_connection
724 * @todo check validity of $_REQUEST['collation_connection']
726 function checkCollationConnection()
728 if (! empty($_REQUEST['collation_connection'])) {
729 $this->set('collation_connection',
730 strip_tags($_REQUEST['collation_connection']));
735 * checks for font size configuration, and sets font size as requested by user
741 * @uses function_exists()
742 * @uses PMA_Config::set()
743 * @uses PMA_Config::get()
744 * @uses PMA_setCookie()
746 function checkFontsize()
750 if (isset($_GET['fontsize'])) {
751 $new_fontsize = $_GET['fontsize'];
752 } elseif (isset($_POST['fontsize'])) {
753 $new_fontsize = $_POST['fontsize'];
754 } elseif (isset($_COOKIE['pma_fontsize'])) {
755 $new_fontsize = $_COOKIE['pma_fontsize'];
758 if (preg_match('/^[0-9.]+(px|em|pt|\%)$/', $new_fontsize)) {
759 $this->set('fontsize', $new_fontsize);
760 } elseif (! $this->get('fontsize')) {
761 // 80% would correspond to the default browser font size
762 // of 16, but use 82% to help read the monoface font
763 $this->set('fontsize', '82%');
766 if (function_exists('PMA_setCookie')) {
767 PMA_setCookie('pma_fontsize', $this->get('fontsize'), '82%');
772 * checks if upload is enabled
776 function checkUpload()
778 if (ini_get('file_uploads')) {
779 $this->set('enable_upload', true);
780 // if set "php_admin_value file_uploads Off" in httpd.conf
781 // ini_get() also returns the string "Off" in this case:
782 if ('off' == strtolower(ini_get('file_uploads'))) {
783 $this->set('enable_upload', false);
786 $this->set('enable_upload', false);
791 * Maximum upload size as limited by PHP
792 * Used with permission from Moodle (http://moodle.org) by Martin Dougiamas
794 * this section generates $max_upload_size in bytes
796 function checkUploadSize()
798 if (! $filesize = ini_get('upload_max_filesize')) {
802 if ($postsize = ini_get('post_max_size')) {
803 $this->set('max_upload_size',
804 min(PMA_get_real_size($filesize), PMA_get_real_size($postsize)));
806 $this->set('max_upload_size', PMA_get_real_size($filesize));
813 function checkIsHttps()
815 $this->set('is_https', PMA_Config
::isHttps());
821 static public function isHttps()
827 // At first we try to parse REQUEST_URI, it might contain full URL,
828 if (PMA_getenv('REQUEST_URI')) {
829 $url = @parse_url
(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
835 // If we don't have scheme, we didn't have full URL so we need to
837 if (empty($url['scheme'])) {
839 if (PMA_getenv('HTTP_SCHEME')) {
840 $url['scheme'] = PMA_getenv('HTTP_SCHEME');
843 PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
849 if (isset($url['scheme'])
850 && $url['scheme'] == 'https') {
860 * detect correct cookie path
862 function checkCookiePath()
864 $this->set('cookie_path', PMA_Config
::getCookiePath());
870 static public function getCookiePath()
872 static $cookie_path = null;
874 if (null !== $cookie_path) {
881 * REQUEST_URI contains PATH_INFO too, this is not what we want
882 * script-php/pathinfo/
883 if (PMA_getenv('REQUEST_URI')) {
884 $url = PMA_getenv('REQUEST_URI');
888 // If we don't have path
890 if ($GLOBALS['PMA_PHP_SELF']) {
891 // PHP_SELF in CGI often points to cgi executable, so use it
893 $url = $GLOBALS['PMA_PHP_SELF'];
894 // on IIS with PHP-CGI:
895 } elseif (PMA_getenv('SCRIPT_NAME')) {
896 $url = PMA_getenv('SCRIPT_NAME');
901 * REQUEST_URI contains PATH_INFO too, this is not what we want
902 * script-php/pathinfo/
903 $parsed_url = @parse_url($_SERVER['REQUEST_URI']); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
904 if ($parsed_url === false) {
906 $parsed_url = array('path' => $url);
909 $cookie_path = substr($parsed_url['path'], 0, strrpos($parsed_url['path'], '/')) . '/';
915 * enables backward compatibility
919 $GLOBALS['cfg'] = $this->settings
;
920 $GLOBALS['default_server'] = $this->default_server
;
921 unset($this->default_server
);
922 $GLOBALS['collation_connection'] = $this->get('collation_connection');
923 $GLOBALS['is_upload'] = $this->get('enable_upload');
924 $GLOBALS['max_upload_size'] = $this->get('max_upload_size');
925 $GLOBALS['cookie_path'] = $this->get('cookie_path');
926 $GLOBALS['is_https'] = $this->get('is_https');
931 'PMA_THEME_GENERATION',
932 'PMA_PHP_STR_VERSION',
933 'PMA_PHP_INT_VERSION',
938 'PMA_USR_BROWSER_VER',
939 'PMA_USR_BROWSER_AGENT'
942 foreach ($defines as $define) {
943 if (! defined($define)) {
944 define($define, $this->get($define));
955 * returns options for font size selection
957 * @uses preg_replace()
960 * @param string $current_size current selected font size with unit
961 * @return array selectable font sizes
963 static protected function _getFontsizeOptions($current_size = '82%')
965 $unit = preg_replace('/[0-9.]*/', '', $current_size);
966 $value = preg_replace('/[^0-9.]*/', '', $current_size);
970 $options["$value"] = $value . $unit;
976 } elseif ($unit === 'em') {
980 } elseif ($unit === 'pt') {
983 } elseif ($unit === 'px') {
988 //unknown font size unit
996 foreach ($factors as $key => $factor) {
997 $option_inc = $value +
$factor;
998 $option_dec = $value - $factor;
999 while (count($options) < 21) {
1000 $options["$option_inc"] = $option_inc . $unit;
1001 if ($option_dec > $factors[0]) {
1002 $options["$option_dec"] = $option_dec . $unit;
1004 $option_inc +
= $factor;
1005 $option_dec -= $factor;
1006 if (isset($factors[$key +
1])
1007 && $option_inc >= $value +
$factors[$key +
1]) {
1017 * returns html selectbox for font sizes
1019 * @uses $_SESSION['PMA_Config']
1020 * @uses PMA_Config::get()
1021 * @uses PMA_Config::_getFontsizeOptions()
1022 * @uses $GLOBALS['strFontSize']
1024 * @param string $current_size currently slected font size with unit
1025 * @return string html selectbox
1027 static protected function _getFontsizeSelection()
1029 $current_size = $_SESSION['PMA_Config']->get('fontsize');
1030 // for the case when there is no config file (this is supported)
1031 if (empty($current_size)) {
1032 if (isset($_COOKIE['pma_fontsize'])) {
1033 $current_size = $_COOKIE['pma_fontsize'];
1035 $current_size = '82%';
1038 $options = PMA_Config
::_getFontsizeOptions($current_size);
1040 $return = '<label for="select_fontsize">' . $GLOBALS['strFontSize'] . ':</label>' . "\n";
1041 $return .= '<select name="fontsize" id="select_fontsize" onchange="this.form.submit();">' . "\n";
1042 foreach ($options as $option) {
1043 $return .= '<option value="' . $option . '"';
1044 if ($option == $current_size) {
1045 $return .= ' selected="selected"';
1047 $return .= '>' . $option . '</option>' . "\n";
1049 $return .= '</select>';
1055 * return complete font size selection form
1057 * @uses PMA_generate_common_hidden_inputs()
1058 * @uses PMA_Config::_getFontsizeSelection()
1059 * @uses $GLOBALS['strGo']
1061 * @param string $current_size currently slected font size with unit
1062 * @return string html selectbox
1064 static public function getFontsizeForm()
1066 return '<form name="form_fontsize_selection" id="form_fontsize_selection"'
1067 . ' method="post" action="index.php" target="_parent">' . "\n"
1068 . PMA_generate_common_hidden_inputs() . "\n"
1069 . PMA_Config
::_getFontsizeSelection() . "\n"
1070 . '<noscript>' . "\n"
1071 . '<input type="submit" value="' . $GLOBALS['strGo'] . '" />' . "\n"
1072 . '</noscript>' . "\n"