<?php
/*
 BMForum Datium! Bulletin Board Systems
 Version : Datium!
 
 This is a freeware, but don't change the copyright information.
 A SourceForge Project.
 Web Site: http://www.bmforum.com
 Copyright (C) Bluview Technology
*/
// Included: Interface and Language, headers,etc.
// -----------------------------------------------------------
if (!defined('CONFIGLOADED')) die("Access Denied");
@define("INBMFORUM", 1);
if ($gzip_compress == "1" && !defined("DISABLED_GZIP")) {
    ob_start("ob_gzhandler");
} else {
    ob_start();
} 
$sqltype = basename($sqltype);
$skin = $useraccess = $admgroupdata = ""; 
require_once("datafile/language.php");

if (!empty($_COOKIE["userlanguage"]) && file_exists("lang/" . basename($_COOKIE["userlanguage"]) . "/global.php")) $language = $_COOKIE["userlanguage"];
elseif (empty($_COOKIE["userlanguage"]) && $autolang) {
    $langlist = @file("datafile/langlist.php");
    $count_language = count($langlist);
    $useraccept = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
    $useraccept = $useraccept[0];
    for($i = 0;$i < $count_language;$i++) {
        $xlangshow = explode("|", $langlist[$i]);
        $langarray[$xlangshow[1]] = $xlangshow[2];
    } 
    $langkeyname = array_search_bit($useraccept, $langarray);
    if (!empty($langkeyname)) {
    	bmb_setcookie("userlanguage", $langkeyname);
        $_SESSION['userlanguage'] = $langkeyname;
        $language = $langkeyname;
    } 
} 
// ================== Show List Cookie
if ($_COOKIE['view_online'] == "show") $view_index_online = 1;
elseif ($_COOKIE['view_online'] == "hide") $view_index_online = 0;

if ($_GET["online_show"] == "show" || $_GET["online_show"] == "hide") {
    bmb_setcookie("view_online", $_GET["online_show"]);
}
//......... No AJAX option
if ($_COOKIE['close_ajax'] == 1) $allow_ajax_reply = $allow_ajax_browse = 0;
//
require_once("datafile/time.php");
require_once("include/global.php");
require_once("datafile/style.php");

$skinname = basename($_COOKIE['bmbskin']);
$styleopen = file("datafile/stylelist.php");
$stylecount = count($styleopen);
for($styi = 0;$styi < $stylecount;$styi++) {
	$styledetail = explode("|", $styleopen[$styi]);
	if ($styledetail[1] == $skinname) {
		$styledetail[3] = basename($styledetail[3]);
		if (file_exists("datafile/style/" . $styledetail[3])) include("datafile/style/" . $styledetail[3]);
		else include("datafile/style/" . basename($skin));
	} 
} 
// Schedule
include_once("include/schedule.php");


@header("Forum-Powered-By: $verandproname / BMForum.com");
@header("Content-Type: $encode_info");

$bbsdetime = $time_1;
if ($_COOKIE["usertimezone"] != "") {
    $time_1 = $_COOKIE["usertimezone"];
} 
if ($_COOKIE["customshowtime"] != "") {
    $time_2 = $_COOKIE["customshowtime"];
} 
$time_f = $_COOKIE["bmf_date_format"] ? $_COOKIE["bmf_date_format"] : $time_f;

get_forum_info("");
if ($forum_style <> "") {
    if (file_exists("datafile/style/" . basename($forum_style))) include("datafile/style/" . basename($forum_style));
} 
require("newtem/$temfilename/global.php");
$error = $cancel_guestfile = "";

if (($bbs_is_open == 0 && empty($thisprog) && $usertype[21] != 1 && $usertype[22] != 1) || (($nowhours < $ddwtail[0] || $nowhours >= $ddwtail[1]) && empty($thisprog))) {
	error_page($gl[469], $gl[469], $gl[469], $bbs_close_msg);
} 
@include_once("datafile/pluginclude.php");
// Forum permission check of some types
if (!defined("canceltbauto")) tbuser();

function array_search_bit($search, $array_in)
{
    foreach ($array_in as $key => $value) {
        if (@strpos($value, $search) !== false)
            return $key;
    } 
    return false;
} 
// BMForum Cookie
function bmb_setcookie ($varname, $varcookie)
{
	global $cookie_p, $cookie_d;
    if ($_COOKIE["cookie_time_bmb"] > 0 && $_COOKIE["cookie_time_bmb"] != "") {
        setcookie($varname, $varcookie, time() + $_COOKIE["cookie_time_bmb"], $cookie_p, $cookie_d);
    } else {
        setcookie($varname, $varcookie, 0, $cookie_p, $cookie_d);
    } 
}