From 03014de725a6b4f31df4cc2d374b54981bfef746 Mon Sep 17 00:00:00 2001 From: damian Date: Mon, 1 Oct 2018 16:45:01 +1000 Subject: [PATCH] Added constant support for language pack %VARIABLES%. Updated en_US language pack to include source PSM server. --- src/includes/functions.inc.php | 5 +++++ src/lang/en_US.lang.php | 32 +++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index e3ea0e54..4889c73d 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -330,7 +330,12 @@ function psm_parse_msg($status, $type, $vars, $combi = false) { if (!$message) { return $message; } + $vars['date'] = date('Y-m-d H:i:s'); + + // merge the constants into the $vars so we can do a %LOOKUP% from language packs + $constants = get_defined_constants(true); + array_merge($vars, $constants['user']); foreach ($vars as $k => $v) { $message = str_replace('%'.strtoupper($k).'%', $v, $message); diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 34c26a31..db118c44 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -342,16 +342,30 @@ $sm_lang = array( 'notifications' => array( 'off_sms' => 'Server \'%LABEL%\' is DOWN: ip=%IP%, port=%PORT%. Error=%ERROR%', 'off_email_subject' => 'IMPORTANT: Server \'%LABEL%\' is DOWN', - 'off_email_body' => "Failed to connect to the following server:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Error: %ERROR%
Date: %DATE%", + 'off_email_body' => "Failed to connect to the following server:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Error: %ERROR%
Date: %DATE%

Source: %PSM_BASE_URL%", 'off_pushover_title' => 'Server \'%LABEL%\' is DOWN', - 'off_pushover_message' => "Failed to connect to the following server:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Error: %ERROR%
Date: %DATE%", - 'off_telegram_message' => "Failed to connect to the following server:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Error: %ERROR%
Date: %DATE%", + 'off_pushover_message' => "Failed to connect to the following server:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Error: %ERROR%
Date: %DATE%

Source: %PSM_BASE_URL%", + 'off_telegram_message' => "Failed to connect to the following server:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Error: %ERROR%
Date: %DATE%

Source: %PSM_BASE_URL%", 'on_sms' => 'Server \'%LABEL%\' is RUNNING: ip=%IP%, port=%PORT%, it was down for %LAST_OFFLINE_DURATION%', 'on_email_subject' => 'IMPORTANT: Server \'%LABEL%\' is RUNNING', - 'on_email_body' => "Server '%LABEL%' is running again, it was down for %LAST_OFFLINE_DURATION%:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Date: %DATE%", + 'on_email_body' => "Server '%LABEL%' is running again, it was down for %LAST_OFFLINE_DURATION%:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Date: %DATE%

Source: %PSM_BASE_URL%", 'on_pushover_title' => 'Server \'%LABEL%\' is RUNNING', - 'on_pushover_message' => 'Server \'%LABEL%\' is running again, it was down for %LAST_OFFLINE_DURATION%:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Date: %DATE%', - 'on_telegram_message' => 'Server \'%LABEL%\' is running again, it was down for :

Server: %LABEL%
IP: %IP%
Port: %PORT%
Downtime: %LAST_OFFLINE_DURATION%
Date: %DATE%', + 'on_pushover_message' => 'Server \'%LABEL%\' is running again, it was down for %LAST_OFFLINE_DURATION%:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Date: %DATE%

Source: %PSM_BASE_URL%', + 'on_telegram_message' => 'Server \'%LABEL%\' is running again, it was down for %LAST_OFFLINE_DURATION%:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Date: %DATE%

Source: %PSM_BASE_URL%', + ), + 'notifications' => array( + 'off_sms' => 'Server \'%LABEL%\' is DOWN: ip=%IP%, port=%PORT%. Error=%ERROR%', + 'off_email_subject' => 'IMPORTANT: Server \'%LABEL%\' is DOWN', + 'off_email_body' => "Failed to connect to the following server:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Error: %ERROR%
Date: %DATE%

Source: %PSM_BASE_URL%", + 'off_pushover_title' => 'Server \'%LABEL%\' is DOWN', + 'off_pushover_message' => "Failed to connect to the following server:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Error: %ERROR%
Date: %DATE%

Source: %PSM_BASE_URL%", + 'off_telegram_message' => "Failed to connect to the following server:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Error: %ERROR%
Date: %DATE%

Source: %PSM_BASE_URL%", + 'on_sms' => 'Server \'%LABEL%\' is RUNNING: ip=%IP%, port=%PORT%, it was down for %LAST_OFFLINE_DURATION%', + 'on_email_subject' => 'IMPORTANT: Server \'%LABEL%\' is RUNNING', + 'on_email_body' => "Server '%LABEL%' is running again, it was down for %LAST_OFFLINE_DURATION%:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Date: %DATE%

Source: %PSM_BASE_URL%", + 'on_pushover_title' => 'Server \'%LABEL%\' is RUNNING', + 'on_pushover_message' => 'Server \'%LABEL%\' is running again, it was down for %LAST_OFFLINE_DURATION%:

Server: %LABEL%
IP: %IP%
Port: %PORT%
Date: %DATE%

Source: %PSM_BASE_URL%', + 'on_telegram_message' => 'Server \'%LABEL%\' is running again, it was down for :

Server: %LABEL%
IP: %IP%
Port: %PORT%
Downtime: %LAST_OFFLINE_DURATION%
Date: %DATE%

Source: %PSM_BASE_URL%', 'combi_off_email_message' => "", 'combi_off_pushover_message' => "", 'combi_off_telegram_message' => "- Server: %LABEL%
- IP: %IP%
- Port: %PORT%
- Error: %ERROR%
- Date: %DATE%

", @@ -360,9 +374,9 @@ $sm_lang = array( 'combi_on_telegram_message' => '- Server: %LABEL%
- IP: %IP%
- Port: %PORT%
- Downtime: %LAST_OFFLINE_DURATION%
- Date: %DATE%

', 'combi_email_subject' => 'IMPORTANT: \'%UP%\' servers UP again, \'%DOWN%\' servers DOWN', 'combi_pushover_subject' => '\'%UP%\' servers UP again, \'%DOWN%\' servers DOWN', - 'combi_email_message' => 'The following servers went down:
%DOWN_SERVERS%
The following servers are up again:
%UP_SERVERS%', - 'combi_pushover_message' => 'The following servers went down:
%DOWN_SERVERS%
The following servers are up again:
%UP_SERVERS%', - 'combi_telegram_message' => 'The following servers went down:
%DOWN_SERVERS%
The following servers are up again:
%UP_SERVERS%', + 'combi_email_message' => 'The following servers went down:
%DOWN_SERVERS%
The following servers are up again:
%UP_SERVERS%

Source: %PSM_BASE_URL%', + 'combi_pushover_message' => 'The following servers went down:
%DOWN_SERVERS%
The following servers are up again:
%UP_SERVERS%

Source: %PSM_BASE_URL%', + 'combi_telegram_message' => 'The following servers went down:
%DOWN_SERVERS%
The following servers are up again:
%UP_SERVERS%

Source: %PSM_BASE_URL%', ), 'login' => array( 'welcome_usermenu' => 'Welcome, %user_name%',