Merge branch 'origin/master' into Weblate.
[phpmyadmin.git] / changelog.php
blobf8b7f7f57aa3cbac3f25a5067c38df01bb0254cb
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Simple script to set correct charset for changelog
6 * @package PhpMyAdmin
7 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Response;
12 if (! defined('ROOT_PATH')) {
13 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
16 /**
17 * Gets core libraries and defines some variables
19 require ROOT_PATH . 'libraries/common.inc.php';
21 $response = Response::getInstance();
22 $response->disable();
23 $response->getHeader()->sendHttpHeaders();
25 $filename = CHANGELOG_FILE;
27 /**
28 * Read changelog.
30 // Check if the file is available, some distributions remove these.
31 if (@is_readable($filename)) {
32 // Test if the if is in a compressed format
33 if (substr($filename, -3) == '.gz') {
34 ob_start();
35 readgzfile($filename);
36 $changelog = ob_get_contents();
37 ob_end_clean();
38 } else {
39 $changelog = file_get_contents($filename);
41 } else {
42 printf(
43 __(
44 'The %s file is not available on this system, please visit ' .
45 '%s for more information.'
47 $filename,
48 '<a href="https://www.phpmyadmin.net/">phpmyadmin.net</a>'
50 exit;
53 /**
54 * Whole changelog in variable.
56 $changelog = htmlspecialchars($changelog);
58 $github_url = 'https://github.com/phpmyadmin/phpmyadmin/';
59 $faq_url = 'https://docs.phpmyadmin.net/en/latest/faq.html';
61 $replaces = [
62 '@(https?://[./a-zA-Z0-9.-_-]*[/a-zA-Z0-9_])@'
63 => '<a href="url.php?url=\\1">\\1</a>',
65 // mail address
66 '/([0-9]{4}-[0-9]{2}-[0-9]{2}) (.+[^ ]) +&lt;(.*@.*)&gt;/i'
67 => '\\1 <a href="mailto:\\3">\\2</a>',
69 // FAQ entries
70 '/FAQ ([0-9]+)\.([0-9a-z]+)/i'
71 => '<a href="url.php?url=' . $faq_url . '#faq\\1-\\2">FAQ \\1.\\2</a>',
73 // GitHub issues
74 '/issue\s*#?([0-9]{4,5}) /i'
75 => '<a href="url.php?url=' . $github_url . 'issues/\\1">issue #\\1</a> ',
77 // CVE/CAN entries
78 '/((CAN|CVE)-[0-9]+-[0-9]+)/'
79 => '<a href="url.php?url=https://cve.mitre.org/cgi-bin/cvename.cgi?name=\\1">\\1</a>',
81 // PMASAentries
82 '/(PMASA-[0-9]+-[0-9]+)/'
83 => '<a href="url.php?url=https://www.phpmyadmin.net/security/\\1/">\\1</a>',
85 // Highlight releases (with links)
86 '/([0-9]+)\.([0-9]+)\.([0-9]+)\.0 (\([0-9-]+\))/'
87 => '<a name="\\1_\\2_\\3"></a>'
88 . '<a href="url.php?url=' . $github_url . 'commits/RELEASE_\\1_\\2_\\3">'
89 . '\\1.\\2.\\3.0 \\4</a>',
90 '/([0-9]+)\.([0-9]+)\.([0-9]+)\.([1-9][0-9]*) (\([0-9-]+\))/'
91 => '<a name="\\1_\\2_\\3_\\4"></a>'
92 . '<a href="url.php?url=' . $github_url . 'commits/RELEASE_\\1_\\2_\\3_\\4">'
93 . '\\1.\\2.\\3.\\4 \\5</a>',
95 // Highlight releases (not linkable)
96 '/( ### )(.*)/'
97 => '\\1<b>\\2</b>',
99 // Links target and rel
100 '/a href="/' => 'a target="_blank" rel="noopener noreferrer" href="'
104 header('Content-type: text/html; charset=utf-8');
106 <!DOCTYPE HTML>
107 <html lang="en" dir="ltr">
108 <head>
109 <link rel="icon" href="favicon.ico" type="image/x-icon">
110 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
111 <title>phpMyAdmin - ChangeLog</title>
112 <meta charset="utf-8">
113 </head>
114 <body>
115 <h1>phpMyAdmin - ChangeLog</h1>
116 <?php
117 echo '<pre>';
118 echo preg_replace(array_keys($replaces), $replaces, $changelog);
119 echo '</pre>';
121 </body>
122 </html>