<?php

/*
+--------------------------------------------------------------------------
|   IPB NULL EN
|   ========================================
|   by IPB NULL EN
|   (c) 2001 - 2004 IPB NULL EN
|   http://ipb-null.narod.ru/
|   ========================================
|   Web: http://www.ipb-null.narod.ru
|   Email: ipb-null@ya.ru
|   Licence Info: http://ipb-null.narod.ru/
+---------------------------------------------------------------------------
|
|   > IPB UPGRADE MODULE:: IPB 2.0.2 -> IPB 2.0.3
|   > Script written by Matt Mecham
|   > Date started: 23rd April 2004
|   > "So what, pop is dead - it's no great loss.
	   So many facelifts, it's face flew off"
+--------------------------------------------------------------------------
*/

if ( ! defined( 'IN_IPB' ) )
{
	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
	exit();
}

class version_upgrade
{
	var $install;
	
	/*-------------------------------------------------------------------------*/
	// CONSTRUCTOR
	/*-------------------------------------------------------------------------*/
	
	function version_upgrade( & $install )
	{
		$this->install = & $install;
	}
	
	/*-------------------------------------------------------------------------*/
	// Auto run..
	/*-------------------------------------------------------------------------*/

	function auto_run()
	{
		if( !defined( 'SQL_DRIVER' ) )
		{
			define( 'SQL_DRIVER', $this->install->saved_data['sql_driver'] );
		}
		
		if( !defined('CACHE_PATH') )
		{
			define( 'CACHE_PATH', ROOT_PATH );
		}
		
		//-----------------------------------------
		// Skip for safe_mode peeps
		//-----------------------------------------
		
		$safe_mode = @ini_get("safe_mode") ? 1 : 0;
		
		if( $safe_mode )
		{
			$this->install->message = "We detected that safe mode is enabled on your server.  Skipping IPB NULL EN Pro skin insertion...";
			return true;
		}
		
		require_once( ROOT_PATH . 'sources/api/api_skins.php' );
		$api = new api_skins();
		$api->ipsclass =& $this->install->ipsclass;
		
		if( !function_exists('gzopen') )
		{
			$this->install->error = "You must have zlib support in your PHP installation to be able to import skins.  The new default IPB NULL EN Pro Skin has not been imported";
			return true;
		}
		
		if( !$this->install->saved_data['didskin'] )
		{
			$api->skin_add_set( ROOT_PATH . 'resources/ipb_skin-pro.xml.gz' );
			$this->install->saved_data['didskin'] = 1;
			$this->install->message = "IPB NULL EN Pro skin templates inserted";
			return false;
		}
		else
		{
			$id = $this->install->ipsclass->DB->build_and_exec_query( array( 'select' => 'set_skin_set_id', 'from' => 'skin_sets', 'where' => "set_key='IPB NULL EN_pro'" ) );
			
			$api->images_add_set( ROOT_PATH . 'resources/ipb_images-pro.xml.gz', $id['set_skin_set_id'] );
			
			unset($this->install->saved_data['didskin']);
			$this->install->message = "IPB NULL EN Pro skin images inserted";
		}
		
		return true;
	}
	
}
	
	
?>