<?php
/**
* logout.php
* Logout page removes session and cookie data
*
* @author Ed Parrish
* @version 1.2 11/12/05
*/

ob_start();
if (!session_id()) session_start();

main("Artzy Secure Logout");

// Control the operation of a page
function main($title = "") {
    $redirect = "http://".$_SERVER['HTTP_HOST']
                ."index.html";
    $other = "<meta http-equiv=\"Refresh\"";
    $other .= "content=\"5;URL=$redirect\">\n";
    $user = "";
    if (isset($_SESSION['user'])) {
        $user = $_SESSION['user'];
    }
    $_SESSION = array();
    if (isset($_COOKIE[session_name()])) {
        setcookie(session_name(), '', time() - 86400, '/');
    }
    session_destroy();
    include("includes/header.php");
    showContent($title, $redirect, $user);
    include("includes/footer.php");
}

/**
* Purpose: Display the content of a page
*/
function showContent($title, $redirect, $user) {
    $msg = $user;
    if (!$user) {
        $msg = "You are";
    }
    echo "<h1>$title</h1>";
    echo<<<HTML
<p>$msg logged out securely.</p></p>
<p>Click <a href="$redirect">here</a> to continue.</p>
HTML;
}
?>