.
*
* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
* California 94120-7775, or email info@knowledgetree.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* KnowledgeTree" logo and retain the original copyright notice. If the display of the
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
* must display the words "Powered by KnowledgeTree" and retain the original
* copyright notice.
*
* @copyright 2008-2009, KnowledgeTree Inc.
* @license GNU General Public License version 3
* @author KnowledgeTree Team
* @package Installer
* @version Version 0.1
*/
include("path.php"); // Paths
function __autoload($class) { // Attempt and autoload classes
$class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems.
if(file_exists(WIZARD_DIR."$class.php")) {
require(WIZARD_DIR."$class.php");
} elseif (file_exists(STEP_DIR."$class.php")) {
require(STEP_DIR."$class.php");
} else {
return false;
}
}
class InstallWizard {
/**
* Install bypass flag
*
* @author KnowledgeTree Team
* @access protected
* @var mixed
*/
protected $bypass = null;
/**
* Reference to installer utility object
*
* @author KnowledgeTree Team
* @access protected
* @var boolean
*/
protected $iutil = null;
/**
* Constructs installation wizard object
*
* @author KnowledgeTree Team
* @access public
*/
public function __construct(){}
/**
* Check if system has been install
*
* @author KnowledgeTree Team
* @access private
* @param none
* @return boolean
*/
private function isSystemInstalled() {
return $this->iutil->isSystemInstalled();
}
/**
* Display the wizard
*
* @author KnowledgeTree Team
* @access private
* @param string
* @return void
*/
public function displayInstaller($response = null) {
if($response) {
$ins = new Installer(); // Instantiate the installer
$ins->resolveErrors($response); // Run step
} else {
$ins = new Installer(new Session()); // Instantiate the installer and pass the session class
$ins->step(); // Run step
}
}
/**
* Set bypass flag
*
* @author KnowledgeTree Team
* @access private
* @param boolean
* @return void
*/
private function setBypass($bypass) {
$this->bypass = $bypass;
}
/**
* Set util reference
*
* @author KnowledgeTree Team
* @access private
* @param object installer utility
* @return void
*/
private function setIUtil($iutil) {
$this->iutil = $iutil;
}
/**
* Get bypass flag
*
* @author KnowledgeTree Team
* @access public
* @param none
* @return boolean
*/
public function getBypass() {
return $this->bypass;
}
/**
* Bypass and force an install
*
* @author KnowledgeTree Team
* @access private
* @param none
* @return boolean
*/
private function bypass() {
}
/**
* Create install file
*
* @author KnowledgeTree Team
* @access private
* @param none
* @return void
*/
private function createInstallFile() {
touch("install");
}
/**
* Remove install file
*
* @author KnowledgeTree Team
* @access private
* @param none
* @return void
*/
private function removeInstallFile() {
unlink("install");
}
/**
* Load default values
*
* @author KnowledgeTree Team
* @access private
* @param none
* @return void
*/
function load() {
if(isset($_GET['bypass'])) {
$this->setBypass($_GET['bypass']);
}
$this->setIUtil(new InstallUtil());
}
/**
* Run pre-installation system checks
*
* @author KnowledgeTree Team
* @access public
* @param none
* @return void
*/
public function systemChecks() {
$res = $this->iutil->checkStructurePermissions();
if($res === true) return $res;
switch ($res) {
case "wizard":
return 'Installer directory is not writable
';
break;
case "/":
return 'System root is not writable
';
break;
default:
return true;
break;
}
return $res;
}
/**
* Control all requests to wizard
*
* @author KnowledgeTree Team
* @access public
* @param none
* @return void
*/
public function dispatch() {
$this->load();
if($this->getBypass() === "1") {
$this->removeInstallFile();
} elseif ($this->getBypass() === "0") {
$this->createInstallFile();
}
if(!$this->isSystemInstalled()) { // Check if the systems not installed
$response = $this->systemChecks();
if($response === true) {
$this->displayInstaller();
} else {
$this->displayInstaller($response);
}
} else {
// TODO: Die gracefully
echo "System has been installed Goto Login";
}
}
}
$ic = new InstallWizard();
$ic->dispatch();
?>