Skip to content

Instantly share code, notes, and snippets.

@ChaosPower
Last active February 26, 2020 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChaosPower/2a9fdb62e7013d2ccd2f9a145708ed2e to your computer and use it in GitHub Desktop.
Save ChaosPower/2a9fdb62e7013d2ccd2f9a145708ed2e to your computer and use it in GitHub Desktop.
PHP CLI Script
<?php
$options = getopt('f:', ['file:']);
if ($options['file'] != '') {
require_once $options['file'];
$oracle = new oracle(); // Files with same class name instance.
if (!property_exists($oracle, 'fields')) {
} else {
if (count($oracle->fields) != 4) {
$type = substr($options['file'], 0, -11); // Got lazy, just duplicated this from the other file. this can be converted to options['type']
if ($type !== "\r\n") // Reject new lines {
$type = str_replace('{absolute_path}', '', $type) . "\n";
process($oracle->fields, $type); // Call process method.
}
}
}
}
<?php
$directory = __DIR__ . '/class';
$dir = scandir($directory);
$oracles = array_filter($dir, function ($val) {
return strpos($val, '_oracle'); // returns > 0 if true else 0, interprets as false.
});
foreach ($oracles as $oracle) {
$type = substr($oracle, 0, -11); // includes _oracle.php 11 characters.
$phpFile = __DIR__ . '/class/' . $oracle;
//Exempt file.
if (strtoupper($type) !== 'COMMON' && strtoupper($type) !== 'ERROR') {
if(is_file($phpFile)) {
print shell_exec('php Eval.php --file=' . $phpFile); // Run to Eval.php file.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment