Changeset 6202
- Timestamp:
- 08/20/08 13:44:57 (5 months ago)
- Location:
- trunk/centreon/www/include/configuration/configObject
- Files:
-
- 20 modified
-
command/DB-Func.php (modified) (11 diffs)
-
command/command.php (modified) (1 diff)
-
command/formCommand.ihtml (modified) (1 diff)
-
command/formCommand.php (modified) (10 diffs)
-
command/listCommand.ihtml (modified) (4 diffs)
-
command/listCommand.php (modified) (12 diffs)
-
command/minCommand.php (modified) (5 diffs)
-
command/minHelpCommand.php (modified) (4 diffs)
-
command/minPlayCommand.php (modified) (7 diffs)
-
command_categories/DB-Func.php (modified) (5 diffs)
-
command_categories/commandCategories.php (modified) (1 diff)
-
command_categories/formCommandCategories.ihtml (modified) (1 diff)
-
command_categories/formCommandCategories.php (modified) (9 diffs)
-
command_categories/listCommandCategories.ihtml (modified) (4 diffs)
-
command_categories/listCommandCategories.php (modified) (7 diffs)
-
contactgroup/DB-Func.php (modified) (9 diffs)
-
contactgroup/contactGroup.php (modified) (1 diff)
-
contactgroup/formContactGroup.php (modified) (9 diffs)
-
contactgroup/listContactGroup.ihtml (modified) (5 diffs)
-
contactgroup/listContactGroup.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/centreon/www/include/configuration/configObject/command/DB-Func.php
r5226 r6202 16 16 */ 17 17 18 19 18 if (!isset ($oreon)) 20 19 exit (); … … 23 22 global $pearDB, $form; 24 23 $id = NULL; 24 25 25 if (isset($form)) 26 26 $id = $form->getSubmitValue('command_id'); 27 $DBRESULT =& $pearDB->query("SELECT command_name, command_id FROM command WHERE command_name = '".htmlentities($name, ENT_QUOTES)."'"); 27 28 $DBRESULT =& $pearDB->query("SELECT `command_name`, `command_id` FROM `command` WHERE `command_name` = '".htmlentities($name, ENT_QUOTES)."'"); 28 29 if (PEAR::isError($DBRESULT)) 29 30 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 30 31 $command =& $DBRESULT->fetchRow(); 31 #Modif case 32 if ($DBRESULT->numRows() >= 1 && $command["command_id"] == $id) 32 if ($DBRESULT->numRows() >= 1 && $command["command_id"] == $id) { 33 /* 34 * Mofication case 35 */ 33 36 return true; 34 #Duplicate entry 35 else if ($DBRESULT->numRows() >= 1 && $command["command_id"] != $id) 37 } else if ($DBRESULT->numRows() >= 1 && $command["command_id"] != $id) { 38 /* 39 * Duplicate case 40 */ 36 41 return false; 37 else42 } else 38 43 return true; 39 44 } … … 41 46 function deleteCommandInDB ($commands = array()) { 42 47 global $pearDB; 43 foreach($commands as $key=>$value) { 44 $DBRESULT =& $pearDB->query("DELETE FROM command WHERE command_id = '".$key."'"); 48 49 foreach ($commands as $key => $value) { 50 $DBRESULT =& $pearDB->query("DELETE FROM `command` WHERE `command_id` = '".$key."'"); 45 51 if (PEAR::isError($DBRESULT)) 46 52 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; … … 49 55 50 56 function multipleCommandInDB ($commands = array(), $nbrDup = array()) { 51 foreach($commands as $key=>$value) { 52 global $pearDB; 53 $DBRESULT =& $pearDB->query("SELECT * FROM command WHERE command_id = '".$key."' LIMIT 1"); 57 global $pearDB; 58 59 foreach($commands as $key => $value) { 60 61 $DBRESULT =& $pearDB->query("SELECT * FROM `command` WHERE `command_id` = '".$key."' LIMIT 1"); 54 62 if (PEAR::isError($DBRESULT)) 55 63 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 64 56 65 $row = $DBRESULT->fetchRow(); 57 66 $row["command_id"] = ''; 67 58 68 for ($i = 1; $i <= $nbrDup[$key]; $i++) { 59 69 $val = null; 70 60 71 foreach ($row as $key2=>$value2) { 61 $key2 == " command_name" ? ($command_name = $value2 = $value2."_".$i) : null;72 $key2 == "`command_name`" ? ($command_name = $value2 = $value2."_".$i) : null; 62 73 $val ? $val .= ($value2 != NULL?(", '".$value2."'"):", NULL") : $val .= ($value2 != NULL?("'".$value2."'"):"NULL"); 63 74 } 75 64 76 if (testCmdExistence($command_name)) { 65 $val ? $rq = "INSERT INTO commandVALUES (".$val.")" : $rq = null;77 $val ? $rq = "INSERT INTO `command` VALUES (".$val.")" : $rq = null; 66 78 $DBRESULT =& $pearDB->query($rq); 67 79 if (PEAR::isError($DBRESULT)) … … 78 90 79 91 function updateCommand($cmd_id = null) { 80 if (!$cmd_id) return; 81 global $form; 82 global $pearDB; 92 global $form, $pearDB; 93 94 if (!$cmd_id) 95 return; 96 83 97 $ret = array(); 84 98 $ret = $form->getSubmitValues(); 99 85 100 set_magic_quotes_runtime(1); 101 86 102 $ret["command_line"] = str_replace('\n', "#BR#", $ret["command_line"]); 87 103 $ret["command_line"] = str_replace('\t', "#T#", $ret["command_line"]); … … 89 105 $ret["command_line"] = str_replace('/', "#S#", $ret["command_line"]); 90 106 $ret["command_line"] = str_replace('\\', "#BS#", $ret["command_line"]); 91 $ret["command_example"] = str_replace("\n", "#BR#", $ret["command_example"]); 92 $ret["command_example"] = str_replace("\t", "#T#", $ret["command_example"]); 93 $ret["command_example"] = str_replace("\r", "#R#", $ret["command_example"]); 107 108 $ret["command_example"] = str_replace('\n', "#BR#", $ret["command_example"]); 109 $ret["command_example"] = str_replace('\t', "#T#", $ret["command_example"]); 110 $ret["command_example"] = str_replace('\r', "#R#", $ret["command_example"]); 94 111 $ret["command_example"] = str_replace('/', "#S#", $ret["command_example"]); 95 112 $ret["command_example"] = str_replace('\\', "#BS#", $ret["command_example"]); 96 $rq = "UPDATE command ";97 $rq .= "SET command_name= '".htmlentities($ret["command_name"], ENT_QUOTES)."', " .98 " command_line= '".htmlentities($ret["command_line"], ENT_QUOTES)."', " .99 " command_example= '".htmlentities($ret["command_example"], ENT_QUOTES)."', " .100 " command_type= '".htmlentities($ret["command_type"]["command_type"], ENT_QUOTES)."', " .101 " graph_id= '".htmlentities($ret["graph_id"], ENT_QUOTES)."' " .102 "WHERE command_id= '".$cmd_id."'";113 114 $rq = "UPDATE `command` SET `command_name` = '".htmlentities($ret["command_name"], ENT_QUOTES)."', " . 115 "`command_line` = '".htmlentities($ret["command_line"], ENT_QUOTES)."', " . 116 "`command_example` = '".htmlentities($ret["command_example"], ENT_QUOTES)."', " . 117 "`command_type` = '".htmlentities($ret["command_type"]["command_type"], ENT_QUOTES)."', " . 118 "`graph_id` = '".htmlentities($ret["graph_id"], ENT_QUOTES)."' " . 119 "WHERE `command_id` = '".$cmd_id."'"; 103 120 $DBRESULT =& $pearDB->query($rq); 104 121 if (PEAR::isError($DBRESULT)) … … 112 129 113 130 function insertCommand($ret = array()) { 114 global $form; 115 global $pearDB; 131 global $form, $pearDB; 116 132 if (!count($ret)) 117 133 $ret = $form->getSubmitValues(); 118 134 set_magic_quotes_runtime(1); 135 119 136 $ret["command_line"] = str_replace("\n", "#BR#", $ret["command_line"]); 120 137 $ret["command_line"] = str_replace("\t", "#T#", $ret["command_line"]); … … 122 139 $ret["command_line"] = str_replace('/', "#S#", $ret["command_line"]); 123 140 $ret["command_line"] = str_replace('\\', "#BS#", $ret["command_line"]); 141 124 142 $ret["command_example"] = str_replace("\n", "#BR#", $ret["command_example"]); 125 143 $ret["command_example"] = str_replace("\t", "#T#", $ret["command_example"]); … … 127 145 $ret["command_example"] = str_replace('/', "#S#", $ret["command_example"]); 128 146 $ret["command_example"] = str_replace('\\', "#BS#", $ret["command_example"]); 129 $rq = "INSERT INTO command "; 130 $rq .= "(command_name, command_line, command_example, command_type, graph_id) "; 131 $rq .= "VALUES "; 132 $rq .= "('".htmlentities($ret["command_name"], ENT_QUOTES)."', '".htmlentities($ret["command_line"], ENT_QUOTES)."', '".htmlentities($ret["command_example"], ENT_QUOTES)."', '".$ret["command_type"]["command_type"]."', '".$ret["graph_id"]."')"; 147 148 /* 149 * Insert 150 */ 151 $rq = "INSERT INTO `command` (`command_name`, `command_line`, `command_example`, `command_type`, `graph_id`) "; 152 $rq .= "VALUES ('".htmlentities($ret["command_name"], ENT_QUOTES)."', '".htmlentities($ret["command_line"], ENT_QUOTES)."', '".htmlentities($ret["command_example"], ENT_QUOTES)."', '".$ret["command_type"]["command_type"]."', '".$ret["graph_id"]."')"; 133 153 $DBRESULT =& $pearDB->query($rq); 134 154 if (PEAR::isError($DBRESULT)) 135 155 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 136 $DBRESULT =& $pearDB->query("SELECT MAX(command_id) FROM command"); 156 157 /* 158 * Get Max ID 159 */ 160 $DBRESULT =& $pearDB->query("SELECT MAX(command_id) FROM `command`"); 137 161 if (PEAR::isError($DBRESULT)) 138 162 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 139 163 $cmd_id = $DBRESULT->fetchRow(); 164 140 165 return ($cmd_id["MAX(command_id)"]); 141 166 } … … 144 169 global $oreon; 145 170 $plugins = array(); 146 $is_not_a_plugin = array("." =>".", ".."=>"..", "oreon.conf"=>"oreon.conf", "oreon.pm"=>"oreon.pm", "utils.pm"=>"utils.pm", "negate"=>"negate");171 $is_not_a_plugin = array("." => 1, ".." => 1, "oreon.conf" => 1, "oreon.pm" => 1, "utils.pm" => 1, "negate" => 1, "centreon.conf" => 1, "centreon.pm" => 1); 147 172 $handle[$rep] = opendir($rep); 148 173 while (false !== ($filename = readdir($handle[$rep]))){ … … 152 177 $plugins = array_merge($plugins, $plg_tmp); 153 178 unset($plg_tmp); 154 } else if (! array_key_exists($filename, $is_not_a_plugin) && substr($filename, -1)!= "~"){179 } else if (!isset($is_not_a_plugin[$filename]) && substr($filename, -1)!= "~"){ 155 180 $key = substr($rep."/".$filename, strlen($oreon->optGen["nagios_path_plugins"])); 156 181 $plugins[$key] = $key; -
trunk/centreon/www/include/configuration/configObject/command/command.php
r6145 r6202 64 64 } 65 65 66 if ($min) 66 if ($min) { 67 67 switch ($o) { 68 case "h" : require_once($path."minHelpCommand.php"); break; #Show Help Command # Wistof 69 case "p" : require_once($path."minPlayCommand.php"); break; #Test the plugin 70 default : require_once($path."minCommand.php"); break; 68 case "h" : 69 /* 70 * Show Help Command 71 */ 72 require_once($path."minHelpCommand.php"); 73 break; 74 case "p" : 75 /* 76 * Test the plugin 77 */ 78 require_once($path."minPlayCommand.php"); 79 break; 80 default : 81 require_once($path."minCommand.php"); 82 break; 71 83 } 72 else84 } else { 73 85 switch ($o) { 74 case "a" : require_once($path."formCommand.php"); break; #Add a Command 75 case "w" : require_once($path."formCommand.php"); break; #Watch a Command 76 case "c" : require_once($path."formCommand.php"); break; #Modify a Command 77 case "m" : multipleCommandInDB(isset($select) ? $select : array(), $dupNbr); require_once($path."listCommand.php"); break; #Duplicate n Commands 78 case "d" : deleteCommandInDB(isset($select) ? $select : array()); require_once($path."listCommand.php"); break; #Delete n Commands 79 default : require_once($path."listCommand.php"); break; 86 case "a" : 87 /* 88 * Add a Command 89 */ 90 require_once($path."formCommand.php"); 91 break; 92 case "w" : 93 /* 94 * Watch a Command 95 */ 96 require_once($path."formCommand.php"); 97 break; 98 case "c" : 99 /* 100 * Modify a Command 101 */ 102 require_once($path."formCommand.php"); 103 break; 104 case "m" : 105 /* 106 * Duplicate n Commands 107 */ 108 multipleCommandInDB(isset($select) ? $select : array(), $dupNbr); 109 require_once($path."listCommand.php"); 110 break; 111 case "d" : 112 /* 113 * Delete n Commands 114 */ 115 deleteCommandInDB(isset($select) ? $select : array()); 116 require_once($path."listCommand.php"); 117 break; 118 default : 119 require_once($path."listCommand.php"); 120 break; 80 121 } 122 } 81 123 ?> -
trunk/centreon/www/include/configuration/configObject/command/formCommand.ihtml
r5379 r6202 1 1 {$form.javascript} 2 {$insertValueQuery} 2 <script type='text/javascript'> 3 <!-- 4 function insertValueQuery(elem) { 5 var myQuery = document.Form.command_line; 6 if(elem == 1) { 7 var myListBox = document.Form.resource; 8 } else if (elem == 2) { 9 var myListBox = document.Form.plugins; 10 } else if (elem == 3) { 11 var myListBox = document.Form.macros; 12 } 13 if (myListBox.options.length > 0) { 14 var chaineAj = ''; 15 var NbSelect = 0; 16 for(var i=0; i<myListBox.options.length; i++) { 17 if (myListBox.options[i].selected){ 18 NbSelect++; 19 if (NbSelect > 1) 20 chaineAj += ', '; 21 chaineAj += myListBox.options[i].value; 22 } 23 } 24 25 if (document.selection) { 26 // IE support 27 myQuery.focus(); 28 sel = document.selection.createRange(); 29 sel.text = chaineAj; 30 document.Form.insert.focus(); 31 } else if (document.Form.command_line.selectionStart || document.Form.command_line.selectionStart == '0') { 32 // MOZILLA/NETSCAPE support 33 var startPos = document.Form.command_line.selectionStart; 34 var endPos = document.Form.command_line.selectionEnd; 35 var chaineSql = document.Form.command_line.value; 36 myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length); 37 } else { 38 myQuery.value += chaineAj; 39 } 40 } 41 } 42 //--> 43 </script> 3 44 <form {$form.attributes}> 4 45 <div id="validFormTop"> -
trunk/centreon/www/include/configuration/configObject/command/formCommand.php
r6061 r6202 16 16 */ 17 17 18 # 19 ## Database retrieve information for Command 20 # 21 function myDecodeCommand($arg) { 18 /* 19 * Form Rules 20 */ 21 22 function myReplace() { 23 global $form; 24 $ret = $form->getSubmitValues(); 25 return (str_replace(" ", "_", $ret["command_name"])); 26 } 27 28 /* 29 * Database retrieve information for Command 30 */ 31 function myDecodeCommand($arg) { 22 32 $arg = html_entity_decode($arg, ENT_QUOTES); 23 33 $arg = str_replace('#BR#', "\\n", $arg); … … 32 42 $cmd = array(); 33 43 if (($o == "c" || $o == "w") && $command_id) { 34 $DBRESULT =& $pearDB->query("SELECT * FROM command WHERE command_id= '".$command_id."' LIMIT 1");44 $DBRESULT =& $pearDB->query("SELECT * FROM `command` WHERE `command_id` = '".$command_id."' LIMIT 1"); 35 45 if (PEAR::isError($DBRESULT)) 36 46 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; … … 38 48 $cmd = array_map("myDecodeCommand", $DBRESULT->fetchRow()); 39 49 } 40 # 41 ## Database retrieve information for differents elements list we need on the page 42 # 43 # Resource Macro 50 51 /* 52 * Resource Macro 53 */ 54 44 55 $resource = array(); 45 $DBRESULT =& $pearDB->query("SELECT DISTINCT resource_name, resource_comment FROM cfg_resource ORDER BY resource_line");56 $DBRESULT =& $pearDB->query("SELECT DISTINCT `resource_name`, `resource_comment` FROM `cfg_resource` ORDER BY `resource_line`"); 46 57 if (PEAR::isError($DBRESULT)) 47 58 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; … … 57 68 */ 58 69 $graphTpls = array(NULL=>NULL); 59 $DBRESULT =& $pearDB->query("SELECT graph_id, name FROM giv_graphs_template ORDER BY name");70 $DBRESULT =& $pearDB->query("SELECT `graph_id`, `name` FROM `giv_graphs_template` ORDER BY `name`"); 60 71 if (PEAR::isError($DBRESULT)) 61 72 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 62 while ($graphTpl =& $DBRESULT->fetchRow())73 while ($graphTpl =& $DBRESULT->fetchRow()) 63 74 $graphTpls[$graphTpl["graph_id"]] = $graphTpl["name"]; 64 75 $DBRESULT->free(); 65 76 66 # Nagios Macro 77 /* 78 * Nagios Macro 79 */ 67 80 $macros = array(); 68 $DBRESULT =& $pearDB->query("SELECT macro_name FROM nagios_macro ORDER BY macro_name");81 $DBRESULT =& $pearDB->query("SELECT `macro_name` FROM `nagios_macro` ORDER BY `macro_name`"); 69 82 if (PEAR::isError($DBRESULT)) 70 83 print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 71 while ($row =& $DBRESULT->fetchRow())84 while ($row =& $DBRESULT->fetchRow()) 72 85 $macros[$row["macro_name"]] = $row["macro_name"]; 73 86 $DBRESULT->free(); 74 # 75 # End of "database-retrieved" information 76 ########################################################## 77 ########################################################## 78 # Var information to format the element 79 # 87 80 88 $attrsText = array("size"=>"35"); 81 89 $attrsTextarea = array("rows"=>"9", "cols"=>"65"); 82 90 83 #84 ##Form begin85 #91 /* 92 * Form begin 93 */ 86 94 $form = new HTML_QuickForm('Form', 'post', "?p=".$p); 87 95 if ($o == "a") … … 92 100 $form->addElement('header', 'title', _("View a Command")); 93 101 94 #95 ##Command information96 #102 /* 103 * Command information 104 */ 97 105 if ($type == "1") 98 106 $form->addElement('header', 'information', _("Notification")); … … 103 111 else 104 112 $form->addElement('header', 'information', _("Information")); 113 105 114 $cmdType[] = &HTML_QuickForm::createElement('radio', 'command_type', null, _("Notification"), '1'); 106 115 $cmdType[] = &HTML_QuickForm::createElement('radio', 'command_type', null, _("Check"), '2'); 107 116 $cmdType[] = &HTML_QuickForm::createElement('radio', 'command_type', null, _("Misc"), '3'); 117 108 118 $form->addGroup($cmdType, 'command_type', _("Command Type"), ' '); 109 119 $form->setDefaults(array('command_type' => '2')); … … 126 136 $form->addElement('select', 'plugins', null, $plugins_list); 127 137 128 #129 ##Further informations130 #138 /* 139 * Further informations 140 */ 131 141 $form->addElement('hidden', 'command_id'); 132 142 $redirectType = $form->addElement('hidden', 'type'); … … 134 144 $redirect =& $form->addElement('hidden', 'o'); 135 145 $redirect->setValue($o); 136 137 # 138 ## Form Rules 139 # 140 function myReplace() { 141 global $form; 142 $ret = $form->getSubmitValues(); 143 return (str_replace(" ", "_", $ret["command_name"])); 144 } 146 145 147 $form->applyFilter('__ALL__', 'myTrim'); 146 148 $form->applyFilter('command_name', 'myReplace'); … … 152 154 $form->setRequiredNote("<font style='color: red;'>*</font>". _(" Required fields")); 153 155 154 # 155 ##End of form definition 156 # 157 158 # Smarty template Init 156 /* 157 * Smarty template Init 158 */ 159 159 $tpl = new Smarty(); 160 160 $tpl = initSmartyTpl($path, $tpl); 161 161 162 # Just watch a Command information 162 /* 163 * Just watch a Command information 164 */ 163 165 if ($o == "w") { 164 166 $form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&command_id=".$command_id."&type=".$type."'")); 165 167 $form->setDefaults($cmd); 166 168 $form->freeze(); 167 } 168 # Modify a Command information 169 else if ($o == "c") { 169 } else if ($o == "c") { 170 /* 171 * Modify a Command information 172 */ 170 173 $subC =& $form->addElement('submit', 'submitC', _("Save")); 171 174 $res =& $form->addElement('reset', 'reset', _("Reset")); 172
