From 2f4651411b1827e1e5859ba6053052b508f455e0 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 22 Feb 2014 16:30:03 -0500 Subject: Add kiosk mode, public board access with read-only and auto-refresh --- models/base.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'models/base.php') diff --git a/models/base.php b/models/base.php index 981c7839..3c071623 100644 --- a/models/base.php +++ b/models/base.php @@ -17,7 +17,7 @@ require __DIR__.'/schema.php'; abstract class Base { const APP_VERSION = 'master'; - const DB_VERSION = 2; + const DB_VERSION = 3; const DB_FILENAME = 'data/db.sqlite'; private static $dbInstance = null; @@ -46,4 +46,17 @@ abstract class Base die('Unable to migrate database schema!'); } } + + // Generate a random token from /dev/urandom or with uniqid() + public static function generateToken() + { + if (ini_get('open_basedir') === '') { + $token = file_get_contents('/dev/urandom', false, null, 0, 30); + } + else { + $token = uniqid(mt_rand(), true); + } + + return hash('crc32b', $token); + } } -- cgit v1.2.3