| 1 | <? |
|---|
| 2 | /** |
|---|
| 3 | Oreon is developped with GPL Licence 2.0 : |
|---|
| 4 | http://www.gnu.org/licenses/gpl.txt |
|---|
| 5 | Developped by : Julien Mathis - Romain Le Merlus - Christophe Coraboeuf |
|---|
| 6 | |
|---|
| 7 | The Software is provided to you AS IS and WITH ALL FAULTS. |
|---|
| 8 | OREON makes no representation and gives no warranty whatsoever, |
|---|
| 9 | whether express or implied, and without limitation, with regard to the quality, |
|---|
| 10 | safety, contents, performance, merchantability, non-infringement or suitability for |
|---|
| 11 | any particular or intended purpose of the Software found on the OREON web site. |
|---|
| 12 | In no event will OREON be liable for any direct, indirect, punitive, special, |
|---|
| 13 | incidental or consequential damages however they may arise and even if OREON has |
|---|
| 14 | been previously advised of the possibility of such damages. |
|---|
| 15 | |
|---|
| 16 | For information : contact@oreon-project.org |
|---|
| 17 | */ |
|---|
| 18 | |
|---|
| 19 | function getStatusmapcgiOpt() { |
|---|
| 20 | global $pearDB; |
|---|
| 21 | global $form; |
|---|
| 22 | $statusmapcgi = array(); |
|---|
| 23 | |
|---|
| 24 | $res =& $pearDB->query("SELECT * FROM statusmapcgi_opt WHERE sopt_id = '1' LIMIT 1"); |
|---|
| 25 | if (PEAR::isError($pearDB)) { |
|---|
| 26 | print "Mysql Error : ".$pearDB->getMessage(); |
|---|
| 27 | } |
|---|
| 28 | # Set base value |
|---|
| 29 | $statusmapcgi = array_map("myDecode", $res->fetchRow()); |
|---|
| 30 | |
|---|
| 31 | return $statusmapcgi; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | function getActiveCgiInfo() { |
|---|
| 37 | global $pearDB; |
|---|
| 38 | global $form; |
|---|
| 39 | $cgi = array(); |
|---|
| 40 | |
|---|
| 41 | $res =& $pearDB->query("SELECT * FROM cfg_cgi WHERE cgi_activate = '1' LIMIT 1"); |
|---|
| 42 | if (PEAR::isError($pearDB)) { |
|---|
| 43 | print "Mysql Error : ".$pearDB->getMessage(); |
|---|
| 44 | } |
|---|
| 45 | # Set base value |
|---|
| 46 | $cgi = array_map("myDecode", $res->fetchRow()); |
|---|
| 47 | |
|---|
| 48 | return $cgi; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | function getHostGroups() { |
|---|
| 52 | global $pearDB; |
|---|
| 53 | global $oreon; |
|---|
| 54 | |
|---|
| 55 | $lcaHost = getLcaHostByID($pearDB); |
|---|
| 56 | $lcaHostGroupstr = getLcaHGStr($lcaHost["LcaHostGroup"]); |
|---|
| 57 | |
|---|
| 58 | # Host Groups comes from DB -> Store in $hgs Array |
|---|
| 59 | $hgs = array(); |
|---|
| 60 | if ($oreon->user->admin || !HadUserLca($pearDB)) |
|---|
| 61 | $res =& $pearDB->query("SELECT hg_id, hg_name FROM hostgroup ORDER BY hg_name"); |
|---|
| 62 | else |
|---|
| 63 | $res =& $pearDB->query("SELECT hg_id, hg_name FROM hostgroup WHERE hg_id IN (".$lcaHostGroupstr.") ORDER BY hg_name"); |
|---|
| 64 | |
|---|
| 65 | if (PEAR::isError($pearDB)) { |
|---|
| 66 | print "Mysql Error : ".$pearDB->getMessage(); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | while($res->fetchInto($hg)) |
|---|
| 70 | $hgs[$hg["hg_id"]] = $hg["hg_name"]; |
|---|
| 71 | $res->free(); |
|---|
| 72 | |
|---|
| 73 | return $hgs; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | function updateStatusmapcgiOptInDB ($sopt_id = NULL) { |
|---|
| 79 | if (!$sopt_id) return; |
|---|
| 80 | updateStatusmapcgiOpt($sopt_id); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | function updateStatusmapcifConfigData($sopt_id = null) { |
|---|
| 84 | if (!$sopt_id) return; |
|---|
| 85 | global $form, $pearDB, $oreon; |
|---|
| 86 | $ret = array(); |
|---|
| 87 | $ret = $form->getSubmitValues(); |
|---|
| 88 | $rq = "UPDATE `statusmapcgi_opt` SET "; |
|---|
| 89 | $rq .= "nagios_statusmapcgi_html_path = "; |
|---|
| 90 | isset($ret["nagios_statusmapcgi_html_path"]) && $ret["nagios_statusmapcgi_html_path"] != NULL ? $rq .= "'".htmlentities($ret["nagios_statusmapcgi_html_path"], ENT_QUOTES)."', ": $rq .= "NULL, "; |
|---|
| 91 | $rq .= "nagios_statusmap_user = "; |
|---|
| 92 | isset($ret["nagios_statusmap_user"]) && $ret["nagios_statusmap_user"] != NULL ? $rq .= "'".htmlentities($ret["nagios_statusmap_user"], ENT_QUOTES)."', ": $rq .= "NULL, "; |
|---|
| 93 | $rq .= "nagios_statusmap_password = "; |
|---|
| 94 | isset($ret["nagios_statusmap_password"]) && $ret["nagios_statusmap_password"] != NULL ? $rq .= "'".htmlentities($ret["nagios_statusmap_password"], ENT_QUOTES)."', ": $rq .= "NULL, "; |
|---|
| 95 | $rq .= "nagios_statusmap_use_lca = "; |
|---|
| 96 | isset($ret["nagios_statusmap_use_lca"]["nagios_statusmap_use_lca"]) && $ret["nagios_statusmap_use_lca"]["nagios_statusmap_use_lca"] != NULL ? $rq .= "'".$ret["nagios_statusmap_use_lca"]["nagios_statusmap_use_lca"]."' ": $rq .= "NULL "; |
|---|
| 97 | |
|---|
| 98 | $rq .= "WHERE sopt_id = '".$sopt_id."'"; |
|---|
| 99 | $DBRESULT =& $pearDB->query($rq); |
|---|
| 100 | if (PEAR::isError($DBRESULT)) |
|---|
| 101 | print $DBRESULT->getDebugInfo()."<br>"; |
|---|
| 102 | $oreon->optStatusmap = array(); |
|---|
| 103 | $DBRESULT =& $pearDB->query("SELECT * FROM `statusmapcgi_opt` LIMIT 1"); |
|---|
| 104 | if (PEAR::isError($DBRESULT)) |
|---|
| 105 | print $DBRESULT->getDebugInfo()."<br>"; |
|---|
| 106 | $oreon->optStatusmap = $DBRESULT->fetchRow(); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | ?> |
|---|