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.
60 lines
1.8 KiB
60 lines
1.8 KiB
<?php
|
|
|
|
namespace utils;
|
|
|
|
class php {
|
|
|
|
function r_sapi($ver) {
|
|
if (is_string_found($ver, "-s ") && is_string_found($ver, "-v ")) {
|
|
return $ver;
|
|
}
|
|
switch ($ver) {
|
|
case "cli":
|
|
return "-s cli ";
|
|
case "fpm":
|
|
return "-s fpm ";
|
|
case "apache2":
|
|
return "-s apache2 ";
|
|
case false:
|
|
return "";
|
|
default:
|
|
return "-v " . $ver . " ";
|
|
}
|
|
}
|
|
|
|
public static function enable_module($name, $ver = false) {
|
|
exec(\neato::get_super_user_bin . 'phpenmod ' . 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 ' . 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;
|
|
}
|
|
|
|
} |