Private GIT

Skip to content
Snippets Groups Projects
Commit 3e96ef0a authored by Lionel Assepo's avatar Lionel Assepo
Browse files

Add Check for module

parent e70562b5
No related branches found
No related tags found
No related merge requests found
...@@ -88,6 +88,9 @@ class CentreonAPI ...@@ -88,6 +88,9 @@ class CentreonAPI
public function __construct($user, $password, $action, $centreon_path, $options) public function __construct($user, $password, $action, $centreon_path, $options)
{ {
global $version; global $version;
global $licensedModule;
$licensedModule = array();
/** /**
* Set variables * Set variables
...@@ -303,11 +306,14 @@ class CentreonAPI ...@@ -303,11 +306,14 @@ class CentreonAPI
$objectsPath = array(); $objectsPath = array();
$DBRESULT = $this->DB->query("SELECT name FROM modules_informations"); $DBRESULT = $this->DB->query("SELECT name FROM modules_informations");
while ($row = $DBRESULT->fetchRow()) { while ($row = $DBRESULT->fetchRow()) {
if ($this->checkModuleValidity($row['name'])) {
$objectsPath = array_merge( $objectsPath = array_merge(
$objectsPath, $objectsPath,
glob(_CENTREON_PATH_ . 'www/modules/' . $row['name'] . '/centreon-clapi/class/*.php') glob(_CENTREON_PATH_ . 'www/modules/' . $row['name'] . '/centreon-clapi/class/*.php')
); );
} }
}
foreach ($objectsPath as $objectPath) { foreach ($objectsPath as $objectPath) {
if (preg_match('/([\w-]+)\/centreon-clapi\/class\/centreon(\w+).class.php/', $objectPath, $matches)) { if (preg_match('/([\w-]+)\/centreon-clapi\/class\/centreon(\w+).class.php/', $objectPath, $matches)) {
...@@ -341,6 +347,58 @@ class CentreonAPI ...@@ -341,6 +347,58 @@ class CentreonAPI
$this->delim = ";"; $this->delim = ";";
} }
/**
* @param $moduleName
* @return bool
*/
public function checkModuleValidity($moduleName)
{
global $licensedModule;
$isValid = true;
$checkLicenseFile = _CENTREON_PATH_ . "www/modules/$moduleName/extensions/checkLicense.php";
if (file_exists($checkLicenseFile)) {
require_once $checkLicenseFile;
}
if (in_array($moduleName, $licensedModule)) {
$isValid = false;
$licenseFile = _CENTREON_PATH_ . "www/modules/$moduleName/license/merethis_lic_temp.zl";
if (function_exists("zend_loader_file_encoded")) {
if (file_exists($licenseFile)) {
$zend_info = $this->parseZendLicenseFile($licenseFile);
$license_expires = strtotime($zend_info['Expires']);
if ($license_expires > time()) {
$isValid = true;
}
}
}
}
return $isValid;
}
/**
* @param $file
* @return array
*/
private function parseZendLicenseFile($file)
{
$lines = preg_split('/\n/', file_get_contents($file));
$infos = array();
foreach ($lines as $line) {
if (preg_match('/^([^= ]+)\s*=\s*(.+)$/', $line, $match)) {
$infos[$match[1]] = $match[2];
}
}
return $infos;
}
/** /**
* *
* @param void * @param void
...@@ -352,7 +410,8 @@ class CentreonAPI ...@@ -352,7 +410,8 @@ class CentreonAPI
$action = null, $action = null,
$centreon_path = null, $centreon_path = null,
$options = null $options = null
) { )
{
if (is_null(self::$_instance)) { if (is_null(self::$_instance)) {
self::$_instance = new CentreonAPI($user, $password, $action, $centreon_path, $options); self::$_instance = new CentreonAPI($user, $password, $action, $centreon_path, $options);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment