From 04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 9 Jan 2020 10:55:03 +0100 Subject: phpmyadmin working --- srcs/phpmyadmin/changelog.php | 112 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 srcs/phpmyadmin/changelog.php (limited to 'srcs/phpmyadmin/changelog.php') diff --git a/srcs/phpmyadmin/changelog.php b/srcs/phpmyadmin/changelog.php new file mode 100644 index 0000000..c706dd5 --- /dev/null +++ b/srcs/phpmyadmin/changelog.php @@ -0,0 +1,112 @@ +get('template'); + +$response = Response::getInstance(); +$response->disable(); +$response->getHeader()->sendHttpHeaders(); + +$filename = CHANGELOG_FILE; + +/** + * Read changelog. + */ +// Check if the file is available, some distributions remove these. +if (@is_readable($filename)) { + // Test if the if is in a compressed format + if (substr($filename, -3) == '.gz') { + ob_start(); + readgzfile($filename); + $changelog = ob_get_contents(); + ob_end_clean(); + } else { + $changelog = file_get_contents($filename); + } +} else { + printf( + __( + 'The %s file is not available on this system, please visit ' . + '%s for more information.' + ), + $filename, + 'phpmyadmin.net' + ); + exit; +} + +/** + * Whole changelog in variable. + */ +$changelog = htmlspecialchars($changelog); + +$github_url = 'https://github.com/phpmyadmin/phpmyadmin/'; +$faq_url = 'https://docs.phpmyadmin.net/en/latest/faq.html'; + +$replaces = [ + '@(https?://[./a-zA-Z0-9.-_-]*[/a-zA-Z0-9_])@' + => '\\1', + + // mail address + '/([0-9]{4}-[0-9]{2}-[0-9]{2}) (.+[^ ]) +<(.*@.*)>/i' + => '\\1 \\2', + + // FAQ entries + '/FAQ ([0-9]+)\.([0-9a-z]+)/i' + => 'FAQ \\1.\\2', + + // GitHub issues + '/issue\s*#?([0-9]{4,5}) /i' + => 'issue #\\1 ', + + // CVE/CAN entries + '/((CAN|CVE)-[0-9]+-[0-9]+)/' + => '\\1', + + // PMASAentries + '/(PMASA-[0-9]+-[0-9]+)/' + => '\\1', + + // Highlight releases (with links) + '/([0-9]+)\.([0-9]+)\.([0-9]+)\.0 (\([0-9-]+\))/' + => '' + . '' + . '\\1.\\2.\\3.0 \\4', + '/([0-9]+)\.([0-9]+)\.([0-9]+)\.([1-9][0-9]*) (\([0-9-]+\))/' + => '' + . '' + . '\\1.\\2.\\3.\\4 \\5', + + // Highlight releases (not linkable) + '/( ### )(.*)/' + => '\\1\\2', + + // Links target and rel + '/a href="/' => 'a target="_blank" rel="noopener noreferrer" href="', + +]; + +header('Content-type: text/html; charset=utf-8'); + +echo $template->render('changelog', [ + 'changelog' => preg_replace(array_keys($replaces), $replaces, $changelog), +]); -- cgit