<?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 04-12-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.
//================================================================================

require_once './Includes/configs/functions.php';
require_once './Includes/libs/Smarty.class.php';
include_once "./Includes/language/$site_lang.php";

$smarty = new Smarty;

$smarty->assign("manufacturerslist",getSearchList("make"));
$smarty->assign("modelslist",getSearchList("model"));
$smarty->assign("typeslist",getSearchList("vehicle_type"));

//if the user is logged in let them be else redirect them to login
if (isset($_SESSION["logged_in"]) == 1){
	$smarty->assign("logged_in",1);
	//check privs to find out if user 
	//is a seller, admin or user
	$status = checkPrivs();
	$smarty->assign("$status",1);
	
	$records = getUserRecords($_SESSION["user"]);
	$smarty->assign("records",$records);

	$file = $records[0]['image'];
	if (!empty($file)) {
		$ext_split = split("\.",$file);
		$ext = $ext_split[1];
		$base = $ext_split[0];
	
		$smarty->assign("thumb","$base" . "_thumb" . "." . "$ext");
		if (isset($_GET["action"]) && $_GET["action"] == "viewfull") {
			$smarty->assign("img","$base" . "." . "$ext");
			$smarty->assign("fullview",1);
		} elseif (isset($_GET["action"]) && $_GET["action"] == "delete") {
			if (deleteUserImage($_SESSION["user"])) {
			$smarty->assign("success",MEMBER_DELETE_IMAGE_SUCCESS);
			} else {
				$smarty->assign("error_message",MEMBER_DELETE_ERROR);
			}
		}
	}
} else {
	header("Location: login.php");
	exit();
}

$smarty->display('member.tpl');
?>