Vergleich install/resources/upgrade12.php - 1.6.3 - 1.6.12

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: upgrade12.php 5440 2011-04-15 10:18:35Z Tomm $

 * $Id$

 */

/**

 */

/**

Zeile 22Zeile 22

@set_time_limit(0);



@set_time_limit(0);


// We need to globalize $db here because when this script is called 

// We need to globalize $db here because when this script is called

// during load_module $db is not globalized in the function
global $db;


// during load_module $db is not globalized in the function
global $db;


Zeile 54Zeile 54
		"users" => array("uid","allownotices","hideemail","invisible","receivepms","pmpopup","pmnotify","remember","showsigs","showavatars","showquickreply","showredirect","away"),
"threads" => array("tid", "closed")
);

		"users" => array("uid","allownotices","hideemail","invisible","receivepms","pmpopup","pmnotify","remember","showsigs","showavatars","showquickreply","showredirect","away"),
"threads" => array("tid", "closed")
);

	



	if(!$db->field_exists('pmpopup', "users"))
{
$pmpopup_key = array_search('pmpopup', $to_int['users']);

	if(!$db->field_exists('pmpopup', "users"))
{
$pmpopup_key = array_search('pmpopup', $to_int['users']);

Zeile 68Zeile 68
	if($mybb->input['last_table'])
{
$current_table = $mybb->input['last_table'];

	if($mybb->input['last_table'])
{
$current_table = $mybb->input['last_table'];

	}

	}

	else
{
$current_table = array_keys($to_int);
$current_table = $current_table[0];
echo "<p>MyBB 1.4 represents a huge leap forward for the MyBB project.</p><p>Due to this, lots of information in the database needs to be converted to a new format.</p>";
}

	else
{
$current_table = array_keys($to_int);
$current_table = $current_table[0];
echo "<p>MyBB 1.4 represents a huge leap forward for the MyBB project.</p><p>Due to this, lots of information in the database needs to be converted to a new format.</p>";
}





	echo "<p>MyBB is now currently converting a section of data to the new format, this may take a while.</p>";

$remaining = $perpage;

$final_table = array_keys($to_int);
$final_table = $final_table[count($final_table)-1];

	echo "<p>MyBB is now currently converting a section of data to the new format, this may take a while.</p>";

$remaining = $perpage;

$final_table = array_keys($to_int);
$final_table = $final_table[count($final_table)-1];





	$next_act = "12_dbchanges";

$start = intval($mybb->input['start']);

	$next_act = "12_dbchanges";

$start = intval($mybb->input['start']);

Zeile 96Zeile 96
			if($remaining <= 0)
{
break;

			if($remaining <= 0)
{
break;

			}

			}

			$columns_sql = implode(",", $columns);
$primary_key = $columns[0];
if(!$mybb->input['count'])

			$columns_sql = implode(",", $columns);
$primary_key = $columns[0];
if(!$mybb->input['count'])

Zeile 109Zeile 109
				$end = $start+$perpage;
if($end > $count) $end = $count;
echo "<p>{$table}: Converting {$start} to {$end} of {$count}</p>";

				$end = $start+$perpage;
if($end > $count) $end = $count;
echo "<p>{$table}: Converting {$start} to {$end} of {$count}</p>";

				flush();

				flush();

				$form_fields['start'] = $perpage+$start;

$query = $db->simple_select($table, $columns_sql, "", array('order_by' => $pimary_key, 'limit_start' => $start, 'limit' => $remaining));

				$form_fields['start'] = $perpage+$start;

$query = $db->simple_select($table, $columns_sql, "", array('order_by' => $pimary_key, 'limit_start' => $start, 'limit' => $remaining));

Zeile 191Zeile 191
		echo "<p>Click next to continue with the upgrade process.</p>";
global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";

		echo "<p>Click next to continue with the upgrade process.</p>";
global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";





		$output->print_footer($next_act);
}

		$output->print_footer($next_act);
}

}


}


function upgrade12_dbchanges1()
{
global $db, $output, $mybb;

function upgrade12_dbchanges1()
{
global $db, $output, $mybb;

Zeile 205Zeile 205
	echo "<p>Performing necessary upgrade queries..</p>";
echo "<p>Adding index to private messages table ... ";
flush();

	echo "<p>Performing necessary upgrade queries..</p>";
echo "<p>Adding index to private messages table ... ";
flush();

	



	$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages ADD INDEX ( `uid` )");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages ADD INDEX ( `uid` )");

	



	echo "done.</p>";

	echo "done.</p>";

	



	$contents = "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);

	$contents = "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);





	global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";

	global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";





	$output->print_footer("12_dbchanges_post1");
}

function upgrade12_dbchanges_post1()

	$output->print_footer("12_dbchanges_post1");
}

function upgrade12_dbchanges_post1()

{
global $db, $output, $mybb;


{
global $db, $output, $mybb;


	$output->print_header("Performing Queries");


	$output->print_header("Performing Queries");


	echo "<p>Performing necessary upgrade queries..</p>";	

	echo "<p>Performing necessary upgrade queries..</p>";

	echo "<p>Adding index to posts table ... ";
flush();

	echo "<p>Adding index to posts table ... ";
flush();

	



	// This will take a LONG time on huge post databases, so we only run it isolted from most of the other queries
$db->write_query("ALTER TABLE ".TABLE_PREFIX."posts ADD INDEX ( `visible` )");

	// This will take a LONG time on huge post databases, so we only run it isolted from most of the other queries
$db->write_query("ALTER TABLE ".TABLE_PREFIX."posts ADD INDEX ( `visible` )");

	



	echo "done.</p>";
flush();

	echo "done.</p>";
flush();

	



	$contents = "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);


	$contents = "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);


Zeile 247Zeile 247
function upgrade12_dbchanges_post2()
{
global $db, $output, $mybb;

function upgrade12_dbchanges_post2()
{
global $db, $output, $mybb;





	$output->print_header("Performing Queries");

	$output->print_header("Performing Queries");





	echo "<p>Performing necessary upgrade queries..</p>";

	echo "<p>Performing necessary upgrade queries..</p>";

	



	if($db->field_exists('longipaddress', "posts"))
{
echo "<p>Dropping longipaddress column in posts table ... ";
flush();

	if($db->field_exists('longipaddress', "posts"))
{
echo "<p>Dropping longipaddress column in posts table ... ";
flush();

	



		$db->write_query("ALTER TABLE ".TABLE_PREFIX."posts DROP longipaddress;");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."posts DROP longipaddress;");

		



		echo "done.</p>";
flush();
}

		echo "done.</p>";
flush();
}

	



	echo "<p>Adding longipaddress column to posts table ... ";
flush();

	echo "<p>Adding longipaddress column to posts table ... ";
flush();

	



	$db->write_query("ALTER TABLE ".TABLE_PREFIX."posts ADD longipaddress int(11) NOT NULL default '0' AFTER ipaddress");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."posts ADD longipaddress int(11) NOT NULL default '0' AFTER ipaddress");

	



	echo "done.</p>";
flush();

	echo "done.</p>";
flush();

	



	$contents = "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);


	$contents = "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);


Zeile 286Zeile 286

$output->print_header("Performing Queries");



$output->print_header("Performing Queries");


	echo "<p>Performing necessary upgrade queries..</p>";	

	echo "<p>Performing necessary upgrade queries..</p>";

	echo "<p>Adding index to users table ... ";
flush();

	echo "<p>Adding index to users table ... ";
flush();

	



	// This will take a LONG time on huge user databases, so we only run it isolted from most of the other queries
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD INDEX ( `lastvisit` )");
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD INDEX ( `regdate` )");

	// This will take a LONG time on huge user databases, so we only run it isolted from most of the other queries
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD INDEX ( `lastvisit` )");
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD INDEX ( `regdate` )");

	



	echo "done.</p>";
flush();

	echo "done.</p>";
flush();

	



	$contents = "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);


	$contents = "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);


Zeile 305Zeile 305

$output->print_footer("12_dbchanges2");
}


$output->print_footer("12_dbchanges2");
}





function upgrade12_dbchanges2()
{
global $db, $output, $mybb;

$output->print_header("Performing Queries");

function upgrade12_dbchanges2()
{
global $db, $output, $mybb;

$output->print_header("Performing Queries");





	echo "<p>Performing necessary upgrade queries..</p>";
flush();

	echo "<p>Performing necessary upgrade queries..</p>";
flush();

	



	if($db->field_exists('recipients', "privatemessages"))

	if($db->field_exists('recipients', "privatemessages"))

	{

	{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages DROP recipients;");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages DROP recipients;");

	}	

	}

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages ADD recipients text NOT NULL AFTER fromid");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages ADD recipients text NOT NULL AFTER fromid");

	



	if($db->field_exists('deletetime', "privatemessages"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages DROP deletetime;");

	if($db->field_exists('deletetime', "privatemessages"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages DROP deletetime;");

	}

	}

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages ADD deletetime bigint(30) NOT NULL default '0' AFTER dateline");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages ADD deletetime bigint(30) NOT NULL default '0' AFTER dateline");

		



	if($db->field_exists('maxpmrecipients', "usergroups"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP maxpmrecipients;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD maxpmrecipients int(4) NOT NULL default '5' AFTER pmquota");

	if($db->field_exists('maxpmrecipients', "usergroups"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP maxpmrecipients;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD maxpmrecipients int(4) NOT NULL default '5' AFTER pmquota");





	if($db->field_exists('canwarnusers', "usergroups"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP canwarnusers;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD canwarnusers int(1) NOT NULL default '0' AFTER cancustomtitle");

	if($db->field_exists('canwarnusers', "usergroups"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP canwarnusers;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD canwarnusers int(1) NOT NULL default '0' AFTER cancustomtitle");

	



	if($db->field_exists('lastip', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP lastip;");

	if($db->field_exists('lastip', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP lastip;");

	}

	}

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD lastip varchar(50) NOT NULL default '' AFTER regip");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD lastip varchar(50) NOT NULL default '' AFTER regip");







if($db->field_exists('coppauser', "users"))



if($db->field_exists('coppauser', "users"))

Zeile 352Zeile 352
		$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP coppauser;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD coppauser int(1) NOT NULL default '0'");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP coppauser;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD coppauser int(1) NOT NULL default '0'");

	



	if($db->field_exists('classicpostbit', 'users'))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP classicpostbit;");

	if($db->field_exists('classicpostbit', 'users'))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP classicpostbit;");

Zeile 364Zeile 364
		$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP canreceivewarnings;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD canreceivewarnings int(1) NOT NULL default '0' AFTER canwarnusers");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP canreceivewarnings;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD canreceivewarnings int(1) NOT NULL default '0' AFTER canwarnusers");

	



	if($db->field_exists('maxwarningsday', "usergroups"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP maxwarningsday;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD maxwarningsday int(3) NOT NULL default '3' AFTER canreceivewarnings");

	if($db->field_exists('maxwarningsday', "usergroups"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP maxwarningsday;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD maxwarningsday int(3) NOT NULL default '3' AFTER canreceivewarnings");

	



	$db->update_query("usergroups", array('canreceivewarnings' => 1), "cancp != 1");
$db->update_query("usergroups", array('maxwarningsday' => 3, 'canwarnusers' => 1), "cancp=1 OR issupermod=1 OR gid=6"); // Admins, Super Mods and Mods


	$db->update_query("usergroups", array('canreceivewarnings' => 1), "cancp != 1");
$db->update_query("usergroups", array('maxwarningsday' => 3, 'canwarnusers' => 1), "cancp=1 OR issupermod=1 OR gid=6"); // Admins, Super Mods and Mods


Zeile 385Zeile 385
	{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP newpms;");
}

	{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP newpms;");
}

	



	if($db->field_exists('keywords', "searchlog"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."searchlog DROP keywords;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."searchlog ADD keywords text NOT NULL AFTER querycache");

	if($db->field_exists('keywords', "searchlog"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."searchlog DROP keywords;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."searchlog ADD keywords text NOT NULL AFTER querycache");

	



	if($db->field_exists('canaddpublicevents', "usergroups") && !$db->field_exists('canaddevents', "usergroups"))
{
$db->update_query("usergroups", array('canaddpublicevents' => 0), "canaddpublicevents='no'");
$db->update_query("usergroups", array('canaddpublicevents' => 1), "canaddpublicevents='yes'");
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups CHANGE canaddpublicevents canaddevents int(1) NOT NULL default '0';");
}

	if($db->field_exists('canaddpublicevents', "usergroups") && !$db->field_exists('canaddevents', "usergroups"))
{
$db->update_query("usergroups", array('canaddpublicevents' => 0), "canaddpublicevents='no'");
$db->update_query("usergroups", array('canaddpublicevents' => 1), "canaddpublicevents='yes'");
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups CHANGE canaddpublicevents canaddevents int(1) NOT NULL default '0';");
}

	



	if($db->field_exists('canaddprivateevents', "usergroups"))

	if($db->field_exists('canaddprivateevents', "usergroups"))

	{

	{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP canaddprivateevents;");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP canaddprivateevents;");

	}


	}


	if($db->field_exists('canbypasseventmod', "usergroups"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP canbypasseventmod;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD canbypasseventmod int(1) NOT NULL default '0' AFTER canaddevents;");

	if($db->field_exists('canbypasseventmod', "usergroups"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP canbypasseventmod;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD canbypasseventmod int(1) NOT NULL default '0' AFTER canaddevents;");

	



	if($db->field_exists('canmoderateevents', "usergroups"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP canmoderateevents;");

	if($db->field_exists('canmoderateevents', "usergroups"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP canmoderateevents;");

Zeile 419Zeile 419
	$db->update_query("usergroups", array('canbypasseventmod' => 0, 'canmoderateevents' => 0), "cancp=0 AND issupermod=0");
$db->update_query("usergroups", array('canaddevents' => 0), "gid='1'");


	$db->update_query("usergroups", array('canbypasseventmod' => 0, 'canmoderateevents' => 0), "cancp=0 AND issupermod=0");
$db->update_query("usergroups", array('canaddevents' => 0), "gid='1'");


	$db->drop_table("maillogs");	

	$db->drop_table("maillogs");

	$db->drop_table("mailerrors");
$db->drop_table("promotions");
$db->drop_table("promotionlogs");
$db->drop_table("massemails");

	$db->drop_table("mailerrors");
$db->drop_table("promotions");
$db->drop_table("promotionlogs");
$db->drop_table("massemails");

	



	$collation = $db->build_create_table_collation();

$db->write_query("CREATE TABLE ".TABLE_PREFIX."massemails (

	$collation = $db->build_create_table_collation();

$db->write_query("CREATE TABLE ".TABLE_PREFIX."massemails (

Zeile 444Zeile 444
		perpage smallint(4) NOT NULL default '50',
PRIMARY KEY(mid)
) ENGINE=MyISAM{$collation};");

		perpage smallint(4) NOT NULL default '50',
PRIMARY KEY(mid)
) ENGINE=MyISAM{$collation};");

	



	$db->write_query("CREATE TABLE ".TABLE_PREFIX."maillogs (
mid int unsigned NOT NULL auto_increment,
subject varchar(200) not null default '',

	$db->write_query("CREATE TABLE ".TABLE_PREFIX."maillogs (
mid int unsigned NOT NULL auto_increment,
subject varchar(200) not null default '',

Zeile 471Zeile 471
		smtpcode int(5) NOT NULL default '0',
PRIMARY KEY(eid)
) ENGINE=MyISAM{$collation};");

		smtpcode int(5) NOT NULL default '0',
PRIMARY KEY(eid)
) ENGINE=MyISAM{$collation};");

	



	$db->write_query("CREATE TABLE ".TABLE_PREFIX."promotions (
pid int unsigned NOT NULL auto_increment,
title varchar(120) NOT NULL default '',

	$db->write_query("CREATE TABLE ".TABLE_PREFIX."promotions (
pid int unsigned NOT NULL auto_increment,
title varchar(120) NOT NULL default '',

Zeile 490Zeile 490
		usergrouptype varchar(120) NOT NULL default '0',
PRIMARY KEY (pid)
) ENGINE=MyISAM{$collation};");

		usergrouptype varchar(120) NOT NULL default '0',
PRIMARY KEY (pid)
) ENGINE=MyISAM{$collation};");

	



	$db->write_query("CREATE TABLE ".TABLE_PREFIX."promotionlogs(
plid int unsigned NOT NULL auto_increment,
pid int unsigned NOT NULL default '0',

	$db->write_query("CREATE TABLE ".TABLE_PREFIX."promotionlogs(
plid int unsigned NOT NULL auto_increment,
pid int unsigned NOT NULL default '0',

Zeile 507Zeile 507
		$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP maxemails;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD maxemails int(3) NOT NULL default '5' AFTER cansendemail");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP maxemails;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD maxemails int(3) NOT NULL default '5' AFTER cansendemail");

	



	if($db->field_exists('parseorder', "mycode"))

	if($db->field_exists('parseorder', "mycode"))

	{

	{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."mycode DROP parseorder;");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."mycode DROP parseorder;");

	}

	}

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."mycode ADD parseorder smallint unsigned NOT NULL default '0' AFTER active");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."mycode ADD parseorder smallint unsigned NOT NULL default '0' AFTER active");

	



	if($db->field_exists('mod_edit_posts', "forums"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."forums DROP mod_edit_posts;");

	if($db->field_exists('mod_edit_posts', "forums"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."forums DROP mod_edit_posts;");

Zeile 524Zeile 524
	{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users CHANGE pmpopup pmnotice int(1) NOT NULL default '0'");
}

	{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users CHANGE pmpopup pmnotice int(1) NOT NULL default '0'");
}

	



	$db->drop_table("tasks");
$db->drop_table("tasklog");


	$db->drop_table("tasks");
$db->drop_table("tasklog");


Zeile 588Zeile 588
	{
$db->write_query("RENAME TABLE ".TABLE_PREFIX."favorites TO ".TABLE_PREFIX."threadsubscriptions");
}

	{
$db->write_query("RENAME TABLE ".TABLE_PREFIX."favorites TO ".TABLE_PREFIX."threadsubscriptions");
}

	



	if($db->field_exists('fid', "threadsubscriptions"))

	if($db->field_exists('fid', "threadsubscriptions"))

	{

	{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions CHANGE fid sid int unsigned NOT NULL auto_increment");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions CHANGE fid sid int unsigned NOT NULL auto_increment");

	}


	}


	if($db->field_exists('type', "threadsubscriptions"))

	if($db->field_exists('type', "threadsubscriptions"))

	{

	{

		$db->update_query("threadsubscriptions", array('type' => 0), "type='f'");
$db->update_query("threadsubscriptions", array('type' => 1), "type='s'");
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions CHANGE type notification int(1) NOT NULL default '0'");

		$db->update_query("threadsubscriptions", array('type' => 0), "type='f'");
$db->update_query("threadsubscriptions", array('type' => 1), "type='s'");
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions CHANGE type notification int(1) NOT NULL default '0'");

	}


	}


	if($db->field_exists('dateline', "threadsubscriptions"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions DROP dateline;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions ADD dateline bigint(30) NOT NULL default '0'");

	if($db->field_exists('dateline', "threadsubscriptions"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions DROP dateline;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions ADD dateline bigint(30) NOT NULL default '0'");

		



	if($db->field_exists('subscriptionkey', "threadsubscriptions"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions DROP subscriptionkey;");

	if($db->field_exists('subscriptionkey', "threadsubscriptions"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions DROP subscriptionkey;");

Zeile 620Zeile 620
		$db->update_query("users", array('emailnotify' => 0), "emailnotify != 1 AND emailnotify != 2");
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users CHANGE emailnotify subscriptionmethod int(1) NOT NULL default '0'");
}

		$db->update_query("users", array('emailnotify' => 0), "emailnotify != 1 AND emailnotify != 2");
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users CHANGE emailnotify subscriptionmethod int(1) NOT NULL default '0'");
}

	



	$db->drop_table("warninglevels");
$db->drop_table("warningtypes");
$db->drop_table("warnings");

	$db->drop_table("warninglevels");
$db->drop_table("warningtypes");
$db->drop_table("warnings");

Zeile 634Zeile 634

$db->write_query("CREATE TABLE ".TABLE_PREFIX."warningtypes (
tid int unsigned NOT NULL auto_increment,


$db->write_query("CREATE TABLE ".TABLE_PREFIX."warningtypes (
tid int unsigned NOT NULL auto_increment,

		title varchar(120) NOT NULL default '',
points int unsigned NOT NULL default '0',

		title varchar(120) NOT NULL default '',
points int unsigned NOT NULL default '0',

		expirationtime bigint(30) NOT NULL default '0',
PRIMARY KEY(tid)
) ENGINE=MyISAM{$collation};");

		expirationtime bigint(30) NOT NULL default '0',
PRIMARY KEY(tid)
) ENGINE=MyISAM{$collation};");

Zeile 656Zeile 656
		revokereason text NOT NULL,
notes text NOT NULL,
PRIMARY KEY(wid)

		revokereason text NOT NULL,
notes text NOT NULL,
PRIMARY KEY(wid)

	) ENGINE=MyISAM{$collation};");

	) ENGINE=MyISAM{$collation};");


if($db->field_exists('warningpoints', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP warningpoints;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD warningpoints int(3) NOT NULL default '0' AFTER unreadpms");


if($db->field_exists('warningpoints', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP warningpoints;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD warningpoints int(3) NOT NULL default '0' AFTER unreadpms");

	



	if($db->field_exists('moderateposts', "users"))

	if($db->field_exists('moderateposts', "users"))

	{

	{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP moderateposts;");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP moderateposts;");

	}

	}

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD moderateposts int(1) NOT NULL default '0' AFTER warningpoints");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD moderateposts int(1) NOT NULL default '0' AFTER warningpoints");

	



	if($db->field_exists('moderationtime', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP moderationtime;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD moderationtime bigint(30) NOT NULL default '0' AFTER moderateposts");

	if($db->field_exists('moderationtime', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP moderationtime;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD moderationtime bigint(30) NOT NULL default '0' AFTER moderateposts");

	



	if($db->field_exists('suspendposting', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP suspendposting;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD suspendposting int(1) NOT NULL default '0' AFTER moderationtime");

	if($db->field_exists('suspendposting', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP suspendposting;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD suspendposting int(1) NOT NULL default '0' AFTER moderationtime");

	



	if($db->field_exists('suspensiontime', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP suspensiontime;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD suspensiontime bigint(30) NOT NULL default '0' AFTER suspendposting");

	if($db->field_exists('suspensiontime', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP suspensiontime;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD suspensiontime bigint(30) NOT NULL default '0' AFTER suspendposting");

	



	$db->write_query("ALTER TABLE ".TABLE_PREFIX."banned CHANGE oldadditionalgroups oldadditionalgroups TEXT NOT NULL");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."banned CHANGE oldadditionalgroups oldadditionalgroups TEXT NOT NULL");

	
if($db->field_exists('birthdayprivacy', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP birthdayprivacy;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD birthdayprivacy varchar(4) NOT NULL default 'all' AFTER birthday");










	if($db->field_exists('birthdayprivacy', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP birthdayprivacy;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD birthdayprivacy varchar(4) NOT NULL default 'all' AFTER birthday");

	if($db->field_exists('birthdayprivacy', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP birthdayprivacy;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD birthdayprivacy varchar(4) NOT NULL default 'all' AFTER birthday");

	








if($db->field_exists('birthdayprivacy', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP birthdayprivacy;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD birthdayprivacy varchar(4) NOT NULL default 'all' AFTER birthday");


	if($db->field_exists('longregip', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP longregip;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD longregip int(11) NOT NULL default '0' AFTER lastip");

	if($db->field_exists('longregip', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP longregip;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD longregip int(11) NOT NULL default '0' AFTER lastip");

	



	if($db->field_exists('longlastip', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP longlastip;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD longlastip int(11) NOT NULL default '0' AFTER lastip");

	if($db->field_exists('longlastip', "users"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP longlastip;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD longlastip int(11) NOT NULL default '0' AFTER lastip");

	



	// Unused column
if($db->field_exists('titles', "searchlog"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."searchlog DROP titles;");
}

	// Unused column
if($db->field_exists('titles', "searchlog"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."searchlog DROP titles;");
}





	$db->drop_table("adminlog");
$db->write_query("CREATE TABLE ".TABLE_PREFIX."adminlog (
uid int unsigned NOT NULL default '0',

	$db->drop_table("adminlog");
$db->write_query("CREATE TABLE ".TABLE_PREFIX."adminlog (
uid int unsigned NOT NULL default '0',

Zeile 730Zeile 730
	  data text NOT NULL,
KEY module (module, action)
) ENGINE=MyISAM{$collation};");

	  data text NOT NULL,
KEY module (module, action)
) ENGINE=MyISAM{$collation};");

	



	if($db->field_exists('data', "adminsessions"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."adminsessions DROP data;");
}

	if($db->field_exists('data', "adminsessions"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."adminsessions DROP data;");
}

	



	$db->write_query("ALTER TABLE ".TABLE_PREFIX."adminsessions ADD data TEXT NOT NULL AFTER lastactive;");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."adminsessions ADD data TEXT NOT NULL AFTER lastactive;");

	



	if($db->field_exists('isdefault', "settings"))

	if($db->field_exists('isdefault', "settings"))

	{

	{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."settings DROP isdefault;");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."settings DROP isdefault;");

	}

	}

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."settings ADD isdefault int(1) NOT NULL default '0' AFTER gid;");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."settings ADD isdefault int(1) NOT NULL default '0' AFTER gid;");

	



	$setting_group_cache = array();
$query = $db->simple_select("settinggroups", "gid, isdefault");
while($settinggroup = $db->fetch_array($query))
{
$setting_group_cache[$settinggroup['gid']] = $settinggroup['isdefault'];
}

	$setting_group_cache = array();
$query = $db->simple_select("settinggroups", "gid, isdefault");
while($settinggroup = $db->fetch_array($query))
{
$setting_group_cache[$settinggroup['gid']] = $settinggroup['isdefault'];
}

	



	$query = $db->simple_select("settings", "gid, sid");
while($setting = $db->fetch_array($query))
{

	$query = $db->simple_select("settings", "gid, sid");
while($setting = $db->fetch_array($query))
{

Zeile 759Zeile 759
			$db->update_query("settings", array('isdefault' => 1), "sid = '{$setting['sid']}'", 1);
}
}

			$db->update_query("settings", array('isdefault' => 1), "sid = '{$setting['sid']}'", 1);
}
}

	



	$db->update_query("settings", array('value' => 'classic'), "name='postlayout' AND value != 'horizontal'");

	$db->update_query("settings", array('value' => 'classic'), "name='postlayout' AND value != 'horizontal'");

	



	$db->update_query("settings", array('optionscode' => $db->escape_string('php
<select name=\"upsetting[{$setting[\'name\']}]\"><option value=\"standard\">".($lang->setting_searchtype_standard?$lang->setting_searchtype_standard:"Standard")."</option>".($db->supports_fulltext("threads") && $db->supports_fulltext_boolean("posts")?"<option value=\"fulltext\"".($setting[\'value\']=="fulltext"?" selected=\"selected\"":"").">".($lang->setting_searchtype_fulltext?$lang->setting_searchtype_fulltext:"Full Text")."</option>":"")."</select>')), "name='searchtype'", 1);

	$db->update_query("settings", array('optionscode' => $db->escape_string('php
<select name=\"upsetting[{$setting[\'name\']}]\"><option value=\"standard\">".($lang->setting_searchtype_standard?$lang->setting_searchtype_standard:"Standard")."</option>".($db->supports_fulltext("threads") && $db->supports_fulltext_boolean("posts")?"<option value=\"fulltext\"".($setting[\'value\']=="fulltext"?" selected=\"selected\"":"").">".($lang->setting_searchtype_fulltext?$lang->setting_searchtype_fulltext:"Full Text")."</option>":"")."</select>')), "name='searchtype'", 1);

	



	$contents = "Done</p>";
$contents .= "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);

	$contents = "Done</p>";
$contents .= "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);

	



	global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";

	global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";

	



	$output->print_footer("12_dbchanges3");
}


	$output->print_footer("12_dbchanges3");
}


Zeile 779Zeile 779
{
global $db, $output, $mybb;


{
global $db, $output, $mybb;


	$output->print_header("Converting Ban Filters");


	$output->print_header("Converting Ban Filters");


	echo "<p>Converting existing banned IP addresses, email addresses and usernames..</p>";
flush();

	echo "<p>Converting existing banned IP addresses, email addresses and usernames..</p>";
flush();

	



	$db->drop_table("banfilters");

	$db->drop_table("banfilters");

	



	$collation = $db->build_create_table_collation();

	$collation = $db->build_create_table_collation();

	



	$db->write_query("CREATE TABLE ".TABLE_PREFIX."banfilters (
fid int unsigned NOT NULL auto_increment,
filter varchar(200) NOT NULL default '',

	$db->write_query("CREATE TABLE ".TABLE_PREFIX."banfilters (
fid int unsigned NOT NULL auto_increment,
filter varchar(200) NOT NULL default '',

Zeile 803Zeile 803
	{
// Some people put spaces or breaks (\r\n) instead, so we should take that into account.
$mybb->settings[$type] = str_replace(array("\n", "\r\n", "\r"), ",", $mybb->settings[$type]);

	{
// Some people put spaces or breaks (\r\n) instead, so we should take that into account.
$mybb->settings[$type] = str_replace(array("\n", "\r\n", "\r"), ",", $mybb->settings[$type]);

		



		// Usernames can have spaces so don't replace those with commas.
if($type != 'bannedusernames')
{
$mybb->settings[$type] = str_replace(" ", ",", $mybb->settings[$type]);
}

		// Usernames can have spaces so don't replace those with commas.
if($type != 'bannedusernames')
{
$mybb->settings[$type] = str_replace(" ", ",", $mybb->settings[$type]);
}

		



		$bans = explode(",", $mybb->settings[$type]);
$bans = array_unique($bans);
$bans = array_map("trim", $bans);
foreach($bans as $ban)
{
if(!$ban)

		$bans = explode(",", $mybb->settings[$type]);
$bans = array_unique($bans);
$bans = array_map("trim", $bans);
foreach($bans as $ban)
{
if(!$ban)

			{

			{

				continue;
}

				continue;
}

			



			if($type == "bannedips")
{
$ban_type = 1;

			if($type == "bannedips")
{
$ban_type = 1;

Zeile 859Zeile 859

echo "<p>Performing necessary upgrade queries..</p>";
flush();


echo "<p>Performing necessary upgrade queries..</p>";
flush();

	



	$db->drop_table("spiders");
$db->drop_table("stats");

	$db->drop_table("spiders");
$db->drop_table("stats");

	



	$collation = $db->build_create_table_collation();

$db->write_query("CREATE TABLE ".TABLE_PREFIX."spiders (

	$collation = $db->build_create_table_collation();

$db->write_query("CREATE TABLE ".TABLE_PREFIX."spiders (

Zeile 874Zeile 874
		useragent varchar(200) NOT NULL default '',
lastvisit bigint(30) NOT NULL default '0',
PRIMARY KEY(sid)

		useragent varchar(200) NOT NULL default '',
lastvisit bigint(30) NOT NULL default '0',
PRIMARY KEY(sid)

	) ENGINE=MyISAM{$collation};");


	) ENGINE=MyISAM{$collation};");


	$db->write_query("CREATE TABLE ".TABLE_PREFIX."stats (
dateline bigint(30) NOT NULL default '0',
numusers int unsigned NOT NULL default '0',

	$db->write_query("CREATE TABLE ".TABLE_PREFIX."stats (
dateline bigint(30) NOT NULL default '0',
numusers int unsigned NOT NULL default '0',

Zeile 906Zeile 906
	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD dstcorrection INT(1) NOT NULL default '0' AFTER dst");

$db->update_query("users", array('dstcorrection' => 2));

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD dstcorrection INT(1) NOT NULL default '0' AFTER dst");

$db->update_query("users", array('dstcorrection' => 2));

	



	$db->update_query("adminoptions", array('cpstyle' => ''));

	$db->update_query("adminoptions", array('cpstyle' => ''));

	



	if($db->field_exists('permsset', "adminoptions") && !$db->field_exists('permissions', "adminoptions"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions CHANGE permsset permissions TEXT NOT NULL ");
}

	if($db->field_exists('permsset', "adminoptions") && !$db->field_exists('permissions', "adminoptions"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions CHANGE permsset permissions TEXT NOT NULL ");
}

	



	$adminoptions = file_get_contents(INSTALL_ROOT.'resources/adminoptions.xml');
$parser = new XMLParser($adminoptions);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();

	$adminoptions = file_get_contents(INSTALL_ROOT.'resources/adminoptions.xml');
$parser = new XMLParser($adminoptions);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();

	



	// Fetch default permissions list
$default_permissions = array();
foreach($tree['adminoptions'][0]['user'] as $users)

	// Fetch default permissions list
$default_permissions = array();
foreach($tree['adminoptions'][0]['user'] as $users)

Zeile 936Zeile 936
			break;
}
}

			break;
}
}

	



	$convert_permissions = array(
"caneditsettings" => array(
"module" => "config",
"permission" => "settings"
),
"caneditann" => array(

	$convert_permissions = array(
"caneditsettings" => array(
"module" => "config",
"permission" => "settings"
),
"caneditann" => array(

				"module" => "forum",

				"module" => "forum",

				"permission" => "announcements",
),
"caneditforums" => array(

				"permission" => "announcements",
),
"caneditforums" => array(

				"module" => "forum",

				"module" => "forum",

				"permission" => "management",
),
"canmodposts" => array(
"module" => "forum",
"permission" => "moderation_queue",

				"permission" => "management",
),
"canmodposts" => array(
"module" => "forum",
"permission" => "moderation_queue",

			),

			),

		"caneditsmilies" => array(
"module" => "config",
"permission" => "smilies",

		"caneditsmilies" => array(
"module" => "config",
"permission" => "smilies",

			),

			),

		"caneditpicons" => array(
"module" => "config",
"permission" => "post_icons",
),
"caneditthemes" => array(

		"caneditpicons" => array(
"module" => "config",
"permission" => "post_icons",
),
"caneditthemes" => array(

				"module" => "style",

				"module" => "style",

				"permission" => "themes",
),
"canedittemps" => array(

				"permission" => "themes",
),
"canedittemps" => array(

Zeile 1015Zeile 1015
				"permission" => "backupdb",
),
);

				"permission" => "backupdb",
),
);

	



	$new_permissions = $default_permissions;

	$new_permissions = $default_permissions;

	



	$query = $db->simple_select("adminoptions");
while($adminoption = $db->fetch_array($query))

	$query = $db->simple_select("adminoptions");
while($adminoption = $db->fetch_array($query))

	{

	{

		foreach($adminoption as $field => $value)
{
if(strtolower(substr($field, 0, 3)) != "can")

		foreach($adminoption as $field => $value)
{
if(strtolower(substr($field, 0, 3)) != "can")

			{

			{

				continue;
}

				continue;
}

			



			if(array_key_exists($field, $convert_permissions))
{
// Note: old adminoptions table is still yes/no - do not change me
if($value == "yes")

			if(array_key_exists($field, $convert_permissions))
{
// Note: old adminoptions table is still yes/no - do not change me
if($value == "yes")

				{

				{

					$value = 1;
}
else

					$value = 1;
}
else

Zeile 1042Zeile 1042
				$new_permissions[$convert_permissions[$field]['module']][$convert_permissions[$field]['permission']] = $value;
}
}

				$new_permissions[$convert_permissions[$field]['module']][$convert_permissions[$field]['permission']] = $value;
}
}

		



		$db->update_query("adminoptions", array('permissions' => serialize($new_permissions)), "uid = '{$adminoption['uid']}'");

		$db->update_query("adminoptions", array('permissions' => serialize($new_permissions)), "uid = '{$adminoption['uid']}'");

		



		$new_permissions = $default_permissions;
}

foreach($convert_permissions as $field => $value)
{
if($db->field_exists($field, "adminoptions"))

		$new_permissions = $default_permissions;
}

foreach($convert_permissions as $field => $value)
{
if($db->field_exists($field, "adminoptions"))

		{

		{

			$db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions DROP {$field}");
}
}

			$db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions DROP {$field}");
}
}

	



	// Set default views
if($db->field_exists('defaultviews', "adminoptions"))
{

	// Set default views
if($db->field_exists('defaultviews', "adminoptions"))
{

Zeile 1063Zeile 1063
	}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions ADD defaultviews TEXT NOT NULL");
$db->update_query("adminoptions", array('defaultviews' => serialize(array('user' => 1))));

	}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions ADD defaultviews TEXT NOT NULL");
$db->update_query("adminoptions", array('defaultviews' => serialize(array('user' => 1))));





	require_once MYBB_ROOT."inc/functions_rebuild.php";
rebuild_stats();

	require_once MYBB_ROOT."inc/functions_rebuild.php";
rebuild_stats();





	$contents = "Done</p>";
$contents .= "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);

	$contents = "Done</p>";
$contents .= "<p>Click next to continue with the upgrade process.</p>";
$output->print_contents($contents);





	global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";

	global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";





	$output->print_footer("12_dbchanges5");
}


	$output->print_footer("12_dbchanges5");
}


Zeile 1081Zeile 1081
{
global $db, $output, $mybb;


{
global $db, $output, $mybb;


	$output->print_header("Performing Queries");


	$output->print_header("Performing Queries");


	echo "<p>Performing necessary upgrade queries..</p>";
flush();

	echo "<p>Performing necessary upgrade queries..</p>";
flush();

	



	$db->drop_table("templategroups");
$db->write_query("CREATE TABLE ".TABLE_PREFIX."templategroups (
gid int unsigned NOT NULL auto_increment,

	$db->drop_table("templategroups");
$db->write_query("CREATE TABLE ".TABLE_PREFIX."templategroups (
gid int unsigned NOT NULL auto_increment,

Zeile 1093Zeile 1093
		title varchar(100) NOT NULL default '',
PRIMARY KEY (gid)
) ENGINE=MyISAM{$collation};");

		title varchar(100) NOT NULL default '',
PRIMARY KEY (gid)
) ENGINE=MyISAM{$collation};");

	



	$db->write_query("INSERT INTO ".TABLE_PREFIX."templategroups (gid,prefix,title) VALUES ('1','calendar','<lang:group_calendar>');");
$db->write_query("INSERT INTO ".TABLE_PREFIX."templategroups (gid,prefix,title) VALUES ('2','editpost','<lang:group_editpost>');");
$db->write_query("INSERT INTO ".TABLE_PREFIX."templategroups (gid,prefix,title) VALUES ('3','forumbit','<lang:group_forumbit>');");

	$db->write_query("INSERT INTO ".TABLE_PREFIX."templategroups (gid,prefix,title) VALUES ('1','calendar','<lang:group_calendar>');");
$db->write_query("INSERT INTO ".TABLE_PREFIX."templategroups (gid,prefix,title) VALUES ('2','editpost','<lang:group_editpost>');");
$db->write_query("INSERT INTO ".TABLE_PREFIX."templategroups (gid,prefix,title) VALUES ('3','forumbit','<lang:group_forumbit>');");

Zeile 1154Zeile 1154
		$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages DROP statustime;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages ADD statustime bigint(30) NOT NULL default '0' AFTER status");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages DROP statustime;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages ADD statustime bigint(30) NOT NULL default '0' AFTER status");

	



	$collation = $db->build_create_table_collation();

	$collation = $db->build_create_table_collation();

	



	$db->drop_table("calendars");
$db->drop_table("calendarpermissions");
$db->drop_table("forumsread");
$db->drop_table("adminviews");
$db->drop_table("threadviews");

	$db->drop_table("calendars");
$db->drop_table("calendarpermissions");
$db->drop_table("forumsread");
$db->drop_table("adminviews");
$db->drop_table("threadviews");

	



	$db->write_query("CREATE TABLE ".TABLE_PREFIX."threadviews (
tid int unsigned NOT NULL default '0'
) ENGINE=MyISAM{$collation};");

	$db->write_query("CREATE TABLE ".TABLE_PREFIX."threadviews (
tid int unsigned NOT NULL default '0'
) ENGINE=MyISAM{$collation};");

Zeile 1251Zeile 1251
		if($view['conditions'][0]['condition'])
{
foreach($view['conditions'][0]['condition'] as $condition)

		if($view['conditions'][0]['condition'])
{
foreach($view['conditions'][0]['condition'] as $condition)

			{

			{

				if(!$condition['value']) continue;
if($condition['attributes']['is_serialized'] == 1)
{

				if(!$condition['value']) continue;
if($condition['attributes']['is_serialized'] == 1)
{

Zeile 1275Zeile 1275
		$db->insert_query("adminviews", $new_view);
$view_count++;
}

		$db->insert_query("adminviews", $new_view);
$view_count++;
}

	



	$avatardimensions = str_replace('x', '|', my_strtolower($mybb->settings['postmaxavatarsize']));

	$avatardimensions = str_replace('x', '|', my_strtolower($mybb->settings['postmaxavatarsize']));

	



	$db->simple_select("users", "uid", "avatar != '' AND avatardimensions = ''");
while($user = $db->fetch_array($query))
{

	$db->simple_select("users", "uid", "avatar != '' AND avatardimensions = ''");
while($user = $db->fetch_array($query))
{

Zeile 1297Zeile 1297
function upgrade12_redoconfig()
{
global $db, $output, $orig_config, $mybb;

function upgrade12_redoconfig()
{
global $db, $output, $orig_config, $mybb;

	



	$config = $orig_config;

	$config = $orig_config;

	



	$output->print_header("Rewriting config.php");

	$output->print_header("Rewriting config.php");





	if(!is_array($config['database']))
{
// Backup our old Config file
@copy(MYBB_ROOT."inc/config.php", MYBB_ROOT."inc/config.backup.php");

	if(!is_array($config['database']))
{
// Backup our old Config file
@copy(MYBB_ROOT."inc/config.php", MYBB_ROOT."inc/config.backup.php");

		



		$fh = @fopen(MYBB_ROOT."inc/config.php", "w");
if(!$fh)
{

		$fh = @fopen(MYBB_ROOT."inc/config.php", "w");
if(!$fh)
{

Zeile 1319Zeile 1319
		{
$config['memcache_host'] = "localhost";
}

		{
$config['memcache_host'] = "localhost";
}

		



		if(!$config['memcache_port'])

		if(!$config['memcache_port'])

		{

		{

			$config['memcache_port'] = 11211;

			$config['memcache_port'] = 11211;

		}


		}


		$comment = "";

		$comment = "";

		



		if(!$db->db_encoding || !$config['db_encoding'])

		if(!$db->db_encoding || !$config['db_encoding'])

		{

		{

			$comment = " // ";

			$comment = " // ";

		}


		}


		if(!$config['db_encoding'])
{
$config['db_encoding'] = "utf8";
}

		if(!$config['db_encoding'])
{
$config['db_encoding'] = "utf8";
}

		





		$configdata = "<?php
/**
* Database configuration
*

		$configdata = "<?php
/**
* Database configuration
*

 * Please see the MyBB Wiki for advanced

 * Please see the MyBB Docs for advanced

 * database configuration for larger installations

 * database configuration for larger installations

 * http://wiki.mybboard.net/

 * http://docs.mybb.com/

 */

\$config['database']['type'] = '{$config['dbtype']}';

 */

\$config['database']['type'] = '{$config['dbtype']}';

Zeile 1371Zeile 1371
 *  on the front end of the board after
* renaming your Admin CP directory, set this
* to 1.

 *  on the front end of the board after
* renaming your Admin CP directory, set this
* to 1.

 */

\$config['hide_admin_links'] = {$config['hide_admin_links']};

/**

 */

\$config['hide_admin_links'] = {$config['hide_admin_links']};

/**

 * Data-cache configuration
* The data cache is a temporary cache
* of the most commonly accessed data in MyBB.

 * Data-cache configuration
* The data cache is a temporary cache
* of the most commonly accessed data in MyBB.

Zeile 1411Zeile 1411

/**
* Database Encoding


/**
* Database Encoding

 *  If you wish to set an encoding for MyBB uncomment 

 *  If you wish to set an encoding for MyBB uncomment

 *  the line below (if it isn't already) and change
* the current value to the mysql charset:
* http://dev.mysql.com/doc/refman/5.1/en/charset-mysql.html

 *  the line below (if it isn't already) and change
* the current value to the mysql charset:
* http://dev.mysql.com/doc/refman/5.1/en/charset-mysql.html

Zeile 1453Zeile 1453
function upgrade12_dbchanges6()
{
global $db, $output;

function upgrade12_dbchanges6()
{
global $db, $output;

	



	$output->print_header("Post IP Conversion");

if(!$_POST['ipspage'])
{
$ipp = 5000;

	$output->print_header("Post IP Conversion");

if(!$_POST['ipspage'])
{
$ipp = 5000;

	}
else

	}
else

	{
$ipp = $_POST['ipspage'];

	{
$ipp = $_POST['ipspage'];

	}


	}


	if($_POST['ipstart'])
{
$startat = $_POST['ipstart'];

	if($_POST['ipstart'])
{
$startat = $_POST['ipstart'];

Zeile 1476Zeile 1476
		$startat = 0;
$upper = $ipp;
$lower = 1;

		$startat = 0;
$upper = $ipp;
$lower = 1;

	}


	}


	$query = $db->simple_select("posts", "COUNT(pid) AS ipcount");
$cnt = $db->fetch_array($query);

	$query = $db->simple_select("posts", "COUNT(pid) AS ipcount");
$cnt = $db->fetch_array($query);

	



	if($upper > $cnt['ipcount'])
{
$upper = $cnt['ipcount'];

	if($upper > $cnt['ipcount'])
{
$upper = $cnt['ipcount'];

Zeile 1488Zeile 1488

echo "<p>Converting ip {$lower} to {$upper} ({$cnt['ipcount']} Total)</p>";
flush();


echo "<p>Converting ip {$lower} to {$upper} ({$cnt['ipcount']} Total)</p>";
flush();

	
$ipaddress = false;



$ipaddress = false;


	$query = $db->simple_select("posts", "ipaddress, longipaddress, pid", "", array('limit_start' => $lower, 'limit' => $ipp));
while($post = $db->fetch_array($query))

	$query = $db->simple_select("posts", "ipaddress, longipaddress, pid", "", array('limit_start' => $lower, 'limit' => $ipp));
while($post = $db->fetch_array($query))

	{

	{

		// Have we already converted this ip?
if(!$post['longipaddress'])
{

		// Have we already converted this ip?
if(!$post['longipaddress'])
{

Zeile 1501Zeile 1501
		}
$ipaddress = true;
}

		}
$ipaddress = true;
}

	



	$remaining = $upper-$cnt['ipcount'];
if($remaining && $ipaddress)
{

	$remaining = $upper-$cnt['ipcount'];
if($remaining && $ipaddress)
{

Zeile 1513Zeile 1513
	{
$nextact = "12_dbchanges7";
$contents = "<p>Done</p><p>All post ips have been converted to the new ip format. Click next to continue.</p>";

	{
$nextact = "12_dbchanges7";
$contents = "<p>Done</p><p>All post ips have been converted to the new ip format. Click next to continue.</p>";

	}
$output->print_contents($contents);


	}
$output->print_contents($contents);


	global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";

	global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";





	$output->print_footer($nextact);
}

	$output->print_footer($nextact);
}





function upgrade12_dbchanges7()
{
global $db, $output;

function upgrade12_dbchanges7()
{
global $db, $output;

	



	$output->print_header("User IP Conversion");

if(!$_POST['ipspage'])

	$output->print_header("User IP Conversion");

if(!$_POST['ipspage'])

Zeile 1552Zeile 1552

$query = $db->simple_select("users", "COUNT(uid) AS ipcount");
$cnt = $db->fetch_array($query);


$query = $db->simple_select("users", "COUNT(uid) AS ipcount");
$cnt = $db->fetch_array($query);

	



	if($upper > $cnt['ipcount'])
{
$upper = $cnt['ipcount'];
}

	if($upper > $cnt['ipcount'])
{
$upper = $cnt['ipcount'];
}





	$contents .= "<p>Converting ip {$lower} to {$upper} ({$cnt['ipcount']} Total)</p>";

	$contents .= "<p>Converting ip {$lower} to {$upper} ({$cnt['ipcount']} Total)</p>";

	



	$ipaddress = false;
$update_array = array();

	$ipaddress = false;
$update_array = array();

	



	$query = $db->simple_select("users", "regip, lastip, longlastip, longregip, uid", "", array('limit_start' => $lower, 'limit' => $ipp));
while($user = $db->fetch_array($query))
{

	$query = $db->simple_select("users", "regip, lastip, longlastip, longregip, uid", "", array('limit_start' => $lower, 'limit' => $ipp));
while($user = $db->fetch_array($query))
{

Zeile 1571Zeile 1571
		{
$update_array['longregip'] = intval(my_ip2long($user['regip']));
}

		{
$update_array['longregip'] = intval(my_ip2long($user['regip']));
}

		



		if(!$user['longlastip'])
{
$update_array['longlastip'] = intval(my_ip2long($user['lastip']));
}

		if(!$user['longlastip'])
{
$update_array['longlastip'] = intval(my_ip2long($user['lastip']));
}

		



		if(!empty($update_array))
{
$db->update_query("users", $update_array, "uid = '{$user['uid']}'");
}

		if(!empty($update_array))
{
$db->update_query("users", $update_array, "uid = '{$user['uid']}'");
}

		



		$update_array = array();
$ipaddress = true;
}

		$update_array = array();
$ipaddress = true;
}

Zeile 1592Zeile 1592
		$nextact = "12_dbchanges7";
$startat = $startat+$ipp;
$contents .= "<p><input type=\"hidden\" name=\"ipspage\" value=\"$ipp\" /><input type=\"hidden\" name=\"ipstart\" value=\"$startat\" />Done. Click Next to move on to the next set of user ips.</p>";

		$nextact = "12_dbchanges7";
$startat = $startat+$ipp;
$contents .= "<p><input type=\"hidden\" name=\"ipspage\" value=\"$ipp\" /><input type=\"hidden\" name=\"ipstart\" value=\"$startat\" />Done. Click Next to move on to the next set of user ips.</p>";

	}
else

	}
else

	{
$nextact = "12_dbchanges8";
$contents .= "<p>Done</p><p>All user ips have been converted to the new ip format. Click next to continue.</p>";
}
$output->print_contents($contents);

	{
$nextact = "12_dbchanges8";
$contents .= "<p>Done</p><p>All user ips have been converted to the new ip format. Click next to continue.</p>";
}
$output->print_contents($contents);





	global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";


	global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";


	$output->print_footer($nextact);	

	$output->print_footer($nextact);

}

function upgrade12_dbchanges8()

}

function upgrade12_dbchanges8()

Zeile 1636Zeile 1636

$query = $db->simple_select("events", "COUNT(eid) AS eventcount");
$cnt = $db->fetch_array($query);


$query = $db->simple_select("events", "COUNT(eid) AS eventcount");
$cnt = $db->fetch_array($query);

	



	if($upper > $cnt['eventcount'])
{
$upper = $cnt['eventcount'];
}

$contents .= "<p>Converting events {$lower} to {$upper} ({$cnt['eventcount']} Total)</p>";

	if($upper > $cnt['eventcount'])
{
$upper = $cnt['eventcount'];
}

$contents .= "<p>Converting events {$lower} to {$upper} ({$cnt['eventcount']} Total)</p>";

	



	// Just started - add fields
if(!$db->field_exists("donecon", "events"))
{
// Add temporary column
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events ADD donecon smallint(1) NOT NULL;");

	// Just started - add fields
if(!$db->field_exists("donecon", "events"))
{
// Add temporary column
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events ADD donecon smallint(1) NOT NULL;");

		



		if($db->field_exists('cid', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP cid;");
}

		if($db->field_exists('cid', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP cid;");
}

		



		if($db->field_exists('visible', "events"))

		if($db->field_exists('visible', "events"))

		{

		{

			$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP visible;");
}

			$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP visible;");
}

		



		if($db->field_exists('dateline', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP dateline;");
}

		if($db->field_exists('dateline', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP dateline;");
}

		



		if($db->field_exists('starttime', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP starttime;");
}

		if($db->field_exists('starttime', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP starttime;");
}

		



		if($db->field_exists('endtime', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP endtime;");
}

		if($db->field_exists('endtime', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP endtime;");
}

		



		if($db->field_exists('timezone', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP timezone;");
}

		if($db->field_exists('timezone', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP timezone;");
}

		



		if($db->field_exists('ignoretimezone', "events"))

		if($db->field_exists('ignoretimezone', "events"))

		{

		{

			$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP ignoretimezone;");
}

			$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP ignoretimezone;");
}

		



		if($db->field_exists('usingtime', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP usingtime;");
}

		if($db->field_exists('usingtime', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP usingtime;");
}

		



		if($db->field_exists('repeats', "events"))

		if($db->field_exists('repeats', "events"))

		{

		{

			$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP repeats;");

			$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP repeats;");

		}

// Got structural changes?

		}

// Got structural changes?

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."events ADD cid int unsigned NOT NULL default '0' AFTER eid");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."events ADD cid int unsigned NOT NULL default '0' AFTER eid");

		



		if($db->field_exists('author', "events") && !$db->field_exists('uid', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events CHANGE author uid int unsigned NOT NULL default '0'");
}

		if($db->field_exists('author', "events") && !$db->field_exists('uid', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events CHANGE author uid int unsigned NOT NULL default '0'");
}

		



		if($db->field_exists('subject', "events") && !$db->field_exists('name', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events CHANGE subject name varchar(120) NOT NULL default ''");

		if($db->field_exists('subject', "events") && !$db->field_exists('name', "events"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events CHANGE subject name varchar(120) NOT NULL default ''");

Zeile 1737Zeile 1737
			);
$db->update_query("events", $updated_event, "eid='{$event['eid']}'", 1);
}

			);
$db->update_query("events", $updated_event, "eid='{$event['eid']}'", 1);
}

		



		$date = true;

		$date = true;

	}
else
{

	}
else
{

		$date = false;
}

		$date = false;
}

	



	$query = $db->simple_select("events", "COUNT(eid) AS remaining", "donecon!=1");

	$query = $db->simple_select("events", "COUNT(eid) AS remaining", "donecon!=1");

	$remaining = $db->fetch_field($query, "remaining");	

	$remaining = $db->fetch_field($query, "remaining");

	if($remaining && $date)
{
$nextact = "12_dbchanges8";

	if($remaining && $date)
{
$nextact = "12_dbchanges8";

Zeile 1767Zeile 1767

global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";


global $footer_extra;
$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>";





	$output->print_footer($nextact);
}

	$output->print_footer($nextact);
}





function upgrade12_redothemes()
{
global $db, $output, $config, $mybb;

function upgrade12_redothemes()
{
global $db, $output, $config, $mybb;

	



	$output->print_header("Converting themes");

if(!@is_dir(MYBB_ROOT.'cache/'))
{
@mkdir(MYBB_ROOT.'cache/', 077);

	$output->print_header("Converting themes");

if(!@is_dir(MYBB_ROOT.'cache/'))
{
@mkdir(MYBB_ROOT.'cache/', 077);

		



		// Add in empty index.html!
$fp = @fopen(MYBB_ROOT."cache/index.html", "w");
@fwrite($fp, "");

		// Add in empty index.html!
$fp = @fopen(MYBB_ROOT."cache/index.html", "w");
@fwrite($fp, "");

Zeile 1806Zeile 1806
		$output->print_footer("12_redothemes");
exit;
}

		$output->print_footer("12_redothemes");
exit;
}

	



	$not_writable = false;
if(!@is_dir(MYBB_ROOT.'cache/themes/'))
{
@mkdir(MYBB_ROOT.'cache/themes/', 077);

	$not_writable = false;
if(!@is_dir(MYBB_ROOT.'cache/themes/'))
{
@mkdir(MYBB_ROOT.'cache/themes/', 077);

		



		// Add in empty index.html!
$fp = @fopen(MYBB_ROOT."cache/themes/index.html", "w");
@fwrite($fp, "");

		// Add in empty index.html!
$fp = @fopen(MYBB_ROOT."cache/themes/index.html", "w");
@fwrite($fp, "");

Zeile 1830Zeile 1830
	  	@my_chmod(MYBB_ROOT.'cache/themes/test.write', '0777');
@unlink(MYBB_ROOT.'cache/themes/test.write');
}

	  	@my_chmod(MYBB_ROOT.'cache/themes/test.write', '0777');
@unlink(MYBB_ROOT.'cache/themes/test.write');
}

	



	if($not_writable)
{
echo "<p><span style=\"color: red; font-weight: bold;\">Unable to write to the cache/themes/ directory.</span><br />Before the upgrade process can continue you need to make sure this directory exists and is writable (chmod 777)</p>";
$output->print_footer("12_redothemes");
exit;

	if($not_writable)
{
echo "<p><span style=\"color: red; font-weight: bold;\">Unable to write to the cache/themes/ directory.</span><br />Before the upgrade process can continue you need to make sure this directory exists and is writable (chmod 777)</p>";
$output->print_footer("12_redothemes");
exit;

	}


	}


	if($db->field_exists('themebits', "themes") && !$db->field_exists('properties', "themes"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes CHANGE themebits properties text NOT NULL");
}

	if($db->field_exists('themebits', "themes") && !$db->field_exists('properties', "themes"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes CHANGE themebits properties text NOT NULL");
}

	



	if($db->field_exists('cssbits', "themes"))

	if($db->field_exists('cssbits', "themes"))

	{

	{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP cssbits");
}

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP cssbits");
}

	



	if($db->field_exists('csscached', "themes"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP csscached");

	if($db->field_exists('csscached', "themes"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP csscached");

	}


	}


	if($db->field_exists('stylesheets', "themes"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP stylesheets");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes ADD stylesheets text NOT NULL AFTER properties");

	if($db->field_exists('stylesheets', "themes"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP stylesheets");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes ADD stylesheets text NOT NULL AFTER properties");

	



	if($db->table_exists("themestylesheets"))
{
$db->drop_table("themestylesheets");

	if($db->table_exists("themestylesheets"))
{
$db->drop_table("themestylesheets");

Zeile 1901Zeile 1901
	$master_theme = $db->fetch_array($query);

$master_stylesheets = unserialize($master_theme['stylesheets']);

	$master_theme = $db->fetch_array($query);

$master_stylesheets = unserialize($master_theme['stylesheets']);

	



	if(is_array($master_stylesheets))
{
// Note: 1.4 only ships with one global|global stylesheet

	if(is_array($master_stylesheets))
{
// Note: 1.4 only ships with one global|global stylesheet

Zeile 1915Zeile 1915
					{
continue; // Skip global
}

					{
continue; // Skip global
}

					



					$default_stylesheets[$location][$action][] = $stylesheet;
$default_stylesheets['inherited']["{$location}_{$action}"][$stylesheet] = 1; // This stylesheet is inherited from the master
}
}
}
}

					$default_stylesheets[$location][$action][] = $stylesheet;
$default_stylesheets['inherited']["{$location}_{$action}"][$stylesheet] = 1; // This stylesheet is inherited from the master
}
}
}
}

	



	$query = $db->simple_select("themes");
while($theme = $db->fetch_array($query))
{

	$query = $db->simple_select("themes");
while($theme = $db->fetch_array($query))
{

Zeile 1930Zeile 1930
		{
continue;
}

		{
continue;
}

		



		$theme['css'] .= "\n\n".$theme['extracss'];

		$theme['css'] .= "\n\n".$theme['extracss'];

		



		$theme['css'] = upgrade_css_120_to_140($theme['css']);

		$theme['css'] = upgrade_css_120_to_140($theme['css']);

		





		// Create stylesheets
$cache_file = cache_stylesheet($theme['tid'], "global.css", $theme['css']);


		// Create stylesheets
$cache_file = cache_stylesheet($theme['tid'], "global.css", $theme['css']);


Zeile 1963Zeile 1963
		// Update the theme
$db->update_query("themes", array("stylesheets" => $db->escape_string(serialize($stylesheets))), "tid='{$theme['tid']}'");
}

		// Update the theme
$db->update_query("themes", array("stylesheets" => $db->escape_string(serialize($stylesheets))), "tid='{$theme['tid']}'");
}

	



	if($db->field_exists('css', "themes"))

	if($db->field_exists('css', "themes"))

	{

	{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP css");

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP css");

	}


	}


	if($db->field_exists('extracss', "themes"))

	if($db->field_exists('extracss', "themes"))

	{

	{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP extracss");
}

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP extracss");
}

	



	// We need to replace this for our themes css to show up
// <link rel="stylesheet" type="text/css" href="{$theme['css_url']}" /> must be present in the old template (it usually is)
$query = $db->simple_select("templates", "tid,template", "title='headerinclude'");
while($template = $db->fetch_array($query))
{
$template['template'] = str_replace('<link rel="stylesheet" type="text/css" href="{$theme[\'css_url\']}" />', '{$stylesheets}', $template['template']);

	// We need to replace this for our themes css to show up
// <link rel="stylesheet" type="text/css" href="{$theme['css_url']}" /> must be present in the old template (it usually is)
$query = $db->simple_select("templates", "tid,template", "title='headerinclude'");
while($template = $db->fetch_array($query))
{
$template['template'] = str_replace('<link rel="stylesheet" type="text/css" href="{$theme[\'css_url\']}" />', '{$stylesheets}', $template['template']);

		



		$db->update_query("templates", array('template' => $db->escape_string($template['template'])), "tid='{$template['tid']}'");
}


		$db->update_query("templates", array('template' => $db->escape_string($template['template'])), "tid='{$template['tid']}'");
}