| 1 | <? |
|---|
| 2 | /** |
|---|
| 3 | Oreon is developped with GPL Licence 2.0 : |
|---|
| 4 | http://www.gnu.org/licenses/gpl.txt |
|---|
| 5 | Developped by : Christophe Coraboeuf |
|---|
| 6 | |
|---|
| 7 | Adapted to Pear library by Merethis company, under direction of Cedrick Facon, Romain Le Merlus, Julien Mathis |
|---|
| 8 | |
|---|
| 9 | The Software is provided to you AS IS and WITH ALL FAULTS. |
|---|
| 10 | OREON makes no representation and gives no warranty whatsoever, |
|---|
| 11 | whether express or implied, and without limitation, with regard to the quality, |
|---|
| 12 | safety, contents, performance, merchantability, non-infringement or suitability for |
|---|
| 13 | any particular or intended purpose of the Software found on the OREON web site. |
|---|
| 14 | In no event will OREON be liable for any direct, indirect, punitive, special, |
|---|
| 15 | incidental or consequential damages however they may arise and even if OREON has |
|---|
| 16 | been previously advised of the possibility of such damages. |
|---|
| 17 | |
|---|
| 18 | For information : contact@oreon-project.org |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | require_once("../../oreon.conf.php"); |
|---|
| 23 | require_once("../../DBconnect.php"); |
|---|
| 24 | require_once("../../$classdir/Session.class.php"); |
|---|
| 25 | require_once("../../$classdir/Oreon.class.php"); |
|---|
| 26 | require_once("../../include/common/common-Func.php"); |
|---|
| 27 | require_once("../../include/common/common-Func-ACL.php"); |
|---|
| 28 | |
|---|
| 29 | Session::start(); |
|---|
| 30 | $oreon =& $_SESSION["oreon"]; |
|---|
| 31 | |
|---|
| 32 | #Path to the configuration dir |
|---|
| 33 | global $path; |
|---|
| 34 | global $pearDB; |
|---|
| 35 | |
|---|
| 36 | $path = "./modules/statusmap/"; |
|---|
| 37 | |
|---|
| 38 | #PHP functions |
|---|
| 39 | require_once "DB.php"; |
|---|
| 40 | require_once "DB-Func.php"; |
|---|
| 41 | |
|---|
| 42 | #PHP functions |
|---|
| 43 | |
|---|
| 44 | $cgi = array(); |
|---|
| 45 | $cgi = array(); |
|---|
| 46 | |
|---|
| 47 | $statusmapcgiOpt = getStatusmapcgiOpt() ; |
|---|
| 48 | $cgi = getActiveCgiInfo(); |
|---|
| 49 | $hgs = getHostGroups(); |
|---|
| 50 | |
|---|
| 51 | isset($_GET["layout"]) ? $layout = $_GET["layout"] : $layout = NULL; |
|---|
| 52 | isset($_GET["layer"]) ? $layer = $_GET["layer"] : $layer = NULL; |
|---|
| 53 | isset($_GET["layermode"]) ? $layermode = $_GET["layermode"] : $layermode = NULL; |
|---|
| 54 | isset($_GET["host"]) ? $host = $_GET["host"] : $host = "all"; |
|---|
| 55 | |
|---|
| 56 | if (isset($_GET["map"]) && $_GET["map"] && ($_GET["map"] == "1")){ |
|---|
| 57 | $use_map = 1; |
|---|
| 58 | } else { |
|---|
| 59 | $use_map =0; |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | if (isset($cgi['use_authentication']) and $cgi['use_authentication'] == '1' ) { |
|---|
| 63 | $urls = parse_url( $statusmapcgiOpt['nagios_statusmapcgi_html_path']); |
|---|
| 64 | $url = $urls["scheme"] ."://". $statusmapcgiOpt['nagios_statusmap_user'] . ":" . $statusmapcgiOpt['nagios_statusmap_password'] . "@" . $urls["host"] .$urls["path"] ; |
|---|
| 65 | $img_url = $urls["scheme"] ."://". $statusmapcgiOpt['nagios_statusmap_user'] . ":" . $statusmapcgiOpt['nagios_statusmap_password'] . "@" . $urls["host"] ; |
|---|
| 66 | } else { |
|---|
| 67 | $url = $statusmapcgiOpt['nagios_statusmapcgi_html_path'] ; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | //$refresh = (isset($cgi['refresh_rate']) ? $cgi['refresh_rate'] : "90"); |
|---|
| 71 | $use_lca = (isset($statusmapcgiOpt['nagios_statusmap_use_lca']) ? $statusmapcgiOpt['nagios_statusmap_use_lca'] : "0"); |
|---|
| 72 | |
|---|
| 73 | $areamap_url = $url . "?nohighlights&random=" . rand() ; |
|---|
| 74 | $url = $url . "?createimage&nohighlights&random=" . rand() ; |
|---|
| 75 | |
|---|
| 76 | if (isset($layout)) |
|---|
| 77 | $options = $options . "&layout=" . $layout; |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | if ($use_lca == '1') { |
|---|
| 81 | if (isset($layermode)) { |
|---|
| 82 | $layers = explode(",",$layer); |
|---|
| 83 | if ( strcasecmp($layermode ,"include") == 0 ) { |
|---|
| 84 | |
|---|
| 85 | $options = $options . join("&layer=",$layers); |
|---|
| 86 | $options = $options . "&layermode=include"; |
|---|
| 87 | } else { |
|---|
| 88 | foreach ($hgs as $hg) { |
|---|
| 89 | if (!(in_array($hg,$layers)) ) |
|---|
| 90 | $options = $options . "&layer=" . $hg; |
|---|
| 91 | } |
|---|
| 92 | $options = $options . "&layermode=include"; |
|---|
| 93 | } |
|---|
| 94 | } else { |
|---|
| 95 | $options = $options . "&layer=" . implode("&layer=",$hgs); |
|---|
| 96 | $options = $options . "&layermode=include"; |
|---|
| 97 | } |
|---|
| 98 | } else { |
|---|
| 99 | if (isset($layer)) { |
|---|
| 100 | $layers = explode(",",$layer); |
|---|
| 101 | $options = $options . join("&layer=",$layers); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | if (isset($layermode)) |
|---|
| 105 | $options = $options . "&layermode=" . $layermode; |
|---|
| 106 | else |
|---|
| 107 | $options = $options . "&host=all" ; |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | $url = $url . $options; |
|---|
| 111 | $areamap_url = $areamap_url . $options; |
|---|
| 112 | |
|---|
| 113 | if ($use_map) { |
|---|
| 114 | $areamap_content=file_get_contents($areamap_url); |
|---|
| 115 | // retrieve all <AREA> from statusmap.cgi |
|---|
| 116 | preg_match_all('/.*(<area.*>)/i', $areamap_content ,$maps, PREG_SET_ORDER); |
|---|
| 117 | $path_img = substr($oreon->optGen["nagios_path_img"] , strlen( $cgi['physical_html_path'] )); |
|---|
| 118 | |
|---|
| 119 | foreach ($maps as $map) { |
|---|
| 120 | if (isset($cgi['use_authentication']) and $cgi['use_authentication'] == '1' ) { |
|---|
| 121 | $pattern = '|(<img src=)'. $cgi['url_html_path']. $path_img .'(.*\.\w{1,3})( border=0 .*>)|i'; |
|---|
| 122 | $replacement = '$1include/common/getHiddenImage.php?logo=1&path=$2$3'; |
|---|
| 123 | $tmp_map = preg_replace($pattern, $replacement,$map[0]); |
|---|
| 124 | |
|---|
| 125 | } else { |
|---|
| 126 | $tmp_map = $map[0]; |
|---|
| 127 | } |
|---|
| 128 | $pattern = "|statusmap\.cgi\?host=([A-Za-z0-9-_\.]*)&[^ ]*'|i"; |
|---|
| 129 | $replacement = "oreon.php?search_type_host=&search_type_host=1&p=2&search=$1'"; |
|---|
| 130 | $tmp_map = preg_replace($pattern, $replacement,$tmp_map); |
|---|
| 131 | |
|---|
| 132 | $map_str = $map_str . $tmp_map ; |
|---|
| 133 | } |
|---|
| 134 | print $map_str; |
|---|
| 135 | } else { // statusmap.cgi in createimage mode |
|---|
| 136 | $content=file_get_contents($url); |
|---|
| 137 | print $content; |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | ?> |
|---|