Merge pull request #4 from phpservermon/develop

Pull from upstream
pull/19/head
Perri Vardy-Mason 2014-02-24 13:18:12 +00:00
commit c1797b93ec
41 changed files with 4787 additions and 1990 deletions

View File

@ -1,6 +1,18 @@
######################### #########################
# #
# Version 2.1 # Version 2.x
# ?, 2014
#
#########################
- Switched from mysql_* to PDO.
- Added SMTP support.
- Updated PHPMailer package to v5.2.6.
- When checking a website, the updater will now follow 302 Location headers.
#########################
#
# Version 2.1.0
# February 8, 2014
# #
######################### #########################
- 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).

12
CREDITS Executable file
View File

@ -0,0 +1,12 @@
Credits
=======
* Bugfixes & features - Perri Vardy-Mason
* PHP Mailer - Brent R. Matzelle
* German translation - Brunbaur Herbert
* French translation - David Ribeiro
* Korean translation - Ik-Jun
* Brazilian translation - Luiz Alberto S. Ribeiro
* Bootstrap implementation - Luiz Alberto S. Ribeiro
* Mosms implementation - Andreas Ek
* Status page - Michael Greenhill

View File

@ -2,12 +2,11 @@
## SUMMARY ## SUMMARY
PHP Server Monitor is a script that checks whether the servers on your list are up and running on the selected ports. PHP Server Monitor is a script that checks whether your websites and servers are up and running.
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 and 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 there's the support for websites as well. On the "Add server" page, you can choose There are two different ways to monitor a server:
whether it is a "service" or a "website":
* Service * Service
@ -17,10 +16,10 @@ whether it is a "service" or a "website":
* Website * Website
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, it will then use cURL to open the website and check the HTTP status code.
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 occurred and the website is not accessible 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.
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. You can also set a regular expression to match for 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. 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.
@ -46,15 +45,15 @@ 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://www.phpservermonitor.org/>.
You can also clone the git repo at <http://github.com/phpservermon/phpservermon> if you want to contribute. You can also clone the git repo at <http://github.com/phpservermon/phpservermon> if you want to contribute.
## REQUIREMENTS ## REQUIREMENTS
* PHP 5.3+ * PHP 5.3+
* PHP packages: cURL, MySQL * PHP cURL package
* MySQL Database * PHP PDO mysql driver
## INSTALL ## INSTALL
@ -171,15 +170,7 @@ The second part is the actual message. There are a few variables you can use in
## CREDITS ## CREDITS
* Bugfixes & features - Perri Vardy-Mason See CREDITS file.
* PHP Mailer - Brent R. Matzelle
* German translation - Brunbaur Herbert
* French translation - David Ribeiro
* Korean translation - Ik-Jun
* Brazilian translation - Luiz Alberto S. Ribeiro
* Bootstrap implementation - Luiz Alberto S. Ribeiro
* Mosms implementation - Andreas Ek
* Status page - Michael Greenhill
## License ## License

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
// include main configuration and functionality // include main configuration and functionality

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
require 'src/bootstrap.php'; require 'src/bootstrap.php';

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
define('PSM_INSTALL', true); define('PSM_INSTALL', true);

View File

@ -1,4 +1,30 @@
<?php <?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: phpservermon 2.1.0
* @link http://www.phpservermonitor.org/
* @since phpservermon 2.1.0
**/
define('PSM_VERSION', '2.1.0'); define('PSM_VERSION', '2.1.0');
// Include paths // Include paths
@ -54,7 +80,7 @@ foreach($includes as $file) {
// init db connection // init db connection
$db = new psm\Service\Database(); $db = new psm\Service\Database();
if($db->getLink() !== null) { if($db->status()) {
psm_load_conf(); psm_load_conf();
} else { } else {

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
############################################### ###############################################
@ -197,15 +197,25 @@ function psm_parse_msg($status, $type, $vars) {
* Shortcut to curl_init(), curl_exec and curl_close() * Shortcut to curl_init(), curl_exec and curl_close()
* *
* @param string $href * @param string $href
* @param boolean $header return headers?
* @param boolean $body return body?
* @param int $timeout connection timeout in seconds
* @param boolean $add_agent add user agent?
* @return string cURL result * @return string cURL result
*/ */
function psm_curl_get($href) { function psm_curl_get($href, $header = false, $body = true, $timeout = 10, $add_agent = true) {
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_NOBODY, (!$body));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt ($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_URL, $href); curl_setopt($ch, CURLOPT_URL, $href);
if($add_agent) {
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');
}
$result = curl_exec($ch); $result = curl_exec($ch);
curl_close($ch); curl_close($ch);
@ -259,7 +269,7 @@ function psm_check_updates() {
// 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(PSM_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 = psm_curl_get('http://phpservermon.neanderthal-technology.com/version.php'); $latest = psm_curl_get('http://www.phpservermonitor.org/version.php');
$current = psm_get_conf('version'); $current = psm_get_conf('version');
return version_compare($latest, $current, '>'); return version_compare($latest, $current, '>');
@ -267,6 +277,46 @@ function psm_check_updates() {
return false; return false;
} }
/**
* Prepare a new Mailer util.
*
* If the from name and email are left blank they will be prefilled from the config.
* @param string $from_name
* @param string $from_email
* @return \psm\Util\Mailer
*/
function psm_build_mail($from_name = null, $from_email = null) {
$phpmailer = new \psm\Util\Mailer();
$phpmailer->Encoding = "base64";
$phpmailer->SMTPDebug = false;
if(psm_get_conf('email_smtp') == '1') {
$phpmailer->IsSMTP();
$phpmailer->Host = psm_get_conf('email_smtp_host');
$phpmailer->Port = psm_get_conf('email_smtp_port');
$smtp_user = psm_get_conf('email_smtp_username');
$smtp_pass = psm_get_conf('email_smtp_password');
if($smtp_user != '' && $smtp_pass != '') {
$phpmailer->SMTPAuth = true;
$phpmailer->Username = $smtp_user;
$phpmailer->Password = $smtp_pass;
}
} else {
$phpmailer->IsMail();
}
if($from_name == null) {
$from_name = psm_get_conf('email_from_name');
}
if($from_email == null) {
$from_email = psm_get_conf('email_from_email');
}
$phpmailer->SetFrom($from_email, $from_name);
return $phpmailer;
}
############################################### ###############################################
# #
# Debug functions # Debug functions

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
$sm_lang = array( $sm_lang = array(
@ -95,6 +95,12 @@ $sm_lang = array(
'email_status' => 'Habilitar envio de email?', 'email_status' => 'Habilitar envio de email?',
'email_from_email' => 'Endereço do envio de email', 'email_from_email' => 'Endereço do envio de email',
'email_from_name' => 'Nome do envio de email', 'email_from_name' => 'Nome do envio de email',
'email_smtp' => 'Enable SMTP',
'email_smtp_host' => 'SMTP host',
'email_smtp_port' => 'SMTP port',
'email_smtp_username' => 'SMTP username',
'email_smtp_password' => 'SMTP password',
'email_smtp_noauth' => 'Leave blank for no authentication',
'sms_status' => 'Habilitar o envio de mensagem de texto?', 'sms_status' => 'Habilitar o envio de mensagem de texto?',
'sms_gateway' => 'Gateway para o uso de envio de mensagens', 'sms_gateway' => 'Gateway para o uso de envio de mensagens',
'sms_gateway_mosms' => 'Mosms', 'sms_gateway_mosms' => 'Mosms',

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
$sm_lang = array( $sm_lang = array(
@ -95,6 +95,12 @@ $sm_lang = array(
'email_status' => 'Email senden erlauben?', 'email_status' => 'Email senden erlauben?',
'email_from_email' => 'Email from address', 'email_from_email' => 'Email from address',
'email_from_name' => 'Email from name', 'email_from_name' => 'Email from name',
'email_smtp' => 'Enable SMTP',
'email_smtp_host' => 'SMTP host',
'email_smtp_port' => 'SMTP port',
'email_smtp_username' => 'SMTP username',
'email_smtp_password' => 'SMTP password',
'email_smtp_noauth' => 'Leave blank for no authentication',
'sms_status' => 'SMS Nachricht senden erlauben?', 'sms_status' => 'SMS Nachricht senden erlauben?',
'sms_gateway' => 'SMS Gateway', 'sms_gateway' => 'SMS Gateway',
'sms_gateway_mosms' => 'Mosms', 'sms_gateway_mosms' => 'Mosms',

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
$sm_lang = array( $sm_lang = array(
@ -95,6 +95,12 @@ $sm_lang = array(
'email_status' => 'Allow sending email?', 'email_status' => 'Allow sending email?',
'email_from_email' => 'Email from address', 'email_from_email' => 'Email from address',
'email_from_name' => 'Email from name', 'email_from_name' => 'Email from name',
'email_smtp' => 'Enable SMTP',
'email_smtp_host' => 'SMTP host',
'email_smtp_port' => 'SMTP port',
'email_smtp_username' => 'SMTP username',
'email_smtp_password' => 'SMTP password',
'email_smtp_noauth' => 'Leave blank for no authentication',
'sms_status' => 'Allow sending text messages?', 'sms_status' => 'Allow sending text messages?',
'sms_gateway' => 'Gateway to use for sending messages', 'sms_gateway' => 'Gateway to use for sending messages',
'sms_gateway_mosms' => 'Mosms', 'sms_gateway_mosms' => 'Mosms',

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
$sm_lang = array( $sm_lang = array(
@ -95,6 +95,12 @@ $sm_lang = array(
'email_status' => 'Autoriser l envoi de mail?', 'email_status' => 'Autoriser l envoi de mail?',
'email_from_email' => 'Exp&eacute;diteur', 'email_from_email' => 'Exp&eacute;diteur',
'email_from_name' => 'Nom de l exp&eacute;diteur', 'email_from_name' => 'Nom de l exp&eacute;diteur',
'email_smtp' => 'Enable SMTP',
'email_smtp_host' => 'SMTP host',
'email_smtp_port' => 'SMTP port',
'email_smtp_username' => 'SMTP username',
'email_smtp_password' => 'SMTP password',
'email_smtp_noauth' => 'Leave blank for no authentication',
'sms_status' => 'Autoriser l envoi de SMS?', 'sms_status' => 'Autoriser l envoi de SMS?',
'sms_gateway' => 'Passerelle &agrave; utiliser pour l envoi de SMS', 'sms_gateway' => 'Passerelle &agrave; utiliser pour l envoi de SMS',
'sms_gateway_mosms' => 'Mosms', 'sms_gateway_mosms' => 'Mosms',

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
* @since phpservermon 2.1 * @since phpservermon 2.1
**/ **/
@ -96,6 +96,12 @@ $sm_lang = array(
'email_status' => '메일전송 허용', 'email_status' => '메일전송 허용',
'email_from_email' => 'Email 주소', 'email_from_email' => 'Email 주소',
'email_from_name' => 'Email 사용자', 'email_from_name' => 'Email 사용자',
'email_smtp' => 'Enable SMTP',
'email_smtp_host' => 'SMTP host',
'email_smtp_port' => 'SMTP port',
'email_smtp_username' => 'SMTP username',
'email_smtp_password' => 'SMTP password',
'email_smtp_noauth' => 'Leave blank for no authentication',
'sms_status' => 'SMS전송 허용', 'sms_status' => 'SMS전송 허용',
'sms_gateway' => '메세지 전송을 위한 게이트웨이 허용', 'sms_gateway' => '메세지 전송을 위한 게이트웨이 허용',
'sms_gateway_mosms' => 'Mosms', 'sms_gateway_mosms' => 'Mosms',

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
$sm_lang = array( $sm_lang = array(
@ -95,6 +95,12 @@ $sm_lang = array(
'email_status' => 'Sta email berichten toe?', 'email_status' => 'Sta email berichten toe?',
'email_from_email' => 'Email van adres', 'email_from_email' => 'Email van adres',
'email_from_name' => 'Email van naam', 'email_from_name' => 'Email van naam',
'email_smtp' => 'SMTP gebruiken',
'email_smtp_host' => 'SMTP host',
'email_smtp_port' => 'SMTP poort',
'email_smtp_username' => 'SMTP gebruikersnaam',
'email_smtp_password' => 'SMTP wachtwoord',
'email_smtp_noauth' => 'Laat leeg voor geen authenticatie',
'sms_status' => 'Sta SMS berichten toe?', 'sms_status' => 'Sta SMS berichten toe?',
'sms_gateway' => 'Gateway voor het sturen van SMS', 'sms_gateway' => 'Gateway voor het sturen van SMS',
'sms_gateway_mosms' => 'Mosms', 'sms_gateway_mosms' => 'Mosms',

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Module; namespace psm\Module;

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Module; namespace psm\Module;
@ -31,6 +31,36 @@ use psm\Service\Template;
class Config extends AbstractModule { class Config extends AbstractModule {
/**
* Checkboxes
* @var array $checkboxes
*/
protected $checkboxes = array(
'email_status',
'email_smtp',
'sms_status',
'log_status',
'log_email',
'log_sms',
'show_update',
);
/**
* Fields for saving
* @var array $fields
*/
protected $fields = array(
'email_from_name',
'email_from_email',
'email_smtp_host',
'email_smtp_port',
'email_smtp_username',
'email_smtp_password',
'sms_gateway_username',
'sms_gateway_password',
'sms_from',
);
function __construct(Database $db, Template $tpl) { function __construct(Database $db, Template $tpl) {
parent::__construct($db, $tpl); parent::__construct($db, $tpl);
@ -74,25 +104,23 @@ class Config extends AbstractModule {
} }
$this->tpl->addTemplateDataRepeat($this->getTemplateId(), 'languages', $languages); $this->tpl->addTemplateDataRepeat($this->getTemplateId(), 'languages', $languages);
$this->tpl->addTemplateData( $tpl_data = array(
$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_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"', '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', 'auto_refresh_servers' => (isset($config['auto_refresh_servers'])) ? $config['auto_refresh_servers'] : '0',
)
); );
foreach($this->checkboxes as $input_key) {
$tpl_data[$input_key . '_checked'] =
(isset($config[$input_key]) && (int) $config[$input_key] == 1)
? 'checked="checked"'
: '';
}
foreach($this->fields as $input_key) {
$tpl_data[$input_key] = (isset($config[$input_key])) ? $config[$input_key] : '';
}
$this->tpl->addTemplateData($this->getTemplateId(), $tpl_data);
} }
/** /**
@ -104,21 +132,18 @@ class Config extends AbstractModule {
// save new config // save new config
$clean = array( $clean = array(
'language' => $_POST['language'], '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' => $_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'], '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', 'auto_refresh_servers' => (isset($_POST['auto_refresh_servers'])) ? intval($_POST['auto_refresh_servers']) : '0',
); );
foreach($this->checkboxes as $input_key) {
$clean[$input_key] = (isset($_POST[$input_key])) ? '1': '0';
}
foreach($this->fields as $input_key) {
if(isset($_POST[$input_key])) {
$clean[$input_key] = $_POST[$input_key];
}
}
// save all values to the database // save all values to the database
foreach($clean as $key => $value) { foreach($clean as $key => $value) {
@ -167,6 +192,12 @@ class Config extends AbstractModule {
'label_email_status' => psm_get_lang('config', 'email_status'), 'label_email_status' => psm_get_lang('config', 'email_status'),
'label_email_from_email' => psm_get_lang('config', 'email_from_email'), 'label_email_from_email' => psm_get_lang('config', 'email_from_email'),
'label_email_from_name' => psm_get_lang('config', 'email_from_name'), 'label_email_from_name' => psm_get_lang('config', 'email_from_name'),
'label_email_smtp' => psm_get_lang('config', 'email_smtp'),
'label_email_smtp_host' => psm_get_lang('config', 'email_smtp_host'),
'label_email_smtp_port' => psm_get_lang('config', 'email_smtp_port'),
'label_email_smtp_username' => psm_get_lang('config', 'email_smtp_username'),
'label_email_smtp_password' => psm_get_lang('config', 'email_smtp_password'),
'label_email_smtp_noauth' => psm_get_lang('config', 'email_smtp_noauth'),
'label_sms_status' => psm_get_lang('config', 'sms_status'), 'label_sms_status' => psm_get_lang('config', 'sms_status'),
'label_sms_gateway' => psm_get_lang('config', 'sms_gateway'), 'label_sms_gateway' => psm_get_lang('config', 'sms_gateway'),
'label_sms_gateway_mosms' => psm_get_lang('config', 'sms_gateway_mosms'), 'label_sms_gateway_mosms' => psm_get_lang('config', 'sms_gateway_mosms'),
@ -187,6 +218,7 @@ class Config extends AbstractModule {
'label_log_email' => psm_get_lang('config', 'log_email'), 'label_log_email' => psm_get_lang('config', 'log_email'),
'label_log_sms' => psm_get_lang('config', 'log_sms'), 'label_log_sms' => psm_get_lang('config', 'log_sms'),
'label_auto_refresh_servers' => psm_get_lang('config', 'auto_refresh_servers'), 'label_auto_refresh_servers' => psm_get_lang('config', 'auto_refresh_servers'),
'label_save' => psm_get_lang('system', 'save'),
) )
); );

14
src/psm/Module/Install.class.php Normal file → Executable file
View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
* @since phpservermon 2.1.0 * @since phpservermon 2.1.0
**/ **/
@ -103,9 +103,9 @@ class Install extends AbstractModule {
} else { } else {
$this->addResult('cURL installed'); $this->addResult('cURL installed');
} }
if(!function_exists('mysql_connect')) { if(!in_array('mysql', \PDO::getAvailableDrivers())) {
$errors++; $errors++;
$this->addResult('php-mysql needs to be installed.', 'error'); $this->addResult('The PDO MySQL driver needs to be installed.', 'error');
} }
if($errors > 0) { if($errors > 0) {
@ -170,7 +170,7 @@ class Install extends AbstractModule {
$config['name'] $config['name']
); );
if(is_resource($this->db->getLink())) { if($this->db->status()) {
$this->addResult('Connection to MySQL successful.'); $this->addResult('Connection to MySQL successful.');
$config_php = $this->writeConfigFile($config); $config_php = $this->writeConfigFile($config);
if($config_php === true) { if($config_php === true) {
@ -222,7 +222,7 @@ class Install extends AbstractModule {
$this->addResult('No valid configuration found.', 'error'); $this->addResult('No valid configuration found.', 'error');
return $this->executeConfig(); return $this->executeConfig();
} }
if(!is_resource($this->db->getLink())) { if(!$this->db->status()) {
$this->addResult('MySQL connection failed.', 'error'); $this->addResult('MySQL connection failed.', 'error');
return; return;
} }
@ -234,7 +234,7 @@ class Install extends AbstractModule {
if(!empty($if_table_exists)) { if(!empty($if_table_exists)) {
$this->addResult('Table ' . $name . ' already exists in your database!'); $this->addResult('Table ' . $name . ' already exists in your database!');
} else { } else {
$this->db->query($sql); $this->db->exec($sql);
$this->addResult('Table ' . $name . ' added.'); $this->addResult('Table ' . $name . ' added.');
} }
} }
@ -256,7 +256,7 @@ class Install extends AbstractModule {
$install_queries = $queries->upgrade(PSM_VERSION, $version_from); $install_queries = $queries->upgrade(PSM_VERSION, $version_from);
foreach($install_queries as $sql) { foreach($install_queries as $sql) {
$this->db->query($sql); $this->db->exec($sql);
} }
$this->addResult('Installation finished!'); $this->addResult('Installation finished!');

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Module; namespace psm\Module;

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
* @since phpservermon 2.1 * @since phpservermon 2.1
**/ **/

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Module; namespace psm\Module;

View File

@ -23,7 +23,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Module; namespace psm\Module;

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Module; namespace psm\Module;

View File

@ -22,123 +22,137 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Service; namespace psm\Service;
class Database { class Database {
protected $debug = array(); /**
protected $last_inserted_id; * DB hostname
protected $link; * @var string $db_host
protected $num_rows_found; */
protected $num_rows_returned; protected $db_host;
function __construct($host = null, $user = null, $pass = null, $db = null) {
if($host != null && $user != null && $pass != null && $db != null) {
$this->connect($host, $user, $pass, $db);
} elseif(defined('PSM_DB_HOST') && defined('PSM_DB_USER') && defined('PSM_DB_PASS') && defined('PSM_DB_NAME')) {
$this->connect(PSM_DB_HOST, PSM_DB_USER, PSM_DB_PASS, PSM_DB_NAME);
}
}
/** /**
* Connect to the database * DB name
* @var string $db_name
*/
protected $db_name;
/**
* DB user password
* @var string $db_pass
*/
protected $db_pass;
/**
* DB username
* @var string $db_user
*/
protected $db_user;
/**
* PDOStatement of last query
* @var \PDOStatement $last
*/
protected $last;
/**
* Mysql db connection identifer
* @var \PDO $pdo
* @see pdo()
*/
protected $pdo;
/**
* Connect status
* @var boolean
* @see connect()
*/
protected $status = false;
/**
* Constructor
*
* @param string $host * @param string $host
* @param string $db
* @param string $user * @param string $user
* @param string $pass * @param string $pass
* @param string $db
* @return boolean
*/ */
protected function connect($host, $user, $pass, $db) { function __construct($host = null, $user = null, $pass = null, $db = null) {
$this->link = mysql_connect($host, $user, $pass); if($host != null && $user != null && $pass != null && $db != null) {
$this->db_host = $host;
if (!mysql_select_db($db, $this->link)) { $this->db_name = $db;
trigger_error(mysql_errno() . ": " . mysql_error()); $this->db_user = $user;
return false; $this->db_pass = $pass;
$this->connect();
} elseif(defined('PSM_DB_HOST') && defined('PSM_DB_USER') && defined('PSM_DB_PASS') && defined('PSM_DB_NAME')) {
$this->db_host = PSM_DB_HOST;
$this->db_name = PSM_DB_NAME;
$this->db_user = PSM_DB_USER;
$this->db_pass = PSM_DB_PASS;
$this->connect();
} }
mysql_query("SET NAMES utf8;", $this->link);
mysql_query("SET CHARACTER SET 'utf8';", $this->link);
return true;
} }
/** /**
* Executes a query * Exectues query and fetches result.
* *
* @param $sql string MySQL query * If you dont want to fetch a result, use exec().
* @return resource mysql resource * @param string $query SQL query
* @param boolean $fetch automatically fetch results, or return PDOStatement?
* @return array|\PDOStatement if $fetch = true, array, otherwise \PDOStatement
*/ */
public function query($query, $fetch = true) {
public function executeQuery($sql) {
$result = mysql_query($sql, $this->getLink());
if (mysql_error($this->getLink())) {
trigger_error(mysql_errno($this->getLink()) . ': ' . mysql_error($this->getLink()));
return false;
}
if (is_resource($result) && mysql_num_rows($result) > 0) {
// Rows returned
$this->num_rows_returned = mysql_num_rows($result);
// Rows found
$result_num_rows_found = $this->fetchResults(mysql_query('SELECT FOUND_ROWS();'));
$this->num_rows_found = $result_num_rows_found[0]['FOUND_ROWS()'];
}
if (substr(strtolower(trim($sql)), 0, 6) == 'insert') {
// we have an insert
$this->last_inserted_id = mysql_insert_id($this->getLink());
$result = $this->last_inserted_id;
}
return $result;
}
/**
* Exectues query and fetches result
*
* @param $query string MySQL query
* @return $result array
*/
public function query($query) {
// Execute query and process results // Execute query and process results
$result_resource = $this->executeQuery($query); try {
$result = $this->fetchResults($result_resource); $this->last = $this->pdo()->query($query);
} catch (\PDOException $e) {
$this->error($e);
}
if($fetch && $this->last != false) {
$cmd = strtolower(substr($query, 0, 6));
switch($cmd) {
case 'insert':
// insert query, return insert id
$result = $this->getLastInsertedId();
break;
case 'update':
case 'delete':
// update/delete, returns rowCount
$result = $this->getNumRows();
break;
default:
$result = $this->last->fetchAll(\PDO::FETCH_ASSOC);
break;
}
} else {
$result = $this->last;
}
return $result; return $result;
} }
/** /**
* Fetch results from a query * Execute SQL statement and return number of affected rows
* * @param string $query
* @param resource $result result from a mysql query * @return int
* @return array $array with results (multi-dimimensial) for more than one rows
*/ */
public function exec($query) {
public function fetchResults($result_query){ try {
$this->last = $this->pdo()->exec($query);
if (!is_resource($result_query)) { } catch (\PDOException $e) {
return array(); $this->error($e);
} }
$num_rows = mysql_num_rows($result_query); return $this->last;
$result = array();
while($record = mysql_fetch_assoc($result_query)) {
$result[] = $record;
}
return $result;
} }
/** /**
* Performs a select on the given table and returns an multi dimensional associative array with results * Performs a select on the given table and returns an multi dimensional associative array with results
*
* @param string $table tablename * @param string $table tablename
* @param mixed $where string or array with where data * @param mixed $where string or array with where data
* @param array $fields array with fields to be retrieved. if empty all fields will be retrieved * @param array $fields array with fields to be retrieved. if empty all fields will be retrieved
@ -147,7 +161,6 @@ class Database {
* @param string $direction ASC or DESC. Defaults to ASC * @param string $direction ASC or DESC. Defaults to ASC
* @return array multi dimensional array with results * @return array multi dimensional array with results
*/ */
public function select($table, $where = null, $fields = null, $limit = '', $orderby = null, $direction = 'ASC'){ public function select($table, $where = null, $fields = null, $limit = '', $orderby = null, $direction = 'ASC'){
// build query // build query
$query_parts = array(); $query_parts = array();
@ -164,16 +177,11 @@ class Database {
$query_parts[] = "FROM `{$table}`"; $query_parts[] = "FROM `{$table}`";
// Where clause // Where clause
$query_parts[] = $this->buildWhereClause($table, $where); $query_parts[] = $this->buildSQLClauseWhere($table, $where);
// Order by // Order by
if ($orderby !== null && !empty($orderby)) { if($orderby) {
$orderby_clause = 'ORDER BY '; $query_parts[] = $this->buildSQLClauseOrderBy($orderby, $direction);
foreach($orderby as $field) {
$orderby_clause .= "`{$field}`, ";
}
$query_parts[] = substr($orderby_clause, 0, -2) . ' ' . $direction;
} }
// Limit // Limit
@ -183,74 +191,169 @@ class Database {
$query = implode(' ', $query_parts); $query = implode(' ', $query_parts);
// Get results return $this->query($query);
$result = $this->query($query);
return $result;
} }
public function selectRow($table, $where = null, $fields = null, $limit = '', $orderby = null, $direction = 'ASC') { /**
$result = $this->select($table, $where, $fields, $limit, $orderby, $direction); * Alias to select() but uses limit = 1 to return only one row.
* @param string $table tablename
* @param mixed $where string or array with where data
* @param array $fields array with fields to be retrieved. if empty all fields will be retrieved
* @param array $orderby fields for the orderby clause
* @param string $direction ASC or DESC. Defaults to ASC
* @return array
*/
public function selectRow($table, $where = null, $fields = null, $orderby = null, $direction = 'ASC') {
$result = $this->select($table, $where, $fields, '1', $orderby, $direction);
if ($this->getNumRowsReturned() == '1') { if(isset($result[0])) {
$result = $result[0]; $result = $result[0];
} }
return $result; return $result;
} }
/** /**
* Remove a record from database * Remove a record from database
*
* @param string $table tablename * @param string $table tablename
* @param mixed $where Where clause array or primary Id (string) or where clause (string) * @param mixed $where Where clause array or primary Id (string) or where clause (string)
* @return boolean * @return int number of affected rows
*/ */
public function delete($table, $where = null){ public function delete($table, $where = null){
$sql = 'DELETE FROM `'.$table.'` ' . $this->buildSQLClauseWhere($table, $where);
if ($table != '') { return $this->exec($sql);
$sql = 'DELETE FROM `'.$table.'` ' . $this->buildWhereClause($table, $where);
$this->query($sql);
}
} }
/** /**
* Insert or update data to the database * Insert or update data to the database
* * @param string $table table name
* @param array $table table name
* @param array $data data to save or insert * @param array $data data to save or insert
* @param mixed $where either string ('user_id=2' or just '2' (works only with primary field)) or array with where clause (only when updating) * @param mixed $where either string ('user_id=2' or just '2' (works only with primary field)) or array with where clause (only when updating)
*/ */
public function save($table, $data, $where = null) { public function save($table, array $data, $where = null) {
if ($where === null) { if ($where === null) {
// insert mode // insert mode
$query = "INSERT INTO "; $query = "INSERT INTO ";
$exec = false;
} else { } else {
$query = "UPDATE "; $query = "UPDATE ";
$exec = true;
} }
$query .= "`{$table}` SET "; $query .= "`{$table}` SET ";
foreach($data as $field => $value) { foreach($data as $field => $value) {
$value = $this->escapeValue($value); if(is_null($value)) {
$query .= "`{$table}`.`{$field}`='{$value}', "; $value = 'NULL';
} else {
$value = $this->quote($value);
}
$query .= "`{$table}`.`{$field}`={$value}, ";
} }
$query = substr($query, 0, -2) . ' ' . $this->buildWhereClause($table, $where); $query = substr($query, 0, -2) . ' ' . $this->buildSQLClauseWhere($table, $where);
if($exec) {
return $this->exec($query);
} else {
return $this->query($query); return $this->query($query);
} }
}
/**
* Insert multiple rows into a single table
*
* This method is preferred over calling the insert() lots of times
* so it can be optimized to be inserted with 1 query.
* It can only be used if all inserts have the same fields, records
* that do not match the fields provided in the first record will be
* skipped.
*
* @param type $table
* @param array $data
* @return \PDOStatement
* @see insert()
*/
public function insertMultiple($table, array $data) {
if(empty($data)) return false;
// prepare first part
$query = "INSERT INTO `{$table}` ";
$fields = array_keys($data[0]);
$query .= "(`".implode('`,`', $fields)."`) VALUES ";
// prepare all rows to be inserted with placeholders for vars (\?)
$q_part = array_fill(0, count($fields), '?');
$q_part = "(".implode(',', $q_part).")";
$q_part = array_fill(0, count($data), $q_part);
$query .= implode(',', $q_part);
$pst = $this->pdo()->prepare($query);
$i = 1;
foreach($data as $row) {
// make sure the fields of this row are identical to first row
$diff_keys = array_diff_key($fields, array_keys($row));
if(!empty($diff_keys)) {
continue;
}
foreach($fields as $field) {
$pst->bindParam($i++, $row[$field]);
}
}
try {
$this->last = $pst->execute();
} catch (\PDOException $e) {
$this->error($e);
}
return $this->last;
}
/**
* Quote a string
* @param string $value
* @return string
*/
public function quote($value) {
return $this->pdo()->quote($value);
}
/**
* Get the PDO object
* @return \PDO
*/
public function pdo() {
return $this->pdo;
}
/**
* Get number of rows of last statement
* @return int number of rows
*/
public function getNumRows() {
return $this->last->rowCount();
}
/**
* Get the last inserted id after an insert
* @return int
*/
public function getLastInsertedId() {
return $this->pdo()->lastInsertId();
}
/** /**
* Build WHERE clause for query * Build WHERE clause for query
*
* @param string $table table name * @param string $table table name
* @param mixed $where can be primary id (eg '2'), can be string (eg 'name=pepe') or can be array * @param mixed $where can be primary id (eg '2'), can be string (eg 'name=pepe') or can be array
* @return string sql where clause * @return string sql where clause
* @see buildSQLClauseOrderBy()
*/ */
public function buildWhereClause($table, $where = null) { public function buildSQLClauseWhere($table, $where = null) {
$query = ''; $query = '';
@ -259,16 +362,14 @@ class Database {
$query .= " WHERE "; $query .= " WHERE ";
foreach($where as $field => $value) { foreach($where as $field => $value) {
$value = $this->escapeValue($value); $query .= "`{$table}`.`{$field}`={$this->quote($value)} AND ";
$query .= "`{$table}`.`{$field}`='{$value}' AND ";
} }
$query = substr($query, 0, -5); $query = substr($query, 0, -5);
} else { } else {
if (strpos($where, '=') === false) { if (strpos($where, '=') === false) {
// no field given, use primary field // no field given, use primary field
$structure = $this->getTableStructure($table); $primary = $this->getPrimary($table);
$where = $this->escapeValue($where); $query .= " WHERE `{$table}`.`{$primary}`={$this->quote($where)}";
$query .= " WHERE `{$table}`.`{$structure['primary']}`='{$where}'";
} elseif (strpos(strtolower(trim($where)), 'where') === false) { } elseif (strpos(strtolower(trim($where)), 'where') === false) {
$query .= " WHERE {$where}"; $query .= " WHERE {$where}";
} else { } else {
@ -280,106 +381,117 @@ class Database {
} }
/** /**
* Get table structure and primary key * Build ORDER BY clause for a query
* * @param mixed $order_by can be string (with or without order by) or array
* @param string $table table name * @param string $direction
* @return array primary key and database structure * @return string sql order by clause
* @see buildSQLClauseWhere()
*/ */
public function getTableStructure($table) { public function buildSQLClauseOrderBy($order_by, $direction) {
if ($table == '') return false; $query = '';
$structure = $this->query("DESCRIBE `{$table}`"); if ($order_by !== null) {
if (is_array($order_by)) {
$query .= " ORDER BY ";
if (empty($structure)) return false; foreach($order_by as $field) {
$query .= "`{$field}`, ";
}
// remove trailing ", "
$query = substr($query, 0, -2);
} else {
if (strpos(strtolower(trim($order_by)), 'order by') === false) {
$query .= " ORDER BY {$order_by}";
} else {
$query .= ' '.$order_by;
}
}
}
if(strlen($query) > 0) {
// check if "ASC" or "DESC" is already in the order by clause
if(strpos(strtolower(trim($query)), 'asc') === false && strpos(strtolower(trim($query)), 'desc') === false) {
$query .= ' '.$direction;
}
}
// use arrray search function to get primary key return $query;
$search_needle = array(
'key' => 'Key',
'value' => 'PRI'
);
$primary = pep_array_search_key_value(
$structure,
array(
'key' => 'Key',
'value' => 'PRI'
)
);
$primary_field = $structure[$primary[0]['path'][0]]['Field'];
return array(
'primary' => $primary_field,
'fields' => $structure
);
} }
/** /**
* Get information about a field from the database * Get the host of the current connection
*
* @param string $table
* @param string $field
* @return array mysql field information
*/
public function getFieldInfo($table, $field) {
if ($table == '' || $field == '') return array();
$db_structure = $this->getTableStructure($table);
$field_info = pep_array_search_key_value(
$db_structure,
array(
'key' => 'Field',
'value' => $field
)
);
if (empty($field_info)) {
return array();
}
// return field info
return $field_info[0]['result'];
}
/**
* Formats the value for the SQL query to secure against injections
*
* @param string $value
* @return string * @return string
*/ */
public function escapeValue($value) { public function getDbHost() {
if(get_magic_quotes_gpc()) { return $this->db_host;
$value = stripslashes($value);
}
$value = mysql_real_escape_string($value, $this->link);
return $value;
} }
/** /**
* Get number of rows found * Get the db name of the current connection
* * @return string
* @return int number of rows found
*/ */
public function getNumRowsFound() { public function getDbName() {
return $this->num_rows_found; return $this->db_name;
} }
/** /**
* Get number of rows returned * Get the db user of the current connection
* * @return string
* @return int number of rows returned
*/ */
public function getNumRowsReturned() { public function getDbUser() {
return $this->num_rows_returned; return $this->db_user;
} }
/** /**
* Get the database connection identifier * Get status of the connection
* * @return boolean
* @return object db connection
*/ */
public function getLink() { public function status() {
return $this->link; return $this->status;
}
/**
* Connect to the database.
*
* @return resource mysql resource
*/
protected function connect() {
// Initizale connection
try {
$this->pdo = new \PDO(
'mysql:host='.$this->db_host.';dbname='.$this->db_name.';charset=utf8',
$this->db_user,
$this->db_pass
);
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->status = true;
} catch (\PDOException $e) {
$this->status = false;
return $this->onConnectFailure($e);
}
return $this->pdo;
}
/**
* Is called after connection failure
*/
protected function onConnectFailure(\PDOException $e) {
trigger_error('MySQL connection failed: '.$e->getMessage(), E_USER_WARNING);
return false;
}
/**
* Disconnect from current link
*/
protected function disconnect() {
$this->pdo = null;
}
/**
* Handle a PDOException
* @param \PDOException $e
*/
protected function error(\PDOException $e) {
trigger_error('SQL error: ' . $e->getMessage(), E_USER_WARNING);
} }
} }

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Service; namespace psm\Service;
@ -93,9 +93,6 @@ class Template {
} }
foreach($data as $key => $value) { foreach($data as $key => $value) {
// check if $value is a file
$value = (file_exists($value)) ? $this->parseFile($value) : $value;
$this->templates[$id] = str_replace('{'.$key.'}', $value, $this->templates[$id]); $this->templates[$id] = str_replace('{'.$key.'}', $value, $this->templates[$id]);
} }
return $this->templates[$id]; return $this->templates[$id];

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Txtmsg; namespace psm\Txtmsg;

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Txtmsg; namespace psm\Txtmsg;

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Txtmsg; namespace psm\Txtmsg;

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Txtmsg; namespace psm\Txtmsg;

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
* @since phpservermon 2.1 * @since phpservermon 2.1
**/ **/

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Txtmsg; namespace psm\Txtmsg;

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
* @since phpservermon 2.1 * @since phpservermon 2.1
**/ **/

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Txtmsg; namespace psm\Txtmsg;

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
* @since phpservermon 2.1.0 * @since phpservermon 2.1.0
**/ **/

57
src/psm/Util/Mailer.class.php Executable file
View File

@ -0,0 +1,57 @@
<?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://www.phpservermonitor.org/
* @since phpservermon 2.2.0
**/
namespace psm\Util;
/**
* PHPMailer is not using namespaces so unable to load files in autoloader.
*/
require_once(PSM_PATH_VENDOR . '/PHPMailer/class.phpmailer.php');
require_once(PSM_PATH_VENDOR . '/PHPMailer/class.smtp.php');
/**
* PSM Mailer utility
*
* The PHPMailer is an open source lib that can be found in vendor/PHPMailer.
*
* @see \PHPMailer
*/
class Mailer extends \PHPMailer {
/**
* Open new PHPMailer
*
* @param boolean $exceptions
*/
function __construct($exceptions = false) {
parent::__construct($exceptions);
}
}
?>

View File

@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2014 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 * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://phpservermon.neanderthal-technology.com/ * @link http://www.phpservermonitor.org/
**/ **/
namespace psm\Util\Updater; namespace psm\Util\Updater;
@ -122,20 +122,13 @@ class Status {
$time = explode(' ', microtime()); $time = explode(' ', microtime());
$starttime = $time[1] + $time[0]; $starttime = $time[1] + $time[0];
$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $this->server['ip']);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt ($ch, CURLOPT_TIMEOUT, 10);
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! // unless we have a pattern to search for!
curl_setopt($ch, CURLOPT_HEADER, true); $curl_result = psm_curl_get(
curl_setopt($ch, CURLOPT_NOBODY, ($this->server['pattern'] != '' ? false : true)); $this->server['ip'],
true,
$curl_result = curl_exec ($ch); ($this->server['pattern'] == '' ? false : true)
curl_close ($ch); );
$time = explode(" ", microtime()); $time = explode(" ", microtime());
$endtime = $time[1] + $time[0]; $endtime = $time[1] + $time[0];
@ -260,10 +253,7 @@ class Status {
} }
// build mail object with some default values // build mail object with some default values
$mail = new \phpmailer(); $mail = psm_build_mail();
$mail->From = psm_get_conf('email_from_email');
$mail->FromName = psm_get_conf('email_from_name');
$mail->Subject = psm_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;

View File

@ -2,12 +2,20 @@
{config_update} {config_update}
<div class="span12"> <div class="span12">
<form class="form-horizontal well" action="index.php?type=config&action=save" id="edit_config" method="post"> <form class="form-horizontal well" action="index.php?type=config&action=save" id="edit_config" method="post">
<ul class="nav nav-tabs">
<li class="active"><a href="#config-general" data-toggle="tab">{label_general}</a></li>
<li><a href="#config-email" data-toggle="tab">{label_settings_email}</a></li>
<li><a href="#config-sms" data-toggle="tab">{label_settings_sms}</a></li>
<li><a href="#config-logging" data-toggle="tab">{label_settings_log}</a></li>
</ul>
<div class="tab-content">
<div id="config-general" class="tab-pane active">
<fieldset> <fieldset>
<legend>{label_general}</legend> <legend>{label_general}</legend>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="language">{label_language}</label> <label class="control-label" for="language">{label_language}</label>
<div class="controls"> <div class="controls">
<select name="language"> <select id="language" name="language">
<!--%tpl_repeat_languages--> <!--%tpl_repeat_languages-->
<option value="{value}" {selected}>{label}</option> <option value="{value}" {selected}>{label}</option>
<!--%%tpl_repeat_languages--> <!--%%tpl_repeat_languages-->
@ -16,47 +24,100 @@
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="auto_refresh_servers">{label_show_update}</label> <label class="control-label" for="show_update">{label_show_update}</label>
<div class="controls"> <div class="controls">
<input type="checkbox" name="show_update[]" {show_update_checked} /> <input type="checkbox" id="show_update" name="show_update[]" {show_update_checked} />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="auto_refresh_servers">{label_auto_refresh_servers}</label> <label class="control-label" for="auto_refresh_servers">{label_auto_refresh_servers}</label>
<div class="controls"> <div class="controls">
<input type="text" name="auto_refresh_servers" value="{auto_refresh_servers}" maxlength="10" />&nbsp;seconds <input type="text" id="auto_refresh_servers" name="auto_refresh_servers" value="{auto_refresh_servers}" maxlength="10" />&nbsp;seconds
</div> </div>
</div> </div>
<legend>{label_settings_notification}</legend>
<div class="control-group">
<label class="control-label" for="alert_type">{label_alert_type}</label>
<div class="controls">
<select id="alert_type" name="alert_type">
<option value="status" {alert_type_selected_status}>{label_alert_type_status}</option>
<option value="offline" {alert_type_selected_offline}>{label_alert_type_offline}</option>
<option value="always" {alert_type_selected_always}>{label_alert_type_always}</option>
</select>
<p class="help-block">
{label_alert_type_description}
</p>
</div>
</div>
<div class="form-actions">
<button class="btn btn-success" type="submit">{label_save}</button>
</div>
</fieldset>
</div>
<div id="config-email" class="tab-pane">
<fieldset>
<legend>{label_settings_email}</legend> <legend>{label_settings_email}</legend>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="email_status">{label_email_status}</label> <label class="control-label" for="email_status">{label_email_status}</label>
<div class="controls"> <div class="controls">
<input type="checkbox" name="email_status[]" {email_status_checked} /> <input type="checkbox" id="email_status" name="email_status[]" {email_status_checked} />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="email_from_name">{label_email_from_name}</label> <label class="control-label" for="email_from_name">{label_email_from_name}</label>
<div class="controls"> <div class="controls">
<input type="text" name="email_from_name" value="{email_from_name}" maxlength="255" /> <input type="text" id="email_from_name" name="email_from_name" value="{email_from_name}" maxlength="255" />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="email_from_email">{label_email_from_email}</label> <label class="control-label" for="email_from_email">{label_email_from_email}</label>
<div class="controls"> <div class="controls">
<input type="text" name="email_from_email" value="{email_from_email}" maxlength="255" /> <input type="text" id="email_from_email" name="email_from_email" value="{email_from_email}" maxlength="255" />
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label" for="email_smtp">{label_email_smtp}</label>
<div class="controls">
<input type="checkbox" id="email_smtp" name="email_smtp[]" {email_smtp_checked} />
</div>
</div>
<div class="control-group">
<label class="control-label" for="email_smtp_host">{label_email_smtp_host}</label>
<div class="controls">
<input type="text" id="email_smtp_host" name="email_smtp_host" value="{email_smtp_host}" maxlength="100" placeholder="{label_email_smtp_host}" />
<input type="text" class="input-small" id="email_smtp_port" name="email_smtp_port" value="{email_smtp_port}" maxlength="10" placeholder="{label_email_smtp_port}" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="email_smtp_username">{label_email_smtp_username}</label>
<div class="controls">
<input type="text" id="email_smtp_username" name="email_smtp_username" value="{email_smtp_username}" maxlength="100" placeholder="{label_email_smtp_noauth}" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="email_smtp_password">{label_email_smtp_password}</label>
<div class="controls">
<input type="password" id="email_smtp_password" name="email_smtp_password" value="{email_smtp_password}" maxlength="100" placeholder="{label_email_smtp_noauth}" />
</div>
</div>
<div class="form-actions">
<button class="btn btn-success" type="submit">{label_save}</button>
</div>
</fieldset>
</div>
<div id="config-sms" class="tab-pane">
<fieldset>
<legend>{label_settings_sms}</legend> <legend>{label_settings_sms}</legend>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="sms_status">{label_sms_status}</label> <label class="control-label" for="sms_status">{label_sms_status}</label>
<div class="controls"> <div class="controls">
<input type="checkbox" name="sms_status[]" {sms_status_checked} /> <input type="checkbox" id="sms_status" name="sms_status[]" {sms_status_checked} />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="sms_gateway">{label_sms_gateway}</label> <label class="control-label" for="sms_gateway">{label_sms_gateway}</label>
<div class="controls"> <div class="controls">
<select name="sms_gateway"> <select id="sms_gateway" name="sms_gateway">
<option value="mosms" {sms_selected_mosms}>{label_sms_gateway_mosms}</option> <option value="mosms" {sms_selected_mosms}>{label_sms_gateway_mosms}</option>
<option value="mollie" {sms_selected_mollie}>{label_sms_gateway_mollie}</option> <option value="mollie" {sms_selected_mollie}>{label_sms_gateway_mollie}</option>
<option value="spryng" {sms_selected_spryng}>{label_sms_gateway_spryng}</option> <option value="spryng" {sms_selected_spryng}>{label_sms_gateway_spryng}</option>
@ -69,58 +130,53 @@
<div class="control-group"> <div class="control-group">
<label class="control-label" for="sms_gateway_username">{label_sms_gateway_username}</label> <label class="control-label" for="sms_gateway_username">{label_sms_gateway_username}</label>
<div class="controls"> <div class="controls">
<input type="text" name="sms_gateway_username" value="{sms_gateway_username}" maxlength="255" /> <input type="text" id="sms_gateway_username" name="sms_gateway_username" value="{sms_gateway_username}" maxlength="255" />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="sms_gateway_password">{label_sms_gateway_password}</label> <label class="control-label" for="sms_gateway_password">{label_sms_gateway_password}</label>
<div class="controls"> <div class="controls">
<input type="password" name="sms_gateway_password" value="{sms_gateway_password}" maxlength="255" /> <input type="password" id="sms_gateway_password" name="sms_gateway_password" value="{sms_gateway_password}" maxlength="255" />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="sms_from">{label_sms_from}</label> <label class="control-label" for="sms_from">{label_sms_from}</label>
<div class="controls"> <div class="controls">
<input type="text" name="sms_from" value="{sms_from}" maxlength="255" /> <input type="text" id="sms_from" name="sms_from" value="{sms_from}" maxlength="255" />
</div> </div>
</div> </div>
<legend>{label_settings_notification}</legend> <div class="form-actions">
<div class="control-group"> <button class="btn btn-success" type="submit">{label_save}</button>
<label class="control-label" for="alert_type">{label_alert_type}</label>
<div class="controls">
<select name="alert_type">
<option value="status" {alert_type_selected_status}>{label_alert_type_status}</option>
<option value="offline" {alert_type_selected_offline}>{label_alert_type_offline}</option>
<option value="always" {alert_type_selected_always}>{label_alert_type_always}</option>
</select>
<p class="help-block">
{label_alert_type_description}
</p>
</div> </div>
</fieldset>
</div> </div>
<div id="config-logging" class="tab-pane">
<fieldset>
<legend>{label_settings_log}</legend> <legend>{label_settings_log}</legend>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="log_status">{label_log_status}</label> <label class="control-label" for="log_status">{label_log_status}</label>
<div class="controls"> <div class="controls">
<input type="checkbox" name="log_status[]" {log_status_checked} /> <input type="checkbox" id="log_status" name="log_status[]" {log_status_checked} />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="log_status">{label_log_email}</label> <label class="control-label" for="log_email">{label_log_email}</label>
<div class="controls"> <div class="controls">
<input type="checkbox" name="log_email[]" {log_email_checked} /> <input type="checkbox" id="log_email" name="log_email[]" {log_email_checked} />
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="log_sms">{label_log_sms}</label> <label class="control-label" for="log_sms">{label_log_sms}</label>
<div class="controls"> <div class="controls">
<input type="checkbox" name="log_sms[]" {log_sms_checked} /> <input type="checkbox" id="log_sms" name="log_sms[]" {log_sms_checked} />
</div> </div>
</div> </div>
<div class="form-actions"> <div class="form-actions">
<button class="btn btn-success" type="submit">Save</button> <button class="btn btn-success" type="submit">{label_save}</button>
</div> </div>
</fieldset> </fieldset>
</div>
</div>
</form> </form>
</div> </div>
<!--%%tpl_config--> <!--%%tpl_config-->

View File

@ -3,7 +3,7 @@
<h1><img class="pull-right" src="static/opensource.png" width="100" alt="" /> &nbsp;PHP Server Monitor</h1> <h1><img class="pull-right" src="static/opensource.png" width="100" alt="" /> &nbsp;PHP Server Monitor</h1>
<p>&nbsp;</p> <p>&nbsp;</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-primary btn-large" target="_blank" href="http://www.phpservermonitor.org/">PHP Server Monitor</a>
<a class="btn btn-large" target="_blank" href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a> <a class="btn btn-large" target="_blank" href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>
</p> </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>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>

View File

@ -87,7 +87,7 @@
<a href="index.php?action=check">{label_update}</a> <a href="index.php?action=check">{label_update}</a>
</li> </li>
<li id="nav_option_help"> <li id="nav_option_help">
<a href="http://phpservermon.sourceforge.net" target="_blank">{label_help}</a> <a href="http://www.phpservermonitor.org/" target="_blank">{label_help}</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -101,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.neanderthal-technology.com" target="_blank">PHP Server Monitor</a> and Powered by <a href="http://www.phpservermonitor.org/" 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 &copy; 2008-2014 <a href="mailto:pep@neanderthal-technology.com">Pepijn Over</a> Copyright &copy; 2008-2014 <a href="mailto:pep@neanderthal-technology.com">Pepijn Over</a>

2949
vendor/PHPMailer/class.phpmailer.php vendored Executable file

File diff suppressed because it is too large Load Diff

1092
vendor/PHPMailer/class.smtp.php vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff