Skip to content

Commit

Permalink
Fixes for phar
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Mar 21, 2018
1 parent 5db10dd commit a18918c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/danog/PrimeModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ public static function python_single($what)
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)) {
return false;
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)) {
Expand Down Expand Up @@ -116,7 +121,12 @@ public static function python_single_alt($what)
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)) {
return false;
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)) {
Expand Down

0 comments on commit a18918c

Please sign in to comment.