source: subversion/sites/other/tilesAtHome/lib/tokens.inc @ 3655

Last change on this file since 3655 was 3470, checked in by ojw, 13 years ago

Library for generating upload tokens

File size: 422 bytes
Line 
1<?php
2
3function GetTokens($UserID = -1, $Secret = "secret"){
4  $Interval = 10 * 60;
5  $Time = time();
6 
7  $Timeslot1 = floor($Time / $Interval);
8  $Timeslot2 = $Timeslot1 - 1;
9
10  $Token1 = Token($Timeslot1, $UserID, $Secret);
11  $Token2 = Token($Timeslot2, $UserID, $Secret);
12
13  return(array($Token1, $Token2));
14}
15
16function Token($Time, $UserID, $Secret){
17  return(md5(sprintf("%s_%d_%d", $Secret, $Time, $UserID)));
18}
19?>
Note: See TracBrowser for help on using the repository browser.