364 lines
9.9 KiB
PHP
364 lines
9.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
+--------------------------------------------------------------------------
|
|
| Invision Power Board 2.1.7
|
|
| =============================================
|
|
| by Matthew Mecham
|
|
| (c) 2001 - 2005 Invision Power Services, Inc.
|
|
| http://www.invisionpower.com
|
|
| =============================================
|
|
| Web: http://www.invisionboard.com
|
|
| http://www.ibresource.ru/products/invisionpowerboard/
|
|
| Time: Tuesday 18th of July 2006 05:56:00 PM
|
|
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
|
|
| Licence Info: http://www.invisionboard.com/?license
|
|
| http://www.ibresource.ru/license
|
|
+---------------------------------------------------------------------------
|
|
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
|
|
+---------------------------------------------------------------------------
|
|
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
|
|
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
|
|
+---------------------------------------------------------------------------
|
|
|
|
|
| > IPB UPGRADE LOADER
|
|
| > Script written by Matt Mecham
|
|
| > Date started: 21st April 2004
|
|
| > Interesting fact: Radiohead rock (still)
|
|
+--------------------------------------------------------------------------
|
|
*/
|
|
|
|
|
|
/**
|
|
* Upgrade wrapper
|
|
*
|
|
* Set-up and load module to run
|
|
*
|
|
* @package InvisionPowerBoard
|
|
* @author Matt Mecham
|
|
* @version 2.1
|
|
*/
|
|
|
|
/**
|
|
* Script type
|
|
*
|
|
*/
|
|
define( 'IPB_THIS_SCRIPT', 'upgrade' );
|
|
define( 'IPB_LOAD_SQL' , 'admin_queries' );
|
|
|
|
require_once( '../init.php' );
|
|
|
|
//-----------------------------------------------
|
|
// USER CONFIGURABLE ELEMENTS
|
|
//-----------------------------------------------
|
|
|
|
define( 'THIS_PATH' , './' );
|
|
define( 'UPGRADE_DIR', 'upgrade' );
|
|
|
|
//===========================================================================
|
|
// MAIN PROGRAM
|
|
//===========================================================================
|
|
|
|
if ( TRIAL_VERSION )
|
|
{
|
|
print "Ýòà ôóíêöèÿ îòêëþ÷åíà â òðèàëüíîé âåðñèè.";
|
|
exit();
|
|
}
|
|
|
|
$INFO = array();
|
|
|
|
//--------------------------------
|
|
// Require our global functions
|
|
//--------------------------------
|
|
|
|
require ROOT_PATH . "conf_global.php";
|
|
require ROOT_PATH . "sources/ipsclass.php";
|
|
require KERNEL_PATH . "class_converge.php";
|
|
require THIS_PATH . "core/functions.php";
|
|
require THIS_PATH . "core/template.php";
|
|
|
|
# Initiate super-class
|
|
$ipsclass = new ipsclass();
|
|
$ipsclass->vars = $INFO;
|
|
|
|
//--------------------------------
|
|
// The clocks a' tickin'
|
|
//--------------------------------
|
|
|
|
$Debug = new Debug;
|
|
$Debug->startTimer();
|
|
|
|
//--------------------------------
|
|
// Load the DB driver and such
|
|
//--------------------------------
|
|
|
|
$ipsclass->init_db_connection();
|
|
|
|
//--------------------------------
|
|
// Check to make sure we're not
|
|
// trying to update < 2.0.0
|
|
//--------------------------------
|
|
|
|
if ( ! $ipsclass->DB->field_exists( 'sub_id', 'subscriptions' ) OR ! $ipsclass->DB->field_exists( 'perm_id', 'forum_perms' ) )
|
|
{
|
|
$ipsclass->boink_it( $INFO['board_url'].'/upgrade/upgrade.php' );
|
|
}
|
|
|
|
//--------------------------------
|
|
// Set up our vars
|
|
//--------------------------------
|
|
|
|
$ipsclass->parse_incoming();
|
|
|
|
//--------------------------------
|
|
// Set converge
|
|
//--------------------------------
|
|
|
|
$ipsclass->converge = new class_converge( $ipsclass->DB );
|
|
|
|
//--------------------------------
|
|
// Get cache...
|
|
//--------------------------------
|
|
|
|
$ipsclass->init_load_cache();
|
|
|
|
//--------------------------------
|
|
// Initialize the FUNC
|
|
//--------------------------------
|
|
|
|
$ipsclass->initiate_ipsclass();
|
|
|
|
//--------------------------------
|
|
// Set up our vars
|
|
//--------------------------------
|
|
|
|
$ipsclass->core = new core_functions();
|
|
$ipsclass->core->ipsclass =& $ipsclass;
|
|
|
|
$ipsclass->template = new template();
|
|
$ipsclass->template->ipsclass =& $ipsclass;
|
|
|
|
//--------------------------------
|
|
// Get dir contents
|
|
//--------------------------------
|
|
|
|
$ipsclass->dir_contents = $ipsclass->core->get_dir_structure();
|
|
|
|
//--------------------------------
|
|
// Get DB contents
|
|
//--------------------------------
|
|
|
|
$ipsclass->db_contents = $ipsclass->core->get_db_structure();
|
|
|
|
//--------------------------------
|
|
// Get latest ID...
|
|
//--------------------------------
|
|
|
|
# PHP 5.0.5 problem...
|
|
$tmp_var = array_reverse($ipsclass->dir_contents);
|
|
$ipsclass->last_poss_id = array_shift( $tmp_var );
|
|
|
|
//--------------------------------
|
|
// OK to disCO
|
|
//--------------------------------
|
|
|
|
$ipsclass->safe_act = array( 'recache', 'acpperms', 'templates', 'templatescache', 'settings', 'finish' );
|
|
|
|
//--------------------------------
|
|
// Get datafile
|
|
//--------------------------------
|
|
|
|
if ( ! $ipsclass->last_poss_id )
|
|
{
|
|
$ipsclass->core->login_screen( "Îáíàðóæåíà îøèáêà — ìû íå ìîæåì îïðåäåëèòü òåêóùóþ âåðñèþ, èëè îòñóòñòâóþò íåêîòîðûå ôàéëû, òðåáóåìûå äëÿ îáíîâëåíèÿ" );
|
|
}
|
|
|
|
if ( file_exists( THIS_PATH.'upg_'.$ipsclass->last_poss_id.'/version_history.php' ) )
|
|
{
|
|
require_once( THIS_PATH.'upg_'.$ipsclass->last_poss_id.'/version_history.php' );
|
|
|
|
$ipsclass->versions = $import_versions;
|
|
}
|
|
else
|
|
{
|
|
$ipsclass->core->login_screen( "Íåâîçìîæíî íàéòè òðåáóåìûé ôàéë: 'upg_{$ipsclass->last_poss_id}/version_history.php'");
|
|
}
|
|
|
|
//--------------------------------
|
|
// Version logic check
|
|
//--------------------------------
|
|
|
|
$ipsclass->core->get_version_latest();
|
|
|
|
if ( ! $ipsclass->current_version )
|
|
{
|
|
$ipsclass->core->login_screen( "Íåâîçìîæíî íàéòè òðåáóåìûé ôàéë" );
|
|
}
|
|
|
|
if ( ! $ipsclass->input['act'] )
|
|
{
|
|
if ( $ipsclass->current_version >= intval( $ipsclass->current_upgrade ) )
|
|
{
|
|
$ipsclass->core->login_screen( "ÎÁÍÎÂËÅÍÈÅ ÍÅ ÒÐÅÁÓÅÒÑß! Âû èìååòå èëè ïîñëåäíþþ âåðñèþ ôîðóìà èëè âàøà âåðñèÿ íîâåå òîé, äî êîòîðîé âû ïûòàåòåñü îáíîâèòüñÿ. :)" );
|
|
}
|
|
}
|
|
|
|
//--------------------------------
|
|
// Get our loverly member
|
|
//--------------------------------
|
|
|
|
$ipsclass->member = $ipsclass->core->get_member();
|
|
|
|
//--------------------------------
|
|
// Log in?
|
|
//--------------------------------
|
|
|
|
if ( $ipsclass->input['act'] != 'login' )
|
|
{
|
|
if ( ! $ipsclass->member['id'] )
|
|
{
|
|
$ipsclass->core->login_screen("Âû íå èìååòå äîñòóï ê ýòîé ñèñòåìå îáíîâëåíèÿ.");
|
|
}
|
|
|
|
if ( $ipsclass->return_md5_check() != $ipsclass->securekey )
|
|
{
|
|
$ipsclass->core->login_screen("Âû íå èìååòå äîñòóï ê ýòîé ñèñòåìå îáíîâëåíèÿ!");
|
|
}
|
|
|
|
if ( ! $ipsclass->member['g_access_cp'] )
|
|
{
|
|
$ipsclass->core->login_screen('Âû îáÿçàíû áûòü àäìèíèñòðàòîðîì äëÿ äîñòóïà ê ñèñòåìå îáíîâëåíèÿ!');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//----------------------------------
|
|
// We must have submitted the form
|
|
// time to check some details.
|
|
//----------------------------------
|
|
|
|
if ( empty($ipsclass->input['username']) )
|
|
{
|
|
$ipsclass->core->login_screen("Âû îáÿçàíû ââåñòè âàøå èìÿ ïîëüçîâàòåëÿ íà ôîðóìå ïðåæäå, ÷åì ïðîäîëæèòü");
|
|
}
|
|
|
|
if ( empty($ipsclass->input['password']) )
|
|
{
|
|
$ipsclass->core->login_screen("Âû îáÿçàíû ââåñòè âàø ïàðîëü íà ôîðóìå ïðåæäå, ÷åì ïðîäîëæèòü");
|
|
}
|
|
|
|
//----------------------------------
|
|
// Attempt to get the details from the
|
|
// DB
|
|
//----------------------------------
|
|
|
|
$ipsclass->DB->query("SELECT m.*, g.* FROM ibf_members m, ibf_groups g WHERE LOWER(name)='".strtolower($ipsclass->input['username'])."' and m.mgroup=g.g_id");
|
|
|
|
$mem = $ipsclass->DB->fetch_row();
|
|
|
|
//----------------------------------
|
|
// Get perms
|
|
//----------------------------------
|
|
|
|
if ( empty($mem['id']) )
|
|
{
|
|
$ipsclass->core->login_screen("Íåâîçìîæíî íàéòè ïîëüçîâàòåëÿ ñ óêàçàííûì èìåíåì, ïîæàëóéñòà ïåðåïðîâåðüòå äàííûå è ïîïðîáóéòå ñíîâà");
|
|
}
|
|
|
|
//----------------------------------
|
|
// Load converge member
|
|
//----------------------------------
|
|
|
|
$ipsclass->converge->converge_load_member($mem['email']);
|
|
|
|
if ( ! $ipsclass->converge->member['converge_id'] )
|
|
{
|
|
$ipsclass->core->login_screen("Íåâîçìîæíî íàéòè ïîëüçîâàòåëÿ ñ óêàçàííûì èìåíåì, ïîæàëóéñòà ïåðåïðîâåðüòå äàííûå è ïîïðîáóéòå ñíîâà");
|
|
}
|
|
|
|
//----------------------------------
|
|
// Check converge pass
|
|
//----------------------------------
|
|
|
|
$pass = md5( $ipsclass->input['password'] );
|
|
|
|
//------------------------------
|
|
// Check password...
|
|
//------------------------------
|
|
|
|
if ( $ipsclass->converge->converge_authenticate_member( $pass ) != TRUE )
|
|
{
|
|
$ipsclass->core->login_screen("Ââåäåííûé ïàðîëü íåêîððåêòíûé");
|
|
}
|
|
else
|
|
{
|
|
if ( $mem['g_access_cp'] != 1 )
|
|
{
|
|
$ipsclass->core->login_screen("Âû íå èìååò äîñòóï ê àäìèíöåíòðó ôîðóìà");
|
|
}
|
|
else
|
|
{
|
|
|
|
//----------------------------------
|
|
// All is good, bounce onwards...
|
|
//----------------------------------
|
|
|
|
$ipsclass->member = $mem;
|
|
|
|
$ipsclass->core->redirect( "index.php?act=work&loginkey={$mem['member_login_key']}&securekey=".$ipsclass->return_md5_check()."&mid={$mem['id']}", "Ñïàñèáî çà àâòîðèçàöèþ...." );
|
|
}
|
|
}
|
|
}
|
|
|
|
//===========================================================================
|
|
// MAIN LOGIC...
|
|
//===========================================================================
|
|
|
|
//--------------------------------
|
|
// Get and run upgrade script
|
|
//--------------------------------
|
|
|
|
if ( ! in_array( $ipsclass->input['act'], $ipsclass->safe_act ) )
|
|
{
|
|
if ( file_exists( THIS_PATH.'upg_'.$ipsclass->current_upgrade.'/version_upgrade.php' ) )
|
|
{
|
|
require_once( THIS_PATH.'upg_'.$ipsclass->current_upgrade.'/version_upgrade.php' );
|
|
$runme = new version_upgrade();
|
|
$runme->ipsclass =& $ipsclass;
|
|
$runme->version_process();
|
|
}
|
|
else
|
|
{
|
|
$ipsclass->core->login_screen( "Íåâîçìîæíî íàéòè òðåáóåìûé ôàéë: 'upg_{$ipsclass->current_upgrade}/version_upgrade.php'");
|
|
}
|
|
}
|
|
|
|
// Module(work) -> done [ settings -> acpperms -> templatecomponents ] -> recache -> templates -> templatesrecache -> finish
|
|
|
|
switch ($ipsclass->input['act'])
|
|
{
|
|
case 'recache':
|
|
$ipsclass->core->rebuild_caches();
|
|
break;
|
|
case 'templates':
|
|
$ipsclass->core->rebuild_templates();
|
|
break;
|
|
case 'templatescache':
|
|
$ipsclass->core->rebuild_templates_cache();
|
|
break;
|
|
case 'finish':
|
|
$ipsclass->core->upgrade_complete();
|
|
break;
|
|
case 'done':
|
|
$ipsclass->core->module_complete();
|
|
break;
|
|
case 'work':
|
|
$runme->auto_run();
|
|
break;
|
|
default:
|
|
$ipsclass->core->login_screen();
|
|
break;
|
|
}
|
|
|
|
|
|
?>
|