2 /* vim: set expandtab sw=4 ts=4 sts=4: */
16 * @var string default config source
18 var $default_source = './libraries/config.default.php';
21 * @var array configuration settings
23 var $settings = array();
26 * @var string config source
31 * @var int source modification time
33 var $source_mtime = 0;
34 var $default_source_mtime = 0;
40 var $error_config_file = false;
45 var $error_config_default_file = false;
50 var $error_pma_uri = false;
55 var $default_server = array();
58 * @var boolean wether init is done or mot
59 * set this to false to force some initial checks
60 * like checking for required functions
67 * @param string source to read config from
69 function __construct($source = null)
71 $this->settings
= array();
73 // functions need to refresh in case of config file changed goes in
77 // other settings, independant from config file, comes in
80 $this->checkIsHttps();
84 * sets system and application settings
86 function checkSystem()
88 $this->set('PMA_VERSION', '2.11.7');
92 $this->set('PMA_THEME_VERSION', 2);
96 $this->set('PMA_THEME_GENERATION', 2);
98 $this->checkPhpVersion();
99 $this->checkWebServerOs();
100 $this->checkWebServer();
102 $this->checkClient();
103 $this->checkUpload();
104 $this->checkUploadSize();
105 $this->checkOutputCompression();
109 * wether to use gzip output compression or not
111 function checkOutputCompression()
113 // If zlib output compression is set in the php configuration file, no
114 // output buffering should be run
115 if (@ini_get
('zlib.output_compression')) {
116 $this->set('OBGzip', false);
119 // disable output-buffering (if set to 'auto') for IE6, else enable it.
120 if (strtolower($this->get('OBGzip')) == 'auto') {
121 if ($this->get('PMA_USR_BROWSER_AGENT') == 'IE'
122 && $this->get('PMA_USR_BROWSER_VER') >= 6
123 && $this->get('PMA_USR_BROWSER_VER') < 7) {
124 $this->set('OBGzip', false);
126 $this->set('OBGzip', true);
132 * Determines platform (OS), browser and version of the user
133 * Based on a phpBuilder article:
134 * @see http://www.phpbuilder.net/columns/tim20000821.php
136 function checkClient()
138 if (PMA_getenv('HTTP_USER_AGENT')) {
139 $HTTP_USER_AGENT = PMA_getenv('HTTP_USER_AGENT');
140 } elseif (!isset($HTTP_USER_AGENT)) {
141 $HTTP_USER_AGENT = '';
145 if (strstr($HTTP_USER_AGENT, 'Win')) {
146 $this->set('PMA_USR_OS', 'Win');
147 } elseif (strstr($HTTP_USER_AGENT, 'Mac')) {
148 $this->set('PMA_USR_OS', 'Mac');
149 } elseif (strstr($HTTP_USER_AGENT, 'Linux')) {
150 $this->set('PMA_USR_OS', 'Linux');
151 } elseif (strstr($HTTP_USER_AGENT, 'Unix')) {
152 $this->set('PMA_USR_OS', 'Unix');
153 } elseif (strstr($HTTP_USER_AGENT, 'OS/2')) {
154 $this->set('PMA_USR_OS', 'OS/2');
156 $this->set('PMA_USR_OS', 'Other');
159 // 2. browser and version
160 // (must check everything else before Mozilla)
162 if (preg_match('@Opera(/| )([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
163 $this->set('PMA_USR_BROWSER_VER', $log_version[2]);
164 $this->set('PMA_USR_BROWSER_AGENT', 'OPERA');
165 } elseif (preg_match('@MSIE ([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
166 $this->set('PMA_USR_BROWSER_VER', $log_version[1]);
167 $this->set('PMA_USR_BROWSER_AGENT', 'IE');
168 } elseif (preg_match('@OmniWeb/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
169 $this->set('PMA_USR_BROWSER_VER', $log_version[1]);
170 $this->set('PMA_USR_BROWSER_AGENT', 'OMNIWEB');
171 //} elseif (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
172 // Konqueror 2.2.2 says Konqueror/2.2.2
173 // Konqueror 3.0.3 says Konqueror/3
174 } elseif (preg_match('@(Konqueror/)(.*)(;)@', $HTTP_USER_AGENT, $log_version)) {
175 $this->set('PMA_USR_BROWSER_VER', $log_version[2]);
176 $this->set('PMA_USR_BROWSER_AGENT', 'KONQUEROR');
177 } elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)
178 && preg_match('@Safari/([0-9]*)@', $HTTP_USER_AGENT, $log_version2)) {
179 $this->set('PMA_USR_BROWSER_VER', $log_version[1] . '.' . $log_version2[1]);
180 $this->set('PMA_USR_BROWSER_AGENT', 'SAFARI');
181 } elseif (preg_match('@rv:1.9(.*)Gecko@', $HTTP_USER_AGENT)) {
182 $this->set('PMA_USR_BROWSER_VER', '1.9');
183 $this->set('PMA_USR_BROWSER_AGENT', 'GECKO');
184 } elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
185 $this->set('PMA_USR_BROWSER_VER', $log_version[1]);
186 $this->set('PMA_USR_BROWSER_AGENT', 'MOZILLA');
188 $this->set('PMA_USR_BROWSER_VER', 0);
189 $this->set('PMA_USR_BROWSER_AGENT', 'OTHER');
194 * Whether GD2 is present
198 if ($this->get('GD2Available') == 'yes') {
199 $this->set('PMA_IS_GD2', 1);
200 } elseif ($this->get('GD2Available') == 'no') {
201 $this->set('PMA_IS_GD2', 0);
203 if (!@extension_loaded
('gd')) {
206 if (!@function_exists
('imagecreatetruecolor')) {
207 $this->set('PMA_IS_GD2', 0);
209 if (@function_exists
('gd_info')) {
211 if (strstr($gd_nfo["GD Version"], '2.')) {
212 $this->set('PMA_IS_GD2', 1);
214 $this->set('PMA_IS_GD2', 0);
217 /* We must do hard way... */
219 phpinfo(INFO_MODULES
); /* Only modules */
220 $a = strip_tags(ob_get_contents());
222 /* Get GD version string from phpinfo output */
223 if (preg_match('@GD Version[[:space:]]*\(.*\)@', $a, $v)) {
224 if (strstr($v, '2.')) {
225 $this->set('PMA_IS_GD2', 1);
227 $this->set('PMA_IS_GD2', 0);
230 $this->set('PMA_IS_GD2', 0);
238 * Whether the Web server php is running on is IIS
240 function checkWebServer()
242 if (PMA_getenv('SERVER_SOFTWARE')
243 // some versions return Microsoft-IIS, some Microsoft/IIS
244 // we could use a preg_match() but it's slower
245 && stristr(PMA_getenv('SERVER_SOFTWARE'), 'Microsoft')
246 && stristr(PMA_getenv('SERVER_SOFTWARE'), 'IIS')) {
247 $this->set('PMA_IS_IIS', 1);
249 $this->set('PMA_IS_IIS', 0);
254 * Whether the os php is running on is windows or not
256 function checkWebServerOs()
258 // Default to Unix or Equiv
259 $this->set('PMA_IS_WINDOWS', 0);
260 // If PHP_OS is defined then continue
261 if (defined('PHP_OS')) {
262 if (stristr(PHP_OS
, 'win')) {
263 // Is it some version of Windows
264 $this->set('PMA_IS_WINDOWS', 1);
265 } elseif (stristr(PHP_OS
, 'OS/2')) {
266 // Is it OS/2 (No file permissions like Windows)
267 $this->set('PMA_IS_WINDOWS', 1);
273 * detects PHP version
275 function checkPhpVersion()
278 if (! preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@',
279 phpversion(), $match)) {
280 $result = preg_match('@([0-9]{1,2}).([0-9]{1,2})@',
281 phpversion(), $match);
283 if (isset($match) && ! empty($match[1])) {
284 if (! isset($match[2])) {
287 if (! isset($match[3])) {
290 $this->set('PMA_PHP_INT_VERSION',
291 (int) sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));
293 $this->set('PMA_PHP_INT_VERSION', 0);
295 $this->set('PMA_PHP_STR_VERSION', phpversion());
299 * re-init object after loading from session file
300 * checks config file for changes and relaods if neccessary
304 if (! $this->checkConfigSource()
305 ||
$this->source_mtime
!== filemtime($this->getSource())
306 ||
$this->default_source_mtime
!== filemtime($this->default_source
)
307 ||
$this->error_config_file
308 ||
$this->error_config_default_file
) {
309 $this->settings
= array();
311 $this->checkSystem();
314 // check for https needs to be done everytime,
315 // as https and http uses same session so this info can not be stored
317 $this->checkIsHttps();
319 $this->checkCollationConnection();
320 $this->checkFontsize();
324 * loads default values from default source
326 * @uses file_exists()
327 * @uses $this->default_source
328 * @uses $this->error_config_default_file
329 * @uses $this->settings
330 * @return boolean success
332 function loadDefaults()
335 if (! file_exists($this->default_source
)) {
336 $this->error_config_default_file
= true;
339 include $this->default_source
;
341 $this->default_source_mtime
= filemtime($this->default_source
);
343 $this->default_server
= $cfg['Servers'][1];
344 unset($cfg['Servers']);
346 $this->settings
= PMA_array_merge_recursive($this->settings
, $cfg);
348 $this->error_config_default_file
= false;
354 * loads configuration from $source, usally the config file
355 * should be called on object creation and from __wakeup if config file
358 * @param string $source config file
360 function load($source = null)
362 $this->loadDefaults();
364 if (null !== $source) {
365 $this->setSource($source);
368 if (! $this->checkConfigSource()) {
375 * Parses the configuration file
377 $old_error_reporting = error_reporting(0);
378 // avoid "headers already sent" error when file contains a BOM
380 if (function_exists('file_get_contents')) {
382 eval('?>' . trim(file_get_contents($this->getSource())));
385 eval('?>' . trim(implode("\n", file($this->getSource()))));
388 error_reporting($old_error_reporting);
390 if ($eval_result === false) {
391 $this->error_config_file
= true;
393 $this->error_config_file
= false;
394 $this->source_mtime
= filemtime($this->getSource());
398 * Backward compatibility code
400 if (!empty($cfg['DefaultTabTable'])) {
401 $cfg['DefaultTabTable'] = str_replace('_properties', '', str_replace('tbl_properties.php', 'tbl_sql.php', $cfg['DefaultTabTable']));
403 if (!empty($cfg['DefaultTabDatabase'])) {
404 $cfg['DefaultTabDatabase'] = str_replace('_details', '', str_replace('db_details.php', 'db_sql.php', $cfg['DefaultTabDatabase']));
407 $this->checkFontsize();
408 //$this->checkPmaAbsoluteUri();
409 $this->settings
= PMA_array_merge_recursive($this->settings
, $cfg);
411 // Handling of the collation must be done after merging of $cfg
412 // (from config.inc.php) so that $cfg['DefaultConnectionCollation']
413 // can have an effect. Note that the presence of collation
414 // information in a cookie has priority over what is defined
415 // in the default or user's config files.
417 * @todo check validity of $_COOKIE['pma_collation_connection']
419 if (! empty($_COOKIE['pma_collation_connection'])) {
420 $this->set('collation_connection',
421 strip_tags($_COOKIE['pma_collation_connection']));
423 $this->set('collation_connection',
424 $this->get('DefaultConnectionCollation'));
426 // Now, a collation information could come from REQUEST
427 // (an example of this: the collation selector in main.php)
428 // so the following handles the setting of collation_connection
429 // and later, in common.inc.php, the cookie will be set
430 // according to this.
431 $this->checkCollationConnection();
438 * @param string $source
440 function setSource($source)
442 $this->source
= trim($source);
446 * checks if the config folder still exists and terminates app if true
448 function checkConfigFolder()
450 // Refuse to work while there still might be some world writable dir:
451 if (is_dir('./config')) {
452 die('Remove "./config" directory before using phpMyAdmin!');
457 * check config source
459 * @return boolean wether source is valid or not
461 function checkConfigSource()
463 if (! $this->getSource()) {
464 // no configuration file set at all
468 if (! file_exists($this->getSource())) {
469 // do not trigger error here
470 // https://sf.net/tracker/?func=detail&aid=1370269&group_id=23067&atid=377408
473 'phpMyAdmin-ERROR: unkown configuration source: ' . $source,
476 $this->source_mtime
= 0;
480 if (! is_readable($this->getSource())) {
481 $this->source_mtime
= 0;
482 die('Existing configuration file (' . $this->getSource() . ') is not readable.');
485 // Check for permissions (on platforms that support it):
486 $perms = @fileperms
($this->getSource());
487 if (!($perms === false) && ($perms & 2)) {
488 // This check is normally done after loading configuration
489 $this->checkWebServerOs();
490 if ($this->get('PMA_IS_WINDOWS') == 0) {
491 $this->source_mtime
= 0;
492 die('Wrong permissions on configuration file, should not be world writable!');
500 * returns specific config setting
501 * @param string $setting
502 * @return mixed value
504 function get($setting)
506 if (isset($this->settings
[$setting])) {
507 return $this->settings
[$setting];
513 * sets configuration variable
515 * @uses $this->settings
516 * @param string $setting configuration option
517 * @param string $value new value for configuration option
519 function set($setting, $value)
521 if (!isset($this->settings
[$setting]) ||
$this->settings
[$setting] != $value) {
522 $this->settings
[$setting] = $value;
523 $this->set_mtime
= time();
528 * returns source for current config
529 * @return string config source
533 return $this->source
;
537 * old PHP 4 style constructor
541 function PMA_Config($source = null)
543 $this->__construct($source);
547 * returns a unique value to force a CSS reload if either the config
548 * or the theme changes
549 * @return int Unix timestamp
551 function getThemeUniqueValue()
553 return intval($_SESSION['PMA_Config']->get('fontsize')) +
($this->source_mtime +
$this->default_source_mtime +
$_SESSION['PMA_Theme']->mtime_info +
$_SESSION['PMA_Theme']->filesize_info
);
557 * $cfg['PmaAbsoluteUri'] is a required directive else cookies won't be
558 * set properly and, depending on browsers, inserting or updating a
561 function checkPmaAbsoluteUri()
563 // Setup a default value to let the people and lazy syadmins work anyway,
564 // they'll get an error if the autodetect code doesn't work
565 $pma_absolute_uri = $this->get('PmaAbsoluteUri');
566 $is_https = $this->get('is_https');
568 if (strlen($pma_absolute_uri) < 5
569 // needed to catch http/https switch
570 ||
($is_https && substr($pma_absolute_uri, 0, 6) != 'https:')
571 ||
(!$is_https && substr($pma_absolute_uri, 0, 5) != 'http:')
575 // At first we try to parse REQUEST_URI, it might contain full URL
576 if (PMA_getenv('REQUEST_URI')) {
577 $url = @parse_url
(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
578 if ($url === false) {
579 $url = array('path' => $_SERVER['REQUEST_URI']);
583 // If we don't have scheme, we didn't have full URL so we need to
585 if (empty($url['scheme'])) {
587 if (PMA_getenv('HTTP_SCHEME')) {
588 $url['scheme'] = PMA_getenv('HTTP_SCHEME');
591 PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
597 if (PMA_getenv('HTTP_HOST')) {
598 if (strpos(PMA_getenv('HTTP_HOST'), ':') !== false) {
599 list($url['host'], $url['port']) =
600 explode(':', PMA_getenv('HTTP_HOST'));
602 $url['host'] = PMA_getenv('HTTP_HOST');
604 } elseif (PMA_getenv('SERVER_NAME')) {
605 $url['host'] = PMA_getenv('SERVER_NAME');
607 $this->error_pma_uri
= true;
611 // If we didn't set port yet...
612 if (empty($url['port']) && PMA_getenv('SERVER_PORT')) {
613 $url['port'] = PMA_getenv('SERVER_PORT');
616 // And finally the path could be already set from REQUEST_URI
617 if (empty($url['path'])) {
618 if (PMA_getenv('PATH_INFO')) {
619 $path = parse_url(PMA_getenv('PATH_INFO'));
621 // PHP_SELF in CGI often points to cgi executable, so use it
623 $path = parse_url(PMA_getenv('PHP_SELF'));
625 $url['path'] = $path['path'];
629 // Make url from parts we have
630 $pma_absolute_uri = $url['scheme'] . '://';
631 // Was there user information?
632 if (!empty($url['user'])) {
633 $pma_absolute_uri .= $url['user'];
634 if (!empty($url['pass'])) {
635 $pma_absolute_uri .= ':' . $url['pass'];
637 $pma_absolute_uri .= '@';
640 $pma_absolute_uri .= $url['host'];
641 // Add port, if it not the default one
642 if (! empty($url['port'])
643 && (($url['scheme'] == 'http' && $url['port'] != 80)
644 ||
($url['scheme'] == 'https' && $url['port'] != 443))) {
645 $pma_absolute_uri .= ':' . $url['port'];
647 // And finally path, without script name, the 'a' is there not to
648 // strip our directory, when path is only /pmadir/ without filename.
649 // Backslashes returned by Windows have to be changed.
650 // Only replace backslashes by forward slashes if on Windows,
651 // as the backslash could be valid on a non-Windows system.
652 if ($this->get('PMA_IS_WINDOWS') == 1) {
653 $path = str_replace("\\", "/", dirname($url['path'] . 'a'));
655 $path = dirname($url['path'] . 'a');
658 // To work correctly within transformations overview:
659 if (defined('PMA_PATH_TO_BASEDIR') && PMA_PATH_TO_BASEDIR
== '../../') {
660 if ($this->get('PMA_IS_WINDOWS') == 1) {
661 $path = str_replace("\\", "/", dirname(dirname($path)));
663 $path = dirname(dirname($path));
666 // in vhost situations, there could be already an ending slash
667 if (substr($path, -1) != '/') {
670 $pma_absolute_uri .= $path;
672 // We used to display a warning if PmaAbsoluteUri wasn't set, but now
673 // the autodetect code works well enough that we don't display the
674 // warning at all. The user can still set PmaAbsoluteUri manually.
676 // http://sf.net/tracker/?func=detail&aid=1257134&group_id=23067&atid=377411
679 // The URI is specified, however users do often specify this
680 // wrongly, so we try to fix this.
682 // Adds a trailing slash et the end of the phpMyAdmin uri if it
684 if (substr($pma_absolute_uri, -1) != '/') {
685 $pma_absolute_uri .= '/';
688 // If URI doesn't start with http:// or https://, we will add
690 if (substr($pma_absolute_uri, 0, 7) != 'http://'
691 && substr($pma_absolute_uri, 0, 8) != 'https://') {
693 (PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
696 . ':' . (substr($pma_absolute_uri, 0, 2) == '//' ?
'' : '//')
700 $this->set('PmaAbsoluteUri', $pma_absolute_uri);
704 * check selected collation_connection
705 * @todo check validity of $_REQUEST['collation_connection']
707 function checkCollationConnection()
709 // (could be improved by executing it after the MySQL connection only if
710 // PMA_MYSQL_INT_VERSION >= 40100)
711 if (! empty($_REQUEST['collation_connection'])) {
712 $this->set('collation_connection',
713 strip_tags($_REQUEST['collation_connection']));
718 * checks for font size configuration, and sets font size as requested by user
724 * @uses function_exists()
725 * @uses PMA_Config::set()
726 * @uses PMA_Config::get()
727 * @uses PMA_setCookie()
729 function checkFontsize()
733 if (isset($_GET['fontsize'])) {
734 $new_fontsize = $_GET['fontsize'];
735 } elseif (isset($_POST['fontsize'])) {
736 $new_fontsize = $_POST['fontsize'];
737 } elseif (isset($_COOKIE['pma_fontsize'])) {
738 $new_fontsize = $_COOKIE['pma_fontsize'];
741 if (preg_match('/^[0-9.]+(px|em|pt|\%)$/', $new_fontsize)) {
742 $this->set('fontsize', $new_fontsize);
743 } elseif (! $this->get('fontsize')) {
744 // 80% would correspond to the default browser font size
745 // of 16, but use 82% to help read the monoface font
746 $this->set('fontsize', '82%');
749 if (function_exists('PMA_setCookie')) {
750 PMA_setCookie('pma_fontsize', $this->get('fontsize'), '82%');
755 * checks if upload is enabled
758 function checkUpload()
760 if (ini_get('file_uploads')) {
761 $this->set('enable_upload', true);
762 // if set "php_admin_value file_uploads Off" in httpd.conf
763 // ini_get() also returns the string "Off" in this case:
764 if ('off' == strtolower(ini_get('file_uploads'))) {
765 $this->set('enable_upload', false);
768 $this->set('enable_upload', false);
773 * Maximum upload size as limited by PHP
774 * Used with permission from Moodle (http://moodle.org) by Martin Dougiamas
776 * this section generates $max_upload_size in bytes
778 function checkUploadSize()
780 if (! $filesize = ini_get('upload_max_filesize')) {
784 if ($postsize = ini_get('post_max_size')) {
785 $this->set('max_upload_size',
786 min(PMA_get_real_size($filesize), PMA_get_real_size($postsize)));
788 $this->set('max_upload_size', PMA_get_real_size($filesize));
795 function checkIsHttps()
797 $this->set('is_https', PMA_Config
::isHttps());
809 // At first we try to parse REQUEST_URI, it might contain full URL,
810 if (PMA_getenv('REQUEST_URI')) {
811 $url = @parse_url
(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
817 // If we don't have scheme, we didn't have full URL so we need to
819 if (empty($url['scheme'])) {
821 if (PMA_getenv('HTTP_SCHEME')) {
822 $url['scheme'] = PMA_getenv('HTTP_SCHEME');
825 PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
831 if (isset($url['scheme'])
832 && $url['scheme'] == 'https') {
842 * detect correct cookie path
844 function checkCookiePath()
846 $this->set('cookie_path', PMA_Config
::getCookiePath());
852 function getCookiePath()
854 static $cookie_path = null;
856 if (null !== $cookie_path) {
862 if (PMA_getenv('REQUEST_URI')) {
863 $url = PMA_getenv('REQUEST_URI');
866 // If we don't have path
868 if (PMA_getenv('PATH_INFO')) {
869 $url = PMA_getenv('PATH_INFO');
870 // on IIS with PHP-CGI:
871 } elseif (PMA_getenv('SCRIPT_NAME')) {
872 $url = PMA_getenv('SCRIPT_NAME');
873 } elseif (PMA_getenv('PHP_SELF')) {
874 // PHP_SELF in CGI often points to cgi executable, so use it
876 $url = PMA_getenv('PHP_SELF');
880 $parsed_url = @parse_url
($_SERVER['REQUEST_URI']); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
881 if ($parsed_url === false ||
empty($parsed_url['path'])) {
882 $parsed_url = array('path' => $url);
885 $cookie_path = substr($parsed_url['path'], 0, strrpos($parsed_url['path'], '/')) . '/';
891 * enables backward compatibility
895 $GLOBALS['cfg'] = $this->settings
;
896 $GLOBALS['default_server'] = $this->default_server
;
897 unset($this->default_server
);
898 $GLOBALS['collation_connection'] = $this->get('collation_connection');
899 $GLOBALS['is_upload'] = $this->get('enable_upload');
900 $GLOBALS['max_upload_size'] = $this->get('max_upload_size');
901 $GLOBALS['cookie_path'] = $this->get('cookie_path');
902 $GLOBALS['is_https'] = $this->get('is_https');
907 'PMA_THEME_GENERATION',
908 'PMA_PHP_STR_VERSION',
909 'PMA_PHP_INT_VERSION',
914 'PMA_USR_BROWSER_VER',
915 'PMA_USR_BROWSER_AGENT'
918 foreach ($defines as $define) {
919 if (! defined($define)) {
920 define($define, $this->get($define));
931 * returns options for font size selection
933 * @uses preg_replace()
936 * @param string $current_size current selected font size with unit
937 * @return array selectable font sizes
939 function getFontsizeOptions($current_size = '82%')
941 $unit = preg_replace('/[0-9.]*/', '', $current_size);
942 $value = preg_replace('/[^0-9.]*/', '', $current_size);
946 $options["$value"] = $value . $unit;
952 } elseif ($unit === 'em') {
956 } elseif ($unit === 'pt') {
959 } elseif ($unit === 'px') {
964 //unknown font size unit
972 foreach ($factors as $key => $factor) {
973 $option_inc = $value +
$factor;
974 $option_dec = $value - $factor;
975 while (count($options) < 21) {
976 $options["$option_inc"] = $option_inc . $unit;
977 if ($option_dec > $factors[0]) {
978 $options["$option_dec"] = $option_dec . $unit;
980 $option_inc +
= $factor;
981 $option_dec -= $factor;
982 if (isset($factors[$key +
1])
983 && $option_inc >= $value +
$factors[$key +
1]) {
993 * returns html selectbox for font sizes
995 * @uses $_SESSION['PMA_Config']
996 * @uses PMA_Config::get()
997 * @uses PMA_Config::getFontsizeOptions()
998 * @uses $GLOBALS['strFontSize']
1000 * @param string $current_size currently slected font size with unit
1001 * @return string html selectbox
1003 function getFontsizeSelection()
1005 $current_size = $_SESSION['PMA_Config']->get('fontsize');
1006 $options = PMA_Config
::getFontsizeOptions($current_size);
1008 $return = '<label for="select_fontsize">' . $GLOBALS['strFontSize'] . ':</label>' . "\n";
1009 $return .= '<select name="fontsize" id="select_fontsize" onchange="this.form.submit();">' . "\n";
1010 foreach ($options as $option) {
1011 $return .= '<option value="' . $option . '"';
1012 if ($option == $current_size) {
1013 $return .= ' selected="selected"';
1015 $return .= '>' . $option . '</option>' . "\n";
1017 $return .= '</select>';
1023 * return complete font size selection form
1025 * @uses PMA_generate_common_hidden_inputs()
1026 * @uses PMA_Config::getFontsizeSelection()
1027 * @uses $GLOBALS['strGo']
1029 * @param string $current_size currently slected font size with unit
1030 * @return string html selectbox
1032 function getFontsizeForm()
1034 return '<form name="form_fontsize_selection" id="form_fontsize_selection"'
1035 . ' method="post" action="index.php" target="_parent">' . "\n"
1036 . PMA_generate_common_hidden_inputs() . "\n"
1037 . PMA_Config
::getFontsizeSelection() . "\n"
1038 . '<noscript>' . "\n"
1039 . '<input type="submit" value="' . $GLOBALS['strGo'] . '" />' . "\n"
1040 . '</noscript>' . "\n"