/** * Builds an instance object of this class only if there is no one. * * @return CampSession */ public static function singleton() { if (!isset(self::$m_instance)) { self::$m_instance = new CampSession(); } return self::$m_instance; }
/** * */ public static function ConnectDB() { global $g_db; if (is_a($g_db, 'ADONewConnection')) { return true; } $session = CampSession::singleton(); $dbData = $session->getData('config.db', 'installation'); if (empty($dbData)) { return false; } $dbhost = $dbData['hostname']; if (!empty($dbData['hostport'])) { // add port to hostname $dbhost .= ':' . $dbData['hostport']; } $g_db = ADONewConnection('mysql'); $g_db->SetFetchMode(ADODB_FETCH_ASSOC); return @$g_db->Connect($dbhost, $dbData['username'], $dbData['userpass'], $dbData['database']); } // fn ConnectDB
public static function DeleteSystemPrefsFromCache() { CampSession::singleton()->setData('system_preferences', null, 'default', true); if (file_exists($GLOBALS['g_campsiteDir'].'/'.self::CACHE_FILE_NAME)) { unlink($GLOBALS['g_campsiteDir'].'/'.self::CACHE_FILE_NAME); } return true; }
/** * */ public function render() { $tpl = CampTemplate::singleton(); $tpl->assign('site_title', $this->m_title); $tpl->assign('message', $this->m_message); $tpl->assign('package', $this->m_version->getPackage()); $tpl->assign('version', $this->m_version->getVersion()); $tpl->assign('release_date', $this->m_version->getReleaseDate()); $tpl->assign('organization', $this->m_version->getOrganization()); $tpl->assign('copyright', $this->m_version->getCopyright()); $tpl->assign('license', $this->m_version->getLicense()); $tpl->assign('host_os', $this->m_os); $tpl->assign('current_step', $this->m_step); $tpl->assign('current_step_title', $this->m_steps[$this->m_step]['title']); $tpl->assign('step_titles', $this->m_steps); $session = CampSession::singleton(); $config_db = $session->getData('config.db', 'installation'); $files = array(); if ($handle = opendir('./sample_templates')) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && is_dir('./sample_templates/' . $file)) { $files[] = $file; } } closedir($handle); } $tpl->assign('sample_templates', $files); $tpl->assign('overwrite_db', $this->m_overwriteDb); $database_conf = dirname(__FILE__) . '/../../conf/database_conf.php'; if (!empty($config_db)) { $tpl->assign('db', $config_db); } elseif (file_exists($database_conf)) { // use predefined settings global $Campsite; require_once $database_conf; $tpl->assign('db', array('hostname' => $Campsite['db']['host'], 'hostport' => $Campsite['db']['port'], 'username' => $Campsite['db']['user'], 'userpass' => $Campsite['db']['pass'], 'database' => $Campsite['db']['name'], 'predefined' => TRUE)); } else { $tpl->assign('db', array('hostname' => 'localhost', 'username' => 'root', 'database' => 'newscoop', 'hostport' => '', 'userpass' => '')); } $config_site = $session->getData('config.site', 'installation'); if (!empty($config_site)) { $tpl->assign('mc', $config_site); } else { $tpl->assign('mc', array('sitetitle' => '', 'adminemail' => '')); } $config_demo = $session->getData('config.demo', 'installation'); if (!empty($config_demo)) { $tpl->assign('dm', $config_demo); } else { $tpl->assign('dm', array('loaddemo' => '')); } $view = new CampInstallationView($this->m_step); $tpl->display($this->getTemplateName()); }
/** * Returns a CampSession instance. * * @return object * A CampSession instance */ public static function GetSessionInstance() { return CampSession::singleton(); } // fn GetSession
public static function ConnectDB() { global $g_db; if ($g_db !== null) { return true; } $session = CampSession::singleton(); $dbData = $session->getData('config.db', 'installation'); if (empty($dbData)) { return false; } $params = array('dbname' => $dbData['database'], 'user' => $dbData['username'], 'password' => $dbData['userpass'], 'host' => $dbData['hostname'], 'driver' => 'pdo_mysql', 'charset' => 'UTF8'); $config = new \Doctrine\DBAL\Configuration(); $connection = \Doctrine\DBAL\DriverManager::getConnection($params, $config); return $g_db = new \Newscoop\Doctrine\AdoDbAdapter($connection); }
public static function isValid() { return CampSession::singleton()->getToken() === Input::Get(self::SECURITY_TOKEN, 'string', null, true); }
/** * Clears the cache. * * @param string * $p_type If given is 'user', the user cache will be cleard, * otherwise the system cache (cached files) will be. * * @return boolean * TRUE on success, FALSE on failure */ public function clear($p_type = null) { if (!self::$m_enabled) { return false; } CampSession::singleton()->setData(SystemPref::SESSION_KEY_CACHE_ENGINE, null, 'default', true); if ($p_type == 'user') { return $this->m_cacheEngine->clearValues(); } else { return $this->m_cacheEngine->clearPages(); } } // fn clear