Improve getPHPExecutableFromPath()
phpipam open-source IP address management
Brought to you by:
myha
On Linux and certain install, env variable PATH is not available (nginx+fpm), so PHP executable is never found.
We could rewrite function getPHPExecutableFromPath() in functions/functions-common.php to check additional paths :
<?php
function getPHPExecutableFromPath()
{
$paths = explode(PATH_SEPARATOR, getenv('PATH'));
foreach ($paths as $path) {
// we need this for XAMPP (Windows)
if (strstr($path, 'php.exe') && isset($_SERVER["WINDIR"]) && file_exists($path) && is_file($path)) {
return $path;
}
else {
$php_executable = $path . DIRECTORY_SEPARATOR . "php" . (isset($_SERVER["WINDIR"]) ? ".exe" : "");
if (file_exists($php_executable) && is_file($php_executable)) {
return $php_executable;
}
}
}
// Nothing found yet ? Linux ?
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
$paths = array('/bin', '/usr/bin', '/usr/local/bin');
foreach ($paths as $path) {
if (file_exists($path.'/php'))
return $path.'/php';
}
}
return FALSE; // not found
}
Anonymous
Hi, I have change lots of this in latest dev release, returning also the error code if ping fails.
For above it seems there is a PHP_BINDIR constant that can be used instead of this for linux: