. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ /** * ServerConfiguration - serverConf class * * @author Hugo Loza * @copyright 2010 COLOSA * @license GNU Affero General Public License * @package workflow.engine.ProcessMaker */ class serverConf { private $_aProperties = array(); private $_aHeartbeatConfig = array(); private $_aWSapces = array(); private $aWSinfo = array(); private $pluginsA = array(); private $errors = array(); private static $instance = null; private $haveSetupData = false; private $beatType = 'starting'; private $ip; private $index = 0; private $os; private $webserver; private $host; private $php; private $mysql; private $pmVersion; private $pmProduct = 'PMCE'; private $nextBeatDate; public $logins; private $lanDirection; private $lanLanguage; public $workspaces = array(); public $rtlLang = array('ar', 'iw', 'fa'); public $filePath = ''; public function __construct() { if (defined('PATH_DATA')) { $this->filePath = PATH_DATA . 'srvConf.singleton'; } } /** * This function is instancing to this object * param * * @return object */ public function &getSingleton() { if (self::$instance == null) { self::$instance = new serverConf(); if ((file_exists(self::$instance->filePath)) && (filesize(self::$instance->filePath) > 0)) { self::$instance->unSerializeInstance(file_get_contents(self::$instance->filePath)); } } return self::$instance; } /** * This function generates a storable representation of this obejct * param * * @return void */ public function serializeInstance() { return serialize(self::$instance); } /** * This function takes a single serialized object and converts it back a object * * @param string $serialized * @return void */ public function unSerializeInstance($serialized) { if (self::$instance == null) { self::$instance = new serverConf(); } if ($instance = @unserialize($serialized)) { self::$instance = $instance; } } /** * This will save the object in the specified file (defined as a property of this class) * param * * @return void */ public function saveSingleton() { if (defined('PATH_DATA')) { $this->filePath = PATH_DATA . 'srvConf.singleton'; $size = file_put_contents($this->filePath, $this->serializeInstance()); } } /** * With this is possible to save a property that will be saved in the properties * array of this class. * * @param string $propertyName * @param string $propertyValue */ public function setProperty($propertyName, $propertyValue) { $this->_aProperties[$propertyName] = $propertyValue; $this->saveSingleton(); } /** * To unset a defined property. * If it doesn't exist then it does nothing. * * @param string $propertyName * @return void */ public function unsetProperty($propertyName) { if (isset($this->_aProperties[$propertyName])) { unset($this->_aProperties[$propertyName]); $this->saveSingleton(); } } /** * Returns the value of a defined property. * If it doesn't exist then returns null * * @param string $propertyName * @return string/null */ public function getProperty($propertyName) { if (isset($this->_aProperties[$propertyName])) { return $this->_aProperties[$propertyName]; } else { return null; } } /** * Used to have a record of succesful logins to the system (total and by WS) * param * * @return void */ public function sucessfulLogin() { $this->logins++; if (isset($this->workspaces[SYS_SYS]) && isset($this->workspaces[SYS_SYS]['WSP_LOGINS'])) { $this->workspaces[SYS_SYS]['WSP_LOGINS']++; } if (isset($this->workspaces[SYS_SYS]) && !isset($this->workspaces[SYS_SYS]['WSP_LOGINS'])) { $this->workspaces[SYS_SYS]['WSP_LOGINS'] = 1; } $this->saveSingleton(); } public function setWsInfo($wsname, $info) { $this->aWSinfo[$wsname] = $info; } /** * This will togle the status of a workspace (enabled,disabled) * * @param string $wsName * @return void */ public function changeStatusWS($wsName) { if (isset($this->_aWSapces[$wsName])) { //Enable WS unset($this->_aWSapces[$wsName]); } else { $this->_aWSapces[$wsName] = 'disabled'; } $this->saveSingleton(); } /** * Return the status of a WS. * If is disabled will return 1 otherwise 0 * * @param $wsname * @return boolean */ public function isWSDisabled($wsName) { return isset($this->_aWSapces[$wsName]); } /** * Check only if the server address or server name has changed, * to send another beat in next minute. * param * * @return boolean */ public function checkIfHostNameHasChanged() { //removed the PM_VERSION control, because when an upgrade is done, the haveSetupData has to be changed. if ($this->ip != getenv('SERVER_ADDR')) { return false; } if ($this->host != getenv('SERVER_NAME')) { return false; } return $this->haveSetupData; } /** * Will return a list of all WS in this system and their related information. * * @uses getWSList * param * @return array */ public function getWSList() { $dir = PATH_DB; $wsArray = array(); if (file_exists($dir)) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (($file != ".") && ($file != "..")) { if (file_exists(PATH_DB . $file . '/db.php')) { //print $file."/db.php