1
0
mirror of https://github.com/danog/PrimeModule.git synced 2024-11-26 20:34:37 +01:00

Fixes for phar

This commit is contained in:
Daniil Gentili 2018-03-21 11:47:51 +01:00
parent 5db10ddfc6
commit a18918c409

View File

@ -81,9 +81,14 @@ class PrimeModule
{
if (function_exists('shell_exec')) {
$res = trim(shell_exec('timeout 10 python '.__DIR__.'/prime.py '.$what.' 2>&1'));
if ($res == '' || is_null($res) || !is_numeric($res)) {
copy(__DIR__.'/prime.py', getcwd().'/.prime.py');
$res = trim(shell_exec('timeout 10 python '.getcwd().'/.prime.py '.$what.' 2>&1'));
unlink(getcwd().'/.prime.py');
if ($res == '' || is_null($res) || !is_numeric($res)) {
return false;
}
}
$newval = intval($res);
if (is_int($newval)) {
$res = $newval;
@ -115,9 +120,14 @@ class PrimeModule
{
if (function_exists('shell_exec')) {
$res = trim(shell_exec('python '.__DIR__.'/alt_prime.py '.$what.' 2>&1'));
if ($res == '' || is_null($res) || !is_numeric($res)) {
copy(__DIR__.'/alt_prime.py', getcwd().'/.alt_prime.py');
$res = trim(shell_exec('python '.getcwd().'/.alt_prime.py '.$what.' 2>&1'));
unlink(getcwd().'/.alt_prime.py');
if ($res == '' || is_null($res) || !is_numeric($res)) {
return false;
}
}
$newval = intval($res);
if (is_int($newval)) {
$res = $newval;