720 lines
24 KiB
PHP
720 lines
24 KiB
PHP
<?php
|
|
|
|
/*
|
|
+--------------------------------------------------------------------------
|
|
| Invision Power Board v<{%dyn.down.var.human.version%}>
|
|
| ========================================
|
|
| by Matthew Mecham
|
|
| (c) 2001 - 2004 Invision Power Services
|
|
| http://www.invisionpower.com
|
|
| ========================================
|
|
| Web: http://www.invisionboard.com
|
|
| Time: <{%dyn.down.var.time%}>
|
|
| Release: <{%dyn.down.var.md5%}>
|
|
| Email: matt@invisionpower.com
|
|
| Licence Info: http://www.invisionboard.com/?license
|
|
+---------------------------------------------------------------------------
|
|
|
|
|
| > IPB UPGRADE LOADER
|
|
| > Script written by Matt Mecham
|
|
| > Date started: 21st April 2004
|
|
| > Interesting fact: Radiohead rock (still)
|
|
+--------------------------------------------------------------------------
|
|
*/
|
|
|
|
if ( ! defined( 'IN_IPB' ) )
|
|
{
|
|
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
|
|
exit();
|
|
}
|
|
|
|
class core_functions
|
|
{
|
|
/*-------------------------------------------------------------------------*/
|
|
// CONSTRUCTOR
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function core_functions()
|
|
{
|
|
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// FINISH _EVERYTHING_
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function upgrade_complete()
|
|
{
|
|
$this->ipsclass->template->content .= "
|
|
<div class='tableborder'>
|
|
<div class='maintitle'>IPB Upgrade Complete!</div>
|
|
<div class='tdrow1' style='padding:6px'>You have now been upgraded!
|
|
<br /><br />
|
|
You may want to disable permissions on the script 'upgrade/index.php' to increase security or rename the 'upgrade' directory.
|
|
</div>
|
|
</div>
|
|
";
|
|
|
|
$this->ipsclass->template->output();
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// Continue with error
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function show_error( $msg, $nextact )
|
|
{
|
|
$this->ipsclass->template->content .= "
|
|
<div class='tableborder'>
|
|
<div class='maintitle'>Error!</div>
|
|
<div class='tdrow1' style='padding:6px'>The following database error(s) were returned:</b>
|
|
<br /><br />$msg
|
|
<div align='center'><span style='font-weight:bold;font-size:14px'>» <a href='index.php?act={$nextact}&loginkey={$this->ipsclass->input['loginkey']}&securekey={$this->ipsclass->input['securekey']}&mid={$this->ipsclass->input['mid']}'>Continue regardless?</a></span></div>
|
|
</div>
|
|
</div>
|
|
";
|
|
|
|
$this->ipsclass->template->output();
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// REBUILD TEMPLATES
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function rebuild_templates_cache()
|
|
{
|
|
//-----------------------------------
|
|
// Get ACP library
|
|
//-----------------------------------
|
|
|
|
require_once( ROOT_PATH.'sources/lib/admin_cache_functions.php' );
|
|
$acp = new admin_cache_functions();
|
|
$acp->ipsclass =& $this->ipsclass;
|
|
|
|
$justdone = intval($this->ipsclass->input['justdone']);
|
|
$justdone = $justdone ? $justdone : 1;
|
|
|
|
//-----------------------------------
|
|
// Get skins
|
|
//-----------------------------------
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
|
|
'from' => 'skin_sets',
|
|
'where' => 'set_skin_set_id > '.$justdone,
|
|
'order' => 'set_skin_set_id',
|
|
'limit' => array( 0, 1 )
|
|
) );
|
|
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
//-----------------------------------
|
|
// Got a biggun?
|
|
//-----------------------------------
|
|
|
|
$r = $this->ipsclass->DB->fetch_row();
|
|
|
|
if ( $r['set_skin_set_id'] )
|
|
{
|
|
$acp->_rebuild_all_caches( array($r['set_skin_set_id']) );
|
|
|
|
$extra = implode( "<br />", $acp->messages );
|
|
|
|
$this->ipsclass->core->redirect( "index.php?act=templatescache&justdone={$r['set_skin_set_id']}&loginkey={$this->ipsclass->input['loginkey']}&securekey={$this->ipsclass->input['securekey']}&mid={$this->ipsclass->input['mid']}", "Rebuild cache for skin set {$r['set_name']}<br />{$extra}<br />Proceeding to the next skin..." );
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->core->redirect( "index.php?act=finish&loginkey={$this->ipsclass->input['loginkey']}&securekey={$this->ipsclass->input['securekey']}&mid={$this->ipsclass->input['mid']}", "No more skins to rebuild..." );
|
|
}
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// REBUILD TEMPLATES
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function rebuild_templates()
|
|
{
|
|
//-----------------------------------
|
|
// 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 )
|
|
{
|
|
|
|
$row = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'suid',
|
|
'from' => 'skin_templates',
|
|
'where' => "group_name='{$entry[ 'group_name' ]['VALUE']}' AND func_name='{$entry[ 'func_name' ]['VALUE']}' and set_id=1"
|
|
) );
|
|
|
|
if ( $row['suid'] )
|
|
{
|
|
$this->ipsclass->DB->do_update( 'skin_templates', array( 'func_data' => $entry[ 'func_data' ]['VALUE'],
|
|
'section_content' => $entry[ 'section_content' ]['VALUE'],
|
|
'updated' => time()
|
|
)
|
|
, 'suid='.$row['suid'] );
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->DB->do_insert( 'skin_templates', array( 'func_data' => $entry[ 'func_data' ]['VALUE'],
|
|
'func_name' => $entry[ 'func_name' ]['VALUE'],
|
|
'section_content' => $entry[ 'section_content' ]['VALUE'],
|
|
'group_name' => $entry[ 'group_name' ]['VALUE'],
|
|
'updated' => time(),
|
|
'set_id' => 1
|
|
) );
|
|
}
|
|
}
|
|
|
|
//-----------------------------------
|
|
// Boink..
|
|
//-----------------------------------
|
|
|
|
$this->ipsclass->core->redirect( "index.php?act=templatescache&loginkey={$this->ipsclass->input['loginkey']}&securekey={$this->ipsclass->input['securekey']}&mid={$this->ipsclass->input['mid']}", "Master templates rebuilt, proceeding to recache templates..." );
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// REBUILD CACHES
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function rebuild_caches()
|
|
{
|
|
//-------------------------------------------------------------
|
|
// BBCODE
|
|
//-------------------------------------------------------------
|
|
|
|
$this->ipsclass->cache['bbcode'] = array();
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'custom_bbcode' ) );
|
|
$bbcode = $this->ipsclass->DB->simple_exec();
|
|
|
|
while ( $r = $this->ipsclass->DB->fetch_row($bbcode) )
|
|
{
|
|
$this->ipsclass->cache['bbcode'][] = $r;
|
|
}
|
|
|
|
$this->ipsclass->update_cache( array( 'name' => 'bbcode', 'array' => 1, 'deletefirst' => 1 ) );
|
|
|
|
//-------------------------------------------------------------
|
|
// Forum cache
|
|
//-------------------------------------------------------------
|
|
|
|
$this->ipsclass->update_forum_cache();
|
|
|
|
//-------------------------------------------------------------
|
|
// Group Cache
|
|
//-------------------------------------------------------------
|
|
|
|
$this->ipsclass->cache['group_cache'] = array();
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => "*",
|
|
'from' => 'groups'
|
|
) );
|
|
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while ( $i = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$this->ipsclass->cache['group_cache'][ $i['g_id'] ] = $i;
|
|
}
|
|
|
|
$this->ipsclass->update_cache( array( 'name' => 'group_cache', 'array' => 1, 'deletefirst' => 1 ) );
|
|
|
|
//-------------------------------------------------------------
|
|
// Systemvars
|
|
//-------------------------------------------------------------
|
|
|
|
$this->ipsclass->cache['systemvars'] = array();
|
|
|
|
$result = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'count(*) as cnt', 'from' => 'mail_queue' ) );
|
|
|
|
$this->ipsclass->cache['systemvars']['mail_queue'] = intval( $result['cnt'] );
|
|
$this->ipsclass->cache['systemvars']['task_next_run'] = time() + 3600;
|
|
|
|
$this->ipsclass->update_cache( array( 'name' => 'systemvars', 'array' => 1, 'deletefirst' => 1 ) );
|
|
|
|
//-----------------------------------------
|
|
// Moderators
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->cache['moderators'] = array();
|
|
|
|
require_once( ROOT_PATH.'sources/action_admin/moderator.php' );
|
|
$mod = new ad_moderator();
|
|
$mod->ipsclass =& $this->ipsclass;
|
|
|
|
$mod->rebuild_moderator_cache();
|
|
|
|
//-----------------------------------------
|
|
// Cal events / Birthdays
|
|
//-----------------------------------------
|
|
|
|
require_once( ROOT_PATH . 'sources/action_admin/calendars.php' );
|
|
$calendars = new ad_calendars();
|
|
$calendars->ipsclass =& $this->ipsclass;
|
|
|
|
$calendars->calendar_rebuildcache( 0 );
|
|
|
|
//-------------------------------------------------------------
|
|
// Ranks
|
|
//-------------------------------------------------------------
|
|
|
|
$this->ipsclass->cache['ranks'] = array();
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, title, pips, posts',
|
|
'from' => 'titles',
|
|
'order' => "posts DESC",
|
|
) );
|
|
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while ($i = $this->ipsclass->DB->fetch_row())
|
|
{
|
|
$this->ipsclass->cache['ranks'][ $i['id'] ] = array(
|
|
'TITLE' => $i['title'],
|
|
'PIPS' => $i['pips'],
|
|
'POSTS' => $i['posts'],
|
|
);
|
|
}
|
|
|
|
$this->ipsclass->update_cache( array( 'name' => 'ranks', 'array' => 1, 'deletefirst' => 1 ) );
|
|
|
|
|
|
//-------------------------------------------------------------
|
|
// SETTINGS
|
|
//-------------------------------------------------------------
|
|
|
|
require_once( ROOT_PATH . 'sources/action_admin/settings.php' );
|
|
$settings = new ad_settings();
|
|
$settings->ipsclass =& $this->ipsclass;
|
|
|
|
$settings->setting_rebuildcache();
|
|
|
|
//-------------------------------------------------------------
|
|
// EMOTICONS
|
|
//-------------------------------------------------------------
|
|
|
|
require_once( ROOT_PATH . 'sources/action_admin/emoticons.php' );
|
|
$emoticons = new ad_emoticons();
|
|
$emoticons->ipsclass =& $this->ipsclass;
|
|
|
|
$emoticons->emoticon_rebuildcache();
|
|
|
|
//-------------------------------------------------------------
|
|
// LANGUAGES
|
|
//-------------------------------------------------------------
|
|
|
|
$this->ipsclass->cache['languages'] = array();
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => 'ldir,lname', 'from' => 'languages' ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while ( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$this->ipsclass->cache['languages'][] = $r;
|
|
}
|
|
|
|
$this->ipsclass->update_cache( array( 'name' => 'languages', 'array' => 1, 'deletefirst' => 1 ) );
|
|
|
|
//-------------------------------------------------------------
|
|
// ATTACHMENT TYPES
|
|
//-------------------------------------------------------------
|
|
|
|
$this->ipsclass->cache['attachtypes'] = array();
|
|
|
|
$this->ipsclass->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" ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while ( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$this->ipsclass->cache['attachtypes'][ $r['atype_extension'] ] = $r;
|
|
}
|
|
|
|
$this->ipsclass->update_cache( array( 'name' => 'attachtypes', 'array' => 1, 'deletefirst' => 1 ) );
|
|
|
|
$this->ipsclass->core->redirect( "index.php?act=templates&loginkey={$this->ipsclass->input['loginkey']}&securekey={$this->ipsclass->input['securekey']}&mid={$this->ipsclass->input['mid']}", "Caches rebuilt, proceeding to rebuild templates..." );
|
|
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// MODULE RUN - Look for next, or finish up...
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function module_complete()
|
|
{
|
|
$message = array();
|
|
|
|
//--------------------------------
|
|
// Upgrade templates
|
|
//--------------------------------
|
|
|
|
if ( @file_exists( THIS_PATH.'upg_'.$this->ipsclass->current_upgrade.'/components.php' ) )
|
|
{
|
|
require_once( THIS_PATH.'upg_'.$this->ipsclass->current_upgrade.'/components.php' );
|
|
|
|
$this->ipsclass->DB->do_update( 'skin_sets', array( 'set_css' => $CSS,
|
|
'set_cache_css' => $CSS,
|
|
'set_wrapper' => $WRAPPER,
|
|
'set_cache_wrapper' => $WRAPPER,
|
|
), 'set_skin_set_id=1' );
|
|
|
|
$message[] = "Template components updated...";
|
|
}
|
|
|
|
//--------------------------------
|
|
// ACP Perms
|
|
//--------------------------------
|
|
|
|
if ( @file_exists( THIS_PATH.'upg_'.$this->ipsclass->current_upgrade.'/ipb_acpperms.xml' ) )
|
|
{
|
|
//-------------------------------
|
|
// Load module...
|
|
//-------------------------------
|
|
|
|
require_once( ROOT_PATH . 'sources/action_admin/acppermissions.php' );
|
|
$settings = new ad_acppermissions();
|
|
$settings->ipsclass =& $this->ipsclass;
|
|
|
|
//-------------------------------
|
|
// Set location
|
|
//-------------------------------
|
|
|
|
$this->ipsclass->input['file_location'] = UPGRADE_DIR.'/upg_'.$this->ipsclass->current_upgrade.'/ipb_acpperms.xml';
|
|
|
|
//-------------------------------
|
|
// Run it
|
|
//-------------------------------
|
|
|
|
$settings->acpperms_xml_import( 1 );
|
|
|
|
$message[] = $this->ipsclass->main_msg;
|
|
}
|
|
|
|
//--------------------------------
|
|
// Settings
|
|
//--------------------------------
|
|
|
|
if ( @file_exists( THIS_PATH.'upg_'.$this->ipsclass->current_upgrade.'/ipb_settings_partial.xml' ) )
|
|
{
|
|
//-------------------------------
|
|
// Load module...
|
|
//-------------------------------
|
|
|
|
require_once( ROOT_PATH . 'sources/action_admin/settings.php' );
|
|
$settings = new ad_settings();
|
|
$settings->ipsclass =& $this->ipsclass;
|
|
|
|
//-------------------------------
|
|
// Set location
|
|
//-------------------------------
|
|
|
|
$this->ipsclass->input['file_location'] = UPGRADE_DIR.'/upg_'.$this->ipsclass->current_upgrade.'/ipb_settings_partial.xml';
|
|
|
|
//-------------------------------
|
|
// Run it
|
|
//-------------------------------
|
|
|
|
$settings->settings_do_import( 1 );
|
|
|
|
$message[] = $this->ipsclass->main_msg;
|
|
}
|
|
|
|
//------------------------------------------
|
|
// Update DB
|
|
//------------------------------------------
|
|
|
|
$this->ipsclass->DB->do_insert( 'upgrade_history', array( 'upgrade_version_id' => $this->ipsclass->current_upgrade,
|
|
'upgrade_version_human' => $this->ipsclass->versions[ $this->ipsclass->current_upgrade ],
|
|
'upgrade_date' => time(),
|
|
'upgrade_mid' => $this->ipsclass->input['mid']
|
|
) );
|
|
|
|
//------------------------------------------
|
|
// Anymore to run?
|
|
//------------------------------------------
|
|
|
|
if ( $this->ipsclass->last_poss_id != $this->ipsclass->current_upgrade )
|
|
{
|
|
$this->ipsclass->core->redirect( "index.php?act=work&loginkey={$this->ipsclass->input['loginkey']}&securekey={$this->ipsclass->input['securekey']}&mid={$this->ipsclass->input['mid']}",
|
|
implode( "<br />", $message ) . "<br />Upgrade module complete, moving on to the next upgrade module...." );
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->template->content .= "
|
|
<div class='tableborder'>
|
|
<div class='maintitle'>IPB Upgrade Complete</div>
|
|
<div class='tdrow1' style='padding:6px'>".implode( "<br />", $message ) . "<br />
|
|
You have now been upgraded from {$this->ipsclass->versions[$this->ipsclass->current_version]} to {$this->ipsclass->versions[$this->ipsclass->current_upgrade]}
|
|
<br /><br />
|
|
The next few final steps will check for updated settings and recache your cached data (forums, groups, moderators, etc) and rebuild your master templates to ensure
|
|
that all the template additions and modifications are updated.
|
|
<br /><br />
|
|
<div align='center'><span style='font-weight:bold;font-size:14px'>» <a href='index.php?act=recache&loginkey={$this->ipsclass->input['loginkey']}&securekey={$this->ipsclass->input['securekey']}&mid={$this->ipsclass->input['mid']}'>Proceed...</a></span></div>
|
|
</div>
|
|
</div>
|
|
";
|
|
|
|
$this->ipsclass->template->output();
|
|
|
|
}
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// Redirect
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function redirect($url, $text, $time=2)
|
|
{
|
|
$this->ipsclass->template->content .= "<meta http-equiv='refresh' content=\"{$time}; url={$url}\">
|
|
<div class='tableborder'>
|
|
<div class='maintitle'>Redirecting</div>
|
|
<div class='tdrow1' style='padding:8px'>
|
|
<div style='font-size:12px'>$text
|
|
<br />
|
|
<br />
|
|
<center><a href='{$url}'>Click here if not redirected...</a></center>
|
|
</div>
|
|
</div>
|
|
</div>";
|
|
|
|
$this->ipsclass->template->output("Redirecting...");
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// SHOW LOG IN SCREEN
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function login_screen($msg='')
|
|
{
|
|
$alert = "";
|
|
|
|
if ( ! file_exists( ROOT_PATH.'ipb_templates.xml' ) )
|
|
{
|
|
$alert .= "<div class='warnbox'><b>Cannot locate XML templates</b><br />This should be located in 'ipb_templates.xml' please ensure this file is uploaded (recreating the file structure if needed) before continuing.
|
|
<br /><strong>Failure to upload this file will mean that your templates will not be updated.</strong></div>";
|
|
}
|
|
|
|
if ( ! is_writeable( CACHE_PATH . 'cache/skin_cache' ) )
|
|
{
|
|
$alert .= "<div class='warnbox'><strong>WARNING: cache/skin_cache is not writeable</strong><br />
|
|
Please check the CHMOD value on this folder before continuing. Failure to do so could mean that
|
|
your skin files will not be installed correctly.</div>";
|
|
}
|
|
|
|
if ( $alert )
|
|
{
|
|
$this->ipsclass->template->content .= "{$alert}";
|
|
$this->ipsclass->template->output("WARNING");
|
|
exit();
|
|
}
|
|
|
|
if ( $msg != "" )
|
|
{
|
|
$msg = "<div class='warnbox'>$msg</div><br />";
|
|
}
|
|
|
|
$this->ipsclass->template->content .= "
|
|
<form action='index.php?act=login' method='post' name='theAdminForm'>
|
|
{$msg}
|
|
<div>
|
|
<strong>You must log in with your forums administrative log in details to access the upgrade system.
|
|
<br />Upgrading from {$this->ipsclass->versions[$this->ipsclass->current_version]} to {$this->ipsclass->versions[$this->ipsclass->current_upgrade]}</strong>
|
|
</div>
|
|
<br />
|
|
<div class='tableborder'>
|
|
<div class='maintitle'>Verification Required - Please Log In</div>
|
|
<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>
|
|
<tr>
|
|
<td class='tdrow1' width='40%' valign='middle'>Your Forums Username:</td>
|
|
<td class='tdrow2' width='60%' valign='middle'><input type='text' style='width:100%' name='username' value=''></td>
|
|
</tr>
|
|
<tr>
|
|
<td class='tdrow1' width='40%' valign='middle'>Your Forums Password:</td>
|
|
<td class='tdrow2' width='60%' valign='middle'><input type='password' style='width:100%' name='password' value=''></td>
|
|
</tr>
|
|
<tr>
|
|
<td class='pformstrip' colspan='2'><div align='center'><input type='submit' value='Log in' id='button' accesskey='s'></div></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</form>";
|
|
|
|
$this->ipsclass->template->output("Log In");
|
|
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// Authorise da membah
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function get_member()
|
|
{
|
|
$member = array( 'id' => 0 );
|
|
|
|
$this->ipsclass->loginkey = $this->check_md5( isset($this->ipsclass->input['loginkey']) ? $this->ipsclass->input['loginkey'] : '' );
|
|
$this->ipsclass->securekey = $this->check_md5( isset($this->ipsclass->input['securekey']) ? $this->ipsclass->input['securekey'] : '' );
|
|
$this->ipsclass->member_id = trim(intval( isset($this->ipsclass->input['mid']) ? $this->ipsclass->input['mid'] : 0 ) );
|
|
|
|
if ( ! $this->ipsclass->loginkey or ! $this->ipsclass->securekey )
|
|
{
|
|
return $member;
|
|
}
|
|
|
|
$this->ipsclass->DB->build_query( array( 'select' => 'm.*,g.*',
|
|
'from' => array( 'members' => 'm' ),
|
|
'where' => "m.member_login_key='{$this->ipsclass->loginkey}' and m.id='{$this->ipsclass->member_id}'",
|
|
'limit' => array( 0, 1 ),
|
|
'add_join' => array( 1 => array( 'type' => 'left',
|
|
'from' => array( 'groups' => 'g' ),
|
|
'where' => 'g.g_id=m.mgroup',
|
|
) )
|
|
) );
|
|
$this->ipsclass->DB->exec_query();
|
|
|
|
$member = $this->ipsclass->DB->fetch_row();
|
|
|
|
return $member;
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// Get the current version and the next version to upgrade to..
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function get_version_latest()
|
|
{
|
|
$this->ipsclass->current_version = '';
|
|
$this->ipsclass->current_upgrade = '';
|
|
|
|
//------------------------------------------
|
|
// Copy & pop DB array and get next
|
|
// upgrade script
|
|
//------------------------------------------
|
|
|
|
$tmp = $this->ipsclass->db_contents;
|
|
|
|
$this->ipsclass->current_version = array_pop( $tmp );
|
|
|
|
//------------------------------------------
|
|
// Get the next upgrade script
|
|
//------------------------------------------
|
|
|
|
ksort( $this->ipsclass->dir_contents );
|
|
|
|
foreach( $this->ipsclass->dir_contents as $i => $a )
|
|
{
|
|
if ( $a > $this->ipsclass->current_version )
|
|
{
|
|
if ( ! $this->ipsclass->current_upgrade )
|
|
{
|
|
$this->ipsclass->current_upgrade = $a;
|
|
}
|
|
|
|
$this->ipsclass->modules_to_run[] = $this->ipsclass->versions[ $a ];
|
|
}
|
|
}
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// GET INFO FROM THE DERTABASTIC
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function get_db_structure()
|
|
{
|
|
$vers = array();
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'upgrade_history', 'order' => 'upgrade_version_id ASC' ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$vers[ $r['upgrade_version_id'] ] = $r['upgrade_version_id'];
|
|
}
|
|
|
|
return $vers;
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// Get dir structure..
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function get_dir_structure()
|
|
{
|
|
$return = array();
|
|
|
|
//------------------------------------------
|
|
// Get the folder names
|
|
//------------------------------------------
|
|
|
|
$dh = opendir( THIS_PATH );
|
|
|
|
while ( $file = readdir( $dh ) )
|
|
{
|
|
if ( is_dir( THIS_PATH."/".$file ) )
|
|
{
|
|
if ( $file != "." && $file != ".." )
|
|
{
|
|
if ( strstr( $file, 'upg_' ) )
|
|
{
|
|
$tmp = str_replace( "upg_", "", $file );
|
|
$return[ $tmp ] = $tmp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
closedir( $dh );
|
|
|
|
sort($return);
|
|
|
|
return $return;
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// Check to see if its a 'real' MD5
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function check_md5($t)
|
|
{
|
|
$t = preg_replace( "#[^a-z0-9]#", "", trim($t) );
|
|
|
|
if ( strlen($t) != 32 )
|
|
{
|
|
return '';
|
|
}
|
|
else
|
|
{
|
|
return $t;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
?>
|