mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-17 20:54:52 +08:00
prevent user from executing phar stub file directly
This commit is contained in:
parent
396444a089
commit
a934037179
@ -11,3 +11,4 @@ parameters:
|
||||
dynamicConstantNames:
|
||||
- SWOOLE_VERSION
|
||||
- ZM_TEST_LOG_DEBUG
|
||||
- _PHAR_STUB_ID
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
const _PHAR_STUB_ID = '__generated_id__';
|
||||
|
||||
function loader__generated_id__()
|
||||
{
|
||||
$obj = json_decode(file_get_contents(__DIR__ . '/zmplugin.json'), true);
|
||||
@ -12,4 +14,8 @@ function loader__generated_id__()
|
||||
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];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user