array( 'win', 'UWIN', ), 'mac' => array( 'mac', 'darwin', ), 'linux' => array( 'linux', 'cygwin', 'GNU', 'FreeBSD', 'OpenBSD', 'NetBSD', ), ); $sysOS = strtolower(PHP_OS); foreach ($osList as $osName => $osSystem) { if (preg_match('/^('.implode('|', $osSystem).')/i', $sysOS)) { return $osName; } } return false; } /** * Get root directory of EspoCRM * * @return string */ public function getRootDir() { $bPath = realpath('bootstrap.php'); $rootDir = dirname($bPath); return $rootDir; } /** * Get path to PHP * * @return string */ public function getPhpBin() { if (isset($_SERVER['PHP_PATH']) && !empty($_SERVER['PHP_PATH'])) { return $_SERVER['PHP_PATH']; } $phpBin = @exec('which php'); if (!empty($phpBin)) { return $phpBin; } return defined("PHP_BINDIR") ? PHP_BINDIR . DIRECTORY_SEPARATOR . 'php' : 'php'; } /** * Get PHP binary * * @return string */ public function getPhpBinary() { return defined("PHP_BINARY") ? PHP_BINARY : 'php'; } /** * Get php version (only digits and dots) * * @return string */ public static function getPhpVersion() { $version = phpversion(); if (preg_match('/^[0-9\.]+[0-9]/', $version, $matches)) { return $matches[0]; } return $version; } public function getPhpParam($name) { return ini_get($name); } public function hasPhpLib($name) { return extension_loaded($name); } public static function getPid() { if (function_exists('getmypid')) { return getmypid(); } } public static function isProcessActive($pid) { if (empty($pid)) return false; if (!self::isPosixSupported()) return false; if (posix_getsid($pid) === false) return false; return true; } public static function isPosixSupported() { return function_exists('posix_getsid'); } }