<?php

if(!defined('IN_WEENCOMPANY'))
  die('File not found!');



$time_start = microtime(true);

error_reporting(E_ALL & ~E_NOTICE);


define('TIMENOW', time());
define('EMAIL_CRLF', "\r\n");	




if(is_file($rootpath . 'includes/config.php'))
{
  include($rootpath . 'includes/config.php');
}




if(!defined('CWSINSTALLED'))
{
  header('Location: '.$rootpath . 'install/index.php');
  exit;
}




if(!defined('TABLE_PREFIX'))
{
  define('TABLE_PREFIX', "");
}




include($rootpath . 'includes/db/' . $dbtype . '.php');

$DB = new DB;

$DB->database = $dbname;
$DB->server   = $servername;
$DB->user     = $dbusername;
$DB->password = $dbpassword;

$DB->connect();

$dbpassword   = '';
$DB->password = '';




$gettechnicalemail = $DB->query_first("SELECT value FROM " . TABLE_PREFIX . "mainsettings WHERE varname = 'technicalemail'");
$technicalemail    = $gettechnicalemail['value'];

$getversion = $DB->query_first("SELECT value FROM " . TABLE_PREFIX . "mainsettings WHERE  varname = 'sdversion'");
$cwsversion    = $getversion['value']; 


$getadmindir = $DB->query_first("SELECT value FROM " . TABLE_PREFIX . "mainsettings WHERE  varname = 'admin_dir'");

define('ADMIN_DIR', $getadmindir['value']);




if(defined('IN_ADMIN'))
{
  include($rootpath . ADMIN_DIR.'/adminfunctions.php');
}
else
{
  include_once($rootpath . 'includes/functions.php');
}

ini_set("magic_quotes_runtime", 0);




if(get_magic_quotes_gpc())
{
  if($_POST)   $_POST   = StripSlashesArray($_POST);
  if($_GET)    $_GET    = StripSlashesArray($_GET);
  if($_COOKIE) $_COOKIE = StripSlashesArray($_COOKIE);
}



if(defined('IN_ADMIN'))
{
  if($_POST)   $_POST   = AddSlashesArray($_POST);
  if($_GET)    $_GET    = AddSlashesArray($_GET);
  if($_COOKIE) $_COOKIE = AddSlashesArray($_COOKIE);
}



if(!defined('IN_ADMIN'))
{
  if($_POST)   $_POST   = PreClean($_POST);
  if($_GET)    $_GET    = PreClean($_GET);
  if($_COOKIE) $_COOKIE = PreClean($_COOKIE);
}




if(!$globalsoption = ini_get('register_globals'))
{
  @extract($_POST,    EXTR_SKIP);
  @extract($_GET,     EXTR_SKIP);
  @extract($_SERVER,  EXTR_SKIP);
  @extract($_FILES,   EXTR_SKIP);
  @extract($_ENV,     EXTR_SKIP);
  @extract($_COOKIE,  EXTR_SKIP);
}




$sdlanguage = GetLanguage(1);

$thisfiledirname = strtolower(substr(str_replace(dirname(dirname(dirname(__FILE__))), '', dirname(dirname(__FILE__))), 1));
$script_name = strtolower($_SERVER['SCRIPT_NAME']);

if (strstr($script_name, $thisfiledirname.'/')){
	$thiswebsitedir = str_replace(strstr($script_name, $thisfiledirname.'/'), '', $script_name);
	$weenurl = "http://". $_SERVER['HTTP_HOST'] . $thiswebsitedir . $thisfiledirname . '/';
}else{
	$weenurl = "http://". $_SERVER['HTTP_HOST'] . '/';
}




$usersystem = $DB->query_first("SELECT * FROM " . TABLE_PREFIX . "usersystems WHERE activated='1'");




if(defined('IN_ADMIN'))
{
  $getadmincookietime = $DB->query_first("SELECT value FROM " . TABLE_PREFIX . "mainsettings WHERE varname = 'admincookietimeout'");
  $mainsettings['admincookietimeout'] = $getadmincookietime['value'];
  include($rootpath . ADMIN_DIR.'/authenticate.php');
}



$smilieimagetexts = array();
$smilieimagepaths = array();

LoadSmilies($usersystem);

?>