<?php
require_once dirname( __FILE__ ).'/include/xpress_debug_log.php' ;
require_once dirname( __FILE__ ).'/class/config_from_xoops.class.php' ;
$xoops_config = new ConfigFromXoops;
require_once dirname( __FILE__ ).'/include/set_cash_cookie_path.php' ;

/**
 * mb_language() sets language. If language  is omitted, it returns current language as string.
 * language setting is used for encoding e-mail messages. 
 * Valid languages are "Japanese", "ja","English","en" and "uni" (UTF-8). 
 * mb_send_mail() uses this setting to encode e-mail.
 * Language and its setting is ISO-2022-JP/Base64 for Japanese, UTF-8/Base64 for uni, ISO-8859-1/quoted printable for English. 
 */
// if (function_exists("mb_language")) mb_language('uni');


// ** MySQL settings - You can get this info from your web host ** //
// Do not change  'DB_NAME','DB_USER','DB_PASSWORD' & 'DB_HOST'
// because copies a set value of XOOPS. 

/** Do not change. The name of the database for WordPress */
define('DB_NAME', $xoops_config->xoops_db_name);

/** Do not change. MySQL database username */
define('DB_USER', $xoops_config->xoops_db_user);

/** Do not change. MySQL database password */
define('DB_PASSWORD', $xoops_config->xoops_db_pass);

/** Do not change. MySQL hostname */
define('DB_HOST', $xoops_config->xoops_db_host);
	
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/**#@+
 * Chaves únicas de autenticação.
 *
 * Altere cada chave para um frase única!
 * Você pode gerá-las usando {@link http://api.wordpress.org/secret-key/1.1/ WordPress.org secret-key service}
 *
 * @since 2.6.0
 */
define('AUTH_KEY', 'coloque sua frase única aqui');
define('SECURE_AUTH_KEY', 'coloque sua frase única aqui');
define('LOGGED_IN_KEY', 'coloque sua frase única aqui');
define('NONCE_KEY', 'coloque sua frase única aqui');
/**#@-*/

if ($xoops_config->is_wpmu){	//for WordPressMU
	define('VHOST', 'no'); 
	$base = $xoops_config->mu_path_current_site;
	define('DOMAIN_CURRENT_SITE', $xoops_config->mu_domain_current_site );
	define('PATH_CURRENT_SITE', $xoops_config->mu_path_current_site );
	define('SITE_ID_CURRENT_SITE', 1);
	define('BLOGID_CURRENT_SITE', '1' );

	define('AUTH_SALT', 'put your unique phrase here');
	define('LOGGED_IN_SALT', 'put your unique phrase here');
	define('SECURE_AUTH_SALT', 'put your unique phrase here');
}

/**
 * Prefixo da tabela do banco de dados do WordPress.
 *
 * Você pode ter várias instalações em um único banco de dados se você der para cada um um único
 * prefixo. Somente números, letras e sublinhados!
 */
// Do not change. $table_prefix is generated from XOOPS DB Priefix and the module directory name. 
$table_prefix  = $xoops_config->module_db_prefix;

/**
 * O idioma localizado do WordPress é o inglês por padrão.
 *
 * Altere esta definição para localizar o WordPress. Um arquivo MO correspondente a
 * língua escolhida deve ser instalado em wp-content/languages. Por exemplo, instale
 * pt_BR.mo em wp-content/languages e altere WPLANG para 'pt_BR' para habilitar o suporte
 * ao português do Brasil.
 */
define ('WPLANG', 'pt_BR');

/* Isto é tudo, pode parar de editar! :) */

/** Caminho absoluto do WordPress para o diretório Wordpress. */
if ( !defined('ABSPATH') )
	define('ABSPATH', dirname(__FILE__) . '/');

require_once( ABSPATH .'/include/request_url.php');
if (is_xpress_index_page_call()){
	require_once $xoops_config->xoops_mainfile_path; //It is necessary to execute it for the user attestation before wp-settings.php. 
	require_once(ABSPATH.'wp-settings.php');
	wp();
	
	if (!function_exists('is_wordpress_style')){	// When the XPressME plug-in is invalid
		require_once dirname( __FILE__ ).'/include/xpress_active_plugin.php' ;
		xpress_pulugin_activation('xpressme/xpressme.php');
		// reloaded 
		header('Location: ' . $xoops_config->module_url . '/');
		
		$err_str = "The activation of the XPressME plugin was executed.<br />\n";
		$err_str .= "Because the XPressME plugin was invalid.<br />\n";
		$err_str .= "Please do the rereading seeing on the page.\n";			
		die($err_str);
	}

	// It judges it here because it does in is_index_page() through feed to which the permalink is set. 
	if (is_wordpress_style() || is_feed()) {
		require_once( ABSPATH . WPINC . '/template-loader.php' );
	} else {
		ob_start();	
			require_once( ABSPATH . WPINC . '/template-loader.php' );
			$wp_output = ob_get_contents();
		ob_end_clean();
		require_once( ABSPATH .'/include/xpress_render.php' );
		xpress_render($wp_output);
	}
		
	
	//When there is no block cache, and an optional block is different, cache is refreshed. 
	//When adding, and changing and deleting Post & Comment, block cache is refreshed by add_action at any time. 
	// This Function in xpressme plugin
	require_once( ABSPATH .'/include/xpress_block_render.php' );	
	xpress_unnecessary_block_cache_delete($xoops_config->module_name);
	if (is_home()) xpress_block_cache_refresh($xoops_config->module_name);
	exit();		// The return to wp-blog-header.php is stolen here
}
if (is_admin_post_call()) require_once $xoops_config->xoops_mainfile_path;
if (is_xpress_comments_post_call()) require_once $xoops_config->xoops_mainfile_path;
require_once(ABSPATH.'wp-settings.php');
?>