update to support PHP 8.1.0 (#1270)
* update to support PHP 8.1.0 * localized date * reverted for compatibility up to PHP 7.4 * PHP 8.4 support * remove unused images --------- Co-authored-by: Tim Zandbergen <TimZ99@users.noreply.github.com>develop
parent
c70d23859a
commit
601139b866
|
@ -4,20 +4,22 @@
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"homepage": "https://www.phpservermonitor.org",
|
"homepage": "https://www.phpservermonitor.org",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.5.9|>=7.0.8",
|
"php": "^7.4|>=8.1",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"ext-xml": "*",
|
"ext-xml": "*",
|
||||||
"phpmailer/phpmailer": ">=6.5.0 ~6.0",
|
"phpmailer/phpmailer": "^6.9",
|
||||||
"symfony/config": "~3.4",
|
"symfony/config": "6.4",
|
||||||
"symfony/dependency-injection": "~4.0",
|
"symfony/dependency-injection": "6.4",
|
||||||
"symfony/event-dispatcher": "~3.4",
|
"symfony/event-dispatcher": "6.4",
|
||||||
"symfony/http-foundation": ">=3.4.35 ~3.4",
|
"symfony/http-foundation": "6.4.16",
|
||||||
"symfony/filesystem": "~3.4",
|
"symfony/filesystem": "6.4",
|
||||||
"php-pushover/php-pushover": "dev-master",
|
"symfony/deprecation-contracts": "^2.5",
|
||||||
|
"symfony/event-dispatcher-contracts": "^2.5",
|
||||||
|
"php-pushover/php-pushover": "^1.0",
|
||||||
"paragonie/random_compat": "^9.99",
|
"paragonie/random_compat": "^9.99",
|
||||||
"twig/twig": "~1.35",
|
"twig/twig": "^3.8",
|
||||||
"jaxl/jaxl": "^3.1",
|
"jaxl/jaxl": "^3.1",
|
||||||
"viharm/psm-ldap-auth": "^1.1"
|
"viharm/psm-ldap-auth": "^1.1"
|
||||||
},
|
},
|
||||||
|
@ -29,5 +31,10 @@
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"psm\\": "src/psm/"
|
"psm\\": "src/psm/"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"allow-plugins": {
|
||||||
|
"mnsami/composer-custom-directory-installer": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -69,7 +69,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
$cron_timeout = PSM_CRON_TIMEOUT;
|
$cron_timeout = PSM_CRON_TIMEOUT;
|
||||||
// parse a couple of arguments
|
// parse a couple of arguments
|
||||||
if (!empty($_SERVER['argv'])) {
|
if (!empty($_SERVER['argv'])) {
|
||||||
foreach ($_SERVER['argv'] as $argv) {
|
foreach ($_SERVER['argv'] as $argv) {
|
||||||
$argi = explode('=', ltrim($argv, '--'));
|
$argi = explode('=', ltrim($argv, '--'));
|
||||||
|
@ -89,10 +89,10 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent cron from running twice at the same time
|
// prevent cron from running twice at the same time
|
||||||
// however if the cron has been running for X mins, we'll assume it died and run anyway
|
// however if the cron has been running for X mins, we'll assume it died and run anyway
|
||||||
// if you want to change PSM_CRON_TIMEOUT, have a look in src/includes/psmconfig.inc.php.
|
// if you want to change PSM_CRON_TIMEOUT, have a look in src/includes/psmconfig.inc.php.
|
||||||
// or you can provide the --timeout=x argument
|
// or you can provide the --timeout=x argument
|
||||||
|
|
||||||
$status = null;
|
$status = null;
|
||||||
if (PHP_SAPI === 'cli') {
|
if (PHP_SAPI === 'cli') {
|
||||||
|
|
|
@ -42,16 +42,16 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc
|
||||||
<argument>%db.port%</argument>
|
<argument>%db.port%</argument>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="event" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
|
<service id="event" class="Symfony\Component\EventDispatcher\EventDispatcher">
|
||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
</service>
|
</service>
|
||||||
<service id="user" class="psm\Service\User">
|
<service id="user" class="psm\Service\User">
|
||||||
<argument type="service" id="db" />
|
<argument type="service" id="db" />
|
||||||
</service>
|
</service>
|
||||||
<service id="twig.loader" class="Twig_Loader_Filesystem">
|
<service id="twig.loader" class="Twig\Loader\FilesystemLoader">
|
||||||
<argument>%path.templates%/%config.theme%</argument>
|
<argument>%path.templates%/%config.theme%</argument>
|
||||||
</service>
|
</service>
|
||||||
<service id="twig" class="Twig_Environment">
|
<service id="twig" class="Twig\Environment">
|
||||||
<argument type="service" id="twig.loader" />
|
<argument type="service" id="twig.loader" />
|
||||||
</service>
|
</service>
|
||||||
<!--SERVICES end-->
|
<!--SERVICES end-->
|
||||||
|
|
|
@ -495,20 +495,15 @@ namespace {
|
||||||
$time = strtotime($time);
|
$time = strtotime($time);
|
||||||
}
|
}
|
||||||
if ($time < strtotime(date('Y-m-d 00:00:00')) - 60 * 60 * 24 * 3) {
|
if ($time < strtotime(date('Y-m-d 00:00:00')) - 60 * 60 * 24 * 3) {
|
||||||
$format = psm_get_lang('system', (date('Y') !== date('Y', $time)) ?
|
$format = psm_get_lang('system', (date('Y') !== date('Y', $time) ? 'long_day_format' : 'short_day_format'));
|
||||||
'long_day_format' : 'short_day_format');
|
|
||||||
// Check for Windows to find and replace the %e
|
return formatLanguage($format, $time);
|
||||||
// modifier correctly
|
|
||||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
|
||||||
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
|
|
||||||
}
|
|
||||||
return strftime($format, $time);
|
|
||||||
}
|
}
|
||||||
$d = time() - $time;
|
$d = time() - $time;
|
||||||
if ($d >= 60 * 60 * 24) {
|
if ($d >= 60 * 60 * 24) {
|
||||||
$format = psm_get_lang('system', (date('l', time() - 60 * 60 * 24) == date('l', $time)) ?
|
$format = psm_get_lang('system', (date('l', time() - 60 * 60 * 24) == date('l', $time)) ?
|
||||||
'yesterday_format' : 'other_day_format');
|
'yesterday_format' : 'other_day_format');
|
||||||
return strftime($format, $time);
|
return formatLanguage($format, $time);
|
||||||
}
|
}
|
||||||
if ($d >= 60 * 60 * 2) {
|
if ($d >= 60 * 60 * 2) {
|
||||||
return sprintf(psm_get_lang('system', 'hours_ago'), intval($d / (60 * 60)));
|
return sprintf(psm_get_lang('system', 'hours_ago'), intval($d / (60 * 60)));
|
||||||
|
@ -539,7 +534,7 @@ namespace {
|
||||||
if (empty($time) || $time == '0000-00-00 00:00:00') {
|
if (empty($time) || $time == '0000-00-00 00:00:00') {
|
||||||
return psm_get_lang('system', 'never');
|
return psm_get_lang('system', 'never');
|
||||||
}
|
}
|
||||||
return strftime('%x %X', strtotime($time));
|
return formatLanguage('%x %X', strtotime($time));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1012,13 +1007,81 @@ namespace {
|
||||||
|
|
||||||
return $decrypted;
|
return $decrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send notification to Telegram
|
* Convert strftime format to php date format
|
||||||
*
|
* @param $strftimeformat
|
||||||
* @return string
|
* @return string|string[]
|
||||||
* @author Tim Zandbergen <tim@xervion.nl>
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
function strftimeFormatToDateFormat($strftimeformat){
|
||||||
|
$unsupported = ['%U', '%V', '%C', '%g', '%G'];
|
||||||
|
$foundunsupported = [];
|
||||||
|
foreach($unsupported as $unsup){
|
||||||
|
if (strpos($strftimeformat, $unsup) !== false){
|
||||||
|
$foundunsupported[] = $unsup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($foundunsupported)){
|
||||||
|
throw new \Exception("Found these unsupported chars: ".implode(",", $foundunsupported).' in '.$strftimeformat);
|
||||||
|
}
|
||||||
|
// It is important to note that some do not translate accurately ie. lowercase L is supposed to convert to number with a preceding space if it is under 10, there is no accurate conversion so we just use 'g'
|
||||||
|
$phpdateformat = str_replace(
|
||||||
|
['%a','%A','%d','%e','%u','%w','%W','%b','%h','%B','%m','%y','%Y', '%D', '%F', '%x', '%n', '%t', '%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r' /* %I:%M:%S %p */, '%R' /* %H:%M */, '%S', '%T' /* %H:%M:%S */, '%X', '%z', '%Z',
|
||||||
|
'%c', '%s',
|
||||||
|
'%%'],
|
||||||
|
['D','l', 'd', 'j', 'N', 'w', 'W', 'M', 'M', 'F', 'm', 'y', 'Y', 'm/d/y', 'Y-m-d', 'm/d/y',"\n","\t", 'H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s', 'O', 'T',
|
||||||
|
'D M j H:i:s Y' /*Tue Feb 5 00:45:10 2009*/, 'U',
|
||||||
|
'%'],
|
||||||
|
$strftimeformat
|
||||||
|
);
|
||||||
|
return $phpdateformat;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatLanguage(string $formatSTRF,int $timestamp) : string {
|
||||||
|
$format = strftimeFormatToDateFormat($formatSTRF);
|
||||||
|
|
||||||
|
$dt = new DateTime();
|
||||||
|
$dt->setTimestamp($timestamp);
|
||||||
|
|
||||||
|
$language = isset($GLOBALS['sm_lang']) ? $GLOBALS['sm_lang']['locale'][1] : $GLOBALS['sm_lang_default']['locale'][1];
|
||||||
|
$curTz = $dt->getTimezone();
|
||||||
|
if($curTz->getName() === 'Z'){
|
||||||
|
//INTL don't know Z
|
||||||
|
$curTz = new DateTimeZone('UTC');
|
||||||
|
}
|
||||||
|
|
||||||
|
$formatPattern = strtr($format,array(
|
||||||
|
'D' => '{#1}',
|
||||||
|
'l' => '{#2}',
|
||||||
|
'M' => '{#3}',
|
||||||
|
'F' => '{#4}',
|
||||||
|
));
|
||||||
|
$strDate = $dt->format($formatPattern);
|
||||||
|
$regEx = '~\{#\d\}~';
|
||||||
|
while(preg_match($regEx,$strDate,$match)) {
|
||||||
|
$IntlFormat = strtr($match[0],array(
|
||||||
|
'{#1}' => 'E',
|
||||||
|
'{#2}' => 'EEEE',
|
||||||
|
'{#3}' => 'MMM',
|
||||||
|
'{#4}' => 'MMMM',
|
||||||
|
));
|
||||||
|
$fmt = datefmt_create($language, IntlDateFormatter::FULL, IntlDateFormatter::FULL,
|
||||||
|
$curTz, IntlDateFormatter::GREGORIAN, $IntlFormat
|
||||||
|
);
|
||||||
|
$replace = $fmt ? datefmt_format( $fmt ,$dt) : "???";
|
||||||
|
$strDate = str_replace($match[0], $replace, $strDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $strDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send notification to Telegram
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @author Tim Zandbergen <tim@xervion.nl>
|
||||||
|
*/
|
||||||
class Telegram
|
class Telegram
|
||||||
{
|
{
|
||||||
private $token;
|
private $token;
|
||||||
|
|
|
@ -109,7 +109,7 @@ abstract class AbstractController implements ControllerInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Twig object
|
* Twig object
|
||||||
* @var \Twig_Environment $twig
|
* @var \Twig\Environment $twig
|
||||||
*/
|
*/
|
||||||
protected $twig;
|
protected $twig;
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ abstract class AbstractController implements ControllerInterface
|
||||||
*/
|
*/
|
||||||
protected $xhr = false;
|
protected $xhr = false;
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->twig = $twig;
|
$this->twig = $twig;
|
||||||
|
|
|
@ -114,7 +114,7 @@ class ConfigController extends AbstractController
|
||||||
|
|
||||||
private $default_tab = 'general';
|
private $default_tab = 'general';
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
parent::__construct($db, $twig);
|
parent::__construct($db, $twig);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
interface ControllerInterface extends ContainerAwareInterface
|
interface ControllerInterface extends ContainerAwareInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig);
|
public function __construct(Database $db, \Twig\Environment $twig);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the controller
|
* Run the controller
|
||||||
|
|
|
@ -35,7 +35,7 @@ use psm\Service\Database;
|
||||||
class ErrorController extends AbstractController
|
class ErrorController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
parent::__construct($db, $twig);
|
parent::__construct($db, $twig);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class InstallController extends AbstractController
|
||||||
*/
|
*/
|
||||||
protected $path_config_old;
|
protected $path_config_old;
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
parent::__construct($db, $twig);
|
parent::__construct($db, $twig);
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ abstract class AbstractServerController extends AbstractController
|
||||||
`s`.`active`,
|
`s`.`active`,
|
||||||
`s`.`email`,
|
`s`.`email`,
|
||||||
`s`.`sms`,
|
`s`.`sms`,
|
||||||
`s`.`discord`,
|
`s`.`discord`,
|
||||||
`s`.`webhook`,
|
`s`.`webhook`,
|
||||||
`s`.`pushover`,
|
`s`.`pushover`,
|
||||||
`s`.`telegram`,
|
`s`.`telegram`,
|
||||||
|
|
|
@ -36,7 +36,7 @@ use psm\Service\Database;
|
||||||
class LogController extends AbstractServerController
|
class LogController extends AbstractServerController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
parent::__construct($db, $twig);
|
parent::__construct($db, $twig);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class ServerController extends AbstractServerController
|
||||||
*/
|
*/
|
||||||
protected $server_id;
|
protected $server_id;
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
parent::__construct($db, $twig);
|
parent::__construct($db, $twig);
|
||||||
|
|
||||||
|
@ -535,14 +535,14 @@ class ServerController extends AbstractServerController
|
||||||
'label' => $server_available['label'],
|
'label' => $server_available['label'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl_data['last_output_truncated'] = $tpl_data['last_output'];
|
$tpl_data['last_output_truncated'] = $tpl_data['last_output'];
|
||||||
$tpl_data['last_error_output_truncated'] = $tpl_data['last_error_output'];
|
$tpl_data['last_error_output_truncated'] = $tpl_data['last_error_output'];
|
||||||
|
|
||||||
if (strlen($tpl_data['last_output']) > 255) {
|
if (strlen($tpl_data['last_output']) > 255) {
|
||||||
$tpl_data['last_output_truncated'] = substr($tpl_data['last_output'], 0, 255) . '...';
|
$tpl_data['last_output_truncated'] = substr($tpl_data['last_output'], 0, 255) . '...';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($tpl_data['last_error_output']) > 255) {
|
if (strlen($tpl_data['last_error_output']) > 255) {
|
||||||
$tpl_data['last_error_output_truncated'] = substr($tpl_data['last_error_output'], 0, 255) . '...';
|
$tpl_data['last_error_output_truncated'] = substr($tpl_data['last_error_output'], 0, 255) . '...';
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ use psm\Service\Database;
|
||||||
class StatusController extends AbstractServerController
|
class StatusController extends AbstractServerController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
parent::__construct($db, $twig);
|
parent::__construct($db, $twig);
|
||||||
|
|
||||||
|
@ -70,6 +70,13 @@ class StatusController extends AbstractServerController
|
||||||
'layout' => $layout,
|
'layout' => $layout,
|
||||||
'url_save' => psm_build_url(array('mod' => 'server', 'action' => 'edit')),
|
'url_save' => psm_build_url(array('mod' => 'server', 'action' => 'edit')),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$auto_refresh_seconds = psm_get_conf('auto_refresh_servers');
|
||||||
|
if (intval($auto_refresh_seconds) > 0) {
|
||||||
|
$this->twig->addGlobal('auto_refresh', true);
|
||||||
|
$this->twig->addGlobal('auto_refresh_seconds', $auto_refresh_seconds);
|
||||||
|
}
|
||||||
|
|
||||||
$this->setHeaderAccessories($this->twig->render('module/server/status/header.tpl.html', $layout_data));
|
$this->setHeaderAccessories($this->twig->render('module/server/status/header.tpl.html', $layout_data));
|
||||||
|
|
||||||
$this->addFooter(false);
|
$this->addFooter(false);
|
||||||
|
@ -107,12 +114,6 @@ class StatusController extends AbstractServerController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$auto_refresh_seconds = psm_get_conf('auto_refresh_servers');
|
|
||||||
if (intval($auto_refresh_seconds) > 0) {
|
|
||||||
$this->twig->addGlobal('auto_refresh', true);
|
|
||||||
$this->twig->addGlobal('auto_refresh_seconds', $auto_refresh_seconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->isXHR() || isset($_SERVER["HTTP_X_REQUESTED_WITH"])) {
|
if ($this->isXHR() || isset($_SERVER["HTTP_X_REQUESTED_WITH"])) {
|
||||||
$this->xhr = true;
|
$this->xhr = true;
|
||||||
//disable auto refresh in ajax return html
|
//disable auto refresh in ajax return html
|
||||||
|
|
|
@ -36,7 +36,7 @@ use psm\Service\Database;
|
||||||
class UpdateController extends AbstractController
|
class UpdateController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
parent::__construct($db, $twig);
|
parent::__construct($db, $twig);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ use psm\Service\Database;
|
||||||
class LoginController extends AbstractController
|
class LoginController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
parent::__construct($db, $twig);
|
parent::__construct($db, $twig);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ProfileController extends AbstractController
|
||||||
protected $profile_fields =
|
protected $profile_fields =
|
||||||
array('name', 'user_name', 'email', 'mobile', 'pushover_key', 'pushover_device', 'discord', 'webhook_url', 'webhook_json', 'telegram_id', 'jabber');
|
array('name', 'user_name', 'email', 'mobile', 'pushover_key', 'pushover_device', 'discord', 'webhook_url', 'webhook_json', 'telegram_id', 'jabber');
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
parent::__construct($db, $twig);
|
parent::__construct($db, $twig);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class UserController extends AbstractController
|
||||||
{
|
{
|
||||||
public $servers = array();
|
public $servers = array();
|
||||||
|
|
||||||
public function __construct(Database $db, \Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
parent::__construct($db, $twig);
|
parent::__construct($db, $twig);
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ class Router
|
||||||
}
|
}
|
||||||
|
|
||||||
$twig->addFunction(
|
$twig->addFunction(
|
||||||
new \Twig_SimpleFunction(
|
new \Twig\TwigFunction(
|
||||||
'csrf_token',
|
'csrf_token',
|
||||||
function ($lock_to = null) use ($session) {
|
function ($lock_to = null) use ($session) {
|
||||||
if (empty($lock_to)) {
|
if (empty($lock_to)) {
|
||||||
|
|
|
@ -67,11 +67,11 @@ class Modal implements ModalInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Twig environment
|
* Twig environment
|
||||||
* @var \Twig_Environment $twig
|
* @var \Twig\Environment $twig
|
||||||
*/
|
*/
|
||||||
protected $twig;
|
protected $twig;
|
||||||
|
|
||||||
public function __construct(\Twig_Environment $twig, $modal_id = 'main', $type = self::MODAL_TYPE_OK)
|
public function __construct(\Twig\Environment $twig, $modal_id = 'main', $type = self::MODAL_TYPE_OK)
|
||||||
{
|
{
|
||||||
$this->modal_id = $modal_id;
|
$this->modal_id = $modal_id;
|
||||||
$this->twig = $twig;
|
$this->twig = $twig;
|
||||||
|
@ -142,7 +142,7 @@ class Modal implements ModalInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl = $this->twig->loadTemplate('util/module/modal.tpl.html');
|
$tpl = $this->twig->load('util/module/modal.tpl.html');
|
||||||
$html = $tpl->render(array(
|
$html = $tpl->render(array(
|
||||||
'modal_id' => $this->modal_id,
|
'modal_id' => $this->modal_id,
|
||||||
'modal_title' => !empty($this->title) ? $this->title : psm_get_conf('site_title', psm_get_lang('system', 'title')),
|
'modal_title' => !empty($this->title) ? $this->title : psm_get_conf('site_title', psm_get_lang('system', 'title')),
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace psm\Util\Module;
|
||||||
interface ModalInterface
|
interface ModalInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(\Twig_Environment $twig);
|
public function __construct(\Twig\Environment $twig);
|
||||||
|
|
||||||
public function getModalID();
|
public function getModalID();
|
||||||
public function createHTML();
|
public function createHTML();
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Sidebar implements SidebarInterface
|
||||||
*/
|
*/
|
||||||
protected $twig;
|
protected $twig;
|
||||||
|
|
||||||
public function __construct(\Twig_Environment $twig)
|
public function __construct(\Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
$this->twig = $twig;
|
$this->twig = $twig;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ class Sidebar implements SidebarInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl = $this->twig->loadTemplate('util/module/sidebar.tpl.html');
|
$tpl = $this->twig->load('util/module/sidebar.tpl.html');
|
||||||
$html = $tpl->render($tpl_data);
|
$html = $tpl->render($tpl_data);
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace psm\Util\Module;
|
||||||
interface SidebarInterface
|
interface SidebarInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct(\Twig_Environment $twig);
|
public function __construct(\Twig\Environment $twig);
|
||||||
|
|
||||||
public function createHTML();
|
public function createHTML();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace psm\Util\Server;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use psm\Service\Database;
|
use psm\Service\Database;
|
||||||
use Twig\Error\Error;
|
use Twig\Error\Error;
|
||||||
use Twig_Environment;
|
use Twig\Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* History util, create HTML for server graphs
|
* History util, create HTML for server graphs
|
||||||
|
@ -52,7 +52,7 @@ class HistoryGraph
|
||||||
*/
|
*/
|
||||||
protected $twig;
|
protected $twig;
|
||||||
|
|
||||||
public function __construct(Database $db, Twig_Environment $twig)
|
public function __construct(Database $db, \Twig\Environment $twig)
|
||||||
{
|
{
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->twig = $twig;
|
$this->twig = $twig;
|
||||||
|
@ -310,7 +310,7 @@ class HistoryGraph
|
||||||
// Previous datapoint was offline
|
// Previous datapoint was offline
|
||||||
: ['x' => $time_ms, 'y' => null];
|
: ['x' => $time_ms, 'y' => null];
|
||||||
// new outage start
|
// new outage start
|
||||||
$lines['offline'][] = ['x' => $time_ms, 'y' => $highest_latency];
|
$lines['offline'][] = ['x' => $time_ms, 'y' => 0];
|
||||||
|
|
||||||
if ($prev_downtime === 0) {
|
if ($prev_downtime === 0) {
|
||||||
$prev_downtime = $time;
|
$prev_downtime = $time;
|
||||||
|
@ -322,7 +322,7 @@ class HistoryGraph
|
||||||
// Previous datapoint was online
|
// Previous datapoint was online
|
||||||
? ['x' => $time_ms, 'y' => null]
|
? ['x' => $time_ms, 'y' => null]
|
||||||
// Previous datapoint was offline
|
// Previous datapoint was offline
|
||||||
: ['x' => $time_ms, 'y' => $highest_latency];
|
: ['x' => $time_ms, 'y' => 0];
|
||||||
$lines['online'][] = ['x' => $time_ms, 'y' => round($record['latency'] * 1000, 3)];
|
$lines['online'][] = ['x' => $time_ms, 'y' => round($record['latency'] * 1000, 3)];
|
||||||
|
|
||||||
if ($prev_downtime !== 0) {
|
if ($prev_downtime !== 0) {
|
||||||
|
|
|
@ -237,7 +237,7 @@
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
<dt class="col-md-3">{{ label_last_output }}:</dt>
|
<dt class="col-md-3">{{ label_last_output }}:</dt>
|
||||||
<dd class="col-md-9">{{ last_output_truncated|nl2br }}</dd>
|
<dd class="col-md-9">{{ last_output_truncated|raw|nl2br }}</dd>
|
||||||
{% if last_output_truncated != last_output %}
|
{% if last_output_truncated != last_output %}
|
||||||
<dt class="col-md-3"></dt>
|
<dt class="col-md-3"></dt>
|
||||||
<dd class="col-md-9">
|
<dd class="col-md-9">
|
||||||
|
@ -420,7 +420,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body" style="word-wrap: break-word;">
|
<div class="modal-body" style="word-wrap: break-word;">
|
||||||
{{ last_output|nl2br }}
|
{{ last_output|raw|nl2br }}
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
|
Loading…
Reference in New Issue