Added upgrader & changed version

Upgrades the install to include a protocol field.
Defined the upgrade version as 3.5.0
pull/834/head
Nayef Alebrahim 2020-01-16 14:24:12 +03:00
parent 1bd8e821f0
commit d0680834fd
No known key found for this signature in database
GPG Key ID: 7F1502304671A40F
3 changed files with 27 additions and 2 deletions

View File

@ -30,7 +30,7 @@
/**
* Current PSM version
*/
define('PSM_VERSION', '3.4.5');
define('PSM_VERSION', '3.5.0');
/**
* URL to check for updates. Will not be checked if turned off on config page.

View File

@ -342,6 +342,9 @@ class Installer
if (version_compare($version_from, '3.4.2', '<')) {
$this->upgrade342();
}
if (version_compare($version_from, '3.5.0', '<')) {
$this->upgrade350();
}
psm_update_conf('version', $version_to);
}
@ -656,4 +659,20 @@ class Installer
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `last_output` `last_output` TEXT;";
$this->execSQL($queries);
}
/**
* Upgrade for v3.5.0 release
*/
protected function upgrade350()
{
/**
* Adds a protocol column which defaults to TCP
* This sets the field to TCP on older installations
* ensuring they do not break
*/
$queries = array();
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD COLUMN `protocol` ENUM( 'tcp','udp' )
NOT NULL DEFAULT 'tcp' AFTER `port`;";
$this->execSQL($queries);
}
}

View File

@ -222,7 +222,13 @@ class StatusUpdater
// save response time
$starttime = microtime(true);
$fp = @fsockopen($this->server['protocol'] . '://' . $this->server['ip'], $this->server['port'], $errno, $this->error, $timeout);
$fp = @fsockopen(
$this->server['protocol'] . '://' . $this->server['ip'],
$this->server['port'],
$errno,
$this->error,
$timeout
);
$status = ($fp === false) ? false : true;
$this->rtime = (microtime(true) - $starttime);