<?php
error_reporting(2039);
set_magic_quotes_runtime(0);
init_wiz();

include_once("../include/version.php");
include_once("../include/functions.php");
include_once("../modules/system/cache/config.php");

//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function init_wiz() {
global $HTTP_COOKIE_VARS, $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_SERVER_VARS, $HTTP_ENV_VARS;

$globals_test = @ini_get('register_globals');
if ( isset($globals_test) && empty($globals_test) ) {
	if ( !empty($HTTP_GET_VARS) )  { extract($HTTP_GET_VARS, EXTR_SKIP);  }
	if ( !empty($HTTP_POST_VARS) ) { extract($HTTP_POST_VARS, EXTR_OVERWRITE); }
	define('_GLOBALS', FALSE);
	} else {
		define('_GLOBALS', TRUE);
	}

define('_PHP_SELF', $HTTP_SERVER_VARS['PHP_SELF']);

!empty($HTTP_SERVER_VARS['HTTP_HOST'])       ? define('_HTTP_HOST'      , $HTTP_SERVER_VARS['HTTP_HOST'])       : define('_HTTP_HOST'      , $HTTP_ENV_VARS['HTTP_HOST']);
!empty($HTTP_SERVER_VARS['QUERY_STRING'])    ? define('_QUERY_STRING'   , $HTTP_SERVER_VARS['QUERY_STRING'])    : define('_QUERY_STRING'   , $HTTP_ENV_VARS['QUERY_STRING']);
!empty($HTTP_SERVER_VARS['SCRIPT_NAME'])     ? define('_SCRIPT_NAME'    , $HTTP_SERVER_VARS['SCRIPT_NAME'])     : define('_SCRIPT_NAME'    , $HTTP_ENV_VARS['SCRIPT_NAME']);
!empty($HTTP_SERVER_VARS['HTTP_REFERER'])    ? define('_HTTP_REFERER'   , $HTTP_SERVER_VARS['HTTP_REFERER'])    : define('_HTTP_REFERER'   , $HTTP_ENV_VARS['HTTP_REFERER']);
!empty($HTTP_SERVER_VARS['REQUEST_METHOD'])  ? define('_REQUEST_METHOD' , $HTTP_SERVER_VARS['REQUEST_METHOD'])  : define('_REQUEST_METHOD' , $HTTP_ENV_VARS['REQUEST_METHOD']);
!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT']) ? define('_HTTP_USER_AGENT', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) : define('_HTTP_USER_AGENT', $HTTP_ENV_VARS['HTTP_USER_AGENT']);

$R_URI = !empty($HTTP_SERVER_VARS['REQUEST_URI']) ? $HTTP_SERVER_VARS['REQUEST_URI'] : $HTTP_ENV_VARS['REQUEST_URI'];
!empty($R_URI) ? define('_REQUEST_URI', $R_URI) : define('_REQUEST_URI', _PHP_SELF._QUERY_STRING);

switch(strtoupper(PHP_OS)) {
	case 'WINDOWS':
	case 'CYGWIN':
	case 'WINNT':
	case 'WIN32':
		define('_OS', 'W');
		break;

	case 'DARWIN':
	case 'OSX':
		define('_OS', 'M');
		break;

	default:
		define('_OS', 'U');
}

$base_path = str_replace('\\', '/', getcwd());
if ( substr($base_path, -1) == '/') {
	$base_path = substr($base_path, 0, -1);
}
define('WIZ_PATH', $base_path);

if ( !defined('XOOPS_ROOT_PATH') &&  XOOPS_ROOT_PATH != '' ) {
	define('XOOPS_ROOT_PATH', preg_replace("/\/_install.*/i", "", WIZ_PATH));
}

$parts = pathinfo(_PHP_SELF);
define('BASE_URL', preg_replace("/\/_install.*/i", "", $parts["dirname"]));

if ( !defined('XOOPS_URL') && XOOPS_URL != '' ) {
	$root_url = "http://" . _HTTP_HOST. preg_replace("'/_install/install\.php$'i", "", _PHP_SELF);
	define("XOOPS_URL", $root_url);
}

$lang = !empty($HTTP_POST_VARS['lang']) ? $HTTP_POST_VARS['lang'] : $HTTP_COOKIE_VARS['lang'];

if ( @file_exists(WIZ_PATH."/language/".$lang."/main.php") ) {
	include_once(WIZ_PATH."/language/".$lang."/main.php");
	} else {
		include_once(WIZ_PATH."/language/english/main.php");
	}

if ( @file_exists("../language/".$lang."/global.php") ) {
	include_once("../language/".$lang."/global.php");
	} else {
		include_once("../language/english/global.php");
	}

if ( @file_exists("../language/".$lang."/admin.php") ) {
	include_once("../language/".$lang."/admin.php");
	} else {
		include_once("../language/english/admin.php");
	}

if ( @file_exists("../language/".$lang."/user.php") ) {
	include_once("../language/".$lang."/user.php");
	} else {
		include_once("../language/english/user.php");
	}
}

//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function wiz_header($title=_INSTALL_G_TITLE) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
	<html>
	<head>
	<title><?php echo $title;?></title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<link href="style/style.css" rel="stylesheet" type="text/css">
	</head>
	<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
	<table align="center" width="100%" border="0" cellpadding="0" cellspacing="0"><tr>
	<td width="100%" height="75">
	<p align="center">   <img src="images/logo_01.gif" width="227" height="65"></td>
	</tr><tr>
	<td width="100%" height="18">
	<p align="center"><img src="images/text.gif" width="280" height="18"></td>
	</tr><tr>
	<td width="250"><img src="images/midttxt.gif" width="280" height="7"></td>
	</tr><tr>
	<td colspan="2">
	<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"><tr>
	<td width="7"><img src="images/midtvenstre.gif" width="7" height="13"></td>
	<td width="100%"><img src="images/midttop.gif" width="100%" height="13"></td>
	<td width="7"><img src="images/midthojre.gif" width="7" height="13"></td>
	</tr><tr>
	<td width="7" background="images/centervtxt.gif">&nbsp;</td>
	<td align="center" width="100%">
	<font color="#999999" size="2" face="Verdana, Arial, Helvetica, sans-serif">
	<br />
<?php
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function wiz_footer() {
?>
	</font></td>
	<td width="7" background="images/centerhtxt.gif">&nbsp;</td>
	</tr><tr>
	<td width="7" height="13"><img src="images/bundvenstre.gif" width="7" height="13"></td>
	<td width="100%"><img src="images/bund.gif" width="100%" height="13"></td>
	<td width="7"><img src="images/bundhojre.gif" width="7" height="13"></td>
	</tr></table></td>
	</tr></table>
	<br /><div align="center">
	<a href="http://www.runcms.org" target="_blank"><img src="../images/button.gif" border="0" alt="<?php echo XOOPS_VERSION;?>" /></a>
	</div><br />
	</body>
	</html>
<?php
}

//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function version_check($min, $curr) {

$testVer = intval( str_replace(".", "", $min) );
$curVer  = intval( str_replace(".", "", $curr ) );
if( $curVer < $testVer ) {
	return false;
	} else {
		return true;
	}
}
?>
