PHP Classes

File: bin/build

Recommend this page to a friend!
  Classes of Marco Cesarato   PHP Malware Scanner Free Tool   bin/build   Download  
File: bin/build
Role: Example script
Content typex: text/plain
Description: Example script
Class: PHP Malware Scanner Free Tool
Scan PHP files to find malicious code
Author: By
Last change: Merge pull request #92 from esurov/composer-2.2.21

Composer updated
Date: 3 months ago
Size: 1,399 bytes
 

Contents

Class file image Download
#!/usr/bin/env php
<?php

/**
 * Antimalware Scanner
 * @author Marco Cesarato <[email protected]>
 * @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();

// pointing main file which requires all classes
$defaultStub = $p->createDefaultStub('index.php', '/index.php');

// creating our library using whole directory
$p->buildFromDirectory($input);

// Create a custom stub to add the shebang
$stub = "#!/usr/bin/env php\n" . $defaultStub;

// Add the stub
$p->setStub($stub);

$p->stopBuffering();

unset(
$p);
rename($output, $finalOutput);

chmod($finalOutput, 0755);

echo
"$output successfully created";