<?php
/*
 * This file is part of a larger software package. Please read the License file 
 * in the root of this installation for terms of usage and distribution.
 * 
 * @author The Web Pro Miami, Inc. <info@thewebpro.com>
 * @copyright The Web Pro Miami, Inc. <info@thewebpro.com>, http://www.thewebpro.com/
 * 
 * CORE: manage/process_logout.php - version 1.0
*/

$nReferrer = $_SERVER['HTTP_REFERER'];
if($nReferrer){
	$nReferrerARRAY = parse_url($nReferrer);
	$nFromManage = strpos($nReferrerARRAY["path"],"/manage/");
	$nFromPwdRec = strpos($nReferrerARRAY["path"],"pwd_recovery.php");
	if($nFromManage===false){
		$nRedirect = $nReferrer;
	} else {
		$nRedirect = "index.php?msg=1";
	}
}

if(!isset($_SESSION)){ session_start(); }
if(!isset($_SESSION["ValidUser"])){ unset($_SESSION["ValidUser"]); }
if(!isset($_SESSION["nAdminAccess"])){ unset($_SESSION["nAdminAccess"]); }
if(!isset($_SESSION["nUserLang"])){ unset($_SESSION["nUserLang"]); }
session_destroy();
// Remove cookies (trigger auto removal by browser by setting date to past
setcookie ("nMemUser","",time()-3600);
setcookie ("nMemUserToken","",time()-3600);
header ("Location: $nRedirect"); exit;
?>
