From: Christian Weiske Date: Fri, 13 Oct 2017 16:25:40 +0000 (+0200) Subject: Make random IDs configurable X-Git-Url: https://git.cweiske.de/phorkie.git/commitdiff_plain/25b59cbc644e59559296beef66b8509fd4cdefcf?hp=ede9ef521fbe3b9fc3ee95c410edd906f8e64284 Make random IDs configurable --- 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 . '/';