관리-도구
편집 파일: build
#!/usr/bin/env php <?php /** * Antimalware Scanner * @author Marco Cesarato <cesarato.developer@gmail.com> * @copyright Copyright (c) 2019 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License * @link https://github.com/marcocesarato/PHP-Antimalware-Scanner */ $root = dirname(__DIR__); require_once $root . '/vendor/autoload.php'; $input = $root . '/src/'; $output = $root . '/dist/scanner.phar'; $finalOutput = $root . '/dist/scanner'; // clean up if (file_exists($output)) { unlink($output); } if (file_exists($output . '.gz')) { unlink($output . '.gz'); } if (file_exists($finalOutput)) { unlink($finalOutput); } // check that phar.readonly to off if (1 == ini_get('phar.readonly')) { echo "Can't create a Phar file. Please set `phar.readonly = Off` in your php.ini\n"; exit(1); } // create phar $p = new Phar($output); // start buffering. Mandatory to modify stub. $p->startBuffering(); // creating our library using whole directory $p->buildFromDirectory($input); // Create a custom CLI-only stub without webPhar() // This avoids signature verification issues when the phar is downloaded/transferred // webPhar() performs strict signature validation which can fail if the file is // corrupted during download. mapPhar() is more lenient and suitable for CLI-only usage. $stub = <<<'STUB' #!/usr/bin/env php <?php Phar::mapPhar(); require 'phar://' . __FILE__ . '/index.php'; __HALT_COMPILER(); STUB; // Add the stub $p->setStub($stub); $p->stopBuffering(); unset($p); rename($output, $finalOutput); chmod($finalOutput, 0755); echo "$output successfully created";