summaryrefslogtreecommitdiff
path: root/models/base.php
diff options
context:
space:
mode:
Diffstat (limited to 'models/base.php')
-rw-r--r--models/base.php15
1 files changed, 14 insertions, 1 deletions
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);
+ }
}