Version 3.1.4

This commit is contained in:
Neo committed 2025-12-19 00:32:22 -08:00
1 parent 1d4720f3e2
commit ae5c01cc78
2563 files changed
+283048 -240689

No files matched your search

+382 -52
View File
@@ -1,20 +1,22 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Static SETUP Classes for IP.Board 3
*
* These classes are not required as objects.
* Last Updated: $Date: 2009-10-13 17:40:38 -0400 (Tue, 13 Oct 2009) $
* Last Updated: $Date: 2010-11-15 11:39:10 -0500 (Mon, 15 Nov 2010) $
* </pre>
*
* @author Matt Mecham
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since 1st December 2008
* @version $Revision: 5228 $
* @version $Revision: 7185 $
*
*/
@@ -166,7 +168,279 @@ class IPSSetUp
return FALSE;
}
}
/**
* Check for previous sessions.
* Checks to see if there's an unfinished upgrade.
*
* @access public
*/
static public function checkForPreviousSessions()
{
$session = ipsRegistry::DB()->buildAndFetch( array( 'select' => '*',
'from' => 'upgrade_sessions',
'where' => 'session_section != \'done\' AND session_section != \'apps\' AND session_id !=\'' . addslashes( ipsRegistry::$request['s'] ) . '\'',
'order' => 'session_current_time DESC',
'limit' => array( 0, 1 ) ) );
/* Expand some stuff */
$session['_session_post'] = unserialize( $session['session_post'] );
$session['_session_get'] = unserialize( $session['session_get'] );
$session['_session_data'] = unserialize( $session['session_data'] );
if ( $session['_session_post']['_sd'] )
{
$session['_sd'] = unserialize( urldecode( $session['_session_post']['_sd'] ) );
}
return ( $session ) ? $session : array();
}
/**
* Removes previous session
*
* @param array
* @access public
*/
static public function removePreviousSession()
{
/* Delete all previous sessions */
ipsRegistry::DB()->delete( 'upgrade_sessions', 'session_id != \'' . ipsRegistry::$request['s'] . '\'' );
}
/**
* Check for previous sessions.
* Checks to see if there's an unfinished upgrade.
*
* @param array
* @access public
*/
static public function restorePreviousSession( $session )
{
/* Delete all previous sessions */
ipsRegistry::DB()->delete( 'upgrade_sessions', 'session_id != \'' . ipsRegistry::$request['s'] . '\'' );
/* Update the session */
ipsRegistry::DB()->update( 'upgrade_sessions', array( 'session_current_time' => time(),
'session_section' => $session['session_section'],
'session_post' => serialize( $session['_session_post'] ),
'session_get' => serialize( $session['_session_get'] ) ), 'session_id=\'' . ipsRegistry::$request['s'] . '\'' );
/* Set correct app */
$_GET['app'] = 'upgrade';
$_POST['app'] = 'upgrade';
ipsRegistry::$request['app'] = 'upgrade';
ipsRegistry::$current_section = 'upgrade';
/* Set correct section */
$_GET['section'] = $session['_session_get']['section'];
$_POST['section'] = $session['_session_get']['section'];
ipsRegistry::$request['section'] = $session['_session_get']['section'];
ipsRegistry::$current_section = $session['_session_get']['section'];
/* Set up the correct do */
$_GET['do'] = $session['_session_get']['do'];
$_POST['do'] = $session['_session_get']['do'];
ipsRegistry::$request['do'] = $session['_session_get']['do'];
/* Set up the correct previous */
$_GET['previous'] = $session['_session_get']['previous'];
$_POST['previous'] = $session['_session_get']['previous'];
ipsRegistry::$request['previous'] = $session['_session_get']['previous'];
/* Set up SD */
$_POST['_sd'] = $session['_sd'];
ipsRegistry::$request['_sd'] = $session['_sd'];
/* App dir, etc */
ipsRegistry::$request['appdir'] = $session['_sd']['appdir'];
ipsRegistry::$request['man'] = $session['_sd']['man'];
ipsRegistry::$request['helpfile'] = $session['_sd']['helpfile'];
$apps = explode( ',', $session['_sd']['install_apps'] );
$toSave = array();
$vNums = array();
/* set saved data */
if ( count( $session['_sd'] ) )
{
foreach( $session['_sd'] as $k => $v )
{
if ( $k )
{
IPSSetUp::setSavedData( $k, $v );
}
}
}
if ( is_array( $apps ) and count( $apps ) )
{
/* Grab data */
foreach( $apps as $app )
{
/* Grab version numbers */
$numbers = IPSSetUp::fetchAppVersionNumbers( $app );
/* Grab all numbers */
$nums[ $app ] = IPSSetUp::fetchXmlAppVersions( $app );
/* Grab app data */
$appData[ $app ] = IPSSetUp::fetchXmlAppInformation( $app );
$appClasses[ $app ] = IPSSetUp::fetchVersionClasses( $app, $numbers['current'][0], $numbers['latest'][0] );
/* Store starting vnums */
$vNums[ $app ] = $numbers['current'][0];
}
/* Got anything? */
if ( count( $appClasses ) )
{
foreach( $appClasses as $app => $data )
{
foreach( $data as $num )
{
if ( file_exists( IPSLib::getAppDir( $app ) . '/setup/versions/upg_' . $num . '/version_class.php' ) )
{
$_class = 'version_class_' . $num;
require_once( IPSLib::getAppDir( $app ) . '/setup/versions/upg_' . $num . '/version_class.php' );
$_tmp = new $_class( ipsRegistry::instance() );
if ( method_exists( $_tmp, 'preInstallOptionsSave' ) )
{
$_t = $_tmp->preInstallOptionsSave();
if ( is_array( $_t ) AND count( $_t ) )
{
$toSave[ $app ][ $num ] = $_t;
}
}
}
}
}
/* Save it */
if ( count( $toSave ) )
{
IPSSetUp::setSavedData('custom_options', $toSave );
}
if ( count( $vNums ) )
{
IPSSetUp::setSavedData('version_numbers', $vNums );
}
}
/* Freeze data */
IPSSetUp::freezeSavedData();
/* Thaw it */
IPSSetUp::thawSavedData();
}
/* Re run our controller */
ipsController::run();
}
/**
* Update previous template data
*
* @access public
* @param string Current Human version ID
* @param int Current Long Version ID
* @param string App key (aka app_dir)
*/
static public function resetPreviousTemplates( $uipLong, $uipHuman, $app )
{
# For now, if not core, skip
if ( $app != 'core' )
{
return;
}
# < 3.1.0 won't have this, so just skip
if ( ipsRegistry::DB()->checkForField( 'template_master_key', 'skin_templates' ) )
{
ipsRegistry::DB()->delete( 'skin_templates_previous' );
ipsRegistry::DB()->delete( 'skin_css_previous' );
ipsRegistry::DB()->build( array( 'select' => '*',
'from' => 'skin_templates',
'where' => 'template_master_key != \'\'' ) );
$o = ipsRegistry::DB()->execute();
while( $row = ipsRegistry::DB()->fetch( $o ) )
{
ipsRegistry::DB()->insert( 'skin_templates_previous', array( 'p_template_group' => $row['template_group'],
'p_template_content' => $row['template_content'],
'p_template_name' => $row['template_name'],
'p_template_data' => $row['template_data'],
'p_template_master_key' => $row['template_master_key'],
'p_template_long_version' => $uipLong,
'p_template_human_version' => $uipHuman ) );
}
ipsRegistry::DB()->build( array( 'select' => '*',
'from' => 'skin_css',
'where' => 'css_master_key != \'\'' ) );
$o = ipsRegistry::DB()->execute();
while( $row = ipsRegistry::DB()->fetch( $o ) )
{
ipsRegistry::DB()->insert( 'skin_css_previous', array( 'p_css_group' => $row['css_group'],
'p_css_content' => $row['css_content'],
'p_css_app' => $row['css_app'],
'p_css_attributes' => $row['css_attributes'],
'p_css_modules' => $row['css_modules'],
'p_css_master_key' => $row['css_master_key'],
'p_css_long_version' => $uipLong,
'p_css_human_version' => $uipHuman ) );
}
}
# If this is 3.0.x, save the templates
else if ( ipsRegistry::DB()->checkForTable( 'skin_collections' ) )
{
ipsRegistry::DB()->build( array( 'select' => '*',
'from' => 'skin_templates',
'where' => 'template_set_id=0' ) );
$o = ipsRegistry::DB()->execute();
while( $row = ipsRegistry::DB()->fetch( $o ) )
{
ipsRegistry::DB()->insert( 'skin_templates_previous', array( 'p_template_group' => $row['template_group'],
'p_template_content' => $row['template_content'],
'p_template_name' => $row['template_name'],
'p_template_data' => $row['template_data'],
'p_template_master_key' => 'root',
'p_template_long_version' => $uipLong,
'p_template_human_version' => $uipHuman ) );
}
ipsRegistry::DB()->build( array( 'select' => '*',
'from' => 'skin_css',
'where' => 'css_set_id=0' ) );
$o = ipsRegistry::DB()->execute();
while( $row = ipsRegistry::DB()->fetch( $o ) )
{
ipsRegistry::DB()->insert( 'skin_css_previous', array( 'p_css_group' => $row['css_group'],
'p_css_content' => $row['css_content'],
'p_css_app' => $row['css_app'],
'p_css_attributes' => $row['css_attributes'],
'p_css_modules' => $row['css_modules'],
'p_css_master_key' => 'root',
'p_css_long_version' => $uipLong,
'p_css_human_version' => $uipHuman ) );
}
}
}
/**
* Create a MySQL source file for larger boards
*
@@ -254,6 +528,13 @@ class IPSSetUp
$query = preg_replace( "#(\s|'|\")PK_(\S+)#", " \\1" . $prefix."PK_\\2", $query );
$query = preg_replace( "#(\s|'|\")ftcatalog(\s|'|\")#", " \\1" . $prefix."ftcatalog\\2", $query );
$query = preg_replace( "#^SET IDENTITY_INSERT (?:\s+?)?(\S+)\s+?#i" , "SET IDENTITY_INSERT " . $prefix."\\1 ", $query );
$query = preg_replace( "#(\S+)(.*)IDENTITY PK_(\S+) PRIMARY KEY#", "\\1\\2IDENTITY " . $prefix."PK_\\3 PRIMARY KEY", $query );
$query = preg_replace( "#(\S+)(.*)IDENTITY CONSTRAINT PK_(\S+) PRIMARY KEY#", "\\1\\2IDENTITY CONSTRAINT " . $prefix."PK_\\3 PRIMARY KEY", $query );
$query = preg_replace( "#^CREATE INDEX (\S+) ON (\S+) #", "CREATE INDEX \\1 ON " . $prefix."\\2 " , $query );
$query = preg_replace( "#^CREATE UNIQUE INDEX (\S+) ON (\S+) #", "CREATE UNIQUE INDEX \\1 ON " . $prefix."\\2 " , $query );
$query = preg_replace( "# PK_(\S+)#", " " . $prefix."PK_\\1", $query );
}
return $query;
@@ -271,14 +552,16 @@ class IPSSetUp
{
$file_name = DOC_IPS_ROOT_PATH . 'cache/sql_upgrade_log_'.date('m_d_y').'.cgi';
$_error_string = "\n===================================================";
$_error_string .= "\n Дата: ". date( 'r' );
$_error_string .= "\n IP адрес: " . $_SERVER['REMOTE_ADDR'];
$_error_string .= "\n Приложение " . $app;
$_error_string .= "\n Версия: " . $version;
$_error_string .= "\n Шаг: " . ipsRegistry::$request['do'];
$_error_string .= "\n Действие: " . ipsRegistry::$request['workact'];
$_error_string .= "\n\n\n ".$message;
$_error_string = "===================================================";
$_error_string .= "\nDate: ". date( 'r' );
$_error_string .= "\nIP Address: " . $_SERVER['REMOTE_ADDR'];
$_error_string .= "\nApplication " . $app;
$_error_string .= "\nVersion Folder: " . $version;
$_error_string .= "\nCurrent Sub Step: " . ipsRegistry::$request['do'];
$_error_string .= "\nCurrent workact: " . ipsRegistry::$request['workact'];
$_error_string .= "\n---------------------------------------------------";
$_error_string .= "\n".$message . "\n";
if ( $fh = @fopen( $file_name, "a" ) )
{
@@ -308,28 +591,31 @@ class IPSSetUp
}
/* Search for files... */
$dh = opendir( IPSLib::getAppDir( $app ) . '/setup/versions' );
while ( false !== ( $file = readdir( $dh ) ) )
{
if ( is_dir( IPSLib::getAppDir( $app ) . '/setup/versions/' . $file ) )
{
if ( $file != "." && $file != ".." && $file != 'install' )
if( is_dir( IPSLib::getAppDir( $app ) . '/setup/versions' ) )
{
$dh = opendir( IPSLib::getAppDir( $app ) . '/setup/versions' );
while ( false !== ( $file = readdir( $dh ) ) )
{
if ( is_dir( IPSLib::getAppDir( $app ) . '/setup/versions/' . $file ) )
{
if ( strstr( $file, 'upg_' ) )
if ( $file != "." && $file != ".." && $file != 'install' )
{
$tmp = intval( str_replace( "upg_", "", $file ) );
if ( $tmp > $from AND $tmp <= $to )
if ( strstr( $file, 'upg_' ) )
{
if ( file_exists( IPSLib::getAppDir( $app ) . '/setup/versions/' . $file . '/version_class.php' ) )
$tmp = intval( str_replace( "upg_", "", $file ) );
if ( $tmp > $from AND $tmp <= $to )
{
$classes[] = $tmp;
if ( file_exists( IPSLib::getAppDir( $app ) . '/setup/versions/' . $file . '/version_class.php' ) )
{
$classes[] = $tmp;
}
}
}
}
}
}
}
}
return $classes;
@@ -338,7 +624,8 @@ class IPSSetUp
/**
* Fetch current and next app versions
*
* @access public Application Directory
* @access public
* @param string Application Directory
* @return array array( 'current' => array( 000000, '1.0.0 Beta1' ), 'next' => array( 000000, '1.0.0 Beta1' ), 'latest' => array( 000000, '1.0.0 Beta1' ) )
*/
static public function fetchAppVersionNumbers( $app )
@@ -350,12 +637,16 @@ class IPSSetUp
/* Latest version */
$XMLVersions = self::fetchXmlAppVersions( $app );
$tmp = $XMLVersions;
krsort( $tmp );
foreach( $tmp as $long => $human )
if( is_array($tmp) AND count($tmp) )
{
$return['latest'] = array( $long, $human );
break;
krsort( $tmp );
foreach( $tmp as $long => $human )
{
$return['latest'] = array( $long, $human );
break;
}
}
/* Current Version */
@@ -434,6 +725,32 @@ class IPSSetUp
$key = 0;
}
}
else if( $app == 'ipchat' )
{
if ( ipsRegistry::DB()->checkForTable( 'chat_log_archive' ) )
{
$_a = array_keys( $XMLVersions );
$a = array_shift( $_a );
$key = ( $a ) ? $a : '11005';
}
else
{
$key = 0;
}
}
else if( $app == 'ccs' )
{
if ( ipsRegistry::DB()->checkForTable( 'ccs_pages' ) )
{
$_a = array_keys( $XMLVersions );
$a = array_shift( $_a );
$key = ( $a ) ? $a : '20006';
}
else
{
$key = 0;
}
}
}
$return['current'] = ( $key ) ? array( $key, $XMLVersions[ $key ] ) : array( 0, 'install' );
@@ -441,12 +758,15 @@ class IPSSetUp
/* Next version */
$nextKey = 0;
foreach( $XMLVersions as $long => $human )
if( is_array($XMLVersions) AND count($XMLVersions) )
{
if ( $long > $return['current'][0] )
foreach( $XMLVersions as $long => $human )
{
$nextKey = $long;
break;
if ( $long > $return['current'][0] )
{
$nextKey = $long;
break;
}
}
}
@@ -493,7 +813,8 @@ class IPSSetUp
/**
* Fetch app DB versions
*
* @access public Application Directory
* @access public
* @param string Application Directory
* @return array
*/
static public function fetchDbAppVersions( $app )
@@ -595,6 +916,11 @@ class IPSSetUp
try
{
if( !file_exists( IPSLib::getAppDir( $app ) . '/xml/versions.xml' ) )
{
return false;
}
$xml->load( IPSLib::getAppDir( $app ) . '/xml/versions.xml' );
/* Fetch general information */
@@ -639,9 +965,10 @@ class IPSSetUp
* @access public
* @param string Previous application
* @param string XML file to search for. If supplied, function will return next app that has the XML file. Use {app} for $app ({app}_settings.xml)
* @param string Charset (used post-install)
* @return mixed
*/
static public function fetchNextApplication( $previous='', $xmlFileSearch='' )
static public function fetchNextApplication( $previous='', $xmlFileSearch='', $charset='' )
{
//-----------------------------------------
// INIT
@@ -690,7 +1017,7 @@ class IPSSetUp
if ( $return )
{
return self::fetchXmlAppInformation( $return );
return self::fetchXmlAppInformation( $return, $charset );
}
return FALSE;
@@ -784,16 +1111,17 @@ class IPSSetUp
*
* @access public
* @param string Application Directory
* @param string Character set (used for ACP)
* @return array ..of data
*/
static public function fetchXmlAppInformation( $app )
static public function fetchXmlAppInformation( $app, $charset='' )
{
/* INIT */
$info = array();
/* Fetch core writeable files */
require_once( IPS_KERNEL_PATH . 'classXML.php' );
$xml = new classXML( IPSSetUp::charSet );
$xml = new classXML( $charset ? $charset : IPSSetUp::charSet );
try
{
@@ -844,9 +1172,10 @@ class IPSSetUp
*
* @access public
* @param string Application Directory
* @param string Charset (post install)
* @return array ..of data
*/
static public function fetchXmlAppModules( $app )
static public function fetchXmlAppModules( $app, $charset='' )
{
//-----------------------------------------
// No modules?
@@ -860,14 +1189,10 @@ class IPSSetUp
/* INIT */
$modules = array();
/* Fetch core writeable files */
require_once( IPS_KERNEL_PATH . 'classXML.php' );
$xml = new classXML( IPSSetUp::charSet );
try
{
require_once( IPS_KERNEL_PATH . 'classXML.php' );
$xml = new classXML( IPSSetUp::charSet );
$xml = new classXML( $charset ? $charset : IPSSetUp::charSet );
$xml->load( IPSLib::getAppDir( $app ) . '/xml/' . $app . '_modules.xml' );
@@ -880,6 +1205,11 @@ class IPSSetUp
{
unset($data['sys_module_id']);
}
/* Remove fields removed from 3.1.3+ to avoid driver errors */
unset($data['sys_module_parent']);
unset($data['sys_module_tables']);
unset($data['sys_module_hooks']);
$modules[ $data['sys_module_key'] . intval($data['sys_module_admin']) ] = $data;
}
@@ -946,7 +1276,7 @@ class IPSSetUp
static function freezeSavedData()
{
/* Encode */
$data = urlencode( serialize( self::$_savedData ) );
$data = base64_encode( serialize( self::$_savedData ) );
/* Write to our cache file */
if ( is_array( self::$_savedData ) )
@@ -979,7 +1309,7 @@ class IPSSetUp
}
}
self::$_savedData = unserialize( urldecode( $data ) );
self::$_savedData = unserialize( base64_decode( $data ) );
}
/**