setDBO(VoxelCareDB::getDatabase()); } function getFilePath() { return JPATH_BASE. '/components/com_vxc/settings_'.SiteOptionsHelper::getFranchiseName().'.ini'; } function getVar($key, $defaultValue=null) { $settings =& $this->getSettings(); if ($settings[$key] === NULL) return $defaultValue; else return $settings[$key]; } function getSettings() { if (!$this->_settings) { $session =& JFactory::getSession(); $settings = $session->get('settings',null,'vxc'); $fileIniPath = $this->getFilePath(); if ($settings!==null) { $timeIniChange = @filemtime($fileIniPath); if ($timeIniChange===FALSE) return $settings; $settingsStoreDate = $session->get('settingsstoredate',null,'vxc'); if ($settingsStoreDate ===null ) $iniChanged = true; else $iniChanged = $timeIniChange > $settingsStoreDate; } else $iniChanged = true; if ($iniChanged) { $settings = @parse_ini_file($fileIniPath); if ($settings === FALSE) { $oldFileName = JPATH_BASE. '/components/com_vxc/settings.ini'; $settings = @parse_ini_file($fileIniPath); if ($settings===FALSE) $settings = array(); } $session->set('settingsstoredate',time(),'vxc'); $session->set('settings',$settings,'vxc'); } $this->_settings = $settings; } return $this->_settings; } function recoverBackup() { $filePath = $this->getFilePath(); $backupFilePath = $filePath.".old"; @copy($backupFilePath,$filePath); @chmod($filePath,0666); } function storeAsText(&$settings) { $filePath = $this->getFilePath(); // Backup storage $backupFilePath = $filePath.".".strtotime ("now"); @copy($filePath,$backupFilePath); @chmod($backupFilePath,0666); $fic=@fopen($filePath,"wb"); if ($fic) { @fputs($fic,$settings); @fclose($fic); @chmod($filePath,0666); } } function getSettingsAsText() { $filePath = $this->getFilePath(); $contents = @file_get_contents($filePath); if ($contents===FALSE) { $oldFileName = JPATH_BASE. '/components/com_vxc/settings.ini'; $contents = @file_get_contents($oldFileName); if ($contents ===FALSE) return ""; else return $contents; } else return $contents; } }// class