<?php

/**
 * video.php - The First Entry Point
 **/

session_start();
// Get Token
$token = $_GET['vid'];

// Get Current Session ID
$prev = session_id();
/*// Test the session variable token is set
if (isset($_SESSION['setToken'])) {
    // This was a one time token and this is your security
    unset($_SESSION['setToken']);
    // Now we will re-encrypt the token
    $token = openssl_decrypt($token, "aes128", session_id(), 0, '1234567812345678');
    // Now Regenerate the session id
    session_regenerate_id();
    // Now re-encrypt the token with a key combination of both new and old ids
    $token = openssl_encrypt($token, "aes128", $prev . session_id(), 0, '1234567812345678');
} else {
    // If token was not matched, we have changed the id therefore the next script will not be able to decrypt the token
    session_regenerate_id(true);
}*/
$token = str_replace(" ", "/", $token);
/*$token_encrypted = openssl_encrypt($token, "DES-ECB", session_id());
$token_decrypted = openssl_decrypt($token, "DES-ECB", session_id());
echo ("now: " . $token);
echo ("<br>");
echo ("token_encrypted:" . $token_encrypted);
echo ("<br>");
echo ("token_decrypted:" . $token_decrypted);*/
header("Location: access.php?id=" . $prev . "&vid=" . $token);
