Source for file Installer.php
Documentation is available at Installer.php
* @package linea21.externals
* @subpackage Class Installer
* @author Vadim V. Gabriel <vadimg88@gmail.com> - modified by Simon Georget <simon@linea21.com>
* @link http://www.vadimg.co.il/
* @license GNU Lesser General Public License
/** Load the template class **/
require_once(INSTALLER_PATH . '/Installer_Template.php');
protected $lang = array();
if(isset ($_COOKIE['lang']) && $_COOKIE['lang'] != '')
if(isset ($_POST['lang']) && $_POST['lang'] != '' && $this->default_lang != $_POST['lang'])
$path = INSTALLER_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $_POST['lang'] . '.php';
$path = '../languages/' . $_POST['lang']. '/installer.utf-8.php';
require_once( '../languages/' . $this->default_lang. '/installer.utf-8.php' );
# Load the template class
$this->view->error($this->lang['L-01']);
$allwed_steps = array('index' => 'indexAction', 'db' => 'dbAction', 'cfg' => 'configAction', 'database' => 'dbTables', 'config' => 'configWrite', 'finish' => 'finishInstaller');
$this->$allwed_steps[$_POST['step']]($_POST);
$_SESSION = array(); // unset session
$this->view->vars = array('options' => $options);
$this->view->render('index');
* Show database setup stuff
$this->view->render('db');
$this->view->vars = array('root_url' => $root_url, 'path' => $root_path);
$this->view->render('config');
public function dbTables(array $options)
# Make sure we have an array of options
$this->view->error($this->lang['L-02']);
# Make sure we have everything we need!
$required_db_options = array('dbtype', 'dbname', 'dbuser', 'dbpass', 'dbhost');
foreach ($required_db_options as $required_db_option)
if(isset ($_SESSION[$required_db_option])) unset ($_SESSION[$required_db_option]);
$_SESSION[$required_db_option] = $options[$required_db_option];
if(!isset ($options[$required_db_option]))
$this->view->error($this->lang['L-03']);
# Pass in to the options property
if($this->_options['dbtype']== 'mysql') {
# First test the connection
$this->view->error($this->lang['L-04']);
if(!$db_selected && $this->_options['create_database']== 0)
$this->view->error($this->lang['L-05']);
elseif (!$db_selected && $this->_options['create_database']== 1)
$result = mysql_query("CREATE DATABASE {$this->_options['dbname']}", $link);
} elseif($this->_options['dbtype']== 'pgsql') {
$this->view->error($this->lang['L-04']);
# Load the database stuff
require_once( '../languages/' . $this->default_lang. '/installer_input.utf-8.php' );
$path = INSTALLER_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'database.php' ;
$error_string = "<br /><br />". sprintf($this->lang['I-14'], implode("<br /><br />", $errors));
$this->view->vars = array('message' => sprintf($this->lang['L-09'], $count, $errors_count, $error_string), 'button' => $error_string ? $this->lang['I-16'] : $this->lang['I-03']);
$this->view->render('dbdone');
* Write the configuration File
include_once('../class/class.config_file.php');
$ini_db['DB_NAME']= $_SESSION['dbname'];
$ini_db['DB_USER']= $_SESSION['dbuser'];
$ini_db['DB_PASS']= $_SESSION['dbpass'];
$ini_db['DB_HOST']= $_SESSION['dbhost'];
else $ini_r['DATE_FORMAT']= "dd-mm-yyyy";
$ini_r['SITE_NAME']= $_POST['SITE_NAME'];
$ini_r['SITE_PATH']= $_POST['SITE_PATH'];
$ini_r['SITE_ROOT_URL']= $_POST['SITE_ROOT_URL'];
$ini_r['SITE_MAIL']= $_POST['MAIL_FROM'];
$ini_r['MAIL_FROM']= $_POST['MAIL_FROM'];
$ini_r['MAIL_FROMNAME']= $_POST['MAIL_FROMNAME'];
$ini_r['MAIL_REPLY']= $_POST['MAIL_FROM'];
$ini_r['MAIL_REPLYNAME']= $_POST['MAIL_FROMNAME'];
$ini_r['SQL']= $_SESSION['dbtype'];
$config_file->setParams('define_release',$ini_r);
$config_file->setParams('define_db',$ini_db);
$config_file->writeDbParams();
$config_file->writeReleaseParams();
* Finish the installer proccess
$path = INSTALLER_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'installer.lock';
$this->view->render('finish');
* Redirect to the next step
print "<html><body><meta http-equiv='refresh' content='1;url={$url}'></body></html>";
* Redirect screen with a message
$this->view->redirect($message, $step);
|