Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Mon, Sep 22, 7:11 PM

in-portal

Index: trunk/core/install/steps_db.xml
===================================================================
--- trunk/core/install/steps_db.xml (revision 6690)
+++ trunk/core/install/steps_db.xml (revision 6691)
@@ -1,28 +1,43 @@
<steps>
<step name="db_config" title="Database Configuration">
<![CDATA[Host name (<i>normally "localhost"</i>), Database user name, and database Password.
These fields are required to connect to the database.</p><p>If you would like In-Portal
to use a table prefix, enter it in the field provided. This prefix can be any
text which can be used in the names of tables on your system. The characters entered in this field
are placed <i>before</i> the names of the tables used by In-Portal. For example, if you enter "inp_"
into the prefix field, the table named Category will be named inp_Category.</p>]]>
</step>
<step name="root_password" title="Set Root Password" help_title="Set Admin Root Password">
<![CDATA[<p>The Root Password is initially required to access the admin sections of In-Portal.
The root user cannot be used to access the front-end of the system, so it is recommended that you
create additional users with admin privlidges.</p>]]>
</step>
- <step name="choose_modules" title="Select Modules">
+ <step name="choose_modules" title="Select Modules to Install">
<![CDATA[<p>Select the In-Portal modules you wish to install. The modules listed to the right
are all modules included in this installation that are licensed to run on this server. </p>]]>
</step>
<step name="check_paths" title="Filesystem Check">
<![CDATA[<b>Write</b><br />Shows folder and files, that write permissions should be adjusted
to allow web server to write data into them.]]>
</step>
<step name="finish" title="Installation Complete" help_title="Thank You!">
<![CDATA[<p>Thanks for using In-Portal! Be sure to visit <a target="_new" href="http://www.in-portal.net">www.in-portal.net</a>
for the latest news, module releases and support. </p>
<p>*Make sure to clean your browser' cache after upgrading In-portal version</p>]]>
</step>
+ <step name="install_setup" title="Installation Maintenance">
+ <![CDATA[<p>A Configuration file has been detected on your system and it appears In-Portal is correctly installed.
+ In order to work with the maintenance functions provided to the left you must provide the Intechnic
+ Username and Password you used when obtaining the license file residing on the server, or your admin Root password.
+ <i>(Use Username 'root' if using your root password)</i></p>
+ <p>To removing your existing database and start with a fresh installation, select the first option
+ provided. Note that this operation cannot be undone and no backups are made! Use at your own risk.</p>
+ <p>If you wish to scrap your current installation and install to a new location, choose the second option.
+ If this option is selected you will be prompted for new database configuration information.</p>
+ <p>The <i>Update License Information</i> option is used to update your In-Portal license data. Select this option if you have
+ modified your licensing status with Intechnic, or you have received new license data via email</p>
+ <p>The <i>Fix Paths</i> option should be used when the location of the In-portal files has changed.
+ For example, if you moved them from one folder to another. It will update all settings and ensure the
+ program is operational at the new location.</p>]]>
+ </step>
</steps>
\ No newline at end of file
Property changes on: trunk/core/install/steps_db.xml
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/core/install/step_templates/root_password.tpl
===================================================================
--- trunk/core/install/step_templates/root_password.tpl (nonexistent)
+++ trunk/core/install/step_templates/root_password.tpl (revision 6691)
@@ -0,0 +1,16 @@
+<tr class="table_color2">
+ <td class="text">
+ <b>Root Password<span class="error">*</span>:</b>
+ </td>
+ <td>
+ <input type="password" name="root_password" class="text">
+ </td>
+</tr>
+<tr class="table_color2">
+ <td class="text">
+ <b>Confirm Root Password<span class="error">*</span>:</b>
+ </td>
+ <td>
+ <input type="password" name="root_password_verify" class="text">
+ </td>
+</tr>
\ No newline at end of file
Property changes on: trunk/core/install/step_templates/root_password.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/core/install/step_templates/install_setup.tpl
===================================================================
--- trunk/core/install/step_templates/install_setup.tpl (nonexistent)
+++ trunk/core/install/step_templates/install_setup.tpl (revision 6691)
@@ -0,0 +1,51 @@
+<tr class="table_color2">
+ <td colspan="2">
+ In order to use the installation tool, please provide your Intechnic account information:
+ </td>
+</tr>
+<tr class="table_color2">
+ <td class="text">
+ <b>Username<span class="error">*</span>:</b>
+ </td>
+ <td width="80%">
+ <input type="text" name="user_name" value="<?php $this->GetVar('user_name'); ?>" class="text" />
+ </td>
+</tr>
+<tr class="table_color2">
+ <td class="text">
+ <b>Password<span class="error">*</span>:</b>
+ </td>
+ <td>
+ <input type="password" name="user_password" class="text" />
+ </td>
+</tr>
+
+<?php
+ ob_start();
+?>
+<tr class="%4$s">
+ <td colspan="2">
+ <input type="radio" value="%1$s" name="inp_opt" id="inp_opt_%1$s"%2$s><label for="inp_opt_%1$s">%3$s</label></span>
+ </td>
+</tr>
+<?php
+ $option_tpl = ob_get_clean();
+
+ $options = Array (
+ 6 => 'Upgrade In-Portal',
+ 1 => 'Clean out the In-Portal database and reinstall',
+ 4 => 'Clean out the In-Portal database and reinstall from backup',
+ 2 => 'Install to a new database',
+ 3 => 'Update License Information',
+ 5 => 'Change Database Configuration',
+ 7 => 'Fix Paths',
+ );
+
+ $td_class = 'table_color1';
+ foreach ($options as $option_key => $option_title) {
+ $checked = $this->GetVar('inp_opt') == $option_key ? ' checked' : '';
+ echo sprintf($option_tpl, $option_key, $checked, $option_title, $td_class);
+ $td_class = ($td_class == 'table_color1') ? 'table_color2' : 'table_color1';
+ }
+
+?>
\ No newline at end of file
Property changes on: trunk/core/install/step_templates/install_setup.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/core/install/step_templates/choose_modules.tpl
===================================================================
--- trunk/core/install/step_templates/choose_modules.tpl (nonexistent)
+++ trunk/core/install/step_templates/choose_modules.tpl (revision 6691)
@@ -0,0 +1,16 @@
+<?php
+ ob_start();
+?>
+<tr class="table_color2">
+ <td class="text" colspan="2" valign="middle">
+ <input type="checkbox" name="modules[]" id="module_%1$s" value="%1$s"/><label for="module_%1$s">%1$s</label>
+ </td>
+</tr>
+<?php
+ $module_tpl = ob_get_clean();
+
+ $modules = $this->ScanModules();
+ foreach ($modules as $module) {
+ echo sprintf($module_tpl, $module);
+ }
+?>
\ No newline at end of file
Property changes on: trunk/core/install/step_templates/choose_modules.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/core/install/step_templates/db_config.tpl
===================================================================
--- trunk/core/install/step_templates/db_config.tpl (nonexistent)
+++ trunk/core/install/step_templates/db_config.tpl (revision 6691)
@@ -0,0 +1,51 @@
+<tr class="table_color2">
+ <td class="text"><b>Server Type<span class="error">*</span>:</b></td>
+ <td align="left">
+ <select name="DBType">
+ <?php
+ $options = Array ('mysql' => 'MySQL', /*'mssql' => 'MS-SQL Server', 'pgsql' => 'pgSQL'*/);
+ $option_tpl = '<option value="%1$s"%2$s>%3$s</option>'."\n";
+
+ foreach ($options as $option_key => $option_title) {
+ $selected = $option_key == $this->systemConfig['Database']['DBType'] ? ' selected' : '';
+ echo sprintf($option_tpl, $option_key, $selected, $option_title);
+ }
+ ?>
+ </select>
+ </td>
+</tr>
+
+<tr class="table_color2">
+ <td class="text"><b>Hostname<span class="error">*</span>:</b></td>
+ <td align="left">
+ <input type="text" name="DBHost" class="text" value="<?php echo $this->systemConfig['Database']['DBHost']; ?>" />
+ </td>
+</tr>
+
+<tr class="table_color2">
+ <td class="text"><b>Database Name<span class="error">*</span>:</b></td>
+ <td align="left">
+ <input type="text" name="DBName" class="text" value="<?php echo $this->systemConfig['Database']['DBName']; ?>" />
+ </td>
+</tr>
+
+<tr class="table_color2">
+ <td class="text"><b>Database User Name<span class="error">*</span>:</b></td>
+ <td align="left">
+ <input type="text" name="DBUser" class="text" value="<?php echo $this->systemConfig['Database']['DBUser']; ?>" />
+ </td>
+</tr>
+
+<tr class="table_color2">
+ <td class="text"><b>Database User Password:</b></td>
+ <td align="left">
+ <input type="password" name="DBUserPassword" class="text" value="<?php echo $this->systemConfig['Database']['DBUserPassword']; ?>" />
+ </td>
+</tr>
+
+<tr class="table_color2">
+ <td class="text"><b>Table Name Prefix:</b></td>
+ <td align="left">
+ <input type="text" name="TablePrefix" class="text" maxlength="7" value="<?php echo $this->systemConfig['Database']['TablePrefix']; ?>" />
+ </td>
+</tr>
\ No newline at end of file
Property changes on: trunk/core/install/step_templates/db_config.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/core/install/step_templates/check_paths.tpl
===================================================================
--- trunk/core/install/step_templates/check_paths.tpl (nonexistent)
+++ trunk/core/install/step_templates/check_paths.tpl (revision 6691)
@@ -0,0 +1,16 @@
+<?php
+ ob_start();
+?>
+<tr class="table_color2">
+ <td class="text"><b>%s</b></td>
+ <td align="left">%s</td>
+</tr>
+<?php
+ $folder_tpl = ob_get_clean();
+
+ foreach ($this->writeableFolders as $folder_path) {
+ $file_path = FULL_PATH.$folder_path;
+ $folder_status = is_writable($file_path) ? 'OK' : '<span class="error">FAILED</span>';
+ echo sprintf($folder_tpl, $file_path, $folder_status);
+ }
+?>
\ No newline at end of file
Property changes on: trunk/core/install/step_templates/check_paths.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/core/install/step_templates/finish.tpl
===================================================================
--- trunk/core/install/step_templates/finish.tpl (nonexistent)
+++ trunk/core/install/step_templates/finish.tpl (revision 6691)
@@ -0,0 +1,7 @@
+<tr class="table_color2">
+ <td align="left" class="text" colspan="2">
+ In-portal has successfully been installed on your server.
+ Click the button below to log into the site administration
+ using the root password you just configured.<br />
+ </td>
+</tr>
\ No newline at end of file
Property changes on: trunk/core/install/step_templates/finish.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/core/install.php
===================================================================
--- trunk/core/install.php (revision 6690)
+++ trunk/core/install.php (revision 6691)
@@ -1,897 +1,831 @@
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
define('IS_INSTALL', 1);
define('FULL_PATH', realpath(dirname(__FILE__).'/..') );
define('REL_PATH', '/core');
// print_pre($_POST);
$install_engine = new kInstallator();
$install_engine->Init();
$install_engine->Run();
$install_engine->Done();
class kInstallator {
/**
* Reference to kApplication class object
*
* @var kApplication
*/
var $Application = null;
/**
* Connection to database
*
* @var kDBConnection
*/
var $Conn = null;
/**
* Path to config.php
*
* @var string
*/
var $INIFile = '';
/**
* XML file containing steps information
*
* @var string
*/
var $StepDBFile = '';
/**
* Parsed data from config.php
*
* @var Array
*/
var $systemConfig = Array ();
/**
* Step name, that currently being processed
*
* @var string
*/
var $currentStep = '';
/**
* Steps list (preset) to use for current installation
*
* @var string
*/
var $stepsPreset = '';
/**
* Installtion steps to be done
*
* @var Array
*/
var $steps = Array(
'fresh_install' => Array ('check_paths', 'db_config', 'root_password', 'choose_modules', 'finish'),
- 'already_installed' => Array ('installed_select', 'finish'),
+ 'already_installed' => Array ('install_setup'),
+
+ 'upgrade' => Array ('install_setup',/* ..., */ 'finish'),
+ 'db_reconfig' => Array ('install_setup',/* ..., */ 'finish'),
+ 'fix_paths' => Array ('install_setup',/* ..., */ 'finish'),
);
/**
* Steps, on which kApplication should not be initialized, because of missing correct db table structure
*
* @var Array
*/
- var $skipApplicationSteps = Array ('check_paths', 'db_config');
+ var $skipApplicationSteps = Array ('check_paths', 'db_config', 'install_setup'); // remove install_setup when application will work separately from install
/**
* Folders that should be writeable to continue installation
*
* @var Array
*/
var $writeableFolders = Array ('/', '/system');
/**
* Contains last error message text
*
* @var string
*/
var $errorMessage = '';
/**
* Base path for includes in templates
*
* @var string
*/
var $baseURL = '';
function Init()
{
$this->INIFile = FULL_PATH.'/config.php';
$this->StepDBFile = FULL_PATH.'/'.REL_PATH.'/install/steps_db.xml';
+ $base_path = rtrim(preg_replace('/'.preg_quote(rtrim(REL_PATH, '/'), '/').'$/', '', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']))), '/');
+ $this->baseURL = 'http://'.$_SERVER['HTTP_HOST'].$base_path.'/core/install/';
+
set_error_handler( Array(&$this, 'ErrorHandler') );
if (file_exists($this->INIFile)) {
// if config.php found, then check his write permission too
$this->writeableFolders[] = '/config.php';
}
+ $this->systemConfig = $this->ParseConfig(true);
+ $this->systemConfig['Misc']['WriteablePath'] = '/system'; // for development purposes
+
$this->currentStep = $this->GetVar('step');
- if (!$this->stepsPreset) {
- $this->stepsPreset = 'fresh_install';
- }
+ $this->SelectPreset();
if (!$this->currentStep) {
// first step of current preset
reset($this->steps[$this->stepsPreset]);
$this->currentStep = current($this->steps[$this->stepsPreset]);
}
- $this->systemConfig = $this->ParseConfig(true);
-
- $this->systemConfig['Misc']['WriteablePath'] = '/system'; // for development purposes
-
$this->InitStep();
+ }
+
+ /**
+ * Selects preset to proceed based on various criteria
+ *
+ */
+ function SelectPreset()
+ {
+ $preset = 'fresh_install';
- $base_path = rtrim(preg_replace('/'.preg_quote(rtrim(REL_PATH, '/'), '/').'$/', '', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']))), '/');
- $this->baseURL = 'http://'.$_SERVER['HTTP_HOST'].$base_path.'/core/install/';
+ if (file_exists($this->INIFile) && $this->GetVar('step') === false) {
+ // only at installation first step
+ $status = $this->CheckDatabase(false);
+ if ($status && $this->AlreadyInstalled()) {
+ $preset = 'already_installed';
+ }
+ }
+
+ $this->stepsPreset = $preset;
}
function GetVar($name)
{
return isset($_REQUEST[$name]) ? $_REQUEST[$name] : false;
}
/**
* Performs needed intialization of data, that step requires
*
*/
function InitStep()
{
- $go_next = $this->GetVar('step') === false ? false : true;
-
$this->InitApplication();
switch ($this->currentStep) {
case 'check_paths':
foreach ($this->writeableFolders as $folder_path) {
$file_path = FULL_PATH.$folder_path;
if (!is_writable($file_path)) {
- $go_next = false;
$this->errorMessage = 'Install cannot write to specified folder in the root directory of your installation';
break;
}
}
break;
case 'db_config':
$section_name = 'Database';
$fields = Array ('DBType', 'DBHost', 'DBName', 'DBUser', 'DBUserPassword', 'TablePrefix');
if (!isset($this->systemConfig[$section_name])) {
$this->systemConfig[$section_name] = Array ();
}
// set fields
foreach ($fields as $field_name) {
$submit_value = $this->GetVar($field_name);
if ($submit_value !== false) {
$this->systemConfig[$section_name][$field_name] = $submit_value;
}
elseif (!isset($this->systemConfig[$section_name][$field_name])) {
$this->systemConfig[$section_name][$field_name] = '';
}
}
break;
+
+ case 'choose_modules':
+ // if no modules found, then proceed to next step
+ $modules = $this->ScanModules();
+ if (!$modules) {
+ $this->currentStep = $this->GetNextStep();
+ }
+ break;
+
+ case 'install_setup':
+ $next_preset = $this->GetVar('preset');
+ if (!$next_preset) {
+ // if preset was not choosen, then raise error
+ $this->errorMessage = 'Please select action to perform';
+ }
+ else {
+ // if preset was choosen, then check root password entered
+ }
+ break;
}
$this->PerformValidation(); // returns validation status (just in case)
}
/**
* Validates data entered by user
*
* @return bool
*/
function PerformValidation()
{
if ($this->GetVar('step') != $this->currentStep) {
// just redirect from previous step, don't validate
return true;
}
$status = true;
switch ($this->currentStep) {
case 'db_config':
// 1. check if required fields are filled
$section_name = 'Database';
$required_fields = Array ('DBType', 'DBHost', 'DBName', 'DBUser');
foreach ($required_fields as $required_field) {
if (!$this->systemConfig[$section_name][$required_field]) {
$status = false;
$this->errorMessage = 'Please fill all required fields';
break;
}
}
if (!$status) break;
// 2. check permissions, that use have in this database
- $status = $this->CheckDatabase(true);
+ $status = $this->CheckDatabase();
break;
case 'root_password':
// check, that password & verify password match
$password = $this->Application->GetVar('root_password');
$password_verify = $this->Application->GetVar('root_password_verify');
if ($password != $password_verify) {
$this->errorMessage = 'Passwords does not match';
}
elseif (strlen($password) < 4) {
$this->errorMessage = 'Root Password must be at least 4 characters';
}
$status = $this->errorMessage == '';
break;
}
return $status;
}
/**
* Perform installation step actions
*
*/
function Run()
{
if ($this->errorMessage) {
// was error during data validation stage
return ;
}
switch ($this->currentStep) {
case 'db_config':
// store db configuration
$this->SaveConfig();
// import base data into database
$this->RunSQL('/core/install/install_schema.sql');
$this->RunSQL('/core/install/install_data.sql');
break;
case 'root_password':
// update root password in database
$password = md5( md5($this->Application->GetVar('root_password')) . 'b38');
$sql = 'UPDATE '.TABLE_PREFIX.'ConfigurationValues
SET VariableValue = '.$this->Conn->qstr($password).'
WHERE VariableName = "RootPass"';
$this->Conn->Query($sql);
// import base language for core (english)
$this->ImportLanguage('/core/install/english');
break;
case 'choose_modules':
$modules = $this->Application->GetVar('modules');
foreach ($modules as $module) {
$install_file = MODULES_PATH.'/'.$module.'/install.php';
if (file_exists($install_file)) {
include_once($install_file);
}
}
break;
}
if ($this->errorMessage) {
// was error during run stage
return ;
}
$this->currentStep = $this->GetNextStep();
$this->InitStep(); // init next step (that will be shown now)
$this->InitApplication();
if ($this->currentStep == -1) {
// step after last step -> redirect to admin
$this->Application->Redirect('index', null, '', 'admin/index.php');
}
}
function InitApplication()
{
if (!in_array($this->currentStep, $this->skipApplicationSteps) && !isset($this->Application)) {
// step is allowed for application usage & it was not initialized in previous step
global $debugger;
include_once(FULL_PATH.'/core/kernel/startup.php');
$this->Application =& kApplication::Instance();
$this->Application->Init();
$this->Conn =& $this->Application->GetADODBConnection();
}
}
/**
* Show next step screen
*
*/
function Done($error_message = null)
{
if (isset($error_message)) {
$this->errorMessage = $error_message;
}
include_once (FULL_PATH.'/'.REL_PATH.'/install/incs/install.tpl');
if (isset($this->Application)) {
$this->Application->Done();
echo 'SID: ['.$this->Application->GetSID().']<br />';
}
exit;
}
function GetModuleVersion($module_name)
{
return '0.1.1';
}
function ConnectToDatabase()
{
include_once FULL_PATH.'/core/kernel/db/db_connection.php';
$this->Conn = new kDBConnection($this->systemConfig['Database']['DBType'], Array(&$this, 'DBErrorHandler'));
$this->Conn->Connect($this->systemConfig['Database']['DBHost'], $this->systemConfig['Database']['DBUser'], $this->systemConfig['Database']['DBUserPassword'], $this->systemConfig['Database']['DBName']);
return $this->Conn->errorCode == 0;
}
- function CheckDatabase($check_installed = false)
+ /**
+ * Checks if core is already installed
+ *
+ * @return bool
+ */
+ function AlreadyInstalled()
+ {
+ return $this->TableExists('ConfigurationAdmin'); //,Category,Permissions');
+ }
+
+ function CheckDatabase($check_installed = true)
{
// perform various check type to database specified
// 1. user is allowed to connect to database
// 2. user has all types of permissions in database
if (strlen($this->systemConfig['Database']['TablePrefix']) > 7) {
$this->errorMessage = 'Table prefix should not be longer than 7 characters';
return false;
}
// connect to database
$status = $this->ConnectToDatabase();
if ($status) {
// if connected, then check if all sql statements work
$sql_tests[] = 'DROP TABLE IF EXISTS test_table';
$sql_tests[] = 'CREATE TABLE test_table(test_col mediumint(6))';
$sql_tests[] = 'LOCK TABLES test_table WRITE';
$sql_tests[] = 'INSERT INTO test_table(test_col) VALUES (5)';
$sql_tests[] = 'UPDATE test_table SET test_col = 12';
$sql_tests[] = 'UNLOCK TABLES';
$sql_tests[] = 'ALTER TABLE test_table ADD COLUMN new_col varchar(10)';
$sql_tests[] = 'SELECT * FROM test_table';
$sql_tests[] = 'DELETE FROM test_table';
$sql_tests[] = 'DROP TABLE IF EXISTS test_table';
foreach ($sql_tests as $sql_test) {
$this->Conn->Query($sql_test);
if ($this->Conn->getErrorCode() != 0) {
$status = false;
break;
}
}
if ($status) {
// if statements work & connection made, then check table existance
- $already_installed = $this->TableExists('ConfigurationAdmin,Category,Permissions');
-
- if ($check_installed && $already_installed) {
- // already installed at that location
- $this->errorMessage = 'An In-Portal Database already exists at this location'; // : 'An In-Portal Database was not found at this location';
+ if ($check_installed && $this->AlreadyInstalled()) {
+ $this->errorMessage = 'An In-Portal Database already exists at this location';
return false;
}
}
else {
// user has insufficient permissions in database specified
$db_error = 'Permission Error: ('.$this->Conn->getErrorCode().') '.$this->Conn->getErrorMsg();
return false;
}
}
else {
// was error while connecting
$this->errorMessage = 'Connection Error: ('.$this->Conn->getErrorCode().') '.$this->Conn->getErrorMsg();
return false;
}
return true;
}
/**
* Checks if all passed tables exists
*
* @param string $tables comma separated tables list
* @return bool
*/
function TableExists($tables)
{
$prefix = $this->systemConfig['Database']['TablePrefix'];
$all_found = true;
$tables = explode(',', $tables);
foreach ($tables as $table_name) {
$sql = 'SHOW TABLES LIKE "'.$prefix.$table_name.'"';
if (count($this->Conn->Query($sql)) == 0) {
$all_found = false;
break;
}
}
return $all_found;
}
function RunSQL($filename, $replace_from = null, $replace_to = null)
{
if (!file_exists(FULL_PATH.$filename)) {
return ;
}
$sqls = file_get_contents(FULL_PATH.$filename);
$table_prefix = $this->systemConfig['Database']['TablePrefix'];
// add prefix to all tables
if (strlen($table_prefix) > 0) {
$replacements = Array ('CREATE TABLE ', 'INSERT INTO ', 'UPDATE ', 'ALTER TABLE ');
foreach ($replacements as $replacement) {
$sqls = str_replace($replacement, $replacement.$table_prefix, $sqls);
}
$sqls = str_replace('DROP TABLE ', 'DROP TABLE IF EXISTS '.$table_prefix, $sqls);
}
if (isset($replace_from) && isset($replace_to)) {
// replace something additionally, e.g. module root category
$sqls = str_replace($replace_from, $replace_to, $sqls);
}
$sqls = explode(";\n", $sqls);
foreach ($sqls as $sql) {
$sql = trim($sql);
if (!$sql || substr($sql, 0, 1) == '#') {
continue; // usually last line || comment
}
$this->Conn->Query($sql);
if ($this->Conn->getErrorCode() != 0) {
$this->errorMessage = 'Error: ('.$this->Conn->getErrorCode().') '.$this->Conn->getErrorMsg().'<br /><br />Database Query:<pre>'.htmlspecialchars($sql).'</pre>';
$this->Done();
break;
}
}
}
function ImportLanguage($lang_file)
{
$lang_file = FULL_PATH.$lang_file.'.lang';
if (!file_exists($lang_file)) {
return ;
}
$lang_xml =& $this->Application->recallObjectP('LangXML', null, Array(), false); // false - don't use temp tables
$lang_xml->Parse($lang_file, '|0|1|2|', '');
}
/**
+ * Returns modules list found in modules folder
+ *
+ * @return Array
+ */
+ function ScanModules()
+ {
+ static $modules = null;
+
+ if (!isset($modules)) {
+ $modules = Array();
+ $fh = opendir(MODULES_PATH);
+ while (($sub_folder = readdir($fh))) {
+ $folder_path = MODULES_PATH.'/'.$sub_folder;
+ if ($sub_folder != '.' && $sub_folder != '..' && is_dir($folder_path)) {
+ if ($sub_folder == 'core') {
+ // skip modules here
+ continue;
+ }
+ // this is folder in MODULES_PATH directory
+ if (file_exists($folder_path.'/install.php') && file_exists($folder_path.'/install/install_schema.sql')) {
+ $modules[] = $sub_folder;
+ }
+ }
+ }
+ }
+
+ return $modules;
+ }
+
+ /**
* Returns content to show for current step
*
* @return string
*/
function GetStepBody()
{
- ob_start();
- switch ($this->currentStep) {
- case 'check_paths':
- ?>
- <tr class="table_color2">
- <td class="text"><b>%s</b></td>
- <td align="left">%s</td>
- </tr>
- <?
- $folder_tpl = ob_get_clean();
-
- ob_start();
- foreach ($this->writeableFolders as $folder_path) {
- $file_path = FULL_PATH.$folder_path;
- $folder_status = is_writable($file_path) ? 'OK' : '<span class="error">FAILED</span>';
- echo sprintf($folder_tpl, $file_path, $folder_status);
- }
- break;
-
- case 'db_config':
- ?>
- <tr class="table_color2">
- <td class="text"><b>Server Type<span class="error">*</span>:</b></td>
- <td align="left">
- <select name="DBType">
- <?php
- $options = Array ('mysql' => 'MySQL', /*'mssql' => 'MS-SQL Server', 'pgsql' => 'pgSQL'*/);
- $option_tpl = '<option value="%1$s"%2$s>%3$s</option>'."\n";
-
- foreach ($options as $option_key => $option_title) {
- $selected = $option_key == $this->systemConfig['Database']['DBType'] ? ' selected' : '';
- echo sprintf($option_tpl, $option_key, $selected, $option_title);
- }
- ?>
- </select>
- </td>
- </tr>
-
- <tr class="table_color2">
- <td class="text"><b>Hostname<span class="error">*</span>:</b></td>
- <td align="left">
- <input type="text" name="DBHost" class="text" value="<?php echo $this->systemConfig['Database']['DBHost']; ?>" />
- </td>
- </tr>
-
- <tr class="table_color2">
- <td class="text"><b>Database Name<span class="error">*</span>:</b></td>
- <td align="left">
- <input type="text" name="DBName" class="text" value="<?php echo $this->systemConfig['Database']['DBName']; ?>" />
- </td>
- </tr>
-
- <tr class="table_color2">
- <td class="text"><b>Database User Name<span class="error">*</span>:</b></td>
- <td align="left">
- <input type="text" name="DBUser" class="text" value="<?php echo $this->systemConfig['Database']['DBUser']; ?>" />
- </td>
- </tr>
-
- <tr class="table_color2">
- <td class="text"><b>Database User Password:</b></td>
- <td align="left">
- <input type="password" name="DBUserPassword" class="text" value="<?php echo $this->systemConfig['Database']['DBUserPassword']; ?>" />
- </td>
- </tr>
-
- <tr class="table_color2">
- <td class="text"><b>Table Name Prefix:</b></td>
- <td align="left">
- <input type="text" name="TablePrefix" class="text" maxlength="7" value="<?php echo $this->systemConfig['Database']['TablePrefix']; ?>" />
- </td>
- </tr>
- <?php
- break;
-
- case 'root_password':
- ?>
- <tr class="table_color2">
- <td class="text">
- <b>Root Password:</b>
- </td>
- <td>
- <input type="password" name="root_password" class="text">
- </td>
- </tr>
- <tr class="table_color2">
- <td class="text">
- <b>Confirm Root Password:</b>
- </td>
- <td>
- <input type="password" name="root_password_verify" class="text">
- </td>
- </tr>
- <?php
- break;
-
- case 'choose_modules':
- ?>
- <tr class="table_color2">
- <td class="text" colspan="2" valign="middle">
- <input type="checkbox" name="modules[]" id="module_%1$s" value="%1$s"/><label for="module_%1$s">%1$s</label>
- </td>
- </tr>
- <?php
-
- $module_tpl = ob_get_clean();
-
- ob_start();
- // scan MODULES_PATH for available modules
- $modules = Array ();
- $fh = opendir(MODULES_PATH);
- while (($sub_folder = readdir($fh))) {
- $folder_path = MODULES_PATH.'/'.$sub_folder;
- if ($sub_folder != '.' && $sub_folder != '..' && is_dir($folder_path)) {
- if ($sub_folder == 'core') {
- // skip modules here
- continue;
- }
- // this is folder in MODULES_PATH directory
- if (file_exists($folder_path.'/install.php') && file_exists($folder_path.'/install/install_schema.sql')) {
- $modules[] = $sub_folder;
- }
- }
- }
-
-
-
- foreach ($modules as $module) {
- echo sprintf($module_tpl, $module);
- }
-
- break;
-
- case 'finish':
- ?>
- <tr class="table_color2">
- <td align="left" class="text" colspan="2">
- In-portal has successfully been installed on your server.
- Click the button below to log into the site administration
- using the root password you just configured.<br />
- </td>
- </tr>
- <?php
- break;
+ $step_template = FULL_PATH.'/core/install/step_templates/'.$this->currentStep.'.tpl';
+ if (file_exists($step_template)) {
+ ob_start();
+ include_once ($step_template);
+ return ob_get_clean();
}
- return ob_get_clean();
+ return '{step template "'.$this->currentStep.'" missing}';
}
/**
* Parses step information file, cache result for current step ONLY & return it
*
* @return Array
*/
function &_getStepInfo()
{
static $info = Array('help_title' => null, 'step_title' => null, 'help_body' => null, 'queried' => false);
if (!$info['queried']) {
$fdata = file_get_contents($this->StepDBFile);
$parser = xml_parser_create();
xml_parse_into_struct($parser, $fdata, $values, $index);
xml_parser_free($parser);
foreach ($index['STEP'] as $section_index) {
$step_data =& $values[$section_index];
if ($step_data['attributes']['NAME'] == $this->currentStep) {
$info['step_title'] = $step_data['attributes']['TITLE'];
if (isset($step_data['attributes']['HELP_TITLE'])) {
$info['help_title'] = $step_data['attributes']['HELP_TITLE'];
}
else {
// if help title not set, then use step title
$info['help_title'] = $step_data['attributes']['TITLE'];
}
$info['help_body'] = trim($step_data['value']);
break;
}
}
$info['queried'] = true;
}
return $info;
}
/**
* Returns particular information abou current step
*
* @param string $info_type
* @return string
*/
function GetStepInfo($info_type)
{
$step_info =& $this->_getStepInfo();
if (isset($step_info[$info_type])) {
return $step_info[$info_type];
}
return '{step "'.$this->currentStep.'"; param "'.$info_type.'" missing}';
}
/**
* Returns passed steps titles
*
* @param Array $steps
* @return Array
* @see kInstaller:PrintSteps
*/
function _getStepTitles($steps)
{
$fdata = file_get_contents($this->StepDBFile);
$parser = xml_parser_create();
xml_parse_into_struct($parser, $fdata, $values, $index);
xml_parser_free($parser);
$ret = Array ();
foreach ($index['STEP'] as $section_index) {
$step_data =& $values[$section_index];
if (in_array($step_data['attributes']['NAME'], $steps)) {
$ret[ $step_data['attributes']['NAME'] ] = $step_data['attributes']['TITLE'];
}
}
return $ret;
}
/**
* Returns current step number in active steps_preset.
* Value can't be cached, because same step can have different number in different presets
*
* @return int
*/
function GetStepNumber()
{
return array_search($this->currentStep, $this->steps[$this->stepsPreset]) + 1;
}
/**
* Returns step name to process next
*
* @return string
*/
function GetNextStep()
{
$next_index = $this->GetStepNumber();
if ($next_index > count($this->steps[$this->stepsPreset]) - 1) {
return -1;
}
return $this->steps[$this->stepsPreset][$next_index];
}
/**
* Returns step name, that was processed before this step
*
* @return string
*/
function GetPreviousStep()
{
$next_index = $this->GetStepNumber() - 1;
if ($next_index < 0) {
$next_index = 0;
}
return $this->steps[$this->stepsPreset][$next_index];
}
/**
* Prints all steps from active steps preset and highlights current step
*
* @param string $active_tpl
* @param string $passive_tpl
* @return string
*/
function PrintSteps($active_tpl, $passive_tpl)
{
$ret = '';
$step_titles = $this->_getStepTitles($this->steps[$this->stepsPreset]);
foreach ($this->steps[$this->stepsPreset] as $step_name) {
$template = $step_name == $this->currentStep ? $active_tpl : $passive_tpl;
$ret .= sprintf($template, $step_titles[$step_name]);
}
return $ret;
}
function ParseConfig($parse_section = false)
{
if (!file_exists($this->INIFile)) {
return Array();
}
if( file_exists($this->INIFile) && !is_readable($this->INIFile) ) {
die('Could Not Open Ini File');
}
$contents = file($this->INIFile);
$retval = Array();
$section = '';
$ln = 1;
$resave = false;
foreach ($contents as $line) {
if ($ln == 1 && $line != '<'.'?'.'php die() ?'.">\n") {
$resave = true;
}
$ln++;
$line = trim($line);
$line = eregi_replace(';[.]*','',$line);
if (strlen($line) > 0) {
//echo $line . " - ";
if(eregi('^[[a-z]+]$',str_replace(' ', '', $line))) {
//echo 'section';
$section = substr($line, 1, (strlen($line) - 2));
if ($parse_section) {
$retval[$section] = array();
}
continue;
} elseif (eregi('=',$line)) {
//echo 'main element';
list ($key, $val) = explode(' = ', $line);
if (!$parse_section) {
$retval[trim($key)] = str_replace('"', '', $val);
}
else {
$retval[$section][trim($key)] = str_replace('"', '', $val);
}
}
}
}
if ($resave) {
$fp = fopen($this->INIFile, 'w');
reset($contents);
fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
foreach ($contents as $line) {
fwrite($fp,"$line");
}
fclose($fp);
}
return $retval;
}
function SaveConfig()
{
$fp = fopen($this->INIFile, 'w');
fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
foreach ($this->systemConfig as $section_name => $section_data) {
fwrite($fp, '['.$section_name."]\n");
foreach ($section_data as $key => $value) {
fwrite($fp, $key.' = "'.$value.'"'."\n");
}
fwrite($fp, "\n");
}
fclose($fp);
}
/**
* Installation error handler for sql errors
*
* @param int $code
* @param string $msg
* @param string $sql
* @return bool
* @access private
*/
function DBErrorHandler($code, $msg, $sql)
{
$this->errorMessage = 'Query: <br />'.htmlspecialchars($sql).'<br />execution result is error:<br />['.$code.'] '.$msg;
return true;
}
/**
* Installation error handler
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
* @param Array $errcontext
*/
function ErrorHandler($errno, $errstr, $errfile = '', $errline = '', $errcontext = '')
{
if ($errno == E_USER_ERROR) {
// only react on user fatal errors
$this->Done($errstr);
}
}
}
/*function print_pre($s)
{
echo '<pre>', print_r($s, true). '</pre>';
}*/
?>
\ No newline at end of file
Property changes on: trunk/core/install.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property

Event Timeline