|
|
|
@ -29,9 +29,36 @@ if (is_cli() === false) { |
|
|
|
exit(1); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getOSInformation() { |
|
|
|
function get_Windows_version() { |
|
|
|
|
|
|
|
$os_info = php_uname(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Regular expression pattern to extract version and build number |
|
|
|
|
|
|
|
$pattern = '/Windows\sNT\s(\d+\.\d+).*build\s(\d+)/'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Perform the regular expression match |
|
|
|
|
|
|
|
preg_match($pattern, $os_info, $matches); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if the match was successful |
|
|
|
|
|
|
|
if ($matches && count($matches) >= 3) { |
|
|
|
|
|
|
|
// Extracted version and build number |
|
|
|
|
|
|
|
$version = $matches[1]; |
|
|
|
|
|
|
|
$build_number = $matches[2]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Return as an array |
|
|
|
|
|
|
|
return ['version' => $version, 'build' => $build_number]; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// Return an empty array or handle the case when information is not found |
|
|
|
|
|
|
|
return []; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function get_OS_information() { |
|
|
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
|
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
|
|
return ['name' => 'Windows']; |
|
|
|
// Get Windows version information |
|
|
|
|
|
|
|
$windows_version = get_Windows_version(); |
|
|
|
|
|
|
|
$build = $windows_version['build'] ?? false; |
|
|
|
|
|
|
|
$version = $windows_version['version'] ?? false; |
|
|
|
|
|
|
|
return ['name' => 'Windows', 'id' => 'win', 'build'=>$build, 'version_id'=>$version, 'id_like'=>'Windows']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (false == function_exists("shell_exec") || false == is_readable("/etc/os-release")) { |
|
|
|
if (false == function_exists("shell_exec") || false == is_readable("/etc/os-release")) { |
|
|
|
@ -39,21 +66,21 @@ function getOSInformation() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$os = shell_exec('cat /etc/os-release'); |
|
|
|
$os = shell_exec('cat /etc/os-release'); |
|
|
|
$listIds = preg_match_all('/.*=/', $os, $matchListIds); |
|
|
|
$list_ids = preg_match_all('/.*=/', $os, $match_list_ids); |
|
|
|
$listIds = $matchListIds[0]; |
|
|
|
$list_ids = $match_list_ids[0]; |
|
|
|
|
|
|
|
|
|
|
|
$listVal = preg_match_all('/=.*/', $os, $matchListVal); |
|
|
|
$list_val = preg_match_all('/=.*/', $os, $match_list_val); |
|
|
|
$listVal = $matchListVal[0]; |
|
|
|
$list_val = $match_list_val[0]; |
|
|
|
|
|
|
|
|
|
|
|
array_walk($listIds, function(&$v, $k) { |
|
|
|
array_walk($list_ids, function(&$v, $k) { |
|
|
|
$v = strtolower(str_replace('=', '', $v)); |
|
|
|
$v = strtolower(str_replace('=', '', $v)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
array_walk($listVal, function(&$v, $k) { |
|
|
|
array_walk($list_val, function(&$v, $k) { |
|
|
|
$v = preg_replace('/=|"/', '', $v); |
|
|
|
$v = preg_replace('/=|"/', '', $v); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return array_combine($listIds, $listVal); |
|
|
|
return array_combine($list_ids, $list_val); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function is_string_found(string $data, string $find): bool { |
|
|
|
function is_string_found(string $data, string $find): bool { |
|
|
|
@ -68,7 +95,7 @@ function get_right(string $str, int $length): string { |
|
|
|
return substr($str, -$length); |
|
|
|
return substr($str, -$length); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$os = getOSInformation(); |
|
|
|
$os = get_OS_information(); |
|
|
|
$osVer = (isset($os['version_id'])) ? $os['version_id'] : false; |
|
|
|
$osVer = (isset($os['version_id'])) ? $os['version_id'] : false; |
|
|
|
$codeName = (isset($os['version_codename'])) ? $os['version_codename'] : false; |
|
|
|
$codeName = (isset($os['version_codename'])) ? $os['version_codename'] : false; |
|
|
|
$os_like = (isset($os['id_like'])) ? $os['id_like'] : false; |
|
|
|
$os_like = (isset($os['id_like'])) ? $os['id_like'] : false; |