Location: PHPKode > projects > PHPFreeNews > phpfn/Upgrade/Upgrade160164.php
<?php

/*	+--------------------------------------------------------------
	| PHPFreeNews - News Headlines on your website                |
	| Developed by Jim Willsher.                                  |
	| http://www.phpfreenews.co.uk                                |
	+-------------------------------------------------------------+
*/

require('../Config/Config.php');
require('../Inc/Functions.php');

$UpgradeScript = $_SERVER['PHP_SELF'];
$Step = isset($_GET['step']) ? $_GET['step'] : '';
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title><?= $SiteDescription ?> Upgrade Version 1.60 to Version 1.64</title>
			<meta name="Author" content="Jim Willsher">
			<meta name="Keywords" content="PHP, News, Headlines, PHPFreeNews">
			<meta name="Description" content="PHP Free News">
			<link rel="stylesheet" href="../Inc/Styles.css" type="text/css" />
		</head>
		<body>
			<p class="plaintext"><img src="../Inc/Images/<?= $AdminSiteLogo ?>" width="266" height="61"></p>
			<p class="plaintext">


			<?php
			// =============================================================================================================

			if ($Step == '')
			{
				// First Stage
				?>
				Welcome to the Version 1.60 to 1.64 Upgrade Script for <b><?= $SiteDescription ?></b>.<br />
				<br />
				This script will update your database to make it compliant with Version 1.64 of <?= $SiteDescription ?>.
				<br />
				The installer will upgrade database <b>"<?= $db ?>"</b>. Remember to upgrade every database you have.</p>
				<p class="plaintext">It is assumed that you are already running version 1.60, 1.61, 1.62 or 1.63<br />
		    	<br />
		    	The MySql User in your Config.php file must have the following permissions: ALTER.<br />
		    	Once the database has been installed you can safely revoke ALTER.<br />
				<br />
		    	Step 1 of the upgrade will add new fields to the database.<br />
				<br />
				<a href="<?=$UpgradeScript?>?step=1">Perform Upgrade Step 1>></a>
				<?php
			}

			// =============================================================================================================

			elseif ($Step == '1')
			{
				// Set up the tables and indexes...
				echo ('<br />Creating table: news_users_categories...');
				$sql_query = mysql_query("CREATE TABLE news_users_categories (
					UserID MEDIUMINT NOT NULL,
					CatID MEDIUMINT NOT NULL)");
				if ($sql_query)
				{
					echo ('<b> Done!</b>');
				}
				else
				{
					echo mysql_error();
					exit();
				}

				echo ('<br />Creating index: news_users_categories->UserCat');
				$sql_query = mysql_query("ALTER TABLE news_users_categories ADD UNIQUE INDEX UserCat (UserID, CatID) ");
				if ($sql_query)
				{
					echo ('<b> Done!</b>');
				}
				else
				{
					echo mysql_error();
					exit();
				}

				echo ('<br />Creating index: news_users_categories->CatUser');
				$sql_query = mysql_query("ALTER TABLE news_users_categories ADD UNIQUE INDEX CatUser (CatID, UserID)");
				if ($sql_query)
				{
					echo ('<b> Done!</b>');
				}
				else
				{
					echo mysql_error();
					exit();
				}

				// Insert
				echo ('<br />Creating new Audit event...');
				$sql_query = mysql_query("INSERT INTO `news_audit_categories` SET ID=13, CatDesc='Authorised Categories'");
				if ($sql_query)
				{
					echo ('<b> Done!</b>');
				}
				else
				{
					echo mysql_error();
				}

				// ===============================================================================================

				?>
				<br />
				<br />
				If there were no errors generated then the Database tables were updated successfully.<br /><br />
				<br />
				Please now delete this Upgrade script (<?= $_SERVER['PHP_SELF'] ?>) or make it inaccessible.<br />
				Ideally, you should delete the entire Upgrade folder.
				<br />
				<?php
			}
			?>
	    	</p>
		</body>
</html>
Return current item: PHPFreeNews