diff --git a/LICENSE b/LICENSE index d85d0841..da5082c1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,11 +1,13 @@ +MIT License + Copyright (c) 2017-2018 Kevin Papst Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -15,5 +17,5 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/src/Controller/Admin/AboutController.php b/src/Controller/Admin/AboutController.php new file mode 100644 index 00000000..6ee7ec92 --- /dev/null +++ b/src/Controller/Admin/AboutController.php @@ -0,0 +1,148 @@ +projectDirectory = $projectDirectory; + } + + /** + * @Route(path="", name="about", methods={"GET"}) + + * @param Request $request + * @return \Symfony\Component\HttpFoundation\Response + */ + public function indexAction(Request $request) + { + $phpInfo = $this->getPhpInfo(); + unset($phpInfo[0]); + unset($phpInfo[1]); + + $ini = [ + 'allow_url_fopen', + 'allow_url_include', + 'default_charset', + 'default_mimetype', + 'display_errors', + 'error_log', + 'error_reporting', + 'log_errors', + 'max_execution_time', + 'memory_limit', + 'open_basedir', + 'post_max_size', + 'sys_temp_dir', + ]; + + $settings = []; + foreach ($ini as $name) { + try { + $settings[$name] = ini_get($name); + } catch (\Exception $ex) { + $settings[$name] = "Couldn't load ini setting: " . $ex->getMessage(); + } + } + + return $this->render('admin/system.html.twig', [ + 'modules' => get_loaded_extensions(), + 'dotenv' => [ + 'APP_ENV' => getenv('APP_ENV'), + 'DATABASE_PREFIX' => getenv('DATABASE_PREFIX'), + 'MAILER_FROM' => getenv('MAILER_FROM'), + 'MAILER_URL' => getenv('MAILER_URL'), + 'CORS_ALLOW_ORIGIN' => getenv('CORS_ALLOW_ORIGIN'), + ], + 'info' => $phpInfo, + 'settings' => $settings, + 'license' => $this->getLicense(), + ]); + } + + /** + * @return string + */ + protected function getLicense() + { + $filename = $this->projectDirectory . '/LICENSE'; + + try { + $license = file_get_contents($filename); + } catch (\Exception $ex) { + $license = false; + } + + if (false === $license) { + $license = 'Failed reading license file: ' . $filename . '. ' . + 'Check this instead: ' . Constants::GITHUB . 'blob/master/LICENSE'; + } + + return $license; + } + + /** + * @author https://php.net/manual/en/function.phpinfo.php#117961 + * @return array + */ + private function getPhpInfo() + { + $plainText = function ($input) { + return trim(html_entity_decode(strip_tags($input))); + }; + + ob_start(); + phpinfo(1); + + $phpinfo = ['phpinfo' => []]; + + if (preg_match_all( + '#(?:(?:)?(.*?)(?:<\/a>)?<\/h2>)|' . + '(?:(.*?)\s*(?:(.*?)\s*(?:(.*?)\s*)?)?)#s', + ob_get_clean(), + $matches, + PREG_SET_ORDER + )) { + foreach ($matches as $match) { + $fn = $plainText; + if (isset($match[3])) { + $keys1 = array_keys($phpinfo); + $phpinfo[end($keys1)][$fn($match[2])] = isset($match[4]) ? [$fn($match[3]), $fn($match[4])] : $fn($match[3]); + } else { + $keys1 = array_keys($phpinfo); + $phpinfo[end($keys1)][] = $fn($match[2]); + } + } + } + + return $phpinfo['phpinfo']; + } +} diff --git a/templates/admin/system.html.twig b/templates/admin/system.html.twig new file mode 100644 index 00000000..0a664385 --- /dev/null +++ b/templates/admin/system.html.twig @@ -0,0 +1,112 @@ +{% extends 'base.html.twig' %} + +{% block page_title %}{{ 'about.title'|trans({}, 'about') }}{% endblock %} +{% block page_subtitle %}{{ 'about.subtitle'|trans({}, 'about') }}{% endblock %} + +{% block main %} +
+
+ + +
+
+{% endblock %} diff --git a/templates/sidebar/home.html.twig b/templates/sidebar/home.html.twig index 53bf0665..b072b89e 100644 --- a/templates/sidebar/home.html.twig +++ b/templates/sidebar/home.html.twig @@ -28,6 +28,18 @@ + {% if is_granted('ROLE_SUPER_ADMIN') %} +
  • + + + + + +
  • + {% endif %}


    Made with ♥ by Kevin Papst and great contributors.

    diff --git a/tests/Controller/Admin/AboutControllerTest.php b/tests/Controller/Admin/AboutControllerTest.php new file mode 100644 index 00000000..afc5bccc --- /dev/null +++ b/tests/Controller/Admin/AboutControllerTest.php @@ -0,0 +1,38 @@ +assertUrlIsSecured('/admin/about'); + $this->assertUrlIsSecuredForRole(User::ROLE_ADMIN, '/admin/about'); + } + + public function testIndexAction() + { + $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN); + $this->assertAccessIsGranted($client, '/admin/about'); + + $result = $client->getCrawler()->filter('div.nav-tabs-custom ul.nav.nav-tabs li'); + $this->assertEquals(3, count($result)); + + $result = $client->getCrawler()->filter('div.nav-tabs-custom div.tab-content div.tab-pane'); + $this->assertEquals(3, count($result)); + } +} diff --git a/translations/about.de.xliff b/translations/about.de.xliff new file mode 100644 index 00000000..d39e8fda --- /dev/null +++ b/translations/about.de.xliff @@ -0,0 +1,15 @@ + + + + + + about.title + Über Kimai + + + about.subtitle + System Informationen + + + + diff --git a/translations/about.en.xliff b/translations/about.en.xliff new file mode 100644 index 00000000..336300ca --- /dev/null +++ b/translations/about.en.xliff @@ -0,0 +1,15 @@ + + + + + + about.title + About Kimai + + + about.subtitle + System information + + + +