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",
|
||||
"homepage": "https://www.phpservermonitor.org",
|
||||
"require": {
|
||||
"php": "^5.5.9|>=7.0.8",
|
||||
"php": "^7.4|>=8.1",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-pdo": "*",
|
||||
"ext-xml": "*",
|
||||
"phpmailer/phpmailer": ">=6.5.0 ~6.0",
|
||||
"symfony/config": "~3.4",
|
||||
"symfony/dependency-injection": "~4.0",
|
||||
"symfony/event-dispatcher": "~3.4",
|
||||
"symfony/http-foundation": ">=3.4.35 ~3.4",
|
||||
"symfony/filesystem": "~3.4",
|
||||
"php-pushover/php-pushover": "dev-master",
|
||||
"phpmailer/phpmailer": "^6.9",
|
||||
"symfony/config": "6.4",
|
||||
"symfony/dependency-injection": "6.4",
|
||||
"symfony/event-dispatcher": "6.4",
|
||||
"symfony/http-foundation": "6.4.16",
|
||||
"symfony/filesystem": "6.4",
|
||||
"symfony/deprecation-contracts": "^2.5",
|
||||
"symfony/event-dispatcher-contracts": "^2.5",
|
||||
"php-pushover/php-pushover": "^1.0",
|
||||
"paragonie/random_compat": "^9.99",
|
||||
"twig/twig": "~1.35",
|
||||
"twig/twig": "^3.8",
|
||||
"jaxl/jaxl": "^3.1",
|
||||
"viharm/psm-ldap-auth": "^1.1"
|
||||
},
|
||||
|
@ -29,5 +31,10 @@
|
|||
"psr-4": {
|
||||
"psm\\": "src/psm/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"mnsami/composer-custom-directory-installer": true
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -42,16 +42,16 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc
|
|||
<argument>%db.port%</argument>
|
||||
</service>
|
||||
|
||||
<service id="event" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
|
||||
<service id="event" class="Symfony\Component\EventDispatcher\EventDispatcher">
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
<service id="user" class="psm\Service\User">
|
||||
<argument type="service" id="db" />
|
||||
</service>
|
||||
<service id="twig.loader" class="Twig_Loader_Filesystem">
|
||||
<service id="twig.loader" class="Twig\Loader\FilesystemLoader">
|
||||
<argument>%path.templates%/%config.theme%</argument>
|
||||
</service>
|
||||
<service id="twig" class="Twig_Environment">
|
||||
<service id="twig" class="Twig\Environment">
|
||||
<argument type="service" id="twig.loader" />
|
||||
</service>
|
||||
<!--SERVICES end-->
|
||||
|
|
|
@ -495,20 +495,15 @@ namespace {
|
|||
$time = strtotime($time);
|
||||
}
|
||||
if ($time < strtotime(date('Y-m-d 00:00:00')) - 60 * 60 * 24 * 3) {
|
||||
$format = psm_get_lang('system', (date('Y') !== date('Y', $time)) ?
|
||||
'long_day_format' : 'short_day_format');
|
||||
// Check for Windows to find and replace the %e
|
||||
// modifier correctly
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
|
||||
}
|
||||
return strftime($format, $time);
|
||||
$format = psm_get_lang('system', (date('Y') !== date('Y', $time) ? 'long_day_format' : 'short_day_format'));
|
||||
|
||||
return formatLanguage($format, $time);
|
||||
}
|
||||
$d = time() - $time;
|
||||
if ($d >= 60 * 60 * 24) {
|
||||
$format = psm_get_lang('system', (date('l', time() - 60 * 60 * 24) == date('l', $time)) ?
|
||||
'yesterday_format' : 'other_day_format');
|
||||
return strftime($format, $time);
|
||||
return formatLanguage($format, $time);
|
||||
}
|
||||
if ($d >= 60 * 60 * 2) {
|
||||
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') {
|
||||
return psm_get_lang('system', 'never');
|
||||
}
|
||||
return strftime('%x %X', strtotime($time));
|
||||
return formatLanguage('%x %X', strtotime($time));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1013,6 +1008,74 @@ namespace {
|
|||
return $decrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert strftime format to php date format
|
||||
* @param $strftimeformat
|
||||
* @return string|string[]
|
||||
* @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
|
||||
*
|
||||
|
|
|
@ -109,7 +109,7 @@ abstract class AbstractController implements ControllerInterface
|
|||
|
||||
/**
|
||||
* Twig object
|
||||
* @var \Twig_Environment $twig
|
||||
* @var \Twig\Environment $twig
|
||||
*/
|
||||
protected $twig;
|
||||
|
||||
|
@ -146,7 +146,7 @@ abstract class AbstractController implements ControllerInterface
|
|||
*/
|
||||
protected $xhr = false;
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->twig = $twig;
|
||||
|
|
|
@ -114,7 +114,7 @@ class ConfigController extends AbstractController
|
|||
|
||||
private $default_tab = 'general';
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
parent::__construct($db, $twig);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
|||
interface ControllerInterface extends ContainerAwareInterface
|
||||
{
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig);
|
||||
public function __construct(Database $db, \Twig\Environment $twig);
|
||||
|
||||
/**
|
||||
* Run the controller
|
||||
|
|
|
@ -35,7 +35,7 @@ use psm\Service\Database;
|
|||
class ErrorController extends AbstractController
|
||||
{
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
parent::__construct($db, $twig);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class InstallController extends AbstractController
|
|||
*/
|
||||
protected $path_config_old;
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
parent::__construct($db, $twig);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ use psm\Service\Database;
|
|||
class LogController extends AbstractServerController
|
||||
{
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
parent::__construct($db, $twig);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class ServerController extends AbstractServerController
|
|||
*/
|
||||
protected $server_id;
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
parent::__construct($db, $twig);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ use psm\Service\Database;
|
|||
class StatusController extends AbstractServerController
|
||||
{
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
parent::__construct($db, $twig);
|
||||
|
||||
|
@ -70,6 +70,13 @@ class StatusController extends AbstractServerController
|
|||
'layout' => $layout,
|
||||
'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->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"])) {
|
||||
$this->xhr = true;
|
||||
//disable auto refresh in ajax return html
|
||||
|
|
|
@ -36,7 +36,7 @@ use psm\Service\Database;
|
|||
class UpdateController extends AbstractController
|
||||
{
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
parent::__construct($db, $twig);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ use psm\Service\Database;
|
|||
class LoginController extends AbstractController
|
||||
{
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
parent::__construct($db, $twig);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class ProfileController extends AbstractController
|
|||
protected $profile_fields =
|
||||
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);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class UserController extends AbstractController
|
|||
{
|
||||
public $servers = array();
|
||||
|
||||
public function __construct(Database $db, \Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
parent::__construct($db, $twig);
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ class Router
|
|||
}
|
||||
|
||||
$twig->addFunction(
|
||||
new \Twig_SimpleFunction(
|
||||
new \Twig\TwigFunction(
|
||||
'csrf_token',
|
||||
function ($lock_to = null) use ($session) {
|
||||
if (empty($lock_to)) {
|
||||
|
|
|
@ -67,11 +67,11 @@ class Modal implements ModalInterface
|
|||
|
||||
/**
|
||||
* Twig environment
|
||||
* @var \Twig_Environment $twig
|
||||
* @var \Twig\Environment $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->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(
|
||||
'modal_id' => $this->modal_id,
|
||||
'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
|
||||
{
|
||||
|
||||
public function __construct(\Twig_Environment $twig);
|
||||
public function __construct(\Twig\Environment $twig);
|
||||
|
||||
public function getModalID();
|
||||
public function createHTML();
|
||||
|
|
|
@ -57,7 +57,7 @@ class Sidebar implements SidebarInterface
|
|||
*/
|
||||
protected $twig;
|
||||
|
||||
public function __construct(\Twig_Environment $twig)
|
||||
public function __construct(\Twig\Environment $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);
|
||||
|
||||
return $html;
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace psm\Util\Module;
|
|||
interface SidebarInterface
|
||||
{
|
||||
|
||||
public function __construct(\Twig_Environment $twig);
|
||||
public function __construct(\Twig\Environment $twig);
|
||||
|
||||
public function createHTML();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace psm\Util\Server;
|
|||
use DateTime;
|
||||
use psm\Service\Database;
|
||||
use Twig\Error\Error;
|
||||
use Twig_Environment;
|
||||
use Twig\Environment;
|
||||
|
||||
/**
|
||||
* History util, create HTML for server graphs
|
||||
|
@ -52,7 +52,7 @@ class HistoryGraph
|
|||
*/
|
||||
protected $twig;
|
||||
|
||||
public function __construct(Database $db, Twig_Environment $twig)
|
||||
public function __construct(Database $db, \Twig\Environment $twig)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->twig = $twig;
|
||||
|
@ -310,7 +310,7 @@ class HistoryGraph
|
|||
// Previous datapoint was offline
|
||||
: ['x' => $time_ms, 'y' => null];
|
||||
// new outage start
|
||||
$lines['offline'][] = ['x' => $time_ms, 'y' => $highest_latency];
|
||||
$lines['offline'][] = ['x' => $time_ms, 'y' => 0];
|
||||
|
||||
if ($prev_downtime === 0) {
|
||||
$prev_downtime = $time;
|
||||
|
@ -322,7 +322,7 @@ class HistoryGraph
|
|||
// Previous datapoint was online
|
||||
? ['x' => $time_ms, 'y' => null]
|
||||
// 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)];
|
||||
|
||||
if ($prev_downtime !== 0) {
|
||||
|
|
|
@ -237,7 +237,7 @@
|
|||
<li class="list-group-item">
|
||||
<dl class="row">
|
||||
<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 %}
|
||||
<dt class="col-md-3"></dt>
|
||||
<dd class="col-md-9">
|
||||
|
@ -420,7 +420,7 @@
|
|||
</button>
|
||||
</div>
|
||||
<div class="modal-body" style="word-wrap: break-word;">
|
||||
{{ last_output|nl2br }}
|
||||
{{ last_output|raw|nl2br }}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
|
|
Loading…
Reference in New Issue