Last active
February 26, 2020 01:24
-
-
Save ChaosPower/2a9fdb62e7013d2ccd2f9a145708ed2e to your computer and use it in GitHub Desktop.
PHP CLI Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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