Version 2.2.0 RC-1
This commit is contained in:
1 parent
f73f8bff6d
commit
22f1b963ee
1034 files changed
+178610
-70897
No files matched your search
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Board
|
||||
* Action controller for Adresses page
|
||||
*/
|
||||
|
||||
class action_address
|
||||
{
|
||||
var $install;
|
||||
|
||||
function action_address( & $install )
|
||||
{
|
||||
$this->install =& $install;
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
/* Check input? */
|
||||
if( $this->install->ipsclass->input['sub'] == 'check' )
|
||||
{
|
||||
/* Check Directory */
|
||||
if( ! ( is_dir( $this->install->ipsclass->input['install_dir'] ) ) )
|
||||
{
|
||||
$errors[] = 'The specified directory does not exist';
|
||||
}
|
||||
|
||||
/* Check URL */
|
||||
if( ! $this->install->ipsclass->input['install_dir'] )
|
||||
{
|
||||
$errors[] = 'You did not specify a URL';
|
||||
}
|
||||
|
||||
if( is_array( $errors ) )
|
||||
{
|
||||
$this->install->template->warning( $errors );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Save Form Data */
|
||||
$this->install->saved_data['install_dir'] = preg_replace( "#(//)$#", "", str_replace( '\\', '/', $this->install->ipsclass->input['install_dir'] ) . '/' );
|
||||
$this->install->saved_data['install_url'] = preg_replace( "#(//)$#", "", str_replace( '\\', '/', $this->install->ipsclass->input['install_url'] ) . '/' );
|
||||
|
||||
/* Next Action */
|
||||
$this->install->template->page_current = 'db';
|
||||
$this->install->ipsclass->input['sub'] = '';
|
||||
require_once( INS_ROOT_PATH . 'core/actions/db.php' );
|
||||
$action = new action_db( &$this->install );
|
||||
$action->run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Guess at directory */
|
||||
$dir = str_replace( 'installer', '' , getcwd() );
|
||||
$dir = str_replace( 'install' , '' , getcwd() );
|
||||
$dir = str_replace( '\\' , '/', $dir );
|
||||
|
||||
/* Guess at URL */
|
||||
$url = str_replace( "/installer/index.php" , "", $this->install->ipsclass->my_getenv('HTTP_REFERER') );
|
||||
$url = str_replace( "/installer/" , "", $url);
|
||||
$url = str_replace( "/installer" , "", $url);
|
||||
$url = str_replace( "/install/index.php" , "", $this->install->ipsclass->my_getenv('HTTP_REFERER') );
|
||||
$url = str_replace( "/install/" , "", $url);
|
||||
$url = str_replace( "/installr" , "", $url);
|
||||
$url = str_replace( "index.php" , "", $url);
|
||||
$url = preg_replace( "!\?(.+?)*!" , "", $url );
|
||||
$url = "{$url}/";
|
||||
|
||||
/* Page Output */
|
||||
$this->install->template->append( $this->install->template->address_page( $dir, $url ) );
|
||||
$this->install->template->next_action = '?p=address&sub=check';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Board
|
||||
* Action controller for admin page
|
||||
*/
|
||||
|
||||
class action_admin
|
||||
{
|
||||
var $install;
|
||||
|
||||
function action_admin( & $install )
|
||||
{
|
||||
$this->install =& $install;
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
/* Check input? */
|
||||
if( $this->install->ipsclass->input['sub'] == 'check' )
|
||||
{
|
||||
if( ! $this->install->ipsclass->input['username'] )
|
||||
{
|
||||
$errors[] = 'You must specify a username for the admin account';
|
||||
}
|
||||
|
||||
if( ! $this->install->ipsclass->input['password'] )
|
||||
{
|
||||
$errors[] = 'You must specify a password for the admin account';
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $this->install->ipsclass->input['password'] != $this->install->ipsclass->input['confirm_password'] )
|
||||
{
|
||||
$errors[] = 'The admin passwords did not match';
|
||||
}
|
||||
}
|
||||
|
||||
if( ! $this->install->ipsclass->input['email'] )
|
||||
{
|
||||
$errors[] = 'You must sepcify an email account for the admin account';
|
||||
}
|
||||
|
||||
if( is_array( $errors ) )
|
||||
{
|
||||
$this->install->template->warning( $errors );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Save Form Data */
|
||||
$this->install->saved_data['admin_user'] = $this->install->ipsclass->input['username'];
|
||||
$this->install->saved_data['admin_pass'] = $this->install->ipsclass->input['password'];
|
||||
$this->install->saved_data['admin_email'] = $this->install->ipsclass->input['email'];
|
||||
|
||||
/* Next Action */
|
||||
$this->install->template->page_current = 'install';
|
||||
require_once( INS_ROOT_PATH . 'core/actions/install.php' );
|
||||
$action = new action_install( &$this->install );
|
||||
$action->run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->install->template->append( $this->install->template->admin_page() );
|
||||
$this->install->template->next_action = '?p=admin&sub=check';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Board
|
||||
* Action controller for DB page
|
||||
*/
|
||||
|
||||
class action_db
|
||||
{
|
||||
var $install;
|
||||
|
||||
function action_db( & $install )
|
||||
{
|
||||
$this->install =& $install;
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
/* Check input? */
|
||||
if ( $this->install->ipsclass->input['sub'] == 'check' )
|
||||
{
|
||||
/* Make sure the fields were filled out */
|
||||
if ( ! $this->install->ipsclass->input['db_host'] || ! $this->install->ipsclass->input['db_name'] || ! $this->install->ipsclass->input['db_user'] )
|
||||
{
|
||||
$errors[] = 'You must fill out the form completely';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Error check
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array( $errors ) )
|
||||
{
|
||||
$this->install->template->warning( $errors );
|
||||
return;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Load DB driver..
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( INS_KERNEL_PATH . 'class_db_' . $this->install->saved_data['sql_driver'] . '.php' );
|
||||
|
||||
$classname = "db_driver_".$this->install->saved_data['sql_driver'];
|
||||
|
||||
$DB = new $classname;
|
||||
|
||||
$DB->obj['sql_database'] = $this->install->ipsclass->input['db_name'];
|
||||
$DB->obj['sql_user'] = $this->install->ipsclass->input['db_user'];
|
||||
$DB->obj['sql_pass'] = $_REQUEST['db_pass'];
|
||||
$DB->obj['sql_host'] = $this->install->ipsclass->input['db_host'];
|
||||
$DB->obj['sql_tbl_prefix'] = $this->install->ipsclass->input['db_pre'];
|
||||
|
||||
//--------------------------------------------------
|
||||
// Any "extra" configs required for this driver?
|
||||
//--------------------------------------------------
|
||||
|
||||
if ( file_exists( INS_ROOT_PATH.'sql/'.$this->install->saved_data['sql_driver'].'_install.php' ) )
|
||||
{
|
||||
require_once( INS_ROOT_PATH.'sql/'.$this->install->saved_data['sql_driver'].'_install.php' );
|
||||
|
||||
$extra_install = new install_extra();
|
||||
$extra_install->ipsclass =& $this->install->ipsclass;
|
||||
|
||||
$extra_install->install_form_process();
|
||||
|
||||
if ( count( $extra_install->errors ) )
|
||||
{
|
||||
$this->install->template->warning( implode( "<br />", $extra_install->errors ) );
|
||||
}
|
||||
|
||||
if ( is_array( $extra_install->info_extra ) and count( $extra_install->info_extra ) )
|
||||
{
|
||||
foreach( $extra_install->info_extra as $k => $v )
|
||||
{
|
||||
$this->install->saved_data[ '__sql__' . $k ] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array( $DB->connect_vars ) and count( $DB->connect_vars ) )
|
||||
{
|
||||
foreach( $DB->connect_vars as $k => $v )
|
||||
{
|
||||
$DB->connect_vars[ $k ] = $extra_install->info_extra[ $k ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Error check
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array( $errors ) )
|
||||
{
|
||||
$this->install->template->warning( $errors );
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------
|
||||
// Make CONSTANT
|
||||
//--------------------------------
|
||||
|
||||
define( 'SQL_DRIVER' , $this->install->saved_data['sql_driver'] );
|
||||
define( 'IPS_MAIN_DB_CLASS_LOADED', TRUE );
|
||||
|
||||
//--------------------------------
|
||||
// Try a DB connection
|
||||
//--------------------------------
|
||||
|
||||
$DB->return_die = 1;
|
||||
|
||||
if ( ! $DB->connect() )
|
||||
{
|
||||
$errors[] = $DB->error;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Error check
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array( $errors ) )
|
||||
{
|
||||
$this->install->template->warning( $errors );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Save Form Data */
|
||||
$this->install->saved_data['db_host'] = $this->install->ipsclass->input['db_host'];
|
||||
$this->install->saved_data['db_name'] = $this->install->ipsclass->input['db_name'];
|
||||
$this->install->saved_data['db_user'] = $this->install->ipsclass->input['db_user'];
|
||||
$this->install->saved_data['db_pass'] = $_REQUEST['db_pass'];
|
||||
$this->install->saved_data['db_pre'] = $this->install->ipsclass->input['db_pre'];
|
||||
$this->install->saved_data['_drop_tables'] = $this->install->ipsclass->input['_drop_tables'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Tables exist?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->install->saved_data['_drop_tables'] AND $DB->field_exists( 'id', 'members' ) )
|
||||
{
|
||||
/* Output */
|
||||
$this->install->saved_data['_show_overwrite'] = 1;
|
||||
$this->install->template->append( $this->install->template->db_page( $drivers ) );
|
||||
$this->install->template->next_action = '?p=db&sub=check';
|
||||
|
||||
//-----------------------------------------
|
||||
// Show overwrite?
|
||||
//-----------------------------------------
|
||||
|
||||
$html = "<tr>
|
||||
<td colspan='2'>
|
||||
<div class='warning'>
|
||||
<p><strong style='color:red'>You are attempting to install in a database that already has tables from another installation</strong>
|
||||
<br />If you wish to install in this database, all current tables will be dropped which means any existing data will be deleted.
|
||||
You can either continue, choosing to delete all current data or you can choose another SQL table prefix.</p>
|
||||
<input type='checkbox' value='1' name='_drop_tables' /><strong>DELETE ANY CURRENT TABLES BEFORE INSTALLING</strong>
|
||||
</div>
|
||||
</td>
|
||||
</tr>";
|
||||
|
||||
$this->install->template->page_content = str_replace( '<!--{TOP.SQL}-->', $html, $this->install->template->page_content );
|
||||
|
||||
//--------------------------------------------------
|
||||
// Any "extra" configs required for this driver?
|
||||
//--------------------------------------------------
|
||||
|
||||
if ( file_exists( INS_ROOT_PATH.'sql/'.$this->install->saved_data['sql_driver'].'_install.php' ) )
|
||||
{
|
||||
require_once( INS_ROOT_PATH.'sql/'.$this->install->saved_data['sql_driver'].'_install.php' );
|
||||
$extra_install = new install_extra();
|
||||
|
||||
$this->install->template->page_content = str_replace( '<!--{EXTRA.SQL}-->', $extra_install->install_form_extra(), $this->install->template->page_content );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Next Action */
|
||||
$this->install->template->page_current = 'admin';
|
||||
$this->install->ipsclass->input['sub'] = '';
|
||||
require_once( INS_ROOT_PATH . 'core/actions/admin.php' );
|
||||
$action = new action_admin( $this->install );
|
||||
$action->run();
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// DO WE HAVE A DB DRIVER SET?
|
||||
//--------------------------------------------------
|
||||
|
||||
$this->install->saved_data['sql_driver'] = ( $this->install->saved_data['sql_driver'] == "" ) ? $_REQUEST['sql_driver'] : $this->install->saved_data['sql_driver'];
|
||||
|
||||
if ( ! $this->install->saved_data['sql_driver'] )
|
||||
{
|
||||
//----------------------------------------------
|
||||
// Test to see how many DB driver's we've got..
|
||||
//----------------------------------------------
|
||||
|
||||
$dh = opendir( INS_KERNEL_PATH );
|
||||
|
||||
while ( $file = @readdir( $dh ) )
|
||||
{
|
||||
if ( preg_match( "/^class_db_([a-zA-Z0-9]*)\.php/i", $file, $driver ) )
|
||||
{
|
||||
$drivers[] = $driver[1];
|
||||
}
|
||||
}
|
||||
|
||||
@closedir( $dh );
|
||||
|
||||
//----------------------------------------------
|
||||
// Got more than one?
|
||||
//----------------------------------------------
|
||||
|
||||
if ( count($drivers) > 1 )
|
||||
{
|
||||
//------------------------------------------
|
||||
// Show choice screen first...
|
||||
//------------------------------------------
|
||||
|
||||
/* Output */
|
||||
$this->install->template->append( $this->install->template->db_check_page( $drivers ) );
|
||||
$this->install->template->next_action = '?p=db';
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//------------------------------------------
|
||||
// Use only driver installed
|
||||
//------------------------------------------
|
||||
|
||||
$this->install->saved_data['sql_driver'] = $drivers[0];
|
||||
}
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->install->template->append( $this->install->template->db_page() );
|
||||
$this->install->template->next_action = '?p=db&sub=check';
|
||||
|
||||
//--------------------------------------------------
|
||||
// Any "extra" configs required for this driver?
|
||||
//--------------------------------------------------
|
||||
|
||||
if ( file_exists( INS_ROOT_PATH.'sql/'.$this->install->saved_data['sql_driver'].'_install.php' ) )
|
||||
{
|
||||
require_once( INS_ROOT_PATH.'sql/'.$this->install->saved_data['sql_driver'].'_install.php' );
|
||||
$extra_install = new install_extra();
|
||||
|
||||
$this->install->template->page_content = str_replace( '<!--{EXTRA.SQL}-->', $extra_install->install_form_extra(), $this->install->template->page_content );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Board
|
||||
* Action controller for done page
|
||||
*/
|
||||
|
||||
class action_done
|
||||
{
|
||||
var $install;
|
||||
|
||||
function action_done( & $install )
|
||||
{
|
||||
$this->install =& $install;
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Lock installer
|
||||
//-----------------------------------------
|
||||
|
||||
$this->install->lock_installer();
|
||||
|
||||
//-----------------------------------------
|
||||
// Show page
|
||||
//-----------------------------------------
|
||||
|
||||
$this->install->template->append( $this->install->template->install_done( $this->install->saved_data['admin_url'], $this->install->check_lock() ) );
|
||||
$this->install->template->next_action = '';
|
||||
$this->install->template->hide_next = 1;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Board
|
||||
* Action controller for EULA page
|
||||
*/
|
||||
|
||||
class action_eula
|
||||
{
|
||||
var $install;
|
||||
|
||||
function action_eula( & $install )
|
||||
{
|
||||
$this->install =& $install;
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
/* Page Output */
|
||||
$this->install->template->append( $this->install->template->eula_page( nl2br($this->install->product_license) ) );
|
||||
$this->install->template->next_action = '?p=address';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,939 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Board
|
||||
* Action controller for install page
|
||||
*/
|
||||
|
||||
class action_install
|
||||
{
|
||||
var $install;
|
||||
|
||||
function action_install( & $install )
|
||||
{
|
||||
$this->install =& $install;
|
||||
}
|
||||
|
||||
// SQL - ADMIN - CONF > SETTINGS > ACPPERMS > TEMPLATES > OTHER [ Email Templates ] > Build Caches
|
||||
|
||||
function run()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Any "extra" configs required for this driver?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array( $this->install->saved_data ) and count( $this->install->saved_data ) )
|
||||
{
|
||||
foreach( $this->install->saved_data as $k => $v )
|
||||
{
|
||||
if ( preg_match( "#^__sql__#", $k ) )
|
||||
{
|
||||
$k = str_replace( "__sql__", "", $k );
|
||||
|
||||
$this->install->ipsclass->vars[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Switch */
|
||||
switch( $this->install->ipsclass->input['sub'] )
|
||||
{
|
||||
case 'sql':
|
||||
$this->install_sql();
|
||||
break;
|
||||
|
||||
case 'settings':
|
||||
$this->install_settings();
|
||||
break;
|
||||
|
||||
case 'acpperms':
|
||||
$this->install_acpperms();
|
||||
break;
|
||||
|
||||
case 'templates':
|
||||
$this->install_templates();
|
||||
break;
|
||||
|
||||
case 'other':
|
||||
$this->install_other();
|
||||
break;
|
||||
|
||||
case 'caches':
|
||||
$this->install_caches();
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Output */
|
||||
$this->install->template->append( $this->install->template->install_page() );
|
||||
$this->install->template->next_action = '?p=install&sub=sql';
|
||||
$this->install->template->hide_next = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Installs the SQL
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Installs SQL schematic
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function install_sql()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Write config
|
||||
//-----------------------------------------
|
||||
|
||||
$this->install->write_configuration();
|
||||
|
||||
//--------------------------------------------------
|
||||
// Any "extra" configs required for this driver?
|
||||
//--------------------------------------------------
|
||||
|
||||
if ( file_exists( INS_ROOT_PATH.'sql/'.$this->install->saved_data['sql_driver'].'_install.php' ) )
|
||||
{
|
||||
require_once( INS_ROOT_PATH.'sql/'.$this->install->saved_data['sql_driver'].'_install.php' );
|
||||
|
||||
$extra_install = new install_extra();
|
||||
$extra_install->ipsclass =& $this->install->ipsclass;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Run SQL commands
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( INS_KERNEL_PATH . 'class_db_' . $this->install->saved_data['sql_driver'] . '.php' );
|
||||
|
||||
$this->install->ipsclass->init_db_connection( $this->install->saved_data['db_name'],
|
||||
$this->install->saved_data['db_user'],
|
||||
$this->install->saved_data['db_pass'],
|
||||
$this->install->saved_data['db_host'],
|
||||
$this->install->saved_data['db_pre'],
|
||||
$this->install->saved_data['sql_driver'] );
|
||||
|
||||
$this->install->ipsclass->converge = new class_converge( $this->install->ipsclass->DB );
|
||||
|
||||
include( INS_ROOT_PATH . 'sql/' . $this->install->saved_data['sql_driver'] . '_tables.php' );
|
||||
$output[] = "Creating SQL Tables...";
|
||||
|
||||
foreach( $TABLE as $q )
|
||||
{
|
||||
preg_match("/CREATE TABLE (\S+) \(/", $q, $match);
|
||||
|
||||
if ( $match[1] AND $this->install->saved_data['_drop_tables'] )
|
||||
{
|
||||
$this->install->ipsclass->DB->sql_drop_table( str_replace( 'ibf_', '', $match[1] ) );
|
||||
}
|
||||
|
||||
$q = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $this->install->saved_data['db_pre']."\\1\\2", $q);
|
||||
|
||||
//-----------------------------------
|
||||
// Pass to handler
|
||||
//-----------------------------------
|
||||
|
||||
if ( $extra_install AND method_exists( $extra_install, 'process_query_create' ) )
|
||||
{
|
||||
$q = $extra_install->process_query_create( $q );
|
||||
}
|
||||
|
||||
$this->install->ipsclass->DB->query( $q );
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
// Create the fulltext index...
|
||||
//-----------------------------------
|
||||
|
||||
if ( $this->install->ipsclass->DB->sql_can_fulltext() )
|
||||
{
|
||||
include( INS_ROOT_PATH . 'sql/' . $this->install->saved_data['sql_driver'] . '_fulltext.php' );
|
||||
$output[] = "Building indexes...";
|
||||
|
||||
foreach( $INDEX as $q )
|
||||
{
|
||||
$q = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $this->install->saved_data['db_pre']."\\1\\2", $q);
|
||||
|
||||
//-----------------------------------
|
||||
// Pass to handler
|
||||
//-----------------------------------
|
||||
|
||||
if ( $extra_install AND method_exists( $extra_install, 'process_query_index' ) )
|
||||
{
|
||||
$q = $extra_install->process_query_index( $q );
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
// Pass query
|
||||
//-----------------------------------
|
||||
|
||||
if ( ! $this->install->ipsclass->DB->query($q) )
|
||||
{
|
||||
$this->install->template->warning($q."<br /><br />".$this->install->ipsclass->DB->error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include( INS_ROOT_PATH . 'sql/' . $this->install->saved_data['sql_driver'] . '_inserts.php' );
|
||||
$output[] = "Populating SQL Tables...";
|
||||
|
||||
foreach( $INSERT as $q )
|
||||
{
|
||||
$q = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $this->install->saved_data['db_pre']."\\1\\2", $q);
|
||||
$q = str_replace( "<%time%>" , time(), $q );
|
||||
|
||||
# Admin's name
|
||||
$q = str_replace( "<%admin_name%>", $this->install->saved_data['admin_user'], $q );
|
||||
|
||||
//-----------------------------------
|
||||
// Pass to handler
|
||||
//-----------------------------------
|
||||
|
||||
if ( $extra_install AND method_exists( $extra_install, 'process_query_insert' ) )
|
||||
{
|
||||
$q = $extra_install->process_query_insert( $q );
|
||||
}
|
||||
|
||||
$this->install->ipsclass->DB->query( $q );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Create Admin account
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Creating admin account...";
|
||||
|
||||
$this->install->create_admin_account();
|
||||
|
||||
//-----------------------------------------
|
||||
// Next...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->install->template->append( $this->install->template->install_page_refresh( $output ) );
|
||||
$this->install->template->next_action = '?p=install&sub=settings';
|
||||
$this->install->template->hide_next = 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Installs the settings
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Installs SQL schematic
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function install_settings()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get DB
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( INS_KERNEL_PATH . 'class_db_' . $this->install->saved_data['sql_driver'] . '.php' );
|
||||
|
||||
$this->install->ipsclass->init_db_connection( $this->install->saved_data['db_name'],
|
||||
$this->install->saved_data['db_user'],
|
||||
$this->install->saved_data['db_pass'],
|
||||
$this->install->saved_data['db_host'],
|
||||
$this->install->saved_data['db_pre'],
|
||||
$this->install->saved_data['sql_driver'] );
|
||||
//-----------------------------------------
|
||||
// Install settings
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting settings...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_DOC_ROOT_PATH . 'resources/settings.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
//-----------------------------------------
|
||||
// Known settings
|
||||
//-----------------------------------------
|
||||
|
||||
if ( substr( $this->install->saved_data['install_url'], -1 ) == '/' )
|
||||
{
|
||||
$this->install->saved_data['install_url'] = substr( $this->install->saved_data['install_url'], 0, -1 );
|
||||
}
|
||||
|
||||
$_urls = parse_url( $this->install->saved_data['install_url'] );
|
||||
|
||||
$known = array( 'email_in' => $this->install->saved_data['admin_email'],
|
||||
'email_out' => $this->install->saved_data['admin_email'],
|
||||
'base_dir' => $this->install->saved_data['install_dir'],
|
||||
'upload_dir' => $this->install->saved_data['install_dir'] . '/uploads',
|
||||
'upload_url' => $this->install->saved_data['install_url'] . '/uploads',
|
||||
'search_sql_method' => $this->install->ipsclass->DB->sql_can_fulltext() ? 'ftext' : 'man',
|
||||
//'cookie_domain' => $_urls['host'] != 'localhost' ? '.' . preg_replace( "#^(?:.+?\.)?([a-z0-9\-]{3,})\.(([a-z]{2,4})(\.([a-z]{2}))?|museum)$#is", "\\1.\\2", $_urls['host'] ) : '',
|
||||
);
|
||||
|
||||
//-----------------------------------------
|
||||
// Parse
|
||||
//-----------------------------------------
|
||||
|
||||
$fields = array( 'conf_title' , 'conf_description', 'conf_group' , 'conf_type' , 'conf_key' , 'conf_default',
|
||||
'conf_extra' , 'conf_evalphp' , 'conf_protected', 'conf_position', 'conf_start_group', 'conf_end_group',
|
||||
'conf_help_key', 'conf_add_cache' , 'conf_title_keyword' );
|
||||
|
||||
$setting_fields = array( 'conf_title_keyword', 'conf_title_title', 'conf_title_desc', 'conf_title_noshow', 'conf_title_module' );
|
||||
|
||||
//-----------------------------------------
|
||||
// Fix up...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! is_array( $xml->xml_array['settingexport']['settinggroup']['setting'][0] ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Ensure [0] is populated
|
||||
//-----------------------------------------
|
||||
|
||||
$tmp = $xml->xml_array['settingexport']['settinggroup']['setting'];
|
||||
|
||||
unset($xml->xml_array['settingexport']['settinggroup']['setting']);
|
||||
|
||||
$xml->xml_array['settingexport']['settinggroup']['setting'][0] = $tmp;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Loop through and sort out settings...
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $xml->xml_array['settingexport']['settinggroup']['setting'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Is setting?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $entry['conf_is_title']['VALUE'] )
|
||||
{
|
||||
foreach( $fields as $f )
|
||||
{
|
||||
$newrow[$f] = $entry[ $f ]['VALUE'];
|
||||
}
|
||||
|
||||
$new_settings[] = $newrow;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Is title?
|
||||
//-----------------------------------------
|
||||
|
||||
else
|
||||
{
|
||||
foreach( $setting_fields as $f )
|
||||
{
|
||||
$newrow[$f] = $entry[ $f ]['VALUE'];
|
||||
}
|
||||
|
||||
$new_titles[] = $newrow;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Sort out titles...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array( $new_titles ) and count( $new_titles ) )
|
||||
{
|
||||
foreach( $new_titles as $idx => $data )
|
||||
{
|
||||
if ( $data['conf_title_title'] AND $data['conf_title_keyword'] )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get ID based on key
|
||||
//-----------------------------------------
|
||||
|
||||
$save = array( 'conf_title_title' => $data['conf_title_title'],
|
||||
'conf_title_desc' => $data['conf_title_desc'],
|
||||
'conf_title_keyword' => $data['conf_title_keyword'],
|
||||
'conf_title_noshow' => $data['conf_title_noshow'],
|
||||
'conf_title_module' => $data['conf_title_module'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// Insert first
|
||||
//-----------------------------------------
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'conf_settings_titles', $save );
|
||||
|
||||
$conf_id = $this->install->ipsclass->DB->get_insert_id();
|
||||
$save['conf_title_id'] = $conf_id;
|
||||
|
||||
//-----------------------------------------
|
||||
// Update settings cache
|
||||
//-----------------------------------------
|
||||
|
||||
$setting_groups_by_key[ $save['conf_title_keyword'] ] = $save;
|
||||
$setting_groups[ $save['conf_title_id'] ] = $save;
|
||||
|
||||
$need_update[] = $conf_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Sort out settings
|
||||
//-----------------------------------------
|
||||
|
||||
if ( is_array( $new_settings ) and count( $new_settings ) )
|
||||
{
|
||||
foreach( $new_settings as $idx => $data )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Insert known
|
||||
//-----------------------------------------
|
||||
|
||||
if ( in_array( $data['conf_key'], array_keys( $known ) ) )
|
||||
{
|
||||
$data['conf_value'] = $known[ $data['conf_key'] ];
|
||||
#$data['conf_default'] = $known[ $data['conf_key'] ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['conf_value'] = '';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Now assign to the correct ID based on
|
||||
// our title keyword...
|
||||
//-----------------------------------------
|
||||
|
||||
$data['conf_group'] = $setting_groups_by_key[ $data['conf_title_keyword'] ]['conf_title_id'];
|
||||
|
||||
//-----------------------------------------
|
||||
// Remove from array
|
||||
//-----------------------------------------
|
||||
|
||||
unset( $data['conf_title_keyword'] );
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'conf_settings', $data );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Update group counts...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( count( $need_update ) )
|
||||
{
|
||||
foreach( $need_update as $i => $idx )
|
||||
{
|
||||
$conf = $this->install->ipsclass->DB->simple_exec_query( array( 'select' => 'count(*) as count', 'from' => 'conf_settings', 'where' => 'conf_group='.$idx ) );
|
||||
|
||||
$count = intval($conf['count']);
|
||||
|
||||
$this->install->ipsclass->DB->do_update( 'conf_settings_titles', array( 'conf_title_count' => $count ), 'conf_title_id='.$idx );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Next...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->install->template->append( $this->install->template->install_page_refresh( $output ) );
|
||||
$this->install->template->next_action = '?p=install&sub=acpperms';
|
||||
$this->install->template->hide_next = 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Installs the ACP Perms
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Installs SQL schematic
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function install_acpperms()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$cur_perms = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Get DB
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( INS_KERNEL_PATH . 'class_db_' . $this->install->saved_data['sql_driver'] . '.php' );
|
||||
|
||||
$this->install->ipsclass->init_db_connection( $this->install->saved_data['db_name'],
|
||||
$this->install->saved_data['db_user'],
|
||||
$this->install->saved_data['db_pass'],
|
||||
$this->install->saved_data['db_host'],
|
||||
$this->install->saved_data['db_pre'],
|
||||
$this->install->saved_data['sql_driver'] );
|
||||
//-----------------------------------------
|
||||
// Install settings
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting ACP Permissions...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_DOC_ROOT_PATH . 'resources/acpperms.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
//-----------------------------------------
|
||||
// Loop through and sort out settings...
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $xml->xml_array['permsexport']['permsgroup']['perm'] as $id => $entry )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Do we have a row matching this already?
|
||||
//-----------------------------------------
|
||||
|
||||
$_perm_main = $entry['acpperm_main']['VALUE'];
|
||||
$_perm_child = $entry['acpperm_child']['VALUE'];
|
||||
$_perm_bit = $entry['acpperm_bit']['VALUE'];
|
||||
|
||||
$_perm_key = $_perm_main.':'.$_perm_child.':'.$_perm_bit;
|
||||
|
||||
if ( ! $cur_perms[ $_perm_key ] )
|
||||
{
|
||||
$this->install->ipsclass->DB->do_insert( 'admin_permission_keys', array( 'perm_key' => $_perm_key,
|
||||
'perm_main' => $_perm_main,
|
||||
'perm_child' => $_perm_child,
|
||||
'perm_bit' => $_perm_bit ) );
|
||||
|
||||
$inserted++;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Next...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->install->template->append( $this->install->template->install_page_refresh( $output ) );
|
||||
$this->install->template->next_action = '?p=install&sub=templates';
|
||||
$this->install->template->hide_next = 1;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Install: Templates
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Install templates
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function install_templates()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get DB
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( INS_KERNEL_PATH . 'class_db_' . $this->install->saved_data['sql_driver'] . '.php' );
|
||||
|
||||
$this->install->ipsclass->init_db_connection( $this->install->saved_data['db_name'],
|
||||
$this->install->saved_data['db_user'],
|
||||
$this->install->saved_data['db_pass'],
|
||||
$this->install->saved_data['db_host'],
|
||||
$this->install->saved_data['db_pre'],
|
||||
$this->install->saved_data['sql_driver'] );
|
||||
//-----------------------------------------
|
||||
// Install settings
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting templates...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_DOC_ROOT_PATH . 'resources/ipb_templates.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
//-----------------------------------------
|
||||
// Install
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $xml->xml_array['templateexport']['templategroup']['template'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
$newrow['group_name'] = $entry[ 'group_name' ]['VALUE'];
|
||||
$newrow['section_content'] = $entry[ 'section_content' ]['VALUE'];
|
||||
$newrow['func_name'] = $entry[ 'func_name' ]['VALUE'];
|
||||
$newrow['func_data'] = $entry[ 'func_data' ]['VALUE'];
|
||||
$newrow['set_id'] = 1;
|
||||
$newrow['updated'] = time();
|
||||
|
||||
$this->install->ipsclass->DB->allow_sub_select = 1;
|
||||
$this->install->ipsclass->DB->do_insert( 'skin_templates', $newrow );
|
||||
}
|
||||
|
||||
//-------------------------------
|
||||
// GET MACROS
|
||||
//-------------------------------
|
||||
|
||||
$content = implode( "", file( INS_DOC_ROOT_PATH . 'resources/macro.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
//-------------------------------
|
||||
// (MACRO)
|
||||
//-------------------------------
|
||||
|
||||
foreach( $xml->xml_array['macroexport']['macrogroup']['macro'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
$newrow['macro_value'] = $entry[ 'macro_value' ]['VALUE'];
|
||||
$newrow['macro_replace'] = $entry[ 'macro_replace' ]['VALUE'];
|
||||
$newrow['macro_set'] = 1;
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'skin_macro', $newrow );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Next...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->install->template->append( $this->install->template->install_page_refresh( $output ) );
|
||||
$this->install->template->next_action = '?p=install&sub=other';
|
||||
$this->install->template->hide_next = 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Install: Other
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Install Other stuff
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function install_other()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get DB
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( INS_KERNEL_PATH . 'class_db_' . $this->install->saved_data['sql_driver'] . '.php' );
|
||||
|
||||
$this->install->ipsclass->init_db_connection( $this->install->saved_data['db_name'],
|
||||
$this->install->saved_data['db_user'],
|
||||
$this->install->saved_data['db_pass'],
|
||||
$this->install->saved_data['db_host'],
|
||||
$this->install->saved_data['db_pre'],
|
||||
$this->install->saved_data['sql_driver'] );
|
||||
//-----------------------------------------
|
||||
// XML: COMPONENTS
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting components information...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_DOC_ROOT_PATH . 'resources/components.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
foreach( $xml->xml_array['export']['group']['row'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
foreach( $entry as $f => $data )
|
||||
{
|
||||
if ( $f == 'VALUE' or $f == 'com_id' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$newrow[$f] = $entry[ $f ]['VALUE'];
|
||||
}
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'components', $newrow );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// XML: LOG IN MODULES
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting log in modules information...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_ROOT_PATH . 'installfiles/loginauth.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
foreach( $xml->xml_array['export']['group']['row'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
foreach( $entry as $f => $data )
|
||||
{
|
||||
if ( $f == 'VALUE' or $f == 'login_id' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$newrow[$f] = $entry[ $f ]['VALUE'];
|
||||
}
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'login_methods', $newrow );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// XML: GROUPS
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting groups information...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_ROOT_PATH . 'installfiles/groups.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
foreach( $xml->xml_array['export']['group']['row'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
foreach( $entry as $f => $data )
|
||||
{
|
||||
if ( $f == 'VALUE' or $f == 'g_id' or preg_match( "#^g_blog_#is", $f ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$newrow[$f] = $entry[ $f ]['VALUE'];
|
||||
}
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'groups', $newrow );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// XML: ATTACHMENTS
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting attachment type information...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_ROOT_PATH . 'installfiles/attachments.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
foreach( $xml->xml_array['export']['group']['row'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
foreach( $entry as $f => $data )
|
||||
{
|
||||
if ( $f == 'VALUE' or $f == 'atype_id' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$newrow[$f] = $entry[ $f ]['VALUE'];
|
||||
}
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'attachments_type', $newrow );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// XML: SKIN SETS
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting template set data...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_DOC_ROOT_PATH . 'resources/skinsets.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
//-----------------------------------------
|
||||
// Fix up...
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! is_array( $xml->xml_array['export']['group']['row'][0] ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Ensure [0] is populated
|
||||
//-----------------------------------------
|
||||
|
||||
$tmp = $xml->xml_array['export']['group']['row'];
|
||||
|
||||
unset($xml->xml_array['export']['group']['row']);
|
||||
|
||||
$xml->xml_array['export']['group']['row'][0] = $tmp;
|
||||
}
|
||||
|
||||
foreach( $xml->xml_array['export']['group']['row'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
foreach( $entry as $f => $data )
|
||||
{
|
||||
if ( $f == 'VALUE' or $f == 'set_skin_set_id' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$newrow[$f] = $entry[ $f ]['VALUE'];
|
||||
}
|
||||
|
||||
$this->install->ipsclass->DB->allow_sub_select = 1;
|
||||
$this->install->ipsclass->DB->do_insert( 'skin_sets', $newrow );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// XML: TASKS :D
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting task manager information...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_DOC_ROOT_PATH . 'resources/tasks.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
foreach( $xml->xml_array['export']['group']['row'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
foreach( $entry as $f => $data )
|
||||
{
|
||||
if ( $f == 'VALUE' or $f == 'task_id' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $f == 'task_cronkey' )
|
||||
{
|
||||
$entry[ $f ]['VALUE'] = md5( uniqid( microtime() ) );
|
||||
}
|
||||
|
||||
if ( $f == 'task_next_run' )
|
||||
{
|
||||
$entry[ $f ]['VALUE'] = time();
|
||||
}
|
||||
|
||||
$newrow[$f] = $entry[ $f ]['VALUE'];
|
||||
}
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'task_manager', $newrow );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// XML: FAQ
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting FAQ information...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_DOC_ROOT_PATH . 'resources/faq.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
foreach( $xml->xml_array['export']['group']['row'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
foreach( $entry as $f => $data )
|
||||
{
|
||||
if ( $f == 'VALUE' or $f == 'id' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$newrow[$f] = $entry[ $f ]['VALUE'];
|
||||
}
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'faq', $newrow );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// XML: BBCode
|
||||
//-----------------------------------------
|
||||
|
||||
$output[] = "Inserting custom BBCode information...";
|
||||
$xml = new class_xml();
|
||||
$xml->lite_parser = 1;
|
||||
|
||||
$content = implode( "", file( INS_DOC_ROOT_PATH . 'resources/bbcode.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
foreach( $xml->xml_array['bbcodeexport']['bbcodegroup']['bbcode'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
foreach( $entry as $f => $data )
|
||||
{
|
||||
if ( $f == 'VALUE' or $f == 'bbcode_id' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$newrow[$f] = $entry[ $f ]['VALUE'];
|
||||
}
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'custom_bbcode', $newrow );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// XML: MACROS
|
||||
//-----------------------------------------
|
||||
|
||||
/* - Macros inserted on line 560 above - only need to be inserted once..
|
||||
$output[] = "Inserting macro information...";
|
||||
$xml = new class_xml();
|
||||
|
||||
$content = implode( "", file( INS_ROOT_PATH . 'installfiles/macro.xml' ) );
|
||||
$xml->xml_parse_document( $content );
|
||||
|
||||
foreach( $xml->xml_array['macroexport']['macrogroup']['macro'] as $id => $entry )
|
||||
{
|
||||
$newrow = array();
|
||||
|
||||
$newrow['macro_value'] = $entry[ 'macro_value' ]['VALUE'];
|
||||
$newrow['macro_replace'] = $entry[ 'macro_replace' ]['VALUE'];
|
||||
$newrow['macro_set'] = 1;
|
||||
|
||||
$this->install->ipsclass->DB->do_insert( 'skin_macro', $newrow );
|
||||
}*/
|
||||
|
||||
//-----------------------------------------
|
||||
// Next...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->install->template->append( $this->install->template->install_page_refresh( $output ) );
|
||||
$this->install->template->next_action = '?p=install&sub=caches';
|
||||
$this->install->template->hide_next = 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Install: Caches
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Install Caches
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function install_caches()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get DB
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( INS_KERNEL_PATH . 'class_db_' . $this->install->saved_data['sql_driver'] . '.php' );
|
||||
|
||||
$this->install->ipsclass->init_db_connection( $this->install->saved_data['db_name'],
|
||||
$this->install->saved_data['db_user'],
|
||||
$this->install->saved_data['db_pass'],
|
||||
$this->install->saved_data['db_host'],
|
||||
$this->install->saved_data['db_pre'],
|
||||
$this->install->saved_data['sql_driver'] );
|
||||
//-----------------------------------------
|
||||
// Do Caches
|
||||
//-----------------------------------------
|
||||
|
||||
$output = $this->install->cache_and_cleanup();
|
||||
|
||||
//-----------------------------------------
|
||||
// Next...
|
||||
//-----------------------------------------
|
||||
|
||||
$this->install->template->append( $this->install->template->install_progress( $output ) );
|
||||
$this->install->template->next_action = '?p=done';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Board
|
||||
* Action controller for requirements page
|
||||
*/
|
||||
|
||||
class action_requirements
|
||||
{
|
||||
var $install;
|
||||
|
||||
function action_requirements( & $install )
|
||||
{
|
||||
$this->install =& $install;
|
||||
}
|
||||
|
||||
function run()
|
||||
{
|
||||
/* Set App Specific Requirements */
|
||||
$this->install->set_requirements();
|
||||
|
||||
/* Page Output */
|
||||
$this->install->template->append( $this->install->template->requirements_page( $this->install->version_php_min, $this->install->version_mysql_min ) );
|
||||
|
||||
/* Check Requirements */
|
||||
$errors = $this->install->check_requirements();
|
||||
|
||||
/* Check for errors */
|
||||
if( count( $errors ) )
|
||||
{
|
||||
$this->install->template->warning( $errors );
|
||||
$this->install->template->next_action = 'disabled';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->install->template->next_action = '?p=eula';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Board
|
||||
* Invision Installer Framework
|
||||
*/
|
||||
|
||||
class class_installer
|
||||
{
|
||||
var $product_name = '';
|
||||
var $product_license = '';
|
||||
var $product_version = '';
|
||||
var $product_key = '';
|
||||
|
||||
var $build_id = '';
|
||||
|
||||
var $version_php_min = '';
|
||||
var $version_mysql_min = '';
|
||||
|
||||
var $required_dirs = array();
|
||||
var $required_files = array();
|
||||
|
||||
var $writeable_dirs = array();
|
||||
var $writeable_files = array();
|
||||
|
||||
/**
|
||||
* class_installer::set_product_info
|
||||
*
|
||||
* Set basic information about the product being installed
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $license
|
||||
* @param array $versions
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
function set_product_info( $name, $license, $versions, $key )
|
||||
{
|
||||
$this->product_name = $name;
|
||||
$this->product_license = $license;
|
||||
$this->product_versions = $versions;
|
||||
$this->product_key = $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* class_installer:set_software_versions
|
||||
*
|
||||
* Set required software versions of php and mysql
|
||||
*
|
||||
* @param string $php_min Example: 3.0.0
|
||||
* @param string $mysql_min Example: 4.4.0
|
||||
*/
|
||||
function set_software_versions( $php_min, $mysql_min )
|
||||
{
|
||||
$this->version_php_min = explode( '.', $php_min );
|
||||
$this->version_mysql_min = $mysql_min;
|
||||
}
|
||||
|
||||
/**
|
||||
* class_installer::set_required
|
||||
*
|
||||
* Set what files and directories must be present for an installation
|
||||
*
|
||||
* @param array $dirs
|
||||
* @param array $files
|
||||
*/
|
||||
function set_required( $dirs, $files )
|
||||
{
|
||||
$this->required_dirs = $dirs;
|
||||
$this->required_files = $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* class_installer::set_writeable
|
||||
*
|
||||
* Set what files and directories must be writeable
|
||||
*
|
||||
* @param array $dirs
|
||||
* @param array $files
|
||||
*/
|
||||
function set_writeable( $dirs=array(), $files=array() )
|
||||
{
|
||||
$this->writeable_dirs = $dirs;
|
||||
$this->writeable_files = $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* class_installer::check_requirements
|
||||
*
|
||||
* Checks to make sure that all requirements are met, including software versions,
|
||||
* directories, and files.
|
||||
*
|
||||
* @return array $errors
|
||||
*/
|
||||
function check_requirements()
|
||||
{
|
||||
/* Errors Array */
|
||||
$errors = array();
|
||||
|
||||
/**
|
||||
* PHP Version Checking
|
||||
*/
|
||||
|
||||
/* Check Min PHP Version */
|
||||
$check_php = explode( '.', $this->version_php_min );
|
||||
|
||||
if ( PHP_VERSION < $this->version_php_min )
|
||||
{
|
||||
$errors[] = 'Your PHP installation is too old to run this product, please upgrade before continuing.';
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL Version Checking
|
||||
*/
|
||||
|
||||
/**
|
||||
* Required Directories/Files Checking
|
||||
*/
|
||||
if( count( $this->required_dirs ) )
|
||||
{
|
||||
foreach( $this->required_dirs as $_d )
|
||||
{
|
||||
if( ! ( is_dir( $_d) && is_readable( $_d ) ) )
|
||||
{
|
||||
$errors[] = 'A required directory could not be located: "' . $_d . '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( count( $this->required_files ) )
|
||||
{
|
||||
foreach( $this->required_files as $_f )
|
||||
{
|
||||
if( ! ( file_exists( $_f) && is_readable( $_f ) ) )
|
||||
{
|
||||
$errors[] = 'A required file could not be located: "' . $_f . '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writeable Directories/File Checking
|
||||
*/
|
||||
if( count( $this->writeable_dirs ) )
|
||||
{
|
||||
foreach( $this->writeable_dirs as $_d )
|
||||
{
|
||||
if( ! is_writeable( $_d ) )
|
||||
{
|
||||
$errors[] = 'Can not write to directory: "' . $_d . '", please CHMOD to 777';
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $this->writeable_files as $_f )
|
||||
{
|
||||
if( ! is_writeable( $_f ) )
|
||||
{
|
||||
$errors[] = 'Can not write to file: "' . $_f . '", please CHMOD to 777';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* class_installer::unpack_config
|
||||
*
|
||||
* Reads and stores the information from the config.xml file
|
||||
*
|
||||
*/
|
||||
function read_config()
|
||||
{
|
||||
// Get Configuration File
|
||||
$config = implode( '', file( INS_ROOT_PATH . 'installfiles/config.xml' ) );
|
||||
$xml = new class_xml();
|
||||
|
||||
$config = $xml->xml_parse_document( $config );
|
||||
|
||||
// Set Info
|
||||
$this->product_name = $xml->xml_array['installdata']['package']['name']['VALUE'];
|
||||
$this->product_license = $xml->xml_array['installdata']['package']['license']['VALUE'];
|
||||
$this->product_version = $xml->xml_array['installdata']['package']['version']['VALUE'];
|
||||
$this->product_long_version = $xml->xml_array['installdata']['package']['versionlong']['VALUE'];
|
||||
$this->build_id = $xml->xml_array['installdata']['package']['build']['VALUE'];
|
||||
|
||||
// Override.
|
||||
$this->product_version = IPBVERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* class_installer::write_file
|
||||
*
|
||||
* Simple method for writing a file
|
||||
*
|
||||
* @param string $name Full name, including path, of file to write
|
||||
* @param string $data Contents of file
|
||||
*/
|
||||
function write_file( $name, $data )
|
||||
{
|
||||
$fh = @fopen( $name, "w" );
|
||||
@fwrite( $fh, $data, strlen( $data ) );
|
||||
@fclose( $fh );
|
||||
}
|
||||
|
||||
/**
|
||||
* class_installer::create_admin_converge
|
||||
*
|
||||
* Builds converge entry for admin
|
||||
*
|
||||
* @return integer $id Converge ID
|
||||
*/
|
||||
function create_admin_converge()
|
||||
{
|
||||
/* Build Entry */
|
||||
$salt = $this->ipsclass->converge->generate_password_salt( 5 );
|
||||
$passhash = $this->ipsclass->converge->generate_compiled_passhash( $salt, md5( $this->saved_data['admin_pass'] ) );
|
||||
|
||||
$converge = array( 'converge_email' => $this->saved_data['admin_email'],
|
||||
'converge_joined' => time(),
|
||||
'converge_pass_hash' => $passhash,
|
||||
'converge_pass_salt' => str_replace( '\\', "\\\\", $salt ),
|
||||
);
|
||||
|
||||
/* Insert */
|
||||
$this->ipsclass->DB->do_insert( 'members_converge', $converge );
|
||||
|
||||
/* Return ID */
|
||||
return $this->ipsclass->DB->get_insert_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* class_installer::chmod_dir
|
||||
*
|
||||
* chmods all files and directories in the given path
|
||||
*
|
||||
* @param string $path
|
||||
* @param integer $mode
|
||||
*/
|
||||
function chmod_dir( $path, $mode )
|
||||
{
|
||||
/* Open directory */
|
||||
$dh = @opendir( $path );
|
||||
|
||||
while( $f = @readdir( $dh ) )
|
||||
{
|
||||
if( $f != '.' && $f != '..' )
|
||||
{
|
||||
/* Full file path */
|
||||
$_path = $path . '/'. $f;
|
||||
|
||||
/* CHMOD directory and contents */
|
||||
if( @is_dir( $_path ) )
|
||||
{
|
||||
@chmod( $_path, $mode );
|
||||
$this->chmod_dir( $_path, $mode );
|
||||
}
|
||||
/* CHMOD file */
|
||||
else
|
||||
{
|
||||
@chmod( $_path, $mode );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Close directory */
|
||||
@closedir( $dh );
|
||||
}
|
||||
|
||||
/**
|
||||
* class_installer::process
|
||||
*
|
||||
* Figures out what action to run
|
||||
*
|
||||
*/
|
||||
function process()
|
||||
{
|
||||
/* Require Action */
|
||||
require_once( INS_ROOT_PATH . 'core/actions/' . $this->template->page_current . '.php' );
|
||||
|
||||
/* Initialize */
|
||||
$class = 'action_' . $this->template->page_current;
|
||||
$this->action = new $class( $this );
|
||||
$this->action->run();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Lock installer
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Lock Installer
|
||||
* Writes a lock file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function lock_installer()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Write!
|
||||
//-----------------------------------------
|
||||
|
||||
$this->write_file( INS_ROOT_PATH . 'installfiles/lock.php', 'LOCKED' );
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
// Check lock
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Lock Installer
|
||||
* Writes a lock file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function check_lock()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Write!
|
||||
//-----------------------------------------
|
||||
|
||||
return file_exists( INS_ROOT_PATH . 'installfiles/lock.php' ) ? 1 : 0;
|
||||
}
|
||||
|
||||
/* Overridden by application specific class */
|
||||
function pre_process() {}
|
||||
function post_process() {}
|
||||
function set_requirements() {}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,869 @@
|
||||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > Tar creation and extraction module
|
||||
| > Module written by Matt Mecham
|
||||
| > Usage style based on the C and Perl modules
|
||||
| > Will only work with PHP 4+
|
||||
|
|
||||
| > Date started: 15th Feb 2002
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > Module Author: Matthew Mecham
|
||||
+--------------------------------------------------------------------------
|
||||
|
|
||||
| QUOTE OF THE MODULE:
|
||||
| If you can't find a program the does what you want it to do, write your
|
||||
| own.
|
||||
|
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*************************************************************
|
||||
|
|
||||
| EXTRACTION USAGE:
|
||||
|
|
||||
| $tar = new tar();
|
||||
| $tar->new_tar("/foo/bar", "myTar.tar");
|
||||
| $files = $tar->list_files();
|
||||
| $tar->extract_files( "/extract/to/here/dir" );
|
||||
|
|
||||
| CREATION USAGE:
|
||||
|
|
||||
| $tar = new tar();
|
||||
| $tar->new_tar("/foo/bar" , "myNewTar.tar");
|
||||
| $tar->current_dir("/foo" ); //Optional - tells the script which dir we are in
|
||||
| to syncronise file creation from the tarball
|
||||
| $tar->add_files( $file_names_with_path_array );
|
||||
| (or $tar->add_directory( "/foo/bar/myDir" ); to archive a complete dir)
|
||||
| $tar->write_tar();
|
||||
|
|
||||
*************************************************************/
|
||||
|
||||
|
||||
|
||||
class tar {
|
||||
|
||||
var $tar_header_length = '512';
|
||||
var $tar_unpack_header = 'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8chksum/a1typeflag/a100linkname/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155/prefix';
|
||||
var $tar_pack_header = 'A100 A8 A8 A8 A12 A12 A8 A1 A100 A6 A2 A32 A32 A8 A8 A155';
|
||||
var $current_dir = "";
|
||||
var $unpack_dir = "";
|
||||
var $pack_dir = "";
|
||||
var $error = "";
|
||||
var $work_dir = array();
|
||||
var $tar_in_mem = array();
|
||||
var $tar_filename = "";
|
||||
var $filehandle = "";
|
||||
var $warnings = array();
|
||||
var $attributes = array();
|
||||
var $tarfile_name = "";
|
||||
var $tarfile_path = "";
|
||||
var $tarfile_path_name = "";
|
||||
var $workfiles = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// CONSTRUCTOR: Attempt to guess the current working dir.
|
||||
//-----------------------------------------
|
||||
|
||||
function tar() {
|
||||
global $HTTP_SERVER_VARS;
|
||||
|
||||
if ($this_dir = getcwd())
|
||||
{
|
||||
$this->current_dir = $this_dir;
|
||||
}
|
||||
else if (isset($HTTP_SERVER_VARS['DOCUMENT_ROOT']))
|
||||
{
|
||||
$this->current_dir = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->current_dir = './';
|
||||
}
|
||||
|
||||
// Set some attributes, these can be overriden later
|
||||
|
||||
$this->attributes = array( 'over_write_existing' => 0,
|
||||
'over_write_newer' => 0,
|
||||
'remove_tar_file' => 0,
|
||||
'remove_original_files' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Set the tarname. If we are extracting a tarball, then it must be the
|
||||
// path to the tarball, and it's name (eg: $tar->new_tar("/foo/bar" ,'myTar.tar')
|
||||
// or if we are creating a tar, then it must be the path and name of the tar file
|
||||
// to create.
|
||||
//-----------------------------------------
|
||||
|
||||
function new_tar($tarpath, $tarname) {
|
||||
|
||||
$this->tarfile_name = $tarname;
|
||||
$this->tarfile_path = $tarpath;
|
||||
|
||||
// Make sure there isn't a trailing slash on the path
|
||||
|
||||
$this->tarfile_path = preg_replace( "#[/\\\]$#" , "" , $this->tarfile_path );
|
||||
|
||||
$this->tarfile_path_name = $this->tarfile_path .'/'. $this->tarfile_name;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Easy way to overwrite defaults
|
||||
//-----------------------------------------
|
||||
|
||||
function over_write_existing() {
|
||||
$this->attributes['over_write_existing'] = 1;
|
||||
}
|
||||
function over_write_newer() {
|
||||
$this->attributes['over_write_newer'] = 1;
|
||||
}
|
||||
function remove_tar_file() {
|
||||
$this->attributes['remove_tar_file'] = 1;
|
||||
}
|
||||
function remove_original_files() {
|
||||
$this->attributes['remove_original_files'] = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// User assigns the root directory for the tar ball creation/extraction
|
||||
//-----------------------------------------
|
||||
|
||||
function current_dir($dir = "") {
|
||||
|
||||
$this->current_dir = $dir;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// list files: returns an array with all the filenames in the tar file
|
||||
//-----------------------------------------
|
||||
|
||||
function list_files($advanced="") {
|
||||
|
||||
// $advanced == "" - return name only
|
||||
// $advanced == 1 - return name, size, mtime, mode
|
||||
|
||||
$data = $this->read_tar();
|
||||
|
||||
$final = array();
|
||||
|
||||
foreach($data as $d)
|
||||
{
|
||||
if ($advanced == 1)
|
||||
{
|
||||
$final[] = array ( 'name' => $d['name'],
|
||||
'size' => $d['size'],
|
||||
'mtime' => $d['mtime'],
|
||||
'mode' => substr(decoct( $d['mode'] ), -4),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$final[] = $d['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $final;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Add a directory to the tar files.
|
||||
// $tar->add_directory( str(TO DIRECTORY) )
|
||||
// Can be used in the following methods.
|
||||
// $tar->add_directory( "/foo/bar" );
|
||||
// $tar->write_tar( "/foo/bar" );
|
||||
//-----------------------------------------
|
||||
|
||||
function add_directory( $dir ) {
|
||||
|
||||
$this->error = "";
|
||||
|
||||
// Make sure the $to_dir is pointing to a valid dir, or we error
|
||||
// and return
|
||||
|
||||
if (! is_dir($dir) )
|
||||
{
|
||||
$this->error = "Extract files error: Destination directory ($to_dir) does not exist";
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$cur_dir = getcwd();
|
||||
chdir($dir);
|
||||
|
||||
$this->get_dir_contents("./");
|
||||
|
||||
$this->add_files($this->workfiles, $dir);
|
||||
|
||||
chdir($cur_dir);
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
function get_dir_contents( $dir )
|
||||
{
|
||||
|
||||
$dir = preg_replace( "#/$#", "", $dir );
|
||||
|
||||
if ( file_exists($dir) )
|
||||
{
|
||||
if ( is_dir($dir) )
|
||||
{
|
||||
$handle = opendir($dir);
|
||||
|
||||
while (($filename = readdir($handle)) !== false)
|
||||
{
|
||||
if (($filename != ".") && ($filename != ".."))
|
||||
{
|
||||
if (is_dir($dir."/".$filename))
|
||||
{
|
||||
$this->get_dir_contents($dir."/".$filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->workfiles[] = $dir."/".$filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = "$dir is not a directory";
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = "Could not locate $dir";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Extract the tarball
|
||||
// $tar->extract_files( str(TO DIRECTORY), [ array( FILENAMES ) ] )
|
||||
// Can be used in the following methods.
|
||||
// $tar->extract( "/foo/bar" , $files );
|
||||
// This will seek out the files in the user array and extract them
|
||||
// $tar->extract( "/foo/bar" );
|
||||
// Will extract the complete tar file into the user specified directory
|
||||
//-----------------------------------------
|
||||
|
||||
function extract_files( $to_dir, $files="" ) {
|
||||
|
||||
$this->error = "";
|
||||
|
||||
// Make sure the $to_dir is pointing to a valid dir, or we error
|
||||
// and return
|
||||
|
||||
if (! is_dir($to_dir) )
|
||||
{
|
||||
$this->error = "Extract files error: Destination directory ($to_dir) does not exist";
|
||||
return;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// change into the directory chosen by the user.
|
||||
//-----------------------------------------
|
||||
|
||||
chdir($to_dir);
|
||||
$cur_dir = getcwd();
|
||||
|
||||
$to_dir_slash = $to_dir . "/";
|
||||
|
||||
//-----------------------------------------
|
||||
// Get the file info from the tar
|
||||
//-----------------------------------------
|
||||
|
||||
$in_files = $this->read_tar();
|
||||
|
||||
if ($this->error != "") {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($in_files as $file)
|
||||
{
|
||||
|
||||
//-----------------------------------------
|
||||
// Stop any potential file traversal issues
|
||||
//-----------------------------------------
|
||||
|
||||
$file['name'] = str_replace( '..', '', $file['name'] );
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we choosing which files to extract?
|
||||
//-----------------------------------------
|
||||
|
||||
if (is_array($files))
|
||||
{
|
||||
if (! in_array($file['name'], $files) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
chdir($cur_dir);
|
||||
|
||||
//-----------------------------------------
|
||||
// GNU TAR format dictates that all paths *must* be in the *nix
|
||||
// format - if this is not the case, blame the tar vendor, not me!
|
||||
//-----------------------------------------
|
||||
|
||||
if ( preg_match("#/#", $file['name']) )
|
||||
{
|
||||
$path_info = explode( "/" , $file['name'] );
|
||||
$file_name = array_pop($path_info);
|
||||
} else
|
||||
{
|
||||
$path_info = array();
|
||||
$file_name = $file['name'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// If we have a path, then we must build the directory tree
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if (count($path_info) > 0)
|
||||
{
|
||||
foreach($path_info as $dir_component)
|
||||
{
|
||||
if ($dir_component == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( (file_exists($dir_component)) && (! is_dir($dir_component)) )
|
||||
{
|
||||
$this->warnings[] = "WARNING: $dir_component exists, but is not a directory";
|
||||
continue;
|
||||
}
|
||||
if (! is_dir($dir_component))
|
||||
{
|
||||
mkdir( $dir_component, 0777);
|
||||
chmod( $dir_component, 0777);
|
||||
}
|
||||
|
||||
if (! @chdir($dir_component))
|
||||
{
|
||||
$this->warnings[] = "ERROR: CHDIR to $dir_component FAILED!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// check the typeflags, and work accordingly
|
||||
//-----------------------------------------
|
||||
|
||||
if (($file['typeflag'] == 0) or (!$file['typeflag']) or ($file['typeflag'] == ""))
|
||||
{
|
||||
if ( $FH = fopen($file_name, "wb") )
|
||||
{
|
||||
fputs( $FH, $file['data'], strlen($file['data']) );
|
||||
fclose($FH);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->warnings[] = "Could not write data to $file_name";
|
||||
}
|
||||
}
|
||||
else if ($file['typeflag'] == 5)
|
||||
{
|
||||
if ( (file_exists($file_name)) && (! is_dir($file_name)) )
|
||||
{
|
||||
$this->warnings[] = "$file_name exists, but is not a directory";
|
||||
continue;
|
||||
}
|
||||
if (! is_dir($file_name))
|
||||
{
|
||||
@mkdir( $file_name, 0777);
|
||||
}
|
||||
}
|
||||
else if ($file['typeflag'] == 6)
|
||||
{
|
||||
$this->warnings[] = "Cannot handle named pipes";
|
||||
continue;
|
||||
}
|
||||
else if ($file['typeflag'] == 1)
|
||||
{
|
||||
$this->warnings[] = "Cannot handle system links";
|
||||
}
|
||||
else if ($file['typeflag'] == 4)
|
||||
{
|
||||
$this->warnings[] = "Cannot handle device files";
|
||||
}
|
||||
else if ($file['typeflag'] == 3)
|
||||
{
|
||||
$this->warnings[] = "Cannot handle device files";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->warnings[] = "Unknown typeflag found";
|
||||
}
|
||||
|
||||
if (! @chmod( $file_name, $file['mode'] ) )
|
||||
{
|
||||
$this->warnings[] = "ERROR: CHMOD $mode on $file_name FAILED!";
|
||||
}
|
||||
|
||||
@touch( $file_name, $file['mtime'] );
|
||||
|
||||
}
|
||||
|
||||
// Return to the "real" directory the scripts are in
|
||||
|
||||
@chdir($this->current_dir);
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// add files:
|
||||
// Takes an array of files, and adds them to the tar file
|
||||
// Optionally takes a path to use as root for the tar file - if omitted, it
|
||||
// assumes the current working directory is the tarball root. Be careful with
|
||||
// this, or you may get unexpected results -especially when attempting to read
|
||||
// and add files to the tarball.
|
||||
// EXAMPLE DIR STRUCTURE
|
||||
// /usr/home/somedir/forums/sources
|
||||
// BRIEF: To tar up the sources directory
|
||||
// $files = array( 'sources/somescript.php', 'sources/anothersscript.php' );
|
||||
// If CWD is 'somedir', you'll need to use $tar->add_files( $files, "/usr/home/somedir/forums" );
|
||||
// or it'll attempt to open /usr/home/somedir/sources/somescript.php - which would result
|
||||
// in an error. Either that, or use:
|
||||
// chdir("/usr/home/somedir/forums");
|
||||
// $tar->add_files( $files );
|
||||
//-----------------------------------------
|
||||
|
||||
function add_files( $files, $root_path="" )
|
||||
{
|
||||
// Do we a root path to change into?
|
||||
|
||||
if ($root_path != "")
|
||||
{
|
||||
chdir($root_path);
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
// is it a Mac OS X work file?
|
||||
|
||||
if ( preg_match("/\.ds_store/i", $file ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$typeflag = 0;
|
||||
$data = "";
|
||||
$linkname = "";
|
||||
|
||||
$stat = stat($file);
|
||||
|
||||
// Did stat fail?
|
||||
|
||||
if (! is_array($stat) )
|
||||
{
|
||||
$this->warnings[] = "Error: Stat failed on $file";
|
||||
continue;
|
||||
}
|
||||
|
||||
$mode = fileperms($file);
|
||||
$uid = $stat[4];
|
||||
$gid = $stat[5];
|
||||
$rdev = $stat[6];
|
||||
$size = filesize($file);
|
||||
$mtime = filemtime($file);
|
||||
|
||||
if (is_file($file))
|
||||
{
|
||||
// It's a plain file, so lets suck it up
|
||||
|
||||
$typeflag = 0;
|
||||
|
||||
if ( $FH = fopen($file, 'rb') )
|
||||
{
|
||||
$data = @fread( $FH, filesize($file) );
|
||||
fclose($FH);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->warnings[] = "ERROR: Failed to open $file";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (is_link($file))
|
||||
{
|
||||
$typeflag = 1;
|
||||
$linkname = @readlink($file);
|
||||
}
|
||||
else if (is_dir($file))
|
||||
{
|
||||
$typeflag = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sockets, Pipes and char/block specials are not
|
||||
// supported, so - lets use a silly value to keep the
|
||||
// tar ball legitimate.
|
||||
$typeflag = 9;
|
||||
}
|
||||
|
||||
// Add this data to our in memory tar file
|
||||
|
||||
$this->tar_in_mem[] = array (
|
||||
'name' => $file,
|
||||
'mode' => $mode,
|
||||
'uid' => $uid,
|
||||
'gid' => $gid,
|
||||
'size' => strlen($data),
|
||||
'mtime' => $mtime,
|
||||
'chksum' => " ",
|
||||
'typeflag' => $typeflag,
|
||||
'linkname' => $linkname,
|
||||
'magic' => "ustar\0",
|
||||
'version' => '00',
|
||||
'uname' => 'unknown',
|
||||
'gname' => 'unknown',
|
||||
'devmajor' => "",
|
||||
'devminor' => "",
|
||||
'prefix' => "",
|
||||
'data' => $data
|
||||
);
|
||||
// Clear the stat cache
|
||||
|
||||
@clearstatcache();
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
@chdir($this->current_dir);
|
||||
|
||||
//Return the number of files to anyone who's interested
|
||||
|
||||
return $count;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// write_tar:
|
||||
// Writes the tarball into the directory specified in new_tar with a filename
|
||||
// specified in new_tar
|
||||
//-----------------------------------------
|
||||
|
||||
function write_tar() {
|
||||
|
||||
if ($this->tarfile_path_name == "") {
|
||||
$this->error = 'No filename or path was specified to create a new tar file';
|
||||
return;
|
||||
}
|
||||
|
||||
if ( count($this->tar_in_mem) < 1 ) {
|
||||
$this->error = 'No data to write to the new tar file';
|
||||
return;
|
||||
}
|
||||
|
||||
$tardata = "";
|
||||
|
||||
foreach ($this->tar_in_mem as $file) {
|
||||
|
||||
$prefix = "";
|
||||
$tmp = "";
|
||||
$last = "";
|
||||
|
||||
// make sure the filename isn't longer than 99 characters.
|
||||
|
||||
if (strlen($file['name']) > 99)
|
||||
{
|
||||
$pos = strrpos( $file['name'], "/" );
|
||||
|
||||
if (is_string($pos) && !$pos)
|
||||
{
|
||||
// filename alone is longer than 99 characters!
|
||||
$this->error[] = "Filename {$file['name']} exceeds the length allowed by GNU Tape ARchives";
|
||||
continue;
|
||||
}
|
||||
|
||||
$prefix = substr( $file['name'], 0 , $pos ); // Move the path to the prefix
|
||||
$file['name'] = substr( $file['name'], ($pos+1));
|
||||
|
||||
if (strlen($prefix) > 154)
|
||||
{
|
||||
$this->error[] = "File path exceeds the length allowed by GNU Tape ARchives";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// BEGIN FORMATTING (a8a1a100)
|
||||
|
||||
$mode = sprintf("%6s ", decoct($file['mode']));
|
||||
$uid = sprintf("%6s ", decoct($file['uid']));
|
||||
$gid = sprintf("%6s ", decoct($file['gid']));
|
||||
$size = sprintf("%11s ", decoct($file['size']));
|
||||
$mtime = sprintf("%11s ", decoct($file['mtime']));
|
||||
|
||||
$tmp = pack("a100a8a8a8a12a12",$file['name'],$mode,$uid,$gid,$size,$mtime);
|
||||
|
||||
$last = pack("a1" , $file['typeflag']);
|
||||
$last .= pack("a100" , $file['linkname']);
|
||||
|
||||
$last .= pack("a6", "ustar"); // magic
|
||||
$last .= pack("a2", "" ); // version
|
||||
$last .= pack("a32", $file['uname']);
|
||||
$last .= pack("a32", $file['gname']);
|
||||
$last .= pack("a8", ""); // devmajor
|
||||
$last .= pack("a8", ""); // devminor
|
||||
$last .= pack("a155", $prefix);
|
||||
//$last .= pack("a12", "");
|
||||
$test_len = $tmp . $last . "12345678";
|
||||
$last .= $this->internal_build_string( "\0" , ($this->tar_header_length - strlen($test_len)) );
|
||||
|
||||
// Here comes the science bit, handling
|
||||
// the checksum.
|
||||
|
||||
$checksum = 0;
|
||||
|
||||
for ($i = 0 ; $i < 148 ; $i++ )
|
||||
{
|
||||
$checksum += ord( substr($tmp, $i, 1) );
|
||||
}
|
||||
|
||||
for ($i = 148 ; $i < 156 ; $i++)
|
||||
{
|
||||
$checksum += ord(' ');
|
||||
}
|
||||
|
||||
for ($i = 156, $j = 0 ; $i < 512 ; $i++, $j++)
|
||||
{
|
||||
$checksum += ord( substr($last, $j, 1) );
|
||||
}
|
||||
|
||||
$checksum = sprintf( "%6s ", decoct($checksum) );
|
||||
|
||||
$tmp .= pack("a8", $checksum);
|
||||
|
||||
$tmp .= $last;
|
||||
|
||||
$tmp .= $file['data'];
|
||||
|
||||
// Tidy up this chunk to the power of 512
|
||||
|
||||
if ($file['size'] > 0)
|
||||
{
|
||||
if ($file['size'] % 512 != 0)
|
||||
{
|
||||
$homer = $this->internal_build_string( "\0" , (512 - ($file['size'] % 512)) );
|
||||
$tmp .= $homer;
|
||||
}
|
||||
}
|
||||
|
||||
$tardata .= $tmp;
|
||||
}
|
||||
|
||||
// Add the footer
|
||||
|
||||
$tardata .= pack( "a512", "" );
|
||||
|
||||
// print it to the tar file
|
||||
|
||||
$FH = fopen( $this->tarfile_path_name, 'wb' );
|
||||
fputs( $FH, $tardata, strlen($tardata) );
|
||||
fclose($FH);
|
||||
|
||||
@chmod( $this->tarfile_path_name, 0777);
|
||||
|
||||
// Done..
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Read the tarball - builds an associative array
|
||||
//-----------------------------------------
|
||||
|
||||
function read_tar() {
|
||||
|
||||
$filename = $this->tarfile_path_name;
|
||||
|
||||
if ($filename == "") {
|
||||
$this->error = 'No filename specified when attempting to read a tar file';
|
||||
return array();
|
||||
}
|
||||
|
||||
if (! file_exists($filename) ) {
|
||||
$this->error = 'Cannot locate the file '.$filename;
|
||||
return array();
|
||||
}
|
||||
|
||||
$tar_info = array();
|
||||
|
||||
$this->tar_filename = $filename;
|
||||
|
||||
// Open up the tar file and start the loop
|
||||
|
||||
if (! $FH = fopen( $filename , 'rb' ) ) {
|
||||
$this->error = "Cannot open $filename for reading";
|
||||
return array();
|
||||
}
|
||||
|
||||
// Grrr, perl allows spaces, PHP doesn't. Pack strings are hard to read without
|
||||
// them, so to save my sanity, I'll create them with spaces and remove them here
|
||||
|
||||
$this->tar_unpack_header = preg_replace( "/\s/", "" , $this->tar_unpack_header);
|
||||
|
||||
while (!feof($FH)) {
|
||||
|
||||
$buffer = @fread( $FH , $this->tar_header_length );
|
||||
|
||||
// check the block
|
||||
|
||||
$checksum = 0;
|
||||
|
||||
for ($i = 0 ; $i < 148 ; $i++) {
|
||||
$checksum += ord( substr($buffer, $i, 1) );
|
||||
}
|
||||
for ($i = 148 ; $i < 156 ; $i++) {
|
||||
$checksum += ord(' ');
|
||||
}
|
||||
for ($i = 156 ; $i < 512 ; $i++) {
|
||||
$checksum += ord( substr($buffer, $i, 1) );
|
||||
}
|
||||
|
||||
$fa = unpack( $this->tar_unpack_header, $buffer);
|
||||
|
||||
$name = trim($fa[filename]);
|
||||
$mode = OctDec(trim($fa[mode]));
|
||||
$uid = OctDec(trim($fa[uid]));
|
||||
$gid = OctDec(trim($fa[gid]));
|
||||
$size = OctDec(trim($fa[size]));
|
||||
$mtime = OctDec(trim($fa[mtime]));
|
||||
$chksum = OctDec(trim($fa[chksum]));
|
||||
$typeflag = trim($fa[typeflag]);
|
||||
$linkname = trim($fa[linkname]);
|
||||
$magic = trim($fa[magic]);
|
||||
$version = trim($fa[version]);
|
||||
$uname = trim($fa[uname]);
|
||||
$gname = trim($fa[gname]);
|
||||
$devmajor = OctDec(trim($fa[devmajor]));
|
||||
$devminor = OctDec(trim($fa[devminor]));
|
||||
$prefix = trim($fa[prefix]);
|
||||
|
||||
if ( ($checksum == 256) && ($chksum == 0) ) {
|
||||
//EOF!
|
||||
break;
|
||||
}
|
||||
|
||||
if ($prefix) {
|
||||
$name = $prefix.'/'.$name;
|
||||
}
|
||||
|
||||
// Some broken tars don't set the type flag
|
||||
// correctly for directories, so we assume that
|
||||
// if it ends in / it's a directory...
|
||||
|
||||
if ( (preg_match( "#/$#" , $name)) and (! $name) ) {
|
||||
$typeflag = 5;
|
||||
}
|
||||
|
||||
// If it's the end of the tarball...
|
||||
$test = $this->internal_build_string( '\0' , 512 );
|
||||
if ($buffer == $test) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Read the next chunk
|
||||
|
||||
$data = @fread( $FH, $size );
|
||||
|
||||
if (strlen($data) != $size) {
|
||||
$this->error = "Read error on tar file";
|
||||
fclose( $FH );
|
||||
return array();
|
||||
}
|
||||
|
||||
$diff = $size % 512;
|
||||
|
||||
if ($diff != 0) {
|
||||
// Padding, throw away
|
||||
$crap = @fread( $FH, (512-$diff) );
|
||||
}
|
||||
|
||||
// Protect against tarfiles with garbage at the end
|
||||
|
||||
if ($name == "") {
|
||||
break;
|
||||
}
|
||||
|
||||
$tar_info[] = array (
|
||||
'name' => $name,
|
||||
'mode' => $mode,
|
||||
'uid' => $uid,
|
||||
'gid' => $gid,
|
||||
'size' => $size,
|
||||
'mtime' => $mtime,
|
||||
'chksum' => $chksum,
|
||||
'typeflag' => $typeflag,
|
||||
'linkname' => $linkname,
|
||||
'magic' => $magic,
|
||||
'version' => $version,
|
||||
'uname' => $uname,
|
||||
'gname' => $gname,
|
||||
'devmajor' => $devmajor,
|
||||
'devminor' => $devminor,
|
||||
'prefix' => $prefix,
|
||||
'data' => $data
|
||||
);
|
||||
}
|
||||
|
||||
fclose($FH);
|
||||
|
||||
return $tar_info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// INTERNAL FUNCTIONS - These should NOT be called outside this module
|
||||
//+------------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------
|
||||
// build_string: Builds a repititive string
|
||||
//-----------------------------------------
|
||||
|
||||
function internal_build_string($string="", $times=0) {
|
||||
|
||||
$return = "";
|
||||
for ($i=0 ; $i < $times ; ++$i ) {
|
||||
$return .= $string;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invision Power Board
|
||||
*
|
||||
* ROOT PATH
|
||||
*
|
||||
* If __FILE__ is not supported, try ./sitecontrol and
|
||||
* turn off "USE_SHUTDOWN" or manually add in
|
||||
* the full path
|
||||
* @since 2.0.0.2005-01-01
|
||||
*/
|
||||
define( 'INS_ROOT_PATH', str_replace( "//", "/", str_replace( "/core", "", str_replace( "\\", "/", dirname( __FILE__ ) ) ) ) . "/" );
|
||||
|
||||
/**
|
||||
* Version numbers
|
||||
*
|
||||
* @since 2.0.0.2005-01-01
|
||||
*/
|
||||
define ( 'IPBVERSION', '2.2.0 RC 1' );
|
||||
define ( 'IPB_LONG_VERSION', '22006' );
|
||||
|
||||
/**
|
||||
* DOC ROOT PATH
|
||||
*
|
||||
* If __FILE__ is not supported, try ./sitecontrol and
|
||||
* turn off "USE_SHUTDOWN" or manually add in
|
||||
* the full path
|
||||
* @since 2.0.0.2005-01-01
|
||||
*/
|
||||
define( 'INS_DOC_ROOT_PATH', preg_replace( "#/{1,}#", "/", str_replace( "/install/core", "", str_replace( "\\", "/", dirname( __FILE__ ) ) ) ) . "/" );
|
||||
|
||||
/**
|
||||
* SQL FILE
|
||||
* Use this to add a SQL file
|
||||
*/
|
||||
define( 'INS_SQL_FILE', INS_DOC_ROOT_PATH . '/sources/sql/<%driver%>_admin_queries.php' );
|
||||
|
||||
/**
|
||||
* SQL DEFAULT PREFIX
|
||||
*/
|
||||
define( 'INS_DEFAULT_SQL_PREFIX', 'ibf_' );
|
||||
|
||||
/**
|
||||
* IPS_KERNEL Location
|
||||
*/
|
||||
//define( 'INS_KERNEL_PATH', "../ips_kernel" );
|
||||
define( 'INS_KERNEL_PATH', INS_DOC_ROOT_PATH . "ips_kernel/" );
|
||||
|
||||
error_reporting ( E_ERROR | E_WARNING | E_PARSE );
|
||||
set_magic_quotes_runtime( 0 );
|
||||
|
||||
define ( 'IN_ACP', 1 );
|
||||
define ( 'IN_IPB', 1 );
|
||||
define ( 'IN_DEV', 0 );
|
||||
define ( 'USE_SHUTDOWN', 0 );
|
||||
define ( 'SAFE_MODE_ON', 0 );
|
||||
define ( 'ROOT_PATH', INS_DOC_ROOT_PATH );
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,607 @@
|
||||
<?php
|
||||
/**
|
||||
* Invision Power Board
|
||||
* Template Controller for installer framework
|
||||
*/
|
||||
|
||||
class install_template
|
||||
{
|
||||
var $page_title = '';
|
||||
var $page_content = '';
|
||||
var $page_current = '';
|
||||
|
||||
var $install_pages = array();
|
||||
|
||||
var $ipsclass;
|
||||
|
||||
/**
|
||||
* install_template::install_template
|
||||
*
|
||||
* CONSTRUCTOR
|
||||
*
|
||||
*/
|
||||
function install_template( &$ipsclass )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$_pages = array();
|
||||
$this->ipsclass =& $ipsclass;
|
||||
|
||||
//-----------------------------------------
|
||||
// Grab XML file and check
|
||||
//-----------------------------------------
|
||||
|
||||
if ( file_exists( INS_ROOT_PATH . 'installfiles/sequence.xml' ) )
|
||||
{
|
||||
$config = implode( '', file( INS_ROOT_PATH . 'installfiles/sequence.xml' ) );
|
||||
$xml = new class_xml();
|
||||
|
||||
$config = $xml->xml_parse_document( $config );
|
||||
|
||||
//-----------------------------------------
|
||||
// Loop through and sort out settings...
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( $xml->xml_array['installdata']['action'] as $id => $entry )
|
||||
{
|
||||
$_pages[ $entry['position']['VALUE'] ] = array( 'file' => $entry['file']['VALUE'],
|
||||
'menu' => $entry['menu']['VALUE'] );
|
||||
}
|
||||
|
||||
ksort( $_pages );
|
||||
|
||||
foreach( $_pages as $position => $data )
|
||||
{
|
||||
$this->install_pages[ $data['file'] ] = $data['menu'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->install_pages['done'] = 'Finish';
|
||||
|
||||
/* Set Current Page */
|
||||
$this->page_current = ( $this->ipsclass->input['p'] ) ? $this->ipsclass->input['p'] : 'requirements';
|
||||
|
||||
if( ! $this->install_pages[$this->page_current] )
|
||||
{
|
||||
$this->page_current = 'requirements';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* install_template::set_title
|
||||
*
|
||||
* Sets the title for the current page
|
||||
*
|
||||
* @var string $title
|
||||
*/
|
||||
function set_title( $title )
|
||||
{
|
||||
$this->page_title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* install_template::append
|
||||
*
|
||||
* Adds to the main body output
|
||||
*
|
||||
* @var string $add
|
||||
*/
|
||||
|
||||
function append( $add )
|
||||
{
|
||||
$this->page_content .= $add;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* install_template::output
|
||||
*
|
||||
* Builds page and sends to browser
|
||||
*
|
||||
*/
|
||||
function output()
|
||||
{
|
||||
/* Build Side Bar */
|
||||
$curr_reached = 0;
|
||||
$this->progress = array();
|
||||
|
||||
foreach( $this->install_pages as $key => $page )
|
||||
{
|
||||
if( $key == $this->page_current )
|
||||
{
|
||||
$this->progress[] = array( 'step_doing', $page );
|
||||
$curr_reached = 1;
|
||||
}
|
||||
else if( $curr_reached )
|
||||
{
|
||||
$this->progress[] = array( 'step_notdone', $page );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->progress[] = array( 'step_done', $page );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->page_template();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* HTML TEMPLATE FUNCTIONS
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Main Template
|
||||
// ------------------------------------------------------------
|
||||
function page_template()
|
||||
{
|
||||
echo <<<EOF
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>IPS Installer</title>
|
||||
<style type='text/css' media='all'>
|
||||
@import url('install.css');
|
||||
</style>
|
||||
<script type='text/javascript'>
|
||||
//<![CDATA[
|
||||
if (top.location != self.location) { top.location = self.location }
|
||||
var use_enhanced_js = 1;
|
||||
//]]>
|
||||
</script>
|
||||
<script type="text/javascript" src='ips_xmlhttprequest.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
<form id='install-form' action='index.php{$this->next_action}' method='post'>
|
||||
<input type='hidden' name='saved_data' value='{$this->saved_data}'>
|
||||
|
||||
<div id='ipswrapper'>
|
||||
<div class='main_shell'>
|
||||
|
||||
<h1><img src='images/package_icon.gif' align='absmiddle' /> Welcome to the IPS Product Installer</h1>
|
||||
<div class='content_shell'>
|
||||
<div class='package'>
|
||||
<div>
|
||||
<div class='install_info'>
|
||||
<h3>{$this->install_pages[$this->page_current]}</h3>
|
||||
|
||||
<ul id='progress'>
|
||||
|
||||
EOF;
|
||||
|
||||
foreach( $this->progress as $p )
|
||||
{
|
||||
echo "<li class='{$p[0]}'>{$p[1]}</li>";
|
||||
}
|
||||
|
||||
echo <<<EOF
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class='content_wrap'>
|
||||
<div style='border-bottom: 1px solid #939393; padding-bottom: 4px;'>
|
||||
<div class='float_img'>
|
||||
<img src='images/box.gif' />
|
||||
</div>
|
||||
|
||||
<div style='vertical-align: middle'>
|
||||
<h2>{$this->product_name} Installation</h2>
|
||||
<strong>{$this->product_version}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div style='clear:both'></div>
|
||||
|
||||
{$this->page_content}
|
||||
<br />
|
||||
</div>
|
||||
</div>
|
||||
<br clear='all' />
|
||||
|
||||
<div class='hr'></div>
|
||||
<div style='padding-top: 17px; padding-right: 15px; padding-left: 15px'>
|
||||
<div style='float: left'>
|
||||
<input type='button' class='nav_button' value='Cancel Installation' onclick="window.location='index.php';return false;">
|
||||
</div>
|
||||
|
||||
<div style='float: right'>
|
||||
EOF;
|
||||
|
||||
if( ! $this->hide_next )
|
||||
{
|
||||
if( $this->next_action == 'disabled' )
|
||||
{
|
||||
echo <<<EOF
|
||||
<input type='submit' class='nav_button' value='Install can not continue...' disabled='disabled'>
|
||||
EOF;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo <<<EOF
|
||||
<input type='submit' class='nav_button' value='Next >'>
|
||||
EOF;
|
||||
}
|
||||
}
|
||||
|
||||
$date = date("Y");
|
||||
|
||||
echo <<<EOF
|
||||
</div>
|
||||
</div>
|
||||
<div style='clear: both;'></div>
|
||||
<div class='copyright'>
|
||||
©
|
||||
EOF;
|
||||
echo date("Y");
|
||||
echo <<<EOF
|
||||
Invision Power Services, Inc.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOF;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Requirements Page Template
|
||||
// ------------------------------------------------------------
|
||||
function requirements_page( $php_version, $sql_version )
|
||||
{
|
||||
return <<<EOF
|
||||
<div>
|
||||
|
||||
<div style='float: left; margin-right: 7px; margin-left: 5px;'>
|
||||
<img src='images/wizard.gif' align='absmiddle' />
|
||||
</div>
|
||||
<div>
|
||||
Welcome to the installer for {$this->product_name}. This wizard will guide you through the installation process.
|
||||
</div>
|
||||
</div>
|
||||
<br/><br/>
|
||||
|
||||
<h3>System Requirements</h3>
|
||||
|
||||
<br />
|
||||
<strong>PHP:</strong> v{$php_version} or better<br />
|
||||
<strong>SQL:</strong> mySQL v$sql_version or better
|
||||
<br /><br />
|
||||
EOF;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// EULA Page Template
|
||||
// ------------------------------------------------------------
|
||||
function eula_page( $eula )
|
||||
{
|
||||
return <<<EOF
|
||||
|
||||
<script language='javascript'>
|
||||
|
||||
check_eula = function()
|
||||
{
|
||||
if( document.getElementById( 'eula' ).checked == true )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
alert( 'You must agree to the license before continuing' );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById( 'install-form' ).onsubmit = check_eula;
|
||||
|
||||
</script>
|
||||
|
||||
Please read and agree to the End User License Agreement before continuing.<br /><br />
|
||||
|
||||
|
||||
<div class='eula'>
|
||||
$eula
|
||||
</div>
|
||||
<input type='checkbox' name='eula' id='eula'><strong> I agree to the license agreement</strong>
|
||||
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Address Page Template
|
||||
// ------------------------------------------------------------
|
||||
function address_page( $dir, $url )
|
||||
{
|
||||
return <<<EOF
|
||||
<div id='warn-message' style='display:none;'><center><div id='warn-message-content'></div></center></div>
|
||||
|
||||
<fieldset>
|
||||
<legend><img src='images/addresses.gif' align='absmiddle' /> Address details</legend>
|
||||
|
||||
<table style='width: 100%; border: 0px; padding:0px' cellspacing='0'>
|
||||
<tr>
|
||||
<td width='30%' class='title'>Install Directory:</td>
|
||||
<td width='70%' class='content'><input type='text' class='sql_form' name='install_dir' value='{$dir}'></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td width='30%' class='title'>Install Address:</td>
|
||||
<td width='70%' class='content'><input type='text' class='sql_form' name='install_url' value='{$url}'></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
EOF;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// DB Check Page Template
|
||||
// ------------------------------------------------------------
|
||||
function db_check_page( $drivers=array() )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// INIT
|
||||
//-----------------------------------------
|
||||
|
||||
$_drivers = '';
|
||||
|
||||
foreach ($drivers as $k => $v)
|
||||
{
|
||||
$selected = ($v == "mysql") ? " selected='selected'" : "";
|
||||
$_drivers .= "<option value='".$v."'".$selected.">".strtoupper($v)."</option>\n";
|
||||
}
|
||||
|
||||
return <<<EOF
|
||||
<div class='info' style='margin-top: 4px;'>
|
||||
<div class='float_img'><img src='images/help.gif' /></div>
|
||||
|
||||
<div>Please select which database engine you wish to use.</div>
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
<legend><img src='images/db.gif' align='absmiddle' /> Database Engine</legend>
|
||||
<table style='width: 100%; border: 0px; padding:0px' cellspacing='0'>
|
||||
<tr>
|
||||
<td width='30%' class='title'>SQL Driver:</td>
|
||||
<td width='70%' class='content'>
|
||||
<select name='sql_driver' class='sql_form'>$_drivers</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
EOF;
|
||||
}
|
||||
// ------------------------------------------------------------
|
||||
// DB Page Template
|
||||
// ------------------------------------------------------------
|
||||
function db_page()
|
||||
{
|
||||
$prefix = $_REQUEST['db_pre'] ? $_REQUEST['db_pre'] : INS_DEFAULT_SQL_PREFIX;
|
||||
|
||||
return <<<EOF
|
||||
<div class='info' style='margin-top: 4px;'>
|
||||
<div class='float_img'><img src='images/help.gif' /></div>
|
||||
|
||||
<div>Ask your webhost if you are unsure about any of these settings. You must create the database before installing..</div>
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
<legend><img src='images/db.gif' align='absmiddle' /> Database details</legend>
|
||||
<table style='width: 100%; border: 0px; padding:0px' cellspacing='0'>
|
||||
<!--{TOP.SQL}-->
|
||||
<tr>
|
||||
<td width='30%' class='title'>SQL Host:</td>
|
||||
<td width='70%' class='content'>
|
||||
<input type='text' class='sql_form' value='localhost' name='db_host'>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='title'>Database Name:</td>
|
||||
<td class='content'>
|
||||
<input type='text' class='sql_form' name='db_name' value='{$_REQUEST['db_name']}'>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='title'>SQL Username:</td>
|
||||
<td class='content'>
|
||||
<input type='text' class='sql_form' name='db_user' value='{$_REQUEST['db_user']}'>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='title'>SQL Password:</td>
|
||||
<td class='content'>
|
||||
<input type='password' class='sql_form' name='db_pass'>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='title'>SQL Table Prefix:</td>
|
||||
<td class='content'>
|
||||
<input type='text' class='sql_form' name='db_pre' value='$prefix'>
|
||||
</td>
|
||||
</tr>
|
||||
<!--{EXTRA.SQL}-->
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Admin Page Template
|
||||
// ------------------------------------------------------------
|
||||
function admin_page()
|
||||
{
|
||||
return <<<EOF
|
||||
<fieldset>
|
||||
<legend><img src='images/admin.gif' align='absmiddle' /> Your administrative account</legend>
|
||||
<table style='width: 100%; border: 0px; padding:0px' cellspacing='0'>
|
||||
<tr>
|
||||
<td width='30%' class='title'>Username:</td>
|
||||
|
||||
<td width='70%' class='content'><input type='text' class='sql_form' name='username'></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='title'>Password:</td>
|
||||
<td class='content'><input type='password' class='sql_form' name='password'></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='title'>Confirm Password:</td>
|
||||
|
||||
<td class='content'><input type='password' class='sql_form' name='confirm_password'></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='title'>E-mail Address:</td>
|
||||
<td class='content'><input type='text' class='sql_form' name='email'></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Install Page SPlash Template
|
||||
// ------------------------------------------------------------
|
||||
function install_page()
|
||||
{
|
||||
return <<<EOF
|
||||
The installer is now ready to complete the installation of your {$this->product_name}. Click <strong>Start</strong> to
|
||||
begin the automatic process!<br /><br />
|
||||
|
||||
|
||||
<div style='float: right'>
|
||||
<input type='submit' class='nav_button' value='Start installation...'>
|
||||
</div>
|
||||
EOF;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Install Page Refresh Template
|
||||
// ------------------------------------------------------------
|
||||
function install_page_refresh( $output=array() )
|
||||
{
|
||||
$HTML = <<<EOF
|
||||
<script type='text/javascript'>
|
||||
//<![CDATA[
|
||||
setTimeout("form_redirect()",2000);
|
||||
|
||||
function form_redirect()
|
||||
{
|
||||
document.getElementById( 'install-form' ).submit();
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<ul id='auto_progress'>
|
||||
EOF;
|
||||
|
||||
foreach( $output as $l )
|
||||
{
|
||||
$HTML .= <<<EOF
|
||||
<li><img src='images/check.gif' align='absmiddle' /> $l</li>
|
||||
EOF;
|
||||
}
|
||||
|
||||
$HTML .= <<<EOF
|
||||
</ul>
|
||||
<br />
|
||||
<div style='float: right'>
|
||||
<input type='submit' class='nav_button' value='Click here if not forwarded' />
|
||||
</div>
|
||||
EOF;
|
||||
|
||||
return $HTML;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Install Progress Screen
|
||||
// ------------------------------------------------------------
|
||||
function install_progress( $line )
|
||||
{
|
||||
$HTML = <<<EOF
|
||||
<ul id='auto_progress'>
|
||||
EOF;
|
||||
|
||||
foreach( $line as $l )
|
||||
{
|
||||
$HTML .= <<<EOF
|
||||
<li><img src='images/check.gif' align='absmiddle' /> $l</li>
|
||||
EOF;
|
||||
}
|
||||
|
||||
$HTML .= <<<EOF
|
||||
</ul>
|
||||
EOF;
|
||||
|
||||
return $HTML;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Install Done Screen
|
||||
// ------------------------------------------------------------
|
||||
function install_done( $url, $install_locked )
|
||||
{
|
||||
$extra = '';
|
||||
|
||||
if ( ! $install_locked )
|
||||
{
|
||||
$extra = "<div class='warning'>
|
||||
<div style='float: left; margin-right: 7px; margin-left: 5px'><img src='images/warning.gif' /></div>
|
||||
<p>INSTALLER NOT LOCKED<br />Please disable or remove 'install/index.php' immediately!</p>
|
||||
</div>";
|
||||
}
|
||||
|
||||
$HTML .= <<<EOF
|
||||
<br />
|
||||
|
||||
<img src='images/install_done.gif' align='absmiddle' /> <span class='done_text'>Installation complete!</span><Br /><Br />
|
||||
Congratulations, your <a href='$url'>{$this->product_name}</a> is now installed and ready to use! Below are some
|
||||
links you may find useful.<br /><br /><br />
|
||||
$extra
|
||||
<h3>Useful Links</h3>
|
||||
<ul id='links'>
|
||||
<li><img src='images/link.gif' align='absmiddle' /> <a href='http://www.invisionpower.com/landing/?p=clientarea'>Client area</a></li>
|
||||
<li><img src='images/link.gif' align='absmiddle' /> <a href='http://www.invisionpower.com/landing/?p=docs-ipb'>Documentation</a></li>
|
||||
<li><img src='images/link.gif' align='absmiddle' /> <a href='http://www.invisionpower.com/landing/?p=forums'>IPS Company Forum</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
EOF;
|
||||
return $HTML;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Warning Message Template
|
||||
// ------------------------------------------------------------
|
||||
function warning( $messages )
|
||||
{
|
||||
$HTML = <<<EOF
|
||||
<br />
|
||||
<div class='warning'>
|
||||
<div style='float: left; margin-right: 7px; margin-left: 5px'><img src='images/warning.gif' /></div>
|
||||
EOF;
|
||||
|
||||
foreach( $messages as $msg )
|
||||
{
|
||||
$HTML .= "<p>$msg</p>";
|
||||
}
|
||||
|
||||
$HTML .= <<<EOF
|
||||
</div><br />
|
||||
EOF;
|
||||
|
||||
$this->append( $HTML );
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user