Script written by Matthew Mecham | > Date started: 19th March 2004 | > Updated for 2.1: 23 June 2005 | +-------------------------------------------------------------------------- */ 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_ACP', 1 ); define ( 'IN_IPB', 1 ); define ( 'IN_DEV', 0 ); define ( 'IPBVERSION', '2.1.3' ); define ( 'IPB_LONG_VERSION', '21009' ); define ( 'USE_SHUTDOWN', 0 ); define ( 'SAFE_MODE_ON', 0 ); $INFO = array(); //-------------------------------- // Load our classes //-------------------------------- require ROOT_PATH . "sources/ipsclass.php"; require KERNEL_PATH . "class_converge.php"; # Initiate super-class $ipsclass = new ipsclass(); $ipsclass->vars = $INFO; $ipsclass->template = new template(); //-------------------------------- // Set up our vars //-------------------------------- $ipsclass->parse_incoming(); $ipsclass->initiate_ipsclass(); //-------------------------------- // Set converge //-------------------------------- $ipsclass->converge = new class_converge( $ipsclass->DB ); //--------------------------------------- // Installer locked? //--------------------------------------- if ( file_exists( THIS_ROOT_PATH.'install.lock') ) { install_error("This installer is locked!
Please (via FTP) remove the 'install/install.lock' file"); exit(); } //--------------------------------------- // Make sure we've renamed conf_global.php //--------------------------------------- if ( file_exists( ROOT_PATH.'conf_global.php.dist') AND ! file_exists( ROOT_PATH.'conf_global.php') ) { if ( ! @rename( ROOT_PATH.'conf_global.php.dist', ROOT_PATH.'conf_global.php' ) ) { install_error("

You MUST rename the file 'conf_global.php.dist' TO 'conf_global.php' before continuing.

This file can be found in the root forum directory on your FTP server, the same directory where 'admin.php' and 'index.php' are stored."); exit(); } } //----------------------------------------------- // What to do? //----------------------------------------------- switch($ipsclass->input['a']) { case '1': do_setup_form(); break; case '2': do_install(); break; case 'templates': do_templates(); break; case 'acpperms': do_acpperms(); break; case '3': do_finish(); break; default: do_intro(); break; } /*-------------------------------------------------------------------------*/ // DO FINISH /*-------------------------------------------------------------------------*/ function do_finish() { global $ipsclass; //----------------------------------- // 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"); } require_once($require); //----------------------------------- // Attempt a DB connection.. //----------------------------------- require_once( KERNEL_PATH.'class_db_'.$INFO['sql_driver'].".php" ); $ipsclass->DB = new db_driver(); $ipsclass->DB->obj['sql_database'] = $INFO['sql_database']; $ipsclass->DB->obj['sql_user'] = $INFO['sql_user']; $ipsclass->DB->obj['sql_pass'] = $INFO['sql_pass']; $ipsclass->DB->obj['sql_host'] = $INFO['sql_host']; $ipsclass->DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix']; $ipsclass->DB->obj['query_cache_file'] = ROOT_PATH.'sources/sql/'.$INFO['sql_driver'].'_admin_queries.php'; $ipsclass->DB->obj['use_shutdown'] = 0; //----------------------------------- // Required vars? //----------------------------------- if ( is_array( $ipsclass->DB->connect_vars ) and count( $ipsclass->DB->connect_vars ) ) { foreach( $ipsclass->DB->connect_vars as $k => $v ) { $ipsclass->DB->connect_vars[ $k ] = $INFO[ $k ]; } } //----------------------------------- // Attempt a connect //----------------------------------- if ( ! $ipsclass->DB->connect() ) { install_error( "Connection error:

".$ipsclass->DB->error ); } //-------------------------------- // Make CONSTANT //-------------------------------- define( 'SQL_PREFIX', $ipsclass->DB->obj['sql_tbl_prefix'] ); define( 'SQL_DRIVER', strtolower($INFO['sql_driver']) ); //----------------------------------- // Get ACP library //----------------------------------- require_once( ROOT_PATH.'sources/lib/admin_cache_functions.php' ); $acp = new admin_cache_functions(); $acp->ipsclass =& $ipsclass; $acp->_rebuild_all_caches( array(2) ); unset( $acp ); //------------------------------------------------------------- // Forum cache //------------------------------------------------------------- $ipsclass->update_forum_cache(); //------------------------------------------------------------- // Group Cache //------------------------------------------------------------- require_once( ROOT_PATH.'sources/action_admin/groups.php' ); $lib = new ad_groups(); $lib->ipsclass =& $ipsclass; $lib->rebuild_group_cache(); unset( $lib ); //------------------------------------------------------------- // Systemvars //------------------------------------------------------------- $ipsclass->cache['systemvars'] = array(); $result = $ipsclass->DB->simple_exec_query( array( 'select' => 'count(*) as cnt', 'from' => 'mail_queue' ) ); $ipsclass->cache['systemvars']['mail_queue'] = intval( $result['cnt'] ); $ipsclass->cache['systemvars']['task_next_run'] = time() + 3600; $ipsclass->update_cache( array( 'name' => 'systemvars', 'array' => 1, 'deletefirst' => 1 ) ); //------------------------------------------------------------- // Stats //------------------------------------------------------------- $ipsclass->cache['stats'] = array(); $ipsclass->cache['stats']['total_replies'] = 0; $ipsclass->cache['stats']['total_topics'] = 1; $ipsclass->cache['stats']['mem_count'] = 1; $r = $ipsclass->DB->simple_exec_query( array( 'select' => 'id, name', 'from' => 'members', 'order' => 'id DESC', 'limit' => '0,1' ) ); $ipsclass->cache['stats']['last_mem_name'] = $r['name']; $ipsclass->cache['stats']['last_mem_id'] = $r['id']; $ipsclass->update_cache( array( 'name' => 'stats', 'array' => 1, 'deletefirst' => 1 ) ); //------------------------------------------------------------- // Ranks //------------------------------------------------------------- require_once( ROOT_PATH.'sources/action_admin/member.php' ); $lib = new ad_member(); $lib->ipsclass =& $ipsclass; $lib->titles_recache(); unset( $lib ); //------------------------------------------------------------- // SETTINGS //------------------------------------------------------------- require_once( ROOT_PATH.'sources/action_admin/settings.php' ); $lib = new ad_settings(); $lib->ipsclass =& $ipsclass; $lib->setting_rebuildcache(); unset( $lib ); //------------------------------------------------------------- // EMOTICONS //------------------------------------------------------------- require_once( ROOT_PATH.'sources/action_admin/emoticons.php' ); $lib = new ad_emoticons(); $lib->ipsclass =& $ipsclass; $lib->emoticon_rebuildcache(); unset( $lib ); //------------------------------------------------------------- // LANGUAGES //------------------------------------------------------------- require_once( ROOT_PATH.'sources/action_admin/languages.php' ); $lib = new ad_languages(); $lib->ipsclass =& $ipsclass; $lib->rebuild_cache(); unset( $lib ); //------------------------------------------------------------- // ATTACHMENT TYPES //------------------------------------------------------------- require_once( ROOT_PATH.'sources/action_admin/attachments.php' ); $lib = new ad_attachments(); $lib->ipsclass =& $ipsclass; $lib->attach_type_rebuildcache(); unset( $lib ); //----------------------------------- // 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 ); $ipsclass->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 { $ipsclass->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!
"; } $ipsclass->template->contents .= "
Success
The installation is now complete!

$msg
"; $ipsclass->template->output(); } //*-------------------------------------------------------------------------*/ // Install the ACP perm keys /*-------------------------------------------------------------------------*/ function do_acpperms() { global $ipsclass; //----------------------------------- // INIT //----------------------------------- $inserted = 0; //----------------------------------- // 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"); } require_once($require); //----------------------------------- // Attempt a DB connection.. //----------------------------------- require_once( KERNEL_PATH.'class_db_'.$INFO['sql_driver'].".php" ); $ipsclass->DB = new db_driver(); $ipsclass->DB->obj['sql_database'] = $INFO['sql_database']; $ipsclass->DB->obj['sql_user'] = $INFO['sql_user']; $ipsclass->DB->obj['sql_pass'] = $INFO['sql_pass']; $ipsclass->DB->obj['sql_host'] = $INFO['sql_host']; $ipsclass->DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix']; $ipsclass->DB->obj['query_cache_file'] = ROOT_PATH.'sources/sql/'.$INFO['sql_driver'].'_admin_queries.php'; $ipsclass->DB->obj['use_shutdown'] = 0; //----------------------------------- // Required vars? //----------------------------------- if ( is_array( $ipsclass->DB->connect_vars ) and count( $ipsclass->DB->connect_vars ) ) { foreach( $ipsclass->DB->connect_vars as $k => $v ) { $ipsclass->DB->connect_vars[ $k ] = $INFO[ $k ]; } } //----------------------------------- // Attempt a connect //----------------------------------- if ( ! $ipsclass->DB->connect() ) { install_error( "Connection error:

".$ipsclass->DB->error ); } //-------------------------------- // Make CONSTANT //-------------------------------- define( 'SQL_PREFIX', $ipsclass->DB->obj['sql_tbl_prefix'] ); define( 'SQL_DRIVER', strtolower($INFO['sql_driver']) ); //----------------------------------- // Get XML //----------------------------------- require_once( KERNEL_PATH.'class_xml.php' ); $xml = new class_xml(); $xml->lite_parser = 1; //------------------------------- // GET MACROS //------------------------------- $xmlfile = THIS_ROOT_PATH.'installfiles/ipb_acpperms.xml'; $content = implode( "", file($xmlfile) ); //------------------------------- // Unpack the datafile (MACRO) //------------------------------- $xml->xml_parse_document( $content ); //----------------------------------------- // Fix up... //----------------------------------------- if ( ! is_array( $xml->xml_array['permsexport']['permsgroup']['perm'][0] ) ) { //----------------------------------------- // Ensure [0] is populated //----------------------------------------- $tmp = $xml->xml_array['permsexport']['permsgroup']['perm']; unset($xml->xml_array['permsexport']['permsgroup']['perm']); $xml->xml_array['permsexport']['permsgroup']['perm'][0] = $tmp; } //----------------------------------------- // 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 ] ) { $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++; } } //------------------------------- // ARE WE DONE? REALLY? COOL!! //------------------------------- $ipsclass->template->print_top('Success!'); $ipsclass->template->contents .= "
Success
Template files installed!

$inserted ACP permission restriction keys inserted.
Click the link below to finish up and build IPB's caches

Click here to continue
"; $ipsclass->template->output(); } //*-------------------------------------------------------------------------*/ // Install the template files, woohoo and stuff /*-------------------------------------------------------------------------*/ function do_templates() { global $ipsclass; //----------------------------------- // 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"); } require_once($require); //----------------------------------- // Attempt a DB connection.. //----------------------------------- require_once( KERNEL_PATH.'class_db_'.$INFO['sql_driver'].".php" ); $ipsclass->DB = new db_driver(); $ipsclass->DB->obj['sql_database'] = $INFO['sql_database']; $ipsclass->DB->obj['sql_user'] = $INFO['sql_user']; $ipsclass->DB->obj['sql_pass'] = $INFO['sql_pass']; $ipsclass->DB->obj['sql_host'] = $INFO['sql_host']; $ipsclass->DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix']; $ipsclass->DB->obj['query_cache_file'] = ROOT_PATH.'sources/sql/'.$INFO['sql_driver'].'_admin_queries.php'; $ipsclass->DB->obj['use_shutdown'] = 0; //----------------------------------- // Required vars? //----------------------------------- if ( is_array( $ipsclass->DB->connect_vars ) and count( $ipsclass->DB->connect_vars ) ) { foreach( $ipsclass->DB->connect_vars as $k => $v ) { $ipsclass->DB->connect_vars[ $k ] = $INFO[ $k ]; } } //----------------------------------- // Attempt a connect //----------------------------------- if ( ! $ipsclass->DB->connect() ) { install_error( "Connection error:

".$ipsclass->DB->error ); } //-------------------------------- // Make CONSTANT //-------------------------------- define( 'SQL_PREFIX', $ipsclass->DB->obj['sql_tbl_prefix'] ); define( 'SQL_DRIVER', strtolower($INFO['sql_driver']) ); //----------------------------------- // Get XML //----------------------------------- require_once( KERNEL_PATH.'class_xml.php' ); $xml = new class_xml(); $xml->lite_parser = 1; //----------------------------------- // 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(); $ipsclass->DB->do_insert( 'skin_templates', $newrow ); } //------------------------------- // GET MACROS //------------------------------- $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; $ipsclass->DB->do_insert( 'skin_macro', $newrow ); } //------------------------------- // WRAPPER / CSS //------------------------------- require_once( THIS_ROOT_PATH.'installfiles/components.php' ); $wrapper_record = array( 'set_wrapper' => $WRAPPER, 'set_css' => $CSS, ); $ipsclass->DB->do_update( 'skin_sets', $wrapper_record, "set_skin_set_id=1" ); //------------------------------- // ARE WE DONE? REALLY? COOL!! //------------------------------- $ipsclass->template->print_top('Success!'); $ipsclass->template->contents .= "
Success
Template files installed!

The installation process is now complete.
Click the link below to install the ACP permission restriction keys

Click here to continue
"; $ipsclass->template->output(); } /*-------------------------------------------------------------------------*/ // DO install /*-------------------------------------------------------------------------*/ function do_install() { global $ipsclass; //----------------------------------- // INIT //----------------------------------- $NEW_INFO = array(); $need = array('board_url','sql_host','sql_database','sql_user','adminname','adminpassword','adminpassword2','email'); $setting_groups_by_key = array(); $setting_groups = array(); $extra_install = ""; //----------------------------------- // Check for blanks //----------------------------------- foreach($need as $greed) { if ( ! $ipsclass->input[ $greed ] ) { install_error("You must complete all of the form with the sole exception of 'SQL Table prefix'"); } } //----------------------------------- // 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 //----------------------------------- $ipsclass->input['board_url'] = preg_replace( "#/$#", "", $ipsclass->input['board_url'] ); //----------------------------------- // TBL prefix //----------------------------------- if ($ipsclass->input['sql_tbl_prefix'] == "") { $ipsclass->input['sql_tbl_prefix'] = 'ibf_'; } //----------------------------------- // Safe mode //----------------------------------- $safe_mode = intval( $ipsclass->input['safe_mode'] ); //----------------------------------- // Did the admin passy and passy2 match? //----------------------------------- if ( $ipsclass->input['adminpassword2'] != $ipsclass->input['adminpassword'] ) { install_error("Your passwords did not match"); } //----------------------------------- // Get a correct 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' => $ipsclass->input['sql_driver'], 'sql_host' => $ipsclass->input['sql_host'], 'sql_database' => $ipsclass->input['sql_database'], 'sql_user' => $_POST['sql_user'], 'sql_pass' => $_POST['sql_pass'], 'sql_tbl_prefix' => $ipsclass->input['sql_tbl_prefix'], 'sql_debug' => 1, 'board_start' => time(), 'installed' => 1, 'php_ext' => 'php', 'safe_mode' => $safe_mode, 'board_url' => $ipsclass->input['board_url'], 'admin_group' => '4', 'guest_group' => '2', 'member_group' => '3', 'auth_group' => '1', ); //-------------------------------------------------- // Update VARS settings //-------------------------------------------------- $ipsclass->vars =& $INFO; //-------------------------------------------------- // Any "extra" configs required for this driver? //-------------------------------------------------- if ( file_exists( THIS_ROOT_PATH.'sql/'.$ipsclass->input['sql_driver'].'_install.php' ) ) { require_once( THIS_ROOT_PATH.'sql/'.$ipsclass->input['sql_driver'].'_install.php' ); $extra_install = new install_extra(); $extra_install->ipsclass =& $ipsclass; $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" ); $ipsclass->DB = new db_driver(); $ipsclass->DB->obj['sql_database'] = $INFO['sql_database']; $ipsclass->DB->obj['sql_user'] = $INFO['sql_user']; $ipsclass->DB->obj['sql_pass'] = $INFO['sql_pass']; $ipsclass->DB->obj['sql_host'] = $INFO['sql_host']; $ipsclass->DB->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix']; $ipsclass->DB->obj['query_cache_file'] = ROOT_PATH.'sources/sql/'.$INFO['sql_driver'].'_admin_queries.php'; $ipsclass->DB->obj['use_shutdown'] = 0; $ipsclass->DB->return_die = 1; //----------------------------------- // Required vars? //----------------------------------- if ( is_array( $ipsclass->DB->connect_vars ) and count( $ipsclass->DB->connect_vars ) ) { foreach( $ipsclass->DB->connect_vars as $k => $v ) { $ipsclass->DB->connect_vars[ $k ] = $INFO[ $k ]; } } //----------------------------------- // Attempt a connect //----------------------------------- if ( ! $ipsclass->DB->connect() ) { install_error( "Connection error:

".$ipsclass->DB->error ); } //-------------------------------- // Make CONSTANT //-------------------------------- define( 'SQL_PREFIX', $ipsclass->DB->obj['sql_tbl_prefix'] ); define( 'SQL_DRIVER', strtolower($INFO['sql_driver']) ); $ipsclass->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]) { $ipsclass->DB->sql_drop_table( str_replace( 'ibf_', '', $match[1] ) ); } if ($ipsclass->input['sql_tbl_prefix'] != "ibf_") { $q = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $ipsclass->input['sql_tbl_prefix']."\\1\\2", $q); } //----------------------------------- // Pass to handler //----------------------------------- if ( $extra_install AND method_exists( $extra_install, 'process_query_create' ) ) { $q = $extra_install->process_query_create( $q ); } //----------------------------------- // Pass query //----------------------------------- if ( ! $ipsclass->DB->query($q) ) { install_error($q."

".$ipsclass->DB->error); } } //----------------------------------- // Create the fulltext index... //----------------------------------- if ( $ipsclass->DB->sql_can_fulltext() ) { foreach( $INDEX as $q ) { if ($ipsclass->input['sql_tbl_prefix'] != "ibf_") { $q = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $ipsclass->input['sql_tbl_prefix']."\\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 ( ! $ipsclass->DB->query($q) ) { install_error($q."

".$ipsclass->DB->error); } } } //----------------------------------- // Populate tables... //----------------------------------- foreach( $INSERT as $q ) { if ($ipsclass->input['sql_tbl_prefix'] != "ibf_") { $q = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $ipsclass->input['sql_tbl_prefix']."\\1\\2", $q); } $q = str_replace( "<%time%>", time(), $q ); //----------------------------------- // Pass to handler //----------------------------------- if ( $extra_install AND method_exists( $extra_install, 'process_query_insert' ) ) { $q = $extra_install->process_query_insert( $q ); } //----------------------------------- // Pass query //----------------------------------- if ( ! $ipsclass->DB->query($q) ) { install_error($q."

".$ipsclass->DB->error); } } //----------------------------------- // Insert the admin... //----------------------------------- $md5_once = trim(md5($ipsclass->input['adminpassword'])); $salt = $ipsclass->converge->generate_password_salt(5); $key = $ipsclass->converge->generate_auto_log_in_key(); $rpass = $ipsclass->converge->generate_compiled_passhash($salt, $md5_once); $time = time(); //----------------------------------- // Members... //----------------------------------- $member_record = array( 'id' => 1, 'name' => $ipsclass->input['adminname'], 'members_display_name' => $ipsclass->input['adminname'], 'mgroup' => 4, 'email' => $ipsclass->input['email'], 'joined' => $time, 'ip_address' => '127.0.0.1', 'posts' => 0, 'title' => 'Administrator', 'last_visit' => $time, 'last_activity' => $time, 'member_login_key' => $key, ); $ipsclass->DB->do_insert( 'members', $member_record ); //----------------------------------- // Converge... //----------------------------------- $converge_record = array( 'converge_email' => $ipsclass->input['email'], 'converge_joined' => $time, 'converge_pass_hash' => $rpass, 'converge_pass_salt' => $salt, ); $ipsclass->DB->do_insert( 'members_converge', $converge_record ); //----------------------------------- // Member Extra... //----------------------------------- $member_extra_record = array ( 'id' => 1, 'signature' => '', 'vdirs' => '', ); $ipsclass->DB->do_insert( 'member_extra', $member_extra_record ); //------------------------------- // 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 == 'PyR8zdl' ) { $customer_reg_key = ''; } } //------------------------------- // Unpack the datafile //------------------------------- $xml->xml_parse_document( $setting_content ); //------------------------------- // Known settings //------------------------------- $known = array( 'email_in' => $ipsclass->input['email'], 'email_out' => $ipsclass->input['email'], 'base_dir' => $root, 'upload_dir' => $root."/uploads", 'upload_url' => $ipsclass->input['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"); } //----------------------------------------- // 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' ); //----------------------------------------- // 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'] ); //----------------------------------------- // Insert first //----------------------------------------- $ipsclass->DB->do_insert( 'conf_settings_titles', $save ); $conf_id = $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 ) { //----------------------------------------- // Make PHP slashes safe //----------------------------------------- //$data['conf_evalphp'] = str_replace( '\\', '\\\\', $data['conf_evalphp'] ); //----------------------------------------- // Insert known //----------------------------------------- if ( in_array( $data['conf_key'], array_keys( $known ) ) ) { $data['conf_value'] = $known[ $data['conf_key'] ]; } //----------------------------------------- // 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'] ); $ipsclass->DB->do_insert( 'conf_settings', $data ); } } //----------------------------------------- // Update group counts... //----------------------------------------- if ( count( $need_update ) ) { foreach( $need_update as $i => $idx ) { $conf = $ipsclass->DB->simple_exec_query( array( 'select' => 'count(*) as count', 'from' => 'conf_settings', 'where' => 'conf_group='.$idx ) ); $count = intval($conf['count']); $ipsclass->DB->do_update( 'conf_settings_titles', array( 'conf_title_count' => $count ), 'conf_title_id='.$idx ); } } //----------------------------------- // ARE WE DONE? REALLY? COOL!! //----------------------------------- $ipsclass->template->print_top('Success!'); $ipsclass->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 if you are not automatically redirected...
"; $ipsclass->template->output(); } /*-------------------------------------------------------------------------*/ // SET UP FORM /*-------------------------------------------------------------------------*/ function do_setup_form() { global $ipsclass; //-------------------------------------------------- // INIT //-------------------------------------------------- $drivers = array(); $ipsclass->template->print_top('Set Up form'); //-------------------------------------------------- // Make sure kernel folder is present //-------------------------------------------------- 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? //-------------------------------------------------- $ipsclass->input['sql_driver'] = ( $ipsclass->input['sql_driver'] == "" ) ? $_REQUEST['sql_driver'] : $ipsclass->input['sql_driver']; if ( ! $ipsclass->input['sql_driver'] ) { //---------------------------------------------- // Test to see how many DB driver's we've got.. //---------------------------------------------- $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... //------------------------------------------ $ipsclass->template->contents .= "
Multiple SQL Drivers Detected
Please which SQL engine you wish to use with your Invision Power Board
SQL Driver
(Select the database engine you are using)
"; $ipsclass->template->output(); exit(); } else { //------------------------------------------ // Use only driver installed //------------------------------------------ $ipsclass->input['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); //-------------------------------------------------- // Test //-------------------------------------------------- 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'); } $ipsclass->template->contents .= "
Your Server Environment
This section requires you to enter the paths and URL's for the board.
"; if ( $safe_mode ) { $ipsclass->template->contents .= " "; } $ipsclass->template->contents .= "
IPB 'index.php' URL
This is the URL (must start with http://) to your main IPB directory
An example might be: http://www.domain.com/forums
Safe Mode Detected
The installer has detected that your PHP is running with safe mode enabled. If you know this is not correct, please adjust the setting.
 

Your SQL Environment
This section requires you to enter your SQL information. If in doubt, please check with your webhost before asking for support. You may choose to enter an existing database name,if not - you must create a new database before continuing.
SQL Driver You have chosen to use ".strtoupper($ipsclass->input['sql_driver'])."
SQL Host
(localhost is usually sufficient)
SQL Database Name
SQL Username
SQL Password
SQL Table Prefix
(You can leave this blank and IPB will use 'ibf_' as a default)
 

Your Admin Account
This section requires information to create your administration account. Please enter the data carefully!
Username
Password
Re-type your password
Email Address
 
"; //-------------------------------------------------- // Any "extra" configs required for this driver? //-------------------------------------------------- if ( file_exists( THIS_ROOT_PATH.'sql/'.$ipsclass->input['sql_driver'].'_install.php' ) ) { require_once( THIS_ROOT_PATH.'sql/'.$ipsclass->input['sql_driver'].'_install.php' ); $extra_install = new install_extra(); $ipsclass->template->contents = str_replace( '', $extra_install->install_form_extra(), $ipsclass->template->contents ); } $ipsclass->template->output(); } /*-------------------------------------------------------------------------*/ // DO INTRO /*-------------------------------------------------------------------------*/ function do_intro() { global $ipsclass; $ipsclass->template->print_top('Welcome'); $ipsclass->template->contents .= "
Intro Welcome to IPB

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", ROOT_PATH ."conf_global.php" ); $writeable = array( ROOT_PATH."conf_global.php", ROOT_PATH."cache", ROOT_PATH."cache/lang_cache/", ROOT_PATH."cache/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 ); $ipsclass->template->contents .= "

Warning! The following errors must be rectified before continuing!

$err_string
"; } else { $ipsclass->template->contents .= "

proceed
"; } $ipsclass->template->contents .= "
"; $ipsclass->template->output(); } /*-------------------------------------------------------------------------*/ // Install Error /*-------------------------------------------------------------------------*/ function install_error($msg="") { global $ipsclass; $ipsclass->template->print_top('Warning!'); $ipsclass->template->contents .= "
Warning!

The following errors must be rectified before continuing!
Please go back and try again!

$msg
"; $ipsclass->template->output(); } /*-------------------------------------------------------------------------*/ // CLASS TEMPLATE /*-------------------------------------------------------------------------*/ class template { var $contents = ""; function output() { $year = date('Y'); echo $this->contents; echo "



Nullfied by PyR8zdl
Invision Power Board © $year Invision Power Services, Inc.
"; exit(); } //-------------------------------------- function print_top($title="") { $this->contents = " Invision Power Board Set Up :: $title
Invision Power Board Installer
 

"; } } ?>