mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
system: yup yup #6376
Most likely this is backend material which needs to be filtered/ used to render page content and react on via formalized API request in order to avoid leaking data. The nice thing about the filtering is that we only ever have to look up service status for matching services making the lookup faster.
This commit is contained in:
parent
c56bb65762
commit
0fc88f2d3d
@ -12,6 +12,6 @@ message:Reloading all
|
||||
|
||||
[list]
|
||||
command:/usr/local/sbin/pluginctl -S
|
||||
parameters:
|
||||
parameters:%s %s
|
||||
type:script_output
|
||||
message:Fetching service list
|
||||
message:Fetching service list (%s %s)
|
||||
|
||||
@ -101,7 +101,22 @@ if (isset($opts['h'])) {
|
||||
}
|
||||
}
|
||||
} elseif (isset($opts['S'])) {
|
||||
echo json_encode(plugins_services(), JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT) . PHP_EOL;
|
||||
$services = [];
|
||||
foreach (plugins_services() as $service) {
|
||||
/* fail if name filter does not match */
|
||||
if (!empty($args[0]) && $service['name'] != $args[0]) {
|
||||
continue;
|
||||
}
|
||||
/* fail if ID lookup is not possible or does not match */
|
||||
if (isset($args[1]) && $args[1] !== '' && (!array_key_exists('id', $service) || $service['id'] != $args[1])) {
|
||||
continue;
|
||||
}
|
||||
/* fetch status so the caller does not have to */
|
||||
$service['status'] = service_status($service);
|
||||
/* collect all matches contrary to what service_by_name() is doing */
|
||||
$services[] = $service;
|
||||
}
|
||||
echo json_encode($services, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT) . PHP_EOL;
|
||||
} elseif (isset($opts['s'])) {
|
||||
$name = !empty($args[0]) ? $args[0] : '';
|
||||
$act = !empty($args[1]) ? $args[1] : '';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user