<?php
$connect_dir = "connect";
$doc_root = $_SERVER['DOCUMENT_ROOT'];
if (file_exists("../connect/config_sites.php"))	{
	$connect_path = "../";
	include ("../connect/config_sites.php");
}
elseif (file_exists($doc_root . "/connect/config_sites.php"))	{	// Custom userfile folders
	$connect_path = $doc_root . "/";
	include ($doc_root . "/connect/config_sites.php");
}
else	{	// Must be installeed in sub domain or sub folder with non-standard userfile folders.
	$php_self = $_SERVER["PHP_SELF"];
	$self_parts = explode('/', $php_self);
	$this_script = $self_parts[count($self_parts) - 1];
	$sub_dir = str_replace(array($doc_root, $this_script), "", $php_self);
	$sub_dir_parts = explode('/', $sub_dir);
	$connect_path = $doc_root . '/' . $sub_dir_parts[0] . "/";
	include ($doc_root . '/' . $sub_dir_parts[0] . "/connect/config_sites.php");
}

if (!defined('BWB_ACTIVE_SITE'))
	define('BWB_ACTIVE_SITE', 1);
if (BWB_ACTIVE_SITE != 1)
	$connect_dir .= BWB_ACTIVE_SITE;

$sess_save_path = session_save_path();
if (!isset($sess_save_path) || ($sess_save_path == ""))	{
		if (defined('SESSION_SAVE_PATH'))
			session_save_path(SESSION_SAVE_PATH);
		else
			session_save_path('/tmp');
	}

session_start();
if (isset($_SESSION['site_under_edit']) && ($_SESSION['site_under_edit'] != BWB_ACTIVE_SITE))	{
	if ($_SESSION['site_under_edit'] == 1)
		$connect_dir = "connect";
	else
		$connect_dir = "connect" . $_SESSION['site_under_edit'];
}

include ($connect_path . $connect_dir . "/config.php");
include ($connect_path . $connect_dir . "/db_connect.php");
?>