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.3');
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('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
182 $this->set('PMA_USR_BROWSER_VER', $log_version[1]);
183 $this->set('PMA_USR_BROWSER_AGENT', 'MOZILLA');
185 $this->set('PMA_USR_BROWSER_VER', 0);
186 $this->set('PMA_USR_BROWSER_AGENT', 'OTHER');
191 * Whether GD2 is present
195 if ($this->get('GD2Available') == 'yes') {
196 $this->set('PMA_IS_GD2', 1);
197 } elseif ($this->get('GD2Available') == 'no') {
198 $this->set('PMA_IS_GD2', 0);
200 if (!@extension_loaded
('gd')) {
203 if (!@function_exists
('imagecreatetruecolor')) {
204 $this->set('PMA_IS_GD2', 0);
206 if (@function_exists
('gd_info')) {
208 if (strstr($gd_nfo["GD Version"], '2.')) {
209 $this->set('PMA_IS_GD2', 1);
211 $this->set('PMA_IS_GD2', 0);
214 /* We must do hard way... */
216 phpinfo(INFO_MODULES
); /* Only modules */
217 $a = strip_tags(ob_get_contents());
219 /* Get GD version string from phpinfo output */
220 if (preg_match('@GD Version[[:space:]]*\(.*\)@', $a, $v)) {
221 if (strstr($v, '2.')) {
222 $this->set('PMA_IS_GD2', 1);
224 $this->set('PMA_IS_GD2', 0);
227 $this->set('PMA_IS_GD2', 0);
235 * Whether the Web server php is running on is IIS
237 function checkWebServer()
239 if (PMA_getenv('SERVER_SOFTWARE')
240 // some versions return Microsoft-IIS, some Microsoft/IIS
241 // we could use a preg_match() but it's slower
242 && stristr(PMA_getenv('SERVER_SOFTWARE'), 'Microsoft')
243 && stristr(PMA_getenv('SERVER_SOFTWARE'), 'IIS')) {
244 $this->set('PMA_IS_IIS', 1);
246 $this->set('PMA_IS_IIS', 0);
251 * Whether the os php is running on is windows or not
253 function checkWebServerOs()
255 // Default to Unix or Equiv
256 $this->set('PMA_IS_WINDOWS', 0);
257 // If PHP_OS is defined then continue
258 if (defined('PHP_OS')) {
259 if (stristr(PHP_OS
, 'win')) {
260 // Is it some version of Windows
261 $this->set('PMA_IS_WINDOWS', 1);
262 } elseif (stristr(PHP_OS
, 'OS/2')) {
263 // Is it OS/2 (No file permissions like Windows)
264 $this->set('PMA_IS_WINDOWS', 1);
270 * detects PHP version
272 function checkPhpVersion()
275 if (! preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@',
276 phpversion(), $match)) {
277 $result = preg_match('@([0-9]{1,2}).([0-9]{1,2})@',
278 phpversion(), $match);
280 if (isset($match) && ! empty($match[1])) {
281 if (! isset($match[2])) {
284 if (! isset($match[3])) {
287 $this->set('PMA_PHP_INT_VERSION',
288 (int) sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));
290 $this->set('PMA_PHP_INT_VERSION', 0);
292 $this->set('PMA_PHP_STR_VERSION', phpversion());
296 * re-init object after loading from session file
297 * checks config file for changes and relaods if neccessary
301 if (! $this->checkConfigSource()
302 ||
$this->source_mtime
!== filemtime($this->getSource())
303 ||
$this->default_source_mtime
!== filemtime($this->default_source
)
304 ||
$this->error_config_file
305 ||
$this->error_config_default_file
) {
306 $this->settings
= array();
308 $this->checkSystem();
311 // check for https needs to be done everytime,
312 // as https and http uses same session so this info can not be stored
314 $this->checkIsHttps();
316 $this->checkCollationConnection();
317 $this->checkFontsize();
321 * loads default values from default source
323 * @uses file_exists()
324 * @uses $this->default_source
325 * @uses $this->error_config_default_file
326 * @uses $this->settings
327 * @return boolean success
329 function loadDefaults()
332 if (! file_exists($this->default_source
)) {
333 $this->error_config_default_file
= true;
336 include $this->default_source
;
338 $this->default_source_mtime
= filemtime($this->default_source
);
340 $this->default_server
= $cfg['Servers'][1];
341 unset($cfg['Servers']);
343 $this->settings
= PMA_array_merge_recursive($this->settings
, $cfg);
345 $this->error_config_default_file
= false;
351 * loads configuration from $source, usally the config file
352 * should be called on object creation and from __wakeup if config file
355 * @param string $source config file
357 function load($source = null)
359 $this->loadDefaults();
361 if (null !== $source) {
362 $this->setSource($source);
365 if (! $this->checkConfigSource()) {
372 * Parses the configuration file
374 $old_error_reporting = error_reporting(0);
375 if (function_exists('file_get_contents')) {
377 eval('?>' . trim(file_get_contents($this->getSource())));
380 eval('?>' . trim(implode("\n", file($this->getSource()))));
382 error_reporting($old_error_reporting);
384 if ($eval_result === false) {
385 $this->error_config_file
= true;
387 $this->error_config_file
= false;
388 $this->source_mtime
= filemtime($this->getSource());
392 * Backward compatibility code
394 if (!empty($cfg['DefaultTabTable'])) {
395 $cfg['DefaultTabTable'] = str_replace('_properties', '', str_replace('tbl_properties.php', 'tbl_sql.php', $cfg['DefaultTabTable']));
397 if (!empty($cfg['DefaultTabDatabase'])) {
398 $cfg['DefaultTabDatabase'] = str_replace('_details', '', str_replace('db_details.php', 'db_sql.php', $cfg['DefaultTabDatabase']));
401 $this->checkFontsize();
402 //$this->checkPmaAbsoluteUri();
403 $this->settings
= PMA_array_merge_recursive($this->settings
, $cfg);
405 // Handling of the collation must be done after merging of $cfg
406 // (from config.inc.php) so that $cfg['DefaultConnectionCollation']
407 // can have an effect. Note that the presence of collation
408 // information in a cookie has priority over what is defined
409 // in the default or user's config files.
411 * @todo check validity of $_COOKIE['pma_collation_connection']
413 if (! empty($_COOKIE['pma_collation_connection'])) {
414 $this->set('collation_connection',
415 strip_tags($_COOKIE['pma_collation_connection']));
417 $this->set('collation_connection',
418 $this->get('DefaultConnectionCollation'));
420 // Now, a collation information could come from REQUEST
421 // (an example of this: the collation selector in main.php)
422 // so the following handles the setting of collation_connection
423 // and later, in common.inc.php, the cookie will be set
424 // according to this.
425 $this->checkCollationConnection();
432 * @param string $source
434 function setSource($source)
436 $this->source
= trim($source);
440 * checks if the config folder still exists and terminates app if true
442 function checkConfigFolder()
444 // Refuse to work while there still might be some world writable dir:
445 if (is_dir('./config')) {
446 die('Remove "./config" directory before using phpMyAdmin!');
451 * check config source
453 * @return boolean wether source is valid or not
455 function checkConfigSource()
457 if (! $this->getSource()) {
458 // no configuration file set at all
462 if (! file_exists($this->getSource())) {
463 // do not trigger error here
464 // https://sf.net/tracker/?func=detail&aid=1370269&group_id=23067&atid=377408
467 'phpMyAdmin-ERROR: unkown configuration source: ' . $source,
470 $this->source_mtime
= 0;
474 if (! is_readable($this->getSource())) {
475 $this->source_mtime
= 0;
476 die('Existing configuration file (' . $this->getSource() . ') is not readable.');
479 // Check for permissions (on platforms that support it):
480 $perms = @fileperms
($this->getSource());
481 if (!($perms === false) && ($perms & 2)) {
482 // This check is normally done after loading configuration
483 $this->checkWebServerOs();
484 if ($this->get('PMA_IS_WINDOWS') == 0) {
485 $this->source_mtime
= 0;
486 die('Wrong permissions on configuration file, should not be world writable!');
494 * returns specific config setting
495 * @param string $setting
496 * @return mixed value
498 function get($setting)
500 if (isset($this->settings
[$setting])) {
501 return $this->settings
[$setting];
507 * sets configuration variable
509 * @uses $this->settings
510 * @param string $setting configuration option
511 * @param string $value new value for configuration option
513 function set($setting, $value)
515 if (!isset($this->settings
[$setting]) ||
$this->settings
[$setting] != $value) {
516 $this->settings
[$setting] = $value;
517 $this->set_mtime
= time();
522 * returns source for current config
523 * @return string config source
527 return $this->source
;
531 * old PHP 4 style constructor
535 function PMA_Config($source = null)
537 $this->__construct($source);
541 * returns a unique value to force a CSS reload if either the config
542 * or the theme changes
543 * @return int Unix timestamp
547 return intval($_SESSION['PMA_Config']->get('fontsize')) +
($this->source_mtime +
$this->default_source_mtime +
$_SESSION['PMA_Theme']->mtime_info
);
551 * $cfg['PmaAbsoluteUri'] is a required directive else cookies won't be
552 * set properly and, depending on browsers, inserting or updating a
555 function checkPmaAbsoluteUri()
557 // Setup a default value to let the people and lazy syadmins work anyway,
558 // they'll get an error if the autodetect code doesn't work
559 $pma_absolute_uri = $this->get('PmaAbsoluteUri');
560 $is_https = $this->get('is_https');
562 if (strlen($pma_absolute_uri) < 5
563 // needed to catch http/https switch
564 ||
($is_https && substr($pma_absolute_uri, 0, 6) != 'https:')
565 ||
(!$is_https && substr($pma_absolute_uri, 0, 5) != 'http:')
569 // At first we try to parse REQUEST_URI, it might contain full URL
570 if (PMA_getenv('REQUEST_URI')) {
571 $url = @parse_url
(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
572 if ($url === false) {
573 $url = array('path' => $_SERVER['REQUEST_URI']);
577 // If we don't have scheme, we didn't have full URL so we need to
579 if (empty($url['scheme'])) {
581 if (PMA_getenv('HTTP_SCHEME')) {
582 $url['scheme'] = PMA_getenv('HTTP_SCHEME');
585 PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
591 if (PMA_getenv('HTTP_HOST')) {
592 if (strpos(PMA_getenv('HTTP_HOST'), ':') !== false) {
593 list($url['host'], $url['port']) =
594 explode(':', PMA_getenv('HTTP_HOST'));
596 $url['host'] = PMA_getenv('HTTP_HOST');
598 } elseif (PMA_getenv('SERVER_NAME')) {
599 $url['host'] = PMA_getenv('SERVER_NAME');
601 $this->error_pma_uri
= true;
605 // If we didn't set port yet...
606 if (empty($url['port']) && PMA_getenv('SERVER_PORT')) {
607 $url['port'] = PMA_getenv('SERVER_PORT');
610 // And finally the path could be already set from REQUEST_URI
611 if (empty($url['path'])) {
612 if (PMA_getenv('PATH_INFO')) {
613 $path = parse_url(PMA_getenv('PATH_INFO'));
615 // PHP_SELF in CGI often points to cgi executable, so use it
617 $path = parse_url(PMA_getenv('PHP_SELF'));
619 $url['path'] = $path['path'];
623 // Make url from parts we have
624 $pma_absolute_uri = $url['scheme'] . '://';
625 // Was there user information?
626 if (!empty($url['user'])) {
627 $pma_absolute_uri .= $url['user'];
628 if (!empty($url['pass'])) {
629 $pma_absolute_uri .= ':' . $url['pass'];
631 $pma_absolute_uri .= '@';
634 $pma_absolute_uri .= $url['host'];
635 // Add port, if it not the default one
636 if (! empty($url['port'])
637 && (($url['scheme'] == 'http' && $url['port'] != 80)
638 ||
($url['scheme'] == 'https' && $url['port'] != 443))) {
639 $pma_absolute_uri .= ':' . $url['port'];
641 // And finally path, without script name, the 'a' is there not to
642 // strip our directory, when path is only /pmadir/ without filename.
643 // Backslashes returned by Windows have to be changed.
644 // Only replace backslashes by forward slashes if on Windows,
645 // as the backslash could be valid on a non-Windows system.
646 if ($this->get('PMA_IS_WINDOWS') == 1) {
647 $path = str_replace("\\", "/", dirname($url['path'] . 'a'));
649 $path = dirname($url['path'] . 'a');
652 // To work correctly within transformations overview:
653 if (defined('PMA_PATH_TO_BASEDIR') && PMA_PATH_TO_BASEDIR
== '../../') {
654 if ($this->get('PMA_IS_WINDOWS') == 1) {
655 $path = str_replace("\\", "/", dirname(dirname($path)));
657 $path = dirname(dirname($path));
660 // in vhost situations, there could be already an ending slash
661 if (substr($path, -1) != '/') {
664 $pma_absolute_uri .= $path;
666 // We used to display a warning if PmaAbsoluteUri wasn't set, but now
667 // the autodetect code works well enough that we don't display the
668 // warning at all. The user can still set PmaAbsoluteUri manually.
670 // http://sf.net/tracker/?func=detail&aid=1257134&group_id=23067&atid=377411
673 // The URI is specified, however users do often specify this
674 // wrongly, so we try to fix this.
676 // Adds a trailing slash et the end of the phpMyAdmin uri if it
678 if (substr($pma_absolute_uri, -1) != '/') {
679 $pma_absolute_uri .= '/';
682 // If URI doesn't start with http:// or https://, we will add
684 if (substr($pma_absolute_uri, 0, 7) != 'http://'
685 && substr($pma_absolute_uri, 0, 8) != 'https://') {
687 (PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
690 . ':' . (substr($pma_absolute_uri, 0, 2) == '//' ?
'' : '//')
694 $this->set('PmaAbsoluteUri', $pma_absolute_uri);
698 * check selected collation_connection
699 * @todo check validity of $_REQUEST['collation_connection']
701 function checkCollationConnection()
703 // (could be improved by executing it after the MySQL connection only if
704 // PMA_MYSQL_INT_VERSION >= 40100)
705 if (! empty($_REQUEST['collation_connection'])) {
706 $this->set('collation_connection',
707 strip_tags($_REQUEST['collation_connection']));
712 * checks for font size configuration, and sets font size as requested by user
718 * @uses function_exists()
719 * @uses PMA_Config::set()
720 * @uses PMA_Config::get()
721 * @uses PMA_setCookie()
723 function checkFontsize()
727 if (isset($_GET['fontsize'])) {
728 $new_fontsize = $_GET['fontsize'];
729 } elseif (isset($_POST['fontsize'])) {
730 $new_fontsize = $_POST['fontsize'];
731 } elseif (isset($_COOKIE['pma_fontsize'])) {
732 $new_fontsize = $_COOKIE['pma_fontsize'];
735 if (preg_match('/^[0-9.]+(px|em|pt|\%)$/', $new_fontsize)) {
736 $this->set('fontsize', $new_fontsize);
737 } elseif (! $this->get('fontsize')) {
738 // 80% would correspond to the default browser font size
739 // of 16, but use 82% to help read the monoface font
740 $this->set('fontsize', '82%');
743 if (function_exists('PMA_setCookie')) {
744 PMA_setCookie('pma_fontsize', $this->get('fontsize'), '82%');
749 * checks if upload is enabled
752 function checkUpload()
754 if (ini_get('file_uploads')) {
755 $this->set('enable_upload', true);
756 // if set "php_admin_value file_uploads Off" in httpd.conf
757 // ini_get() also returns the string "Off" in this case:
758 if ('off' == strtolower(ini_get('file_uploads'))) {
759 $this->set('enable_upload', false);
762 $this->set('enable_upload', false);
767 * Maximum upload size as limited by PHP
768 * Used with permission from Moodle (http://moodle.org) by Martin Dougiamas
770 * this section generates $max_upload_size in bytes
772 function checkUploadSize()
774 if (! $filesize = ini_get('upload_max_filesize')) {
778 if ($postsize = ini_get('post_max_size')) {
779 $this->set('max_upload_size',
780 min(PMA_get_real_size($filesize), PMA_get_real_size($postsize)));
782 $this->set('max_upload_size', PMA_get_real_size($filesize));
789 function checkIsHttps()
791 $this->set('is_https', PMA_Config
::isHttps());
803 // At first we try to parse REQUEST_URI, it might contain full URL,
804 if (PMA_getenv('REQUEST_URI')) {
805 $url = @parse_url
(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
811 // If we don't have scheme, we didn't have full URL so we need to
813 if (empty($url['scheme'])) {
815 if (PMA_getenv('HTTP_SCHEME')) {
816 $url['scheme'] = PMA_getenv('HTTP_SCHEME');
819 PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off'
825 if (isset($url['scheme'])
826 && $url['scheme'] == 'https') {
836 * detect correct cookie path
838 function checkCookiePath()
840 $this->set('cookie_path', PMA_Config
::getCookiePath());
846 function getCookiePath()
848 static $cookie_path = null;
850 if (null !== $cookie_path) {
856 if (PMA_getenv('REQUEST_URI')) {
857 $url = PMA_getenv('REQUEST_URI');
860 // If we don't have path
862 if (PMA_getenv('PATH_INFO')) {
863 $url = PMA_getenv('PATH_INFO');
864 } elseif (PMA_getenv('PHP_SELF')) {
865 // PHP_SELF in CGI often points to cgi executable, so use it
867 $url = PMA_getenv('PHP_SELF');
868 } elseif (PMA_getenv('SCRIPT_NAME')) {
869 $url = PMA_getenv('PHP_SELF');
873 $parsed_url = @parse_url
($_SERVER['REQUEST_URI']); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/'
874 if ($parsed_url === false) {
875 $parsed_url = array('path' => $url);
878 $cookie_path = substr($parsed_url['path'], 0, strrpos($parsed_url['path'], '/')) . '/';
884 * enables backward compatibility
888 $GLOBALS['cfg'] =& $this->settings
;
889 $GLOBALS['default_server'] =& $this->default_server
;
890 $GLOBALS['collation_connection'] = $this->get('collation_connection');
891 $GLOBALS['is_upload'] = $this->get('enable_upload');
892 $GLOBALS['max_upload_size'] = $this->get('max_upload_size');
893 $GLOBALS['cookie_path'] = $this->get('cookie_path');
894 $GLOBALS['is_https'] = $this->get('is_https');
899 'PMA_THEME_GENERATION',
900 'PMA_PHP_STR_VERSION',
901 'PMA_PHP_INT_VERSION',
906 'PMA_USR_BROWSER_VER',
907 'PMA_USR_BROWSER_AGENT'
910 foreach ($defines as $define) {
911 if (! defined($define)) {
912 define($define, $this->get($define));
923 * returns options for font size selection
925 * @uses preg_replace()
928 * @param string $current_size current selected font size with unit
929 * @return array selectable font sizes
931 function getFontsizeOptions($current_size = '82%')
933 $unit = preg_replace('/[0-9.]*/', '', $current_size);
934 $value = preg_replace('/[^0-9.]*/', '', $current_size);
938 $options["$value"] = $value . $unit;
944 } elseif ($unit === 'em') {
948 } elseif ($unit === 'pt') {
951 } elseif ($unit === 'px') {
956 //unknown font size unit
964 foreach ($factors as $key => $factor) {
965 $option_inc = $value +
$factor;
966 $option_dec = $value - $factor;
967 while (count($options) < 21) {
968 $options["$option_inc"] = $option_inc . $unit;
969 if ($option_dec > $factors[0]) {
970 $options["$option_dec"] = $option_dec . $unit;
972 $option_inc +
= $factor;
973 $option_dec -= $factor;
974 if (isset($factors[$key +
1])
975 && $option_inc >= $value +
$factors[$key +
1]) {
985 * returns html selectbox for font sizes
987 * @uses $_SESSION['PMA_Config']
988 * @uses PMA_Config::get()
989 * @uses PMA_Config::getFontsizeOptions()
990 * @uses $GLOBALS['strFontSize']
992 * @param string $current_size currently slected font size with unit
993 * @return string html selectbox
995 function getFontsizeSelection()
997 $current_size = $_SESSION['PMA_Config']->get('fontsize');
998 $options = PMA_Config
::getFontsizeOptions($current_size);
1000 $return = '<label for="select_fontsize">' . $GLOBALS['strFontSize'] . ':</label>' . "\n";
1001 $return .= '<select name="fontsize" id="select_fontsize" onchange="this.form.submit();">' . "\n";
1002 foreach ($options as $option) {
1003 $return .= '<option value="' . $option . '"';
1004 if ($option == $current_size) {
1005 $return .= ' selected="selected"';
1007 $return .= '>' . $option . '</option>' . "\n";
1009 $return .= '</select>';
1015 * return complete font size selection form
1017 * @uses PMA_generate_common_hidden_inputs()
1018 * @uses PMA_Config::getFontsizeSelection()
1019 * @uses $GLOBALS['strGo']
1021 * @param string $current_size currently slected font size with unit
1022 * @return string html selectbox
1024 function getFontsizeForm()
1026 return '<form name="form_fontsize_selection" id="form_fontsize_selection"'
1027 . ' method="post" action="index.php" target="_parent">' . "\n"
1028 . PMA_generate_common_hidden_inputs() . "\n"
1029 . PMA_Config
::getFontsizeSelection() . "\n"
1030 . '<noscript>' . "\n"
1031 . '<input type="submit" value="' . $GLOBALS['strGo'] . '" />' . "\n"
1032 . '</noscript>' . "\n"