2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Simple script to set correct charset for changelog
8 declare(strict_types
=1);
10 use PhpMyAdmin\Response
;
11 use PhpMyAdmin\Template
;
13 if (! defined('ROOT_PATH')) {
14 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
18 * Gets core libraries and defines some variables
20 require ROOT_PATH
. 'libraries/common.inc.php';
22 /** @var Template $template */
23 $template = $containerBuilder->get('template');
25 $response = Response
::getInstance();
27 $response->getHeader()->sendHttpHeaders();
29 $filename = CHANGELOG_FILE
;
34 // Check if the file is available, some distributions remove these.
35 if (@is_readable
($filename)) {
36 // Test if the if is in a compressed format
37 if (substr($filename, -3) == '.gz') {
39 readgzfile($filename);
40 $changelog = ob_get_contents();
43 $changelog = file_get_contents($filename);
48 'The %s file is not available on this system, please visit ' .
49 '%s for more information.'
52 '<a href="https://www.phpmyadmin.net/">phpmyadmin.net</a>'
58 * Whole changelog in variable.
60 $changelog = htmlspecialchars($changelog);
62 $github_url = 'https://github.com/phpmyadmin/phpmyadmin/';
63 $faq_url = 'https://docs.phpmyadmin.net/en/latest/faq.html';
66 '@(https?://[./a-zA-Z0-9.-_-]*[/a-zA-Z0-9_])@'
67 => '<a href="url.php?url=\\1">\\1</a>',
70 '/([0-9]{4}-[0-9]{2}-[0-9]{2}) (.+[^ ]) +<(.*@.*)>/i'
71 => '\\1 <a href="mailto:\\3">\\2</a>',
74 '/FAQ ([0-9]+)\.([0-9a-z]+)/i'
75 => '<a href="url.php?url=' . $faq_url . '#faq\\1-\\2">FAQ \\1.\\2</a>',
78 '/issue\s*#?([0-9]{4,5}) /i'
79 => '<a href="url.php?url=' . $github_url . 'issues/\\1">issue #\\1</a> ',
82 '/((CAN|CVE)-[0-9]+-[0-9]+)/'
83 => '<a href="url.php?url=https://cve.mitre.org/cgi-bin/cvename.cgi?name=\\1">\\1</a>',
86 '/(PMASA-[0-9]+-[0-9]+)/'
87 => '<a href="url.php?url=https://www.phpmyadmin.net/security/\\1/">\\1</a>',
89 // Highlight releases (with links)
90 '/([0-9]+)\.([0-9]+)\.([0-9]+)\.0 (\([0-9-]+\))/'
91 => '<a id="\\1_\\2_\\3"></a>'
92 . '<a href="url.php?url=' . $github_url . 'commits/RELEASE_\\1_\\2_\\3">'
93 . '\\1.\\2.\\3.0 \\4</a>',
94 '/([0-9]+)\.([0-9]+)\.([0-9]+)\.([1-9][0-9]*) (\([0-9-]+\))/'
95 => '<a id="\\1_\\2_\\3_\\4"></a>'
96 . '<a href="url.php?url=' . $github_url . 'commits/RELEASE_\\1_\\2_\\3_\\4">'
97 . '\\1.\\2.\\3.\\4 \\5</a>',
99 // Highlight releases (not linkable)
103 // Links target and rel
104 '/a href="/' => 'a target="_blank" rel="noopener noreferrer" href="',
108 header('Content-type: text/html; charset=utf-8');
110 echo $template->render('changelog', [
111 'changelog' => preg_replace(array_keys($replaces), $replaces, $changelog),