<?PHP
//================================================================================
// PLEASE DO NOT REMOVE THIS HEADER!!!
//
// COPYRIGHT NOTICE
// This script is licensed under the GPL
// 
// Copyright 2007-2008 Alias 454 Studios and Brandon Keep (c) All rights reserved.
// Created 11/18/2007   
// Brandon Keep,    http://www.openautoclassifieds.com
//                  http://www.alias454studios.com/scripts/
//
// Last Modified 05-06-2008 by
// Brandon Keep,    http://alias454studios.com
//================================================================================
// This software IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//================================================================================
//start the session
session_start();

//debuging
//ini_set('display_errors', 1);
//error_reporting(E_ALL|E_STRICT);

//set local variables
$dbhost = "localhost";
$dbuser = "dbuser";
$dbpass = "dbpass";
$dbname = "dbname";

//connect
$db = @mysql_connect($dbhost,$dbuser,$dbpass);
if (!$db) {
    die("<p>Unable to connect to the database at this time.</p>");
}

if (!@mysql_select_db($dbname) ) {
	echo( "<p>Unable to locate the database at this time.</p>" );
	exit();
}

//Get enviorment settings from DB
function getEnvSettings()
{
	$sql = "SELECT * FROM env_settings";
	$res = mysql_query($sql);
	$row = mysql_fetch_row($res);
	
	//print_r($row);
	return $row;
}

	$env = getEnvSettings();
		$site_url = $env[0];
		$admin_name = $env[1];
		$admin_email = $env[2];
		$site_mode = $env[3];
		$site_name = $env[4];
		$description = $env[5];
		$keywords = $env[6];
		$site_lang = $env[7];
		$listings_per_page = $env[8]; 
		$users_per_page = $env[9];
		$listings_stored_path = $env[10]; 
		$users_stored_path = $env[11];
		$use_zip_search = true;
		
//for php5 users set the default timezone if not set in your php ini
$ver = phpversion();
if ($ver >= 5)
	date_default_timezone_set("America/New_York");
	
// referers.. domains/ips that you will allow valid referer for form scripts
$referers = array('openautoclassifieds.com','www.openautoclassifieds.com');

if (isset($_COOKIE["user"])) {
	if (verifyCookie($_COOKIE["user"],$_COOKIE["pass"])) {
		$_SESSION["user"] = $_COOKIE["user"];
        $_SESSION["pass"] = $_COOKIE["pass"];
		$_SESSION["logged_in"] = 1;

	if (checkIfAdmin($_SESSION["user"],$_SESSION["pass"]))
		$_SESSION["admin"] = 1;
	if (checkIfSeller($_SESSION["user"],$_SESSION["pass"]))
		$_SESSION["seller"] = 1;
  	}
}

if (isset($_SESSION["user"])) {
	lastActive($_SESSION["user"]);
}
?>