Script written by Matthew Mecham
| > Date started: 19th March 2004
|
+--------------------------------------------------------------------------
*/
error_reporting (E_ERROR | E_WARNING | E_PARSE);
set_magic_quotes_runtime(0);
//+------------------------------------------------------------------------
// ENTER YOUR PATH TO THE DIRECTORY THIS SCRIPT IS IN.
//+------------------------------------------------------------------------
// Tips:
//
// If you are using Windows and Apache, do not
// use backslashes, use normal forward slashes.
// You may need to remove the drive letter also
// Example: C:\apache\htdocs\ibforums\ will need
// to be: /apache/htdocs/ibforums/
//
// If you are using Windows and IIS, then you will
// need to enter double backslashes.
//
// In all cases, please enter a trailing slash (or
// trailing backslashes...)
//+------------------------------------------------------------------------
define( 'THIS_ROOT_PATH', './' );
//+------------------------------------------------------------------------
// ROOT TO REST OF IPB (SHOULD BE ABLE TO LEAVE AS-IS
//+------------------------------------------------------------------------
define( 'ROOT_PATH', '../' );
//-----------------------------------------------
// NO USER EDITABLE SECTIONS BELOW
//-----------------------------------------------
define( 'KERNEL_PATH', ROOT_PATH.'ips_kernel/' );
define( 'CACHE_PATH' , ROOT_PATH );
define ( 'IN_IPB', 1 );
define ( 'IN_DEV', 0 );
define ( 'IPBVERSION', '2.0.0' );
define ( 'USE_SHUTDOWN', 0 );
define ( 'SAFE_MODE_ON', 0 );
//-----------------------------------------------
// INIT CLASSES
//-----------------------------------------------
require_once( ROOT_PATH.'sources/functions.php' );
$template = new template;
$std = new FUNC();
$ibforums = new info();
//-----------------------------------------------
// PARSE INCOMING
//-----------------------------------------------
$VARS = $std->parse_incoming();
//+---------------------------------------
// What are we doing then? Eh? I'm talking to you!
//+---------------------------------------
if ( file_exists( THIS_ROOT_PATH.'install.lock') )
{
install_error("This installer is locked!
Please (via FTP) remove the 'install/install.lock' file");
exit();
}
switch($VARS['a'])
{
case '1':
do_setup_form();
break;
case '2':
do_install();
break;
case 'templates':
do_templates();
break;
case '3':
do_finish();
break;
default:
do_intro();
break;
}
function do_finish()
{
global $std, $template, $root, $VARS, $DB, $ibforums;
//-----------------------------------
// IMPORT $INFO!
//-----------------------------------
$require = ROOT_PATH."conf_global.php";
if ( ! file_exists($require) )
{
install_error("Could not locate '$require'. You may need to enter a value for the root path in this installer script, to do this, simply open up this script in a text editor and enter a value in \$root - remember to add a trailing slash. NT users will need to use double backslashes");
}
include($require);
$INFO['sql_driver'] = strtolower($INFO['sql_driver']);
//-----------------------------------
// Get SQL engine
//-----------------------------------
require ( KERNEL_PATH.'class_db_'.$INFO['sql_driver'].".php");
$DB = new db_driver();
$DB->obj['sql_database'] = $INFO['sql_database'];
$DB->obj['sql_user'] = $INFO['sql_user'];
$DB->obj['sql_pass'] = $INFO['sql_pass'];
$DB->obj['sql_host'] = $INFO['sql_host'];
$DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix'];
$DB->obj['query_cache_file'] = ROOT_PATH.'sources/sql/'.$INFO['sql_driver'].'_admin_queries.php';
$DB->obj['use_shutdown'] = 0;
//-----------------------------------
// Required vars?
//-----------------------------------
if ( is_array( $DB->connect_vars ) and count( $DB->connect_vars ) )
{
foreach( $DB->connect_vars as $k => $v )
{
$DB->connect_vars[ $k ] = $INFO[ $k ];
}
}
define ( 'SQL_DRIVER', strtolower($INFO['sql_driver']) );
$ibforums->vars['sql_driver'] = SQL_DRIVER;
//--------------------------------
// Get a DB connection
//--------------------------------
$DB->connect();
//-----------------------------------
// Get ACP library
//-----------------------------------
require_once( ROOT_PATH.'sources/admin/admin_cache_functions.php' );
$acp = new admin_cache_functions();
//-----------------------------------
// Cache skins and shit
//-----------------------------------
$acp->_rebuild_all_caches( array(2) );
//-------------------------------------------------------------
// Forum cache
//-------------------------------------------------------------
$ibforums->cache['forum_cache'] = array();
$DB->simple_construct( array( 'select' => '*',
'from' => 'forums',
'order' => 'parent_id, position'
) );
$DB->simple_exec();
while( $fr = $DB->fetch_row() )
{
$perms = unserialize(stripslashes($fr['permission_array']));
$fr['read_perms'] = $perms['read_perms'];
$fr['reply_perms'] = $perms['reply_perms'];
$fr['start_perms'] = $perms['start_perms'];
$fr['upload_perms'] = $perms['upload_perms'];
$fr['show_perms'] = $perms['show_perms'];
unset($fr['permission_array']);
$ibforums->cache['forum_cache'][ $fr['id'] ] = $fr;
}
$std->update_cache( array( 'name' => 'forum_cache', 'array' => 1, 'deletefirst' => 1 ) );
//-------------------------------------------------------------
// Group Cache
//-------------------------------------------------------------
$ibforums->cache['group_cache'] = array();
$DB->simple_construct( array( 'select' => "*",
'from' => 'groups'
) );
$DB->simple_exec();
while ( $i = $DB->fetch_row() )
{
$ibforums->cache['group_cache'][ $i['g_id'] ] = $i;
}
$std->update_cache( array( 'name' => 'group_cache', 'array' => 1, 'deletefirst' => 1 ) );
//-------------------------------------------------------------
// Systemvars
//-------------------------------------------------------------
$ibforums->cache['systemvars'] = array();
$result = $DB->simple_exec_query( array( 'select' => 'count(*) as cnt', 'from' => 'mail_queue' ) );
$ibforums->cache['systemvars']['mail_queue'] = intval( $result['cnt'] );
$ibforums->cache['systemvars']['task_next_run'] = time() + 3600;
$std->update_cache( array( 'name' => 'systemvars', 'array' => 1, 'deletefirst' => 1 ) );
//-------------------------------------------------------------
// Stats
//-------------------------------------------------------------
$ibforums->cache['stats'] = array();
$ibforums->cache['stats']['total_replies'] = 0;
$ibforums->cache['stats']['total_topics'] = 1;
$ibforums->cache['stats']['mem_count'] = 1;
$r = $DB->simple_exec_query( array( 'select' => 'id, name',
'from' => 'members',
'order' => 'id DESC',
'limit' => '0,1'
) );
$ibforums->cache['stats']['last_mem_name'] = $r['name'];
$ibforums->cache['stats']['last_mem_id'] = $r['id'];
$std->update_cache( array( 'name' => 'stats', 'array' => 1, 'deletefirst' => 1 ) );
//-------------------------------------------------------------
// Ranks
//-------------------------------------------------------------
$ibforums->cache['ranks'] = array();
$DB->simple_construct( array( 'select' => 'id, title, pips, posts',
'from' => 'titles',
'order' => "posts DESC",
) );
$DB->simple_exec();
while ($i = $DB->fetch_row())
{
$ibforums->cache['ranks'][ $i['id'] ] = array(
'TITLE' => $i['title'],
'PIPS' => $i['pips'],
'POSTS' => $i['posts'],
);
}
$std->update_cache( array( 'name' => 'ranks', 'array' => 1, 'deletefirst' => 1 ) );
//-------------------------------------------------------------
// SETTINGS
//-------------------------------------------------------------
$ibforums->cache['settings'] = array();
$DB->simple_construct( array( 'select' => '*', 'from' => 'conf_settings', 'where' => 'conf_add_cache=1' ) );
$info = $DB->simple_exec();
while ( $r = $DB->fetch_row($info) )
{
$ibforums->cache['settings'][ $r['conf_key'] ] = $r['conf_value'] != "" ? $r['conf_value'] : $r['conf_default'];
}
$std->update_cache( array( 'name' => 'settings', 'array' => 1, 'deletefirst' => 1 ) );
//-------------------------------------------------------------
// EMOTICONS
//-------------------------------------------------------------
$ibforums->cache['emoticons'] = array();
$DB->simple_construct( array( 'select' => 'typed,image,clickable,emo_set', 'from' => 'emoticons' ) );
$DB->simple_exec();
while ( $r = $DB->fetch_row() )
{
$ibforums->cache['emoticons'][] = $r;
}
$std->update_cache( array( 'name' => 'emoticons', 'array' => 1, 'deletefirst' => 1 ) );
//-------------------------------------------------------------
// LANGUAGES
//-------------------------------------------------------------
$ibforums->cache['languages'] = array();
$DB->simple_construct( array( 'select' => 'ldir,lname', 'from' => 'languages' ) );
$DB->simple_exec();
while ( $r = $DB->fetch_row() )
{
$ibforums->cache['languages'][] = $r;
}
$std->update_cache( array( 'name' => 'languages', 'array' => 1, 'deletefirst' => 1 ) );
//-------------------------------------------------------------
// ATTACHMENT TYPES
//-------------------------------------------------------------
$ibforums->cache['attachtypes'] = array();
$DB->simple_construct( array( 'select' => 'atype_extension,atype_mimetype,atype_post,atype_photo,atype_img', 'from' => 'attachments_type', 'where' => "atype_photo=1 OR atype_post=1" ) );
$DB->simple_exec();
while ( $r = $DB->fetch_row() )
{
$ibforums->cache['attachtypes'][ $r['atype_extension'] ] = $r;
}
$std->update_cache( array( 'name' => 'attachtypes', 'array' => 1, 'deletefirst' => 1 ) );
//-----------------------------------
// Attempt to lock the install..
//-----------------------------------
if ($FH = @fopen( THIS_ROOT_PATH.'install.lock', 'w' ) )
{
@fwrite( $FH, 'bleh', 4 );
@fclose($FH);
@chmod( THIS_ROOT_PATH.'install.lock', 0666 );
$template->print_top('Success!');
$msg="Although the installer is now locked (to re-install, remove the file 'install.lock'), for added security, please remove the index.php program before continuing.
CLICK HERE TO LOG IN!";
}
else
{
$template->print_top('Success!');
$msg = "PLEASE REMOVE THE INSTALLER ('index.php') BEFORE CONTINUING!
Failure to do so will enable ANYONE to delete your board at any time!
CLICK HERE TO LOG IN!";
}
$template->contents .= "
Success
The installation is now complete!
$msg
";
$template->output();
}
//+---------------------------------------
// Install the template files, woohoo and stuff
//+---------------------------------------
function do_templates()
{
global $std, $template, $root, $VARS, $HTTP_POST_VARS;
//-----------------------------------
// IMPORT $INFO!
//-----------------------------------
$require = ROOT_PATH."conf_global.php";
if ( ! file_exists($require) )
{
install_error("Could not locate '$require'. You may need to enter a value for the root path in this installer script, to do this, simply open up this script in a text editor and enter a value in \$root - remember to add a trailing slash. NT users will need to use double backslashes");
}
include($require);
//-----------------------------------
// Attempt a DB connection..
//-----------------------------------
require ( KERNEL_PATH.'class_db_'.$INFO['sql_driver'].".php");
$DB = new db_driver();
$DB->obj['sql_database'] = $INFO['sql_database'];
$DB->obj['sql_user'] = $INFO['sql_user'];
$DB->obj['sql_pass'] = $INFO['sql_pass'];
$DB->obj['sql_host'] = $INFO['sql_host'];
$DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix'];
$DB->obj['use_shutdown'] = 0;
$DB->return_die = 1;
//-----------------------------------
// Required vars?
//-----------------------------------
if ( is_array( $DB->connect_vars ) and count( $DB->connect_vars ) )
{
foreach( $DB->connect_vars as $k => $v )
{
$DB->connect_vars[ $k ] = $INFO[ $k ];
}
}
if (! $DB->connect())
{
install_error($DB->error);
}
define ( 'SQL_DRIVER', strtolower($INFO['sql_driver']) );
$ibforums->vars['sql_driver'] = SQL_DRIVER;
//-----------------------------------
// Get XML
//-----------------------------------
require_once( KERNEL_PATH.'class_xml.php' );
$xml = new class_xml();
//-----------------------------------
// Get XML file (TEMPLATES)
//-----------------------------------
$xmlfile = ROOT_PATH.'ipb_templates.xml';
$setting_content = implode( "", file($xmlfile) );
//-------------------------------
// Unpack the datafile (TEMPLATES)
//-------------------------------
$xml->xml_parse_document( $setting_content );
//-------------------------------
// (TEMPLATES)
//-------------------------------
if ( ! is_array( $xml->xml_array['templateexport']['templategroup']['template'] ) )
{
install_error("Error with ipb_templates.xml - could not process XML properly");
}
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();
$db_string = $DB->compile_db_insert_string($newrow);
$query = "INSERT INTO ".$INFO['sql_tbl_prefix']."skin_templates (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")";
if ( ! $DB->query($query) )
{
install_error($query."
".$DB->error);
}
}
//-------------------------------
// GET MACRO
//-------------------------------
$xmlfile = THIS_ROOT_PATH.'installfiles/ipb_macro.xml';
$setting_content = implode( "", file($xmlfile) );
//-------------------------------
// Unpack the datafile (MACRO)
//-------------------------------
$xml->xml_parse_document( $setting_content );
//-------------------------------
// (MACRO)
//-------------------------------
if ( ! is_array( $xml->xml_array['macroexport']['macrogroup']['macro'] ) )
{
install_error("Error with ipb_macro.xml - could not process XML properly");
}
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;
$db_string = $DB->compile_db_insert_string($newrow);
$query = "INSERT INTO ".$INFO['sql_tbl_prefix']."skin_macro (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")";
if ( ! $DB->query($query) )
{
install_error($query."
".$DB->error);
}
}
//-------------------------------
// WRAPPER / CSS
//-------------------------------
require_once( THIS_ROOT_PATH.'installfiles/components.php' );
$wrapper_record = array( 'set_wrapper' => $WRAPPER,
'set_css' => $CSS,
);
$str = $DB->compile_db_update_string($wrapper_record);
$query = "UPDATE ".$INFO['sql_tbl_prefix']."skin_sets set ".$str." where set_skin_set_id=1";
if ( ! $DB->query($query) )
{
install_error($query."
".$DB->error);
}
//-------------------------------
// ARE WE DONE? REALLY? COOL!!
//-------------------------------
$template->print_top('Success!');
$template->contents .= "
Success
Template files installed!
The installation process is now complete.
Click the link below to clean up the installer and build the required caches
CLICK HERE TO FINISH
";
$template->output();
}
//+---------------------------------------
function do_install()
{
global $std, $template, $VARS;
//-----------------------------------
// Ok, lets check for blankies...
//-----------------------------------
$DB = "";
$NEW_INFO = array();
$need = array('board_url','sql_host','sql_database','sql_user','adminname','adminpassword','adminpassword2','email');
foreach($need as $greed)
{
if ($VARS[ $greed ] == "")
{
install_error("You must complete all of the form with the sole exception of 'SQL Table prefix'");
}
}
//-----------------------------------
// Get converge
//-----------------------------------
require_once( KERNEL_PATH.'class_converge.php' );
$converge = new class_converge( $DB );
//-----------------------------------
// Get XML
//-----------------------------------
require_once( KERNEL_PATH.'class_xml.php' );
$xml = new class_xml();
//-----------------------------------
// Get XML file
//-----------------------------------
$xmlfile = THIS_ROOT_PATH.'installfiles/ipb_settings.xml';
$setting_content = implode( "", file($xmlfile) );
//-----------------------------------
// Fix up URL
//-----------------------------------
$VARS['board_url'] = preg_replace( "#/$#", "", $VARS['board_url'] );
if ($VARS['sql_tbl_prefix'] == "")
{
$VARS['sql_tbl_prefix'] = 'ibf_';
}
$safe_mode = intval( $VARS['safe_mode'] );
//-----------------------------------
// Did the admin passy and passy2 match?
//-----------------------------------
if ($VARS['adminpassword2'] != $VARS['adminpassword'])
{
install_error("Your passwords did not match");
}
//-----------------------------------
// Guess a path
//-----------------------------------
$root = THIS_ROOT_PATH;
if ( $root == './')
{
$root = str_replace( '\\', '/', getcwd() ) . '/';
$root = str_replace( 'install/', '', $root );
}
//-----------------------------------
// Attempt to write the config file.
//-----------------------------------
$INFO = array(
'sql_driver' => $VARS['sql_driver'],
'sql_host' => $VARS['sql_host'],
'sql_database' => $VARS['sql_database'],
'sql_user' => $_POST['sql_user'],
'sql_pass' => $_POST['sql_pass'],
'sql_tbl_prefix' => $VARS['sql_tbl_prefix'],
'sql_debug' => 1,
'board_start' => time(),
'installed' => 1,
'php_ext' => 'php',
'safe_mode' => $safe_mode,
'board_url' => $VARS['board_url'],
'admin_group' => '4',
'guest_group' => '2',
'member_group' => '3',
'auth_group' => '1',
);
//--------------------------------------------------
// Any "extra" configs required for this driver?
//--------------------------------------------------
if ( file_exists( THIS_ROOT_PATH.'sql/'.$VARS['sql_driver'].'_install.php' ) )
{
require_once( THIS_ROOT_PATH.'sql/'.$VARS['sql_driver'].'_install.php' );
$extra_install = new install_extra();
$extra_install->install_form_process();
if ( count( $extra_install->errors ) )
{
install_error( "The following error(s) occured when checking the SQL information:
".implode( "
", $extra_install->errors ) );
}
if ( is_array( $extra_install->info_extra ) and count( $extra_install->info_extra ) )
{
foreach( $extra_install->info_extra as $k => $v )
{
$INFO[ $k ] = $v;
}
}
}
//-----------------------------------
// Attempt a DB connection..
//-----------------------------------
require ( KERNEL_PATH.'class_db_'.$INFO['sql_driver'].".php");
$DB = new db_driver();
$DB->obj['sql_database'] = $INFO['sql_database'];
$DB->obj['sql_user'] = $INFO['sql_user'];
$DB->obj['sql_pass'] = $INFO['sql_pass'];
$DB->obj['sql_host'] = $INFO['sql_host'];
$DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix'];
$DB->obj['query_cache_file'] = ROOT_PATH.'sources/sql/'.$INFO['sql_driver'].'_admin_queries.php';
$DB->obj['use_shutdown'] = 0;
$DB->return_die = 1;
//-----------------------------------
// Required vars?
//-----------------------------------
if ( is_array( $DB->connect_vars ) and count( $DB->connect_vars ) )
{
foreach( $DB->connect_vars as $k => $v )
{
$DB->connect_vars[ $k ] = $INFO[ $k ];
}
}
//-----------------------------------
// Attempt a connect
//-----------------------------------
if ( ! $DB->connect() )
{
install_error( "Connection error:
".$DB->error );
}
define ( 'SQL_DRIVER', strtolower($INFO['sql_driver']) );
$ibforums->vars['sql_driver'] = SQL_DRIVER;
//-----------------------------------
// Write to disk
//-----------------------------------
$file_string = "<"."?php\n";
foreach( $INFO as $k => $v )
{
$file_string .= '$INFO['."'".$k."'".']'."\t\t\t=\t'".$v."';\n";
}
$file_string .= "\n".'?'.'>';
if ( $fh = fopen( ROOT_PATH.'conf_global.php', 'w' ) )
{
fputs($fh, $file_string, strlen($file_string) );
fclose($fh);
}
else
{
install_error("Could not write to 'conf_global.php'");
}
//-----------------------------------
// Require insert files
//-----------------------------------
require_once( THIS_ROOT_PATH.'sql/'.$INFO['sql_driver'].'_tables.php' );
require_once( THIS_ROOT_PATH.'sql/'.$INFO['sql_driver'].'_inserts.php' );
require_once( THIS_ROOT_PATH.'sql/'.$INFO['sql_driver'].'_fulltext.php' );
//-----------------------------------
// Populate the database...
//-----------------------------------
foreach( $TABLE as $q )
{
preg_match("/CREATE TABLE (\S+) \(/", $q, $match);
if ($match[1])
{
$DB->sql_drop_table( str_replace( 'ibf_', '', $match[1] ) );
}
if ($VARS['sql_tbl_prefix'] != "ibf_")
{
$q = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $VARS['sql_tbl_prefix']."\\1\\2", $q);
}
if ( ! $DB->query($q) )
{
install_error($q."
".$DB->error);
}
}
//-----------------------------------
// Create the fulltext index...
//-----------------------------------
if ( $DB->sql_can_fulltext() )
{
foreach( $INDEX as $q )
{
if ($VARS['sql_tbl_prefix'] != "ibf_")
{
$q = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $VARS['sql_tbl_prefix']."\\1\\2", $q);
}
if ( ! $DB->query($q) )
{
install_error($q."
".$DB->error);
}
}
}
//-----------------------------------
// Populate tables...
//-----------------------------------
foreach( $INSERT as $q )
{
if ($VARS['sql_tbl_prefix'] != "ibf_")
{
$q = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $VARS['sql_tbl_prefix']."\\1\\2", $q);
}
$q = str_replace( "<%time%>", time(), $q );
if ( ! $DB->query($q) )
{
install_error($q."
".$DB->error);
}
}
//-----------------------------------
// Insert the admin...
//-----------------------------------
$md5_once = trim(md5($VARS['adminpassword']));
$salt = $converge->generate_password_salt(5);
$key = $converge->generate_auto_log_in_key();
$rpass = $converge->generate_compiled_passhash($salt, $md5_once);
$salt = str_replace( '\\', "\\\\", $salt );
$time = time();
//$salt = preg_replace( "/'/", "\\'", $salt );
//-----------------------------------
// Members...
//-----------------------------------
$member_record = array ( 'id' => 1,
'name' => $VARS['adminname'],
'mgroup' => 4,
'email' => $VARS['email'],
'joined' => $time,
'ip_address' => '127.0.0.1',
'posts' => 0,
'title' => 'Administrator',
'last_visit' => $time,
'last_activity' => $time,
'member_login_key' => $key,
);
$db_string = $DB->compile_db_insert_string($member_record);
$query = "INSERT INTO ".$VARS['sql_tbl_prefix']."members (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")";
if ( ! $DB->query($query) )
{
install_error($query."
".$DB->error);
}
//-----------------------------------
// Converge...
//-----------------------------------
$converge_record = array ( 'converge_email' => $VARS['email'],
'converge_joined' => $time,
'converge_pass_hash' => $rpass,
'converge_pass_salt' => $salt,
);
$db_string = $DB->compile_db_insert_string($converge_record);
$query = "INSERT INTO ".$VARS['sql_tbl_prefix']."members_converge (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")";
if ( ! $DB->query($query) )
{
install_error($query."
".$DB->error);
}
//-----------------------------------
// Member Extra...
//-----------------------------------
$member_extra_record = array ( 'id' => 1,
'signature' => '',
'vdirs' => '',
);
$db_string = $DB->compile_db_insert_string($member_extra_record);
$query = "INSERT INTO ".$VARS['sql_tbl_prefix']."member_extra (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")";
if ( ! $DB->query($query) )
{
install_error($query."
".$DB->error);
}
//-------------------------------
// Do we have a reg / copy key?
//-------------------------------
if ( file_exists( ROOT_PATH . '/retail/regkey.php' ) )
{
require_once( ROOT_PATH . '/retail/regkey.php' );
if ( $customer_reg_key == '1105772400-20366-16-36747-1137308400' )
{
$customer_reg_key = '';
}
}
//-------------------------------
// Unpack the datafile
//-------------------------------
$xml->xml_parse_document( $setting_content );
//-------------------------------
// pArse
//-------------------------------
$fields = array( 'conf_title', 'conf_description', 'conf_group', 'conf_type', 'conf_key', 'conf_value', 'conf_default',
'conf_extra', 'conf_evalphp', 'conf_protected', 'conf_position', 'conf_start_group', 'conf_end_group',
'conf_help_key', 'conf_add_cache' );
$known = array( 'email_in' => $VARS['email'],
'email_out' => $VARS['email'],
'base_dir' => $root,
'upload_dir' => $root."uploads",
'upload_url' => $VARS['board_url']."/uploads",
'ipb_copy_number'=> $customer_copy_key,
'ipb_reg_number' => $customer_reg_key,
);
if ( ! is_array( $xml->xml_array['settingexport']['settinggroup']['setting'] ) )
{
install_error("Error with ipb_settings.xml - could not process XML properly");
}
foreach( $xml->xml_array['settingexport']['settinggroup']['setting'] as $id => $entry )
{
if ( ! $entry['conf_key']['VALUE'] )
{
continue;
}
$newrow = array();
$entry['conf_value']['VALUE'] = "";
if ( in_array( $entry['conf_key']['VALUE'], array_keys( $known ) ) )
{
$entry['conf_value']['VALUE'] = $known[ $entry['conf_key']['VALUE'] ];
}
//-----------------------------------
// Make PHP slashes safe
//-----------------------------------
$entry['conf_evalphp']['VALUE'] = str_replace( '\\', '\\\\', $entry['conf_evalphp']['VALUE'] );
foreach( $fields as $f )
{
$newrow[$f] = $entry[ $f ]['VALUE'];
}
$db_string = $DB->compile_db_insert_string($newrow);
$query = "INSERT INTO ".$VARS['sql_tbl_prefix']."conf_settings (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")";
if ( ! $DB->query($query) )
{
install_error($query."
".$DB->error);
}
}
//-----------------------------------
// ARE WE DONE? REALLY? COOL!!
//-----------------------------------
$template->print_top('Success!');
$template->contents .= "
Success
Your board has now been installed!
The installation process is almost complete.
The next step will install the templates into your database
CLICK HERE TO CONTINUE
";
$template->output();
}
/*-------------------------------------------------------------------------*/
// SET UP FORM
/*-------------------------------------------------------------------------*/
function do_setup_form()
{
global $std, $template;
$template->print_top('Set Up form');
if ( ! is_dir(ROOT_PATH.'ips_kernel') )
{
install_error("Cannot locate 'ips_kernel' directory. Please make sure you uploaded all the folders and files.");
}
//--------------------------------------------------
// DO WE HAVE A DB DRIVER SET?
//--------------------------------------------------
$VARS['sql_driver'] = ( $VARS['sql_driver'] == "" ) ? $_REQUEST['sql_driver'] : $VARS['sql_driver'];
if ( ! $VARS['sql_driver'] )
{
//----------------------------------------------
// Test to see how many DB driver's we've got..
//----------------------------------------------
$drivers = array();
$dh = opendir( ROOT_PATH.'ips_kernel' ) or install_error("Cannot locate 'ips_kernel' directory for reading, please check all paths and permissions");
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...
//------------------------------------------
$template->contents .= "";
$template->output();
exit();
}
else
{
//------------------------------------------
// Use only driver installed
//------------------------------------------
$VARS['sql_driver'] = $drivers[0];
}
}
//--------------------------------------------------
// If we're here, we have chosen a driver, so.......
//--------------------------------------------------
$this_url = str_replace( "/install/index.php", "", $_SERVER['HTTP_REFERER']);
$this_url = str_replace( "/install/" , "", $this_url);
$this_url = str_replace( "/install" , "", $this_url);
$this_url = str_replace( "index.php" , "", $this_url);
if ( ! $this_url )
{
$this_url = substr($_SERVER['SCRIPT_NAME'],0, -17);
if ($this_url == '')
{
$this_url == '/';
}
$this_url = 'http://'.$_SERVER['SERVER_NAME'].$this_url;
}
$this_url = preg_replace( "#/$#", "", str_replace( '?a=1', "", $this_url ) );
//--------------------------------------------------
// Safe mode?
//--------------------------------------------------
$safe_mode = 0;
if ( get_cfg_var('safe_mode') )
{
$safe_mode = get_cfg_var('safe_mode');
}
$template->contents .= "
";
//--------------------------------------------------
// Any "extra" configs required for this driver?
//--------------------------------------------------
if ( file_exists( THIS_ROOT_PATH.'sql/'.$VARS['sql_driver'].'_install.php' ) )
{
require_once( THIS_ROOT_PATH.'sql/'.$VARS['sql_driver'].'_install.php' );
$extra_install = new install_extra();
$template->contents = str_replace( '', $extra_install->install_form_extra(), $template->contents );
}
$template->output();
}
//---------------------------------------
function do_intro()
{
global $std, $template, $root;
$template->print_top('Welcome');
$template->contents .= "
 |
Before we go any further, please ensure that all the files have been uploaded, and that the
file 'conf_global.php' has suitable permissions to allow this script to write to it ( 0666 should be sufficient ).
IPB ".IPBVERSION." requires PHP 4.1.0 or better and an SQL database.
You will also need the following information that your webhost can provide:
- Your SQL database name
- Your SQL username
- Your SQL password
- Your SQL host address (usually localhost)
Once you have clicked on proceed, you will be taken to a form to enter information the installer needs to set up your board.
PLEASE NOTE: USING THIS INSTALLER WILL DELETE ANY CURRENT INVISION POWER BOARD DATABASE IF YOU ARE USING THE SAME TABLE PREFIX
";
//---------------------------------------
// Check to make sure that the config file
// is there and it's got suitable permissions to write to:
//---------------------------------------
$file = ROOT_PATH."conf_global.php";
$templates = THIS_ROOT_PATH."installfiles/ipb_templates.xml";
$warnings = array();
$checkfiles = array( ROOT_PATH ."ipb_templates.xml",
THIS_ROOT_PATH."installfiles/components.php",
THIS_ROOT_PATH."installfiles/ipb_macro.xml",
THIS_ROOT_PATH."installfiles/ipb_settings.xml",
THIS_ROOT_PATH."sql",
KERNEL_PATH ."class_converge.php",
KERNEL_PATH ."class_xml.php",
// KERNEL_PATH ."class_db_".SQL_DRIVER.".php",
ROOT_PATH ."conf_global.php",
);
$writeable = array( ROOT_PATH."conf_global.php",
ROOT_PATH."skin_cache/"
);
foreach ( $checkfiles as $cf )
{
if ( ! file_exists($cf) )
{
$warnings[] = "Cannot locate the file '$cf'.";
}
}
foreach ( $writeable as $cf )
{
if ( ! is_writeable($cf) )
{
$warnings[] = "Cannot write to the file '$cf'. Please CHMOD to 0777.";
}
}
$phpversion = phpversion();
//----------------------------------
// CHECK BASICS
//----------------------------------
if ($phpversion < '4.1.0')
{
$warnings[] = "You cannot install Invision Power Board. Invision Power Board requires PHP Version 4.1.0 or better.";
}
if ( ! function_exists('get_cfg_var') )
{
$warnings[] = "You cannot install Invision Power Board. Your PHP installation isn't sufficient to run IPB.";
}
if ( ! function_exists('xml_parse_into_struct') )
{
$warnings[] = "You cannot install Invision Power Board. IPB requires that the XML functions in PHP are enabled, please ask your host to enable XML.";
}
//----------------------------------
// Got error?
//----------------------------------
if ( count($warnings) > 0 )
{
$err_string = '·'.implode( "
·", $warnings );
$template->contents .= "
Warning!
The following errors must be rectified before continuing!
$err_string
";
}
else
{
$template->contents .= "
";
}
$template->contents .= " |
";
$template->output();
}
function install_error($msg="")
{
global $std, $template, $root;
$template->print_top('Warning!');
$template->contents .= "
Warning!
The following errors must be rectified before continuing!
Please go back and try again!
$msg
";
$template->output();
}
//+--------------------------------------------------------------------------
// CLASSES
//+--------------------------------------------------------------------------
class info
{
function info()
{
global $INFO;
$ibforums->vars = $INFO;
}
}
class template
{
var $contents = "";
function output()
{
echo $this->contents;
echo "
Invision Power Board © 2004 Invision Power Services, Inc.