Location: PHPKode > projects > WB News > install/upgrade.php
<?php

/*========================================================*\
||########################################################||
||#                                                      #||
||#     WB News v2.0.0                                   #||
||# ---------------------------------------------------- #||
||#     Copyright (c) 2004-2008                          #||
||#     Created: 26th September 2005                     #||
||#     Filename: upgrade.php                            #||
||#                                                      #||
||########################################################||
/*========================================================*/

/**
 *  @author $Author: pmcilwaine $
 *	@version $Id: upgrade.php,v 1.5.2.9.2.1 2008/07/14 12:09:24 pmcilwaine Exp $
 */

define( "wbnews", TRUE );
if ( !file_exists("../config.php") )
{
    die( "Upgrade error: <strong>config.php</strong> does not exist" );
}

define( "CLI_UPGRADE", isset($_SERVER["argv"][1]) && "cli-upgrade" == $_SERVER["argv"][1] );

session_start();

$version = "2.0.1";
$supported_versions = array( "2.0.0" );
$aka_versions = array(
	);
require_once "../config.php";

if ( !isset($_SESSION["version_config"]) )
{
	$o_version = $config["version"];
	if ( array_key_exists( $o_version, $aka_versions ) )
	{
		$o_version = $aka_versions[ $o_version ];
	}
	
	$_SESSION["version_config"] = $o_version;
}

if ( !in_array($config['version'], $supported_versions) && (!isset($_SESSION["page"]) || "complete" != $_SESSION["page"]) )
{
    // lets find out why
    if ( $config['version'] == $version )
    {
        die ("Upgrade error: <em>Already have latest version, no need to upgrade</em>");
    }
    else
    {
        die ("Upgrade error: <em>Cannot upgrade due to unknown version</em>");
    }
}

if ( !file_exists("upgrades/upgrade_" . $_SESSION["version_config"] . ".php") )
{
    die ("Upgrade error: <em>Cannot upgrade, cannot find correct upgrade file</em>");
}
else if ( !is_writable("../config.php") )
{
    die ("Upgrade error: <em>Cannot upgrade, please make sure config.php has write permissions</em>");
}

include "upgrades/upgrade_" . $_SESSION["version_config"] . ".php";
exit;

?>
Return current item: WB News