$templateInfo['services'] = $request->post('services'); $templateInfo['hosttemplate'] = $request->post('hosttemplate'); $templateInfo['regex'] = $request->post('regex'); $templateInfo['nregex'] = $request->post('nregex'); $templateInfo['hostgroup'] = $request->post('hostgroup'); $templateInfo['stdtemplate'] = $request->post('stdtemplate'); $templateInfo['nservices'] = $request->post('nservices'); $templateInfo['subdeployment'] = $request->post('subdeployment'); } $templateInfo['type'] = 'dynamic'; if (!isset($templateInfo['name']) || empty($templateInfo['name'])) { $apiResponse = new APIViewData(1, $deployment, "Unable to detect name parameter (name to call the matrix mapping)"); $app->halt(404, $apiResponse->returnJson()); } elseif (preg_match_all('/[^a-zA-Z0-9_-]/s', $templateInfo['name'], $forbidden)) { $apiResponse = new APIViewData(1, $deployment, "Unable to use template name specified, detected forbidden characters " . implode('', array_unique($forbidden[0]))); $apiResponse->setDeployment($deployment); $app->halt(404, $apiResponse->returnJson()); } elseif (!isset($templateInfo['regex']) || empty($templateInfo['regex'])) { $apiResponse = new APIViewData(1, $deployment, "Unable to detect regex parameter (host regex used to apply information against"); $app->halt(404, $apiResponse->returnJson()); } if ((!isset($templateInfo['services']) || empty($templateInfo['services'])) && (!isset($templateInfo['hosttemplate']) || empty($templateInfo['hosttemplate'])) && (!isset($templateInfo['stdtemplate']) || empty($templateInfo['stdtemplate'])) && (!isset($templateInfo['hostgroup']) || empty($templateInfo['hostgroup']))) { $apiResponse = new APIViewData(1, $deployment, "Unable to detect any appropriate parameter to apply to template ( services, hosttemplate, stdtemplate, hostgroup )"); $app->halt(404, $apiResponse->returnJson()); } if (isset($templateInfo['services']) && !empty($templateInfo['services'])) { if (preg_match('/,/', $templateInfo['services'])) { $templateInfo['services'] = preg_replace('/\\s?,\\s?/', ',', $templateInfo['services']); } elseif (is_array($templateInfo['services'])) { $templateInfo['services'] = implode(',', $templateInfo['services']); }