Changeset 5862
- Timestamp:
- 07/23/08 19:47:06 (2 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/centreon/www/include/eventLogs/GetODSXmlLog.php
r5839 r5862 38 38 require_once 'DB.php'; 39 39 40 include_once(" @CENTREON_ETC@/centreon.conf.php");41 include_once($centreon_path ."www/include/eventLogs/common-Func.php");40 include_once("/etc/centreon/centreon.conf.php"); 41 include_once($centreon_path . "www/include/eventLogs/common-Func.php"); 42 42 include_once($centreon_path . "www/DBconnect.php"); 43 43 include_once($centreon_path . "www/DBOdsConnect.php"); … … 60 60 $lca = getLCAHostByName($pearDB); 61 61 $lcaSTR = getLCAHostStr($lca["LcaHost"]); 62 //$lcaSTR_HG = getLCAHostStr($lca["LcaHostGroup"]);63 }62 } 63 64 64 (isset($_GET["num"]) && !check_injection($_GET["num"])) ? $num = htmlentities($_GET["num"]) : $num = "0"; 65 65 (isset($_GET["limit"]) && !check_injection($_GET["limit"])) ? $limit = htmlentities($_GET["limit"]) : $limit = "30"; … … 71 71 (isset($_GET["multi"]) && !check_injection($_GET["multi"])) ? $multi = htmlentities($_GET["multi"]) : $multi = "-1"; 72 72 73 if (isset($_GET["up"]) && !check_injection($_GET["up"])){ 74 $up = htmlentities($_GET["up"]); 75 set_user_param($contact_id, $pearDB, "log_filter_host_up", $up); 76 } else 77 $up = "true"; 78 if (isset($_GET["down"]) && !check_injection($_GET["down"])){ 79 $down = htmlentities($_GET["down"]); 80 set_user_param($contact_id, $pearDB, "log_filter_host_down", $down); 81 } else 82 $down = "true"; 83 84 if (isset($_GET["unreachable"]) && !check_injection($_GET["unreachable"])){ 85 $unreachable = htmlentities($_GET["unreachable"]); 86 set_user_param($contact_id, $pearDB, "log_filter_host_unreachable", $unreachable); 87 } else 88 $unreachable = "true"; 89 90 if (isset($_GET["ok"]) && !check_injection($_GET["ok"])){ 91 $ok = htmlentities($_GET["ok"]); 92 set_user_param($contact_id, $pearDB, "log_filter_svc_ok", $ok); 93 } else 94 $ok = "true"; 95 96 if (isset($_GET["warning"]) && !check_injection($_GET["warning"])){ 97 $warning = htmlentities($_GET["warning"]); 98 set_user_param($contact_id, $pearDB, "log_filter_svc_warning", $warning); 99 } else 100 $warning = "true"; 101 102 if (isset($_GET["critical"]) && !check_injection($_GET["critical"])){ 103 $critical = htmlentities($_GET["critical"]); 104 set_user_param($contact_id, $pearDB, "log_filter_svc_critical", $critical); 105 } else 106 $critical = "true"; 107 108 if (isset($_GET["unknown"]) && !check_injection($_GET["unknown"])){ 109 $unknown = htmlentities($_GET["unknown"]); 110 set_user_param($contact_id, $pearDB, "log_filter_svc_unknown", $unknown); 111 } else 112 $unknown = "true"; 113 114 if(isset($_GET["notification"]) && !check_injection($_GET["notification"])){ 115 $notification = htmlentities($_GET["notification"]); 116 set_user_param($contact_id, $pearDB, "log_filter_notif", $notification); 117 } else 118 $notification = "false"; 119 120 if(isset($_GET["alert"]) && !check_injection($_GET["alert"])){ 121 $alert = htmlentities($_GET["alert"]); 122 set_user_param($contact_id, $pearDB, "log_filter_alert", $alert); 123 } else 124 $alert = "true"; 125 126 if (isset($_GET["error"]) && !check_injection($_GET["error"])){ 127 $error = htmlentities($_GET["error"]); 128 set_user_param($contact_id, $pearDB, "log_filter_error", $error); 129 } else 130 $error = "false"; 131 132 73 (isset($_GET["up"]) && !check_injection($_GET["up"])) ? set_user_param($contact_id, $pearDB, "log_filter_host_up", htmlentities($_GET["up"])) : $up = "true"; 74 (isset($_GET["down"]) && !check_injection($_GET["down"])) ? set_user_param($contact_id, $pearDB, "log_filter_host_down", htmlentities($_GET["down"])) : $down = "true"; 75 (isset($_GET["unreachable"]) && !check_injection($_GET["unreachable"])) ? set_user_param($contact_id, $pearDB, "log_filter_host_unreachable", htmlentities($_GET["unreachable"])) : $unreachable = "true"; 76 (isset($_GET["ok"]) && !check_injection($_GET["ok"])) ? set_user_param($contact_id, $pearDB, "log_filter_svc_ok", htmlentities($_GET["ok"])) : $ok = "true"; 77 (isset($_GET["warning"]) && !check_injection($_GET["warning"])) ? set_user_param($contact_id, $pearDB, "log_filter_svc_warning", htmlentities($_GET["warning"])) : $warning = "true"; 78 (isset($_GET["critical"]) && !check_injection($_GET["critical"])) ? set_user_param($contact_id, $pearDB, "log_filter_svc_critical", htmlentities($_GET["critical"])) : $critical = "true"; 79 (isset($_GET["unknown"]) && !check_injection($_GET["unknown"])) ? set_user_param($contact_id, $pearDB, "log_filter_svc_unknown", htmlentities($_GET["unknown"])) : $unknown = "true"; 80 (isset($_GET["notification"]) && !check_injection($_GET["notification"])) ? set_user_param($contact_id, $pearDB, "log_filter_notif", htmlentities($_GET["notification"])) : $notification = "false"; 81 (isset($_GET["alert"]) && !check_injection($_GET["alert"])) ? set_user_param($contact_id, $pearDB, "log_filter_alert", htmlentities($_GET["alert"])) : $alert = "true"; 82 (isset($_GET["error"]) && !check_injection($_GET["error"])) ? set_user_param($contact_id, $pearDB, "log_filter_error", htmlentities($_GET["error"])) : $error = "false"; 133 83 134 84 if ($contact_id){ … … 205 155 * Print infos.. 206 156 */ 157 207 158 echo "<infos>"; 208 159 echo "<multi>".$multi."</multi>"; … … 234 185 if ($error == 'true') 235 186 array_push ($msg_type_set, "'4'"); 236 $msg_req ='';237 238 if ( count($msg_type_set) > 0)187 $msg_req = ''; 188 189 if (count($msg_type_set) > 0) 239 190 $msg_req .= ' AND msg_type IN (' . implode(",",$msg_type_set). ') '; 240 191 … … 261 212 if (count($msg_status_set) > 0 ){ 262 213 $msg_req .= ' AND (status IN (' . implode(",",$msg_status_set). ') '; 263 if ($error == 'true' || $notification == 'true')214 if ($error == 'true' || $notification == 'true') 264 215 $msg_req .= 'OR status is null'; 265 216 $msg_req .=')'; … … 278 229 foreach ($tab_id as $openid){ 279 230 $tab_tmp = split("_",$openid); 280 #$id = $tab_tmp[1];231 $id = $tab_tmp[1]; 281 232 $type = $tab_tmp[0]; 282 233 283 if ($type == "HG"){234 if ($type == "HG"){ 284 235 $hosts = getMyHostGroupHosts($id); 285 foreach ($hosts as $h_id) {236 foreach ($hosts as $h_id) { 286 237 $host_name = getMyHostName($h_id); 287 238 array_push ($tab_host_name, "'".$host_name."'"); 288 239 } 289 } else if($type == "HH"){ 240 } else if ($type == 'ST') { 241 $services = getMyServiceGroupServices($id); 242 foreach ($services as $svc_id => $svc_name) { 243 $tab_tmp = split("_", $svc_id); 244 if (service_has_graph($tab_tmp[0], $tab_tmp[1]) && (($is_admin) || (!$is_admin && isset($lca["LcaHost"][getMyHostName($id)]) && isset($lca["LcaHost"][getMyHostName($id)]["svc"][$svc_name])))) { 245 $oid = "HS_".$tab_tmp[1]."_".$tab_tmp[0]; 246 array_push($tab_id, $oid); 247 } 248 } 249 } else if ($type == 'MS') { 250 array_push($tab_id, $openid); 251 } else if ($type == "HH"){ 290 252 $host_name = getMyHostName($id); 291 253 array_push ($tab_host_name, "'".$host_name."'"); 292 } else if ($type == "HS"){254 } else if ($type == "HS"){ 293 255 $service_description = getMyServiceName($id); 294 256 $host_id = getMyHostIDService($id); … … 304 266 */ 305 267 306 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req";268 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req"; 307 269 if (count($tab_host_name) > 0){ 308 270 $req .= " AND (host_name in(".implode(",",$tab_host_name).") "; 309 if ($error == 'true' || $notification == 'true')271 if ($error == 'true' || $notification == 'true') 310 272 $req .= ' OR host_name is null'; 311 273 $req .= ")"; … … 314 276 $req .= " AND ( "; 315 277 $flag = 0; 316 foreach ($tab_svc as $svc){317 if ($flag)278 foreach ($tab_svc as $svc){ 279 if ($flag) 318 280 $req .= " OR "; 319 281 $flag = 1; 320 282 $req .= " ((host_name like '".$svc["host_name"]."'"; 321 if ($error == 'true' || $notification == 'true')283 if ($error == 'true' || $notification == 'true') 322 284 $req .= ' OR host_name is null'; 323 $req .= ")"; 324 $req .= " AND (service_description like '".$svc["svc_name"]."' "; 325 $req .= ")) "; 285 $req .= ") AND (service_description like '".$svc["svc_name"]."')) "; 326 286 } 327 287 $req .= " )"; … … 333 293 $id = substr($openid, 3, strlen($openid)); 334 294 $type = substr($openid, 0, 2); 335 if ($type == "HG"){295 if ($type == "HG"){ 336 296 $hosts = getMyHostGroupHosts($id); 337 297 $tab_host_name= array(); 338 foreach ($hosts as $h_id) {298 foreach ($hosts as $h_id) { 339 299 $host_name = getMyHostName($h_id); 340 300 array_push ($tab_host_name, "'".$host_name."'"); 341 301 } 342 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req AND (host_name in(".implode(",",$tab_host_name).") ";343 if ($error == 'true' || $notification == 'true')302 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req AND (host_name in(".implode(",",$tab_host_name).") "; 303 if ($error == 'true' || $notification == 'true') 344 304 $req .= ' OR host_name is null'; 345 305 $req .= ")"; 346 306 } else if($type == "HH") { 347 307 $host_name = getMyHostName($id); 348 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req AND (host_name like '".$host_name."' ";349 if ($error == 'true' || $notification == 'true')308 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req AND (host_name like '".$host_name."' "; 309 if ($error == 'true' || $notification == 'true') 350 310 $req .= ' OR host_name is null'; 351 311 $req .= ")"; … … 355 315 $host_name = getMyHostName($host_id); 356 316 357 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req AND (host_name like '".$host_name."'";358 if ($error == 'true' || $notification == 'true')317 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req AND (host_name like '".$host_name."'"; 318 if ($error == 'true' || $notification == 'true') 359 319 $req .= ' OR host_name is null'; 360 320 $req .= ")"; 361 321 $req .= " AND (service_description like '".$service_description."' "; 362 322 $req .= ") "; 323 } if ($type == "MS"){ 324 $other_services = array(); 325 $DBRESULT2 =& $pearDBO->query("SELECT * FROM index_data WHERE `trashed` = '0' AND special = '1' AND service_description = 'meta_".$id."' ORDER BY service_description"); 326 if (PEAR::isError($DBRESULT2)) 327 print "Mysql Error : ".$DBRESULT2->getDebugInfo(); 328 if ($svc_id =& $DBRESULT2->fetchRow()){ 329 if (preg_match("/meta_([0-9]*)/", $svc_id["service_description"], $matches)){ 330 $DBRESULT_meta =& $pearDB->query("SELECT meta_name FROM meta_service WHERE `meta_id` = '".$matches[1]."'"); 331 if (PEAR::isError($DBRESULT_meta)) 332 print "Mysql Error : ".$DBRESULT_meta->getDebugInfo(); 333 $meta =& $DBRESULT_meta->fetchRow(); 334 $DBRESULT_meta->free(); 335 $svc_id["service_description"] = $meta["meta_name"]; 336 } 337 $svc_id["service_description"] = str_replace("#S#", "/", $svc_id["service_description"]); 338 $svc_id["service_description"] = str_replace("#BS#", "\\", $svc_id["service_description"]); 339 $svc_id[$svc_id["id"]] = $svc_id["service_description"]; 340 } 341 $DBRESULT2->free(); 363 342 } else { 364 343 if ($is_admin) 365 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req";344 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req"; 366 345 else 367 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req AND host_name IN ($lcaSTR)";346 $req = "SELECT * FROM log WHERE ctime > '$start' AND ctime <= '$end' $msg_req AND host_name IN ($lcaSTR)"; 368 347 } 369 348 } … … 453 432 * Full Request 454 433 */ 455 $req .= " ORDER BY ctime DESC,log_id DESC"; 456 $req .= " LIMIT $lstart,$limit"; 434 $req .= " ORDER BY ctime DESC,log_id DESC LIMIT $lstart,$limit"; 457 435 458 436 $DBRESULT =& $pearDBO->query($req);
