Location: PHPKode > projects > Fretsweb > fretsweb-1.2/fretsweb/admin/patch.php
<?php

if($result['version'] != $version)
{
	// For version 0.9 to 1.0
	// Patching is not made for versions lower than 0.9
	if($result['version'] < 1.0)
	{
		$sql = "ALTER TABLE `contest_scores` ADD `stars` INT( 11 ) NOT NULL DEFAULT '1' AFTER `score`";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		$sql = "UPDATE `contest_config` SET `value` = '1.0' WHERE `name` = 'version'";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		// Reload page
		header('location: ' . $_SERVER["PHP_SELF"]);
	}
	
	// For version 1.0 to 1.1
	if($result['version'] == 1.0)
	{
		$sql = "UPDATE `contest_config` SET `value` = '1.1' WHERE `name` = 'version'";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		// Reload page
		header('location: ' . $_SERVER["PHP_SELF"]);
	}
	
	// For version 1.1 to 1.2
	if($result['version'] == 1.1)
	{
		// Alter the score table, time on update can come in handy some time
		$sql = "ALTER TABLE `contest_scores` CHANGE `time` `time` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		$sql = "ALTER TABLE `contest_scores` ADD `notes_hit` INT(11) NOT NULL AFTER `stars`";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		$sql = "ALTER TABLE `contest_scores` ADD `notes_all` INT(11) NOT NULL AFTER `notes_hit`";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		$sql = "ALTER TABLE `contest_scores` ADD `note_streak` INT(11) NOT NULL AFTER `notes_all`";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		$sql = "ALTER TABLE `contest_scores` ADD `original_score` INT(11) NOT NULL AFTER `note_streak`";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		$sql = "ALTER TABLE `contest_scores` ADD `version` VARCHAR(80) NOT NULL AFTER `original_score`";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		$sql = "ALTER TABLE `contest_scores` ADD `score_hash` VARCHAR(80) NOT NULL AFTER `name`";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		// Version update
		$sql = "UPDATE `contest_config` SET `value` = '1.2' WHERE `name` = 'version'";
		mysql_query($sql) or die('Update failed: '.mysql_error());
		
		// Reload page
		header('location: ' . $_SERVER["PHP_SELF"]);
	}
	
}

?>
Return current item: Fretsweb