<?php
/***************************************************************
* mobiquo.php                                                  *
* Copyright 2009 Quoord Systems Ltd. All Rights Reserved.     *
* Created by Dragooon (http://smf-media.com)                   *
****************************************************************
* This file or any content of the file should not be           *
* redistributed in any form of matter. This file is a part of  *
* Tapatalk package and should not be used and distributed      *
* in any form not approved by Quoord Systems Ltd.              *
* http://tapatalk.com | http://taptatalk.com/license.html      *
****************************************************************
* Main file for the SMF package, controls...everything         *
***************************************************************/

global $sourcedir, $mobsettings, $context, $mobdb, $boarddir, $scripturl, $HTTP_RAW_POST_DATA, $modSettings, $user_info;

$forum_root = dirname(dirname(__FILE__));
$ssi_guest_access = true;
// Call SSI.php, because we need it in order to communicate with SMF
if (file_exists($forum_root . '/SSI.php'))
	require_once($forum_root . '/SSI.php');
else
	die('SSI.php not found, could not initialize');

// Call Susb-Mobiquo.php, we need this for major assitance
require_once($boarddir . '/mobiquo/Subs-Mobiquo.php');

// Load settings and the database
loadMobiquoSettings();
loadMobiquoDatabase();

// Call Mobiquo-Functions.php and Mobiquo-Templates.php, these files contains all the functions required
require_once($mobsettings['basepath'] . '/Mobiquo-Functions.php');
require_once($mobsettings['basepath'] . '/Mobiquo-Templates.php');

// Are we not having any raw post data? Forget about it then....
if (empty($HTTP_RAW_POST_DATA))
	redirectexit();

// Are we closed?
if (!empty($context['in_maintenance']) && !$user_info['is_admin'])
	createErrorResponse(5, ' due to maintenance');
/*
elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'])
	createErrorResponse(5, ' to guests');
*/
// Parse the request
parseMobRequest();

// Invalid method?
if (!function_exists('method_' . $context['mob_request']['method']))
	createErrorResponse('unknown_method', ' : ' . $context['mob_request']['method'], 'xmlrpc');
	
require_once($mobsettings['basepath'] . '/config/config.php');
$mobiquo_config = get_mobiquo_config();

if (isset($mobiquo_config['hide_forum_id']) && count($mobiquo_config['hide_forum_id']) && !$user_info['is_admin'])
{
    $user_info['query_see_board'] .= ' AND b.ID_BOARD NOT IN ('. implode(',', $mobiquo_config['hide_forum_id']) .') ';
}
file_put_contents('/tmp/request', var_export($context['mod_request'], true));
// Allright, method passed...call it
call_user_func('method_' . $context['mob_request']['method']);

// Bye Bye...
endOutput();
?>
