request_id, add cli args for prefix

This commit is contained in:
xiaomlove
2021-06-01 15:50:17 +08:00
parent ec7104e5e8
commit 0b839c5970
4 changed files with 15 additions and 4 deletions
+13 -1
View File
@@ -11,4 +11,16 @@ $showversion = " - Powered by ".PROJECTNAME;
defined('ROOT_PATH') || define('ROOT_PATH', dirname(__DIR__) . '/');
defined('CURRENT_SCRIPT') || define('CURRENT_SCRIPT', strstr(basename($_SERVER['SCRIPT_FILENAME']), '.', true));
defined('IS_ANNOUNCE') || define('IS_ANNOUNCE', CURRENT_SCRIPT == 'announce');
defined('REQUEST_ID') || define('REQUEST_ID', $_SERVER['HTTP_X_REQUEST_ID'] ?? $_SERVER['REQUEST_ID'] ?? bin2hex(random_bytes(11)) . str_replace('.', '', substr(uniqid('', true), 12)));
//define the REQUEST_ID
if (!defined('REQUEST_ID')) {
if (!empty($_SERVER['HTTP_X_REQUEST_ID'])) {
$requestId = $_SERVER['HTTP_X_REQUEST_ID'];
} elseif (!empty($_SERVER['REQUEST_ID'])) {
$requestId = $_SERVER['REQUEST_ID'];
} else {
$prefix = implode('', $_SERVER['argv'] ?? []);
$requestId = bin2hex(random_bytes(11)) . str_replace('.', '', substr(uniqid($prefix, true), 12, 10));
}
define('REQUEST_ID', $requestId);
}