File: D:/HostingSpaces/EvLuik/vanluiktegelwerken.nl/wwwroot/plugins/fa/classes/SystemCheckService.php
<?php
/**
* Copyright 2017 Christoph M. Becker
*
* This file is part of Fa_XH.
*
* Fa_XH 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.
*
* Fa_XH 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 Fa_XH. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Fa;
class SystemCheckService
{
/**
* @var string
*/
private $pluginFolder;
/**
* @var array
*/
private $lang;
public function __construct()
{
global $pth, $plugin_tx;
$this->pluginFolder = "{$pth['folder']['plugins']}fa";
$this->lang = $plugin_tx['fa'];
}
/**
* @return object[]
*/
public function getChecks()
{
return array(
$this->checkPhpVersion('5.3.0'),
$this->checkXhVersion('1.6.3'),
$this->checkWritability("$this->pluginFolder/css/"),
$this->checkWritability("$this->pluginFolder/config/"),
$this->checkWritability("$this->pluginFolder/languages/")
);
}
/**
* @param string $version
* @return object
*/
private function checkPhpVersion($version)
{
$state = version_compare(PHP_VERSION, $version, 'ge') ? 'success' : 'fail';
$label = sprintf($this->lang['syscheck_phpversion'], $version);
$stateLabel = $this->lang["syscheck_$state"];
return (object) compact('state', 'label', 'stateLabel');
}
/**
* @param string $version
* @return object
*/
private function checkXhVersion($version)
{
$state = version_compare(CMSIMPLE_XH_VERSION, "CMSimple_XH $version", 'ge') ? 'success' : 'fail';
$label = sprintf($this->lang['syscheck_xhversion'], $version);
$stateLabel = $this->lang["syscheck_$state"];
return (object) compact('state', 'label', 'stateLabel');
}
/**
* @param string $folder
* @return object
*/
private function checkWritability($folder)
{
$state = is_writable($folder) ? 'success' : 'warning';
$label = sprintf($this->lang['syscheck_writable'], $folder);
$stateLabel = $this->lang["syscheck_$state"];
return (object) compact('state', 'label', 'stateLabel');
}
}