require '../bootstrap.php'; Pommo::requireOnce($pommo->_baseDir . 'inc/classes/install.php'); $pommo->init(array('authLevel' => 0, 'install' => TRUE)); session_start(); // required by smartyValidate. TODO -> move to prepareForForm() ?? $logger =& $pommo->_logger; $dbo =& $pommo->_dbo; $dbo->dieOnQuery(FALSE); /********************************** SETUP TEMPLATE, PAGE *********************************/ Pommo::requireOnce($pommo->_baseDir . 'inc/classes/template.php'); $smarty = new PommoTemplate(); $smarty->prepareForForm(); // Check to make sure poMMo is not already installed. if (PommoInstall::verify()) { $logger->addErr(Pommo::_T('poMMo is already installed.')); $smarty->assign('installed', TRUE); $smarty->display('install.tpl'); Pommo::kill(); } if (isset($_REQUEST['disableDebug'])) { unset($_REQUEST['debugInstall']); } elseif (isset($_REQUEST['debugInstall'])) { $smarty->assign('debug', TRUE); } if (!SmartyValidate::is_registered_form() || empty($_POST)) { // ___ USER HAS NOT SENT FORM ___ SmartyValidate::connect($smarty, true); SmartyValidate::register_validator('list_name', 'list_name', 'notEmpty', false, false, 'trim'); SmartyValidate::register_validator('site_name', 'site_name', 'notEmpty', false, false, 'trim');
/** * init -> called by page to load page state, populate config, and track authentication. * valid args [ passed as Pommo::init(array('arg' => val, 'arg2' => val)) ] -> * authLevel : check that authenticated permission level is at least authLevel (non authenticated == 0). exit if not high enough. [default: 1] * keep : keep data stored in session. [default: false] * session : explicity set session name. [default: null] * install : bypass loading of config/version checking [default: false] */ function init($args = array()) { $defaults = array('authLevel' => 1, 'keep' => FALSE, 'noSession' => FALSE, 'sessionID' => NULL, 'install' => FALSE); // merge submitted parameters $p = PommoAPI::getParams($defaults, $args); // Bypass Reading of Config, SESSION creation, and authentication checks and return // if 'install' passed if ($p['install']) { return; } // load configuration data // note; cannot save in session, as session needs unique key -- this is simplest method. $this->_config = PommoAPI::configGetBase(); // check current ("file") revision against database ("last") revision $revision = isset($this->_config['revision']) ? $this->_config['revision'] : false; if (!defined('_poMMo_support')) { if (!$revision) { $this->kill(sprintf(Pommo::_T('Error loading configuration. Has poMMo been installed? %sClick Here%s to install.'), '<a href="' . $this->_baseUrl . 'install/install.php">', '</a>')); } elseif ($this->_revision != $revision) { $this->kill(sprintf(Pommo::_T('Version Mismatch. %sClick Here%s to upgrade.'), '<a href="' . $this->_baseUrl . 'install/upgrade.php">', '</a>')); } } // toggle DB debugging if ($this->_debug) { $this->_dbo->debug(TRUE); } // Bypass SESSION creation, reading of config, authentication checks and return // if 'noSession' passed if ($p['noSession']) { return; } // start the session if (!empty($p['sessionID'])) { session_id($p['sessionID']); } $this->startSession(); // check for "session" language -- user defined language on the fly. if ($this->_slanguage) { $this->_session['slanguage'] = $this->_slanguage; } if (isset($this->_session['slanguage'])) { if ($this->_session['slanguage'] == 'en') { $this->_l10n = FALSE; } else { $this->_l10n = TRUE; Pommo::requireOnce($this->_baseDir . 'inc/helpers/l10n.php'); PommoHelperL10n::init($this->_session['slanguage'], $this->_baseDir); } $this->_slanguage = $this->_session['slanguage']; } // if authLevel == '*' || _poMMo_support (0 if poMMo not installed, 1 if installed) if (defined('_poMMo_support')) { Pommo::requireOnce($this->_baseDir . 'inc/classes/install.php'); $p['authLevel'] = PommoInstall::verify() ? 1 : 0; } // check authentication levels $this->_auth = new PommoAuth(array('requiredLevel' => $p['authLevel'])); // clear SESSION 'data' unless keep is passed. // TODO --> phase this out in favor of page state system? // -- add "persistent" flag & complicate state initilization... if (!$p['keep']) { $this->_session['data'] = array(); } }