PageRenderTime 64ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/Site/phpmyadmin/libraries/Config.class.php

https://github.com/cdau/YWEE
PHP | 1910 lines | 1265 code | 149 blank | 496 comment | 306 complexity | b4fe2cab426da0b0c93c16ad2a9ad9cd MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Configuration handling.
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /**
  12. * Load vendor configuration.
  13. */
  14. require_once './libraries/vendor_config.php';
  15. /**
  16. * Indication for error handler (see end of this file).
  17. */
  18. $GLOBALS['pma_config_loading'] = false;
  19. /**
  20. * Configuration class
  21. *
  22. * @package PhpMyAdmin
  23. */
  24. class PMA_Config
  25. {
  26. /**
  27. * @var string default config source
  28. */
  29. var $default_source = './libraries/config.default.php';
  30. /**
  31. * @var array default configuration settings
  32. */
  33. var $default = array();
  34. /**
  35. * @var array configuration settings, without user preferences applied
  36. */
  37. var $base_settings = array();
  38. /**
  39. * @var array configuration settings
  40. */
  41. var $settings = array();
  42. /**
  43. * @var string config source
  44. */
  45. var $source = '';
  46. /**
  47. * @var int source modification time
  48. */
  49. var $source_mtime = 0;
  50. var $default_source_mtime = 0;
  51. var $set_mtime = 0;
  52. /**
  53. * @var boolean
  54. */
  55. var $error_config_file = false;
  56. /**
  57. * @var boolean
  58. */
  59. var $error_config_default_file = false;
  60. /**
  61. * @var boolean
  62. */
  63. var $error_pma_uri = false;
  64. /**
  65. * @var array
  66. */
  67. var $default_server = array();
  68. /**
  69. * @var boolean whether init is done or not
  70. * set this to false to force some initial checks
  71. * like checking for required functions
  72. */
  73. var $done = false;
  74. /**
  75. * constructor
  76. *
  77. * @param string $source source to read config from
  78. */
  79. function __construct($source = null)
  80. {
  81. $this->settings = array();
  82. // functions need to refresh in case of config file changed goes in
  83. // PMA_Config::load()
  84. $this->load($source);
  85. // other settings, independent from config file, comes in
  86. $this->checkSystem();
  87. $this->isHttps();
  88. $this->base_settings = $this->settings;
  89. }
  90. /**
  91. * sets system and application settings
  92. *
  93. * @return void
  94. */
  95. function checkSystem()
  96. {
  97. $this->set('PMA_VERSION', '4.2.2');
  98. /**
  99. * @deprecated
  100. */
  101. $this->set('PMA_THEME_VERSION', 2);
  102. /**
  103. * @deprecated
  104. */
  105. $this->set('PMA_THEME_GENERATION', 2);
  106. $this->checkPhpVersion();
  107. $this->checkWebServerOs();
  108. $this->checkWebServer();
  109. $this->checkGd2();
  110. $this->checkClient();
  111. $this->checkUpload();
  112. $this->checkUploadSize();
  113. $this->checkOutputCompression();
  114. }
  115. /**
  116. * whether to use gzip output compression or not
  117. *
  118. * @return void
  119. */
  120. function checkOutputCompression()
  121. {
  122. // If zlib output compression is set in the php configuration file, no
  123. // output buffering should be run
  124. if (@ini_get('zlib.output_compression')) {
  125. $this->set('OBGzip', false);
  126. }
  127. // disable output-buffering (if set to 'auto') for IE6, else enable it.
  128. if (strtolower($this->get('OBGzip')) == 'auto') {
  129. if ($this->get('PMA_USR_BROWSER_AGENT') == 'IE'
  130. && $this->get('PMA_USR_BROWSER_VER') >= 6
  131. && $this->get('PMA_USR_BROWSER_VER') < 7
  132. ) {
  133. $this->set('OBGzip', false);
  134. } else {
  135. $this->set('OBGzip', true);
  136. }
  137. }
  138. }
  139. /**
  140. * Determines platform (OS), browser and version of the user
  141. * Based on a phpBuilder article:
  142. *
  143. * @see http://www.phpbuilder.net/columns/tim20000821.php
  144. *
  145. * @return void
  146. */
  147. function checkClient()
  148. {
  149. if (PMA_getenv('HTTP_USER_AGENT')) {
  150. $HTTP_USER_AGENT = PMA_getenv('HTTP_USER_AGENT');
  151. } else {
  152. $HTTP_USER_AGENT = '';
  153. }
  154. // 1. Platform
  155. if (strstr($HTTP_USER_AGENT, 'Win')) {
  156. $this->set('PMA_USR_OS', 'Win');
  157. } elseif (strstr($HTTP_USER_AGENT, 'Mac')) {
  158. $this->set('PMA_USR_OS', 'Mac');
  159. } elseif (strstr($HTTP_USER_AGENT, 'Linux')) {
  160. $this->set('PMA_USR_OS', 'Linux');
  161. } elseif (strstr($HTTP_USER_AGENT, 'Unix')) {
  162. $this->set('PMA_USR_OS', 'Unix');
  163. } elseif (strstr($HTTP_USER_AGENT, 'OS/2')) {
  164. $this->set('PMA_USR_OS', 'OS/2');
  165. } else {
  166. $this->set('PMA_USR_OS', 'Other');
  167. }
  168. // 2. browser and version
  169. // (must check everything else before Mozilla)
  170. $is_mozilla = preg_match(
  171. '@Mozilla/([0-9].[0-9]{1,2})@',
  172. $HTTP_USER_AGENT,
  173. $mozilla_version
  174. );
  175. if (preg_match(
  176. '@Opera(/| )([0-9].[0-9]{1,2})@',
  177. $HTTP_USER_AGENT,
  178. $log_version
  179. )) {
  180. $this->set('PMA_USR_BROWSER_VER', $log_version[2]);
  181. $this->set('PMA_USR_BROWSER_AGENT', 'OPERA');
  182. } elseif (preg_match(
  183. '@(MS)?IE ([0-9]{1,2}.[0-9]{1,2})@',
  184. $HTTP_USER_AGENT,
  185. $log_version
  186. )) {
  187. $this->set('PMA_USR_BROWSER_VER', $log_version[2]);
  188. $this->set('PMA_USR_BROWSER_AGENT', 'IE');
  189. } elseif (preg_match(
  190. '@Trident/(7)\.0@',
  191. $HTTP_USER_AGENT,
  192. $log_version
  193. )) {
  194. $this->set('PMA_USR_BROWSER_VER', intval($log_version[1]) + 4);
  195. $this->set('PMA_USR_BROWSER_AGENT', 'IE');
  196. } elseif (preg_match(
  197. '@OmniWeb/([0-9].[0-9]{1,2})@',
  198. $HTTP_USER_AGENT,
  199. $log_version
  200. )) {
  201. $this->set('PMA_USR_BROWSER_VER', $log_version[1]);
  202. $this->set('PMA_USR_BROWSER_AGENT', 'OMNIWEB');
  203. // Konqueror 2.2.2 says Konqueror/2.2.2
  204. // Konqueror 3.0.3 says Konqueror/3
  205. } elseif (preg_match(
  206. '@(Konqueror/)(.*)(;)@',
  207. $HTTP_USER_AGENT,
  208. $log_version
  209. )) {
  210. $this->set('PMA_USR_BROWSER_VER', $log_version[2]);
  211. $this->set('PMA_USR_BROWSER_AGENT', 'KONQUEROR');
  212. // must check Chrome before Safari
  213. } elseif ($is_mozilla
  214. && preg_match('@Chrome/([0-9.]*)@', $HTTP_USER_AGENT, $log_version)
  215. ) {
  216. $this->set('PMA_USR_BROWSER_VER', $log_version[1]);
  217. $this->set('PMA_USR_BROWSER_AGENT', 'CHROME');
  218. // newer Safari
  219. } elseif ($is_mozilla
  220. && preg_match('@Version/(.*) Safari@', $HTTP_USER_AGENT, $log_version)
  221. ) {
  222. $this->set(
  223. 'PMA_USR_BROWSER_VER', $log_version[1]
  224. );
  225. $this->set('PMA_USR_BROWSER_AGENT', 'SAFARI');
  226. // older Safari
  227. } elseif ($is_mozilla
  228. && preg_match('@Safari/([0-9]*)@', $HTTP_USER_AGENT, $log_version)
  229. ) {
  230. $this->set(
  231. 'PMA_USR_BROWSER_VER', $mozilla_version[1] . '.' . $log_version[1]
  232. );
  233. $this->set('PMA_USR_BROWSER_AGENT', 'SAFARI');
  234. // Firefox
  235. } elseif (! strstr($HTTP_USER_AGENT, 'compatible')
  236. && preg_match('@Firefox/([\w.]+)@', $HTTP_USER_AGENT, $log_version)
  237. ) {
  238. $this->set(
  239. 'PMA_USR_BROWSER_VER', $log_version[1]
  240. );
  241. $this->set('PMA_USR_BROWSER_AGENT', 'FIREFOX');
  242. } elseif (preg_match('@rv:1.9(.*)Gecko@', $HTTP_USER_AGENT)) {
  243. $this->set('PMA_USR_BROWSER_VER', '1.9');
  244. $this->set('PMA_USR_BROWSER_AGENT', 'GECKO');
  245. } elseif ($is_mozilla) {
  246. $this->set('PMA_USR_BROWSER_VER', $mozilla_version[1]);
  247. $this->set('PMA_USR_BROWSER_AGENT', 'MOZILLA');
  248. } else {
  249. $this->set('PMA_USR_BROWSER_VER', 0);
  250. $this->set('PMA_USR_BROWSER_AGENT', 'OTHER');
  251. }
  252. }
  253. /**
  254. * Whether GD2 is present
  255. *
  256. * @return void
  257. */
  258. function checkGd2()
  259. {
  260. if ($this->get('GD2Available') == 'yes') {
  261. $this->set('PMA_IS_GD2', 1);
  262. } elseif ($this->get('GD2Available') == 'no') {
  263. $this->set('PMA_IS_GD2', 0);
  264. } else {
  265. if (!@function_exists('imagecreatetruecolor')) {
  266. $this->set('PMA_IS_GD2', 0);
  267. } else {
  268. if (@function_exists('gd_info')) {
  269. $gd_nfo = gd_info();
  270. if (strstr($gd_nfo["GD Version"], '2.')) {
  271. $this->set('PMA_IS_GD2', 1);
  272. } else {
  273. $this->set('PMA_IS_GD2', 0);
  274. }
  275. } else {
  276. $this->set('PMA_IS_GD2', 0);
  277. }
  278. }
  279. }
  280. }
  281. /**
  282. * Whether the Web server php is running on is IIS
  283. *
  284. * @return void
  285. */
  286. function checkWebServer()
  287. {
  288. // some versions return Microsoft-IIS, some Microsoft/IIS
  289. // we could use a preg_match() but it's slower
  290. if (PMA_getenv('SERVER_SOFTWARE')
  291. && stristr(PMA_getenv('SERVER_SOFTWARE'), 'Microsoft')
  292. && stristr(PMA_getenv('SERVER_SOFTWARE'), 'IIS')
  293. ) {
  294. $this->set('PMA_IS_IIS', 1);
  295. } else {
  296. $this->set('PMA_IS_IIS', 0);
  297. }
  298. }
  299. /**
  300. * Whether the os php is running on is windows or not
  301. *
  302. * @return void
  303. */
  304. function checkWebServerOs()
  305. {
  306. // Default to Unix or Equiv
  307. $this->set('PMA_IS_WINDOWS', 0);
  308. // If PHP_OS is defined then continue
  309. if (defined('PHP_OS')) {
  310. if (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) {
  311. // Is it some version of Windows
  312. $this->set('PMA_IS_WINDOWS', 1);
  313. } elseif (stristr(PHP_OS, 'OS/2')) {
  314. // Is it OS/2 (No file permissions like Windows)
  315. $this->set('PMA_IS_WINDOWS', 1);
  316. }
  317. }
  318. }
  319. /**
  320. * detects PHP version
  321. *
  322. * @return void
  323. */
  324. function checkPhpVersion()
  325. {
  326. $match = array();
  327. if (! preg_match(
  328. '@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@',
  329. phpversion(),
  330. $match
  331. )) {
  332. preg_match(
  333. '@([0-9]{1,2}).([0-9]{1,2})@',
  334. phpversion(),
  335. $match
  336. );
  337. }
  338. if (isset($match) && ! empty($match[1])) {
  339. if (! isset($match[2])) {
  340. $match[2] = 0;
  341. }
  342. if (! isset($match[3])) {
  343. $match[3] = 0;
  344. }
  345. $this->set(
  346. 'PMA_PHP_INT_VERSION',
  347. (int) sprintf('%d%02d%02d', $match[1], $match[2], $match[3])
  348. );
  349. } else {
  350. $this->set('PMA_PHP_INT_VERSION', 0);
  351. }
  352. $this->set('PMA_PHP_STR_VERSION', phpversion());
  353. }
  354. /**
  355. * detects if Git revision
  356. *
  357. * @return boolean
  358. */
  359. function isGitRevision()
  360. {
  361. // caching
  362. if (isset($_SESSION['is_git_revision'])) {
  363. if ($_SESSION['is_git_revision']) {
  364. $this->set('PMA_VERSION_GIT', 1);
  365. }
  366. return $_SESSION['is_git_revision'];
  367. }
  368. // find out if there is a .git folder
  369. $git_folder = '.git';
  370. if (! @file_exists($git_folder)
  371. || ! @file_exists($git_folder . '/config')
  372. ) {
  373. $_SESSION['is_git_revision'] = false;
  374. return false;
  375. }
  376. $_SESSION['is_git_revision'] = true;
  377. return true;
  378. }
  379. /**
  380. * detects Git revision, if running inside repo
  381. *
  382. * @return void
  383. */
  384. function checkGitRevision()
  385. {
  386. // find out if there is a .git folder
  387. $git_folder = '.git';
  388. if (! $this->isGitRevision()) {
  389. return;
  390. }
  391. if (! $ref_head = @file_get_contents($git_folder . '/HEAD')) {
  392. return;
  393. }
  394. $branch = false;
  395. // are we on any branch?
  396. if (strstr($ref_head, '/')) {
  397. $ref_head = substr(trim($ref_head), 5);
  398. if (substr($ref_head, 0, 11) === 'refs/heads/') {
  399. $branch = substr($ref_head, 11);
  400. } else {
  401. $branch = basename($ref_head);
  402. }
  403. $ref_file = $git_folder . '/' . $ref_head;
  404. if (@file_exists($ref_file)) {
  405. $hash = @file_get_contents($ref_file);
  406. if (! $hash) {
  407. return;
  408. }
  409. $hash = trim($hash);
  410. } else {
  411. // deal with packed refs
  412. $packed_refs = @file_get_contents($git_folder . '/packed-refs');
  413. if (! $packed_refs) {
  414. return;
  415. }
  416. // split file to lines
  417. $ref_lines = explode("\n", $packed_refs);
  418. foreach ($ref_lines as $line) {
  419. // skip comments
  420. if ($line[0] == '#') {
  421. continue;
  422. }
  423. // parse line
  424. $parts = explode(' ', $line);
  425. // care only about named refs
  426. if (count($parts) != 2) {
  427. continue;
  428. }
  429. // have found our ref?
  430. if ($parts[1] == $ref_head) {
  431. $hash = $parts[0];
  432. break;
  433. }
  434. }
  435. if (! isset($hash)) {
  436. // Could not find ref
  437. return;
  438. }
  439. }
  440. } else {
  441. $hash = trim($ref_head);
  442. }
  443. $commit = false;
  444. if (! isset($_SESSION['PMA_VERSION_COMMITDATA_' . $hash])) {
  445. $git_file_name = $git_folder . '/objects/' . substr($hash, 0, 2)
  446. . '/' . substr($hash, 2);
  447. if (file_exists($git_file_name) ) {
  448. if (! $commit = @file_get_contents($git_file_name)) {
  449. return;
  450. }
  451. $commit = explode("\0", gzuncompress($commit), 2);
  452. $commit = explode("\n", $commit[1]);
  453. $_SESSION['PMA_VERSION_COMMITDATA_' . $hash] = $commit;
  454. } else {
  455. $pack_names = array();
  456. // work with packed data
  457. $packs_file = $git_folder . '/objects/info/packs';
  458. if (file_exists($packs_file)
  459. && $packs = @file_get_contents($packs_file)
  460. ) {
  461. // File exists. Read it, parse the file to get the names of the
  462. // packs. (to look for them in .git/object/pack directory later)
  463. foreach (explode("\n", $packs) as $line) {
  464. // skip blank lines
  465. if (strlen(trim($line)) == 0) {
  466. continue;
  467. }
  468. // skip non pack lines
  469. if ($line[0] != 'P') {
  470. continue;
  471. }
  472. // parse names
  473. $pack_names[] = substr($line, 2);
  474. }
  475. } else {
  476. // '.git/objects/info/packs' file can be missing
  477. // (atlease in mysGit)
  478. // File missing. May be we can look in the .git/object/pack
  479. // directory for all the .pack files and use that list of
  480. // files instead
  481. $dirIterator = new DirectoryIterator(
  482. $git_folder . '/objects/pack'
  483. );
  484. foreach ($dirIterator as $file_info) {
  485. $file_name = $file_info->getFilename();
  486. // if this is a .pack file
  487. if ($file_info->isFile()
  488. && substr($file_name, -5) == '.pack'
  489. ) {
  490. $pack_names[] = $file_name;
  491. }
  492. }
  493. }
  494. $hash = strtolower($hash);
  495. foreach ($pack_names as $pack_name) {
  496. $index_name = str_replace('.pack', '.idx', $pack_name);
  497. // load index
  498. $index_data = @file_get_contents(
  499. $git_folder . '/objects/pack/' . $index_name
  500. );
  501. if (! $index_data) {
  502. continue;
  503. }
  504. // check format
  505. if (substr($index_data, 0, 4) != "\377tOc") {
  506. continue;
  507. }
  508. // check version
  509. $version = unpack('N', substr($index_data, 4, 4));
  510. if ($version[1] != 2) {
  511. continue;
  512. }
  513. // parse fanout table
  514. $fanout = unpack("N*", substr($index_data, 8, 256 * 4));
  515. // find where we should search
  516. $firstbyte = intval(substr($hash, 0, 2), 16);
  517. // array is indexed from 1 and we need to get
  518. // previous entry for start
  519. if ($firstbyte == 0) {
  520. $start = 0;
  521. } else {
  522. $start = $fanout[$firstbyte];
  523. }
  524. $end = $fanout[$firstbyte + 1];
  525. // stupid linear search for our sha
  526. $found = false;
  527. $offset = 8 + (256 * 4);
  528. for ($position = $start; $position < $end; $position++) {
  529. $sha = strtolower(
  530. bin2hex(
  531. substr(
  532. $index_data, $offset + ($position * 20), 20
  533. )
  534. )
  535. );
  536. if ($sha == $hash) {
  537. $found = true;
  538. break;
  539. }
  540. }
  541. if (! $found) {
  542. continue;
  543. }
  544. // read pack offset
  545. $offset = 8 + (256 * 4) + (24 * $fanout[256]);
  546. $pack_offset = unpack(
  547. 'N', substr($index_data, $offset + ($position * 4), 4)
  548. );
  549. $pack_offset = $pack_offset[1];
  550. // open pack file
  551. $pack_file = fopen(
  552. $git_folder . '/objects/pack/' . $pack_name, 'rb'
  553. );
  554. if ($pack_file === false) {
  555. continue;
  556. }
  557. // seek to start
  558. fseek($pack_file, $pack_offset);
  559. // parse header
  560. $header = ord(fread($pack_file, 1));
  561. $type = ($header >> 4) & 7;
  562. $hasnext = ($header & 128) >> 7;
  563. $size = $header & 0xf;
  564. $offset = 4;
  565. while ($hasnext) {
  566. $byte = ord(fread($pack_file, 1));
  567. $size |= ($byte & 0x7f) << $offset;
  568. $hasnext = ($byte & 128) >> 7;
  569. $offset += 7;
  570. }
  571. // we care only about commit objects
  572. if ($type != 1) {
  573. continue;
  574. }
  575. // read data
  576. $commit = fread($pack_file, $size);
  577. $commit = gzuncompress($commit);
  578. $commit = explode("\n", $commit);
  579. $_SESSION['PMA_VERSION_COMMITDATA_' . $hash] = $commit;
  580. fclose($pack_file);
  581. }
  582. }
  583. } else {
  584. $commit = $_SESSION['PMA_VERSION_COMMITDATA_' . $hash];
  585. }
  586. // check if commit exists in Github
  587. if ($commit !== false
  588. && isset($_SESSION['PMA_VERSION_REMOTECOMMIT_' . $hash])
  589. ) {
  590. $is_remote_commit = $_SESSION['PMA_VERSION_REMOTECOMMIT_' . $hash];
  591. } else {
  592. $link = 'https://api.github.com/repos/phpmyadmin/phpmyadmin/git/commits/'
  593. . $hash;
  594. $is_found = $this->checkHTTP($link, ! $commit);
  595. switch($is_found) {
  596. case false:
  597. $is_remote_commit = false;
  598. $_SESSION['PMA_VERSION_REMOTECOMMIT_' . $hash] = false;
  599. break;
  600. case null:
  601. // no remote link for now, but don't cache this as Github is down
  602. $is_remote_commit = false;
  603. break;
  604. default:
  605. $is_remote_commit = true;
  606. $_SESSION['PMA_VERSION_REMOTECOMMIT_' . $hash] = true;
  607. if ($commit === false) {
  608. // if no local commit data, try loading from Github
  609. $commit_json = json_decode($is_found);
  610. }
  611. break;
  612. }
  613. }
  614. $is_remote_branch = false;
  615. if ($is_remote_commit && $branch !== false) {
  616. // check if branch exists in Github
  617. if (isset($_SESSION['PMA_VERSION_REMOTEBRANCH_' . $hash])) {
  618. $is_remote_branch = $_SESSION['PMA_VERSION_REMOTEBRANCH_' . $hash];
  619. } else {
  620. $link = 'https://api.github.com/repos/phpmyadmin/phpmyadmin'
  621. . '/git/trees/' . $branch;
  622. $is_found = $this->checkHTTP($link);
  623. switch($is_found) {
  624. case true:
  625. $is_remote_branch = true;
  626. $_SESSION['PMA_VERSION_REMOTEBRANCH_' . $hash] = true;
  627. break;
  628. case false:
  629. $is_remote_branch = false;
  630. $_SESSION['PMA_VERSION_REMOTEBRANCH_' . $hash] = false;
  631. break;
  632. case null:
  633. // no remote link for now, but don't cache this as Github is down
  634. $is_remote_branch = false;
  635. break;
  636. }
  637. }
  638. }
  639. if ($commit !== false) {
  640. $author = array('name' => '', 'email' => '', 'date' => '');
  641. $committer = array('name' => '', 'email' => '', 'date' => '');
  642. do {
  643. $dataline = array_shift($commit);
  644. $datalinearr = explode(' ', $dataline, 2);
  645. $linetype = $datalinearr[0];
  646. if (in_array($linetype, array('author', 'committer'))) {
  647. $user = $datalinearr[1];
  648. preg_match('/([^<]+)<([^>]+)> ([0-9]+)( [^ ]+)?/', $user, $user);
  649. $user2 = array(
  650. 'name' => trim($user[1]),
  651. 'email' => trim($user[2]),
  652. 'date' => date('Y-m-d H:i:s', $user[3]));
  653. if (isset($user[4])) {
  654. $user2['date'] .= $user[4];
  655. }
  656. $$linetype = $user2;
  657. }
  658. } while ($dataline != '');
  659. $message = trim(implode(' ', $commit));
  660. } elseif (isset($commit_json)) {
  661. $author = array(
  662. 'name' => $commit_json->author->name,
  663. 'email' => $commit_json->author->email,
  664. 'date' => $commit_json->author->date);
  665. $committer = array(
  666. 'name' => $commit_json->committer->name,
  667. 'email' => $commit_json->committer->email,
  668. 'date' => $commit_json->committer->date);
  669. $message = trim($commit_json->message);
  670. } else {
  671. return;
  672. }
  673. $this->set('PMA_VERSION_GIT', 1);
  674. $this->set('PMA_VERSION_GIT_COMMITHASH', $hash);
  675. $this->set('PMA_VERSION_GIT_BRANCH', $branch);
  676. $this->set('PMA_VERSION_GIT_MESSAGE', $message);
  677. $this->set('PMA_VERSION_GIT_AUTHOR', $author);
  678. $this->set('PMA_VERSION_GIT_COMMITTER', $committer);
  679. $this->set('PMA_VERSION_GIT_ISREMOTECOMMIT', $is_remote_commit);
  680. $this->set('PMA_VERSION_GIT_ISREMOTEBRANCH', $is_remote_branch);
  681. }
  682. /**
  683. * Checks if given URL is 200 or 404, optionally returns data
  684. *
  685. * @param mixed $link curl link
  686. * @param boolean $get_body whether to retrieve body of document
  687. *
  688. * @return string|boolean test result or data
  689. */
  690. function checkHTTP($link, $get_body = false)
  691. {
  692. if (! function_exists('curl_init')) {
  693. return null;
  694. }
  695. $ch = curl_init($link);
  696. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  697. curl_setopt($ch, CURLOPT_HEADER, 1);
  698. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  699. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  700. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  701. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
  702. curl_setopt($ch, CURLOPT_USERAGENT, 'phpMyAdmin/' . PMA_VERSION);
  703. curl_setopt($ch, CURLOPT_TIMEOUT, 5);
  704. if (! defined('TESTSUITE')) {
  705. session_write_close();
  706. }
  707. $data = @curl_exec($ch);
  708. if (! defined('TESTSUITE')) {
  709. ini_set('session.use_only_cookies', false);
  710. ini_set('session.use_cookies', false);
  711. ini_set('session.use_trans_sid', false);
  712. ini_set('session.cache_limiter', null);
  713. session_start();
  714. }
  715. if ($data === false) {
  716. return null;
  717. }
  718. $ok = 'HTTP/1.1 200 OK';
  719. $notfound = 'HTTP/1.1 404 Not Found';
  720. if (substr($data, 0, strlen($ok)) === $ok) {
  721. return $get_body ? substr($data, strpos($data, "\r\n\r\n") + 4) : true;
  722. } elseif (substr($data, 0, strlen($notfound)) === $notfound) {
  723. return false;
  724. }
  725. return null;
  726. }
  727. /**
  728. * loads default values from default source
  729. *
  730. * @return boolean success
  731. */
  732. function loadDefaults()
  733. {
  734. $cfg = array();
  735. if (! file_exists($this->default_source)) {
  736. $this->error_config_default_file = true;
  737. return false;
  738. }
  739. include $this->default_source;
  740. $this->default_source_mtime = filemtime($this->default_source);
  741. $this->default_server = $cfg['Servers'][1];
  742. unset($cfg['Servers']);
  743. $this->default = $cfg;
  744. $this->settings = PMA_arrayMergeRecursive($this->settings, $cfg);
  745. $this->error_config_default_file = false;
  746. return true;
  747. }
  748. /**
  749. * loads configuration from $source, usually the config file
  750. * should be called on object creation
  751. *
  752. * @param string $source config file
  753. *
  754. * @return bool
  755. */
  756. function load($source = null)
  757. {
  758. $this->loadDefaults();
  759. if (null !== $source) {
  760. $this->setSource($source);
  761. }
  762. if (! $this->checkConfigSource()) {
  763. return false;
  764. }
  765. $cfg = array();
  766. /**
  767. * Parses the configuration file, we throw away any errors or
  768. * output.
  769. */
  770. $old_error_reporting = error_reporting(0);
  771. ob_start();
  772. $GLOBALS['pma_config_loading'] = true;
  773. $eval_result = include $this->getSource();
  774. $GLOBALS['pma_config_loading'] = false;
  775. ob_end_clean();
  776. error_reporting($old_error_reporting);
  777. if ($eval_result === false) {
  778. $this->error_config_file = true;
  779. } else {
  780. $this->error_config_file = false;
  781. $this->source_mtime = filemtime($this->getSource());
  782. }
  783. /**
  784. * Backward compatibility code
  785. */
  786. if (!empty($cfg['DefaultTabTable'])) {
  787. $cfg['DefaultTabTable'] = str_replace(
  788. '_properties',
  789. '',
  790. str_replace(
  791. 'tbl_properties.php',
  792. 'tbl_sql.php',
  793. $cfg['DefaultTabTable']
  794. )
  795. );
  796. }
  797. if (!empty($cfg['DefaultTabDatabase'])) {
  798. $cfg['DefaultTabDatabase'] = str_replace(
  799. '_details',
  800. '',
  801. str_replace(
  802. 'db_details.php',
  803. 'db_sql.php',
  804. $cfg['DefaultTabDatabase']
  805. )
  806. );
  807. }
  808. $this->settings = PMA_arrayMergeRecursive($this->settings, $cfg);
  809. $this->checkPmaAbsoluteUri();
  810. $this->checkFontsize();
  811. // Handling of the collation must be done after merging of $cfg
  812. // (from config.inc.php) so that $cfg['DefaultConnectionCollation']
  813. // can have an effect. Note that the presence of collation
  814. // information in a cookie has priority over what is defined
  815. // in the default or user's config files.
  816. /**
  817. * @todo check validity of $_COOKIE['pma_collation_connection']
  818. */
  819. if (! empty($_COOKIE['pma_collation_connection'])) {
  820. $this->set(
  821. 'collation_connection',
  822. strip_tags($_COOKIE['pma_collation_connection'])
  823. );
  824. } else {
  825. $this->set(
  826. 'collation_connection',
  827. $this->get('DefaultConnectionCollation')
  828. );
  829. }
  830. // Now, a collation information could come from REQUEST
  831. // (an example of this: the collation selector in index.php)
  832. // so the following handles the setting of collation_connection
  833. // and later, in common.inc.php, the cookie will be set
  834. // according to this.
  835. $this->checkCollationConnection();
  836. return true;
  837. }
  838. /**
  839. * Loads user preferences and merges them with current config
  840. * must be called after control connection has been estabilished
  841. *
  842. * @return boolean
  843. */
  844. function loadUserPreferences()
  845. {
  846. // index.php should load these settings, so that phpmyadmin.css.php
  847. // will have everything avaiable in session cache
  848. $server = isset($GLOBALS['server'])
  849. ? $GLOBALS['server']
  850. : (!empty($GLOBALS['cfg']['ServerDefault'])
  851. ? $GLOBALS['cfg']['ServerDefault']
  852. : 0);
  853. $cache_key = 'server_' . $server;
  854. if ($server > 0 && !defined('PMA_MINIMUM_COMMON')) {
  855. $config_mtime = max($this->default_source_mtime, $this->source_mtime);
  856. // cache user preferences, use database only when needed
  857. if (! isset($_SESSION['cache'][$cache_key]['userprefs'])
  858. || $_SESSION['cache'][$cache_key]['config_mtime'] < $config_mtime
  859. ) {
  860. // load required libraries
  861. include_once './libraries/user_preferences.lib.php';
  862. $prefs = PMA_loadUserprefs();
  863. $_SESSION['cache'][$cache_key]['userprefs']
  864. = PMA_applyUserprefs($prefs['config_data']);
  865. $_SESSION['cache'][$cache_key]['userprefs_mtime'] = $prefs['mtime'];
  866. $_SESSION['cache'][$cache_key]['userprefs_type'] = $prefs['type'];
  867. $_SESSION['cache'][$cache_key]['config_mtime'] = $config_mtime;
  868. }
  869. } elseif ($server == 0
  870. || ! isset($_SESSION['cache'][$cache_key]['userprefs'])
  871. ) {
  872. $this->set('user_preferences', false);
  873. return;
  874. }
  875. $config_data = $_SESSION['cache'][$cache_key]['userprefs'];
  876. // type is 'db' or 'session'
  877. $this->set(
  878. 'user_preferences',
  879. $_SESSION['cache'][$cache_key]['userprefs_type']
  880. );
  881. $this->set(
  882. 'user_preferences_mtime',
  883. $_SESSION['cache'][$cache_key]['userprefs_mtime']
  884. );
  885. // backup some settings
  886. $org_fontsize = '';
  887. if (isset($this->settings['fontsize'])) {
  888. $org_fontsize = $this->settings['fontsize'];
  889. }
  890. // load config array
  891. $this->settings = PMA_arrayMergeRecursive($this->settings, $config_data);
  892. $GLOBALS['cfg'] = PMA_arrayMergeRecursive($GLOBALS['cfg'], $config_data);
  893. if (defined('PMA_MINIMUM_COMMON')) {
  894. return;
  895. }
  896. // settings below start really working on next page load, but
  897. // changes are made only in index.php so everything is set when
  898. // in frames
  899. // save theme
  900. $tmanager = $_SESSION['PMA_Theme_Manager'];
  901. if ($tmanager->getThemeCookie() || isset($_REQUEST['set_theme'])) {
  902. if ((! isset($config_data['ThemeDefault'])
  903. && $tmanager->theme->getId() != 'original')
  904. || isset($config_data['ThemeDefault'])
  905. && $config_data['ThemeDefault'] != $tmanager->theme->getId()
  906. ) {
  907. // new theme was set in common.inc.php
  908. $this->setUserValue(
  909. null,
  910. 'ThemeDefault',
  911. $tmanager->theme->getId(),
  912. 'original'
  913. );
  914. }
  915. } else {
  916. // no cookie - read default from settings
  917. if ($this->settings['ThemeDefault'] != $tmanager->theme->getId()
  918. && $tmanager->checkTheme($this->settings['ThemeDefault'])
  919. ) {
  920. $tmanager->setActiveTheme($this->settings['ThemeDefault']);
  921. $tmanager->setThemeCookie();
  922. }
  923. }
  924. // save font size
  925. if ((! isset($config_data['fontsize'])
  926. && $org_fontsize != '82%')
  927. || isset($config_data['fontsize'])
  928. && $org_fontsize != $config_data['fontsize']
  929. ) {
  930. $this->setUserValue(null, 'fontsize', $org_fontsize, '82%');
  931. }
  932. // save language
  933. if (isset($_COOKIE['pma_lang']) || isset($_POST['lang'])) {
  934. if ((! isset($config_data['lang'])
  935. && $GLOBALS['lang'] != 'en')
  936. || isset($config_data['lang'])
  937. && $GLOBALS['lang'] != $config_data['lang']
  938. ) {
  939. $this->setUserValue(null, 'lang', $GLOBALS['lang'], 'en');
  940. }
  941. } else {
  942. // read language from settings
  943. if (isset($config_data['lang']) && PMA_langSet($config_data['lang'])) {
  944. $this->setCookie('pma_lang', $GLOBALS['lang']);
  945. }
  946. }
  947. // save connection collation
  948. if (!PMA_DRIZZLE) {
  949. // just to shorten the lines
  950. $collation = 'collation_connection';
  951. if (isset($_COOKIE['pma_collation_connection'])
  952. || isset($_POST[$collation])
  953. ) {
  954. if ((! isset($config_data[$collation])
  955. && $GLOBALS[$collation] != 'utf8_general_ci')
  956. || isset($config_data[$collation])
  957. && $GLOBALS[$collation] != $config_data[$collation]
  958. ) {
  959. $this->setUserValue(
  960. null,
  961. $collation,
  962. $GLOBALS[$collation],
  963. 'utf8_general_ci'
  964. );
  965. }
  966. } else {
  967. // read collation from settings
  968. if (isset($config_data['collation_connection'])) {
  969. $GLOBALS['collation_connection']
  970. = $config_data['collation_connection'];
  971. $this->setCookie(
  972. 'pma_collation_connection',
  973. $GLOBALS['collation_connection']
  974. );
  975. }
  976. }
  977. }
  978. }
  979. /**
  980. * Sets config value which is stored in user preferences (if available)
  981. * or in a cookie.
  982. *
  983. * If user preferences are not yet initialized, option is applied to
  984. * global config and added to a update queue, which is processed
  985. * by {@link loadUserPreferences()}
  986. *
  987. * @param string $cookie_name can be null
  988. * @param string $cfg_path configuration path
  989. * @param mixed $new_cfg_value new value
  990. * @param mixed $default_value default value
  991. *
  992. * @return void
  993. */
  994. function setUserValue($cookie_name, $cfg_path, $new_cfg_value,
  995. $default_value = null
  996. ) {
  997. // use permanent user preferences if possible
  998. $prefs_type = $this->get('user_preferences');
  999. if ($prefs_type) {
  1000. include_once './libraries/user_preferences.lib.php';
  1001. if ($default_value === null) {
  1002. $default_value = PMA_arrayRead($cfg_path, $this->default);
  1003. }
  1004. PMA_persistOption($cfg_path, $new_cfg_value, $default_value);
  1005. }
  1006. if ($prefs_type != 'db' && $cookie_name) {
  1007. // fall back to cookies
  1008. if ($default_value === null) {
  1009. $default_value = PMA_arrayRead($cfg_path, $this->settings);
  1010. }
  1011. $this->setCookie($cookie_name, $new_cfg_value, $default_value);
  1012. }
  1013. PMA_arrayWrite($cfg_path, $GLOBALS['cfg'], $new_cfg_value);
  1014. PMA_arrayWrite($cfg_path, $this->settings, $new_cfg_value);
  1015. }
  1016. /**
  1017. * Reads value stored by {@link setUserValue()}
  1018. *
  1019. * @param string $cookie_name cookie name
  1020. * @param mixed $cfg_value config value
  1021. *
  1022. * @return mixed
  1023. */
  1024. function getUserValue($cookie_name, $cfg_value)
  1025. {
  1026. $cookie_exists = isset($_COOKIE) && !empty($_COOKIE[$cookie_name]);
  1027. $prefs_type = $this->get('user_preferences');
  1028. if ($prefs_type == 'db') {
  1029. // permanent user preferences value exists, remove cookie
  1030. if ($cookie_exists) {
  1031. $this->removeCookie($cookie_name);
  1032. }
  1033. } else if ($cookie_exists) {
  1034. return $_COOKIE[$cookie_name];
  1035. }
  1036. // return value from $cfg array
  1037. return $cfg_value;
  1038. }
  1039. /**
  1040. * set source
  1041. *
  1042. * @param string $source source
  1043. *
  1044. * @return void
  1045. */
  1046. function setSource($source)
  1047. {
  1048. $this->source = trim($source);
  1049. }
  1050. /**
  1051. * check config source
  1052. *
  1053. * @return boolean whether source is valid or not
  1054. */
  1055. function checkConfigSource()
  1056. {
  1057. if (! $this->getSource()) {
  1058. // no configuration file set at all
  1059. return false;
  1060. }
  1061. if (! file_exists($this->getSource())) {
  1062. $this->source_mtime = 0;
  1063. return false;
  1064. }
  1065. if (! is_readable($this->getSource())) {
  1066. // manually check if file is readable
  1067. // might be bug #3059806 Supporting running from CIFS/Samba shares
  1068. $contents = false;
  1069. $handle = @fopen($this->getSource(), 'r');
  1070. if ($handle !== false) {
  1071. $contents = @fread($handle, 1); // reading 1 byte is enough to test
  1072. @fclose($handle);
  1073. }
  1074. if ($contents === false) {
  1075. $this->source_mtime = 0;
  1076. PMA_fatalError(
  1077. sprintf(
  1078. function_exists('__')
  1079. ? __('Existing configuration file (%s) is not readable.')
  1080. : 'Existing configuration file (%s) is not readable.',
  1081. $this->getSource()
  1082. )
  1083. );
  1084. return false;
  1085. }
  1086. }
  1087. return true;
  1088. }
  1089. /**
  1090. * verifies the permissions on config file (if asked by configuration)
  1091. * (must be called after config.inc.php has been merged)
  1092. *
  1093. * @return void
  1094. */
  1095. function checkPermissions()
  1096. {
  1097. // Check for permissions (on platforms that support it):
  1098. if ($this->get('CheckConfigurationPermissions')) {
  1099. $perms = @fileperms($this->getSource());
  1100. if (!($perms === false) && ($perms & 2)) {
  1101. // This check is normally done after loading configuration
  1102. $this->checkWebServerOs();
  1103. if ($this->get('PMA_IS_WINDOWS') == 0) {
  1104. $this->source_mtime = 0;
  1105. PMA_fatalError(
  1106. __(
  1107. 'Wrong permissions on configuration file, '
  1108. . 'should not be world writable!'
  1109. )
  1110. );
  1111. }
  1112. }
  1113. }
  1114. }
  1115. /**
  1116. * returns specific config setting
  1117. *
  1118. * @param string $setting config setting
  1119. *
  1120. * @return mixed value
  1121. */
  1122. function get($setting)
  1123. {
  1124. if (isset($this->settings[$setting])) {
  1125. return $this->settings[$setting];
  1126. }
  1127. return null;
  1128. }
  1129. /**
  1130. * sets configuration variable
  1131. *
  1132. * @param string $setting configuration option
  1133. * @param mixed $value new value for configuration option
  1134. *
  1135. * @return void
  1136. */
  1137. function set($setting, $value)
  1138. {
  1139. if (! isset($this->settings[$setting])
  1140. || $this->settings[$setting] !== $value
  1141. ) {
  1142. $this->settings[$setting] = $value;
  1143. $this->set_mtime = time();
  1144. }
  1145. }
  1146. /**
  1147. * returns source for current config
  1148. *
  1149. * @return string config source
  1150. */
  1151. function getSource()
  1152. {
  1153. return $this->source;
  1154. }
  1155. /**
  1156. * returns a unique value to force a CSS reload if either the config
  1157. * or the theme changes
  1158. * must also check the pma_fontsize cookie in case there is no
  1159. * config file
  1160. *
  1161. * @return int Summary of unix timestamps and fontsize,
  1162. * to be unique on theme parameters change
  1163. */
  1164. function getThemeUniqueValue()
  1165. {
  1166. if (null !== $this->get('fontsize')) {
  1167. $fontsize = intval($this->get('fontsize'));
  1168. } elseif (isset($_COOKIE['pma_fontsize'])) {
  1169. $fontsize = intval($_COOKIE['pma_fontsize']);
  1170. } else {
  1171. $fontsize = 0;
  1172. }
  1173. return (
  1174. $fontsize +
  1175. $this->source_mtime +
  1176. $this->default_source_mtime +
  1177. $this->get('user_preferences_mtime') +
  1178. $_SESSION['PMA_Theme']->mtime_info +
  1179. $_SESSION['PMA_Theme']->filesize_info);
  1180. }
  1181. /**
  1182. * $cfg['PmaAbsoluteUri'] is a required directive else cookies won't be
  1183. * set properly and, depending on browsers, inserting or updating a
  1184. * record might fail
  1185. *
  1186. * @return bool
  1187. */
  1188. function checkPmaAbsoluteUri()
  1189. {
  1190. // Setup a default value to let the people and lazy sysadmins work anyway,
  1191. // they'll get an error if the autodetect code doesn't work
  1192. $pma_absolute_uri = $this->get('PmaAbsoluteUri');
  1193. $is_https = $this->detectHttps();
  1194. if (strlen($pma_absolute_uri) < 5) {
  1195. $url = array();
  1196. // If we don't have scheme, we didn't have full URL so we need to
  1197. // dig deeper
  1198. if (empty($url['scheme'])) {
  1199. // Scheme
  1200. if ($is_https) {
  1201. $url['scheme'] = 'https';
  1202. } else {
  1203. $url['scheme'] = 'http';
  1204. }
  1205. // Host and port
  1206. if (PMA_getenv('HTTP_HOST')) {
  1207. // Prepend the scheme before using parse_url() since this
  1208. // is not part of the RFC2616 Host request-header
  1209. $parsed_url = parse_url(
  1210. $url['scheme'] . '://' . PMA_getenv('HTTP_HOST')
  1211. );
  1212. if (!empty($parsed_url['host'])) {
  1213. $url = $parsed_url;
  1214. } else {
  1215. $url['host'] = PMA_getenv('HTTP_HOST');
  1216. }
  1217. } elseif (PMA_getenv('SERVER_NAME')) {
  1218. $url['host'] = PMA_getenv('SERVER_NAME');
  1219. } else {
  1220. $this->error_pma_uri = true;
  1221. return false;
  1222. }
  1223. // If we didn't set port yet...
  1224. if (empty($url['port']) && PMA_getenv('SERVER_PORT')) {
  1225. $url['port'] = PMA_getenv('SERVER_PORT');
  1226. }
  1227. // And finally the path could be already set from REQUEST_URI
  1228. if (empty($url['path'])) {
  1229. // we got a case with nginx + php-fpm where PHP_SELF
  1230. // was not set, so PMA_PHP_SELF was not set as well
  1231. if (isset($GLOBALS['PMA_PHP_SELF'])) {
  1232. $path = parse_url($GLOBALS['PMA_PHP_SELF']);
  1233. } else {
  1234. $path = parse_url(PMA_getenv('REQUEST_URI'));
  1235. }
  1236. $url['path'] = $path['path'];
  1237. }
  1238. }
  1239. // Make url from parts we have
  1240. $pma_absolute_uri = $url['scheme'] . '://';
  1241. // Was there user information?
  1242. if (!empty($url['user'])) {
  1243. $pma_absolute_uri .= $url['user'];
  1244. if (!empty($url['pass'])) {
  1245. $pma_absolute_uri .= ':' . $url['pass'];
  1246. }
  1247. $pma_absolute_uri .= '@';
  1248. }
  1249. // Add hostname
  1250. $pma_absolute_uri .= $url['host'];
  1251. // Add port, if it not the default one
  1252. if (! empty($url['port'])
  1253. && (($url['scheme'] == 'http' && $url['port'] != 80)
  1254. || ($url['scheme'] == 'https' && $url['port'] != 443))
  1255. ) {
  1256. $pma_absolute_uri .= ':' . $url['port'];
  1257. }
  1258. // And finally path, without script name, the 'a' is there not to
  1259. // strip our directory, when path is only /pmadir/ without filename.
  1260. // Backslashes returned by Windows have to be changed.
  1261. // Only replace backslashes by forward slashes if on Windows,
  1262. // as the backslash could be valid on a non-Windows system.
  1263. $this->checkWebServerOs();
  1264. if ($this->get('PMA_IS_WINDOWS') == 1) {
  1265. $path = str_replace("\\", "/", dirname($url['path'] . 'a'));
  1266. } else {
  1267. $path = dirname($url['path'] . 'a');
  1268. }
  1269. // To work correctly within javascript
  1270. if (defined('PMA_PATH_TO_BASEDIR') && PMA_PATH_TO_BASEDIR == '../') {
  1271. if ($this->get('PMA_IS_WINDOWS') == 1) {
  1272. $path = str_replace("\\", "/", dirname($path));
  1273. } else {
  1274. $path = dirname($path);
  1275. }
  1276. }
  1277. // PHP's dirname function would have returned a dot
  1278. // when $path contains no slash
  1279. if ($path == '.') {
  1280. $path = '';
  1281. }
  1282. // in vhost situations, there could be already an ending slash
  1283. if (substr($path, -1) != '/') {
  1284. $path .= '/';
  1285. }
  1286. $pma_absolute_uri .= $path;
  1287. // This is to handle the case of a reverse proxy
  1288. if ($this->get('ForceSSL')) {
  1289. $this->set('PmaAbsoluteUri', $pma_absolute_uri);
  1290. $pma_absolute_uri = $this->getSSLUri();
  1291. $this->isHttps();
  1292. }
  1293. // We used to display a warning if PmaAbsoluteUri wasn't set, but now
  1294. // the autodetect code works well enough that we don't display the
  1295. // warning at all. The user can still set PmaAbsoluteUri manually.
  1296. } else {
  1297. // The URI is specified, however users do often specify this
  1298. // wrongly, so we try to fix this.
  1299. // Adds a trailing slash et the end of the phpMyAdmin uri if it
  1300. // does not exist.
  1301. if (substr($pma_absolute_uri, -1) != '/') {
  1302. $pma_absolute_uri .= '/';
  1303. }
  1304. // If URI doesn't start with http:// or https://, we will add
  1305. // this.
  1306. if (substr($pma_absolute_uri, 0, 7) != 'http://'
  1307. && substr($pma_absolute_uri, 0, 8) != 'https://'
  1308. ) {
  1309. $pma_absolute_uri
  1310. = ($is_https ? 'https' : 'http')
  1311. . ':' . (substr($pma_absolute_uri, 0, 2) == '//' ? '' : '//')
  1312. . $pma_absolute_uri;
  1313. }
  1314. }
  1315. $this->set('PmaAbsoluteUri', $pma_absolute_uri);
  1316. }
  1317. /**
  1318. * Converts currently used PmaAbsoluteUri to SSL based variant.
  1319. *
  1320. * @return String witch adjusted URI
  1321. */
  1322. function getSSLUri()
  1323. {
  1324. // grab current URL
  1325. $url = $this->get('PmaAbsoluteUri');
  1326. // Parse current URL
  1327. $parsed = parse_url($url);
  1328. // In case parsing has failed do stupid string replacement
  1329. if ($parsed === false) {
  1330. // Replace http protocol
  1331. return preg_replace('@^http:@', 'https:', $url);
  1332. }
  1333. // Reconstruct URL using parsed parts
  1334. return 'https://' . $parsed['host'] . ':443' . $parsed['path'];
  1335. }
  1336. /**
  1337. * check selected collation_connection
  1338. *
  1339. * @todo check validity of $_REQUEST['collation_connection']
  1340. *
  1341. * @return void
  1342. */
  1343. function checkCollationConnection()
  1344. {
  1345. if (! empty($_REQUEST['collation_connection'])) {
  1346. $this->set(
  1347. 'collation_connection',
  1348. strip_tags($_REQUEST['collation_connection'])
  1349. );
  1350. }
  1351. }
  1352. /**
  1353. * checks for font size configuration, and sets font size as requested by user
  1354. *
  1355. * @return void
  1356. */
  1357. function checkFontsize()
  1358. {
  1359. $new_fontsize = '';
  1360. if (isset($_GET['set_fontsize'])) {
  1361. $new_f

Large files files are truncated, but you can click here to view the full file