-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
require '../vendor/autoload.php'; | ||
|
||
use TokenManager\TokenManager; | ||
|
||
// Setup | ||
$options = array( | ||
'dir' => './tokens/', | ||
'prefix' => 'token', | ||
'salt' => 'salt', | ||
'hash' => 'sha256', // hash use to generate token | ||
'maxTimeout' => 120, //max lifetime for a token | ||
'maxTimeout' => 30, //min lifetime for a token | ||
); | ||
$TokenMgr = new TokenManager($options); | ||
|
||
// Get token | ||
$token = $TokenMgr->get(); | ||
?> | ||
|
||
<!doctype html> | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
|
||
<title>php-token-manager : get</title> | ||
<meta name="description" content="php-token-manager : get"> | ||
<meta name="author" content="Gregory Brousse"> | ||
</head> | ||
|
||
<body> | ||
<a href="./usage-verify.php?token=<?php echo $token ?>">Test with right token</a><br/> | ||
<a href="./usage-verify.php?token=123456">Test with wrong token</a><br/> | ||
<a href="./usage-verify.php">Test with no token</a><br/> | ||
<br/> | ||
Last error : <?php echo $TokenMgr->getLastError(); ?> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
require '../vendor/autoload.php'; | ||
|
||
use TokenManager\TokenManager; | ||
|
||
if(isset($_GET['token'])){ | ||
// Setup | ||
$options = array( | ||
'dir' => './tokens/', | ||
'prefix' => 'token', | ||
'salt' => 'salt', | ||
'hash' => 'sha256', // hash use to generate token | ||
'maxTimeout' => '120', //max lifetime for a token | ||
'maxTimeout' => '30', //min lifetime for a token | ||
); | ||
$TokenMgr = new TokenManager($options); | ||
|
||
// Verify token | ||
if($TokenMgr->isValid($_GET['token'])){ | ||
header('Content-type: text/txt'); | ||
header('Content-Disposition: attachment; filename="test.txt"'); | ||
echo file_get_contents('./test.txt'); | ||
}else{ | ||
echo 'Error token not valid'; | ||
} | ||
}else{ | ||
echo 'Error token missing'; | ||
} | ||
?> |