private function fetchPluginInfo($deployment, $action, $redirect, $modrevision) { $pluginInfo = array(); $pluginInfo['name'] = $this->getParam('name'); $pluginInfo['desc'] = $this->getParam('desc'); $pluginInfo['location'] = $this->getParam('location'); $pluginInfo['file'] = $this->fetchUploadedFile('file'); foreach ($pluginInfo as $key => $value) { if ($value === false) { if ($key == 'file') { $oldfile = $this->getParam('useoldfile'); if ($oldfile == 1) { $pluginInfo['file'] = base64_decode(RevDeploy::getDeploymentNagiosPluginFileContents($deployment, $pluginInfo['name'], $modrevision)); continue; } } if ($key != 'location' && $pluginInfo['location'] !== false) { $pluginInfo['location'] = base64_encode($pluginInfo['location']); } $viewData = new ViewData(); $viewData->error = "Unable to detect {$key} param"; $viewData->deployment = $deployment; $viewData->action = $action; $viewData->plugin = $pluginInfo; $this->sendResponse($redirect, $viewData); } } $pluginInfo['md5'] = md5($pluginInfo['file']); $pluginInfo['location'] = base64_encode($pluginInfo['location']); $pluginInfo['file'] = base64_encode($pluginInfo['file']); return $pluginInfo; }
/** * _getPlugins - get plugins for nagios / nrpe and return their contents * * @param mixed $mode mode driving where the plugins are fetched from * @param mixed $deployment deployment we are referencing * @param mixed $revision revision we are referencing * @param mixed $plugins plugins we are referencing * * @static * @access private * @return void */ private static function _getPlugins($mode, $deployment, $revision, $plugins) { $results = array(); foreach ($plugins as $plugin) { if ($mode == 'nrpe-core') { $tmpInfo = RevDeploy::getDeploymentNRPEPluginFileContents($deployment, $plugin, $revision); } elseif ($mode == 'nrpe-sup') { $tmpInfo = RevDeploy::getDeploymentSupNRPEPluginFileContents($deployment, $plugin, $revision); } elseif ($mode == 'nagios') { $tmpInfo = RevDeploy::getDeploymentNagiosPluginFileContents($deployment, $plugin, $revision); } if ($tmpInfo !== false) { $results[$plugin] = base64_decode($tmpInfo); } else { $results[$plugin] = ""; } } return $results; }