<?php
 
/*
 
secretPath class 
 
version 1.0 10/21/2016 
 
 
Authorize access based on the sequence of user clicks
 
*/
 
 
//start session - sequence saved in $_SESSION super global
 
session_start();
 
 
//include class source
 
include('secretpath.class.php');
 
 
//instantiate the class or define class object from saved data
 
if( empty($_SESSION['secpth']) ){
 
    $path = array(1,2,3,2,2);
 
    $secpth = new secretPath('link',$path);
 
}else{
 
    $secpth = unserialize($_SESSION['secpth']);
 
}
 
 
//test user click sequence and send to secret page if sequence completed
 
//correctly
 
if( $secpth->validatePath() === true ){
 
    
 
    //it is important to save the class object before re-directing
 
    $_SESSION['secpth'] = serialize($secpth);
 
    header('location: secret.php');
 
    exit;
 
    
 
}
 
 
//save class object to session
 
$_SESSION['secpth'] = serialize($secpth);
 
 
?>
 
<html>
 
    <head>
 
        <title>Secret Path Example</title>
 
    </head>
 
    <body>
 
        Default secret path is link: 1,2,3,2,2<br><br>
 
        <a href="example.php?link=1">Link 1</a><br>
 
        <a href="example.php?link=2">Link 2</a><br>
 
        <a href="example.php?link=3">Link 3</a><br>
 
    </body>
 
</html>
 
 
 |