Merge branch 'develop' into develop
commit
5a7e0e0bc4
19
.htaccess
19
.htaccess
|
@ -1 +1,20 @@
|
|||
Options -Indexes
|
||||
|
||||
<IfModule mod_expires.c>
|
||||
<FilesMatch "\.(js|jpg|jpeg|gif|png|css)$">
|
||||
ExpiresActive on
|
||||
ExpiresDefault "access plus 1 month"
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_deflate.c>
|
||||
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
|
||||
</IfModule>
|
||||
|
|
|
@ -75,6 +75,7 @@ Requirements
|
|||
* PHP 5.3.7+
|
||||
* PHP cURL package
|
||||
* PHP PDO mysql driver
|
||||
* PHP-XML
|
||||
|
||||
|
||||
Install
|
||||
|
|
|
@ -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');
|
||||
define('PSM_BASE_URL', '');
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 "<?php \
|
||||
header('Location: /psm/index.php'); \
|
||||
?>" > /var/www/default/index.php
|
||||
?>" > /var/www/default/index.php
|
||||
|
|
|
@ -18,6 +18,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc
|
|||
<parameter key="path.templates">%path.src%templates</parameter>
|
||||
|
||||
<parameter key="db.host" type="constant">PSM_DB_HOST</parameter>
|
||||
<parameter key="db.port" type="constant">PSM_DB_PORT</parameter>
|
||||
<parameter key="db.user" type="constant">PSM_DB_USER</parameter>
|
||||
<parameter key="db.pass" type="constant">PSM_DB_PASS</parameter>
|
||||
<parameter key="db.name" type="constant">PSM_DB_NAME</parameter>
|
||||
|
@ -38,6 +39,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/sc
|
|||
<argument>%db.user%</argument>
|
||||
<argument>%db.pass%</argument>
|
||||
<argument>%db.name%</argument>
|
||||
<argument>%db.port%</argument>
|
||||
</service>
|
||||
|
||||
<service id="event" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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.',
|
||||
),
|
||||
);
|
||||
);
|
||||
|
|
|
@ -121,6 +121,7 @@ class InstallController extends AbstractController {
|
|||
|
||||
$config = array(
|
||||
'db_host' => 'localhost',
|
||||
'db_port' => '3306'
|
||||
'db_name' => '',
|
||||
'db_user' => '',
|
||||
'db_pass' => '',
|
||||
|
@ -142,6 +143,7 @@ class InstallController extends AbstractController {
|
|||
// test db connection
|
||||
$this->db = new \psm\Service\Database(
|
||||
$config['db_host'],
|
||||
$config['db_port'],
|
||||
$config['db_user'],
|
||||
$config['db_pass'],
|
||||
$config['db_name']
|
||||
|
@ -308,6 +310,7 @@ class InstallController extends AbstractController {
|
|||
'pass' => '',
|
||||
'name' => '',
|
||||
'host' => '',
|
||||
'port' => '3306'
|
||||
);
|
||||
$pattern = "/define\('SM_{key}', '(.*?)'/u";
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -458,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'),
|
||||
|
|
|
@ -35,6 +35,12 @@ class Database {
|
|||
*/
|
||||
protected $db_host;
|
||||
|
||||
/**
|
||||
* DB port
|
||||
* @var string $db_port
|
||||
*/
|
||||
protected $db_port = 3306;
|
||||
|
||||
/**
|
||||
* DB name
|
||||
* @var string $db_name
|
||||
|
@ -81,9 +87,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 +505,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
|
||||
);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 - Code from http://stackoverflow.com/a/20467492
|
||||
* @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
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<title>{{ title }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, minimum-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<meta name="robots" content="noindex" />
|
||||
<meta name="theme-color" content="#424242">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
<input type="text" id="host" name="db_host" value="{{ db_host }}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="host">Database port</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="port" name="port" value="{{ port }}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="name">Database name</label>
|
||||
<div class="controls">
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<div class="controls">
|
||||
<select id="type" name="type">
|
||||
<option value="">{{ label_please_select }}</option>
|
||||
<option value="ping" {{ edit_type_selected_ping|raw }}>{{ label_ping }}</option>
|
||||
<option value="service" {{ edit_type_selected_service|raw }}>{{ label_service }}</option>
|
||||
<option value="website" {{ edit_type_selected_website|raw }}>{{ label_website }}</option>
|
||||
</select>
|
||||
|
@ -47,6 +48,7 @@
|
|||
<option value="115">SFTP (115)</option>
|
||||
<option value="43">WHOIS (43)</option>
|
||||
<option value="53">BIND (53)</option>
|
||||
<option value="3389">RDP (3389)</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue