Vergleich install/upgrade.php - 1.2.0 - 1.2.10

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 3Zeile 3
 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * MyBB 1.2
* Copyright � 2006 MyBB Group, All Rights Reserved
*

 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html

 *

 *

 * $Id: upgrade.php 2191 2006-09-03 12:11:04Z chris $

 * $Id: upgrade.php 3531 2007-12-02 01:21:43Z chris $

 */
error_reporting(E_ALL & ~E_NOTICE);


 */
error_reporting(E_ALL & ~E_NOTICE);


define("MYBB_ROOT", dirname(dirname(__FILE__)));

define('MYBB_ROOT', dirname(dirname(__FILE__))."/");

define("INSTALL_ROOT", dirname(__FILE__));

define("INSTALL_ROOT", dirname(__FILE__));

 
define('IN_MYBB', 1);





require_once MYBB_ROOT."/inc/class_core.php";

require_once MYBB_ROOT."inc/class_core.php";

$mybb = new MyBB;

// Include the files necessary for installation

$mybb = new MyBB;

// Include the files necessary for installation

require_once MYBB_ROOT."/inc/class_timers.php";
require_once MYBB_ROOT."/inc/functions.php";
require_once MYBB_ROOT."/inc/class_xml.php";
require_once MYBB_ROOT."/inc/config.php";
require_once MYBB_ROOT."/inc/db_".$config['dbtype'].".php";
require_once MYBB_ROOT.'/inc/class_language.php';

require_once MYBB_ROOT."inc/class_timers.php";
require_once MYBB_ROOT."inc/functions.php";
require_once MYBB_ROOT."inc/class_xml.php";
require_once MYBB_ROOT."inc/config.php";
require_once MYBB_ROOT."inc/db_".$config['dbtype'].".php";
require_once MYBB_ROOT.'inc/class_language.php';

$lang = new MyLanguage();

$lang = new MyLanguage();

$lang->set_path('resources/');

$lang->set_path(MYBB_ROOT.'install/resources/');

$lang->load('language');

// If there's a custom admin dir, use it.

$lang->load('language');

// If there's a custom admin dir, use it.

Zeile 32Zeile 33
// Legacy for those boards trying to upgrade from an older version
if(isset($config['admindir']))
{

// Legacy for those boards trying to upgrade from an older version
if(isset($config['admindir']))
{

	require_once MYBB_ROOT."/".$config['admindir']."/adminfunctions.php";

	require_once MYBB_ROOT.$config['admindir']."/adminfunctions.php";

}
// Current
else if(isset($config['admin_dir']))
{

}
// Current
else if(isset($config['admin_dir']))
{

	require_once MYBB_ROOT."/".$config['admin_dir']."/adminfunctions.php";

	require_once MYBB_ROOT.$config['admin_dir']."/adminfunctions.php";

}
// No custom set
else
{

}
// No custom set
else
{

	require_once MYBB_ROOT."/admin/adminfunctions.php";

	require_once MYBB_ROOT."admin/adminfunctions.php";

}

// Include the necessary contants for installation

}

// Include the necessary contants for installation

Zeile 55Zeile 56
require_once INSTALL_ROOT."/resources/output.php";
$output = new installerOutput;
$output->script = "upgrade.php";

require_once INSTALL_ROOT."/resources/output.php";
$output = new installerOutput;
$output->script = "upgrade.php";

 
$output->title = "MyBB Upgrade Wizard";


$db = new databaseEngine;
// Connect to Database


$db = new databaseEngine;
// Connect to Database

Zeile 74Zeile 76

if(!$mybb->input['action'] || $mybb->input['action'] == "intro")
{


if(!$mybb->input['action'] || $mybb->input['action'] == "intro")
{

 
		if($db->table_exists(TABLE_PREFIX."datacache"))
{
require_once MYBB_ROOT."inc/class_datacache.php";
$cache = new datacache;
$plugins = $cache->read('plugins', true);
if(!empty($plugins['active']))
{
$lang->upgrade_welcome = "<div class=\"error\"><strong><span style=\"color: red\">Warning:</span></strong> <p>There are still ".count($plugins['active'])." plugin(s) active. Active plugins can sometimes cause problems during an upgrade procedure.</p></div> <br />".$lang->upgrade_welcome;
}
}


		$output->print_header();

$db->query("DROP TABLE IF EXISTS ".TABLE_PREFIX."upgrade_data");

		$output->print_header();

$db->query("DROP TABLE IF EXISTS ".TABLE_PREFIX."upgrade_data");

Zeile 108Zeile 121
					$vers .= "<option value=\"$keynum[1]\">$verinfo[1]</option>\n";
}
}

					$vers .= "<option value=\"$keynum[1]\">$verinfo[1]</option>\n";
}
}

 


		}
unset($upgradescripts);
unset($upgradescript);

		}
unset($upgradescripts);
unset($upgradescript);

Zeile 124Zeile 138
	$system_upgrade_detail = get_upgrade_store("upgradedetail");

if($mybb->input['action'] == "templates")

	$system_upgrade_detail = get_upgrade_store("upgradedetail");

if($mybb->input['action'] == "templates")

	{

	{

		$runfunction = "upgradethemes";

		$runfunction = "upgradethemes";

	}

	}

	elseif($mybb->input['action'] == "rebuildsettings")
{
$runfunction = "buildsettings";

	elseif($mybb->input['action'] == "rebuildsettings")
{
$runfunction = "buildsettings";

	}

	}

	elseif($mybb->input['action'] == "buildcaches")

	elseif($mybb->input['action'] == "buildcaches")

	{

	{

		$runfunction = "buildcaches";
}
elseif($mybb->input['action'] == "finished")

		$runfunction = "buildcaches";
}
elseif($mybb->input['action'] == "finished")

	{

	{

		$runfunction = "upgradedone";
}
else // Busy running modules, come back later

		$runfunction = "upgradedone";
}
else // Busy running modules, come back later

Zeile 148Zeile 162
			$runfunction = next_function($bits[0], $bits[1]);

}

			$runfunction = next_function($bits[0], $bits[1]);

}

	}

	}

	// Fetch current script we're in

if(function_exists($runfunction))
{
$runfunction();

	// Fetch current script we're in

if(function_exists($runfunction))
{
$runfunction();

	}

	}

}

}





function upgradethemes()
{
global $output, $db, $system_upgrade_detail, $lang;

function upgradethemes()
{
global $output, $db, $system_upgrade_detail, $lang;





	$output->print_header($lang->upgrade_templates_reverted);

if($system_upgrade_detail['revert_all_templates'] > 0)

	$output->print_header($lang->upgrade_templates_reverted);

if($system_upgrade_detail['revert_all_templates'] > 0)

Zeile 171Zeile 185
		  title varchar(120) NOT NULL default '',
template text NOT NULL,
sid int(10) NOT NULL default '0',

		  title varchar(120) NOT NULL default '',
template text NOT NULL,
sid int(10) NOT NULL default '0',

		  version varchar(20) NOT NULL default '0',

		  version int unsigned NOT NULL default '0',

		  status varchar(10) NOT NULL default '',
dateline int(10) NOT NULL default '0',

		  status varchar(10) NOT NULL default '',
dateline int(10) NOT NULL default '0',

		  PRIMARY KEY  (tid)
) TYPE=MyISAM;");
}

		  PRIMARY KEY  (tid)
) TYPE=MyISAM;");
}


if($system_upgrade_detail['revert_all_themes'] > 0)
{


if($system_upgrade_detail['revert_all_themes'] > 0)
{

Zeile 186Zeile 200
		  name varchar(100) NOT NULL default '',
pid smallint unsigned NOT NULL default '0',
def smallint(1) NOT NULL default '0',

		  name varchar(100) NOT NULL default '',
pid smallint unsigned NOT NULL default '0',
def smallint(1) NOT NULL default '0',

		  css text NOT NULL default '',
cssbits text NOT NULL default '',
themebits text NOT NULL default '',
extracss text NOT NULL default '',
allowedgroups text NOT NULL default '',

		  css text NOT NULL,
cssbits text NOT NULL,
themebits text NOT NULL,
extracss text NOT NULL,
allowedgroups text NOT NULL,

		  csscached bigint(30) NOT NULL default '0',
PRIMARY KEY (tid)
) TYPE=MyISAM;");

		  csscached bigint(30) NOT NULL default '0',
PRIMARY KEY (tid)
) TYPE=MyISAM;");

		$db->query("INSERT INTO ".TABLE_PREFIX."themes (name,pid) VALUES ('MyBB Master Style','0')");
$db->query("INSERT INTO ".TABLE_PREFIX."themes (name,pid,def) VALUES ('MyBB Default','1','1')");
























$insert_array = array(
'name' => 'MyBB Master Style',
'pid' => 0,
'css' => '',
'cssbits' => '',
'themebits' => '',
'extracss' => '',
'allowedgroups' => ''
);
$db->insert_query(TABLE_PREFIX."themes", $insert_array);

$insert_array = array(
'name' => 'MyBB Default',
'pid' => 1,
'def' => 1,
'css' => '',
'cssbits' => '',
'themebits' => '',
'extracss' => '',
'allowedgroups' => ''
);
$db->insert_query(TABLE_PREFIX."themes", $insert_array);


		$sid = $db->insert_id();
$db->query("UPDATE ".TABLE_PREFIX."users SET style='$sid'");
$db->query("UPDATE ".TABLE_PREFIX."forums SET style='0'");

		$sid = $db->insert_id();
$db->query("UPDATE ".TABLE_PREFIX."users SET style='$sid'");
$db->query("UPDATE ".TABLE_PREFIX."forums SET style='0'");

Zeile 224Zeile 260
	foreach($templates as $template)
{
$templatename = $template['attributes']['name'];

	foreach($templates as $template)
{
$templatename = $template['attributes']['name'];

		$templateversion = $template['attributes']['version'];

		$templateversion = intval($template['attributes']['version']);

		$templatevalue = $db->escape_string($template['value']);
$time = time();
$query = $db->query("SELECT tid FROM ".TABLE_PREFIX."templates WHERE sid='-2' AND title='$templatename'");

		$templatevalue = $db->escape_string($template['value']);
$time = time();
$query = $db->query("SELECT tid FROM ".TABLE_PREFIX."templates WHERE sid='-2' AND title='$templatename'");

Zeile 240Zeile 276
		}
}
update_theme(1, 0, $themebits, $css, 0);

		}
}
update_theme(1, 0, $themebits, $css, 0);

	$output->print_contents(sprintf($lang->upgrade_template_reverted_success, $synccount[1], $synccount[0]));

	$output->print_contents($lang->upgrade_templates_reverted_success);

	$output->print_footer("rebuildsettings");
}


	$output->print_footer("rebuildsettings");
}


Zeile 248Zeile 284
{
global $db, $output, $system_upgrade_detail, $lang;


{
global $db, $output, $system_upgrade_detail, $lang;


 
	if(!is_writable(MYBB_ROOT."inc/settings.php"))
{
$output->print_header("Rebuilding Settings");
echo "<p><div class=\"error\"><span style=\"color: red; font-weight: bold;\">Error: Unable to open inc/settings.php</span><h3>Before the upgrade process can continue, you need to changes the permissions of inc/settings.php so it is writable.</h3></div></p>";
$output->print_footer("rebuildsettings");
exit;
}

	$synccount = sync_settings($system_upgrade_detail['revert_all_settings']);

$output->print_header($lang->upgrade_settings_sync);

	$synccount = sync_settings($system_upgrade_detail['revert_all_settings']);

$output->print_header($lang->upgrade_settings_sync);

Zeile 262Zeile 305
	$output->print_header($lang->upgrade_datacache_building);

$contents .= $lang->upgrade_building_datacache;

	$output->print_header($lang->upgrade_datacache_building);

$contents .= $lang->upgrade_building_datacache;

	require_once MYBB_ROOT."/inc/class_datacache.php";

	require_once MYBB_ROOT."inc/class_datacache.php";

	$cache = new datacache;
$cache->updateversion();
$cache->updateattachtypes();

	$cache = new datacache;
$cache->updateversion();
$cache->updateattachtypes();

Zeile 303Zeile 346
	{
$lock_note = "<p><b><span style=\"color: red;\">".$lang->upgrade_removedir."</span></b></p>";
}

	{
$lock_note = "<p><b><span style=\"color: red;\">".$lang->upgrade_removedir."</span></b></p>";
}

 


	$output->print_contents(sprintf($lang->upgrade_congrats, $mybb->version, $lock_note));
$output->print_footer();

	$output->print_contents(sprintf($lang->upgrade_congrats, $mybb->version, $lock_note));
$output->print_footer();

}


}


function whatsnext()
{
global $output, $db, $system_upgrade_detail, $lang;

function whatsnext()
{
global $output, $db, $system_upgrade_detail, $lang;





	if($system_upgrade_detail['revert_all_templates'] > 0)
{
$output->print_header($lang->upgrade_template_reversion);

	if($system_upgrade_detail['revert_all_templates'] > 0)
{
$output->print_header($lang->upgrade_template_reversion);

Zeile 338Zeile 382
		if(file_exists(INSTALL_ROOT."/resources/upgrade".$from.".php"))
{
$function = next_function($from);

		if(file_exists(INSTALL_ROOT."/resources/upgrade".$from.".php"))
{
$function = next_function($from);

		}
}

		}
}


if(!$function)
{
$function = "whatsnext";
}
return $function;


if(!$function)
{
$function = "whatsnext";
}
return $function;

}

}


function load_module($module)
{


function load_module($module)
{

Zeile 364Zeile 408
		add_upgrade_store("upgradedetail", $system_upgrade_detail);
add_upgrade_store("currentscript", $module);
}

		add_upgrade_store("upgradedetail", $system_upgrade_detail);
add_upgrade_store("currentscript", $module);
}

}

}


function get_upgrade_store($title)
{


function get_upgrade_store($title)
{

Zeile 383Zeile 427
function sync_settings($redo=0)
{
global $db;

function sync_settings($redo=0)
{
global $db;

 
	

	$settingcount = $groupcount = 0;
if($redo == 2)
{

	$settingcount = $groupcount = 0;
if($redo == 2)
{

		$db->query("DROP TABLE ".TABLE_PREFIX."settinggroups");

		$db->query("DROP TABLE IF EXISTS ".TABLE_PREFIX."settinggroups");

		$db->query("CREATE TABLE ".TABLE_PREFIX."settinggroups (
gid smallint unsigned NOT NULL auto_increment,
name varchar(100) NOT NULL default '',
title varchar(220) NOT NULL default '',

		$db->query("CREATE TABLE ".TABLE_PREFIX."settinggroups (
gid smallint unsigned NOT NULL auto_increment,
name varchar(100) NOT NULL default '',
title varchar(220) NOT NULL default '',

		  description text NOT NULL default '',

		  description text NOT NULL,

		  disporder smallint unsigned NOT NULL default '0',
isdefault char(3) NOT NULL default '',
PRIMARY KEY (gid)
) TYPE=MyISAM;");


		  disporder smallint unsigned NOT NULL default '0',
isdefault char(3) NOT NULL default '',
PRIMARY KEY (gid)
) TYPE=MyISAM;");


		$db->query("DROP TABLE ".TABLE_PREFIX."settings");

		$db->query("DROP TABLE IF EXISTS ".TABLE_PREFIX."settings");


$db->query("CREATE TABLE ".TABLE_PREFIX."settings (
sid smallint(6) NOT NULL auto_increment,


$db->query("CREATE TABLE ".TABLE_PREFIX."settings (
sid smallint(6) NOT NULL auto_increment,

Zeile 438Zeile 483
			"disporder" => intval($settinggroup['attributes']['disporder']),
"isdefault" => $settinggroup['attributes']['isdefault']
);

			"disporder" => intval($settinggroup['attributes']['disporder']),
"isdefault" => $settinggroup['attributes']['isdefault']
);

		if(!$settinggroups[$settinggroup['attributes']['key']] || $redo == 2)

		if(!$settinggroups[$settinggroup['attributes']['name']] || $redo == 2)

		{
$db->insert_query(TABLE_PREFIX."settinggroups", $groupdata);
$gid = $db->insert_id();
$groupcount++;
}
else

		{
$db->insert_query(TABLE_PREFIX."settinggroups", $groupdata);
$gid = $db->insert_id();
$groupcount++;
}
else

		{

		{

			$gid = $settinggroups[$settinggroup['attributes']['name']];

			$gid = $settinggroups[$settinggroup['attributes']['name']];

			$db->insert_query(TABLE_PREFIX."settinggroups", $groupdata, "gid='{$gid}");

			$db->update_query(TABLE_PREFIX."settinggroups", $groupdata, "gid='{$gid}'");

		}
if(!$gid)
{

		}
if(!$gid)
{

Zeile 478Zeile 523
	}
if($redo >= 1)
{

	}
if($redo >= 1)
{

		require_once MYBB_ROOT."/inc/settings.php";

		require MYBB_ROOT."inc/settings.php";

		foreach($settings as $key => $val)
{
$db->update_query(TABLE_PREFIX."settings", array('value' => $db->escape_string($val)), "name='$key'");

		foreach($settings as $key => $val)
{
$db->update_query(TABLE_PREFIX."settings", array('value' => $db->escape_string($val)), "name='$key'");

Zeile 489Zeile 534
	while($setting = $db->fetch_array($query))
{
$setting['value'] = str_replace("\"", "\\\"", $setting['value']);

	while($setting = $db->fetch_array($query))
{
$setting['value'] = str_replace("\"", "\\\"", $setting['value']);

		$settings .= "\$settings[".$setting['name']."] = \"".$setting['value']."\";\n";

		$settings .= "\$settings['{$setting['name']}'] = \"".$setting['value']."\";\n";

	}
$settings = "<?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?>";

	}
$settings = "<?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?>";

	$file = fopen(MYBB_ROOT."/inc/settings.php", "w");

	$file = fopen(MYBB_ROOT."inc/settings.php", "w");

	fwrite($file, $settings);
fclose($file);
return array($groupcount, $settingcount);

	fwrite($file, $settings);
fclose($file);
return array($groupcount, $settingcount);

Zeile 500Zeile 545

function write_settings()
{


function write_settings()
{

	global $db, $cwd;

	global $db;

	$query = $db->query('SELECT * FROM '.TABLE_PREFIX.'settings ORDER BY title ASC');
while($setting = $db->fetch_array($query))
{

	$query = $db->query('SELECT * FROM '.TABLE_PREFIX.'settings ORDER BY title ASC');
while($setting = $db->fetch_array($query))
{

Zeile 510Zeile 555
	if(!empty($settings))
{
$settings = "<?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n{$settings}\n?>";

	if(!empty($settings))
{
$settings = "<?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n{$settings}\n?>";

		$file = fopen(MYBB_ROOT."/inc/settings.php", "w");

		$file = fopen(MYBB_ROOT."inc/settings.php", "w");

		fwrite($file, $settings);
fclose($file);
}

		fwrite($file, $settings);
fclose($file);
}