You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
<?php
|
|
|
|
namespace utils;
|
|
|
|
class php {
|
|
|
|
private static function r_sapi($ver) {
|
|
if (is_string_found($ver, "-s ") && is_string_found($ver, "-v ")) {
|
|
return $ver;
|
|
}
|
|
return match($ver) {
|
|
"cli"=>"-s cli ",
|
|
"fpm"=>"-s fpm ",
|
|
"apache2"=>"-s apache2 ",
|
|
false=>"",
|
|
default=>"-v " . $ver . " ",
|
|
};
|
|
}
|
|
|
|
public static function enable_module($name, $ver = false) {
|
|
exec(\neato::get_super_user_bin . 'phpenmod ' . self::r_sapi($ver) . safe_cmd_quotes($name), $output, $exit_code);
|
|
check_for_error($exit_code, "PHP Unable to enable module: {$name}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function disable_module($name, $ver = false) {
|
|
exec(\neato::get_super_user_bin . 'phpdismod ' . self::r_sapi($ver) . safe_cmd_quotes($name), $output, $exit_code);
|
|
check_for_error($exit_code, "PHP Unable to disable module: {$name}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function query_module($name, $version, $sapi, $display = false) {
|
|
switch ($sapi) {
|
|
case "cli":
|
|
$api = "-s cli ";
|
|
break;
|
|
case "fpm":
|
|
$api = "-s fpm ";
|
|
break;
|
|
case "apache2":
|
|
$api = "-s apache2 ";
|
|
break;
|
|
default:
|
|
return false;
|
|
}
|
|
$ver = "-v {$version} ";
|
|
$module_name = "-m {$name}";
|
|
exec(\neato::get_super_user_bin . 'phpquery ' . $ver . $api . safe_cmd_quotes($module_name), $output, $exit_code);
|
|
if ($display === true) {
|
|
check_for_error($exit_code, "PHP module not enabled: {$name}");
|
|
}
|
|
return $exit_code;
|
|
}
|
|
|
|
} |