Location: PHPKode > projects > Utopia News Pro > upgrade/upgrade7.php
<?php
/*
////////////////////////////////////////////////
//             Utopia Software                //
//      http://www.utopiasoftware.net         //
//             Utopia News Pro                //
////////////////////////////////////////////////
*/

/*
	+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
	| Upgrade Script
	| Version - 1.1.5 to 1.2.0
	| Instructions: Upload to Utopia News Pro directory and
	|               run. Immediately remove file from server
	|               after use.
	+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

*/

/* General Config */
$version_current = '1.1.5'; $version_current_pdless = 115;
$version_next = '1.2.0'; $version_next_pdless = 120;

$this_upgrade = 'upgrade7.php';
$next_upgrade = 'upgrade8.php';
/* General Config */

require('functions.inc.php');

// +------------------------------------------------------------------+
// | Step Setup                                                       |
// +------------------------------------------------------------------+
if (isset($_POST['step1']))     // <--Create New Tables
{
	$step = '1';
}
elseif (isset($_POST['step2'])) // <--Update FAQs
{
	$step = '2';
}
elseif (isset($_POST['step3'])) // <--Settings Update
{
	$step = '3';
}
elseif (isset($_POST['step4'])) // <--Table Alteration
{
	$step = '4';
}
elseif (isset($_POST['step5'])) // <--Updating Templates
{
	$step = '5';
}
elseif (isset($_POST['step6'])) // <--Complete
{
	$step = '6';
}
elseif (isset($_GET['action'])) // <--Miscellaneous Actions
{
	$action = $_GET['action'];
	$step = 'X';
}
else							// <--Introduction
{
	$step = '0';
}

// +------------------------------------------------------------------+
// | Global HTML                                                      |
// +------------------------------------------------------------------+
$p_header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<link rel="stylesheet" href="style.css" media="all" />
	<title>Utopia News Pro '.$version_current.' to '.$version_next.' Upgrade</title>
<meta name="generator" content="Utopia News Pro - http://www.utopiasoftware.net/" />
<meta name="robots" content="noindex, nofollow" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>

<center>
<div align="left" class="hbox">
<div class="lbox"><img src="images/unp_logo.jpg" alt="Utopia News Pro" border="0" /></div>
</div></center>
<br />';

$p_openbox = '<center>
<div align="left" class="box">
<font class="normalfont">
<strong>Utopia News Pro Installer - Step '.$step.' of 6</strong><br /><br />';

$p_closebox = '</font></div></center>';

$p_footer = '
<br />
<center>
<div align="center" class="fbox">
<span class="smallfont">
Utopia News Pro Upgrade<br />
Copyright &copy;2003-2007 UtopiaSoft, UtopiaSoftware.net
</span>
</div></center>
</body>
</html>';

// +------------------------------------------------------------------+
// | Step 0 - Introduction                                            |
// +------------------------------------------------------------------+
if ($step == '0')
{
	if (str_strip('.', $version) <= $version_current_pdless)
	{
		unp_msgbox('You are attempting to upgrade from version '.$version_current.' to '.$version_next.', but you are running version '.$version.'.');
		exit;
	}
	echo ($p_header);
	echo ($p_openbox);
	echo 'Welcome to the Utopia News Pro upgrade! The upgrade will first add any new tables that were not present in version '.$version_current.'<br /><br />';
	echo '<form action="'.$this_upgrade.'" method="post"><input type="submit" name="step1" value="Continue -&gt;" /></form>';
	echo ($p_closebox);
	echo ($p_footer);
}

// +------------------------------------------------------------------+
// | Step 1 - Add New Tables                                          |
// +------------------------------------------------------------------+
if ($step == '1')
{
	echo ($p_header);
	echo ($p_openbox);
	echo 'Upgrade is now adding new tables that appear in '.$version_next.'<br /><br />';
	echo 'There are no new tables in this version.';
	echo '<form action="'.$this_upgrade.'" method="post"><input type="submit" name="step2" value="Continue -&gt;" /></form>';
	echo ($p_closebox);
	echo ($p_footer);
}

// +------------------------------------------------------------------+
// | Step 2 - Update FAQs                                             |
// +------------------------------------------------------------------+
if ($step == '2')
{
	echo ($p_header);
	echo ($p_openbox);
	echo 'The upgrade will now update the internal FAQ.<br /><br />';
	echo 'There are no new FAQs in this new version.';
	echo '<form action="'.$this_upgrade.'" method="post"><input type="submit" name="step3" value="Continue -&gt;" /></form>';
	echo ($p_closebox);
	echo ($p_footer);
}

// +------------------------------------------------------------------+
// | Step 3 - Settings Update                                         |
// +------------------------------------------------------------------+
if ($step == '3')
{
	echo ($p_header);
	echo ($p_openbox);
	echo 'Upgrade will now add any settings introduced by features that appear in '.$version_next.'<br /><br />';
	unp_getSettings();
	$DB->query("DELETE FROM `unp_setting`");
	$DB->query("INSERT INTO `unp_setting` (`id`, `display`, `title`, `varname`, `value`, `description`, `optioncode`) VALUES
	(1, 1, 'Site Title', 'sitetitle', '".$sitetitle."', 'Title of the main site where the news is to be posted.', 'text'),
	(2, 2, 'Site URL', 'siteurl', '".$siteurl."', 'The URL to the main site where the news will be displayed. (Requires preceding http://)', 'text'),
	(4, 6, 'UNP Code Allowances', 'unpallowance', '".$unpallowance."', 'Do you wish for UNP code to be enabled in news posts? If you set this to yes, then special UNP codes can be used in news posts to achieve certain HTML affects.', 'yesno'),
	(5, 10, 'News Limit', 'newslimit', '".$newslimit."', 'The maximum number of news items you wish to display on the news page. Do not set this too high for performance reasons.', 'text'),
	(6, 12, 'Automatically Rebuild Cache', 'autocache', '".$autocache."', 'Setting this feature to yes automatically rebuilds the news cache after submitting news, editing news, editing styles, and editing settings. Leaving this feature set to no will force you to manually rebuild the cache.', 'yesno'),
	(7, 18, 'Date Format', 'dateformat', '".$dateformat."', 'This is the format that will be used to display dates throughout Utopia News Pro.<br /><br />Reference: <a href=\"http://www.php.net/manual/en/function.date.php\" target=\"_blank\">http://www.php.net/manual/en/function.date.php</a><br /><br />Example:<br />US Format: (eg. July 3, 1988) - F j, Y<br />European Format: (eg. 3 July 1988) - j F Y', 'text'),
	(8, 19, 'Time Format', 'timeformat', '".$timeformat."', 'This is the format that will be used to display times throughout Utopia News Pro.<br /><br />Reference: <a href=\"http://www.php.net/manual/en/function.date.php\" target=\"_blank\">http://www.php.net/manual/en/function.date.php</a><br /><br />Example:<br />AM/PM Format: (eg. 10:31 PM) - h:i A<br />AM/PM Format With Seconds: (eg. 10:31:22) - h:i:s A<br />24-Hour Format: (eg. 22:31) - H:i<br />24-Hour Format With Seconds: (eg. 22:31:22) - H:i:s', 'text'),
	(9, 4, 'URL to Utopia News Pro Install', 'unpurl', '".$unpurl."', 'The URL to the location where Utopia News Pro is installed. <b>With</b> final slash (/). (Requires preceding http://)', 'text'),
	(10, 5, 'HTML Allowances', 'htmlallowance', '".$htmlallowance."', 'Do you wish for HTML to be enabled in news posts? We <b>strongly</b> advise against the use of HTML. Instead, to achive many common HTML affects, you can use UNP Code tags.', 'yesno'),
	(11, 7, 'Smilies Allowance', 'smiliesallowance', '".$smiliesallowance."', 'Do you wish for smilies to be enabled in news posts? If you set this to yes, smilie codes will automatically be converted into smilies.', 'yesno'),
	(12, 14, 'Comments', 'commentsallowance', '".$commentsallowance."', 'Do you wish for comments to be enabled? Enabling this will allow visitors to your site submit publicly viewable comments to news posts.', 'yesno'),
	(13, 11, 'Headlines Limit', 'headlineslimit', '".$headlineslimit."', 'If you have headlines turned on, this is the maximum number of headlines to display.', 'text'),
	(14, 13, 'Enable Headlines', 'headlinesallowance', '".$headlinesallowance."', 'Do you want to enable headlines? Setting this to No disables the view of headlines.', 'yesno'),
	(15, 17, 'Time Zone', 'timeoffset', '".$timeoffset."', 'What is the timezone in which you want news posts to be dated?', 'timezone'),
	(16, 15, 'Avatar Allowances', 'avatarallowance', '".$avatarallownace."', 'Do you wish for users to be allowed to have avatars (small images displayed on every post a user makes)?', 'yesno'),
	(17, 16, 'Avatar Dimensions', 'avatardimensions', '".$avatardimensions."', 'If you have avatars turned on, this is the maximum height and width, in pixels, of a user''s avatar.', 'text'),
	(18, 3, 'UNP Directory', 'unpdir', '".$unpdir."', 'The directory in which UNP is installed. <b>Format:</b> /directoryname/', 'text'),
	(19, 9, 'Maximum News Length', 'newstruncatelength', '300', 'If you have news truncation enabled, this is the approximate number of <strong>characters</strong> to display before providing a link to read the rest.', 'text'),
	(20, 8, 'Limit News Length', 'newstruncate', '0', 'Do you wish to limit the amount of text each news story will display on your main page? Any text past the limit can be read by clicking a Read More link.', 'yesno')
	");
	echo 'Successfully updated settings!';
	echo '<form action="'.$this_upgrade.'" method="post"><input type="submit" name="step4" value="Continue -&gt;" /></form>';
	echo ($p_closebox);
	echo ($p_footer);
}

// +------------------------------------------------------------------+
// | Step 4 - Table Alteration                                        |
// +------------------------------------------------------------------+
if ($step == '4')
{
	echo ($p_header);
	echo ($p_openbox);
	echo 'Upgrade is now altering any tables that changed between '.$version_current.' and '.$version_next.'<br /><br />';
	echo 'There are no table alterations in this version.';
	echo '<form action="'.$this_upgrade.'" method="post"><input type="submit" name="step5" value="Continue -&gt;" /></form>';
	echo ($p_closebox);
	echo ($p_footer);
}

// +------------------------------------------------------------------+
// | Step 5 - Updating Templates                                      |
// +------------------------------------------------------------------+
if ($step == '5')
{
	// No need to delete old templates
	$insertNewTemplate = $DB->query("INSERT INTO `unp_template` (`setid`, `templatename`, `template`) VALUES (3, 'news_newsbit_readmorelink', '...<br /><br /><a onClick=\'open(\"{\$unpurl}/comments.php?action=list&amp;newsid={\$newsid}\",\"View\",\"width=550, height=580, top=20,left=20,scrollbars=yes, status=no, toolbar=no, menubar=no\")\' href=\"javascript:void(0)\"><font face=\"verdana,arial,helvetica\" size=\"2\" color=\"{\$linkcolor}\">Read More</font></a>')");
	echo ($p_header);
	echo ($p_openbox);
	echo 'Upgrade will now update old '.$version_current.' templates.<br /><br />';
	echo 'All templates updated!';
	echo '<form action="'.$this_upgrade.'" method="post"><input type="submit" name="step6" value="Continue -&gt;" /></form>';
	echo ($p_closebox);
	echo ($p_footer);
}

// +------------------------------------------------------------------+
// | Step 6 - Complete                                                |
// +------------------------------------------------------------------+
if ($step == '6')
{
	echo ($p_header);
	echo ($p_openbox);
	echo 'Congratulations! You have successfully upgraded Utopia News Pro from '.$version_current.' to '.$version_next.'!<br /><br />';
	echo 'Be sure to configure the new settings that were added in this version.</font><br /><br />';
	echo '<font class="highlight">NOTICE:</font> <font class="normalfont">Please <strong>delete</strong> this file once you have finished reading. Leaving this file on the server can pose a <strong>serious</strong> security threat!<br /><br />
	You may now access ';
	if (file_exists($next_upgrade))
	{
		echo 'the next upgrade script <a href="'.$next_upgrade.'">here</a>.';
	}
	else
	{
		echo 'the admin control panel <a href="index.php">here</a>.';
	}
	echo ($p_closebox);
	echo ($p_footer);
}

?>
Return current item: Utopia News Pro