Skip to content
This repository was archived by the owner on Aug 22, 2021. It is now read-only.

Commit c59c297

Browse files
committed
Fix random number.
1 parent 7876be0 commit c59c297

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/StorageManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ public function formatPath($path)
214214
$path = str_replace('{time}', $time, $path);
215215

216216
//替换随机字符串
217-
$randNum = rand(1, 10000000000).rand(1, 10000000000);
218217
if (preg_match("/\{rand\:([\d]*)\}/i", $path, $matches)) {
219-
$path = preg_replace("/\{rand\:[\d]*\}/i", substr($randNum, 0, $matches[1]), $path);
218+
$length = min($matches[1], strlen(PHP_INT_MAX));
219+
$path = preg_replace("/\{rand\:[\d]*\}/i", str_pad(mt_rand(0, pow(10, $length) - 1), $length, '0', STR_PAD_LEFT), $path);
220220
}
221221

222222
return $path;

0 commit comments

Comments
 (0)