mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-24 00:55:35 +08:00
prevent user from executing phar stub file directly
This commit is contained in:
@@ -11,3 +11,4 @@ parameters:
|
|||||||
dynamicConstantNames:
|
dynamicConstantNames:
|
||||||
- SWOOLE_VERSION
|
- SWOOLE_VERSION
|
||||||
- ZM_TEST_LOG_DEBUG
|
- ZM_TEST_LOG_DEBUG
|
||||||
|
- _PHAR_STUB_ID
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
const _PHAR_STUB_ID = '__generated_id__';
|
||||||
|
|
||||||
function loader__generated_id__()
|
function loader__generated_id__()
|
||||||
{
|
{
|
||||||
$obj = json_decode(file_get_contents(__DIR__ . '/zmplugin.json'), true);
|
$obj = json_decode(file_get_contents(__DIR__ . '/zmplugin.json'), true);
|
||||||
@@ -12,4 +14,8 @@ function loader__generated_id__()
|
|||||||
require_once Phar::running() . '/' . $v;
|
require_once Phar::running() . '/' . $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ('__generate' . 'd_id__' === _PHAR_STUB_ID) {
|
||||||
|
echo 'Cannot execute this file directly!' . PHP_EOL;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
return json_decode(file_get_contents(__DIR__ . '/zmplugin.json'), true) ?? ['zm_module' => false];
|
return json_decode(file_get_contents(__DIR__ . '/zmplugin.json'), true) ?? ['zm_module' => false];
|
||||||
|
|||||||
Reference in New Issue
Block a user