Merge branch 'develop' for v2.1.0 release
commit
c5fab10a9e
|
|
@ -0,0 +1,3 @@
|
||||||
|
.idea/*
|
||||||
|
/nbproject
|
||||||
|
/config.php
|
||||||
|
|
@ -5,10 +5,16 @@
|
||||||
#########################
|
#########################
|
||||||
- Merged PHP Server Monitor Plus project by Luiz Alberto S. Ribeiro (https://github.com/madeinnordeste/PHP-Server-Monitor-Plus).
|
- Merged PHP Server Monitor Plus project by Luiz Alberto S. Ribeiro (https://github.com/madeinnordeste/PHP-Server-Monitor-Plus).
|
||||||
-- New layout (thanks to twitter bootstrap)
|
-- New layout (thanks to twitter bootstrap)
|
||||||
- Support for mosms provider by Andreas Ek (https://github.com/EkAndreas/PHP-Server-Monitor-Plus/commit/105c734a02477befc01831e3b9b2b8fefd9b5ca5).
|
- New install module.
|
||||||
|
- Regex search on website has been added by Paul Feakins.
|
||||||
|
- Support for mosms provider by Andreas Ek.
|
||||||
|
- Support for Textmarketer provider by Perri Vardy-Mason.
|
||||||
- Language files are now automatically detected, instead of a hardcoded list.
|
- Language files are now automatically detected, instead of a hardcoded list.
|
||||||
- Adding Korean language file (thanks to Ik-Jun).
|
- Adding Korean language file (thanks to Ik-Jun).
|
||||||
|
- Adding Portuguese / Brazilian language file (thanks to Luiz Alberto S. Ribeiro).
|
||||||
- Large status page by Michael Greenhill.
|
- Large status page by Michael Greenhill.
|
||||||
|
- New config file (see install instructions in README).
|
||||||
|
- Cronjob will be prevented from running multiple times at the same time (with a 10 mins timeout).
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
#
|
#
|
||||||
|
|
|
||||||
89
README.md
89
README.md
|
|
@ -6,7 +6,7 @@ PHP Server Monitor is a script that checks whether the servers on your list are
|
||||||
It comes with a web based user interface where you can add and remove servers or websites from the MySQL database,
|
It comes with a web based user interface where you can add and remove servers or websites from the MySQL database,
|
||||||
and you can manage users for each server with a mobile number and email address.
|
and you can manage users for each server with a mobile number and email address.
|
||||||
|
|
||||||
With version 2.0 there's the support for websites as well. On the "Add server" page, you can choose
|
With version 2 there's the support for websites as well. On the "Add server" page, you can choose
|
||||||
whether it is a "service" or a "website":
|
whether it is a "service" or a "website":
|
||||||
|
|
||||||
* Service
|
* Service
|
||||||
|
|
@ -17,24 +17,22 @@ whether it is a "service" or a "website":
|
||||||
|
|
||||||
* Website
|
* Website
|
||||||
|
|
||||||
The previous version only tried to establish a connection to the server on port 80. If you are running multiple
|
|
||||||
websites on 1 machine, there was no proper way to check each website for possible errors. Also it was impossible to make
|
|
||||||
sure your site was really up and running, all you knew was that the server was still online.
|
|
||||||
This function takes care of that.
|
|
||||||
You can enter a link to a website (for example <http://sourceforge.net/index.php>), it will use cURL to open the website and
|
You can enter a link to a website (for example <http://sourceforge.net/index.php>), it will use cURL to open the website and
|
||||||
check the HTTP status code (see <http://en.wikipedia.org/wiki/List_of_HTTP_status_codes> for details).
|
check the HTTP status code (see <http://en.wikipedia.org/wiki/List_of_HTTP_status_codes> for details).
|
||||||
If the HTTP status code is in the 4xx range, it means an error occured and the website is not accesible to the public.
|
If the HTTP status code is in the 4xx range, it means an error occurred and the website is not accessible to the public.
|
||||||
In that case the script will return a "status offline", and will start sending out notifications.
|
You can also set a regular expression to match certain content on the page itself. If the regular expression returns no matches, the website is considered down.
|
||||||
|
In both cases the script will return a "status offline", and will start sending out notifications.
|
||||||
|
|
||||||
Each server has it's own settings regarding notification.
|
Each server has it's own settings regarding notification.
|
||||||
You can choose for email notification or text message (SMS). As of version 2.0, there are 3 gateways
|
You can choose for email notification or text message (SMS).
|
||||||
available:
|
The following SMS gateways are currently available:
|
||||||
|
|
||||||
* Mollie - <http://www.mollie.nl>
|
* Mollie - <http://www.mollie.nl>
|
||||||
* Spryng - <http://www.spryng.nl>
|
* Spryng - <http://www.spryng.nl>
|
||||||
* Inetworx - <http://www.inetworx.ch>
|
* Inetworx - <http://www.inetworx.ch>
|
||||||
* Clickatell - <https://www.clickatell.com>
|
* Clickatell - <https://www.clickatell.com>
|
||||||
* Mosms - <http://www.mosms.com>
|
* Mosms - <http://www.mosms.com>
|
||||||
|
* Textmarketer - <http://www.textmarketer.co.uk>
|
||||||
|
|
||||||
For these gateways you need an account with sufficient credits.
|
For these gateways you need an account with sufficient credits.
|
||||||
|
|
||||||
|
|
@ -45,60 +43,76 @@ The cron/status.cron.php can be added as a cronjob which will keep the server st
|
||||||
I'd appreciate any feedback you might have regarding this script. Please leave it on the GitHub
|
I'd appreciate any feedback you might have regarding this script. Please leave it on the GitHub
|
||||||
project page (tracker), or send me an email (see top of file for link).
|
project page (tracker), or send me an email (see top of file for link).
|
||||||
|
|
||||||
|
|
||||||
## DOWNLOAD
|
## DOWNLOAD
|
||||||
|
|
||||||
The latest version can be found at <http://phpservermon.neanderthal-technology.com/>.
|
The latest version can be found at <http://phpservermon.neanderthal-technology.com/>.
|
||||||
You can also clone the git repo at <http://github.com/dopeh/phpservermon>.
|
You can also clone the git repo at <http://github.com/phpservermon/phpservermon> if you want to contribute.
|
||||||
|
|
||||||
|
|
||||||
## REQUIREMENTS
|
## REQUIREMENTS
|
||||||
|
|
||||||
* PHP 5
|
* PHP 5.3+
|
||||||
* PHP packages: cURL
|
* PHP packages: cURL, MySQL
|
||||||
* MySQL Database
|
* MySQL Database
|
||||||
* FTP access
|
|
||||||
|
|
||||||
|
|
||||||
## INSTALL
|
## INSTALL
|
||||||
|
|
||||||
By default the PHP Server Monitor does not come with any security methods. After uploading these files to
|
|
||||||
your public html folder these will be visible to everyone on the web. It is recommended to put a password
|
|
||||||
on this folder to prevent other people from playing with your tool. An example .htaccess login script can
|
|
||||||
be found in the example/ dir. To create your own username and password for the .htpasswd file, see
|
|
||||||
<http://www.htaccesstools.com/htpasswd-generator/>
|
|
||||||
|
|
||||||
### 1. Configuration
|
### 1. Configuration
|
||||||
|
|
||||||
Rename the config.inc.php.sample file to config.inc.php, then open the
|
The install script will guide you through setting up the configuration, but if you want to be ahead of the game, you can do this one first.
|
||||||
config.inc.php file with a plain text editor such as Notepad.
|
Rename the config.php.sample file to config.php, then open the config.php file with a plain text editor such as Notepad.
|
||||||
The first thing to do now in order to get started, is to get your database login information
|
The first thing to do is to get your database login information right.
|
||||||
right. The information is stored using php's define() function.
|
The information is stored using php's define() function.
|
||||||
To change these values correctly, only update the second parameter of the function.
|
To change these values correctly, only update the second parameter of the function.
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
define('SM_DB_USER', 'db_user');
|
define('PSM_DB_USER', 'db_user');
|
||||||
|
|
||||||
To change your username you should ONLY change the 'db\_user' part.
|
To change your username you should ONLY change the 'db\_user' part.
|
||||||
Do NOT remove the quotes around your username as that will result in an error.
|
Do NOT remove the quotes around your username as that will result in an error.
|
||||||
|
If you do not feel comfortable doing this, skip this step and the install script will generate it for you.
|
||||||
|
|
||||||
### 2. Upload files
|
### 2. Upload files
|
||||||
|
|
||||||
The next step is to get your files onto your webserver where you can reach them.
|
The next step is to get your files onto your webserver where you can reach them.
|
||||||
You can rename the folder of the server monitor without trouble, but if you change the structure please make sure
|
You can rename the folder of the server monitor without trouble.
|
||||||
to update the settings in the config.php file.
|
|
||||||
|
|
||||||
### 3. Run install.php
|
### 3. Run install.php
|
||||||
|
|
||||||
Once your database login information is correct, you can run the install.php script located in the root dir.
|
You can now run the install.php script located in the root dir.
|
||||||
This script will create all the database tables you will need.
|
|
||||||
After running the install.php script you can remove it.
|
|
||||||
|
|
||||||
### 4. Configure your installation
|
### 4. Configure your installation
|
||||||
|
|
||||||
Open the main page of the server monitor, by simply calling index.php. In the menu on the top find "config",
|
Open the main page of the server monitor, by simply calling index.php. In the menu on the top find "config",
|
||||||
it will open a page where you can change the necessary information for your tool.
|
it will open a page where you can change the necessary information for your tool.
|
||||||
|
|
||||||
### 5. [optional] Add a cronjob
|
|
||||||
|
## UPGRADE
|
||||||
|
|
||||||
|
### From 2.0
|
||||||
|
|
||||||
|
The structure of the project has changed quite a bit since 2.0, but if you have not made any local changes the upgrade is quite easy.
|
||||||
|
The best thing to do is to replace all your current files with the new release, except for the config.inc.php file.
|
||||||
|
The config file has actually been renamed since 2.0, but if you keep it there while upgrading the install script will use it to prefill your database information.
|
||||||
|
|
||||||
|
* Replace all files except(!) config.inc.php
|
||||||
|
* Navigate to install.php
|
||||||
|
* Follow the steps
|
||||||
|
* Remove the old config.inc.php file
|
||||||
|
|
||||||
|
|
||||||
|
## Security
|
||||||
|
|
||||||
|
By default the PHP Server Monitor does not (yet) come with any security methods. After uploading these files to
|
||||||
|
your public html folder these will be visible to everyone on the web. It is recommended to put a password
|
||||||
|
on this folder to prevent other people from playing with your tool. An example .htaccess login script can
|
||||||
|
be found in the example/ dir. To create your own username and password for the .htpasswd file, see
|
||||||
|
<http://www.htaccesstools.com/htpasswd-generator/>
|
||||||
|
|
||||||
|
|
||||||
|
## Setting up a cronjob
|
||||||
|
|
||||||
In order to keep the server monitor up to date, the monitor.php file has to run regularly.
|
In order to keep the server monitor up to date, the monitor.php file has to run regularly.
|
||||||
If you're running this on a linux machine, the easiest way is to add a cronjob.
|
If you're running this on a linux machine, the easiest way is to add a cronjob.
|
||||||
|
|
@ -109,9 +123,10 @@ If it is your own server or you have shell access and permission to open the cro
|
||||||
*/15 * * * * root /usr/bin/php /var/www/html/phpservermon/cron/status.cron.php
|
*/15 * * * * root /usr/bin/php /var/www/html/phpservermon/cron/status.cron.php
|
||||||
|
|
||||||
As you can see, this line will run the status.cron.php script every 15 minutes. Change the line to suit your needs.
|
As you can see, this line will run the status.cron.php script every 15 minutes. Change the line to suit your needs.
|
||||||
If you do not have shell access, ask your webhosting to set it up for you.
|
If you do not have shell access, ask your web hosting provider to set it up for you.
|
||||||
|
|
||||||
### 6. Voila!
|
The update script has been designed to prevent itself from running multiple times. It has a maximum timeout of 10 minutes.
|
||||||
|
After that the script is assumed dead and the cronjob will run again.
|
||||||
|
|
||||||
|
|
||||||
## CUSTOMIZING
|
## CUSTOMIZING
|
||||||
|
|
@ -119,7 +134,7 @@ If you do not have shell access, ask your webhosting to set it up for you.
|
||||||
### Language
|
### Language
|
||||||
|
|
||||||
The server monitor uses language files. That means that any regular text you see on the screen can easily be
|
The server monitor uses language files. That means that any regular text you see on the screen can easily be
|
||||||
changed without having to digg through the code. These language files are stored in the directory "lang".
|
changed without having to dig through the code. These language files are stored in the directory "src/lang".
|
||||||
The language that's being used by the monitor is defined in the config table. If you like
|
The language that's being used by the monitor is defined in the config table. If you like
|
||||||
you can make changes to the language file or even add a new one.
|
you can make changes to the language file or even add a new one.
|
||||||
|
|
||||||
|
|
@ -147,19 +162,21 @@ The second part is the actual message. There are a few variables you can use in
|
||||||
|
|
||||||
To add a new language, follow these steps:
|
To add a new language, follow these steps:
|
||||||
|
|
||||||
* Create a new file in the directory "lang" named "mylanguage.lang.php".
|
* Create a new file in the directory "src/lang" named "mylanguage.lang.php".
|
||||||
* Copy the contents of the file "en.lang.php" to your new file.
|
* Copy the contents of the file "en.lang.php" to your new file.
|
||||||
* Your new language should now be available on the config page.
|
* Your new language should now be available on the config page.
|
||||||
* Translate the English stuff to your own language.
|
* Translate the English stuff to your own language.
|
||||||
* Send a copy to pep[at]neanderthal-technology.com so I can add it to the next release :)
|
* Send a copy to pep[at]neanderthal-technology.com so I can add it to the next release :)
|
||||||
* Or, send me a pull request on github.
|
* Or, send me a pull request on github (https://github.com/phpservermon/phpservermon).
|
||||||
|
|
||||||
## CREDITS
|
## CREDITS
|
||||||
|
|
||||||
* classes/phpmailer.class.php - Brent R. Matzelle
|
* Bugfixes & features - Perri Vardy-Mason
|
||||||
|
* PHP Mailer - Brent R. Matzelle
|
||||||
* German translation - Brunbaur Herbert
|
* German translation - Brunbaur Herbert
|
||||||
* French translation - David Ribeiro
|
* French translation - David Ribeiro
|
||||||
* Korean translation - Ik-Jun
|
* Korean translation - Ik-Jun
|
||||||
|
* Brazilian translation - Luiz Alberto S. Ribeiro
|
||||||
* Bootstrap implementation - Luiz Alberto S. Ribeiro
|
* Bootstrap implementation - Luiz Alberto S. Ribeiro
|
||||||
* Mosms implementation - Andreas Ek
|
* Mosms implementation - Andreas Ek
|
||||||
* Status page - Michael Greenhill
|
* Status page - Michael Greenhill
|
||||||
|
|
|
||||||
|
|
@ -1,196 +0,0 @@
|
||||||
<?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@neanderthal-technology.com>
|
|
||||||
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
|
||||||
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
|
||||||
* @version Release: @package_version@
|
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
|
||||||
**/
|
|
||||||
|
|
||||||
class modConfig extends modCore {
|
|
||||||
|
|
||||||
function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
|
|
||||||
if(!empty($_POST)) {
|
|
||||||
$this->executeSave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// override parent::createHTML()
|
|
||||||
public function createHTML() {
|
|
||||||
$this->setTemplateId('config', 'config.tpl.html');
|
|
||||||
|
|
||||||
$this->populateFields();
|
|
||||||
|
|
||||||
return parent::createHTML();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Populate all the config fields with values from the database
|
|
||||||
*/
|
|
||||||
public function populateFields() {
|
|
||||||
$config_db = $this->db->select(
|
|
||||||
SM_DB_PREFIX . 'config',
|
|
||||||
null,
|
|
||||||
array('key', 'value')
|
|
||||||
);
|
|
||||||
|
|
||||||
$config = array();
|
|
||||||
foreach($config_db as $entry) {
|
|
||||||
$config[$entry['key']] = $entry['value'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate language array
|
|
||||||
$lang_keys = sm_get_langs();
|
|
||||||
$languages = array();
|
|
||||||
foreach($lang_keys as $key) {
|
|
||||||
$label = sm_get_lang('config', 'language_' . $key);
|
|
||||||
// if we don't have a proper label, just show the key..
|
|
||||||
// better something than nothing huh
|
|
||||||
if($label == null) {
|
|
||||||
$label = $key;
|
|
||||||
}
|
|
||||||
$languages[] = array(
|
|
||||||
'value' => $key,
|
|
||||||
'label' => $label,
|
|
||||||
'selected' => ($key == $config['language']) ? 'selected="selected"' : '',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$this->tpl->addTemplateDataRepeat($this->getTemplateId(), 'languages', $languages);
|
|
||||||
|
|
||||||
$this->tpl->addTemplateData(
|
|
||||||
$this->getTemplateId(),
|
|
||||||
array(
|
|
||||||
'email_status_checked' => ($config['email_status'] == '1') ? 'checked="checked"' : '',
|
|
||||||
'email_from_name' => $config['email_from_name'],
|
|
||||||
'email_from_email' => $config['email_from_email'],
|
|
||||||
'sms_status_checked' => ($config['sms_status'] == '1') ? 'checked="checked"' : '',
|
|
||||||
'sms_selected_' . $config['sms_gateway'] => 'selected="selected"',
|
|
||||||
'sms_gateway_username' => $config['sms_gateway_username'],
|
|
||||||
'sms_gateway_password' => $config['sms_gateway_password'],
|
|
||||||
'sms_from' => $config['sms_from'],
|
|
||||||
'alert_type_selected_' . $config['alert_type'] => 'selected="selected"',
|
|
||||||
'log_status_checked' => ($config['log_status'] == '1') ? 'checked="checked"' : '',
|
|
||||||
'log_email_checked' => ($config['log_email'] == '1') ? 'checked="checked"' : '',
|
|
||||||
'log_sms_checked' => ($config['log_sms'] == '1') ? 'checked="checked"' : '',
|
|
||||||
'show_update_checked' => ($config['show_update'] == '1') ? 'checked="checked"' : '',
|
|
||||||
'auto_refresh_servers' => (isset($config['auto_refresh_servers'])) ? $config['auto_refresh_servers'] : '0',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If a post has been done, gather all the posted data
|
|
||||||
* and save it to the database
|
|
||||||
*/
|
|
||||||
protected function executeSave() {
|
|
||||||
// save new config
|
|
||||||
$clean = array(
|
|
||||||
'language' => $_POST['language'],
|
|
||||||
'show_update' => (isset($_POST['show_update'])) ? '1' : '0',
|
|
||||||
'email_status' => (isset($_POST['email_status'])) ? '1' : '0',
|
|
||||||
'email_from_name' => $_POST['email_from_name'],
|
|
||||||
'email_from_email' => $_POST['email_from_email'],
|
|
||||||
'sms_status' => (isset($_POST['sms_status'])) ? '1' : '0',
|
|
||||||
'sms_gateway' => $_POST['sms_gateway'],
|
|
||||||
'sms_gateway_username' => $_POST['sms_gateway_username'],
|
|
||||||
'sms_gateway_password' => $_POST['sms_gateway_password'],
|
|
||||||
'sms_from' => $_POST['sms_from'],
|
|
||||||
'alert_type' => $_POST['alert_type'],
|
|
||||||
'log_status' => (isset($_POST['log_status'])) ? '1' : '0',
|
|
||||||
'log_email' => (isset($_POST['log_email'])) ? '1' : '0',
|
|
||||||
'log_sms' => (isset($_POST['log_sms'])) ? '1' : '0',
|
|
||||||
'auto_refresh_servers' => (isset($_POST['auto_refresh_servers'])) ? intval($_POST['auto_refresh_servers']) : '0',
|
|
||||||
);
|
|
||||||
|
|
||||||
// save all values to the database
|
|
||||||
foreach($clean as $key => $value) {
|
|
||||||
// check if key already exists, otherwise add it
|
|
||||||
if(sm_get_conf($key) === null) {
|
|
||||||
// not yet set, add it
|
|
||||||
$this->db->save(
|
|
||||||
SM_DB_PREFIX . 'config',
|
|
||||||
array(
|
|
||||||
'key' => $key,
|
|
||||||
'value' => $value,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// update
|
|
||||||
$this->db->save(
|
|
||||||
SM_DB_PREFIX . 'config',
|
|
||||||
array('value' => $value),
|
|
||||||
array('key' => $key)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->message = sm_get_lang('config', 'updated');
|
|
||||||
|
|
||||||
if($clean['language'] != sm_get_conf('language')) {
|
|
||||||
header('Location: ' . $_SERVER['REQUEST_URI']);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// override parent::createHTMLLabels()
|
|
||||||
protected function createHTMLLabels() {
|
|
||||||
$this->tpl->addTemplateData(
|
|
||||||
$this->getTemplateId(),
|
|
||||||
array(
|
|
||||||
'label_settings_email' => sm_get_lang('config', 'settings_email'),
|
|
||||||
'label_settings_sms' => sm_get_lang('config', 'settings_sms'),
|
|
||||||
'label_settings_notification' => sm_get_lang('config', 'settings_notification'),
|
|
||||||
'label_settings_log' => sm_get_lang('config', 'settings_log'),
|
|
||||||
'label_general' => sm_get_lang('config', 'general'),
|
|
||||||
'label_language' => sm_get_lang('config', 'language'),
|
|
||||||
'label_show_update' => sm_get_lang('config', 'show_update'),
|
|
||||||
'label_email_status' => sm_get_lang('config', 'email_status'),
|
|
||||||
'label_email_from_email' => sm_get_lang('config', 'email_from_email'),
|
|
||||||
'label_email_from_name' => sm_get_lang('config', 'email_from_name'),
|
|
||||||
'label_sms_status' => sm_get_lang('config', 'sms_status'),
|
|
||||||
'label_sms_gateway' => sm_get_lang('config', 'sms_gateway'),
|
|
||||||
'label_sms_gateway_mosms' => sm_get_lang('config', 'sms_gateway_mosms'),
|
|
||||||
'label_sms_gateway_mollie' => sm_get_lang('config', 'sms_gateway_mollie'),
|
|
||||||
'label_sms_gateway_spryng' => sm_get_lang('config', 'sms_gateway_spryng'),
|
|
||||||
'label_sms_gateway_inetworx' => sm_get_lang('config', 'sms_gateway_inetworx'),
|
|
||||||
'label_sms_gateway_clickatell' => sm_get_lang('config', 'sms_gateway_clickatell'),
|
|
||||||
'label_sms_gateway_username' => sm_get_lang('config', 'sms_gateway_username'),
|
|
||||||
'label_sms_gateway_password' => sm_get_lang('config', 'sms_gateway_password'),
|
|
||||||
'label_sms_from' => sm_get_lang('config', 'sms_from'),
|
|
||||||
'label_alert_type' => sm_get_lang('config', 'alert_type'),
|
|
||||||
'label_alert_type_description' => sm_get_lang('config', 'alert_type_description'),
|
|
||||||
'label_alert_type_status' => sm_get_lang('config', 'alert_type_status'),
|
|
||||||
'label_alert_type_offline' => sm_get_lang('config', 'alert_type_offline'),
|
|
||||||
'label_alert_type_always' => sm_get_lang('config', 'alert_type_always'),
|
|
||||||
'label_log_status' => sm_get_lang('config', 'log_status'),
|
|
||||||
'label_log_email' => sm_get_lang('config', 'log_email'),
|
|
||||||
'label_log_sms' => sm_get_lang('config', 'log_sms'),
|
|
||||||
'label_auto_refresh_servers' => sm_get_lang('config', 'auto_refresh_servers'),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return parent::createHTMLLabels();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
@ -1,189 +0,0 @@
|
||||||
<?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@neanderthal-technology.com>
|
|
||||||
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
|
||||||
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
|
||||||
* @version Release: @package_version@
|
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
|
||||||
**/
|
|
||||||
|
|
||||||
abstract class modCore {
|
|
||||||
/**
|
|
||||||
* Custom message
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $message;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Current mode. Can be used by modules to determine
|
|
||||||
* what to do
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $mode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add footer to page?
|
|
||||||
* @var boolean $add_footer
|
|
||||||
*/
|
|
||||||
protected $add_footer = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* smDatabase object
|
|
||||||
* @var object
|
|
||||||
*/
|
|
||||||
protected $db;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* smTemplate object
|
|
||||||
* @var object
|
|
||||||
*/
|
|
||||||
protected $tpl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Template Id that should be added to the main template
|
|
||||||
* @var string
|
|
||||||
* @see setTemplateId() getTemplateId()
|
|
||||||
*/
|
|
||||||
protected $tpl_id;
|
|
||||||
|
|
||||||
function __construct() {
|
|
||||||
global $db;
|
|
||||||
|
|
||||||
$this->db = ($db) ? $db : new smDatabase();
|
|
||||||
$this->tpl = new smTemplate();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the HTML code for the module.
|
|
||||||
* First the createHTMLLabels() will be called to add all labels to the template,
|
|
||||||
* Then the tpl_id set in $this->getTemplateId() will be added to the main template automatically
|
|
||||||
*/
|
|
||||||
public function createHTML() {
|
|
||||||
// add footer to page?
|
|
||||||
if($this->add_footer) {
|
|
||||||
$this->tpl->newTemplate('main_footer', 'main.tpl.html');
|
|
||||||
$html_footer = $this->tpl->getTemplate('main_footer');
|
|
||||||
} else {
|
|
||||||
$html_footer = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sm_get_conf('show_update')) {
|
|
||||||
// user wants updates, lets see what we can do
|
|
||||||
$this->createHTMLUpdateAvailable();
|
|
||||||
}
|
|
||||||
$this->createHTMLLabels();
|
|
||||||
|
|
||||||
// add the module's custom template to the main template to get some content
|
|
||||||
$this->tpl->addTemplatedata(
|
|
||||||
'main',
|
|
||||||
array(
|
|
||||||
'content' => $this->tpl->getTemplate($this->getTemplateId()),
|
|
||||||
'message' => ($this->message == '') ? ' ' : $this->message,
|
|
||||||
'html_footer' => $html_footer,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// display main template
|
|
||||||
echo $this->tpl->display('main');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* First check if an update is available, if there is add a message
|
|
||||||
* to the main template
|
|
||||||
*/
|
|
||||||
protected function createHTMLUpdateAvailable() {
|
|
||||||
// check for updates?
|
|
||||||
|
|
||||||
if(sm_check_updates()) {
|
|
||||||
// yay, new update available =D
|
|
||||||
$this->tpl->addTemplateData(
|
|
||||||
'main',
|
|
||||||
array(
|
|
||||||
'update_available' => '<div id="update">'.sm_get_lang('system', 'update_available').'</div>',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this to add language specific labels to template
|
|
||||||
*
|
|
||||||
* @see createHTML()
|
|
||||||
*/
|
|
||||||
protected function createHTMLLabels() {
|
|
||||||
global $type;
|
|
||||||
|
|
||||||
$this->tpl->addTemplateData(
|
|
||||||
'main',
|
|
||||||
array(
|
|
||||||
'title' => strtoupper(sm_get_lang('system', 'title')),
|
|
||||||
'subtitle' => sm_get_lang('system', $type),
|
|
||||||
'active_' . $type => 'active',
|
|
||||||
'label_servers' => sm_get_lang('system', 'servers'),
|
|
||||||
'label_users' => sm_get_lang('system', 'users'),
|
|
||||||
'label_log' => sm_get_lang('system', 'log'),
|
|
||||||
'label_config' => sm_get_lang('system', 'config'),
|
|
||||||
'label_update' => sm_get_lang('system', 'update'),
|
|
||||||
'label_help' => sm_get_lang('system', 'help'),
|
|
||||||
'label_back_to_top' => sm_get_lang('system', 'back_to_top'),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a template id that will be added to the main template automatically
|
|
||||||
* once you call the parent::createHTML()
|
|
||||||
*
|
|
||||||
* @param string $tpl_id
|
|
||||||
* @param string $tpl_file if given, the tpl_id will be created automatically from this file
|
|
||||||
* @see getTemplateId() createHTML()
|
|
||||||
*/
|
|
||||||
public function setTemplateId($tpl_id, $tpl_file = null) {
|
|
||||||
$this->tpl_id = $tpl_id;
|
|
||||||
|
|
||||||
if($tpl_file != null) {
|
|
||||||
// tpl_file given, try to load the template..
|
|
||||||
$this->tpl->newTemplate($tpl_id, $tpl_file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the mpalte id that will be added to the main template
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
* @see setTemplateId()
|
|
||||||
*/
|
|
||||||
public function getTemplateId() {
|
|
||||||
return $this->tpl_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hide or show the footer of the page
|
|
||||||
* @param boolean $value
|
|
||||||
*/
|
|
||||||
protected function addFooter($value) {
|
|
||||||
$this->add_footer = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
<?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@neanderthal-technology.com>
|
|
||||||
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
|
||||||
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
|
||||||
* @version Release: @package_version@
|
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
|
||||||
**/
|
|
||||||
|
|
||||||
########################################
|
|
||||||
#
|
|
||||||
# START SERVER MONITOR CONFIGURATION
|
|
||||||
#
|
|
||||||
########################################
|
|
||||||
|
|
||||||
// Database information
|
|
||||||
// Prefix used for tables
|
|
||||||
define('SM_DB_PREFIX', 'monitor_');
|
|
||||||
// Database username
|
|
||||||
define('SM_DB_USER', 'db_user');
|
|
||||||
// Database password
|
|
||||||
define('SM_DB_PASS', 'db_pass');
|
|
||||||
// Database name
|
|
||||||
define('SM_DB_NAME', 'db_name');
|
|
||||||
// Database host
|
|
||||||
define('SM_DB_HOST', 'localhost');
|
|
||||||
|
|
||||||
########################################
|
|
||||||
#
|
|
||||||
# END SERVER MONITOR CONFIGURATION
|
|
||||||
#
|
|
||||||
########################################
|
|
||||||
|
|
||||||
// Include paths
|
|
||||||
// Tell the script where to find the templates, css files and javascript files.
|
|
||||||
// If you haven't changed anything to the structure you should leave these unchanged
|
|
||||||
define('SM_PATH_TPL', 'tpl/');
|
|
||||||
define('SM_PATH_CSS', 'inc/');
|
|
||||||
define('SM_PATH_JS', 'inc/');
|
|
||||||
|
|
||||||
error_reporting(0);
|
|
||||||
ini_set('display_errors', 'Off');
|
|
||||||
|
|
||||||
require 'functions.inc.php';
|
|
||||||
$db = new smDatabase();
|
|
||||||
|
|
||||||
sm_load_conf();
|
|
||||||
|
|
||||||
$lang = sm_get_conf('language');
|
|
||||||
|
|
||||||
if(!$lang) {
|
|
||||||
$lang = 'en';
|
|
||||||
}
|
|
||||||
sm_load_lang($lang);
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
@ -25,13 +25,10 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
abstract class smCore {
|
define('PSM_CONFIG', true);
|
||||||
public $db;
|
define('PSM_DB_PREFIX', 'monitor_');
|
||||||
|
define('PSM_DB_USER', 'db_user');
|
||||||
function __construct() {
|
define('PSM_DB_PASS', 'db_pass');
|
||||||
// add database handler
|
define('PSM_DB_NAME', 'db_name');
|
||||||
$this->db = $GLOBALS['db'];
|
define('PSM_DB_HOST', 'localhost');
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
@ -26,16 +26,25 @@
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// include main configuration and functionality
|
// include main configuration and functionality
|
||||||
require_once dirname(__FILE__) . '/../config.inc.php';
|
require_once dirname(__FILE__) . '/../src/bootstrap.php';
|
||||||
|
|
||||||
|
// prevent cron from running twice at the same time
|
||||||
|
// however if the cron has been running for 10 mins, we'll assume it died and run anyway
|
||||||
|
$time = time();
|
||||||
|
if(psm_get_conf('cron_running') == 1 && ($time - psm_get_conf('cron_running_time') < 600)) {
|
||||||
|
die('Cron is already running. Exiting.');
|
||||||
|
}
|
||||||
|
psm_update_conf('cron_running', 1);
|
||||||
|
psm_update_conf('cron_running_time', $time);
|
||||||
|
|
||||||
// get the active servers from database
|
// get the active servers from database
|
||||||
$servers = $db->select(
|
$servers = $db->select(
|
||||||
SM_DB_PREFIX.'servers',
|
PSM_DB_PREFIX.'servers',
|
||||||
array('active' => 'yes'),
|
array('active' => 'yes'),
|
||||||
array('server_id', 'ip', 'port', 'label', 'type', 'status', 'active', 'email', 'sms')
|
array('server_id', 'ip', 'port', 'label', 'type', 'pattern', 'status', 'active', 'email', 'sms')
|
||||||
);
|
);
|
||||||
|
|
||||||
$updater = new smUpdaterStatus();
|
$updater = new \psm\Util\Updater\Status();
|
||||||
|
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
$status_org = $server['status'];
|
$status_org = $server['status'];
|
||||||
|
|
@ -64,10 +73,12 @@ foreach ($servers as $server) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->save(
|
$db->save(
|
||||||
SM_DB_PREFIX . 'servers',
|
PSM_DB_PREFIX . 'servers',
|
||||||
$save,
|
$save,
|
||||||
array('server_id' => $server['server_id'])
|
array('server_id' => $server['server_id'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
psm_update_conf('cron_running', 0);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
12
index.php
12
index.php
|
|
@ -25,12 +25,9 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
if(!file_exists('config.inc.php')) {
|
require 'src/bootstrap.php';
|
||||||
die('Failed to locate config file. Please read README.md for more information on how to setup PHP Server Monitor.');
|
|
||||||
}
|
|
||||||
require_once 'config.inc.php';
|
|
||||||
|
|
||||||
sm_no_cache();
|
psm_no_cache();
|
||||||
|
|
||||||
if(isset($_GET['action']) && $_GET['action'] == 'check') {
|
if(isset($_GET['action']) && $_GET['action'] == 'check') {
|
||||||
require 'cron/status.cron.php';
|
require 'cron/status.cron.php';
|
||||||
|
|
@ -44,9 +41,10 @@ $allowed_types = array('servers', 'users', 'log', 'config', 'status');
|
||||||
if(!in_array($type, $allowed_types)) {
|
if(!in_array($type, $allowed_types)) {
|
||||||
$type = $allowed_types[0];
|
$type = $allowed_types[0];
|
||||||
}
|
}
|
||||||
|
$tpl = new \psm\Service\Template();
|
||||||
|
|
||||||
eval('$mod = new mod'.ucfirst($type).'();');
|
eval('$mod = new psm\Module\\'.ucfirst($type).'($db, $tpl);');
|
||||||
// let the module prepare it's HTML code
|
// let the module prepare it's HTML code
|
||||||
$mod->createHTML();
|
$mod->initialize();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
127
install.php
127
install.php
|
|
@ -25,128 +25,15 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// this script creates all the database tables required for server monitor
|
define('PSM_INSTALL', true);
|
||||||
error_reporting(0x0ffffff);
|
|
||||||
|
|
||||||
require 'config.inc.php';
|
require 'src/bootstrap.php';
|
||||||
|
|
||||||
if(!function_exists('curl_init')) {
|
psm_no_cache();
|
||||||
die('PHP is installed without the cURL module. Please install cURL first.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$tpl = new smTemplate();
|
$type = 'install';
|
||||||
$tpl->addCSS('monitor.css', 'install');
|
$tpl = new \psm\Service\Template();
|
||||||
|
$mod = new psm\Module\Install($db, $tpl);
|
||||||
|
$mod->initialize();
|
||||||
|
|
||||||
$tpl->newTemplate('install', 'install.tpl.html');
|
|
||||||
|
|
||||||
|
|
||||||
if(!is_resource($db->getLink())) {
|
|
||||||
// no valid db info
|
|
||||||
$tpl->addTemplatedata(
|
|
||||||
'install',
|
|
||||||
array('error' => 'Couldn\'t connect to database!')
|
|
||||||
);
|
|
||||||
echo $tpl->display('install');
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
$tables = array(
|
|
||||||
'users' =>
|
|
||||||
array(
|
|
||||||
0 => "CREATE TABLE `" . SM_DB_PREFIX . "users` (
|
|
||||||
`user_id` int(11) NOT NULL auto_increment,
|
|
||||||
`server_id` varchar(255) NOT NULL,
|
|
||||||
`name` varchar(255) NOT NULL,
|
|
||||||
`mobile` varchar(15) NOT NULL,
|
|
||||||
`email` varchar(255) NOT NULL,
|
|
||||||
PRIMARY KEY (`user_id`)
|
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
|
||||||
1 => "INSERT INTO `" . SM_DB_PREFIX . "users` (`server_id`, `name`, `mobile`, `email`) VALUES ('1,2', 'example_user', '0123456789', 'user@example.com')"
|
|
||||||
),
|
|
||||||
'log' =>
|
|
||||||
array(
|
|
||||||
0 => "CREATE TABLE `" . SM_DB_PREFIX . "log` (
|
|
||||||
`log_id` int(11) NOT NULL auto_increment,
|
|
||||||
`server_id` int(11) NOT NULL,
|
|
||||||
`type` enum('status','email','sms') NOT NULL,
|
|
||||||
`message` varchar(255) NOT NULL,
|
|
||||||
`datetime` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
|
||||||
`user_id` varchar(255) NOT NULL,
|
|
||||||
PRIMARY KEY (`log_id`)
|
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
|
||||||
),
|
|
||||||
'servers' =>
|
|
||||||
array(
|
|
||||||
0 => "CREATE TABLE `" . SM_DB_PREFIX . "servers` (
|
|
||||||
`server_id` int(11) NOT NULL auto_increment,
|
|
||||||
`ip` varchar(100) NOT NULL,
|
|
||||||
`port` int(5) NOT NULL,
|
|
||||||
`label` varchar(255) NOT NULL,
|
|
||||||
`type` enum('service','website') NOT NULL default 'service',
|
|
||||||
`status` enum('on','off') NOT NULL default 'on',
|
|
||||||
`error` varchar(255) NULL,
|
|
||||||
`rtime` FLOAT(9, 7) NULL,
|
|
||||||
`last_online` datetime NULL,
|
|
||||||
`last_check` datetime NULL,
|
|
||||||
`active` enum('yes','no') NOT NULL default 'yes',
|
|
||||||
`email` enum('yes','no') NOT NULL default 'yes',
|
|
||||||
`sms` enum('yes','no') NOT NULL default 'no',
|
|
||||||
PRIMARY KEY (`server_id`)
|
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
|
||||||
1 => "INSERT INTO `" . SM_DB_PREFIX . "servers` (`ip`, `port`, `label`, `type`, `status`, `error`, `rtime`, `last_online`, `last_check`, `active`, `email`, `sms`) VALUES ('http://sourceforge.net/index.php', 80, 'SourceForge', 'website', 'on', '', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 'yes', 'yes', 'yes'), ('smtp.gmail.com', 465, 'Gmail SMTP', 'service', 'on', '', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 'yes', 'yes', 'yes')",
|
|
||||||
),
|
|
||||||
'config' =>
|
|
||||||
array(
|
|
||||||
0 => "CREATE TABLE `" . SM_DB_PREFIX . "config` (
|
|
||||||
`config_id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`key` varchar(255) NOT NULL,
|
|
||||||
`value` varchar(255) NOT NULL,
|
|
||||||
PRIMARY KEY (`config_id`),
|
|
||||||
KEY `key` (`key`(50))
|
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
|
||||||
1 => "INSERT INTO `" . SM_DB_PREFIX . "config` (`config_id`, `key`, `value`) VALUES
|
|
||||||
(null, 'language', 'en'),
|
|
||||||
(null, 'email_status', '1'),
|
|
||||||
(null, 'email_from_email', 'monitor@example.org'),
|
|
||||||
(null, 'email_from_name', 'Server Monitor'),
|
|
||||||
(null, 'sms_status', '1'),
|
|
||||||
(null, 'sms_gateway', 'mollie'),
|
|
||||||
(null, 'sms_gateway_username', 'username'),
|
|
||||||
(null, 'sms_gateway_password', 'password'),
|
|
||||||
(null, 'sms_from', '1234567890'),
|
|
||||||
(null, 'alert_type', 'status'),
|
|
||||||
(null, 'log_status', '1'),
|
|
||||||
(null, 'log_email', '1'),
|
|
||||||
(null, 'log_sms', '1'),
|
|
||||||
(null, 'version', '200'),
|
|
||||||
(null, 'auto_refresh_servers', '0'),
|
|
||||||
(null, 'show_update', '1'),
|
|
||||||
(null, 'last_update_check', '0');",
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$result = array();
|
|
||||||
|
|
||||||
foreach($tables as $name => $queries) {
|
|
||||||
$if_table_exists = $db->query('SHOW TABLES LIKE \'' . SM_DB_PREFIX . $name.'\'');
|
|
||||||
|
|
||||||
if(!empty($if_table_exists)) {
|
|
||||||
$message = 'Table ' . SM_DB_PREFIX . $name . ' already exists in your database!';
|
|
||||||
} else {
|
|
||||||
$message = '';
|
|
||||||
|
|
||||||
foreach($queries as $query) {
|
|
||||||
$message .= 'Executing ' . $query . '<br/><br/>';
|
|
||||||
$db->query($query);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$result[] = array(
|
|
||||||
'name' => $name,
|
|
||||||
'result' => $message,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$tpl->addTemplateDataRepeat('install', 'tables', $result);
|
|
||||||
|
|
||||||
echo $tpl->display('install');
|
|
||||||
?>
|
?>
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
define('PSM_VERSION', '2.1.0');
|
||||||
|
// Include paths
|
||||||
|
define('PSM_PATH_SRC', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
||||||
|
define('PSM_PATH_VENDOR', PSM_PATH_SRC . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR);
|
||||||
|
define('PSM_PATH_INC', PSM_PATH_SRC . 'includes' . DIRECTORY_SEPARATOR);
|
||||||
|
define('PSM_PATH_TPL', PSM_PATH_SRC . 'templates' . DIRECTORY_SEPARATOR);
|
||||||
|
define('PSM_PATH_LANG', PSM_PATH_SRC . 'lang' . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
|
// find config file
|
||||||
|
$path_conf = PSM_PATH_SRC . '../config.php';
|
||||||
|
if(file_exists($path_conf)) {
|
||||||
|
include_once $path_conf;
|
||||||
|
}
|
||||||
|
// check for a debug var
|
||||||
|
if(defined('PSM_DEBUG') && PSM_DEBUG) {
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_erors', 1);
|
||||||
|
} else {
|
||||||
|
error_reporting(0);
|
||||||
|
ini_set('display_errors', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set autoloader, make sure to set $prepend = true so that our autoloader is called first
|
||||||
|
function __autoload($class) {
|
||||||
|
// remove leading \
|
||||||
|
$class = ltrim($class, '\\');
|
||||||
|
$path_parts = explode('\\', $class);
|
||||||
|
|
||||||
|
$filename = array_pop($path_parts);
|
||||||
|
$path = implode(DIRECTORY_SEPARATOR, $path_parts) .
|
||||||
|
DIRECTORY_SEPARATOR .
|
||||||
|
$filename . '.class.php'
|
||||||
|
;
|
||||||
|
// search in these dirs:
|
||||||
|
$basedirs = array(
|
||||||
|
PSM_PATH_SRC,
|
||||||
|
PSM_PATH_VENDOR
|
||||||
|
);
|
||||||
|
foreach($basedirs as $dir) {
|
||||||
|
if(file_exists($dir . $path)) {
|
||||||
|
require_once $dir . $path;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// auto-find all include files
|
||||||
|
$includes = glob(PSM_PATH_INC . '*.inc.php');
|
||||||
|
foreach($includes as $file) {
|
||||||
|
include_once $file;
|
||||||
|
}
|
||||||
|
// init db connection
|
||||||
|
$db = new psm\Service\Database();
|
||||||
|
|
||||||
|
if($db->getLink() !== null) {
|
||||||
|
|
||||||
|
psm_load_conf();
|
||||||
|
} else {
|
||||||
|
// no config yet! lets help them in the right direction
|
||||||
|
if(!defined('PSM_INSTALL')) {
|
||||||
|
header('Location: install.php');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$lang = psm_get_conf('language', 'en');
|
||||||
|
psm_load_lang($lang);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -25,38 +25,6 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Autoload
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function __autoload($class) {
|
|
||||||
// first check if a subdir exists for the class
|
|
||||||
// it splits using uppercase chars
|
|
||||||
preg_match_all("/(\P{Lu}+)|(\p{Lu}+\P{Lu}*)/", $class, $subdir_matches);
|
|
||||||
|
|
||||||
if(!empty($subdir_matches) && count($subdir_matches[0]) > 1) {
|
|
||||||
// okay we have some upper case, lets see if a dir exists
|
|
||||||
$dir = dirname(__FILE__) . '/classes/' . trim($subdir_matches[0][0]);
|
|
||||||
$file = $dir . '/' . trim($class) . '.class.php';
|
|
||||||
|
|
||||||
if(is_dir($dir) && file_exists($file)) {
|
|
||||||
require $file;
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$file = dirname(__FILE__).'/classes/'.trim(strtolower($class)).'.class.php';
|
|
||||||
|
|
||||||
if(file_exists($file)){
|
|
||||||
require $file;
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger_error("KERNEL_ERR : Unable to find file:\n\t\t[$file]\n\t associated with class:\n\t\t$class", E_USER_ERROR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
#
|
#
|
||||||
# Language functions
|
# Language functions
|
||||||
|
|
@ -67,9 +35,9 @@ function __autoload($class) {
|
||||||
* Retrieve language settings from the selected language file
|
* Retrieve language settings from the selected language file
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @see sm_load_lang()
|
* @see psm_load_lang()
|
||||||
*/
|
*/
|
||||||
function sm_get_lang() {
|
function psm_get_lang() {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
|
||||||
if(empty($args)) return $GLOBALS['sm_lang'];
|
if(empty($args)) return $GLOBALS['sm_lang'];
|
||||||
|
|
@ -89,10 +57,10 @@ function sm_get_lang() {
|
||||||
* Load language from the language file to the $GLOBALS['sm_lang'] variable
|
* Load language from the language file to the $GLOBALS['sm_lang'] variable
|
||||||
*
|
*
|
||||||
* @param string $lang language
|
* @param string $lang language
|
||||||
* @see sm_get_lang()
|
* @see psm_get_lang()
|
||||||
*/
|
*/
|
||||||
function sm_load_lang($lang) {
|
function psm_load_lang($lang) {
|
||||||
$lang_file = dirname(__FILE__) . '/lang/' . $lang . '.lang.php';
|
$lang_file = PSM_PATH_LANG . $lang . '.lang.php';
|
||||||
|
|
||||||
if(!file_exists($lang_file)) {
|
if(!file_exists($lang_file)) {
|
||||||
die('unable to load language file: ' . $lang_file);
|
die('unable to load language file: ' . $lang_file);
|
||||||
|
|
@ -107,11 +75,11 @@ function sm_load_lang($lang) {
|
||||||
* Retrieve a list with keys of the available languages
|
* Retrieve a list with keys of the available languages
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @see sm_load_lang()
|
* @see psm_load_lang()
|
||||||
*/
|
*/
|
||||||
function sm_get_langs() {
|
function psm_get_langs() {
|
||||||
$fn_ext = '.lang.php';
|
$fn_ext = '.lang.php';
|
||||||
$lang_files = glob(dirname(__FILE__) . '/lang/*' . $fn_ext);
|
$lang_files = glob(PSM_PATH_LANG . '*' . $fn_ext);
|
||||||
$langs = array();
|
$langs = array();
|
||||||
|
|
||||||
foreach($lang_files as $file) {
|
foreach($lang_files as $file) {
|
||||||
|
|
@ -122,14 +90,15 @@ function sm_get_langs() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a setting from the config.
|
* Get a setting from the config.
|
||||||
* The config must have been loaded first using sm_load_conf()
|
* The config must have been loaded first using psm_load_conf()
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
|
* @param mixed $alt if not set, return this alternative
|
||||||
* @return string
|
* @return string
|
||||||
* @see sm_load_conf()
|
* @see psm_load_conf()
|
||||||
*/
|
*/
|
||||||
function sm_get_conf($key) {
|
function psm_get_conf($key, $alt = null) {
|
||||||
$result = (isset($GLOBALS['sm_config'][$key])) ? $GLOBALS['sm_config'][$key] : null;
|
$result = (isset($GLOBALS['sm_config'][$key])) ? $GLOBALS['sm_config'][$key] : $alt;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
@ -138,14 +107,14 @@ function sm_get_conf($key) {
|
||||||
* Load config from the database to the $GLOBALS['sm_config'] variable
|
* Load config from the database to the $GLOBALS['sm_config'] variable
|
||||||
*
|
*
|
||||||
* @global object $db
|
* @global object $db
|
||||||
* @see sm_get_conf()
|
* @see psm_get_conf()
|
||||||
*/
|
*/
|
||||||
function sm_load_conf() {
|
function psm_load_conf() {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
// load config from database into global scope
|
// load config from database into global scope
|
||||||
$GLOBALS['sm_config'] = array();
|
$GLOBALS['sm_config'] = array();
|
||||||
$config_db = $db->select(SM_DB_PREFIX . 'config', null, array('key', 'value'));
|
$config_db = $db->select(PSM_DB_PREFIX . 'config', null, array('key', 'value'));
|
||||||
foreach($config_db as $setting) {
|
foreach($config_db as $setting) {
|
||||||
$GLOBALS['sm_config'][$setting['key']] = $setting['value'];
|
$GLOBALS['sm_config'][$setting['key']] = $setting['value'];
|
||||||
}
|
}
|
||||||
|
|
@ -156,6 +125,21 @@ function sm_load_conf() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a config setting
|
||||||
|
* @global \psm\Service\Database $db
|
||||||
|
* @param string $key
|
||||||
|
* @param string $value
|
||||||
|
*/
|
||||||
|
function psm_update_conf($key, $value) {
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
$db->save(
|
||||||
|
PSM_DB_PREFIX.'config',
|
||||||
|
array('value' => $value),
|
||||||
|
array('key' => $key)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
#
|
#
|
||||||
|
|
@ -170,11 +154,11 @@ function sm_load_conf() {
|
||||||
* @param string $server_id
|
* @param string $server_id
|
||||||
* @param string $message
|
* @param string $message
|
||||||
*/
|
*/
|
||||||
function sm_add_log($server_id, $type, $message, $user_id = null) {
|
function psm_add_log($server_id, $type, $message, $user_id = null) {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$db->save(
|
$db->save(
|
||||||
SM_DB_PREFIX.'log',
|
PSM_DB_PREFIX.'log',
|
||||||
array(
|
array(
|
||||||
'server_id' => $server_id,
|
'server_id' => $server_id,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
|
|
@ -192,10 +176,10 @@ function sm_add_log($server_id, $type, $message, $user_id = null) {
|
||||||
* @param array $server information about the server which may be placed in a message: %KEY% will be replaced by your value
|
* @param array $server information about the server which may be placed in a message: %KEY% will be replaced by your value
|
||||||
* @return string parsed message
|
* @return string parsed message
|
||||||
*/
|
*/
|
||||||
function sm_parse_msg($status, $type, $vars) {
|
function psm_parse_msg($status, $type, $vars) {
|
||||||
$message = '';
|
$message = '';
|
||||||
|
|
||||||
$message = sm_get_lang('notifications', $status . '_' . $type);
|
$message = psm_get_lang('notifications', $status . '_' . $type);
|
||||||
|
|
||||||
if(!$message) {
|
if(!$message) {
|
||||||
return $message;
|
return $message;
|
||||||
|
|
@ -215,7 +199,7 @@ function sm_parse_msg($status, $type, $vars) {
|
||||||
* @param string $href
|
* @param string $href
|
||||||
* @return string cURL result
|
* @return string cURL result
|
||||||
*/
|
*/
|
||||||
function sm_curl_get($href) {
|
function psm_curl_get($href) {
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
|
|
@ -236,7 +220,7 @@ function sm_curl_get($href) {
|
||||||
* @return string
|
* @return string
|
||||||
* @todo add translation to timespan messages
|
* @todo add translation to timespan messages
|
||||||
*/
|
*/
|
||||||
function sm_timespan($time) {
|
function psm_timespan($time) {
|
||||||
if ($time !== intval($time)) { $time = strtotime($time); }
|
if ($time !== intval($time)) { $time = strtotime($time); }
|
||||||
$d = time() - $time;
|
$d = time() - $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) {
|
||||||
|
|
@ -266,22 +250,19 @@ function sm_timespan($time) {
|
||||||
* @global object $db
|
* @global object $db
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function sm_check_updates() {
|
function psm_check_updates() {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$last_update = sm_get_conf('last_update_check');
|
$last_update = psm_get_conf('last_update_check');
|
||||||
|
|
||||||
if((time() - (7 * 24 * 60 * 60)) > $last_update) {
|
if((time() - (7 * 24 * 60 * 60)) > $last_update) {
|
||||||
// been more than a week since update, lets go
|
// been more than a week since update, lets go
|
||||||
// update "update-date"
|
// update "update-date"
|
||||||
$db->save(SM_DB_PREFIX . 'config', array('value' => time()), array('key' => 'last_update_check'));
|
$db->save(PSM_DB_PREFIX . 'config', array('value' => time()), array('key' => 'last_update_check'));
|
||||||
$latest = sm_curl_get('http://phpservermon.neanderthal-technology.com/version');
|
$latest = psm_curl_get('http://phpservermon.neanderthal-technology.com/version.php');
|
||||||
$current = sm_get_conf('version');
|
$current = psm_get_conf('version');
|
||||||
|
|
||||||
if((int) $current < (int) $latest) {
|
return version_compare($latest, $current, '>');
|
||||||
// new update available
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -307,7 +288,7 @@ function pre($arr = null) {
|
||||||
/**
|
/**
|
||||||
* Send headers to the browser to avoid caching
|
* Send headers to the browser to avoid caching
|
||||||
*/
|
*/
|
||||||
function sm_no_cache() {
|
function psm_no_cache() {
|
||||||
header("Expires: Mon, 20 Dec 1998 01:00:00 GMT");
|
header("Expires: Mon, 20 Dec 1998 01:00:00 GMT");
|
||||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||||
header("Cache-Control: no-cache, must-revalidate");
|
header("Cache-Control: no-cache, must-revalidate");
|
||||||
|
|
@ -0,0 +1,147 @@
|
||||||
|
<?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 Luiz Alberto S. Ribeiro <madeinnordeste@gmail.com>
|
||||||
|
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||||
|
* @version Release: @package_version@
|
||||||
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
|
**/
|
||||||
|
|
||||||
|
$sm_lang = array(
|
||||||
|
'system' => array(
|
||||||
|
'title' => 'Server Monitor',
|
||||||
|
'servers' => 'Servidores',
|
||||||
|
'users' => 'Usuários',
|
||||||
|
'log' => 'Log',
|
||||||
|
'status' => 'Status',
|
||||||
|
'update' => 'Atualização',
|
||||||
|
'config' => 'Configuração',
|
||||||
|
'help' => 'Ajuda',
|
||||||
|
'install' => 'Install',
|
||||||
|
'action' => 'Ação',
|
||||||
|
'save' => 'Salvar',
|
||||||
|
'edit' => 'Editar',
|
||||||
|
'delete' => 'Excluir',
|
||||||
|
'deleted' => 'Registro excluído',
|
||||||
|
'date' => 'Data',
|
||||||
|
'message' => 'Mensagem',
|
||||||
|
'yes' => 'Sim',
|
||||||
|
'no' => 'Não',
|
||||||
|
'edit' => 'Editar',
|
||||||
|
'insert' => 'Inserir',
|
||||||
|
'add_new' => 'Adicionar novo?',
|
||||||
|
'update_available' => 'Uma atualização disponível em <a href="http://phpservermon.sourceforge.net" target="_blank">http://phpservermon.sourceforge.net</a>.',
|
||||||
|
'back_to_top' => 'Voltar ao topo',
|
||||||
|
),
|
||||||
|
'users' => array(
|
||||||
|
'user' => 'usuário',
|
||||||
|
'name' => 'Nome',
|
||||||
|
'mobile' => 'Celular',
|
||||||
|
'email' => 'Email',
|
||||||
|
'updated' => 'Usuário atualizado.',
|
||||||
|
'inserted' => 'Usuário adicionado.',
|
||||||
|
),
|
||||||
|
'log' => array(
|
||||||
|
'title' => 'Entradas do Log',
|
||||||
|
'type' => 'Tipo',
|
||||||
|
'status' => 'Status',
|
||||||
|
'email' => 'Email',
|
||||||
|
'sms' => 'SMS',
|
||||||
|
),
|
||||||
|
'servers' => array(
|
||||||
|
'server' => 'Servidor',
|
||||||
|
'label' => 'Etiqueta',
|
||||||
|
'domain' => 'Domínio/IP',
|
||||||
|
'port' => 'Porta',
|
||||||
|
'type' => 'Tipo',
|
||||||
|
'pattern' => 'Search string/pattern',
|
||||||
|
'last_check' => 'Última verificação',
|
||||||
|
'last_online' => 'Última vez online',
|
||||||
|
'monitoring' => 'Monitoramento',
|
||||||
|
'send_email' => 'Enviar Email',
|
||||||
|
'send_sms' => 'Enviar SMS',
|
||||||
|
'updated' => 'Servidor atualizado.',
|
||||||
|
'inserted' => 'Servidor adicionar.',
|
||||||
|
'rtime' => 'Tempo de resposta',
|
||||||
|
),
|
||||||
|
'config' => array(
|
||||||
|
'general' => 'Geral',
|
||||||
|
'language' => 'Idioma',
|
||||||
|
'language_en' => 'Inglês',
|
||||||
|
'language_nl' => 'Holandês',
|
||||||
|
'language_fr' => 'Francês',
|
||||||
|
'language_de' => 'Alemão',
|
||||||
|
'language_kr' => 'Koreano',
|
||||||
|
'language_br' => 'Portugês - Brasil',
|
||||||
|
'show_update' => 'verificar atualizações semanalmente?',
|
||||||
|
'email_status' => 'Habilitar envio de email?',
|
||||||
|
'email_from_email' => 'Endereço do envio de email',
|
||||||
|
'email_from_name' => 'Nome do envio de email',
|
||||||
|
'sms_status' => 'Habilitar o envio de mensagem de texto?',
|
||||||
|
'sms_gateway' => 'Gateway para o uso de envio de mensagens',
|
||||||
|
'sms_gateway_mosms' => 'Mosms',
|
||||||
|
'sms_gateway_mollie' => 'Mollie',
|
||||||
|
'sms_gateway_spryng' => 'Spryng',
|
||||||
|
'sms_gateway_inetworx' => 'Inetworx',
|
||||||
|
'sms_gateway_clickatell' => 'Clickatell',
|
||||||
|
'sms_gateway_textmarketer' => 'Textmarketer',
|
||||||
|
'sms_gateway_username' => 'Usuário do Gateway',
|
||||||
|
'sms_gateway_password' => 'Senha do Gateway',
|
||||||
|
'sms_from' => 'Número de telefone de envio',
|
||||||
|
'alert_type' => 'Selecione como você gostaria de ser notificado.<br/>',
|
||||||
|
'alert_type_description' => '<b>Mudança de Status:</b> '.
|
||||||
|
'Você receberá uma notificação quando o seridor tive uma mudança de status. De online -> offline ou offline -> online.<br/>'.
|
||||||
|
'<br /><b>Offline:</b> '.
|
||||||
|
'Você receberá uma notificação quando o servidor fica OFFLINE (Pela primeira vez). Por exemplo, '.
|
||||||
|
'A cronjob é a cada 15 minutos e seu servidor caiu em 1:00 e permanece offline até 6 am. '.
|
||||||
|
'Você receberá uma notificação a 1:00 apenas<br/>'.
|
||||||
|
'<br><b>Sempre:</b> '.
|
||||||
|
'Você receberá uma notificação toda vez que o script é executado e um site esta offline, mesmo se o site tenha ficado '.
|
||||||
|
'offline por horas.',
|
||||||
|
'alert_type_status' => 'Mudança de Status',
|
||||||
|
'alert_type_offline' => 'Offline',
|
||||||
|
'alert_type_always' => 'Sempre',
|
||||||
|
'log_status' => 'Log status<br/><div class="small">Se o status de registro é definido como TRUE, o monitor irá registrar o evento sempre que as configurações de notificação forem passadas</div>',
|
||||||
|
'log_email' => 'Registrar no Log os envios de email feitos pelo script?',
|
||||||
|
'log_sms' => 'Registrar no Log os envios de mensagens de texto feitos pelo script?',
|
||||||
|
'updated' => 'A configuração foi atualizada.',
|
||||||
|
'settings_email' => 'Configuração de email',
|
||||||
|
'settings_sms' => 'Configuração de mensagens de texto',
|
||||||
|
'settings_notification' => 'Configuração de notificações',
|
||||||
|
'settings_log' => 'Configuração de Logs',
|
||||||
|
'auto_refresh_servers' =>
|
||||||
|
'Atualizar automaticamente a página de servidores<br/>'.
|
||||||
|
'<div class="small">'.
|
||||||
|
'Tempo em segundos, Se 0 a página não será atualizada.'.
|
||||||
|
'</div>',
|
||||||
|
),
|
||||||
|
// for newlines in the email messages use <br/>
|
||||||
|
'notifications' => array(
|
||||||
|
'off_sms' => 'Servidor \'%LABEL%\' está OFFLINE: ip=%IP%, porta=%PORT%. Erro=%ERROR%',
|
||||||
|
'off_email_subject' => 'IMPORTANTE: Servidor \'%LABEL%\' está OFFLINE',
|
||||||
|
'off_email_body' => "Falha ao conectar ao servidor:<br/><br/>Servidor: %LABEL%<br/>IP: %IP%<br/>Porta: %PORT%<br/>Erro: %ERROR%<br/>Data: %DATE%",
|
||||||
|
'on_sms' => 'Servidor \'%LABEL%\' esta ONLINE: ip=%IP%, porta=%PORT%',
|
||||||
|
'on_email_subject' => 'IMPORTANTE: Servidor \'%LABEL%\' esta ONLINE',
|
||||||
|
'on_email_body' => "Servidor '%LABEL%' esta ONLINE novamente:<br/><br/>Servidor: %LABEL%<br/>IP: %IP%<br/>Porta: %PORT%<br/>Data: %DATE%",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -31,9 +31,11 @@ $sm_lang = array(
|
||||||
'servers' => 'Server',
|
'servers' => 'Server',
|
||||||
'users' => 'Benutzer',
|
'users' => 'Benutzer',
|
||||||
'log' => 'Log',
|
'log' => 'Log',
|
||||||
|
'status' => 'Status',
|
||||||
'update' => 'Updates',
|
'update' => 'Updates',
|
||||||
'config' => 'Einstellungen',
|
'config' => 'Einstellungen',
|
||||||
'help' => 'Hilfe',
|
'help' => 'Hilfe',
|
||||||
|
'install' => 'Install',
|
||||||
'action' => 'Aktion',
|
'action' => 'Aktion',
|
||||||
'save' => 'Speichern',
|
'save' => 'Speichern',
|
||||||
'edit' => 'Bearbeiten',
|
'edit' => 'Bearbeiten',
|
||||||
|
|
@ -70,6 +72,7 @@ $sm_lang = array(
|
||||||
'domain' => 'Domain/IP',
|
'domain' => 'Domain/IP',
|
||||||
'port' => 'Port',
|
'port' => 'Port',
|
||||||
'type' => 'Type',
|
'type' => 'Type',
|
||||||
|
'pattern' => 'Search string/pattern',
|
||||||
'last_check' => 'Letzter Check',
|
'last_check' => 'Letzter Check',
|
||||||
'last_online' => 'Letztes mal Online',
|
'last_online' => 'Letztes mal Online',
|
||||||
'monitoring' => 'Monitoring',
|
'monitoring' => 'Monitoring',
|
||||||
|
|
@ -87,6 +90,7 @@ $sm_lang = array(
|
||||||
'language_fr' => 'French',
|
'language_fr' => 'French',
|
||||||
'language_de' => 'German',
|
'language_de' => 'German',
|
||||||
'language_kr' => 'Korean',
|
'language_kr' => 'Korean',
|
||||||
|
'language_br' => 'Portuguese - Brazilian',
|
||||||
'show_update' => 'Updats wöchentlich prüfen?',
|
'show_update' => 'Updats wöchentlich prüfen?',
|
||||||
'email_status' => 'Email senden erlauben?',
|
'email_status' => 'Email senden erlauben?',
|
||||||
'email_from_email' => 'Email from address',
|
'email_from_email' => 'Email from address',
|
||||||
|
|
@ -98,6 +102,7 @@ $sm_lang = array(
|
||||||
'sms_gateway_spryng' => 'Spryng',
|
'sms_gateway_spryng' => 'Spryng',
|
||||||
'sms_gateway_inetworx' => 'Inetworx',
|
'sms_gateway_inetworx' => 'Inetworx',
|
||||||
'sms_gateway_clickatell' => 'Clickatell',
|
'sms_gateway_clickatell' => 'Clickatell',
|
||||||
|
'sms_gateway_textmarketer' => 'Textmarketer',
|
||||||
'sms_gateway_username' => 'Gateway Benutzername',
|
'sms_gateway_username' => 'Gateway Benutzername',
|
||||||
'sms_gateway_password' => 'Gateway Passwort',
|
'sms_gateway_password' => 'Gateway Passwort',
|
||||||
'sms_from' => 'SMS Sendernummer',
|
'sms_from' => 'SMS Sendernummer',
|
||||||
|
|
@ -31,9 +31,11 @@ $sm_lang = array(
|
||||||
'servers' => 'Servers',
|
'servers' => 'Servers',
|
||||||
'users' => 'Users',
|
'users' => 'Users',
|
||||||
'log' => 'Log',
|
'log' => 'Log',
|
||||||
|
'status' => 'Status',
|
||||||
'update' => 'Update',
|
'update' => 'Update',
|
||||||
'config' => 'Config',
|
'config' => 'Config',
|
||||||
'help' => 'Help',
|
'help' => 'Help',
|
||||||
|
'install' => 'Install',
|
||||||
'action' => 'Action',
|
'action' => 'Action',
|
||||||
'save' => 'Save',
|
'save' => 'Save',
|
||||||
'edit' => 'Edit',
|
'edit' => 'Edit',
|
||||||
|
|
@ -70,6 +72,7 @@ $sm_lang = array(
|
||||||
'domain' => 'Domain/IP',
|
'domain' => 'Domain/IP',
|
||||||
'port' => 'Port',
|
'port' => 'Port',
|
||||||
'type' => 'Type',
|
'type' => 'Type',
|
||||||
|
'pattern' => 'Search string/pattern',
|
||||||
'last_check' => 'Last check',
|
'last_check' => 'Last check',
|
||||||
'last_online' => 'Last online',
|
'last_online' => 'Last online',
|
||||||
'monitoring' => 'Monitoring',
|
'monitoring' => 'Monitoring',
|
||||||
|
|
@ -87,6 +90,7 @@ $sm_lang = array(
|
||||||
'language_fr' => 'French',
|
'language_fr' => 'French',
|
||||||
'language_de' => 'German',
|
'language_de' => 'German',
|
||||||
'language_kr' => 'Korean',
|
'language_kr' => 'Korean',
|
||||||
|
'language_br' => 'Portuguese - Brazilian',
|
||||||
'show_update' => 'Check for new updates weekly?',
|
'show_update' => 'Check for new updates weekly?',
|
||||||
'email_status' => 'Allow sending email?',
|
'email_status' => 'Allow sending email?',
|
||||||
'email_from_email' => 'Email from address',
|
'email_from_email' => 'Email from address',
|
||||||
|
|
@ -98,6 +102,7 @@ $sm_lang = array(
|
||||||
'sms_gateway_spryng' => 'Spryng',
|
'sms_gateway_spryng' => 'Spryng',
|
||||||
'sms_gateway_inetworx' => 'Inetworx',
|
'sms_gateway_inetworx' => 'Inetworx',
|
||||||
'sms_gateway_clickatell' => 'Clickatell',
|
'sms_gateway_clickatell' => 'Clickatell',
|
||||||
|
'sms_gateway_textmarketer' => 'Textmarketer',
|
||||||
'sms_gateway_username' => 'Gateway username',
|
'sms_gateway_username' => 'Gateway username',
|
||||||
'sms_gateway_password' => 'Gateway password',
|
'sms_gateway_password' => 'Gateway password',
|
||||||
'sms_from' => 'Sender\'s phone number',
|
'sms_from' => 'Sender\'s phone number',
|
||||||
|
|
@ -31,9 +31,11 @@ $sm_lang = array(
|
||||||
'servers' => 'Serveurs',
|
'servers' => 'Serveurs',
|
||||||
'users' => 'Utilisateurs',
|
'users' => 'Utilisateurs',
|
||||||
'log' => 'Evenements',
|
'log' => 'Evenements',
|
||||||
|
'status' => 'Status',
|
||||||
'update' => 'Mise à jour',
|
'update' => 'Mise à jour',
|
||||||
'config' => 'Configuration',
|
'config' => 'Configuration',
|
||||||
'help' => 'Aide',
|
'help' => 'Aide',
|
||||||
|
'install' => 'Install',
|
||||||
'action' => 'Action',
|
'action' => 'Action',
|
||||||
'save' => 'Enregistrer',
|
'save' => 'Enregistrer',
|
||||||
'edit' => 'Editer',
|
'edit' => 'Editer',
|
||||||
|
|
@ -70,6 +72,7 @@ $sm_lang = array(
|
||||||
'domain' => 'Domaine/IP',
|
'domain' => 'Domaine/IP',
|
||||||
'port' => 'Port',
|
'port' => 'Port',
|
||||||
'type' => 'Type',
|
'type' => 'Type',
|
||||||
|
'pattern' => 'Search string/pattern',
|
||||||
'last_check' => 'Dernière vérification',
|
'last_check' => 'Dernière vérification',
|
||||||
'last_online' => 'Dernière fois OK',
|
'last_online' => 'Dernière fois OK',
|
||||||
'monitoring' => 'Supervision',
|
'monitoring' => 'Supervision',
|
||||||
|
|
@ -87,6 +90,7 @@ $sm_lang = array(
|
||||||
'language_fr' => 'Francais',
|
'language_fr' => 'Francais',
|
||||||
'language_de' => 'German',
|
'language_de' => 'German',
|
||||||
'language_kr' => 'Korean',
|
'language_kr' => 'Korean',
|
||||||
|
'language_br' => 'Portuguese - Brazilian',
|
||||||
'show_update' => 'Vérifier les nouvelles mis à jour hebdomadairement?',
|
'show_update' => 'Vérifier les nouvelles mis à jour hebdomadairement?',
|
||||||
'email_status' => 'Autoriser l envoi de mail?',
|
'email_status' => 'Autoriser l envoi de mail?',
|
||||||
'email_from_email' => 'Expéditeur',
|
'email_from_email' => 'Expéditeur',
|
||||||
|
|
@ -98,6 +102,7 @@ $sm_lang = array(
|
||||||
'sms_gateway_spryng' => 'Spryng',
|
'sms_gateway_spryng' => 'Spryng',
|
||||||
'sms_gateway_inetworx' => 'Inetworx',
|
'sms_gateway_inetworx' => 'Inetworx',
|
||||||
'sms_gateway_clickatell' => 'Clickatell',
|
'sms_gateway_clickatell' => 'Clickatell',
|
||||||
|
'sms_gateway_textmarketer' => 'Textmarketer',
|
||||||
'sms_gateway_username' => 'Utilisateur sur la passerelle',
|
'sms_gateway_username' => 'Utilisateur sur la passerelle',
|
||||||
'sms_gateway_password' => 'Mot de passe sur la passerelle',
|
'sms_gateway_password' => 'Mot de passe sur la passerelle',
|
||||||
'sms_from' => 'SMS de l expéditeur',
|
'sms_from' => 'SMS de l expéditeur',
|
||||||
|
|
@ -32,9 +32,11 @@ $sm_lang = array(
|
||||||
'servers' => '서버목록',
|
'servers' => '서버목록',
|
||||||
'users' => '사용자',
|
'users' => '사용자',
|
||||||
'log' => '로그',
|
'log' => '로그',
|
||||||
|
'status' => 'Status',
|
||||||
'update' => '업데이트',
|
'update' => '업데이트',
|
||||||
'config' => '설정',
|
'config' => '설정',
|
||||||
'help' => '도움말',
|
'help' => '도움말',
|
||||||
|
'install' => 'Install',
|
||||||
'action' => 'Action',
|
'action' => 'Action',
|
||||||
'save' => '저장',
|
'save' => '저장',
|
||||||
'edit' => '수정',
|
'edit' => '수정',
|
||||||
|
|
@ -71,6 +73,7 @@ $sm_lang = array(
|
||||||
'domain' => 'Domain/IP',
|
'domain' => 'Domain/IP',
|
||||||
'port' => 'Port',
|
'port' => 'Port',
|
||||||
'type' => 'Type',
|
'type' => 'Type',
|
||||||
|
'pattern' => 'Search string/regex',
|
||||||
'last_check' => '최근체크',
|
'last_check' => '최근체크',
|
||||||
'last_online' => '최근접속',
|
'last_online' => '최근접속',
|
||||||
'monitoring' => '확인중',
|
'monitoring' => '확인중',
|
||||||
|
|
@ -88,6 +91,7 @@ $sm_lang = array(
|
||||||
'language_fr' => '프랑스',
|
'language_fr' => '프랑스',
|
||||||
'language_de' => '독일',
|
'language_de' => '독일',
|
||||||
'language_kr' => '한국',
|
'language_kr' => '한국',
|
||||||
|
'language_br' => 'Portuguese - Brazilian',
|
||||||
'show_update' => '매주 업데이트를 확인하시겠습니까?',
|
'show_update' => '매주 업데이트를 확인하시겠습니까?',
|
||||||
'email_status' => '메일전송 허용',
|
'email_status' => '메일전송 허용',
|
||||||
'email_from_email' => 'Email 주소',
|
'email_from_email' => 'Email 주소',
|
||||||
|
|
@ -99,6 +103,7 @@ $sm_lang = array(
|
||||||
'sms_gateway_spryng' => 'Spryng',
|
'sms_gateway_spryng' => 'Spryng',
|
||||||
'sms_gateway_inetworx' => 'Inetworx',
|
'sms_gateway_inetworx' => 'Inetworx',
|
||||||
'sms_gateway_clickatell' => 'Clickatell',
|
'sms_gateway_clickatell' => 'Clickatell',
|
||||||
|
'sms_gateway_textmarketer' => 'Textmarketer',
|
||||||
'sms_gateway_username' => 'Gateway username',
|
'sms_gateway_username' => 'Gateway username',
|
||||||
'sms_gateway_password' => 'Gateway password',
|
'sms_gateway_password' => 'Gateway password',
|
||||||
'sms_from' => 'Sender\'s phone number',
|
'sms_from' => 'Sender\'s phone number',
|
||||||
|
|
@ -31,9 +31,11 @@ $sm_lang = array(
|
||||||
'servers' => 'Servers',
|
'servers' => 'Servers',
|
||||||
'users' => 'Gebruikers',
|
'users' => 'Gebruikers',
|
||||||
'log' => 'Log',
|
'log' => 'Log',
|
||||||
|
'status' => 'Status',
|
||||||
'update' => 'Update',
|
'update' => 'Update',
|
||||||
'config' => 'Config',
|
'config' => 'Config',
|
||||||
'help' => 'Help',
|
'help' => 'Help',
|
||||||
|
'install' => 'Install',
|
||||||
'action' => 'Actie',
|
'action' => 'Actie',
|
||||||
'save' => 'Opslaan',
|
'save' => 'Opslaan',
|
||||||
'edit' => 'Wijzig',
|
'edit' => 'Wijzig',
|
||||||
|
|
@ -70,6 +72,7 @@ $sm_lang = array(
|
||||||
'domain' => 'Domein/IP',
|
'domain' => 'Domein/IP',
|
||||||
'port' => 'Poort',
|
'port' => 'Poort',
|
||||||
'type' => 'Type',
|
'type' => 'Type',
|
||||||
|
'pattern' => 'Zoek voor tekst/regex',
|
||||||
'last_check' => 'Laatst gecontroleerd',
|
'last_check' => 'Laatst gecontroleerd',
|
||||||
'last_online' => 'Laatst online',
|
'last_online' => 'Laatst online',
|
||||||
'monitoring' => 'Monitoring',
|
'monitoring' => 'Monitoring',
|
||||||
|
|
@ -87,6 +90,7 @@ $sm_lang = array(
|
||||||
'language_fr' => 'Frans',
|
'language_fr' => 'Frans',
|
||||||
'language_de' => 'Duits',
|
'language_de' => 'Duits',
|
||||||
'language_kr' => 'Koreaans',
|
'language_kr' => 'Koreaans',
|
||||||
|
'language_br' => 'Portugees - Braziliaans',
|
||||||
'show_update' => 'Check for new updates weekly?',
|
'show_update' => 'Check for new updates weekly?',
|
||||||
'email_status' => 'Sta email berichten toe?',
|
'email_status' => 'Sta email berichten toe?',
|
||||||
'email_from_email' => 'Email van adres',
|
'email_from_email' => 'Email van adres',
|
||||||
|
|
@ -98,6 +102,7 @@ $sm_lang = array(
|
||||||
'sms_gateway_spryng' => 'Spryng',
|
'sms_gateway_spryng' => 'Spryng',
|
||||||
'sms_gateway_inetworx' => 'Inetworx',
|
'sms_gateway_inetworx' => 'Inetworx',
|
||||||
'sms_gateway_clickatell' => 'Clickatell',
|
'sms_gateway_clickatell' => 'Clickatell',
|
||||||
|
'sms_gateway_textmarketer' => 'Textmarketer',
|
||||||
'sms_gateway_username' => 'Gateway gebruikersnaam',
|
'sms_gateway_username' => 'Gateway gebruikersnaam',
|
||||||
'sms_gateway_password' => 'Gateway wachtwoord',
|
'sms_gateway_password' => 'Gateway wachtwoord',
|
||||||
'sms_from' => 'Telefoonnummer afzender',
|
'sms_from' => 'Telefoonnummer afzender',
|
||||||
|
|
@ -0,0 +1,312 @@
|
||||||
|
<?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@neanderthal-technology.com>
|
||||||
|
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||||
|
* @version Release: @package_version@
|
||||||
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
|
**/
|
||||||
|
|
||||||
|
namespace psm\Module;
|
||||||
|
use psm\Service\Database;
|
||||||
|
use psm\Service\Template;
|
||||||
|
|
||||||
|
abstract class AbstractModule implements ModuleInterface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current mode. Can be used by modules to determine
|
||||||
|
* what to do
|
||||||
|
* @var string $mode
|
||||||
|
*/
|
||||||
|
public $mode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current action
|
||||||
|
* @var string $action
|
||||||
|
*/
|
||||||
|
protected $action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default action
|
||||||
|
* @var string $action_default
|
||||||
|
* @see setActions()
|
||||||
|
*/
|
||||||
|
protected $action_default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actions available for this module
|
||||||
|
* @var array $actions
|
||||||
|
* @see setActions()
|
||||||
|
* @see getAction()
|
||||||
|
*/
|
||||||
|
protected $actions = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add footer to page?
|
||||||
|
* @var boolean $add_footer
|
||||||
|
* @see addFooter()
|
||||||
|
*/
|
||||||
|
protected $add_footer = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add menu to page?
|
||||||
|
* @var boolean $add_menu
|
||||||
|
* @see addMenu()
|
||||||
|
*/
|
||||||
|
protected $add_menu = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Messages to show the user
|
||||||
|
* @var array $messages
|
||||||
|
* @see getMessage()
|
||||||
|
*/
|
||||||
|
protected $messages = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database object
|
||||||
|
* @var \psm\Service\Database $db
|
||||||
|
*/
|
||||||
|
protected $db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template object
|
||||||
|
* @var \psm\Service\Template $tpl
|
||||||
|
*/
|
||||||
|
protected $tpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template Id that should be added to the main template
|
||||||
|
* @var string
|
||||||
|
* @see setTemplateId() getTemplateId()
|
||||||
|
*/
|
||||||
|
protected $tpl_id;
|
||||||
|
|
||||||
|
function __construct(Database $db, Template $tpl) {
|
||||||
|
$this->db = $db;
|
||||||
|
$this->tpl = $tpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the module
|
||||||
|
*/
|
||||||
|
public function initialize() {
|
||||||
|
// yeh baby, "initialize" me..
|
||||||
|
// right, anyway, lets determine the aciton
|
||||||
|
$action = null;
|
||||||
|
|
||||||
|
if(isset($_GET['action'])) {
|
||||||
|
$action = $_GET['action'];
|
||||||
|
} elseif(isset($_POST['action'])) {
|
||||||
|
$action = $_POST['action'];
|
||||||
|
}
|
||||||
|
if($action !== null && in_array($action, $this->actions)) {
|
||||||
|
// we have an action
|
||||||
|
$this->initializeAction($action);
|
||||||
|
} elseif($this->action_default !== null) {
|
||||||
|
$this->initializeAction($this->action_default);
|
||||||
|
} else {
|
||||||
|
// else what..?
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->createHTML();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a specified action
|
||||||
|
*
|
||||||
|
* For it to run, the "execute$action" method must exist
|
||||||
|
* @param string $action
|
||||||
|
*/
|
||||||
|
protected function initializeAction($action) {
|
||||||
|
$this->action = $action;
|
||||||
|
$method = 'execute' . ucfirst($action);
|
||||||
|
if(method_exists($this, $method)) {
|
||||||
|
$this->$method();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the HTML code for the module.
|
||||||
|
* First the createHTMLLabels() will be called to add all labels to the template,
|
||||||
|
* Then the tpl_id set in $this->getTemplateId() will be added to the main template automatically
|
||||||
|
*/
|
||||||
|
protected function createHTML() {
|
||||||
|
if(psm_get_conf('show_update')) {
|
||||||
|
// user wants updates, lets see what we can do
|
||||||
|
$this->createHTMLUpdateAvailable();
|
||||||
|
}
|
||||||
|
$tpl_data = array(
|
||||||
|
'message' => (empty($this->messages)) ? ' ' : implode('<br/>', $this->messages),
|
||||||
|
);
|
||||||
|
// add menu to page?
|
||||||
|
if($this->add_menu) {
|
||||||
|
$this->tpl->newTemplate('main_menu', 'main.tpl.html');
|
||||||
|
$tpl_data['html_menu'] = $this->tpl->getTemplate('main_menu');
|
||||||
|
}
|
||||||
|
// add footer to page?
|
||||||
|
if($this->add_footer) {
|
||||||
|
$this->tpl->newTemplate('main_footer', 'main.tpl.html');
|
||||||
|
$tpl_data['html_footer'] = $this->tpl->getTemplate('main_footer');
|
||||||
|
}
|
||||||
|
|
||||||
|
$tpl_id_content = $this->getTemplateId();
|
||||||
|
if($tpl_id_content) {
|
||||||
|
$tpl_data['content'] = $this->tpl->getTemplate($tpl_id_content);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the module's custom template to the main template to get some content
|
||||||
|
$this->setTemplateId('main');
|
||||||
|
$this->tpl->addTemplatedata($this->getTemplateId(), $tpl_data);
|
||||||
|
$this->createHTMLLabels();
|
||||||
|
|
||||||
|
// display main template
|
||||||
|
echo $this->tpl->display($this->getTemplateId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First check if an update is available, if there is add a message
|
||||||
|
* to the main template
|
||||||
|
*/
|
||||||
|
protected function createHTMLUpdateAvailable() {
|
||||||
|
// check for updates?
|
||||||
|
|
||||||
|
if(psm_check_updates()) {
|
||||||
|
// yay, new update available =D
|
||||||
|
$this->addMessage(psm_get_lang('system', 'update_available'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this to add language specific labels to template
|
||||||
|
*
|
||||||
|
* @see createHTML()
|
||||||
|
*/
|
||||||
|
protected function createHTMLLabels() {
|
||||||
|
global $type;
|
||||||
|
|
||||||
|
$this->tpl->addTemplateData(
|
||||||
|
'main',
|
||||||
|
array(
|
||||||
|
'title' => strtoupper(psm_get_lang('system', 'title')),
|
||||||
|
'subtitle' => psm_get_lang('system', $type),
|
||||||
|
'active_' . $type => 'active',
|
||||||
|
'label_servers' => psm_get_lang('system', 'servers'),
|
||||||
|
'label_users' => psm_get_lang('system', 'users'),
|
||||||
|
'label_log' => psm_get_lang('system', 'log'),
|
||||||
|
'label_status' => psm_get_lang('system', 'status'),
|
||||||
|
'label_config' => psm_get_lang('system', 'config'),
|
||||||
|
'label_update' => psm_get_lang('system', 'update'),
|
||||||
|
'label_help' => psm_get_lang('system', 'help'),
|
||||||
|
'label_back_to_top' => psm_get_lang('system', 'back_to_top'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a template id that will be added to the main template automatically
|
||||||
|
* once you call the parent::createHTML()
|
||||||
|
*
|
||||||
|
* @param string $tpl_id
|
||||||
|
* @param string $tpl_file if given, the tpl_id will be created automatically from this file
|
||||||
|
* @see getTemplateId() createHTML()
|
||||||
|
*/
|
||||||
|
public function setTemplateId($tpl_id, $tpl_file = null) {
|
||||||
|
$this->tpl_id = $tpl_id;
|
||||||
|
|
||||||
|
if($tpl_file != null) {
|
||||||
|
// tpl_file given, try to load the template..
|
||||||
|
$this->tpl->newTemplate($tpl_id, $tpl_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mpalte id that will be added to the main template
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @see setTemplateId()
|
||||||
|
*/
|
||||||
|
public function getTemplateId() {
|
||||||
|
return $this->tpl_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide or show the footer of the page
|
||||||
|
* @param boolean $value
|
||||||
|
*/
|
||||||
|
protected function addFooter($value) {
|
||||||
|
$this->add_footer = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide or show the menu of the page
|
||||||
|
* @param boolean $value
|
||||||
|
*/
|
||||||
|
protected function addMenu($value) {
|
||||||
|
$this->add_menu = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set actions available
|
||||||
|
* @param string|array $actions
|
||||||
|
* @param string $default default action
|
||||||
|
* @param boolean $append if TRUE, the actions will be added to the current actions
|
||||||
|
* @return psm\Module\AbstractModule
|
||||||
|
* @see getAction()
|
||||||
|
*/
|
||||||
|
protected function setActions($actions, $default = null, $append = true) {
|
||||||
|
if(!is_array($actions)) {
|
||||||
|
$actions = array($actions);
|
||||||
|
}
|
||||||
|
if($append) {
|
||||||
|
$this->actions = array_merge($actions);
|
||||||
|
} else {
|
||||||
|
$this->actions = $actions;
|
||||||
|
}
|
||||||
|
if($default !== null) {
|
||||||
|
$this->action_default = $default;
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current action
|
||||||
|
* @return string
|
||||||
|
* @see setActions()
|
||||||
|
*/
|
||||||
|
public function getAction() {
|
||||||
|
return $this->action;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add one or multiple message to the stack to be displayed to the user
|
||||||
|
* @param string|array $msg
|
||||||
|
* @return \psm\Module\AbstractModule
|
||||||
|
*/
|
||||||
|
public function addMessage($msg) {
|
||||||
|
if(!is_array($msg)) {
|
||||||
|
$msg = array($msg);
|
||||||
|
}
|
||||||
|
$this->messages = array_merge($this->messages, $msg);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -0,0 +1,197 @@
|
||||||
|
<?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@neanderthal-technology.com>
|
||||||
|
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||||
|
* @version Release: @package_version@
|
||||||
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
|
**/
|
||||||
|
|
||||||
|
namespace psm\Module;
|
||||||
|
use psm\Service\Database;
|
||||||
|
use psm\Service\Template;
|
||||||
|
|
||||||
|
class Config extends AbstractModule {
|
||||||
|
|
||||||
|
function __construct(Database $db, Template $tpl) {
|
||||||
|
parent::__construct($db, $tpl);
|
||||||
|
|
||||||
|
$this->setActions(array(
|
||||||
|
'index', 'save',
|
||||||
|
), 'index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate all the config fields with values from the database
|
||||||
|
*/
|
||||||
|
protected function executeIndex() {
|
||||||
|
$this->setTemplateId('config', 'config.tpl.html');
|
||||||
|
|
||||||
|
$config_db = $this->db->select(
|
||||||
|
PSM_DB_PREFIX . 'config',
|
||||||
|
null,
|
||||||
|
array('key', 'value')
|
||||||
|
);
|
||||||
|
|
||||||
|
$config = array();
|
||||||
|
foreach($config_db as $entry) {
|
||||||
|
$config[$entry['key']] = $entry['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate language array
|
||||||
|
$lang_keys = psm_get_langs();
|
||||||
|
$languages = array();
|
||||||
|
foreach($lang_keys as $key) {
|
||||||
|
$label = psm_get_lang('config', 'language_' . $key);
|
||||||
|
// if we don't have a proper label, just show the key..
|
||||||
|
// better something than nothing huh
|
||||||
|
if($label == null) {
|
||||||
|
$label = $key;
|
||||||
|
}
|
||||||
|
$languages[] = array(
|
||||||
|
'value' => $key,
|
||||||
|
'label' => $label,
|
||||||
|
'selected' => ($key == $config['language']) ? 'selected="selected"' : '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->tpl->addTemplateDataRepeat($this->getTemplateId(), 'languages', $languages);
|
||||||
|
|
||||||
|
$this->tpl->addTemplateData(
|
||||||
|
$this->getTemplateId(),
|
||||||
|
array(
|
||||||
|
'email_status_checked' => ($config['email_status'] == '1') ? 'checked="checked"' : '',
|
||||||
|
'email_from_name' => $config['email_from_name'],
|
||||||
|
'email_from_email' => $config['email_from_email'],
|
||||||
|
'sms_status_checked' => ($config['sms_status'] == '1') ? 'checked="checked"' : '',
|
||||||
|
'sms_selected_' . $config['sms_gateway'] => 'selected="selected"',
|
||||||
|
'sms_gateway_username' => $config['sms_gateway_username'],
|
||||||
|
'sms_gateway_password' => $config['sms_gateway_password'],
|
||||||
|
'sms_from' => $config['sms_from'],
|
||||||
|
'alert_type_selected_' . $config['alert_type'] => 'selected="selected"',
|
||||||
|
'log_status_checked' => ($config['log_status'] == '1') ? 'checked="checked"' : '',
|
||||||
|
'log_email_checked' => ($config['log_email'] == '1') ? 'checked="checked"' : '',
|
||||||
|
'log_sms_checked' => ($config['log_sms'] == '1') ? 'checked="checked"' : '',
|
||||||
|
'show_update_checked' => ($config['show_update'] == '1') ? 'checked="checked"' : '',
|
||||||
|
'auto_refresh_servers' => (isset($config['auto_refresh_servers'])) ? $config['auto_refresh_servers'] : '0',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a post has been done, gather all the posted data
|
||||||
|
* and save it to the database
|
||||||
|
*/
|
||||||
|
protected function executeSave() {
|
||||||
|
if(!empty($_POST)) {
|
||||||
|
// save new config
|
||||||
|
$clean = array(
|
||||||
|
'language' => $_POST['language'],
|
||||||
|
'show_update' => (isset($_POST['show_update'])) ? '1' : '0',
|
||||||
|
'email_status' => (isset($_POST['email_status'])) ? '1' : '0',
|
||||||
|
'email_from_name' => $_POST['email_from_name'],
|
||||||
|
'email_from_email' => $_POST['email_from_email'],
|
||||||
|
'sms_status' => (isset($_POST['sms_status'])) ? '1' : '0',
|
||||||
|
'sms_gateway' => $_POST['sms_gateway'],
|
||||||
|
'sms_gateway_username' => $_POST['sms_gateway_username'],
|
||||||
|
'sms_gateway_password' => $_POST['sms_gateway_password'],
|
||||||
|
'sms_from' => $_POST['sms_from'],
|
||||||
|
'alert_type' => $_POST['alert_type'],
|
||||||
|
'log_status' => (isset($_POST['log_status'])) ? '1' : '0',
|
||||||
|
'log_email' => (isset($_POST['log_email'])) ? '1' : '0',
|
||||||
|
'log_sms' => (isset($_POST['log_sms'])) ? '1' : '0',
|
||||||
|
'auto_refresh_servers' => (isset($_POST['auto_refresh_servers'])) ? intval($_POST['auto_refresh_servers']) : '0',
|
||||||
|
);
|
||||||
|
|
||||||
|
// save all values to the database
|
||||||
|
foreach($clean as $key => $value) {
|
||||||
|
// check if key already exists, otherwise add it
|
||||||
|
if(psm_get_conf($key) === null) {
|
||||||
|
// not yet set, add it
|
||||||
|
$this->db->save(
|
||||||
|
PSM_DB_PREFIX . 'config',
|
||||||
|
array(
|
||||||
|
'key' => $key,
|
||||||
|
'value' => $value,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// update
|
||||||
|
$this->db->save(
|
||||||
|
PSM_DB_PREFIX . 'config',
|
||||||
|
array('value' => $value),
|
||||||
|
array('key' => $key)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addMessage(psm_get_lang('config', 'updated'));
|
||||||
|
|
||||||
|
if($clean['language'] != psm_get_conf('language')) {
|
||||||
|
header('Location: ' . $_SERVER['REQUEST_URI']);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->initializeAction('index');
|
||||||
|
}
|
||||||
|
|
||||||
|
// override parent::createHTMLLabels()
|
||||||
|
protected function createHTMLLabels() {
|
||||||
|
$this->tpl->addTemplateData(
|
||||||
|
$this->getTemplateId(),
|
||||||
|
array(
|
||||||
|
'label_settings_email' => psm_get_lang('config', 'settings_email'),
|
||||||
|
'label_settings_sms' => psm_get_lang('config', 'settings_sms'),
|
||||||
|
'label_settings_notification' => psm_get_lang('config', 'settings_notification'),
|
||||||
|
'label_settings_log' => psm_get_lang('config', 'settings_log'),
|
||||||
|
'label_general' => psm_get_lang('config', 'general'),
|
||||||
|
'label_language' => psm_get_lang('config', 'language'),
|
||||||
|
'label_show_update' => psm_get_lang('config', 'show_update'),
|
||||||
|
'label_email_status' => psm_get_lang('config', 'email_status'),
|
||||||
|
'label_email_from_email' => psm_get_lang('config', 'email_from_email'),
|
||||||
|
'label_email_from_name' => psm_get_lang('config', 'email_from_name'),
|
||||||
|
'label_sms_status' => psm_get_lang('config', 'sms_status'),
|
||||||
|
'label_sms_gateway' => psm_get_lang('config', 'sms_gateway'),
|
||||||
|
'label_sms_gateway_mosms' => psm_get_lang('config', 'sms_gateway_mosms'),
|
||||||
|
'label_sms_gateway_mollie' => psm_get_lang('config', 'sms_gateway_mollie'),
|
||||||
|
'label_sms_gateway_spryng' => psm_get_lang('config', 'sms_gateway_spryng'),
|
||||||
|
'label_sms_gateway_inetworx' => psm_get_lang('config', 'sms_gateway_inetworx'),
|
||||||
|
'label_sms_gateway_clickatell' => psm_get_lang('config', 'sms_gateway_clickatell'),
|
||||||
|
'label_sms_gateway_textmarketer' => psm_get_lang('config', 'sms_gateway_textmarketer'),
|
||||||
|
'label_sms_gateway_username' => psm_get_lang('config', 'sms_gateway_username'),
|
||||||
|
'label_sms_gateway_password' => psm_get_lang('config', 'sms_gateway_password'),
|
||||||
|
'label_sms_from' => psm_get_lang('config', 'sms_from'),
|
||||||
|
'label_alert_type' => psm_get_lang('config', 'alert_type'),
|
||||||
|
'label_alert_type_description' => psm_get_lang('config', 'alert_type_description'),
|
||||||
|
'label_alert_type_status' => psm_get_lang('config', 'alert_type_status'),
|
||||||
|
'label_alert_type_offline' => psm_get_lang('config', 'alert_type_offline'),
|
||||||
|
'label_alert_type_always' => psm_get_lang('config', 'alert_type_always'),
|
||||||
|
'label_log_status' => psm_get_lang('config', 'log_status'),
|
||||||
|
'label_log_email' => psm_get_lang('config', 'log_email'),
|
||||||
|
'label_log_sms' => psm_get_lang('config', 'log_sms'),
|
||||||
|
'label_auto_refresh_servers' => psm_get_lang('config', 'auto_refresh_servers'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return parent::createHTMLLabels();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -0,0 +1,321 @@
|
||||||
|
<?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@neanderthal-technology.com>
|
||||||
|
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||||
|
* @version Release: @package_version@
|
||||||
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
|
* @since phpservermon 2.1.0
|
||||||
|
**/
|
||||||
|
|
||||||
|
namespace psm\Module;
|
||||||
|
use psm\Service\Database;
|
||||||
|
use psm\Service\Template;
|
||||||
|
|
||||||
|
class Install extends AbstractModule {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result messages to add to the main template
|
||||||
|
* @var array $install_results
|
||||||
|
* @see addResult()
|
||||||
|
*/
|
||||||
|
protected $install_results = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full path to config file
|
||||||
|
* @var string $path_config
|
||||||
|
*/
|
||||||
|
protected $path_config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full path to old config file (2.0)
|
||||||
|
* @var string $path_config_old
|
||||||
|
*/
|
||||||
|
protected $path_config_old;
|
||||||
|
|
||||||
|
function __construct(Database $db, Template $tpl) {
|
||||||
|
parent::__construct($db, $tpl);
|
||||||
|
|
||||||
|
$this->path_config = PSM_PATH_SRC . '../config.php';
|
||||||
|
$this->path_config_old = PSM_PATH_SRC . '../config.inc.php';
|
||||||
|
|
||||||
|
$this->setActions(array(
|
||||||
|
'index', 'config', 'install'
|
||||||
|
), 'index');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createHTML() {
|
||||||
|
$tpl_id_custom = $this->getTemplateId();
|
||||||
|
$this->setTemplateId('install', 'install.tpl.html');
|
||||||
|
$html_install = ($tpl_id_custom) ? $this->tpl->getTemplate($tpl_id_custom) : '';
|
||||||
|
|
||||||
|
$html_results = '';
|
||||||
|
if(!empty($this->install_results)) {
|
||||||
|
$this->tpl->newTemplate('install_results', 'install.tpl.html');
|
||||||
|
$this->tpl->addTemplateDataRepeat('install_results', 'resultmsgs', $this->install_results);
|
||||||
|
$html_results = $this->tpl->getTemplate('install_results');
|
||||||
|
}
|
||||||
|
$this->tpl->addTemplateData($this->getTemplateId(), array(
|
||||||
|
'html_install' => $html_install,
|
||||||
|
'html_results' => $html_results,
|
||||||
|
));
|
||||||
|
|
||||||
|
return parent::createHTML();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the main install page with prerequisites
|
||||||
|
*/
|
||||||
|
protected function executeIndex() {
|
||||||
|
$this->addMenu(false);
|
||||||
|
$tpl_data = array();
|
||||||
|
|
||||||
|
// build prerequisites
|
||||||
|
$errors = 0;
|
||||||
|
|
||||||
|
$phpv = phpversion();
|
||||||
|
if(version_compare($phpv, '5.3.0', '<')) {
|
||||||
|
$errors++;
|
||||||
|
$this->addResult('PHP 5.3+ is required to run PHP Server Monitor.', 'error');
|
||||||
|
} else {
|
||||||
|
$this->addResult('PHP version: ' . $phpv);
|
||||||
|
}
|
||||||
|
if(!function_exists('curl_init')) {
|
||||||
|
$this->addResult('PHP is installed without the cURL module. Please install cURL.', 'warning');
|
||||||
|
} else {
|
||||||
|
$this->addResult('cURL installed');
|
||||||
|
}
|
||||||
|
if(!function_exists('mysql_connect')) {
|
||||||
|
$errors++;
|
||||||
|
$this->addResult('php-mysql needs to be installed.', 'error');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($errors > 0) {
|
||||||
|
// cannot continue
|
||||||
|
$this->addResult($errors . ' error(s) have been encountered. Please fix them and refresh this page.', 'error');
|
||||||
|
} else {
|
||||||
|
if(defined('PSM_CONFIG')) {
|
||||||
|
$this->addResult('Configuration file found.');
|
||||||
|
return $this->executeInstall();
|
||||||
|
} else {
|
||||||
|
return $this->executeConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Help the user create a new config file
|
||||||
|
*/
|
||||||
|
protected function executeConfig() {
|
||||||
|
if(defined('PSM_CONFIG')) {
|
||||||
|
return $this->executeInstall();
|
||||||
|
}
|
||||||
|
// first detect "old" config file (2.0)
|
||||||
|
if(file_exists($this->path_config_old)) {
|
||||||
|
// oldtimer huh
|
||||||
|
$this->addResult('Configuration file for v2.0 found.');
|
||||||
|
$this->addResult(
|
||||||
|
'The location of the config file has been changed since the previous version.<br/>' .
|
||||||
|
'We will attempt to create a new config file for you.'
|
||||||
|
, 'warning');
|
||||||
|
$values = $this->parseConfig20();
|
||||||
|
} else {
|
||||||
|
// fresh install
|
||||||
|
$values = $_POST;
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = array(
|
||||||
|
'host' => 'localhost',
|
||||||
|
'name' => '',
|
||||||
|
'user' => '',
|
||||||
|
'pass' => '',
|
||||||
|
'prefix' => 'psm_',
|
||||||
|
);
|
||||||
|
$this->setTemplateId('install_config_new', 'install.tpl.html');
|
||||||
|
|
||||||
|
$changed = false;
|
||||||
|
foreach($config as $ckey => &$cvalue) {
|
||||||
|
if(isset($values[$ckey])) {
|
||||||
|
$changed = true;
|
||||||
|
$cvalue = $values[$ckey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add config to template data for prefilling the form
|
||||||
|
$tpl_data = $config;
|
||||||
|
|
||||||
|
if($changed) {
|
||||||
|
// test db connection
|
||||||
|
$this->db = new \psm\Service\Database(
|
||||||
|
$config['host'],
|
||||||
|
$config['user'],
|
||||||
|
$config['pass'],
|
||||||
|
$config['name']
|
||||||
|
);
|
||||||
|
|
||||||
|
if(is_resource($this->db->getLink())) {
|
||||||
|
$this->addResult('Connection to MySQL successful.');
|
||||||
|
$config_php = $this->writeConfigFile($config);
|
||||||
|
if($config_php === true) {
|
||||||
|
$this->addResult('Configuration file written successfully.');
|
||||||
|
return $this->executeInstall();
|
||||||
|
} else {
|
||||||
|
$this->addResult('Config file is not writable, we cannot save it for you.', 'error');
|
||||||
|
$this->tpl->newTemplate('install_config_new_copy', 'install.tpl.html');
|
||||||
|
$tpl_data['html_config_copy'] = $this->tpl->getTemplate('install_config_new_copy');
|
||||||
|
$tpl_data['php_config'] = $config_php;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->addResult('Unable to connect to MySQL. Please check your information.', 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tpl->addTemplateData($this->getTemplateId(), $tpl_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the 2.0 config file for prefilling
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function parseConfig20() {
|
||||||
|
$config_old = file_get_contents($this->path_config_old);
|
||||||
|
$vars = array(
|
||||||
|
'prefix' => '',
|
||||||
|
'user' => '',
|
||||||
|
'pass' => '',
|
||||||
|
'name' => '',
|
||||||
|
'host' => '',
|
||||||
|
);
|
||||||
|
$pattern = "/define\('SM_DB_{key}', '(.*?)'/u";
|
||||||
|
|
||||||
|
foreach($vars as $key => $value) {
|
||||||
|
$pattern_key = str_replace('{key}', strtoupper($key), $pattern);
|
||||||
|
preg_match($pattern_key, $config_old, $value_matches);
|
||||||
|
$vars[$key] = (isset($value_matches[1])) ? $value_matches[1] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $vars;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the upgrade process to a newer version
|
||||||
|
*/
|
||||||
|
protected function executeInstall() {
|
||||||
|
if(!defined('PSM_CONFIG')) {
|
||||||
|
$this->addResult('No valid configuration found.', 'error');
|
||||||
|
return $this->executeConfig();
|
||||||
|
}
|
||||||
|
if(!is_resource($this->db->getLink())) {
|
||||||
|
$this->addResult('MySQL connection failed.', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$queries = new \psm\Util\Install\Queries;
|
||||||
|
$tables = $queries->install();
|
||||||
|
foreach($tables as $name => $sql) {
|
||||||
|
$if_table_exists = $this->db->query("SHOW TABLES LIKE '{$name}'");
|
||||||
|
|
||||||
|
if(!empty($if_table_exists)) {
|
||||||
|
$this->addResult('Table ' . $name . ' already exists in your database!');
|
||||||
|
} else {
|
||||||
|
$this->db->query($sql);
|
||||||
|
$this->addResult('Table ' . $name . ' added.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$version_conf = $this->db->selectRow(PSM_DB_PREFIX . 'config', array('key' => 'version'), array('key', 'value'));
|
||||||
|
|
||||||
|
if(empty($version_conf)) {
|
||||||
|
// fresh install
|
||||||
|
$version_from = null;
|
||||||
|
} else {
|
||||||
|
// existing install
|
||||||
|
$version_from = $version_conf['value'];
|
||||||
|
if(strpos($version_from, '.') === false) {
|
||||||
|
// yeah, my bad.. previous version did not follow proper naming scheme
|
||||||
|
$version_from = rtrim(chunk_split($version_from, 1, '.'), '.');
|
||||||
|
}
|
||||||
|
$this->addResult('Upgrade detected, upgrading from ' . $version_from);
|
||||||
|
}
|
||||||
|
$this->addResult('Executing database changes for version ' . PSM_VERSION);
|
||||||
|
$install_queries = $queries->upgrade(PSM_VERSION, $version_from);
|
||||||
|
|
||||||
|
foreach($install_queries as $sql) {
|
||||||
|
$this->db->query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addResult('Installation finished!');
|
||||||
|
$this->setTemplateId('install_success', 'install.tpl.html');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write config file with db variables
|
||||||
|
* @param array $db_vars prefix,user,pass,name,host
|
||||||
|
* @return boolean|string TRUE on success, string with config otherwise
|
||||||
|
*/
|
||||||
|
protected function writeConfigFile($db_vars) {
|
||||||
|
$config =
|
||||||
|
"<?php".PHP_EOL .
|
||||||
|
"define('PSM_CONFIG', true);".PHP_EOL;
|
||||||
|
|
||||||
|
foreach($db_vars as $key => $value) {
|
||||||
|
$line = "define('PSM_DB_{key}', '{value}');".PHP_EOL;
|
||||||
|
$line = str_replace(
|
||||||
|
array('{key}', '{value}'),
|
||||||
|
array(strtoupper($key), $value),
|
||||||
|
$line
|
||||||
|
);
|
||||||
|
$config .= $line;
|
||||||
|
}
|
||||||
|
$config .= "?>".PHP_EOL;
|
||||||
|
if(is_writeable($this->path_config)) {
|
||||||
|
file_put_contents($this->path_config, $config);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add install result to be added to the main template
|
||||||
|
* @param string|array $msg
|
||||||
|
* @param string $status success/warning/error
|
||||||
|
* @return \psm\Module\Install
|
||||||
|
*/
|
||||||
|
protected function addResult($msg, $status = 'success') {
|
||||||
|
if(!is_array($msg)) {
|
||||||
|
$msg = array($msg);
|
||||||
|
}
|
||||||
|
if($status == 'error') {
|
||||||
|
$shortcode = 'important';
|
||||||
|
} else {
|
||||||
|
$shortcode = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($msg as $m) {
|
||||||
|
$this->install_results[] = array(
|
||||||
|
'message' => $m,
|
||||||
|
'status' => strtoupper($status),
|
||||||
|
'shortcode' => $shortcode,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -25,28 +25,25 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
namespace psm\Module;
|
||||||
|
use psm\Service\Database;
|
||||||
|
use psm\Service\Template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log module. Create the page to view previous log messages
|
* Log module. Create the page to view previous log messages
|
||||||
*/
|
*/
|
||||||
class modLog extends modCore {
|
class Log extends AbstractModule {
|
||||||
|
|
||||||
function __construct() {
|
function __construct(Database $db, Template $tpl) {
|
||||||
parent::__construct();
|
parent::__construct($db, $tpl);
|
||||||
}
|
|
||||||
|
|
||||||
// override parent::createHTML()
|
$this->setActions('index', 'index');
|
||||||
public function createHTML() {
|
|
||||||
$this->tpl->addCSS('tabs.css', 'main');
|
|
||||||
|
|
||||||
$this->createHTMLList();
|
|
||||||
|
|
||||||
return parent::createHTML();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the template with a list of all log entries
|
* Prepare the template with a list of all log entries
|
||||||
*/
|
*/
|
||||||
protected function createHTMLList() {
|
protected function executeIndex() {
|
||||||
$this->setTemplateId('log_list', 'log.tpl.html');
|
$this->setTemplateId('log_list', 'log.tpl.html');
|
||||||
|
|
||||||
$entries = array();
|
$entries = array();
|
||||||
|
|
@ -55,7 +52,7 @@ class modLog extends modCore {
|
||||||
$entries['sms'] = $this->getEntries('sms');
|
$entries['sms'] = $this->getEntries('sms');
|
||||||
|
|
||||||
// get users
|
// get users
|
||||||
$users = $this->db->select(SM_DB_PREFIX.'users', null, array('user_id','name'));
|
$users = $this->db->select(PSM_DB_PREFIX.'users', null, array('user_id','name'));
|
||||||
|
|
||||||
$users_labels = array();
|
$users_labels = array();
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
|
|
@ -97,7 +94,6 @@ class modLog extends modCore {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -122,8 +118,8 @@ class modLog extends modCore {
|
||||||
'\'%H:%i:%s %d-%m-%y\''.
|
'\'%H:%i:%s %d-%m-%y\''.
|
||||||
') AS `datetime_format`, '.
|
') AS `datetime_format`, '.
|
||||||
'`user_id` '.
|
'`user_id` '.
|
||||||
'FROM `'.SM_DB_PREFIX.'log` AS `log` '.
|
'FROM `'.PSM_DB_PREFIX.'log` AS `log` '.
|
||||||
'JOIN `'.SM_DB_PREFIX.'servers` AS `servers` ON (`servers`.`server_id`=`log`.`server_id`) '.
|
'JOIN `'.PSM_DB_PREFIX.'servers` AS `servers` ON (`servers`.`server_id`=`log`.`server_id`) '.
|
||||||
'WHERE `log`.`type`=\''.$type.'\' '.
|
'WHERE `log`.`type`=\''.$type.'\' '.
|
||||||
'ORDER BY `datetime` DESC '.
|
'ORDER BY `datetime` DESC '.
|
||||||
'LIMIT 0,20'
|
'LIMIT 0,20'
|
||||||
|
|
@ -136,15 +132,15 @@ class modLog extends modCore {
|
||||||
$this->tpl->addTemplateData(
|
$this->tpl->addTemplateData(
|
||||||
$this->getTemplateId(),
|
$this->getTemplateId(),
|
||||||
array(
|
array(
|
||||||
'label_status' => sm_get_lang('log', 'status'),
|
'label_status' => psm_get_lang('log', 'status'),
|
||||||
'label_email' => sm_get_lang('log', 'email'),
|
'label_email' => psm_get_lang('log', 'email'),
|
||||||
'label_sms' => sm_get_lang('log', 'sms'),
|
'label_sms' => psm_get_lang('log', 'sms'),
|
||||||
'label_title' => sm_get_lang('log', 'title'),
|
'label_title' => psm_get_lang('log', 'title'),
|
||||||
'label_server' => sm_get_lang('servers', 'server'),
|
'label_server' => psm_get_lang('servers', 'server'),
|
||||||
'label_type' => sm_get_lang('log', 'type'),
|
'label_type' => psm_get_lang('log', 'type'),
|
||||||
'label_message' => sm_get_lang('system', 'message'),
|
'label_message' => psm_get_lang('system', 'message'),
|
||||||
'label_date' => sm_get_lang('system', 'date'),
|
'label_date' => psm_get_lang('system', 'date'),
|
||||||
'label_users' => ucfirst(sm_get_lang('system', 'users')),
|
'label_users' => ucfirst(psm_get_lang('system', 'users')),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?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@neanderthal-technology.com>
|
||||||
|
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||||
|
* @version Release: @package_version@
|
||||||
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
|
* @since phpservermon 2.1
|
||||||
|
**/
|
||||||
|
|
||||||
|
namespace psm\Module;
|
||||||
|
use psm\Service\Database;
|
||||||
|
use psm\Service\Template;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public API for all modules
|
||||||
|
*/
|
||||||
|
interface ModuleInterface {
|
||||||
|
|
||||||
|
public function __construct(Database $db, Template $tpl);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the module
|
||||||
|
*/
|
||||||
|
public function initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -25,98 +25,27 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
namespace psm\Module;
|
||||||
|
use psm\Service\Database;
|
||||||
|
use psm\Service\Template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server module. Add/edit/delete servers, show a list of all servers etc.
|
* Server module. Add/edit/delete servers, show a list of all servers etc.
|
||||||
*/
|
*/
|
||||||
class modServers extends modCore {
|
class Servers extends AbstractModule {
|
||||||
|
|
||||||
function __construct() {
|
function __construct(Database $db, Template $tpl) {
|
||||||
parent::__construct();
|
parent::__construct($db, $tpl);
|
||||||
|
|
||||||
// check mode
|
$this->setActions(array(
|
||||||
if (isset($_GET['edit']) && is_numeric($_GET['edit'])) {
|
'index', 'edit', 'save', 'delete',
|
||||||
// edit mode or insert mode
|
), 'index');
|
||||||
$this->mode = 'update';
|
|
||||||
} else {
|
|
||||||
$this->mode = 'list';
|
|
||||||
|
|
||||||
if(!empty($_POST)) {
|
|
||||||
$this->executeSave();
|
|
||||||
}
|
|
||||||
if(isset($_GET['delete']) && is_numeric($_GET['delete'])) {
|
|
||||||
$this->executeDelete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// override parent::createHTML()
|
|
||||||
public function createHTML() {
|
|
||||||
switch($this->mode) {
|
|
||||||
case 'list':
|
|
||||||
$this->createHTMLList();
|
|
||||||
break;
|
|
||||||
case 'update':
|
|
||||||
$this->createHTMLUpdate();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::createHTML();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepare the template to show the update screen for a single server
|
|
||||||
*/
|
|
||||||
protected function createHTMLUpdate() {
|
|
||||||
$this->setTemplateId('servers_update', 'servers.tpl.html');
|
|
||||||
|
|
||||||
$server_id = $_GET['edit'];
|
|
||||||
|
|
||||||
$tpl_data = array();
|
|
||||||
|
|
||||||
switch(intval($server_id)) {
|
|
||||||
case 0:
|
|
||||||
// insert mode
|
|
||||||
$tpl_data['titlemode'] = sm_get_lang('system', 'insert');
|
|
||||||
$tpl_data['edit_server_id'] = '0';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// edit mode
|
|
||||||
|
|
||||||
// get server entry
|
|
||||||
$edit_server = $this->db->selectRow(
|
|
||||||
SM_DB_PREFIX.'servers',
|
|
||||||
array('server_id' => $server_id)
|
|
||||||
);
|
|
||||||
if (empty($edit_server)) {
|
|
||||||
$this->message = 'Invalid server id';
|
|
||||||
return $this->createHTMLList();
|
|
||||||
}
|
|
||||||
|
|
||||||
$tpl_data = array_merge($tpl_data, array(
|
|
||||||
'titlemode' => sm_get_lang('system', 'edit') . ' ' . $edit_server['label'],
|
|
||||||
'edit_server_id' => $edit_server['server_id'],
|
|
||||||
'edit_value_label' => $edit_server['label'],
|
|
||||||
'edit_value_ip' => $edit_server['ip'],
|
|
||||||
'edit_value_port' => $edit_server['port'],
|
|
||||||
'edit_type_selected_' . $edit_server['type'] => 'selected="selected"',
|
|
||||||
'edit_active_selected_' . $edit_server['active'] => 'selected="selected"',
|
|
||||||
'edit_email_selected_' . $edit_server['email'] => 'selected="selected"',
|
|
||||||
'edit_sms_selected_' . $edit_server['sms'] => 'selected="selected"',
|
|
||||||
));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->tpl->addTemplateData(
|
|
||||||
$this->getTemplateId(),
|
|
||||||
$tpl_data
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the template to show a list of all servers
|
* Prepare the template to show a list of all servers
|
||||||
*/
|
*/
|
||||||
protected function createHTMLList() {
|
protected function executeIndex() {
|
||||||
$this->setTemplateId('servers_list', 'servers.tpl.html');
|
$this->setTemplateId('servers_list', 'servers.tpl.html');
|
||||||
|
|
||||||
// get servers from database
|
// get servers from database
|
||||||
|
|
@ -127,6 +56,7 @@ class modServers extends modCore {
|
||||||
'`port`, '.
|
'`port`, '.
|
||||||
'`type`, '.
|
'`type`, '.
|
||||||
'`label`, '.
|
'`label`, '.
|
||||||
|
'`pattern`, '.
|
||||||
'`status`, '.
|
'`status`, '.
|
||||||
'`error`, '.
|
'`error`, '.
|
||||||
'`rtime`, '.
|
'`rtime`, '.
|
||||||
|
|
@ -143,7 +73,7 @@ class modServers extends modCore {
|
||||||
'`active`, '.
|
'`active`, '.
|
||||||
'`email`, '.
|
'`email`, '.
|
||||||
'`sms` '.
|
'`sms` '.
|
||||||
'FROM `'.SM_DB_PREFIX.'servers` '.
|
'FROM `'.PSM_DB_PREFIX.'servers` '.
|
||||||
'ORDER BY `active` ASC, `status` DESC, `type` ASC, `label` ASC'
|
'ORDER BY `active` ASC, `status` DESC, `type` ASC, `label` ASC'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -162,14 +92,63 @@ class modServers extends modCore {
|
||||||
$this->tpl->addTemplateDataRepeat($this->getTemplateId(), 'servers', $servers);
|
$this->tpl->addTemplateDataRepeat($this->getTemplateId(), 'servers', $servers);
|
||||||
|
|
||||||
// check if we need to add the auto refresh
|
// check if we need to add the auto refresh
|
||||||
$auto_refresh = sm_get_conf('auto_refresh_servers');
|
$auto_refresh = psm_get_conf('auto_refresh_servers');
|
||||||
if(intval($auto_refresh) > 0) {
|
if(intval($auto_refresh) > 0) {
|
||||||
// add it
|
// add it
|
||||||
$this->tpl->newTemplate('main_auto_refresh', 'main.tpl.html');
|
$this->tpl->newTemplate('main_auto_refresh', 'main.tpl.html');
|
||||||
$this->tpl->addTemplateData('main_auto_refresh', array('seconds' => $auto_refresh));
|
$this->tpl->addTemplateData('main_auto_refresh', array('seconds' => $auto_refresh));
|
||||||
$this->tpl->addTemplateData('main', array('auto_refresh' => $this->tpl->getTemplate('main_auto_refresh')));
|
$this->tpl->addTemplateData('main', array('auto_refresh' => $this->tpl->getTemplate('main_auto_refresh')));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the template to show the update screen for a single server
|
||||||
|
*/
|
||||||
|
protected function executeEdit() {
|
||||||
|
$this->setTemplateId('servers_update', 'servers.tpl.html');
|
||||||
|
|
||||||
|
$server_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
|
||||||
|
|
||||||
|
$tpl_data = array();
|
||||||
|
|
||||||
|
switch(intval($server_id)) {
|
||||||
|
case 0:
|
||||||
|
// insert mode
|
||||||
|
$tpl_data['titlemode'] = psm_get_lang('system', 'insert');
|
||||||
|
$tpl_data['edit_server_id'] = '0';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// edit mode
|
||||||
|
// get server entry
|
||||||
|
$edit_server = $this->db->selectRow(
|
||||||
|
PSM_DB_PREFIX.'servers',
|
||||||
|
array('server_id' => $server_id)
|
||||||
|
);
|
||||||
|
if (empty($edit_server)) {
|
||||||
|
$this->addMessage('Invalid server id');
|
||||||
|
return $this->initializeAction('index');
|
||||||
|
}
|
||||||
|
|
||||||
|
$tpl_data = array_merge($tpl_data, array(
|
||||||
|
'titlemode' => psm_get_lang('system', 'edit') . ' ' . $edit_server['label'],
|
||||||
|
'edit_server_id' => $edit_server['server_id'],
|
||||||
|
'edit_value_label' => $edit_server['label'],
|
||||||
|
'edit_value_ip' => $edit_server['ip'],
|
||||||
|
'edit_value_port' => $edit_server['port'],
|
||||||
|
'edit_value_pattern' => $edit_server['pattern'],
|
||||||
|
'edit_type_selected_' . $edit_server['type'] => 'selected="selected"',
|
||||||
|
'edit_active_selected_' . $edit_server['active'] => 'selected="selected"',
|
||||||
|
'edit_email_selected_' . $edit_server['email'] => 'selected="selected"',
|
||||||
|
'edit_sms_selected_' . $edit_server['sms'] => 'selected="selected"',
|
||||||
|
));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tpl->addTemplateData(
|
||||||
|
$this->getTemplateId(),
|
||||||
|
$tpl_data
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -178,46 +157,55 @@ class modServers extends modCore {
|
||||||
protected function executeSave() {
|
protected function executeSave() {
|
||||||
// check for add/edit mode
|
// check for add/edit mode
|
||||||
if(isset($_POST['label']) && isset($_POST['ip']) && isset($_POST['port'])) {
|
if(isset($_POST['label']) && isset($_POST['ip']) && isset($_POST['port'])) {
|
||||||
|
$server_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
|
||||||
|
|
||||||
$clean = array(
|
$clean = array(
|
||||||
'label' => $_POST['label'],
|
'label' => strip_tags($_POST['label']),
|
||||||
'ip' => $_POST['ip'],
|
'ip' => strip_tags($_POST['ip']),
|
||||||
'port' => $_POST['port'],
|
'port' => strip_tags($_POST['port']),
|
||||||
|
// @todo validate the following values
|
||||||
'type' => $_POST['type'],
|
'type' => $_POST['type'],
|
||||||
|
'pattern' => $_POST['pattern'],
|
||||||
'active' => $_POST['active'],
|
'active' => $_POST['active'],
|
||||||
'email' => $_POST['email'],
|
'email' => $_POST['email'],
|
||||||
'sms' => $_POST['sms'],
|
'sms' => $_POST['sms'],
|
||||||
);
|
);
|
||||||
|
|
||||||
// check for edit or add
|
// check for edit or add
|
||||||
if ((int) $_POST['server_id'] > 0) {
|
if($server_id > 0) {
|
||||||
// edit
|
// edit
|
||||||
$this->db->save(
|
$this->db->save(
|
||||||
SM_DB_PREFIX.'servers',
|
PSM_DB_PREFIX.'servers',
|
||||||
$clean,
|
$clean,
|
||||||
array('server_id' => $_POST['server_id'])
|
array('server_id' => $server_id)
|
||||||
);
|
);
|
||||||
$this->message = sm_get_lang('servers', 'updated');
|
$this->addMessage(psm_get_lang('servers', 'updated'));
|
||||||
} else {
|
} else {
|
||||||
// add
|
// add
|
||||||
$clean['status'] = 'on';
|
$clean['status'] = 'on';
|
||||||
$this->db->save(SM_DB_PREFIX.'servers', $clean);
|
$this->db->save(PSM_DB_PREFIX.'servers', $clean);
|
||||||
$this->message = sm_get_lang('servers', 'inserted');
|
$this->addMessage(psm_get_lang('servers', 'inserted'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->initializeAction('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the deletion of one of the servers
|
* Executes the deletion of one of the servers
|
||||||
*/
|
*/
|
||||||
protected function executeDelete() {
|
protected function executeDelete() {
|
||||||
|
if(isset($_GET['id'])) {
|
||||||
|
$id = intval($_GET['id']);
|
||||||
// do delete
|
// do delete
|
||||||
$this->db->delete(
|
$this->db->delete(
|
||||||
SM_DB_PREFIX . 'servers',
|
PSM_DB_PREFIX . 'servers',
|
||||||
array(
|
array(
|
||||||
'server_id' => $_GET['delete']
|
'server_id' => $id,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->message = sm_get_lang('system', 'deleted');
|
$this->addMessage(psm_get_lang('system', 'deleted'));
|
||||||
|
}
|
||||||
|
$this->initializeAction('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
// override parent::createHTMLLabels()
|
// override parent::createHTMLLabels()
|
||||||
|
|
@ -225,23 +213,24 @@ class modServers extends modCore {
|
||||||
$this->tpl->addTemplateData(
|
$this->tpl->addTemplateData(
|
||||||
$this->getTemplateId(),
|
$this->getTemplateId(),
|
||||||
array(
|
array(
|
||||||
'label_label' => sm_get_lang('servers', 'label'),
|
'label_label' => psm_get_lang('servers', 'label'),
|
||||||
'label_domain' => sm_get_lang('servers', 'domain'),
|
'label_domain' => psm_get_lang('servers', 'domain'),
|
||||||
'label_port' => sm_get_lang('servers', 'port'),
|
'label_port' => psm_get_lang('servers', 'port'),
|
||||||
'label_type' => sm_get_lang('servers', 'type'),
|
'label_type' => psm_get_lang('servers', 'type'),
|
||||||
'label_last_check' => sm_get_lang('servers', 'last_check'),
|
'label_pattern' => psm_get_lang('servers', 'pattern'),
|
||||||
'label_rtime' => sm_get_lang('servers', 'rtime'),
|
'label_last_check' => psm_get_lang('servers', 'last_check'),
|
||||||
'label_last_online' => sm_get_lang('servers', 'last_online'),
|
'label_rtime' => psm_get_lang('servers', 'rtime'),
|
||||||
'label_monitoring' => sm_get_lang('servers', 'monitoring'),
|
'label_last_online' => psm_get_lang('servers', 'last_online'),
|
||||||
'label_send_email' => sm_get_lang('servers', 'send_email'),
|
'label_monitoring' => psm_get_lang('servers', 'monitoring'),
|
||||||
'label_send_sms' => sm_get_lang('servers', 'send_sms'),
|
'label_send_email' => psm_get_lang('servers', 'send_email'),
|
||||||
'label_action' => sm_get_lang('system', 'action'),
|
'label_send_sms' => psm_get_lang('servers', 'send_sms'),
|
||||||
'label_save' => sm_get_lang('system', 'save'),
|
'label_action' => psm_get_lang('system', 'action'),
|
||||||
'label_edit' => sm_get_lang('system', 'edit') . ' ' . sm_get_lang('servers', 'server'),
|
'label_save' => psm_get_lang('system', 'save'),
|
||||||
'label_delete' => sm_get_lang('system', 'delete') . ' ' . sm_get_lang('servers', 'server'),
|
'label_edit' => psm_get_lang('system', 'edit') . ' ' . psm_get_lang('servers', 'server'),
|
||||||
'label_yes' => sm_get_lang('system', 'yes'),
|
'label_delete' => psm_get_lang('system', 'delete') . ' ' . psm_get_lang('servers', 'server'),
|
||||||
'label_no' => sm_get_lang('system', 'no'),
|
'label_yes' => psm_get_lang('system', 'yes'),
|
||||||
'label_add_new' => sm_get_lang('system', 'add_new'),
|
'label_no' => psm_get_lang('system', 'no'),
|
||||||
|
'label_add_new' => psm_get_lang('system', 'add_new'),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -26,33 +26,32 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
namespace psm\Module;
|
||||||
|
use psm\Service\Database;
|
||||||
|
use psm\Service\Template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status module
|
* Status module
|
||||||
*/
|
*/
|
||||||
class modStatus extends modCore {
|
class Status extends AbstractModule {
|
||||||
|
|
||||||
function __construct() {
|
function __construct(Database $db, Template $tpl) {
|
||||||
parent::__construct();
|
parent::__construct($db, $tpl);
|
||||||
}
|
|
||||||
|
|
||||||
// override parent::createHTML()
|
$this->setActions('index', 'index');
|
||||||
public function createHTML() {
|
|
||||||
$this->createHTMLList();
|
|
||||||
|
|
||||||
return parent::createHTML();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the template to show a list of all servers
|
* Prepare the template to show a list of all servers
|
||||||
* @todo move the background colurs to the config
|
* @todo move the background colurs to the config
|
||||||
*/
|
*/
|
||||||
protected function createHTMLList() {
|
protected function executeIndex() {
|
||||||
$this->setTemplateId('status', 'status.tpl.html');
|
$this->setTemplateId('status', 'status.tpl.html');
|
||||||
$this->addFooter(false);
|
$this->addFooter(false);
|
||||||
|
|
||||||
// get the active servers from database
|
// get the active servers from database
|
||||||
$servers = $this->db->select(
|
$servers = $this->db->select(
|
||||||
SM_DB_PREFIX.'servers',
|
PSM_DB_PREFIX.'servers',
|
||||||
array('active' => 'yes'),
|
array('active' => 'yes'),
|
||||||
array('server_id', 'label', 'status', 'last_online', 'last_check', 'rtime')
|
array('server_id', 'label', 'status', 'last_online', 'last_check', 'rtime')
|
||||||
);
|
);
|
||||||
|
|
@ -66,12 +65,15 @@ class modStatus extends modCore {
|
||||||
'offline_fg' => '#f7cece',
|
'offline_fg' => '#f7cece',
|
||||||
'online_bg' => '#53a000',
|
'online_bg' => '#53a000',
|
||||||
'online_fg' => '#d8f7ce',
|
'online_fg' => '#d8f7ce',
|
||||||
|
'label_last_check' => psm_get_lang('servers', 'last_check'),
|
||||||
|
'label_last_online' => psm_get_lang('servers', 'last_online'),
|
||||||
|
'label_rtime' => psm_get_lang('servers', 'rtime'),
|
||||||
);
|
);
|
||||||
$this->tpl->addTemplateData($this->getTemplateId(), $tpl_data);
|
$this->tpl->addTemplateData($this->getTemplateId(), $tpl_data);
|
||||||
|
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
$server['last_checked_nice'] = sm_timespan($server['last_check']);
|
$server['last_checked_nice'] = psm_timespan($server['last_check']);
|
||||||
$server['last_online_nice'] = sm_timespan($server['last_online']);
|
$server['last_online_nice'] = psm_timespan($server['last_online']);
|
||||||
|
|
||||||
if ($server['status'] == "off") {
|
if ($server['status'] == "off") {
|
||||||
$offline[$server['server_id']] = $server;
|
$offline[$server['server_id']] = $server;
|
||||||
|
|
@ -25,55 +25,34 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
namespace psm\Module;
|
||||||
|
use psm\Service\Database;
|
||||||
|
use psm\Service\Template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User module. Add, edit and delete users, or assign
|
* User module. Add, edit and delete users, or assign
|
||||||
* servers to users.
|
* servers to users.
|
||||||
*/
|
*/
|
||||||
class modUsers extends modCore {
|
class Users extends AbstractModule {
|
||||||
public $servers;
|
public $servers;
|
||||||
|
|
||||||
function __construct() {
|
function __construct(Database $db, Template $tpl) {
|
||||||
parent::__construct();
|
parent::__construct($db, $tpl);
|
||||||
|
|
||||||
// check mode
|
$this->setActions(array(
|
||||||
if (isset($_GET['edit']) && is_numeric($_GET['edit'])) {
|
'index', 'edit', 'delete', 'save',
|
||||||
// edit mode or insert mode
|
), 'index');
|
||||||
$this->mode = 'update';
|
|
||||||
} else {
|
|
||||||
$this->mode = 'list';
|
|
||||||
|
|
||||||
if(!empty($_POST)) {
|
$this->servers = $this->db->select(PSM_DB_PREFIX.'servers', null, array('server_id', 'label'));
|
||||||
$this->executeSave();
|
|
||||||
}
|
|
||||||
if(isset($_GET['delete']) && is_numeric($_GET['delete'])) {
|
|
||||||
$this->executeDelete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->servers = $this->db->select(SM_DB_PREFIX.'servers', null, array('server_id', 'label'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// override parent::createHTML()
|
|
||||||
public function createHTML() {
|
|
||||||
switch($this->mode) {
|
|
||||||
case 'list':
|
|
||||||
$this->createHTMLList();
|
|
||||||
break;
|
|
||||||
case 'update':
|
|
||||||
$this->createHTMLUpdate();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::createHTML();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the template to show the update screen for a user
|
* Prepare the template to show the update screen for a user
|
||||||
*/
|
*/
|
||||||
protected function createHTMLUpdate() {
|
protected function executeEdit() {
|
||||||
$this->setTemplateId('users_update', 'users.tpl.html');
|
$this->setTemplateId('users_update', 'users.tpl.html');
|
||||||
|
|
||||||
$user_id = $_GET['edit'];
|
$user_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
|
||||||
|
|
||||||
$tpl_data = array();
|
$tpl_data = array();
|
||||||
$servers_count = count($this->servers);
|
$servers_count = count($this->servers);
|
||||||
|
|
@ -81,7 +60,7 @@ class modUsers extends modCore {
|
||||||
switch((int) $user_id) {
|
switch((int) $user_id) {
|
||||||
case 0:
|
case 0:
|
||||||
// insert mode
|
// insert mode
|
||||||
$tpl_data['titlemode'] = sm_get_lang('system', 'insert');
|
$tpl_data['titlemode'] = psm_get_lang('system', 'insert');
|
||||||
$tpl_data['edit_user_id'] = '0';
|
$tpl_data['edit_user_id'] = '0';
|
||||||
|
|
||||||
// add inactive class to all servers
|
// add inactive class to all servers
|
||||||
|
|
@ -92,19 +71,17 @@ class modUsers extends modCore {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// edit mode
|
// edit mode
|
||||||
|
|
||||||
// get user entry
|
|
||||||
$edit_user = $this->db->selectRow(
|
$edit_user = $this->db->selectRow(
|
||||||
SM_DB_PREFIX.'users',
|
PSM_DB_PREFIX.'users',
|
||||||
array('user_id' => $user_id)
|
array('user_id' => $user_id)
|
||||||
);
|
);
|
||||||
if (empty($edit_user)) {
|
if (empty($edit_user)) {
|
||||||
$this->message = 'Invalid user id';
|
$this->addMessage('Invalid user.');
|
||||||
return $this->createHTMLList();
|
return $this->initializeAction('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl_data = array_merge($tpl_data, array(
|
$tpl_data = array_merge($tpl_data, array(
|
||||||
'titlemode' => sm_get_lang('system', 'edit') . ' ' . $edit_user['name'],
|
'titlemode' => psm_get_lang('system', 'edit') . ' ' . $edit_user['name'],
|
||||||
'edit_user_id' => $edit_user['user_id'],
|
'edit_user_id' => $edit_user['user_id'],
|
||||||
'edit_value_name' => $edit_user['name'],
|
'edit_value_name' => $edit_user['name'],
|
||||||
'edit_value_mobile' => $edit_user['mobile'],
|
'edit_value_mobile' => $edit_user['mobile'],
|
||||||
|
|
@ -135,7 +112,7 @@ class modUsers extends modCore {
|
||||||
/**
|
/**
|
||||||
* Prepare the template to show a list of all users
|
* Prepare the template to show a list of all users
|
||||||
*/
|
*/
|
||||||
protected function createHTMLList() {
|
protected function executeIndex() {
|
||||||
$this->setTemplateId('users_list', 'users.tpl.html');
|
$this->setTemplateId('users_list', 'users.tpl.html');
|
||||||
|
|
||||||
// build label array for the next loop
|
// build label array for the next loop
|
||||||
|
|
@ -146,7 +123,7 @@ class modUsers extends modCore {
|
||||||
|
|
||||||
// get users from database
|
// get users from database
|
||||||
$users = $this->db->select(
|
$users = $this->db->select(
|
||||||
SM_DB_PREFIX.'users',
|
PSM_DB_PREFIX.'users',
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
|
@ -172,7 +149,6 @@ class modUsers extends modCore {
|
||||||
}
|
}
|
||||||
// add servers to template
|
// add servers to template
|
||||||
$this->tpl->addTemplateDataRepeat($this->getTemplateId(), 'users', $users);
|
$this->tpl->addTemplateDataRepeat($this->getTemplateId(), 'users', $users);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -180,7 +156,6 @@ class modUsers extends modCore {
|
||||||
*/
|
*/
|
||||||
protected function executeSave() {
|
protected function executeSave() {
|
||||||
// check for add/edit mode
|
// check for add/edit mode
|
||||||
|
|
||||||
if (isset($_POST['name']) && isset($_POST['mobile']) && isset($_POST['email'])) {
|
if (isset($_POST['name']) && isset($_POST['mobile']) && isset($_POST['email'])) {
|
||||||
$clean = array(
|
$clean = array(
|
||||||
'name' => $_POST['name'],
|
'name' => $_POST['name'],
|
||||||
|
|
@ -188,36 +163,42 @@ class modUsers extends modCore {
|
||||||
'email' => $_POST['email'],
|
'email' => $_POST['email'],
|
||||||
'server_id' => (isset($_POST['server_id'])) ? implode(',', $_POST['server_id']) : ''
|
'server_id' => (isset($_POST['server_id'])) ? implode(',', $_POST['server_id']) : ''
|
||||||
);
|
);
|
||||||
|
$id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
|
||||||
|
|
||||||
// check for edit or add
|
// check for edit or add
|
||||||
if ((int) $_POST['user_id'] > 0) {
|
if ((int) $id > 0) {
|
||||||
// edit
|
// edit
|
||||||
$this->db->save(
|
$this->db->save(
|
||||||
SM_DB_PREFIX.'users',
|
PSM_DB_PREFIX.'users',
|
||||||
$clean,
|
$clean,
|
||||||
array('user_id' => $_POST['user_id'])
|
array('user_id' => $id)
|
||||||
);
|
);
|
||||||
$this->message = sm_get_lang('users', 'updated');
|
$this->addMessage(psm_get_lang('users', 'updated'));
|
||||||
} else {
|
} else {
|
||||||
// add
|
// add
|
||||||
$this->db->save(SM_DB_PREFIX.'users', $clean);
|
$this->db->save(PSM_DB_PREFIX.'users', $clean);
|
||||||
$this->message = sm_get_lang('users', 'inserted');
|
$this->addMessage(psm_get_lang('users', 'inserted'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->initializeAction('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the deletion of a user
|
* Executes the deletion of a user
|
||||||
*/
|
*/
|
||||||
protected function executeDelete() {
|
protected function executeDelete() {
|
||||||
// do delete
|
$id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
|
||||||
|
|
||||||
|
if($id > 0) {
|
||||||
$this->db->delete(
|
$this->db->delete(
|
||||||
SM_DB_PREFIX . 'users',
|
PSM_DB_PREFIX . 'users',
|
||||||
array(
|
array(
|
||||||
'user_id' => $_GET['delete']
|
'user_id' => $id,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->message = sm_get_lang('system', 'deleted');
|
$this->addMessage(psm_get_lang('system', 'deleted'));
|
||||||
|
}
|
||||||
|
$this->initializeAction('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
// override parent::createHTMLLabels()
|
// override parent::createHTMLLabels()
|
||||||
|
|
@ -225,16 +206,16 @@ class modUsers extends modCore {
|
||||||
$this->tpl->addTemplateData(
|
$this->tpl->addTemplateData(
|
||||||
$this->getTemplateId(),
|
$this->getTemplateId(),
|
||||||
array(
|
array(
|
||||||
'label_users' => sm_get_lang('system', 'users'),
|
'label_users' => psm_get_lang('system', 'users'),
|
||||||
'label_name' => sm_get_lang('users', 'name'),
|
'label_name' => psm_get_lang('users', 'name'),
|
||||||
'label_mobile' => sm_get_lang('users', 'mobile'),
|
'label_mobile' => psm_get_lang('users', 'mobile'),
|
||||||
'label_email' => sm_get_lang('users', 'email'),
|
'label_email' => psm_get_lang('users', 'email'),
|
||||||
'label_servers' => sm_get_lang('system', 'servers'),
|
'label_servers' => psm_get_lang('system', 'servers'),
|
||||||
'label_action' => sm_get_lang('system', 'action'),
|
'label_action' => psm_get_lang('system', 'action'),
|
||||||
'label_save' => sm_get_lang('system', 'save'),
|
'label_save' => psm_get_lang('system', 'save'),
|
||||||
'label_edit' => sm_get_lang('system', 'edit') . ' ' . sm_get_lang('users', 'user'),
|
'label_edit' => psm_get_lang('system', 'edit') . ' ' . psm_get_lang('users', 'user'),
|
||||||
'label_delete' => sm_get_lang('system', 'delete') . ' ' . sm_get_lang('users', 'user'),
|
'label_delete' => psm_get_lang('system', 'delete') . ' ' . psm_get_lang('users', 'user'),
|
||||||
'label_add_new' => sm_get_lang('system', 'add_new'),
|
'label_add_new' => psm_get_lang('system', 'add_new'),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -25,7 +25,9 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class smDatabase {
|
namespace psm\Service;
|
||||||
|
|
||||||
|
class Database {
|
||||||
|
|
||||||
protected $debug = array();
|
protected $debug = array();
|
||||||
protected $last_inserted_id;
|
protected $last_inserted_id;
|
||||||
|
|
@ -33,17 +35,33 @@ class smDatabase {
|
||||||
protected $num_rows_found;
|
protected $num_rows_found;
|
||||||
protected $num_rows_returned;
|
protected $num_rows_returned;
|
||||||
|
|
||||||
function __construct() {
|
function __construct($host = null, $user = null, $pass = null, $db = null) {
|
||||||
// Initizale connection
|
if($host != null && $user != null && $pass != null && $db != null) {
|
||||||
$this->link = mysql_connect(SM_DB_HOST, SM_DB_USER, SM_DB_PASS);
|
$this->connect($host, $user, $pass, $db);
|
||||||
|
} elseif(defined('PSM_DB_HOST') && defined('PSM_DB_USER') && defined('PSM_DB_PASS') && defined('PSM_DB_NAME')) {
|
||||||
if (!mysql_select_db(SM_DB_NAME, $this->link)) {
|
$this->connect(PSM_DB_HOST, PSM_DB_USER, PSM_DB_PASS, PSM_DB_NAME);
|
||||||
trigger_error(mysql_errno() . ": " . mysql_error());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting the utf collection
|
/**
|
||||||
mysql_query("SET NAMES utf8;", $this->getLink());
|
* Connect to the database
|
||||||
mysql_query("SET CHARACTER SET 'utf8';", $this->getLink());
|
* @param string $host
|
||||||
|
* @param string $user
|
||||||
|
* @param string $pass
|
||||||
|
* @param string $db
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
protected function connect($host, $user, $pass, $db) {
|
||||||
|
$this->link = mysql_connect($host, $user, $pass);
|
||||||
|
|
||||||
|
if (!mysql_select_db($db, $this->link)) {
|
||||||
|
trigger_error(mysql_errno() . ": " . mysql_error());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_query("SET NAMES utf8;", $this->link);
|
||||||
|
mysql_query("SET CHARACTER SET 'utf8';", $this->link);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -25,9 +25,9 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class smTemplate {
|
namespace psm\Service;
|
||||||
protected $css_files = array();
|
|
||||||
protected $js_files = array();
|
class Template {
|
||||||
protected $output;
|
protected $output;
|
||||||
protected $templates = array();
|
protected $templates = array();
|
||||||
|
|
||||||
|
|
@ -46,8 +46,8 @@ class smTemplate {
|
||||||
public function newTemplate($id, $filename) {
|
public function newTemplate($id, $filename) {
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
$this->templates[$id] = $this->parseFile($filename);
|
$this->templates[$id] = $this->parseFile($filename);
|
||||||
} elseif (file_exists(SM_PATH_TPL.$filename)) {
|
} elseif (file_exists(PSM_PATH_TPL.$filename)) {
|
||||||
$this->templates[$id] = $this->parseFile(SM_PATH_TPL.$filename);
|
$this->templates[$id] = $this->parseFile(PSM_PATH_TPL.$filename);
|
||||||
} else {
|
} else {
|
||||||
// file does not exist
|
// file does not exist
|
||||||
trigger_error('Template not found with id: '.$id.' and filename: '.$filename);
|
trigger_error('Template not found with id: '.$id.' and filename: '.$filename);
|
||||||
|
|
@ -159,9 +159,6 @@ class smTemplate {
|
||||||
// check for tpl variables that have not been replaced. ie: {name}. ignore literal stuff, though. ie: {{name}} is {name} and should not be removed
|
// check for tpl variables that have not been replaced. ie: {name}. ignore literal stuff, though. ie: {{name}} is {name} and should not be removed
|
||||||
preg_match_all('~{?{(.+?)}}?~', $result, $matches);
|
preg_match_all('~{?{(.+?)}}?~', $result, $matches);
|
||||||
|
|
||||||
// add css and javascript files to header
|
|
||||||
$result = $this->addHeaderFiles($id, $result);
|
|
||||||
|
|
||||||
foreach($matches[0] as $match) {
|
foreach($matches[0] as $match) {
|
||||||
if (substr($match, 0, 2) == '{{') {
|
if (substr($match, 0, 2) == '{{') {
|
||||||
// literal! remove only first and last bracket!
|
// literal! remove only first and last bracket!
|
||||||
|
|
@ -174,48 +171,6 @@ class smTemplate {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a css file to the list which will be added to the template when display() is called
|
|
||||||
*
|
|
||||||
* @param string $template_id
|
|
||||||
* @param string $filename
|
|
||||||
* @param string $path uses default set in config if non specified
|
|
||||||
*/
|
|
||||||
public function addCSS($filename, $template_id = 'main', $path = SM_PATH_CSS) {
|
|
||||||
if (!isset($this->css_files[$template_id])) {
|
|
||||||
$this->css_files[$template_id] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
// if file doesn't exist we assume it's inline
|
|
||||||
$type = (file_exists($path.$filename)) ? 'file' : 'inline';
|
|
||||||
|
|
||||||
$this->css_files[$template_id][$filename] = array(
|
|
||||||
'file' => ($type == 'file') ? $path.$filename : $filename,
|
|
||||||
'type' => $type
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a javascript file to the list which will be added to the template when display() is called
|
|
||||||
*
|
|
||||||
* @param string $template_id
|
|
||||||
* @param string $filename path to file or CSS code to be added inline
|
|
||||||
* @param string $path uses default set in config if non specified
|
|
||||||
*/
|
|
||||||
public function addJS($filename, $template_id = 'main', $path = SM_PATH_JS) {
|
|
||||||
if (!isset($this->js_files[$template_id])) {
|
|
||||||
$this->js_files[$template_id] = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
// if file doesn't exist we assume it's inline
|
|
||||||
$type = (file_exists($path.$filename)) ? 'file' : 'inline';
|
|
||||||
|
|
||||||
$this->js_files[$template_id][$filename] = array(
|
|
||||||
'file' => ($type == 'file') ? $path.$filename : $filename,
|
|
||||||
'type' => $type
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get html code for a template, or if no template id given get all templates
|
* Get html code for a template, or if no template id given get all templates
|
||||||
*
|
*
|
||||||
|
|
@ -232,62 +187,6 @@ class smTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the CSS and JavaScript files to the header html.
|
|
||||||
*
|
|
||||||
* @param string $template_id
|
|
||||||
* @param string $html
|
|
||||||
* @return string new html code
|
|
||||||
*/
|
|
||||||
protected function addHeaderFiles($template_id, $html) {
|
|
||||||
// get code between <head> tags
|
|
||||||
preg_match_all("{<head>(.*?)<\/head>}is", $html, $matches);
|
|
||||||
|
|
||||||
if (isset($matches[1][0]) && $matches[1][0] != '') {
|
|
||||||
$header = $matches[1][0];
|
|
||||||
|
|
||||||
if (isset($this->css_files[$template_id]) && !empty($this->css_files[$template_id])) {
|
|
||||||
$header .= "\t<!--CSS Files-->\n";
|
|
||||||
|
|
||||||
foreach($this->css_files[$template_id] as $filename => $info) {
|
|
||||||
switch($info['type']) {
|
|
||||||
case 'file':
|
|
||||||
$header .= "\t<link type=\"text/css\" href=\"{$info['file']}\" rel=\"stylesheet\" />\n";
|
|
||||||
break;
|
|
||||||
case 'inline':
|
|
||||||
$header .=
|
|
||||||
"\t<style type=\"text/css\">\n".
|
|
||||||
$info['file'].
|
|
||||||
"\t</style>\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($this->js_files[$template_id]) && !empty($this->js_files[$template_id])) {
|
|
||||||
$header .= "\t<!--JavaScript Files-->\n";
|
|
||||||
|
|
||||||
foreach($this->js_files[$template_id] as $filename => $info) {
|
|
||||||
switch($info['type']) {
|
|
||||||
case 'file':
|
|
||||||
$header .= "\t<script src=\"".$info['file']."\" type=\"text/javascript\" ></script>\n";
|
|
||||||
break;
|
|
||||||
case 'inline':
|
|
||||||
$header .=
|
|
||||||
"\t<script type=\"text/javascript\">\n".
|
|
||||||
$info['file'].
|
|
||||||
"\t</script>\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// add new header to html
|
|
||||||
$html = preg_replace('{'.$matches[1][0].'}is', $header, $html);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Get file content
|
* Get file content
|
||||||
|
|
@ -25,7 +25,9 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class txtmsgClickatell extends txtmsgCore {
|
namespace psm\Txtmsg;
|
||||||
|
|
||||||
|
class Clickatell extends Core {
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// [ Fields ]
|
// [ Fields ]
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
@ -59,7 +61,7 @@ class txtmsgClickatell extends txtmsgCore {
|
||||||
|
|
||||||
protected function _auth_https_post($host, $path, $data) {
|
protected function _auth_https_post($host, $path, $data) {
|
||||||
$url = $host . $path . $data;
|
$url = $host . $path . $data;
|
||||||
return sm_curl_get($url);
|
return psm_curl_get($url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,7 +25,9 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
abstract class txtmsgCore implements txtmsgInterface {
|
namespace psm\Txtmsg;
|
||||||
|
|
||||||
|
abstract class Core implements TxtmsgInterface {
|
||||||
protected $originator;
|
protected $originator;
|
||||||
protected $password;
|
protected $password;
|
||||||
protected $recipients = array();
|
protected $recipients = array();
|
||||||
|
|
@ -25,7 +25,9 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class txtmsgInetworx extends txtmsgCore {
|
namespace psm\Txtmsg;
|
||||||
|
|
||||||
|
class Inetworx extends Core {
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// [ Fields ]
|
// [ Fields ]
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
@ -25,7 +25,9 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class txtmsgMollie extends txtmsgCore {
|
namespace psm\Txtmsg;
|
||||||
|
|
||||||
|
class Mollie extends Core {
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// [ Fields ]
|
// [ Fields ]
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
@ -26,7 +26,9 @@
|
||||||
* @since phpservermon 2.1
|
* @since phpservermon 2.1
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class txtmsgMosms extends txtmsgCore {
|
namespace psm\Txtmsg;
|
||||||
|
|
||||||
|
class Mosms extends Core {
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// [ Fields ]
|
// [ Fields ]
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
@ -25,7 +25,9 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class txtmsgSpryng extends txtmsgCore {
|
namespace psm\Txtmsg;
|
||||||
|
|
||||||
|
class Spryng extends Core {
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// [ Fields ]
|
// [ Fields ]
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?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 Perri Vardy-Mason
|
||||||
|
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||||
|
* @version Release: @package_version@
|
||||||
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
|
* @since phpservermon 2.1
|
||||||
|
**/
|
||||||
|
|
||||||
|
namespace psm\Txtmsg;
|
||||||
|
|
||||||
|
class Textmarketer extends Core {
|
||||||
|
// =========================================================================
|
||||||
|
// [ Fields ]
|
||||||
|
// =========================================================================
|
||||||
|
public $gateway = 1;
|
||||||
|
public $resultcode = null;
|
||||||
|
public $resultmessage = null;
|
||||||
|
public $success = false;
|
||||||
|
public $successcount = 0;
|
||||||
|
|
||||||
|
public function sendSMS($message) {
|
||||||
|
|
||||||
|
$textmarketer_url = "https://api.textmarketer.co.uk/gateway/";
|
||||||
|
$textmarketer_data = urlencode( $message );
|
||||||
|
$textmarketer_origin = urlencode( 'SERVERALERT' );
|
||||||
|
|
||||||
|
|
||||||
|
foreach( $this->recipients as $phone ){
|
||||||
|
|
||||||
|
$URL = $textmarketer_url."?username=" . $this->username . "&password=" . $this->password . "&to=" . $phone . "&message=" . $textmarketer_data . "&orig=" . $textmarketer_origin;
|
||||||
|
|
||||||
|
$result = file_get_contents( $URL );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -25,7 +25,9 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
interface txtmsgInterface {
|
namespace psm\Txtmsg;
|
||||||
|
|
||||||
|
interface TxtmsgInterface {
|
||||||
|
|
||||||
public function setLogin($username, $password);
|
public function setLogin($username, $password);
|
||||||
public function setOriginator($originator);
|
public function setOriginator($originator);
|
||||||
|
|
@ -0,0 +1,139 @@
|
||||||
|
<?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@neanderthal-technology.com>
|
||||||
|
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||||
|
* @version Release: @package_version@
|
||||||
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
|
* @since phpservermon 2.1.0
|
||||||
|
**/
|
||||||
|
|
||||||
|
namespace psm\Util\Install;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query class provides al queries required for installing/upgrading.
|
||||||
|
*/
|
||||||
|
class Queries {
|
||||||
|
/**
|
||||||
|
* Retrieve table queries for install
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function install() {
|
||||||
|
$tables = array(
|
||||||
|
PSM_DB_PREFIX . 'users' => "CREATE TABLE `" . PSM_DB_PREFIX . "users` (
|
||||||
|
`user_id` int(11) NOT NULL auto_increment,
|
||||||
|
`server_id` varchar(255) NOT NULL,
|
||||||
|
`name` varchar(255) NOT NULL,
|
||||||
|
`mobile` varchar(15) NOT NULL,
|
||||||
|
`email` varchar(255) NOT NULL,
|
||||||
|
PRIMARY KEY (`user_id`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||||
|
PSM_DB_PREFIX . 'log' => "CREATE TABLE `" . PSM_DB_PREFIX . "log` (
|
||||||
|
`log_id` int(11) NOT NULL auto_increment,
|
||||||
|
`server_id` int(11) NOT NULL,
|
||||||
|
`type` enum('status','email','sms') NOT NULL,
|
||||||
|
`message` varchar(255) NOT NULL,
|
||||||
|
`datetime` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||||
|
`user_id` varchar(255) NOT NULL,
|
||||||
|
PRIMARY KEY (`log_id`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||||
|
PSM_DB_PREFIX . 'servers' => "CREATE TABLE `" . PSM_DB_PREFIX . "servers` (
|
||||||
|
`server_id` int(11) NOT NULL auto_increment,
|
||||||
|
`ip` varchar(100) NOT NULL,
|
||||||
|
`port` int(5) NOT NULL,
|
||||||
|
`label` varchar(255) NOT NULL,
|
||||||
|
`type` enum('service','website') NOT NULL default 'service',
|
||||||
|
`pattern` varchar(255) NOT NULL,
|
||||||
|
`status` enum('on','off') NOT NULL default 'on',
|
||||||
|
`error` varchar(255) NULL,
|
||||||
|
`rtime` FLOAT(9, 7) NULL,
|
||||||
|
`last_online` datetime NULL,
|
||||||
|
`last_check` datetime NULL,
|
||||||
|
`active` enum('yes','no') NOT NULL default 'yes',
|
||||||
|
`email` enum('yes','no') NOT NULL default 'yes',
|
||||||
|
`sms` enum('yes','no') NOT NULL default 'no',
|
||||||
|
PRIMARY KEY (`server_id`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||||
|
PSM_DB_PREFIX . 'config' => "CREATE TABLE `" . PSM_DB_PREFIX . "config` (
|
||||||
|
`key` varchar(255) NOT NULL,
|
||||||
|
`value` varchar(255) NOT NULL,
|
||||||
|
PRIMARY KEY (`key`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
|
||||||
|
);
|
||||||
|
return $tables;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get queries for upgrading
|
||||||
|
* @param string $version
|
||||||
|
* @param string $version_from
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function upgrade($version, $version_from = null) {
|
||||||
|
$queries = array();
|
||||||
|
|
||||||
|
if($version_from === null) {
|
||||||
|
$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "users` (`server_id`, `name`, `mobile`, `email`) VALUES ('1,2', 'example_user', '0123456789', 'user@example.com')";
|
||||||
|
$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "servers` (`ip`, `port`, `label`, `type`, `status`, `error`, `rtime`, `last_online`, `last_check`, `active`, `email`, `sms`) VALUES ('http://sourceforge.net/index.php', 80, 'SourceForge', 'website', 'on', '', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 'yes', 'yes', 'yes'), ('smtp.gmail.com', 465, 'Gmail SMTP', 'service', 'on', '', '', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 'yes', 'yes', 'yes')";
|
||||||
|
$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "config` (`key`, `value`) VALUE
|
||||||
|
('language', 'en'),
|
||||||
|
('email_status', '1'),
|
||||||
|
('email_from_email', 'monitor@example.org'),
|
||||||
|
('email_from_name', 'Server Monitor'),
|
||||||
|
('sms_status', '1'),
|
||||||
|
('sms_gateway', 'mollie'),
|
||||||
|
('sms_gateway_username', 'username'),
|
||||||
|
('sms_gateway_password', 'password'),
|
||||||
|
('sms_from', '1234567890'),
|
||||||
|
('alert_type', 'status'),
|
||||||
|
('log_status', '1'),
|
||||||
|
('log_email', '1'),
|
||||||
|
('log_sms', '1'),
|
||||||
|
('version', '{$version}'),
|
||||||
|
('auto_refresh_servers', '0'),
|
||||||
|
('show_update', '1'),
|
||||||
|
('last_update_check', '0'),
|
||||||
|
('cron_running', '0'),
|
||||||
|
('cron_running_time', '0');";
|
||||||
|
} else {
|
||||||
|
if(version_compare($version_from, '2.1.0', '<')) {
|
||||||
|
// 2.0 upgrade
|
||||||
|
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "config` DROP `config_id`;";
|
||||||
|
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "config` ADD PRIMARY KEY ( `key` );";
|
||||||
|
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "config` DROP INDEX `key`;";
|
||||||
|
$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "config` (`key`, `value`) VALUES ('cron_running', '0');";
|
||||||
|
$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "config` (`key`, `value`) VALUES ('cron_running_time', '0');";
|
||||||
|
|
||||||
|
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `error` `error` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL;";
|
||||||
|
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `rtime` `rtime` FLOAT( 9, 7 ) NULL;";
|
||||||
|
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `last_online` `last_online` DATETIME NULL;";
|
||||||
|
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `last_check` `last_check` DATETIME NULL;";
|
||||||
|
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `pattern` VARCHAR( 255 ) NOT NULL AFTER `type`;";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
$queries[] = "UPDATE `" . PSM_DB_PREFIX . "config` SET `value` = '{$version}' WHERE `key` = 'version';";
|
||||||
|
}
|
||||||
|
return $queries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -25,7 +25,9 @@
|
||||||
* @link http://phpservermon.neanderthal-technology.com/
|
* @link http://phpservermon.neanderthal-technology.com/
|
||||||
**/
|
**/
|
||||||
|
|
||||||
class smUpdaterStatus extends smCore {
|
namespace psm\Util\Updater;
|
||||||
|
|
||||||
|
class Status {
|
||||||
public $error;
|
public $error;
|
||||||
public $notify;
|
public $notify;
|
||||||
public $rtime = 0;
|
public $rtime = 0;
|
||||||
|
|
@ -33,6 +35,13 @@ class smUpdaterStatus extends smCore {
|
||||||
public $status_org = false;
|
public $status_org = false;
|
||||||
public $status_new = false;
|
public $status_new = false;
|
||||||
|
|
||||||
|
public $db;
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
// add database handler
|
||||||
|
$this->db = $GLOBALS['db'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a new server
|
* Set a new server
|
||||||
*
|
*
|
||||||
|
|
@ -121,10 +130,11 @@ class smUpdaterStatus extends smCore {
|
||||||
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11');
|
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11');
|
||||||
|
|
||||||
// We're only interested in the header, because that should tell us plenty!
|
// We're only interested in the header, because that should tell us plenty!
|
||||||
|
// unless we have a pattern to search for!
|
||||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||||
curl_setopt($ch, CURLOPT_NOBODY, true);
|
curl_setopt($ch, CURLOPT_NOBODY, ($this->server['pattern'] != '' ? false : true));
|
||||||
|
|
||||||
$headers = curl_exec ($ch);
|
$curl_result = curl_exec ($ch);
|
||||||
curl_close ($ch);
|
curl_close ($ch);
|
||||||
|
|
||||||
$time = explode(" ", microtime());
|
$time = explode(" ", microtime());
|
||||||
|
|
@ -132,7 +142,7 @@ class smUpdaterStatus extends smCore {
|
||||||
$this->rtime = ($endtime - $starttime);
|
$this->rtime = ($endtime - $starttime);
|
||||||
|
|
||||||
// the first line would be the status code..
|
// the first line would be the status code..
|
||||||
$status_code = strtok($headers, "\r\n");
|
$status_code = strtok($curl_result, "\r\n");
|
||||||
// keep it general
|
// keep it general
|
||||||
// $code[1][0] = status code
|
// $code[1][0] = status code
|
||||||
// $code[2][0] = name of status code
|
// $code[2][0] = name of status code
|
||||||
|
|
@ -154,6 +164,13 @@ class smUpdaterStatus extends smCore {
|
||||||
$this->status_new = 'on';
|
$this->status_new = 'on';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($this->server['pattern'] != '') {
|
||||||
|
// Check to see if the pattern was found.
|
||||||
|
if(!preg_match("/{$this->server['pattern']}/i", $curl_result)) {
|
||||||
|
$this->server['error'] = $this->error = 'Pattern not found.';
|
||||||
|
$this->status_new = 'off';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check if server is available and rerun if asked.
|
// check if server is available and rerun if asked.
|
||||||
if($this->status_new == 'off' && $run < $max_runs) {
|
if($this->status_new == 'off' && $run < $max_runs) {
|
||||||
|
|
@ -168,14 +185,14 @@ class smUpdaterStatus extends smCore {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function notify() {
|
public function notify() {
|
||||||
if(sm_get_conf('email_status') == false && sm_get_conf('sms_status') == false && sm_get_conf('log_status') == false) {
|
if(psm_get_conf('email_status') == false && psm_get_conf('sms_status') == false && psm_get_conf('log_status') == false) {
|
||||||
// seems like we have nothing to do. skip the rest
|
// seems like we have nothing to do. skip the rest
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$notify = false;
|
$notify = false;
|
||||||
|
|
||||||
// check which type of alert the user wants
|
// check which type of alert the user wants
|
||||||
switch(sm_get_conf('alert_type')) {
|
switch(psm_get_conf('alert_type')) {
|
||||||
case 'always':
|
case 'always':
|
||||||
if($this->status_new == 'off') {
|
if($this->status_new == 'off') {
|
||||||
// server is offline. we are in error state.
|
// server is offline. we are in error state.
|
||||||
|
|
@ -196,27 +213,27 @@ class smUpdaterStatus extends smCore {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// first add to log (we use the same text as the SMS message because its short..)
|
||||||
|
if(psm_get_conf('log_status')) {
|
||||||
|
psm_add_log(
|
||||||
|
$this->server['server_id'],
|
||||||
|
'status',
|
||||||
|
psm_parse_msg($this->status_new, 'sms', $this->server)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$notify) {
|
if(!$notify) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// first add to log (we use the same text as the SMS message because its short..)
|
|
||||||
if(sm_get_conf('log_status')) {
|
|
||||||
sm_add_log(
|
|
||||||
$this->server['server_id'],
|
|
||||||
'status',
|
|
||||||
sm_parse_msg($this->status_new, 'sms', $this->server)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if email is enabled for this server
|
// check if email is enabled for this server
|
||||||
if(sm_get_conf('email_status') && $this->server['email'] == 'yes') {
|
if(psm_get_conf('email_status') && $this->server['email'] == 'yes') {
|
||||||
// send email
|
// send email
|
||||||
$this->notifyByEmail();
|
$this->notifyByEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if sms is enabled for this server
|
// check if sms is enabled for this server
|
||||||
if(sm_get_conf('sms_status') && $this->server['sms'] == 'yes') {
|
if(psm_get_conf('sms_status') && $this->server['sms'] == 'yes') {
|
||||||
// yay lets wake those nerds up!
|
// yay lets wake those nerds up!
|
||||||
$this->notifyByTxtMsg();
|
$this->notifyByTxtMsg();
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +250,7 @@ class smUpdaterStatus extends smCore {
|
||||||
|
|
||||||
// find all the users with this server listed
|
// find all the users with this server listed
|
||||||
$users = $this->db->select(
|
$users = $this->db->select(
|
||||||
SM_DB_PREFIX . 'users',
|
PSM_DB_PREFIX . 'users',
|
||||||
'FIND_IN_SET(\''.$this->server['server_id'].'\', `server_id`) AND `email` != \'\'',
|
'FIND_IN_SET(\''.$this->server['server_id'].'\', `server_id`) AND `email` != \'\'',
|
||||||
array('user_id', 'name', 'email')
|
array('user_id', 'name', 'email')
|
||||||
);
|
);
|
||||||
|
|
@ -243,14 +260,14 @@ class smUpdaterStatus extends smCore {
|
||||||
}
|
}
|
||||||
|
|
||||||
// build mail object with some default values
|
// build mail object with some default values
|
||||||
$mail = new phpmailer();
|
$mail = new \phpmailer();
|
||||||
|
|
||||||
$mail->From = sm_get_conf('email_from_email');
|
$mail->From = psm_get_conf('email_from_email');
|
||||||
$mail->FromName = sm_get_conf('email_from_name');
|
$mail->FromName = psm_get_conf('email_from_name');
|
||||||
$mail->Subject = sm_parse_msg($this->status_new, 'email_subject', $this->server);
|
$mail->Subject = psm_parse_msg($this->status_new, 'email_subject', $this->server);
|
||||||
$mail->Priority = 1;
|
$mail->Priority = 1;
|
||||||
|
|
||||||
$body = sm_parse_msg($this->status_new, 'email_body', $this->server);
|
$body = psm_parse_msg($this->status_new, 'email_body', $this->server);
|
||||||
$mail->Body = $body;
|
$mail->Body = $body;
|
||||||
$mail->AltBody = str_replace('<br/>', "\n", $body);
|
$mail->AltBody = str_replace('<br/>', "\n", $body);
|
||||||
|
|
||||||
|
|
@ -263,9 +280,9 @@ class smUpdaterStatus extends smCore {
|
||||||
$mail->ClearAddresses();
|
$mail->ClearAddresses();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sm_get_conf('log_email')) {
|
if(psm_get_conf('log_email')) {
|
||||||
// save to log
|
// save to log
|
||||||
sm_add_log($this->server['server_id'], 'email', $body, implode(',', $userlist));
|
psm_add_log($this->server['server_id'], 'email', $body, implode(',', $userlist));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,7 +294,7 @@ class smUpdaterStatus extends smCore {
|
||||||
protected function notifyByTxtMsg() {
|
protected function notifyByTxtMsg() {
|
||||||
// send sms to all users for this server using defined gateway
|
// send sms to all users for this server using defined gateway
|
||||||
$users = $this->db->select(
|
$users = $this->db->select(
|
||||||
SM_DB_PREFIX . 'users',
|
PSM_DB_PREFIX . 'users',
|
||||||
'FIND_IN_SET(\''.$this->server['server_id'].'\', `server_id`) AND `mobile` != \'\'',
|
'FIND_IN_SET(\''.$this->server['server_id'].'\', `server_id`) AND `mobile` != \'\'',
|
||||||
array('user_id', 'name', 'mobile')
|
array('user_id', 'name', 'mobile')
|
||||||
);
|
);
|
||||||
|
|
@ -291,28 +308,31 @@ class smUpdaterStatus extends smCore {
|
||||||
|
|
||||||
// open the right class
|
// open the right class
|
||||||
// not making this any more dynamic, because perhaps some gateways need custom settings (like Mollie)
|
// not making this any more dynamic, because perhaps some gateways need custom settings (like Mollie)
|
||||||
switch(strtolower(sm_get_conf('sms_gateway'))) {
|
switch(strtolower(psm_get_conf('sms_gateway'))) {
|
||||||
case 'mosms':
|
case 'mosms':
|
||||||
$sms = new txtmsgMosms();
|
$sms = new \psm\Txtmsg\Mosms();
|
||||||
break;
|
break;
|
||||||
case 'inetworx':
|
case 'inetworx':
|
||||||
$sms = new txtmsgInetworx();
|
$sms = new \psm\Txtmsg\Inetworx();
|
||||||
break;
|
break;
|
||||||
case 'mollie':
|
case 'mollie':
|
||||||
$sms = new txtmsgMollie();
|
$sms = new \psm\Txtmsg\Mollie();
|
||||||
$sms->setGateway(1);
|
$sms->setGateway(1);
|
||||||
break;
|
break;
|
||||||
case 'spryng':
|
case 'spryng':
|
||||||
$sms = new txtmsgSpryng();
|
$sms = new \psm\Txtmsg\Spryng();
|
||||||
break;
|
break;
|
||||||
case 'clickatell':
|
case 'clickatell':
|
||||||
$sms = new txtmsgClickatell();
|
$sms = new \psm\Txtmsg\Clickatell();
|
||||||
|
break;
|
||||||
|
case 'textmarketer':
|
||||||
|
$sms = new \psm\Txtmsg\Textmarketer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy login information from the config file
|
// copy login information from the config file
|
||||||
$sms->setLogin(sm_get_conf('sms_gateway_username'), sm_get_conf('sms_gateway_password'));
|
$sms->setLogin(psm_get_conf('sms_gateway_username'), psm_get_conf('sms_gateway_password'));
|
||||||
$sms->setOriginator(sm_get_conf('sms_from'));
|
$sms->setOriginator(psm_get_conf('sms_from'));
|
||||||
|
|
||||||
// add all users to the recipients list
|
// add all users to the recipients list
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
|
|
@ -320,14 +340,14 @@ class smUpdaterStatus extends smCore {
|
||||||
$sms->addRecipients($user['mobile']);
|
$sms->addRecipients($user['mobile']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = sm_parse_msg($this->status_new, 'sms', $this->server);
|
$message = psm_parse_msg($this->status_new, 'sms', $this->server);
|
||||||
|
|
||||||
// Send sms
|
// Send sms
|
||||||
$result = $sms->sendSMS($message);
|
$result = $sms->sendSMS($message);
|
||||||
|
|
||||||
if(sm_get_conf('log_sms')) {
|
if(psm_get_conf('log_sms')) {
|
||||||
// save to log
|
// save to log
|
||||||
sm_add_log($this->server['server_id'], 'sms', $message, implode(',', $userlist));
|
psm_add_log($this->server['server_id'], 'sms', $message, implode(',', $userlist));
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<!--%tpl_config-->
|
<!--%tpl_config-->
|
||||||
{config_update}
|
{config_update}
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<form class="form-horizontal well" action="index.php?type=config" id="edit_config" method="post">
|
<form class="form-horizontal well" action="index.php?type=config&action=save" id="edit_config" method="post">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{label_general}</legend>
|
<legend>{label_general}</legend>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
|
@ -62,6 +62,7 @@
|
||||||
<option value="spryng" {sms_selected_spryng}>{label_sms_gateway_spryng}</option>
|
<option value="spryng" {sms_selected_spryng}>{label_sms_gateway_spryng}</option>
|
||||||
<option value="inetworx" {sms_selected_inetworx}>{label_sms_gateway_inetworx}</option>
|
<option value="inetworx" {sms_selected_inetworx}>{label_sms_gateway_inetworx}</option>
|
||||||
<option value="clickatell" {sms_selected_clickatell}>{label_sms_gateway_clickatell}</option>
|
<option value="clickatell" {sms_selected_clickatell}>{label_sms_gateway_clickatell}</option>
|
||||||
|
<option value="textmarketer" {sms_selected_textmarketer}>{label_sms_gateway_textmarketer}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -117,9 +118,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="hidden" name="server_id" value="{edit_server_id}" />
|
|
||||||
<button class="btn btn-success" type="submit">Save</button>
|
<button class="btn btn-success" type="submit">Save</button>
|
||||||
<button class="btn" onclick="history.back();" >Cancel</button>
|
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
<!--%tpl_install-->
|
||||||
|
<div class="hero-unit">
|
||||||
|
<h1><img class="pull-right" src="static/opensource.png" width="100" alt="" /> PHP Server Monitor</h1>
|
||||||
|
<p> </p>
|
||||||
|
<p>
|
||||||
|
<a class="btn btn-primary btn-large" target="_blank" href="http://phpservermon.neanderthal-technology.com">PHP Server Monitor</a>
|
||||||
|
<a class="btn btn-large" target="_blank" href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>
|
||||||
|
</p>
|
||||||
|
<p>PHP Server Monitor is a script that checks whether the servers on your list are up and running on the selected ports. It comes with a web based user interface where you can add and remove servers or websites from the MySQL database, and you can manage users for each server with a mobile number and email address.</p>
|
||||||
|
<p>To install PHP Server Monitor, please follow the instructions below.</p>
|
||||||
|
</div>
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span12">{html_results}</div>
|
||||||
|
</div>
|
||||||
|
{html_install}
|
||||||
|
<!--%%tpl_install-->
|
||||||
|
|
||||||
|
<!--%tpl_install_config_new-->
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span6">
|
||||||
|
<form id="psm_config" class="form-horizontal" action="install.php" method="post">
|
||||||
|
<!--<input type="hidden" name="action" value="config" />-->
|
||||||
|
<h3>Please enter your database info:</h3>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="host">Database host</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="host" name="host" value="{host}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="name">Database name</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="name" name="name" value="{name}" placeholder="db name" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="user">Database user</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="user" name="user" value="{user}" placeholder="db user" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="pass">Database password</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="password" id="pass" name="pass" value="{pass}" placeholder="db password" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="prefix">Table prefix</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" id="prefix" name="prefix" value="{prefix}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<button type="submit" class="btn">Save configuration</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{html_config_copy}
|
||||||
|
</div>
|
||||||
|
<!--%%tpl_install_config_new-->
|
||||||
|
|
||||||
|
<!--%tpl_install_config_new_copy-->
|
||||||
|
<div class="span6">
|
||||||
|
<h3>Your config file:</h3>
|
||||||
|
<div class="alert alert-error">Unable to save your configuration.</div>
|
||||||
|
<p>Please create a new file in the project directory called "config.php" and copy the information below.</p>
|
||||||
|
<p>After you have copied the configuration, press the button to continue.</p>
|
||||||
|
<p class="pull-left"><textarea rows="10">{php_config}</textarea></p>
|
||||||
|
<p class="offset2"><input type="submit" class="btn btn-primary" value="I have saved the configuration" onclick="location.reload(true);" /></p>
|
||||||
|
</div>
|
||||||
|
<!--%%tpl_install_config_new_copy-->
|
||||||
|
|
||||||
|
<!--%tpl_install_success-->
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span12">
|
||||||
|
The installation is complete. Please check above if errors have occured.<br/>
|
||||||
|
If no errors have occurred, you are good to go.<br><br>
|
||||||
|
<a class="btn btn-primary" href="index.php">Click here to go to the monitor</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--%%tpl_install_success-->
|
||||||
|
|
||||||
|
<!--%tpl_install_results-->
|
||||||
|
<!--%tpl_repeat_resultmsgs-->
|
||||||
|
<div>
|
||||||
|
<p class="pull-left"><span class="label label-{shortcode}">{status}</span></p>
|
||||||
|
<p class="offset1">{message}</p>
|
||||||
|
</div>
|
||||||
|
<!--%%tpl_repeat_resultmsgs-->
|
||||||
|
{resultmsgs}
|
||||||
|
<!--%%tpl_install_results-->
|
||||||
|
|
@ -19,6 +19,11 @@
|
||||||
<script type="text/javascript" src="static/plugin/jquery-1.7.1.min.js"></script>
|
<script type="text/javascript" src="static/plugin/jquery-1.7.1.min.js"></script>
|
||||||
<script type="text/javascript" src="static/plugin/twitter-bootstrap/js/bootstrap.min.js"></script>
|
<script type="text/javascript" src="static/plugin/twitter-bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script type="text/javascript" src="static/js/scripts.js"></script>
|
<script type="text/javascript" src="static/js/scripts.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).bind('ready', function(){
|
||||||
|
psm_flash_message();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body data-spy="scroll" data-target=".subnav" data-offset="50">
|
<body data-spy="scroll" data-target=".subnav" data-offset="50">
|
||||||
<!-- navbar -->
|
<!-- navbar -->
|
||||||
|
|
@ -31,31 +36,7 @@
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</a>
|
</a>
|
||||||
<a class="brand" href="index.php">{title}</a>
|
<a class="brand" href="index.php">{title}</a>
|
||||||
<div class="nav-collapse">
|
{html_menu}
|
||||||
<ul class="nav">
|
|
||||||
<li id="nav_option_servers" class="{active_servers}">
|
|
||||||
<a href="index.php?type=servers">{label_servers}</a>
|
|
||||||
</li>
|
|
||||||
<li id="nav_option_users" class="{active_users}">
|
|
||||||
<a href="index.php?type=users">{label_users}</a>
|
|
||||||
</li>
|
|
||||||
<li id="nav_option_log" class="{active_log}">
|
|
||||||
<a href="index.php?type=log">{label_log}</a>
|
|
||||||
</li>
|
|
||||||
<li id="nav_option_config" class="{active_config}">
|
|
||||||
<a href="index.php?type=config">{label_config}</a>
|
|
||||||
</li>
|
|
||||||
<li id="nav_option_status" class="{active_status}">
|
|
||||||
<a href="index.php?type=status">{label_status}Status</a>
|
|
||||||
</li>
|
|
||||||
<li id="nav_option_update">
|
|
||||||
<a href="index.php?action=check">{label_update}</a>
|
|
||||||
</li>
|
|
||||||
<li id="nav_option_help">
|
|
||||||
<a href="http://phpservermon.sourceforge.net" target="_blank">{label_help}</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -70,33 +51,48 @@
|
||||||
<small> </small>
|
<small> </small>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row-fluid">
|
||||||
{content}
|
<div class="span12">
|
||||||
|
<div id="flashmessage" class="alert alert-info hide">{message}</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row-fluid">{content}</div>
|
||||||
|
|
||||||
{update_available}
|
|
||||||
{html_footer}
|
{html_footer}
|
||||||
</div>
|
</div>
|
||||||
<!-- /container -->
|
<!-- /container -->
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).bind('ready', function(){
|
|
||||||
var flashmessage = $('#flashmessage');
|
|
||||||
if(flashmessage.length){
|
|
||||||
var t = flashmessage.html();
|
|
||||||
var c = trim(t);
|
|
||||||
var t = c.replace(' ', '');
|
|
||||||
if(t){
|
|
||||||
flashmessage.slideDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<!--%%tpl_main-->
|
<!--%%tpl_main-->
|
||||||
|
|
||||||
|
<!--%tpl_main_menu-->
|
||||||
|
<div class="nav-collapse">
|
||||||
|
<ul class="nav">
|
||||||
|
<li id="nav_option_servers" class="{active_servers}">
|
||||||
|
<a href="index.php?type=servers">{label_servers}</a>
|
||||||
|
</li>
|
||||||
|
<li id="nav_option_users" class="{active_users}">
|
||||||
|
<a href="index.php?type=users">{label_users}</a>
|
||||||
|
</li>
|
||||||
|
<li id="nav_option_log" class="{active_log}">
|
||||||
|
<a href="index.php?type=log">{label_log}</a>
|
||||||
|
</li>
|
||||||
|
<li id="nav_option_status" class="{active_status}">
|
||||||
|
<a href="index.php?type=status">{label_status}</a>
|
||||||
|
</li>
|
||||||
|
<li id="nav_option_config" class="{active_config}">
|
||||||
|
<a href="index.php?type=config">{label_config}</a>
|
||||||
|
</li>
|
||||||
|
<li id="nav_option_update">
|
||||||
|
<a href="index.php?action=check">{label_update}</a>
|
||||||
|
</li>
|
||||||
|
<li id="nav_option_help">
|
||||||
|
<a href="http://phpservermon.sourceforge.net" target="_blank">{label_help}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<!--%%tpl_main_menu-->
|
||||||
|
|
||||||
<!--%tpl_main_auto_refresh-->
|
<!--%tpl_main_auto_refresh-->
|
||||||
<meta http-equiv="refresh" content="{seconds}" />
|
<meta http-equiv="refresh" content="{seconds}" />
|
||||||
<!--%%tpl_main_auto_refresh-->
|
<!--%%tpl_main_auto_refresh-->
|
||||||
|
|
@ -105,7 +101,7 @@
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<p class="pull-right"><a href="#">{label_back_to_top}</a></p>
|
<p class="pull-right"><a href="#">{label_back_to_top}</a></p>
|
||||||
<p>
|
<p>
|
||||||
Powered by <a href="http://phpservermon.sourceforge.net" target="_blank">PHP Server Monitor</a> and
|
Powered by <a href="http://phpservermon.neanderthal-technology.com" target="_blank">PHP Server Monitor</a> and
|
||||||
<a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>
|
<a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>
|
||||||
<br/>
|
<br/>
|
||||||
Copyright © 2008-2014 <a href="mailto:pep@neanderthal-technology.com">Pepijn Over</a>
|
Copyright © 2008-2014 <a href="mailto:pep@neanderthal-technology.com">Pepijn Over</a>
|
||||||
|
|
@ -1,12 +1,7 @@
|
||||||
<!--%tpl_servers_list-->
|
<!--%tpl_servers_list-->
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
|
|
||||||
<div id="flashmessage" class="alert alert-info hide">
|
|
||||||
{message}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="top_buutons">
|
<div class="top_buutons">
|
||||||
<a class="btn btn-success" href="index.php?type=servers&edit=0">
|
<a class="btn btn-success" href="index.php?type=servers&action=edit">
|
||||||
<i class="icon-plus icon-white"></i>
|
<i class="icon-plus icon-white"></i>
|
||||||
{label_add_new}
|
{label_add_new}
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -48,7 +43,7 @@
|
||||||
<td>{email}</td>
|
<td>{email}</td>
|
||||||
<td>{sms}</td>
|
<td>{sms}</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="btn btn-small" href="index.php?type=servers&edit={server_id}" title="{label_edit}">
|
<a class="btn btn-small" href="index.php?type=servers&action=edit&id={server_id}" title="{label_edit}">
|
||||||
<i class="icon-pencil"></i>
|
<i class="icon-pencil"></i>
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-small btn-danger" href="javascript:sm_delete('{server_id}', 'servers');" title="{label_delete}">
|
<a class="btn btn-small btn-danger" href="javascript:sm_delete('{server_id}', 'servers');" title="{label_delete}">
|
||||||
|
|
@ -66,7 +61,7 @@
|
||||||
|
|
||||||
<!--%tpl_servers_update-->
|
<!--%tpl_servers_update-->
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<form class="form-horizontal well" action="index.php?type=servers" id="edit_server" method="post">
|
<form class="form-horizontal well" action="index.php?type=servers&action=save&id={edit_server_id}" method="post">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{titlemode}</legend>
|
<legend>{titlemode}</legend>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
|
@ -96,6 +91,12 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="pattern">{label_pattern}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" name="pattern" value="{edit_value_pattern}" maxlength="255" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="active">{label_monitoring}</label>
|
<label class="control-label" for="active">{label_monitoring}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
|
@ -124,9 +125,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="hidden" name="server_id" value="{edit_server_id}" />
|
|
||||||
<button class="btn btn-success" type="submit">Save</button>
|
<button class="btn btn-success" type="submit">Save</button>
|
||||||
<button class="btn" onclick="history.back();" >Cancel</button>
|
<button class="btn" onclick="history.back();return false;" >Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -52,8 +52,8 @@
|
||||||
<!--%tpl_repeat_servers_offline-->
|
<!--%tpl_repeat_servers_offline-->
|
||||||
<div class="entity">
|
<div class="entity">
|
||||||
<h2>{label}</h2>
|
<h2>{label}</h2>
|
||||||
<p>Last online: {last_online_nice}</p>
|
<p>{label_last_online}: {last_online_nice}</p>
|
||||||
<p>Last checked: {last_checked_nice}</p>
|
<p>{label_last_check}: {last_checked_nice}</p>
|
||||||
</div>
|
</div>
|
||||||
<!--%%tpl_repeat_servers_offline-->
|
<!--%%tpl_repeat_servers_offline-->
|
||||||
{servers_offline}
|
{servers_offline}
|
||||||
|
|
@ -62,8 +62,8 @@
|
||||||
<!--%tpl_repeat_servers_online-->
|
<!--%tpl_repeat_servers_online-->
|
||||||
<div class="entity">
|
<div class="entity">
|
||||||
<h2>{label}</h2>
|
<h2>{label}</h2>
|
||||||
<p>Last checked: {last_checked_nice}</p>
|
<p>{label_last_online}: {last_checked_nice}</p>
|
||||||
<p>Latency: {rtime}s</p>
|
<p>{label_rtime}: {rtime}s</p>
|
||||||
</div>
|
</div>
|
||||||
<!--%%tpl_repeat_servers_online-->
|
<!--%%tpl_repeat_servers_online-->
|
||||||
{servers_online}
|
{servers_online}
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
<!--%tpl_users_list-->
|
<!--%tpl_users_list-->
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<div id="flashmessage" class="alert alert-info hide">
|
|
||||||
{message}
|
|
||||||
</div>
|
|
||||||
<div class="top_buutons">
|
<div class="top_buutons">
|
||||||
<a class="btn btn-success" href="index.php?type=users&edit=0">
|
<a class="btn btn-success" href="index.php?type=users&action=edit">
|
||||||
<i class="icon-plus icon-white"></i>
|
<i class="icon-plus icon-white"></i>
|
||||||
{label_add_new}
|
{label_add_new}
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -27,7 +24,7 @@
|
||||||
<td>{email}</td>
|
<td>{email}</td>
|
||||||
<td>{emp_servers}</td>
|
<td>{emp_servers}</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="btn btn-small" href="index.php?type=users&edit={user_id}" title="{label_edit}">
|
<a class="btn btn-small" href="index.php?type=users&action=edit&id={user_id}" title="{label_edit}">
|
||||||
<i class="icon-pencil"></i>
|
<i class="icon-pencil"></i>
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-small btn-danger" href="javascript:sm_delete('{user_id}', 'users');" title="{label_delete}">
|
<a class="btn btn-small btn-danger" href="javascript:sm_delete('{user_id}', 'users');" title="{label_delete}">
|
||||||
|
|
@ -44,7 +41,7 @@
|
||||||
|
|
||||||
<!--%tpl_users_update-->
|
<!--%tpl_users_update-->
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<form class="form-horizontal well" action="index.php?type=users" id="edit_server" method="post">
|
<form class="form-horizontal well" action="index.php?type=users&action=save&id={edit_user_id}" method="post">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{titlemode}</legend>
|
<legend>{titlemode}</legend>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
|
@ -81,9 +78,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="hidden" name="user_id" value="{edit_user_id}" />
|
|
||||||
<button class="btn btn-success" type="submit">Save</button>
|
<button class="btn btn-success" type="submit">Save</button>
|
||||||
<button class="btn" onclick="history.back();" >Cancel</button>
|
<button class="btn" onclick="history.back();return false;" >Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
function sm_delete(id, type) {
|
function sm_delete(id, type) {
|
||||||
var del = confirm("Are you sure you want to delete this record?");
|
var del = confirm("Are you sure you want to delete this record?");
|
||||||
if (del == true) {
|
if (del == true) {
|
||||||
var loc = 'index.php?delete=' + id + '&type=' + type;
|
var loc = 'index.php?action=delete&id=' + id + '&type=' + type;
|
||||||
window.location = loc;
|
window.location = loc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,3 +19,18 @@ function ltrim(str) {
|
||||||
function rtrim(str) {
|
function rtrim(str) {
|
||||||
return str.replace(/\s+$/,"");
|
return str.replace(/\s+$/,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function psm_flash_message(message) {
|
||||||
|
var flashmessage = $('#flashmessage');
|
||||||
|
if(flashmessage.length){
|
||||||
|
if(typeof message != 'undefined') {
|
||||||
|
flashmessage.html(message);
|
||||||
|
}
|
||||||
|
var t = flashmessage.html();
|
||||||
|
var c = trim(t);
|
||||||
|
var t = c.replace(' ', '');
|
||||||
|
if(t){
|
||||||
|
flashmessage.slideDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
<!--%tpl_install-->
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>PHP Server Monitor</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<meta name="description" content="">
|
|
||||||
<meta name="author" content="">
|
|
||||||
<!-- Le styles -->
|
|
||||||
<link href="static/plugin/twitter-bootstrap/css/bootstrap.css" rel="stylesheet">
|
|
||||||
<link href="static/plugin/twitter-bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
|
|
||||||
<link href="static/css/style.css" rel="stylesheet">
|
|
||||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body class="install">
|
|
||||||
<div class="container">
|
|
||||||
|
|
||||||
<div class="hero-unit">
|
|
||||||
<h1>PHP Server Monitor</h1>
|
|
||||||
<p>
|
|
||||||
<a class="btn btn-large" target="_blank" href="http://phpservermon.sourceforge.net">PHP Server Monitor</a>
|
|
||||||
<a class="btn btn-large" target="_blank" href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="span12">
|
|
||||||
<!--%tpl_repeat_tables-->
|
|
||||||
<div class="alert alert-success">
|
|
||||||
<b>Creating table {name}...</b><br/><br/>
|
|
||||||
{result}
|
|
||||||
</div>
|
|
||||||
<!--%%tpl_repeat_tables-->
|
|
||||||
{tables}
|
|
||||||
|
|
||||||
<div class="alert alert-info">
|
|
||||||
The installation is complete. Please check above if errors have occured.<br/>
|
|
||||||
If no errors have occured, you can remove this file.<br><br>
|
|
||||||
<a class="btn btn-primary" href="index.php">Click here to go to your index</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
<!--%%tpl_install-->
|
|
||||||
Loading…
Reference in New Issue