Vergleich install/resources/upgrade12.php - 1.6.1 - 1.6.14

  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 5016 2010-06-12 00:24:02Z RyanGordon $

 * $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 ... ";

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

	flush();


	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 314Zeile 314

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


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

	



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

	if($db->field_exists('recipients', "privatemessages"))
{
$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"))

	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 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");

		$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;");

Zeile 348Zeile 348


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



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

	{

	{

		$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;");

	}

	}

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

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

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

if($db->field_exists('canreceivewarnings', "usergroups"))
{
$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 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

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

	$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

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

	}

	}

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD canmodcp int(1) NOT NULL default '0' AFTER maxwarningsday");
$db->update_query("usergroups", array('canmodcp' => 1), "cancp=1 OR issupermod=1 OR gid='6'"); // Admins, Super Mods and Mods

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

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD canmodcp int(1) NOT NULL default '0' AFTER maxwarningsday");
$db->update_query("usergroups", array('canmodcp' => 1), "cancp=1 OR issupermod=1 OR gid='6'"); // Admins, Super Mods and Mods

if($db->field_exists('newpms', "users"))
{
$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;");

	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;");

	$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 443Zeile 443
		conditions text NOT NULL,
perpage smallint(4) NOT NULL default '50',
PRIMARY KEY(mid)

		conditions text NOT NULL,
perpage smallint(4) NOT NULL default '50',
PRIMARY KEY(mid)

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


	) 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 457Zeile 457
		tid int unsigned NOT NULL default '0',
ipaddress varchar(20) NOT NULL default '',
PRIMARY KEY(mid)

		tid int unsigned NOT NULL default '0',
ipaddress varchar(20) NOT NULL default '',
PRIMARY KEY(mid)

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

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


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


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

Zeile 465Zeile 465
		message TEXT NOT NULL,
toaddress varchar(150) NOT NULL default '',
fromaddress varchar(150) NOT NULL default '',

		message TEXT NOT NULL,
toaddress varchar(150) NOT NULL default '',
fromaddress varchar(150) NOT NULL default '',

		dateline bigint(30) NOT NULL default '0',

		dateline bigint(30) NOT NULL default '0',

		error text NOT NULL,
smtperror varchar(200) NOT NULL default '',
smtpcode int(5) NOT NULL default '0',
PRIMARY KEY(eid)

		error text NOT NULL,
smtperror varchar(200) NOT NULL default '',
smtpcode int(5) NOT NULL default '0',
PRIMARY KEY(eid)

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


 	) 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 489Zeile 489
		newusergroup smallint unsigned NOT NULL default '0',
usergrouptype varchar(120) NOT NULL default '0',
PRIMARY KEY (pid)

		newusergroup smallint unsigned NOT NULL default '0',
usergrouptype varchar(120) NOT NULL default '0',
PRIMARY KEY (pid)

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


	) 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 500Zeile 500
		dateline bigint(30) NOT NULL default '0',
type varchar(9) NOT NULL default 'primary',
PRIMARY KEY(plid)

		dateline bigint(30) NOT NULL default '0',
type varchar(9) NOT NULL default 'primary',
PRIMARY KEY(plid)

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

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


if($db->field_exists('maxemails', "usergroups"))
{
$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('maxemails', "usergroups"))
{
$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 544Zeile 544
		logging int(1) NOT NULL default '0',
locked bigint(30) NOT NULL default '0',
PRIMARY KEY(tid)

		logging int(1) NOT NULL default '0',
locked bigint(30) NOT NULL default '0',
PRIMARY KEY(tid)

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

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



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



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

Zeile 553Zeile 553
		dateline bigint(30) NOT NULL default '0',
data text NOT NULL,
PRIMARY KEY(lid)

		dateline bigint(30) NOT NULL default '0',
data text NOT NULL,
PRIMARY KEY(lid)

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

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



include_once MYBB_ROOT."inc/functions_task.php";



include_once MYBB_ROOT."inc/functions_task.php";

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"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions CHANGE fid sid int unsigned NOT NULL auto_increment");
}

	if($db->field_exists('fid', "threadsubscriptions"))
{
$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;");

	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'");

	$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;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions ADD subscriptionkey varchar(32) NOT NULL default ''");

	if($db->field_exists('subscriptionkey', "threadsubscriptions"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions DROP subscriptionkey;");
}
$db->write_query("ALTER TABLE ".TABLE_PREFIX."threadsubscriptions ADD subscriptionkey varchar(32) NOT NULL default ''");





	if($db->field_exists('emailnotify', "users"))
{
$db->update_query("users", array('emailnotify' => 0), "emailnotify='no' OR emailnotify='0'");

	if($db->field_exists('emailnotify', "users"))
{
$db->update_query("users", array('emailnotify' => 0), "emailnotify='no' OR emailnotify='0'");

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");





	$db->write_query("CREATE TABLE ".TABLE_PREFIX."warninglevels (
lid int unsigned NOT NULL auto_increment,
percentage int(3) NOT NULL default '0',
action text NOT NULL,
PRIMARY KEY(lid)

	$db->write_query("CREATE TABLE ".TABLE_PREFIX."warninglevels (
lid int unsigned NOT NULL auto_increment,
percentage int(3) NOT NULL default '0',
action text NOT NULL,
PRIMARY KEY(lid)

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

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


$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)

		expirationtime bigint(30) NOT NULL default '0',
PRIMARY KEY(tid)

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

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


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


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

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)

	) TYPE=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"))
{
$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");

	if($db->field_exists('moderateposts', "users"))
{
$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");

	



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

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

	{

	{

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

		$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");

	$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"))

	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."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"))

	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");

		$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"))

	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");

		$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 729Zeile 729
	  action varchar(50) NOT NULL default '',
data text NOT NULL,
KEY module (module, action)

	  action varchar(50) NOT NULL default '',
data text NOT NULL,
KEY module (module, action)

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


	) 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");
}





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

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

Zeile 783Zeile 783

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 795Zeile 795
	  lastuse bigint(30) NOT NULL default '0',
dateline bigint(30) NOT NULL default '0',
PRIMARY KEY (fid)

	  lastuse bigint(30) NOT NULL default '0',
dateline bigint(30) NOT NULL default '0',
PRIMARY KEY (fid)

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

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


// Now we convert all of the old bans in to the new system!
$ban_types = array('bannedips', 'bannedemails', 'bannedusernames');


// Now we convert all of the old bans in to the new system!
$ban_types = array('bannedips', 'bannedemails', 'bannedusernames');

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);

		$bans = explode(",", $mybb->settings[$type]);
$bans = array_unique($bans);
$bans = array_map("trim", $bans);

Zeile 819Zeile 819
			{
continue;
}

			{
continue;
}

			



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

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

			{

			{

				$ban_type = 2;
}
else if($type == "bannedemails")
{
$ban_type = 3;

				$ban_type = 2;
}
else if($type == "bannedemails")
{
$ban_type = 3;

			}

			}

			$new_ban = array(
"filter" => $db->escape_string($ban),
"type" => $ban_type,

			$new_ban = array(
"filter" => $db->escape_string($ban),
"type" => $ban_type,

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();


$collation = $db->build_create_table_collation();


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


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

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)

	) TYPE=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',
numthreads int unsigned NOT NULL default '0',
numposts int unsigned NOT NULL default '0',
PRIMARY KEY(dateline)

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

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

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


$db->insert_query("spiders", array('name' => 'GoogleBot', 'useragent' => 'google'));
$db->insert_query("spiders", array('name' => 'Lycos', 'useragent' => 'lycos'));


$db->insert_query("spiders", array('name' => 'GoogleBot', 'useragent' => 'google'));
$db->insert_query("spiders", array('name' => 'Lycos', 'useragent' => 'lycos'));

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",

	$convert_permissions = array(
"caneditsettings" => array(
"module" => "config",

Zeile 945Zeile 945
		"caneditann" => array(
"module" => "forum",
"permission" => "announcements",

		"caneditann" => array(
"module" => "forum",
"permission" => "announcements",

			),

			),

		"caneditforums" => array(
"module" => "forum",
"permission" => "management",

		"caneditforums" => array(
"module" => "forum",
"permission" => "management",

			),

			),

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

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

				"module" => "config",

				"module" => "config",

				"permission" => "smilies",
),
"caneditpicons" => array(

				"permission" => "smilies",
),
"caneditpicons" => array(

Zeile 965Zeile 965
		"caneditthemes" => array(
"module" => "style",
"permission" => "themes",

		"caneditthemes" => array(
"module" => "style",
"permission" => "themes",

			),

			),

		"canedittemps" => array(
"module" => "style",
"permission" => "templates",
),
"caneditusers" => array(

		"canedittemps" => array(
"module" => "style",
"permission" => "templates",
),
"caneditusers" => array(

				"module" => "user",

				"module" => "user",

				"permission" => "view",
),
"caneditpfields" => array(

				"permission" => "view",
),
"caneditpfields" => array(

				"module" => "config",

				"module" => "config",

				"permission" => "profile_fields",
),
"caneditmodactions" => array(
"module" => "config",
"permission" => "mod_tools",

				"permission" => "profile_fields",
),
"caneditmodactions" => array(
"module" => "config",
"permission" => "mod_tools",

			),

			),

		"caneditugroups" => array(
"module" => "user",
"permission" => "groups",

		"caneditugroups" => array(
"module" => "user",
"permission" => "groups",

Zeile 997Zeile 997
		"caneditattach" => array(
"module" => "forum",
"permission" => "attachments",

		"caneditattach" => array(
"module" => "forum",
"permission" => "attachments",

			),

			),

		"canedithelp" => array(
"module" => "config",
"permission" => "help_documents",

		"canedithelp" => array(
"module" => "config",
"permission" => "help_documents",

			),

			),

		"caneditlangs" => array(
"module" => "config",
"permission" => "languages",
),
"canrunmaint" => array(

		"caneditlangs" => array(
"module" => "config",
"permission" => "languages",
),
"canrunmaint" => array(

				"module" => "tools",

				"module" => "tools",

				"permission" => "recount_rebuild",
),
"canrundbtools" => array(

				"permission" => "recount_rebuild",
),
"canrundbtools" => 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))
{
foreach($adminoption as $field => $value)
{
if(strtolower(substr($field, 0, 3)) != "can")

	$query = $db->simple_select("adminoptions");
while($adminoption = $db->fetch_array($query))
{
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;
}


		$new_permissions = $default_permissions;
}


Zeile 1055Zeile 1055
			$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 1085Zeile 1085

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,
prefix varchar(50) NOT NULL default '',
title varchar(100) NOT NULL default '',
PRIMARY KEY (gid)

	$db->drop_table("templategroups");
$db->write_query("CREATE TABLE ".TABLE_PREFIX."templategroups (
gid int unsigned NOT NULL auto_increment,
prefix varchar(50) NOT NULL default '',
title varchar(100) NOT NULL default '',
PRIMARY KEY (gid)

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


		) 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 1141Zeile 1141
		{
$index = $ukey;
break;

		{
$index = $ukey;
break;

		}

		}

	}
if($index)

	}
if($index)

	{

	{

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

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

	}

	}

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD UNIQUE KEY username (username)");

	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD UNIQUE KEY username (username)");





	if($db->field_exists('statustime', "privatemessages"))
{
$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");

	if($db->field_exists('statustime', "privatemessages"))
{
$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'

	$db->write_query("CREATE TABLE ".TABLE_PREFIX."threadviews (
tid int unsigned NOT NULL default '0'

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

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


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


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

Zeile 1180Zeile 1180
	  allowimgcode int(1) NOT NULL default '0',
allowsmilies int(1) NOT NULL default '0',
PRIMARY KEY(cid)

	  allowimgcode int(1) NOT NULL default '0',
allowsmilies int(1) NOT NULL default '0',
PRIMARY KEY(cid)

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

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


$calendar_array = array(
'name' => 'Default Calendar',


$calendar_array = array(
'name' => 'Default Calendar',

Zeile 1203Zeile 1203
	  canaddevents int(1) NOT NULL default '0',
canbypasseventmod int(1) NOT NULL default '0',
canmoderateevents int(1) NOT NULL default '0'

	  canaddevents int(1) NOT NULL default '0',
canbypasseventmod int(1) NOT NULL default '0',
canmoderateevents int(1) NOT NULL default '0'

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

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


$db->write_query("CREATE TABLE ".TABLE_PREFIX."forumsread (
fid int unsigned NOT NULL default '0',


$db->write_query("CREATE TABLE ".TABLE_PREFIX."forumsread (
fid int unsigned NOT NULL default '0',

Zeile 1211Zeile 1211
	  dateline int(10) NOT NULL default '0',
KEY dateline (dateline),
UNIQUE KEY fid (fid,uid)

	  dateline int(10) NOT NULL default '0',
KEY dateline (dateline),
UNIQUE KEY fid (fid,uid)

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

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


if($db->field_exists('dateuploaded', "attachments"))
{


if($db->field_exists('dateuploaded', "attachments"))
{

Zeile 1232Zeile 1232
		perpage int(4) NOT NULL default '0',
view_type varchar(6) NOT NULL default '',
PRIMARY KEY(vid)

		perpage int(4) NOT NULL default '0',
view_type varchar(6) NOT NULL default '',
PRIMARY KEY(vid)

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

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


$views = file_get_contents(INSTALL_ROOT.'resources/adminviews.xml');
$parser = new XMLParser($views);


$views = file_get_contents(INSTALL_ROOT.'resources/adminviews.xml');
$parser = new XMLParser($views);

Zeile 1258Zeile 1258
					$condition['value'] = unserialize($condition['value']);
}
$conditions[$condition['attributes']['name']] = $condition['value'];

					$condition['value'] = unserialize($condition['value']);
}
$conditions[$condition['attributes']['name']] = $condition['value'];

			}

			}

		}
$new_view = array(
"uid" => 0,

		}
$new_view = array(
"uid" => 0,

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 1287Zeile 1287
	$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>";

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

	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_redoconfig");
}





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 1405Zeile 1405
 *  be edited, deleted or banned in the Admin CP.
* The administrator permissions for these users
* cannot be altered either.

 *  be edited, deleted or banned in the Admin CP.
* The administrator permissions for these users
* cannot be altered either.

 */

 */


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

/**
* Database Encoding


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

/**
* 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'])

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

if(!$_POST['ipspage'])

	{

	{

		$ipp = 5000;

		$ipp = 5000;

	}
else
{

	}
else
{

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


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


Zeile 1480Zeile 1480

$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'];
}





	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))
{

Zeile 1501Zeile 1501
		}
$ipaddress = true;
}

		}
$ipaddress = true;
}

	



	$remaining = $upper-$cnt['ipcount'];
if($remaining && $ipaddress)
{
$nextact = "12_dbchanges6";
$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 post ips.</p>";

	$remaining = $upper-$cnt['ipcount'];
if($remaining && $ipaddress)
{
$nextact = "12_dbchanges6";
$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 post ips.</p>";

	}

	}

	else
{
$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);

	else
{
$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);





	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);
}

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

	$output->print_footer($nextact);
}

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

	



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

if(!$_POST['ipspage'])

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

if(!$_POST['ipspage'])

	{

	{

		$ipp = 5000;
}

		$ipp = 5000;
}

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


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


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

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

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'])

		if(!$user['longlastip'])

		{

		{

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

			$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;
}

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

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

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

	{

	{

		$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
{
$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);

	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);





	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 1615Zeile 1615
	if(!$_POST['eventspage'])
{
$epp = 50;

	if(!$_POST['eventspage'])
{
$epp = 50;

	}
else

	}
else

	{
$epp = $_POST['eventspage'];

	{
$epp = $_POST['eventspage'];

	}


	}


	if($_POST['eventstart'])
{
$startat = $_POST['eventstart'];
$upper = $startat+$epp;
$lower = $startat;

	if($_POST['eventstart'])
{
$startat = $_POST['eventstart'];
$upper = $startat+$epp;
$lower = $startat;

	}

	}

	else
{
$startat = 0;
$upper = $epp;
$lower = 1;

	else
{
$startat = 0;
$upper = $epp;
$lower = 1;

	}

	}


$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"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP visible;");

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

		}


		}


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

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

		{

		{

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

			$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"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP ignoretimezone;");
}

		if($db->field_exists('ignoretimezone', "events"))
{
$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"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."events DROP repeats;");

		if($db->field_exists('repeats', "events"))
{
$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;
}
else
{
$date = false;
}

		$date = true;
}
else
{
$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 1774Zeile 1774
function upgrade12_redothemes()
{
global $db, $output, $config, $mybb;

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

	



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

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





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

	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, "");
@fclose($fp);

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

	}

	}

	$cachewritable = @fopen(MYBB_ROOT.'cache/test.write', 'w');
if(!$cachewritable)

	$cachewritable = @fopen(MYBB_ROOT.'cache/test.write', 'w');
if(!$cachewritable)

	{

	{

		$not_writable = true;

		$not_writable = true;

		@fclose($cachewritable);
}

		@fclose($cachewritable);
}

	else
{
@fclose($cachewritable);
@my_chmod(MYBB_ROOT.'cache', '0777');
@my_chmod(MYBB_ROOT.'cache/test.write', '0777');
@unlink(MYBB_ROOT.'cache/test.write');

	else
{
@fclose($cachewritable);
@my_chmod(MYBB_ROOT.'cache', '0777');
@my_chmod(MYBB_ROOT.'cache/test.write', '0777');
@unlink(MYBB_ROOT.'cache/test.write');

	}

if($not_writable)
{

	}

if($not_writable)
{

		echo "<p><span style=\"color: red; font-weight: bold;\">Unable to write to the cache/ 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;

		echo "<p><span style=\"color: red; font-weight: bold;\">Unable to write to the cache/ 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;

	}


	}


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

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

	{

	{

		@mkdir(MYBB_ROOT.'cache/themes/', 077);

		@mkdir(MYBB_ROOT.'cache/themes/', 077);

		



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

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

	}

	}

	$themewritable = @fopen(MYBB_ROOT.'cache/themes/test.write', 'w');
if(!$themewritable)
{

	$themewritable = @fopen(MYBB_ROOT.'cache/themes/test.write', 'w');
if(!$themewritable)
{

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

	  	@my_chmod(MYBB_ROOT.'cache/themes', '0777');
@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"))
{
$db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP cssbits");

	if($db->field_exists('cssbits', "themes"))
{
$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");

	}

	}


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


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

Zeile 1873Zeile 1873
		cachefile varchar(100) NOT NULL default '',
lastmodified bigint(30) NOT NULL default '0',
PRIMARY KEY(sid)

		cachefile varchar(100) NOT NULL default '',
lastmodified bigint(30) NOT NULL default '0',
PRIMARY KEY(sid)

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

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


// Define our default stylesheets - MyBB 1.4 contains additional stylesheets that our converted themes will also need
$contents = @file_get_contents(INSTALL_ROOT.'resources/mybb_theme.xml');


// Define our default stylesheets - MyBB 1.4 contains additional stylesheets that our converted themes will also need
$contents = @file_get_contents(INSTALL_ROOT.'resources/mybb_theme.xml');

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']}'");
}