From 25b59cbc644e59559296beef66b8509fd4cdefcf Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 13 Oct 2017 18:25:40 +0200 Subject: [PATCH] Make random IDs configurable --- data/config.default.php | 1 + data/config.php.dist | 1 + src/phorkie/Repositories.php | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/data/config.default.php b/data/config.default.php index 6e4c20c..06b53ed 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -34,6 +34,7 @@ $GLOBALS['phorkie']['cfg'] = array( 'elasticsearch' => null, 'index' => 'new',//"new" or "list" 'perPage' => 10, + 'randomIds' => false, 'defaultListPage' => 'last',//a number or "last" 'notificator' => array( /* send out pingback/webmentions when a remote paste is forked */ diff --git a/data/config.php.dist b/data/config.php.dist index f1b8704..85499fe 100644 --- a/data/config.php.dist +++ b/data/config.php.dist @@ -8,6 +8,7 @@ //$GLOBALS['phorkie']['cfg']['elasticsearch'] = 'http://localhost:9200/phorkie/'; //$GLOBALS['phorkie']['cfg']['setupcheck'] = false; //$GLOBALS['phorkie']['cfg']['perPage'] = 10; +//$GLOBALS['phorkie']['cfg']['randomIds'] = false; //$GLOBALS['phorkie']['auth']['securityLevel'] = 0; //$GLOBALS['phorkie']['auth']['listedUsersOnly'] = false; diff --git a/src/phorkie/Repositories.php b/src/phorkie/Repositories.php index 7ed3188..9021a2e 100644 --- a/src/phorkie/Repositories.php +++ b/src/phorkie/Repositories.php @@ -23,7 +23,11 @@ class Repositories } ); sort($dirs, SORT_NUMERIC); - $n = end($dirs) + mt_rand(65536, 16777216); + if ($GLOBALS['phorkie']['cfg']['randomIds']) { + $n = end($dirs) + mt_rand(65536, 16777216); + } else { + $n = end($dirs) + 1; + } chdir($this->workDir); $dir = $this->workDir . '/' . $n . '/'; -- 2.30.2