<?php
/**************************************************************************************************
* ChurchCMS
* Copyright (C) 2005 jsvoyager
*
* Developers & Contributors:
* jsvoyager hide@address.com
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* (license.txt)
***************************************************************************************************/
/**************************************
* Bring in the config file
**************************************/
if (!file_exists("lib/config.inc.php")){
//No config file, go to install...
header ("Location: install/index.php");
die();
}
require_once ("lib/config.inc.php");
/**************************************
* Output Buffering
**************************************/
ob_start();
/**************************************
* Initalize the smarty library
**************************************/
include ("lib/smarty/Smarty.class.php");
$smarty = new Smarty;
$smarty->template_dir = _ROOT_ . "/theme/templates/";
$smarty->compile_dir = _ROOT_ . "/theme/templates_c/";
$smarty->config_dir = _ROOT_ . "/theme/configs/";
$smarty->cache_dir = _ROOT_ . "/theme/cache/";
$smarty->assign_by_ref("lang", $lang); //Keeps smarty up with the language additions
/**************************************
* Bring up the db lib
**************************************/
include ("lib/db.inc.php");
include ("lib/tables.def.php");
$db = new mysqldb;
$db->connect(_DB_SERVER_, _DB_USER_, _DB_PASS_, _DB_NAME_);
/**************************************
* Start our session
**************************************/
session_start();
//In an effort to reduce the long {$smart.sesion...}, I've made this
$smarty->assign_by_ref("SES", $_SESSION);
/**************************************
* Update User
**************************************/
if (isset($_SESSION['user'])){
$query = "UPDATE "._USERS_." SET last_activity='" . time() . "' WHERE id='{$_SESSION['user']['id']}'";
$db->query(__FILE__, __LINE__, $query);
}
/**************************************
* Function Definitions
**************************************/
function error ($errnum, $file, $line, $fatal = true, $addinfo = ""){
global $smarty;
include_once("lang/"._LANG_."/errors.inc.php");
$smarty->assign("errnum", $errnum);
$smarty->assign("file", $file);
$smarty->assign("line", $line);
$smarty->assign("errtext", $lang['err'][$errnum]);
$smarty->assign("lang", $lang);
//Clear the output buffer
ob_clean();
$smarty->display("error.tpl");
if ($fatal){
die();
}
}
?>