From 522aafcd145be06373a3f1769a37d47b70654468 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Tue, 9 Jun 2015 21:50:16 +0200 Subject: [PATCH] (mvc) add backend call function with easier parameter handling --- .../mvc/app/library/OPNsense/Core/Backend.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php b/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php index 579437ed8..b263e6bb4 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Backend.php @@ -95,6 +95,24 @@ class Backend return str_replace($endOfStream, "", $resp); } + /** + * send event to backend using command parameter list (which will be quoted for proper handling) + * @param string $event event string + * @param array $params list of parameters to send with command + * @param bool $detach detach process + * @param int $timeout timeout in seconds + * @return string + * @throws \Exception + */ + public function configdpRun($event, $params = array(), $detach = false, $timeout = 120) + { + foreach ($params as $param) { + // quote parameters + $event .= ' "' . str_replace('"', '\\"', $param) . '"'; + } + + return $this->configdRun($event, $detach, $timeout); + } /** * @return int last restart timestamp