<?php
/*
 * XPressME - WordPress for XOOPS
 *
 * @copyright	XPressME Project http://www.toemon.com
 * @license		http://www.fsf.org/copyleft/gpl.html GNU public license
 * @author		toemon
 * @package		module::xpress
 */

/* 
 *	The module loads the XOOPS system only at the time of reading to route index.php. 
 *
 *	When "Media up-loading" is executed, WordPress calls the SWFUpload script. 
 *	After completing up-loading
 *	The SWFUpload script executes wp-admin/async-upload.php. 
 *	At this time, session ID is not succeeded to. 
 *	And, admin/async-upload.php becomes an access inhibit when wordpress is under the management of XOOPS. 
 */

function is_root_index_page_call(){
	$xpress_root_index = basename(dirname(dirname( __FILE__ ))) . '/index.php';
	$php_script_name = $_SERVER['SCRIPT_NAME'];
	$php_query_string = $_SERVER['QUERY_STRING'];
	if (strstr($php_script_name,$xpress_root_index) !== false) {
		if (strstr($php_query_string,'preview') === false) return true; else return false;;
	} else  {
		return false;
	}
}

function is_admin_page_call(){
	$xpress_root_index = basename(dirname(dirname( __FILE__ ))) . '/wp-admin';
	$php_script_name = $_SERVER['SCRIPT_NAME'];
	if (strstr($php_script_name,$xpress_root_index) !== false) return true; else  return false;
}

if (is_admin_page_call()){
	if ( !defined("XOOPS_ROOT_PATH") ) {	
		define('_LEGACY_PREVENT_LOAD_CORE_', 1);		//Module process will not load any XOOPS Cube classes.
		include_once dirname( __FILE__ ).'/../../../mainfile.php';
	}
} else {
	// index page is load xoops
	require dirname( __FILE__ ).'/../../../mainfile.php' ;
}
?>
