",implode(' ', $errors), "

"; // exit; //} // //foreach($xml->children() as $response) foreach($response->children() as $data) //{ // $nodemonstat = $data; //} switch($action) { case "stop": monstop($name); break; case "restart": monrestart($name); break; case "start": monstart($name); break; default: break; } function monstop($plugin) { $xml = docmd("monstop", "", array("$plugin","-r")); return 0; } function monrestart($plugin) { $xml = docmd("monstop", "", array("$plugin", "-r")); if(getXmlErrors($xml, $errors)) { echo "

",implode(' ', $errors), "

"; exit; } $xml = docmd("moncfg", "", array("$plugin", "-r")); if(getXmlErrors($xml, $errors)) { echo "

",implode(' ', $errors), "

"; exit; } $xml = docmd("monstart", "", array("$plugin", "-r")); return 0; } function monstart($plugin) { //Before running "monstart", the command "monls" is used to check $xml = docmd("monls","", NULL); if(getXmlErrors($xml, $errors)) { echo "

",implode(' ', $errors), "

"; exit; } $has_plugin = false; if(count($xml->children()) != 0) { foreach($xml->children() as $response) foreach($response->children() as $data) { $arr = preg_split("/\s+/", $data); if($arr[0] == $plugin) { $has_plugin = true; } } } if($has_plugin == false) { //if $has_plugin == false, that means the plugin is not added into the monitoring table $xml = docmd("monadd",'', array("$plugin")); if(getXmlErrors($xml, $errors)) { echo "

",implode(' ', $errors), "

"; exit; } } //we have to make sure that the plugin is added in the "monitoring" table $xml = docmd("monstart", "", array("$plugin", "-r")); return 0; } ?>