. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. * /** * @package workflow.ProcessMaker */ /** * ServerConfiguration - serverConf class * @author Hugo Loza * @copyright 2010 COLOSA * @license GNU Affero General Public License */ 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; var $logins; private $lanDirection; private $lanLanguage; private function __construct() { $this->filePath = PATH_DATA . 'srvConf.singleton'; } /** * This function is instancing to this object * @param * @return object */ 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 */ function serializeInstance() { return serialize ( self::$instance ); } /** * This function takes a single serialized object and converts it back a object * @param string $serialized * @return void */ 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 */ function saveSingleton() { $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 */ 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 */ 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 */ 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 */ 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 (); } function setWsInfo($wsname,$info){ $this->aWSinfo[$wsname]=$info; } /** * This will togle the status of a workspace (enabled,disabled) * @param string $wsName * @return void */ 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 */ 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 */ 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 getWorkspaceInfo * @param * @return array */ 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