From eadc9b145e574a43d4daad132d7de9157d9e2fe6 Mon Sep 17 00:00:00 2001 From: Samuel Denis-D'Ortun Date: Tue, 15 Nov 2016 13:08:21 -0500 Subject: [PATCH 01/23] Update README.rst --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index fdfa4b39..e76cdaab 100755 --- a/README.rst +++ b/README.rst @@ -75,6 +75,7 @@ Requirements * PHP 5.3.7+ * PHP cURL package * PHP PDO mysql driver +* PHP-XML Install From 92069a29a33222ce6c65fa02072d65d963530597 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 11:12:07 +0100 Subject: [PATCH 02/23] Add RDP port to save method --- src/psm/Module/Server/Controller/ServerController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/psm/Module/Server/Controller/ServerController.php b/src/psm/Module/Server/Controller/ServerController.php index c2c61db2..d2cdbba8 100644 --- a/src/psm/Module/Server/Controller/ServerController.php +++ b/src/psm/Module/Server/Controller/ServerController.php @@ -286,6 +286,8 @@ class ServerController extends AbstractServerController { $clean["port"] = 443; } elseif ($tmp["scheme"] === "http") { $clean["port"] = 80; + } elseif ($tmp["scheme"] === "rdp") { + $clean["port"] = 3389; } } From 2325a6c25f1901088b35ed68f2c47207de0c3edb Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 11:14:30 +0100 Subject: [PATCH 03/23] Add RDP to port list --- src/templates/default/module/server/server/update.tpl.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/templates/default/module/server/server/update.tpl.html b/src/templates/default/module/server/server/update.tpl.html index 2378d21e..96c4d098 100644 --- a/src/templates/default/module/server/server/update.tpl.html +++ b/src/templates/default/module/server/server/update.tpl.html @@ -47,6 +47,7 @@ + From 4c7d2bd4f3ad466905358c3755c69cf63f348549 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 11:29:28 +0100 Subject: [PATCH 04/23] Add updatePing method to check if ip is pingable --- src/psm/Util/Server/Updater/StatusUpdater.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 84b147e1..06335127 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -90,6 +90,9 @@ class StatusUpdater { } switch($this->server['type']) { + case 'ping': + $this->status_new = $this->updatePing($max_runs); + break; case 'service': $this->status_new = $this->updateService($max_runs); break; @@ -134,6 +137,41 @@ class StatusUpdater { } + /** + * Check the current servers ping status + * @param int $max_runs + * @param int $run + * @return boolean + */ + protected function updatePing($max_runs, $run = 1) { + $errno = 0; + // save response time + $starttime = microtime(true); + // set ping payload + $package = "\x08\x00\x7d\x4b\x00\x00\x00\x00PingHost"; + + $fp = @fsockopen ($this->server['ip'], $this->server['port'], $errno, $this->error, 10); + $socket = socket_create(AF_INET, SOCK_RAW, 1); + socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 10, 'usec' => 0)); + socket_connect($socket, $this->server['ip'], null); + + socket_send($socket, $package, strLen($package), 0); + if (socket_read($socket, 255)) { + $this->rtime = microtime(true) - $starttime; + $status = true; + } else { + $status = false; + } + socket_close($socket); + + // check if server is available and rerun if asked. + if(!$status && $run < $max_runs) { + return $this->updatePing($max_runs, $run + 1); + } + + return $status; + } + /** * Check the current server as a service * @param int $max_runs From 363f67b3355c2b4d319c819cb9060e0efed3503c Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 11:30:27 +0100 Subject: [PATCH 05/23] Add copyright notice to updatePing method --- src/psm/Util/Server/Updater/StatusUpdater.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 06335127..ad787b2f 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -138,7 +138,7 @@ class StatusUpdater { } /** - * Check the current servers ping status + * Check the current servers ping status - Code from http://stackoverflow.com/a/20467492 * @param int $max_runs * @param int $run * @return boolean From 3cd90b29aef3f29d677be5240990f11d4893f276 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 11:33:55 +0100 Subject: [PATCH 06/23] Add server type ping to dropdown --- src/templates/default/module/server/server/update.tpl.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/templates/default/module/server/server/update.tpl.html b/src/templates/default/module/server/server/update.tpl.html index 96c4d098..4f26e357 100644 --- a/src/templates/default/module/server/server/update.tpl.html +++ b/src/templates/default/module/server/server/update.tpl.html @@ -20,6 +20,7 @@
From 5c0e889dd2efc8ca55dab06f0c676148411f7fd9 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 11:38:47 +0100 Subject: [PATCH 07/23] Add ping validation checks to ServerValidator --- src/psm/Util/Server/ServerValidator.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/psm/Util/Server/ServerValidator.php b/src/psm/Util/Server/ServerValidator.php index 8b23d14f..4c97333f 100644 --- a/src/psm/Util/Server/ServerValidator.php +++ b/src/psm/Util/Server/ServerValidator.php @@ -101,6 +101,11 @@ class ServerValidator { throw new \InvalidArgumentException('server_ip_bad_service'); } break; + case 'ping': + if(!filter_var($value, FILTER_VALIDATE_IP)) { + throw new \InvalidArgumentException('server_ip_bad_service'); + } + break; } return true; @@ -113,7 +118,7 @@ class ServerValidator { * @throws \InvalidArgumentException */ public function type($type) { - if(!in_array($type, array('service', 'website'))) { + if(!in_array($type, array('ping', 'service', 'website'))) { throw new \InvalidArgumentException('server_type_invalid'); } return true; From b6060e793601aa819eadf1fa6e257ea74b86d411 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 11:44:15 +0100 Subject: [PATCH 08/23] Add ping label to getLabels() --- src/psm/Module/Server/Controller/ServerController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/psm/Module/Server/Controller/ServerController.php b/src/psm/Module/Server/Controller/ServerController.php index d2cdbba8..748f5434 100644 --- a/src/psm/Module/Server/Controller/ServerController.php +++ b/src/psm/Module/Server/Controller/ServerController.php @@ -460,6 +460,7 @@ class ServerController extends AbstractServerController { 'label_type' => psm_get_lang('servers', 'type'), 'label_website' => psm_get_lang('servers', 'type_website'), 'label_service' => psm_get_lang('servers', 'type_service'), + 'label_ping' => psm_get_lang('servers', 'type_ping'), 'label_pattern' => psm_get_lang('servers', 'pattern'), 'label_pattern_description' => psm_get_lang('servers', 'pattern_description'), 'label_last_check' => psm_get_lang('servers', 'last_check'), From 8ee269ceaa4d094408111a08691dbe1d86811d33 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 11:45:27 +0100 Subject: [PATCH 09/23] Add type_ping to lang file --- src/lang/de_DE.lang.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index fd8aee95..885d6199 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -125,6 +125,7 @@ $sm_lang = array( 'type' => 'Typ', 'type_website' => 'Webseite', 'type_service' => 'Service', + 'type_ping' => 'Ping', 'pattern' => 'Suchstring/-muster', 'pattern_description' => 'Wenn das gesuchte Muster nicht in der Webseite ist, wird die Seite als offline markiert. Reguläre Ausdrücke sind erlaubt.', 'last_check' => 'Letzter Check', From 3c961c8b91068b12adf458728bad3aeed95f7aef Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 14:13:11 +0100 Subject: [PATCH 10/23] Add type ping to lang file --- src/lang/en_US.lang.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 51665f08..058c7919 100755 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -135,6 +135,7 @@ $sm_lang = array( 'type' => 'Type', 'type_website' => 'Website', 'type_service' => 'Service', + 'type_ping' => 'Ping', 'pattern' => 'Search string/pattern', 'pattern_description' => 'If this pattern is not found on the website, the server will be marked offline. Regular expressions are allowed.', 'last_check' => 'Last check', @@ -316,4 +317,4 @@ $sm_lang = array( '401_unauthorized' => 'Unauthorized', '401_unauthorized_description' => 'You do not have the privileges to view this page.', ), -); \ No newline at end of file +); From 6bee28c78ececa309ad76c47ad5c583ac463535c Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 14:29:57 +0100 Subject: [PATCH 11/23] Add ping to enum for type column in servers database table --- src/psm/Util/Install/Installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psm/Util/Install/Installer.php b/src/psm/Util/Install/Installer.php index 6c3ee490..612f7764 100644 --- a/src/psm/Util/Install/Installer.php +++ b/src/psm/Util/Install/Installer.php @@ -218,7 +218,7 @@ class Installer { `ip` varchar(500) NOT NULL, `port` int(5) unsigned NOT NULL, `label` varchar(255) NOT NULL, - `type` enum('service','website') NOT NULL default 'service', + `type` enum('ping','service','website') NOT NULL default 'service', `pattern` varchar(255) NOT NULL, `status` enum('on','off') NOT NULL default 'on', `error` varchar(255) NULL, From ff1013ed7c7a517024ce8c657ccab50ba29bdee6 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 15:20:02 +0100 Subject: [PATCH 12/23] Add custom port to config options in db class --- src/psm/Service/Database.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/psm/Service/Database.php b/src/psm/Service/Database.php index c5296170..afb022a7 100644 --- a/src/psm/Service/Database.php +++ b/src/psm/Service/Database.php @@ -81,9 +81,10 @@ class Database { * @param string $pass * @param string $db */ - function __construct($host = null, $user = null, $pass = null, $db = null) { + function __construct($host = null, $user = null, $pass = null, $db = null, $port = null) { if($host != null && $user != null && $pass !== null && $db != null) { $this->db_host = $host; + $this->db_port = $port || 3306; $this->db_name = $db; $this->db_user = $user; $this->db_pass = $pass; @@ -498,7 +499,7 @@ class Database { // Initizale connection try { $this->pdo = new \PDO( - 'mysql:host='.$this->db_host.';dbname='.$this->db_name.';charset=utf8', + 'mysql:host='.$this->db_host.';port='.$this->db_port.';dbname='.$this->db_name.';charset=utf8', $this->db_user, $this->db_pass ); From 80a092fa0c82b66232e3a81c42f2ceed8561c85a Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 15:20:46 +0100 Subject: [PATCH 13/23] Add port static to config file --- config.php.sample | 1 + 1 file changed, 1 insertion(+) diff --git a/config.php.sample b/config.php.sample index 667afe2e..41b09247 100755 --- a/config.php.sample +++ b/config.php.sample @@ -4,4 +4,5 @@ define('PSM_DB_USER', 'db_user'); define('PSM_DB_PASS', 'db_pass'); define('PSM_DB_NAME', 'db_name'); define('PSM_DB_HOST', 'localhost'); +define('PSM_DB_PORT', '3306'); From 4a69f606d3661f034147092f4e96a759c395cdf0 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 15:22:24 +0100 Subject: [PATCH 14/23] Add port constant to psminstall --- puphpet/files/exec-once/psminstall.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/puphpet/files/exec-once/psminstall.sh b/puphpet/files/exec-once/psminstall.sh index 2ebd8b54..b115800f 100644 --- a/puphpet/files/exec-once/psminstall.sh +++ b/puphpet/files/exec-once/psminstall.sh @@ -6,8 +6,9 @@ define('PSM_DB_USER', 'psm'); \ define('PSM_DB_PASS', 'psm'); \ define('PSM_DB_NAME', 'psm'); \ define('PSM_DB_HOST', 'localhost'); \ +define('PSM_DB_PORT', '3306'); \ ?>" > /var/www/default/psm/config.php echo "" > /var/www/default/index.php \ No newline at end of file +?>" > /var/www/default/index.php From a3853241f806dd4edbf1907b103289381de41ef2 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 15:23:31 +0100 Subject: [PATCH 15/23] Add port param and argument --- src/config/services.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/config/services.xml b/src/config/services.xml index 5d3fbd1b..43446dcd 100644 --- a/src/config/services.xml +++ b/src/config/services.xml @@ -18,6 +18,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc %path.src%templates PSM_DB_HOST + PSM_DB_PORT PSM_DB_USER PSM_DB_PASS PSM_DB_NAME @@ -38,6 +39,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc %db.user% %db.pass% %db.name% + %db.port% From a9f11fb691972863848324f38dab177d1bce52d5 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 15:24:25 +0100 Subject: [PATCH 16/23] Add port constant to install readme --- docs/install.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/install.rst b/docs/install.rst index f8e0efa2..627704fb 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -27,6 +27,7 @@ To change these values correctly, only update the second parameter of the functi define('PSM_DB_NAME', 'db_name'); define('PSM_DB_USER', 'db_user'); define('PSM_DB_PASS', 'db_user_password'); + define('PSM_DB_PORT', '3306'); For example: 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. From b2043b1b654c3808f95ec70a90a481fda53d7aa3 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 15:28:25 +0100 Subject: [PATCH 17/23] Add protected variable $db_port --- src/psm/Service/Database.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/psm/Service/Database.php b/src/psm/Service/Database.php index afb022a7..c15348e0 100644 --- a/src/psm/Service/Database.php +++ b/src/psm/Service/Database.php @@ -35,6 +35,12 @@ class Database { */ protected $db_host; + /** + * DB port + * @var string $db_port + */ + protected $db_port; + /** * DB name * @var string $db_name From cd977e2e515e7242330742c3856646c5f2b3e94a Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 15:30:39 +0100 Subject: [PATCH 18/23] Initialize protected variable db_port with value 3306 --- src/psm/Service/Database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psm/Service/Database.php b/src/psm/Service/Database.php index c15348e0..16ff69fc 100644 --- a/src/psm/Service/Database.php +++ b/src/psm/Service/Database.php @@ -39,7 +39,7 @@ class Database { * DB port * @var string $db_port */ - protected $db_port; + protected $db_port = 3306; /** * DB name From b780a6237e72b867a4584886eb3329fdcc877f77 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 15:38:50 +0100 Subject: [PATCH 19/23] Add port input fields to template --- src/templates/default/module/install/config_new.tpl.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/templates/default/module/install/config_new.tpl.html b/src/templates/default/module/install/config_new.tpl.html index 64fe07ab..4a07a4ce 100644 --- a/src/templates/default/module/install/config_new.tpl.html +++ b/src/templates/default/module/install/config_new.tpl.html @@ -17,6 +17,12 @@
+
+ +
+ +
+
@@ -60,4 +66,4 @@
{% endif %}
-{% endblock %} \ No newline at end of file +{% endblock %} From b1df28d4d97d1e006de22fd75fd6348cecafc899 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 15:41:03 +0100 Subject: [PATCH 20/23] Add port to installer --- src/psm/Module/Install/Controller/InstallController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/psm/Module/Install/Controller/InstallController.php b/src/psm/Module/Install/Controller/InstallController.php index dad31b14..fab71709 100644 --- a/src/psm/Module/Install/Controller/InstallController.php +++ b/src/psm/Module/Install/Controller/InstallController.php @@ -121,6 +121,7 @@ class InstallController extends AbstractController { $config = array( 'host' => 'localhost', + 'port' => '3306', 'name' => '', 'user' => '', 'pass' => '', @@ -143,7 +144,8 @@ class InstallController extends AbstractController { $config['host'], $config['user'], $config['pass'], - $config['name'] + $config['name'], + $config['port'], ); if($this->db->status()) { @@ -307,6 +309,7 @@ class InstallController extends AbstractController { 'pass' => '', 'name' => '', 'host' => '', + 'port' => '3306', ); $pattern = "/define\('SM_DB_{key}', '(.*?)'/u"; From 6805903089e54eab6d4157b98553eff86f95e009 Mon Sep 17 00:00:00 2001 From: Tom Hatzer Date: Fri, 23 Dec 2016 15:42:15 +0100 Subject: [PATCH 21/23] Remove trailing comma --- src/psm/Module/Install/Controller/InstallController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/psm/Module/Install/Controller/InstallController.php b/src/psm/Module/Install/Controller/InstallController.php index fab71709..75a7e94a 100644 --- a/src/psm/Module/Install/Controller/InstallController.php +++ b/src/psm/Module/Install/Controller/InstallController.php @@ -145,7 +145,7 @@ class InstallController extends AbstractController { $config['user'], $config['pass'], $config['name'], - $config['port'], + $config['port'] ); if($this->db->status()) { @@ -309,7 +309,7 @@ class InstallController extends AbstractController { 'pass' => '', 'name' => '', 'host' => '', - 'port' => '3306', + 'port' => '3306' ); $pattern = "/define\('SM_DB_{key}', '(.*?)'/u"; From 479f2119f698f9ab7f142a265bf7a2fa932ead01 Mon Sep 17 00:00:00 2001 From: criwe Date: Sun, 25 Dec 2016 22:44:44 +0100 Subject: [PATCH 22/23] add A monitoring website should not be indexed by google. will prevent that. Removed autor-tag, because not relevant anymore (especially for a page like that) --- src/templates/default/main/body.tpl.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/default/main/body.tpl.html b/src/templates/default/main/body.tpl.html index fa7d252a..4ce7dc56 100644 --- a/src/templates/default/main/body.tpl.html +++ b/src/templates/default/main/body.tpl.html @@ -6,7 +6,7 @@ {{ title }} - + From b0add8c2105ea997ab1a49d9e6b612a3c8c60ef3 Mon Sep 17 00:00:00 2001 From: criwe Date: Sun, 25 Dec 2016 23:00:49 +0100 Subject: [PATCH 23/23] Added some basic pagespeed settings Added some basic pagespeed settings to the htaccess --- .htaccess | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.htaccess b/.htaccess index 5a928f6d..1014e510 100644 --- a/.htaccess +++ b/.htaccess @@ -1 +1,20 @@ Options -Indexes + + + + ExpiresActive on + ExpiresDefault "access plus 1 month" + + + + +AddOutputFilterByType DEFLATE text/plain +AddOutputFilterByType DEFLATE text/html +AddOutputFilterByType DEFLATE text/xml +AddOutputFilterByType DEFLATE text/css +AddOutputFilterByType DEFLATE application/xml +AddOutputFilterByType DEFLATE application/xhtml+xml +AddOutputFilterByType DEFLATE application/rss+xml +AddOutputFilterByType DEFLATE application/javascript +AddOutputFilterByType DEFLATE application/x-javascript +