<?php

require("config.php");
require_once(KU_ROOTDIR."inc/functions.php");
require_once(KU_ROOTDIR."inc/encryption.php");

/* Uncomment the line below to show debug information if your upgrade isn't going so well */
//$tc_db->debug = true;

if (isset($_GET['do'])) {
	if ($_GET['do'] == 'insertsql') {
		$tc_db->Execute("ALTER DATABASE `" . KU_DBDATABASE . "` CHARACTER SET utf8 COLLATE utf8_general_ci");
		$tc_db->Execute("ALTER TABLE `" . KU_DBPREFIX . "boards` CHARACTER SET utf8 COLLATE utf8_general_ci");
		
		$results = $tc_db->GetAll("SELECT `name` FROM `" . KU_DBPREFIX . "boards`");
		if (count($results) > 0) {
			$tc_db->Execute("ALTER TABLE `" . KU_DBPREFIX . "posts_" . $line['name'] . "` CHARACTER SET utf8 COLLATE utf8_general_ci");
		}
		
		$tc_db->Execute("ALTER TABLE `" . KU_DBPREFIX . "boards` ADD `anonymous` VARCHAR( 255 ) NOT NULL DEFAULT 'Anonymous' AFTER `redirecttothread` ;");
		$tc_db->Execute("ALTER TABLE `" . KU_DBPREFIX . "passcache` CHANGE `md5` `md5` CHAR( 32 ) NOT NULL");
		
		echo 'SQL inserted.<hr>';
		
		die();
	}
}

echo '<a href="?do=insertsql">Insert upgrade SQL (Step 1)</a>';

?>