private static function check_bin($binPath = '') { $binPath = $binPath ?: '/usr/bin/git'; $resource = proc_open('which git', [1 => ['pipe', 'w']], $pipes); $stdout = stream_get_contents($pipes[1]); foreach ($pipes as $pipe) { fclose($pipe); } $status = trim(proc_close($resource)); if (!$status) { $binPath = trim($stdout); } if (strpos($binPath, ' ') !== false) { $binPath = nzedb\utility\Misc::isWin() ? '"' . $binPath . '"' : str_replace(' ', '\\ ', $binPath); } self::set_bin($binPath); return $binPath; }
foreach ($check as $type) { switch ($type) { case R: readable($folder); break; case W: writable($folder); break; case E: executable($folder); break; } } } echo 'Your permissions seem right for this user. Note, this script does not verify all paths, only the most important ones.' . PHP_EOL; if (!nzedb\utility\Misc::isWin()) { $user = posix_getpwuid(posix_geteuid()); if ($user['name'] !== 'www-data') { echo 'If you have not already done so, please rerun this script using the www-data user: sudo -u www-data php verify_permissions.php yes' . PHP_EOL; } } function readable($folder) { if (!is_readable($folder)) { exit('Error: This path is not readable: (' . $folder . ') resolve this and rerun the script.' . PHP_EOL); } } function writable($folder) { if (!is_writable($folder)) { exit('Error: This path is not writable: (' . $folder . ') resolve this and rerun the script.' . PHP_EOL);