PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/changelog.php

https://gitlab.com/trungthao379/phpmyadmin
PHP | 160 lines | 104 code | 24 blank | 32 comment | 6 complexity | 44ba8c5151dfe355441a4c345df4c05c MD5 | raw file
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Simple script to set correct charset for changelog
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. /**
  9. * Gets core libraries and defines some variables
  10. */
  11. require 'libraries/common.inc.php';
  12. $response = PMA\libraries\Response::getInstance();
  13. $response->disable();
  14. $filename = CHANGELOG_FILE;
  15. /**
  16. * Read changelog.
  17. */
  18. // Check if the file is available, some distributions remove these.
  19. if (@is_readable($filename)) {
  20. // Test if the if is in a compressed format
  21. if (substr($filename, -3) == '.gz') {
  22. ob_start();
  23. readgzfile($filename);
  24. $changelog = ob_get_contents();
  25. ob_end_clean();
  26. } else {
  27. $changelog = file_get_contents($filename);
  28. }
  29. } else {
  30. printf(
  31. __(
  32. 'The %s file is not available on this system, please visit '
  33. . 'www.phpmyadmin.net for more information.'
  34. ),
  35. $filename
  36. );
  37. exit;
  38. }
  39. /**
  40. * Whole changelog in variable.
  41. */
  42. $changelog = htmlspecialchars($changelog);
  43. $tracker_url = 'https://sourceforge.net/support/tracker.php?aid=\\1';
  44. $tracker_url_bug = 'https://sourceforge.net/p/phpmyadmin/bugs/\\1/';
  45. $tracker_url_rfe = 'https://sourceforge.net/p/phpmyadmin/feature-requests/\\1/';
  46. $tracker_url_patch = 'https://sourceforge.net/p/phpmyadmin/patches/\\1/';
  47. $github_url = 'https://github.com/phpmyadmin/phpmyadmin/';
  48. $faq_url = 'https://docs.phpmyadmin.net/en/latest/faq.html';
  49. $replaces = array(
  50. '@(https?://[./a-zA-Z0-9.-_-]*[/a-zA-Z0-9_])@'
  51. => '<a href="url.php?url=\\1">\\1</a>',
  52. // sourceforge users
  53. '/([0-9]{4}-[0-9]{2}-[0-9]{2}) (.+[^ ]) +&lt;(.*)@users.sourceforge.net&gt;/i'
  54. => '\\1 <a href="url.php?url=https://sourceforge.net/users/\\3/">\\2</a>',
  55. '/thanks to ([^\(\r\n]+) \(([-\w]+)\)/i'
  56. => 'thanks to <a href="url.php?url=https://sourceforge.net/users/\\2/">\\1</a>',
  57. '/thanks to ([^\(\r\n]+) -\s+([-\w]+)/i'
  58. => 'thanks to <a href="url.php?url=https://sourceforge.net/users/\\2/">\\1</a>',
  59. // mail address
  60. '/([0-9]{4}-[0-9]{2}-[0-9]{2}) (.+[^ ]) +&lt;(.*@.*)&gt;/i'
  61. => '\\1 <a href="mailto:\\3">\\2</a>',
  62. // linking patches
  63. '/patch\s*#?([0-9]{6,})/i'
  64. => '<a href="url.php?url=' . $tracker_url . '">patch #\\1</a>',
  65. // linking RFE
  66. '/(?:rfe|feature)\s*#?([0-9]{6,})/i'
  67. => '<a href="url.php?url=https://sourceforge.net/support/tracker.php?aid=\\1">RFE #\\1</a>',
  68. // linking files
  69. '/(\s+)([\\/a-z_0-9\.]+\.(?:php3?|html|pl|js|sh))/i'
  70. => '\\1<a href="url.php?url=' . $github_url . 'commits/HEAD/\\2">\\2</a>',
  71. // FAQ entries
  72. '/FAQ ([0-9]+)\.([0-9a-z]+)/i'
  73. => '<a href="url.php?url=' . $faq_url . '#faq\\1-\\2">FAQ \\1.\\2</a>',
  74. // linking bugs
  75. '/bug\s*#?([0-9]{6,})/i'
  76. => '<a href="url.php?url=https://sourceforge.net/support/tracker.php?aid=\\1">bug #\\1</a>',
  77. // all other 6+ digit numbers are treated as bugs
  78. '/(?<!bug|RFE|patch) #?([0-9]{6,})/i'
  79. => '<a href="url.php?url=' . $tracker_url . '">bug #\\1</a>',
  80. // GitHub issues
  81. '/issue\s*#?([0-9]{4,5}) /i'
  82. => '<a href="url.php?url=' . $github_url . 'issues/\\1">issue #\\1</a> ',
  83. // transitioned SF.net project bug/rfe/patch links
  84. // by the time we reach 6-digit numbers, we can probably retire the above links
  85. '/patch\s*#?([0-9]{4,5}) /i'
  86. => '<a href="url.php?url=' . $tracker_url_patch . '">patch #\\1</a> ',
  87. '/(?:rfe|feature)\s*#?([0-9]{4,5}) /i'
  88. => '<a href="url.php?url=' . $tracker_url_rfe . '">RFE #\\1</a> ',
  89. '/bug\s*#?([0-9]{4,5}) /i'
  90. => '<a href="url.php?url=' . $tracker_url_bug . '">bug #\\1</a> ',
  91. '/(?<!bug|RFE|patch) #?([0-9]{4,5}) /i'
  92. => '<a href="url.php?url=' . $tracker_url_bug . '">bug #\\1</a> ',
  93. // CVE/CAN entries
  94. '/((CAN|CVE)-[0-9]+-[0-9]+)/'
  95. => '<a href="url.php?url=https://cve.mitre.org/cgi-bin/cvename.cgi?name=\\1">\\1</a>',
  96. // PMASAentries
  97. '/(PMASA-[0-9]+-[0-9]+)/'
  98. => '<a href="url.php?url=https://www.phpmyadmin.net/security/\\1/">\\1</a>',
  99. // Highlight releases (with links)
  100. '/([0-9]+)\.([0-9]+)\.([0-9]+)\.0 (\([0-9-]+\))/'
  101. => '<a name="\\1_\\2_\\3"></a>'
  102. . '<a href="url.php?url=' . $github_url . 'commits/RELEASE_\\1_\\2_\\3">'
  103. . '\\1.\\2.\\3.0 \\4</a>',
  104. '/([0-9]+)\.([0-9]+)\.([0-9]+)\.([1-9][0-9]*) (\([0-9-]+\))/'
  105. => '<a name="\\1_\\2_\\3_\\4"></a>'
  106. . '<a href="url.php?url=' . $github_url . 'commits/RELEASE_\\1_\\2_\\3_\\4">'
  107. . '\\1.\\2.\\3.\\4 \\5</a>',
  108. // Highlight releases (not linkable)
  109. '/( ### )(.*)/'
  110. => '\\1<b>\\2</b>',
  111. );
  112. header('Content-type: text/html; charset=utf-8');
  113. ?>
  114. <!DOCTYPE HTML>
  115. <html lang="en" dir="ltr">
  116. <head>
  117. <link rel="icon" href="favicon.ico" type="image/x-icon" />
  118. <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
  119. <title>phpMyAdmin - ChangeLog</title>
  120. <meta charset="utf-8" />
  121. </head>
  122. <body>
  123. <h1>phpMyAdmin - ChangeLog</h1>
  124. <?php
  125. echo '<pre>';
  126. echo preg_replace(array_keys($replaces), $replaces, $changelog);
  127. echo '</pre>';
  128. ?>
  129. <script type="text/javascript">
  130. var links = document.getElementsByTagName("a");
  131. for(var i = 0; i < links.length; i++) {
  132. links[i].target = "_blank";
  133. }
  134. </script>
  135. </body>
  136. </html>