Phpserververmonitor > Service consultation > Add an not logged page to view statistics for a website or a service

[+] Allows to retrieve website or service by its own label instead of its ID.
[+] Add a specific AbstractConsultController for customizing some variables passed to the main template body.tpl.html
[+] Add Logo and name Openscop in the main navar but only for page module ConsultController.php
[+] Add some french translations for these features
This commit is contained in:
Martin Massé 2020-10-30 17:27:06 +01:00
parent 5c5d980bd3
commit 55da4cb9c6
13 changed files with 1103 additions and 452 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@ __MACOSX/
.DS_Store
.buildpath
.settings/
.ddev/

View File

@ -18,3 +18,9 @@ AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
#Rule to avoid some characters in urls
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+[a-zàâäéèêëîïôöûüA-Z0-9-\-\'\$\*\µ\§\£\€\:\(\)\,\;\.\!\<\^\{\}\°]+)$ ?mod=consult&action=view&ip=$1 [QSA,L]

314
composer.lock generated
View File

@ -81,16 +81,16 @@
},
{
"name": "paragonie/random_compat",
"version": "v2.0.18",
"version": "v2.0.19",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db"
"reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/0a58ef6e3146256cc3dc7cc393927bcc7d1b72db",
"reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/446fc9faa5c2a9ddf65eb7121c0af7e857295241",
"reference": "446fc9faa5c2a9ddf65eb7121c0af7e857295241",
"shasum": ""
},
"require": {
@ -126,7 +126,7 @@
"pseudorandom",
"random"
],
"time": "2019-01-03T20:59:08+00:00"
"time": "2020-10-15T10:06:57+00:00"
},
{
"name": "php-pushover/php-pushover",
@ -160,21 +160,22 @@
},
{
"name": "phpmailer/phpmailer",
"version": "v6.1.3",
"version": "v6.1.8",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "a25ae38e03de4ee4031725498a600012364787c7"
"reference": "917ab212fa00dc6eacbb26e8bc387ebe40993bc1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/a25ae38e03de4ee4031725498a600012364787c7",
"reference": "a25ae38e03de4ee4031725498a600012364787c7",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/917ab212fa00dc6eacbb26e8bc387ebe40993bc1",
"reference": "917ab212fa00dc6eacbb26e8bc387ebe40993bc1",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-filter": "*",
"ext-hash": "*",
"php": ">=5.5.0"
},
"require-dev": {
@ -218,7 +219,13 @@
}
],
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"time": "2019-11-21T09:37:46+00:00"
"funding": [
{
"url": "https://github.com/synchro",
"type": "github"
}
],
"time": "2020-10-09T14:55:58+00:00"
},
{
"name": "psr/container",
@ -271,16 +278,16 @@
},
{
"name": "symfony/config",
"version": "v3.4.36",
"version": "v3.4.46",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe"
"reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/a599a867d0e4a07c342b5f1e656b3915a540ddbe",
"reference": "a599a867d0e4a07c342b5f1e656b3915a540ddbe",
"url": "https://api.github.com/repos/symfony/config/zipball/bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f",
"reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f",
"shasum": ""
},
"require": {
@ -302,11 +309,6 @@
"symfony/yaml": "To use the yaml reference dumper"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Config\\": ""
@ -331,20 +333,34 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
"time": "2019-12-01T10:45:41+00:00"
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-10-24T10:57:07+00:00"
},
{
"name": "symfony/dependency-injection",
"version": "v3.4.36",
"version": "v3.4.46",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
"reference": "0d201916bfb3af939fec3c0c8815ea16c60ac1a2"
"reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/0d201916bfb3af939fec3c0c8815ea16c60ac1a2",
"reference": "0d201916bfb3af939fec3c0c8815ea16c60ac1a2",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/51d2a2708c6ceadad84393f8581df1dcf9e5e84b",
"reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b",
"shasum": ""
},
"require": {
@ -373,11 +389,6 @@
"symfony/yaml": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\DependencyInjection\\": ""
@ -402,20 +413,34 @@
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
"time": "2019-12-01T08:33:36+00:00"
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-10-24T10:57:07+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v3.4.36",
"version": "v3.4.46",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "f9031c22ec127d4a2450760f81a8677fe8a10177"
"reference": "31fde73757b6bad247c54597beef974919ec6860"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/f9031c22ec127d4a2450760f81a8677fe8a10177",
"reference": "f9031c22ec127d4a2450760f81a8677fe8a10177",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/31fde73757b6bad247c54597beef974919ec6860",
"reference": "31fde73757b6bad247c54597beef974919ec6860",
"shasum": ""
},
"require": {
@ -427,6 +452,7 @@
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~2.8|~3.0|~4.0",
"symfony/debug": "~3.4|~4.4",
"symfony/dependency-injection": "~3.3|~4.0",
"symfony/expression-language": "~2.8|~3.0|~4.0",
"symfony/stopwatch": "~2.8|~3.0|~4.0"
@ -436,11 +462,6 @@
"symfony/http-kernel": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\EventDispatcher\\": ""
@ -465,20 +486,34 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2019-10-24T15:33:53+00:00"
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-10-24T10:57:07+00:00"
},
{
"name": "symfony/filesystem",
"version": "v3.4.36",
"version": "v3.4.46",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "00cdad0936d06fab136944bc2342b762b1c3a4a2"
"reference": "e58d7841cddfed6e846829040dca2cca0ebbbbb3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/00cdad0936d06fab136944bc2342b762b1c3a4a2",
"reference": "00cdad0936d06fab136944bc2342b762b1c3a4a2",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/e58d7841cddfed6e846829040dca2cca0ebbbbb3",
"reference": "e58d7841cddfed6e846829040dca2cca0ebbbbb3",
"shasum": ""
},
"require": {
@ -486,11 +521,6 @@
"symfony/polyfill-ctype": "~1.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Filesystem\\": ""
@ -515,20 +545,34 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2019-11-25T16:36:22+00:00"
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-10-24T10:57:07+00:00"
},
{
"name": "symfony/http-foundation",
"version": "v3.4.36",
"version": "v3.4.46",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "d2d0cfe8e319d9df44c4cca570710fcf221d4593"
"reference": "b9885fcce6fe494201da4f70a9309770e9d13dc8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/d2d0cfe8e319d9df44c4cca570710fcf221d4593",
"reference": "d2d0cfe8e319d9df44c4cca570710fcf221d4593",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/b9885fcce6fe494201da4f70a9309770e9d13dc8",
"reference": "b9885fcce6fe494201da4f70a9309770e9d13dc8",
"shasum": ""
},
"require": {
@ -540,11 +584,6 @@
"symfony/expression-language": "~2.8|~3.0|~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\HttpFoundation\\": ""
@ -569,24 +608,38 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2019-11-28T12:52:59+00:00"
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-10-24T10:57:07+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.13.1",
"version": "v1.20.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3"
"reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3",
"reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f4ba089a5b6366e453971d3aad5fe8e897b37f41",
"reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
"php": ">=7.1"
},
"suggest": {
"ext-ctype": "For best performance"
@ -594,7 +647,11 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
"dev-main": "1.20-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
@ -627,24 +684,38 @@
"polyfill",
"portable"
],
"time": "2019-11-27T13:56:44+00:00"
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-10-23T14:02:19+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.13.1",
"version": "v1.20.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "7b4aab9743c30be783b73de055d24a39cf4b954f"
"reference": "39d483bdf39be819deabf04ec872eb0b2410b531"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f",
"reference": "7b4aab9743c30be783b73de055d24a39cf4b954f",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531",
"reference": "39d483bdf39be819deabf04ec872eb0b2410b531",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
"php": ">=7.1"
},
"suggest": {
"ext-mbstring": "For best performance"
@ -652,7 +723,11 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
"dev-main": "1.20-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
@ -686,43 +761,49 @@
"portable",
"shim"
],
"time": "2019-11-27T14:18:11+00:00"
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-10-23T14:02:19+00:00"
},
{
"name": "symfony/polyfill-php70",
"version": "v1.13.1",
"version": "v1.20.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php70.git",
"reference": "af23c7bb26a73b850840823662dda371484926c4"
"reference": "5f03a781d984aae42cebd18e7912fa80f02ee644"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/af23c7bb26a73b850840823662dda371484926c4",
"reference": "af23c7bb26a73b850840823662dda371484926c4",
"url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/5f03a781d984aae42cebd18e7912fa80f02ee644",
"reference": "5f03a781d984aae42cebd18e7912fa80f02ee644",
"shasum": ""
},
"require": {
"paragonie/random_compat": "~1.0|~2.0|~9.99",
"php": ">=5.3.3"
"php": ">=7.1"
},
"type": "library",
"type": "metapackage",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
"dev-main": "1.20-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php70\\": ""
},
"files": [
"bootstrap.php"
],
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
@ -745,35 +826,48 @@
"portable",
"shim"
],
"time": "2019-11-27T13:56:44+00:00"
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-10-23T14:02:19+00:00"
},
{
"name": "twig/twig",
"version": "v1.42.4",
"version": "v1.44.1",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152"
"reference": "04b15d4c0bb18ddbf82626320ac07f6a73f199c9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/e587180584c3d2d6cb864a0454e777bb6dcb6152",
"reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/04b15d4c0bb18ddbf82626320ac07f6a73f199c9",
"reference": "04b15d4c0bb18ddbf82626320ac07f6a73f199c9",
"shasum": ""
},
"require": {
"php": ">=5.5.0",
"php": ">=7.2.5",
"symfony/polyfill-ctype": "^1.8"
},
"require-dev": {
"psr/container": "^1.0",
"symfony/debug": "^3.4|^4.2",
"symfony/phpunit-bridge": "^4.4@dev|^5.0"
"symfony/phpunit-bridge": "^4.4.9|^5.0.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.42-dev"
"dev-master": "1.44-dev"
}
},
"autoload": {
@ -797,7 +891,6 @@
},
{
"name": "Twig Team",
"homepage": "https://twig.symfony.com/contributors",
"role": "Contributors"
},
{
@ -811,7 +904,17 @@
"keywords": [
"templating"
],
"time": "2019-11-11T16:49:32+00:00"
"funding": [
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
"type": "tidelift"
}
],
"time": "2020-10-27T19:22:48+00:00"
}
],
"packages-dev": [],
@ -828,5 +931,6 @@
"ext-pdo": "*",
"ext-xml": "*"
},
"platform-dev": []
"platform-dev": [],
"plugin-api-version": "1.1.0"
}

View File

@ -12,6 +12,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc
<parameter>module.server</parameter>
<parameter>module.user</parameter>
<parameter>module.install</parameter>
<parameter>module.consult</parameter>
</parameter>
<parameter key="path.src" type="constant">PSM_PATH_SRC</parameter>
@ -31,6 +32,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc
<service id="module.server" class="psm\Module\Server\ServerModule" />
<service id="module.user" class="psm\Module\User\UserModule" />
<service id="module.install" class="psm\Module\Install\InstallModule" />
<service id="module.consult" class="psm\Module\Consult\ConsultModule" />
<!--MODULES end-->
<!--SERVICES start-->

View File

@ -34,6 +34,10 @@ $sm_lang = array(
'1' => 'fr_FR',
'2' => 'french',
),
'openscop' => array(
'title' => 'Openscop',
'consult_title' => 'Disponibilité de service'
),
'locale_tag' => 'fr',
'locale_dir' => 'ltr',
'system' => array(

View File

@ -0,0 +1,25 @@
<?php
namespace psm\Module\Consult;
use psm\Module\ModuleInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class ConsultModule implements ModuleInterface
{
public function load(ContainerBuilder $container)
{
}
public function getControllers()
{
return array(
'consult' => __NAMESPACE__ . '\Controller\ConsultController',
'server' => __NAMESPACE__ . '\Controller\ServerController',
'log' => __NAMESPACE__ . '\Controller\LogController',
'status' => __NAMESPACE__ . '\Controller\StatusController',
'update' => __NAMESPACE__ . '\Controller\UpdateController',
);
}
}

View File

@ -0,0 +1,113 @@
<?php
/**
* PHP Server Monitor
* Monitor your servers and websites.
*
* This file is part of PHP Server Monitor.
* PHP Server Monitor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PHP Server Monitor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PHP Server Monitor. If not, see <http://www.gnu.org/licenses/>.
*
* @package phpservermon
* @author Pepijn Over <pep@mailbox.org>
* @copyright Copyright (c) 2008-2017 Pepijn Over <pep@mailbox.org>
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: v3.5.0
* @link http://www.phpservermonitor.org/
**/
namespace psm\Module\Consult\Controller;
use psm\Module\Server\Controller\AbstractServerController;
use psm\Service\Database;
use Symfony\Component\HttpFoundation\Response;
abstract class AbstractConsultController extends AbstractServerController
{
/**
* Create HTML code for the menu
* @return string
*/
protected function createHTMLMenu()
{
return '';
}
public function __construct(Database $db, \Twig_Environment $twig)
{
parent::__construct($db, $twig);
$this->twig->addGlobal('subtitle', psm_get_lang('openscop', 'consult_title'));
$this->twig->addGlobal('title', psm_get_lang('openscop', 'consult_title'));
}
protected function createHTML($html = null)
{
if (!$this->xhr) {
// in XHR mode, we will not add the main template
$tpl_data = array(
'title' => strtoupper(psm_get_lang('openscop', 'title')),
'label_back_to_top' => psm_get_lang('system', 'back_to_top'),
'add_footer' => $this->add_footer,
'version' => 'v' . PSM_VERSION,
'messages' => $this->getMessages(),
'html_content' => $html,
);
// add menu to page?
if ($this->add_menu) {
$tpl_data['html_menu'] = $this->createHTMLMenu();
}
// add header accessories to page ?
if ($this->header_accessories) {
$tpl_data['header_accessories'] = $this->header_accessories;
}
// add modal dialog to page ?
if (sizeof($this->modal)) {
$html_modal = '';
foreach ($this->modal as $modal) {
$html_modal .= $modal->createHTML();
}
$tpl_data['html_modal'] = $html_modal;
}
// add sidebar to page?
if ($this->sidebar !== null) {
$tpl_data['html_sidebar'] = $this->sidebar->createHTML();
}
if (psm_update_available()) {
$tpl_data['update_available'] = str_replace(
'{version}',
'v' .
psm_get_conf('version_update_check'),
psm_get_lang('system', 'update_available')
);
}
if ($this->black_background) {
$tpl_data['body_class'] = 'black_background';
}
$tpl_data['custom_navbar'] = true;
// Insert logo url in navbar
$tpl_data['logo_url'] = 'https://www.openscop.news/wp-content/uploads/sites/10/2020/04/logo_horizontal_600x150.png';
$html = $this->twig->render('main/body.tpl.html', $tpl_data);
}
$response = new Response($html);
return $response;
}
}

View File

@ -0,0 +1,115 @@
<?php
/**
* PHP Server Monitor
* Monitor your servers and websites.
*
* This file is part of PHP Server Monitor.
* PHP Server Monitor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PHP Server Monitor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PHP Server Monitor. If not, see <http://www.gnu.org/licenses/>.
*
* @package phpservermon
* @author Pepijn Over <pep@mailbox.org>
* @copyright Copyright (c) 2008-2017 Pepijn Over <pep@mailbox.org>
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: v3.5.0
* @link http://www.phpservermonitor.org/
* @since phpservermon 3.0.0
**/
namespace psm\Module\Consult\Controller;
use psm\Module\AbstractController;
use psm\Module\Consult\Controller\AbstractConsultController;
use psm\Module\Server\Controller\AbstractServerController;
use psm\Service\Database;
abstract class AbstractConsultServerController extends AbstractConsultController
{
/**
* Get all servers for the current user
* @param Countable|array|\PDOStatement $server_id (int) if true only that server will be retrieved.
* @param array|\PDOStatement $ip
* @return array
*/
public function getServers($server_id = null, $ip = null)
{
$sql_join = '';
$sql_where = '';
if ($server_id !== null) {
$server_id = intval($server_id);
$sql_where = "WHERE `s`.`server_id`={$server_id} ";
}
$sql = "SELECT
`s`.`server_id`,
`s`.`ip`,
`s`.`port`,
`s`.`request_method`,
`s`.`post_field`,
`s`.`type`,
`s`.`label`,
`s`.`pattern`,
`s`.`pattern_online`,
`s`.`redirect_check`,
`s`.`allow_http_status`,
`s`.`header_name`,
`s`.`header_value`,
`s`.`status`,
`s`.`error`,
`s`.`rtime`,
`s`.`last_check`,
`s`.`last_online`,
`s`.`last_offline`,
`s`.`last_offline_duration`,
`s`.`active`,
`s`.`email`,
`s`.`sms`,
`s`.`pushover`,
`s`.`telegram`,
`s`.`jabber`,
`s`.`warning_threshold`,
`s`.`warning_threshold_counter`,
`s`.`ssl_cert_expiry_days`,
`s`.`ssl_cert_expired_time`,
`s`.`timeout`,
`s`.`website_username`,
`s`.`website_password`,
`s`.`last_error`,
`s`.`last_error_output`,
`s`.`last_output`
FROM `" . PSM_DB_PREFIX . "servers` AS `s`
{$sql_join}
{$sql_where}
ORDER BY `active` ASC, `status` DESC, `label` ASC";
$servers = $this->db->query($sql);
if ($server_id !== null && count($servers) == 1) {
$servers = $servers[0];
}
return $servers;
}
/**
* Format server data for display
* @param array $server
* @return array
*/
protected function formatServer($server)
{
return parent::formatServer($server);
}
}

View File

@ -0,0 +1,142 @@
<?php
namespace psm\Module\Consult\Controller;
use psm\Module\AbstractController;
use psm\Module\Consult\Controller\AbstractConsultServerController;
use psm\Module\Server\Controller\AbstractServerController;
use psm\Service\Database;
class ConsultController extends AbstractConsultServerController
{
public $server_id;
public $ip;
public $id;
function __construct(Database $db, \Twig_Environment $twig)
{
parent::__construct($db, $twig);
$this->ip = isset($_GET['ip']) ? $_GET['ip'] : "";
$this->setActions(array(
'view',
), 'index');
$this->setMinUserLevelRequiredForAction(PSM_USER_ANONYMOUS, []);
$this->setMinUserLevelRequired(PSM_USER_ANONYMOUS);
}
protected function executeView()
{
$sql = 'SELECT server_id FROM ' . PSM_DB_PREFIX . 'servers WHERE label = "' . $this->ip . '"';
$server_id = $this->db->query($sql);
if (empty($server_id)) {
$tpl_data = $this->getError();
return $this->twig->render('module/error/401.tpl.html', $tpl_data);
} else
$id = $server_id[0]['server_id'];
$this->id = $id;
$server = $this->getServers($this->id);
$tpl_data = $this->getLabels();
$tpl_data = array_merge($tpl_data, $this->formatServer($server));
$history = new \psm\Util\Server\HistoryGraph($this->db, $this->twig);
$tpl_data['html_history'] = $history->createHTML($this->id);
$sidebar = new \psm\Util\Module\Sidebar($this->twig);
$this->setSidebar($sidebar);
return $this->twig->render('module/consult/consult.tpl.html', $tpl_data);
}
protected function getError()
{
return array(
'label_title' => "Erreur",
'label_description' => "Vous n'avez pas saisi la bonne adresse !"
);
}
protected function getLabels()
{
return array(
'label_label' => psm_get_lang('servers', 'label'),
'label_status' => psm_get_lang('servers', 'status'),
'label_domain' => psm_get_lang('servers', 'domain'),
'label_timeout' => psm_get_lang('servers', 'timeout'),
'label_timeout_description' => psm_get_lang('servers', 'timeout_description'),
'label_authentication_settings' => psm_get_lang('servers', 'authentication_settings'),
'label_optional' => psm_get_lang('servers', 'optional'),
'label_website_username' => psm_get_lang('servers', 'website_username'),
'label_website_username_description' => psm_get_lang('servers', 'website_username_description'),
'label_website_password' => psm_get_lang('servers', 'website_password'),
'label_website_password_description' => psm_get_lang('servers', 'website_password_description'),
'label_fieldset_monitoring' => psm_get_lang('servers', 'fieldset_monitoring'),
'label_fieldset_permissions' => psm_get_lang('servers', 'fieldset_permissions'),
'label_permissions' => psm_get_lang('servers', 'permissions'),
'label_port' => psm_get_lang('servers', 'port'),
'label_custom_port' => psm_get_lang('servers', 'custom_port'),
'label_popular_ports' => psm_get_lang('servers', 'popular_ports'),
'label_request_method' => psm_get_lang('servers', 'request_method'),
'label_custom_request_method' => psm_get_lang('servers', 'custom_request_method'),
'label_popular_request_methods' => psm_get_lang('servers', 'popular_request_methods'),
'label_post_field' => psm_get_lang('servers', 'post_field'),
'label_post_field_description' => psm_get_lang('servers', 'post_field_description'),
'label_none' => psm_get_lang('system', 'none'),
'label_please_select' => psm_get_lang('servers', 'please_select'),
'label_type' => psm_get_lang('servers', 'type'),
'label_website' => psm_get_lang('servers', 'type_website'),
'label_service' => psm_get_lang('servers', 'type_service'),
'label_ping' => psm_get_lang('servers', 'type_ping'),
'label_pattern' => psm_get_lang('servers', 'pattern'),
'label_pattern_description' => psm_get_lang('servers', 'pattern_description'),
'label_pattern_online' => psm_get_lang('servers', 'pattern_online'),
'label_pattern_online_description' => psm_get_lang('servers', 'pattern_online_description'),
'label_redirect_check' => psm_get_lang('servers', 'redirect_check'),
'label_redirect_check_description' => psm_get_lang('servers', 'redirect_check_description'),
'label_allow_http_status' => psm_get_lang('servers', 'allow_http_status'),
'label_allow_http_status_description' => psm_get_lang('servers', 'allow_http_status_description'),
'label_header_name' => psm_get_lang('servers', 'header_name'),
'label_header_value' => psm_get_lang('servers', 'header_value'),
'label_header_name_description' => psm_get_lang('servers', 'header_name_description'),
'label_header_value_description' => psm_get_lang('servers', 'header_value_description'),
'label_last_check' => psm_get_lang('servers', 'last_check'),
'label_rtime' => psm_get_lang('servers', 'latency'),
'label_last_online' => psm_get_lang('servers', 'last_online'),
'label_last_offline' => psm_get_lang('servers', 'last_offline'),
'label_last_output' => psm_get_lang('servers', 'last_output'),
'label_last_error' => psm_get_lang('servers', 'last_error'),
'label_last_error_output' => psm_get_lang('servers', 'last_error_output'),
'label_monitoring' => psm_get_lang('servers', 'monitoring'),
'label_email' => psm_get_lang('servers', 'email'),
'label_send_email' => psm_get_lang('servers', 'send_email'),
'label_sms' => psm_get_lang('servers', 'sms'),
'label_send_sms' => psm_get_lang('servers', 'send_sms'),
'label_send_pushover' => psm_get_lang('servers', 'send_pushover'),
'label_telegram' => psm_get_lang('servers', 'telegram'),
'label_jabber' => psm_get_lang('servers', 'jabber'),
'label_pushover' => psm_get_lang('servers', 'pushover'),
'label_send_telegram' => psm_get_lang('servers', 'send_telegram'),
'label_send_jabber' => psm_get_lang('servers', 'send_jabber'),
'label_users' => psm_get_lang('servers', 'users'),
'label_warning_threshold' => psm_get_lang('servers', 'warning_threshold'),
'label_warning_threshold_description' => psm_get_lang('servers', 'warning_threshold_description'),
'label_ssl_cert_expiry_days' => psm_get_lang('servers', 'ssl_cert_expiry_days'),
'label_ssl_cert_expiry_days_description' => psm_get_lang('servers', 'ssl_cert_expiry_days_description'),
'label_action' => psm_get_lang('system', 'action'),
'label_save' => psm_get_lang('system', 'save'),
'label_go_back' => psm_get_lang('system', 'go_back'),
'label_edit' => psm_get_lang('system', 'edit'),
'label_delete' => psm_get_lang('system', 'delete'),
'label_view' => psm_get_lang('system', 'view'),
'label_yes' => psm_get_lang('system', 'yes'),
'label_no' => psm_get_lang('system', 'no'),
'label_add_new' => psm_get_lang('system', 'add_new'),
'label_seconds' => psm_get_lang('config', 'seconds'),
'label_online' => psm_get_lang('servers', 'online'),
'label_offline' => psm_get_lang('servers', 'offline'),
'label_ok' => psm_get_lang('system', 'ok'),
'label_bad' => psm_get_lang('system', 'bad'),
'default_value_timeout' => PSM_CURL_TIMEOUT,
'label_settings' => psm_get_lang('system', 'settings'),
'label_output' => psm_get_lang('servers', 'output'),
'label_search' => psm_get_lang('system', 'search'),
);
}
}

View File

@ -95,6 +95,10 @@ class HistoryGraph
$tpl_data = array(
'graphs' => $graphs,
);
//$graphs[1]['info'][0]['value'] = '1.2336';
//echo '<pre>';
//print_r($graphs);die;
return $this->twig->render('module/server/history.tpl.html', $tpl_data);
}

View File

@ -24,14 +24,19 @@
<link href="src/templates/default/static/css/bootstrap.min.css" rel="stylesheet">
<link href="src/templates/default/static/plugin/bootstrap-select/dist/css/bootstrap-select.min.css" rel="stylesheet">
<link href="src/templates/default/static/css/style.min.css" rel="stylesheet">
{% if custom_navbar == 1 %}
<link href="src/templates/default/static/openscop/css/style.css" rel="stylesheet">
{% endif %}
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="index.php">{{ title }}</a>
<nav class="navbar fixed-top navbar-expand-lg navbar-dark {% if custom_navbar == 1 %}bg-light navbar_openscop {% else %} bg-dark {% endif %}">
<a class="navbar-brand" href="index.php">
<img src="{{ logo_url }}" class="img-fluid logo-openscop" />
{{ title }}</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>

View File

@ -0,0 +1,127 @@
{{ macro.input_csrf() }}
<div class="container">
<div class="row">
<div class="card text-white text-center col-md-2 pl-0 pr-0 mb-4 {% if status|lower == 'on' %}bg-success{% elseif status|lower == 'warning' %}bg-warning{% elseif status|lower == 'off' %}bg-danger{% endif %}">
<div class="card-body d-flex align-items-center justify-content-center">
{% if status|lower == 'on' %}
<i class="fas fa-check-circle fa-6x"></i>
<noscript><h1>&#10003</h1></noscript>
{% elseif status|lower == 'warning' %}
<i class="fas fa-exclamation-triangle fa-6x"></i>
<noscript><h1>&#9888</h1></noscript>
{% elseif status|lower == 'off' %}
<i class="fas fa-times-circle fa-6x"></i>
<noscript><h1>&#10005</h1></noscript>
{% else %}
<i class="fas fa-question-circle fa-6x"></i>
<noscript><h1>&#8263</h1></noscript>
{% endif %}
</div>
</div>
<div class="card col-md-5 mr-5 ml-auto pl-0 pr-0 mb-4">
<div class="card-header">
{{ label }}
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<dl class="row">
<dt class="col-md-4">{{ label_domain }}:</dt>
<dd class="col-md-8">
<a href="{{ ip|raw }}" title="{{ ip|raw }}" target="_blank" rel="noopener">
{{ ip|raw }}
</a>
</dd>
</dl>
</li>
{% if type|lower == 'service' %}
<li class="list-group-item">
<dl class="row">
<dt class="col-md-4">{{ label_port }}:</dt>
<dd class="col-md-8">{{ port }}</dd>
</dl>
</li>
{% endif %}
<li class="list-group-item">
<dl class="row">
<dt class="col-md-4">{{ label_status }}:</dt>
<dd class="col-md-8">{{ status }}</dd>
</dl>
</li>
<li class="list-group-item">
<dl class="row">
<dt class="col-md-4">{{ label_rtime }}:</dt>
<dd class="col-md-8">{{ rtime }} {{ label_seconds }}</dd>
</dl>
</li>
</ul>
</div>
<div class="card col-md-3 ml-5 pl-0 pr-0 mb-4">
<div class="card-header">
{{ label_status }}
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<dl class="row">
<dt class="col-md-6">{{ label_last_online }}:</dt>
<dd class="col-md-6">{{ last_online }}</dd>
</dl>
</li>
<li class="list-group-item">
<dl class="row">
<dt class="col-md-6">{{ label_last_offline }}:</dt>
<dd class="col-md-6">{{ last_offline }}</dd>
</dl>
</li>
<li class="list-group-item">
<dl class="row">
<dt class="col-md-6">{{ label_last_check }}:</dt>
<dd class="col-md-6">{{ last_check }}</dd>
</dl>
</li>
</ul>
</div>
</div>
<div class="row">
{{ html_history|raw }}
</div>
<div class="modal fade" id="modal_last_output" tabindex="-1" role="dialog" aria-labelledby="modal_last_output_label" aria-hidden="true">
<div class="modal-dialog" style="width:75%;max-width: 100%" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal_last_output_label">{{ label_last_output }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" style="word-wrap: break-word;">
{{ last_output|nl2br }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="modal_last_error" tabindex="-1" role="dialog" aria-labelledby="modal_last_error_label" aria-hidden="true">
<div class="modal-dialog" style="width:75%;max-width: 100%" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal_last_error_label">{{ label_last_error_output }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" style="word-wrap: break-word;">
{{ last_error_output|nl2br }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,3 @@
.logo-openscop {
height: 50px;
}