mirror of
https://github.com/gamaio/lobli.git
synced 2024-12-22 11:42:40 +00:00
New token generation and fix output on shorten
This token generation should prevent the same token from being used, also considering using a type of cooldown timer. Short links were returning as (shortid)$, which didn't work
This commit is contained in:
parent
fb5ccdce5e
commit
f825c6bd29
@ -51,7 +51,7 @@
|
||||
|
||||
$redis->zAdd("tracking:clicks", 1, $link);
|
||||
|
||||
return "0$seperator$short$";
|
||||
return "0$seperator$short";
|
||||
}
|
||||
}
|
||||
|
||||
|
17
Website/Include/PHP/token.php
Normal file
17
Website/Include/PHP/token.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
session_start();
|
||||
// Generate time expiring token for process.php
|
||||
require('db.php');
|
||||
|
||||
do{ // Generate tokens until one isn't in the redis db
|
||||
$token = substr(number_format(time() * mt_rand(),0,'',''),0,40);
|
||||
$token = base_convert($token, 10, 36);
|
||||
|
||||
if(!$redis->exists("tokens:$token")){
|
||||
break;
|
||||
}
|
||||
} while(1);
|
||||
|
||||
$redis->set("tokens:$token", 0); // Store the token forever, when set to 1, don't allow token to be used anymore.
|
||||
$_SESSION['token'] = $token;
|
||||
?>
|
Loading…
Reference in New Issue
Block a user