<?php
session_start();
error_reporting(E_ERROR);
include('config.php');
include('connect.php');
$query = $mysqli->query("SHOW TABLES LIKE 'users'");
if($query->num_rows == 0) {
die('The Script Isn\'t Installed Successfully. <a href="install/install.php">Go to Installation.</a>');	
}
include('functions.php');
include('pagination.php');
include('general.class.php');
require_once('twitteroauth/twitteroauth.php');
include_once("facebook/facebook.php");
$general = new General;
$general->set_connection($mysqli);
$general_options = $general->get_options('General');
require_once('smarty/Smarty.class.php');
$smarty = new Smarty;
$smarty->compile_dir = 'cache/';
$smarty->template_dir = 'themes/'.$general_options['site_theme'].'/';
$smarty->plugins_dir = array(
                       './include/smarty/plugins',
                       './plugins/'
                       );
$smarty->force_compile = true;
$options = $general->get_all_options();
foreach ($options AS $key=>$value) {
$smarty->assign($key,$value);
}
include('languages/'.$options['general_site_language'].'/site.php');
foreach ($language AS $key=>$value) {
$smarty->assign('lang_'.$key,$value);	
}
$pubkey = $options['api_recaptcha_public'];
$smarty->assign('pubkey',$pubkey);
$smarty->assign('currentpage',curPageURL());
include('autologin.php');
if (isset($_SESSION['media_cms_user'])) {
	$smarty->assign('islogged',$_SESSION['media_cms_user']);
	$user = $general->user($_SESSION['media_cms_user']);
	foreach ($user AS $key=>$value) {
		$smarty->assign('user_'.$key,$value);
	}
} else {
	$smarty->assign('islogged',0);
}
$smarty->assign('currentpage',curPageURL());
$categories = $general->categories('category_order ASC');
$smarty->assign('categories',$categories);
$pages = $general->pages('page_order ASC');
$smarty->assign('pages',$pages);
// ads blocks
$header_ad = file_get_contents('ads/header.txt');
$smarty->assign('header_ad',$header_ad);
$side_ad = file_get_contents('ads/side.txt');
$smarty->assign('side_ad',$side_ad);
$content_ad = file_get_contents('ads/content.txt');
$smarty->assign('content_ad',$content_ad);
// Google Analytics Code
$ga_code = file_get_contents('analytics/code.txt');
$smarty->assign('ga_code',$ga_code);
?>
