Show
Ignore:
Timestamp:
07/23/08 19:47:06 (4 months ago)
Author:
jmathis
Message:

remove bug with #

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/centreon/www/include/eventLogs/GetODSXmlLog.php

    r5839 r5862  
    3838        require_once 'DB.php'; 
    3939         
    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"); 
    4242        include_once($centreon_path . "www/DBconnect.php"); 
    4343        include_once($centreon_path . "www/DBOdsConnect.php"); 
     
    6060                $lca =  getLCAHostByName($pearDB); 
    6161                $lcaSTR = getLCAHostStr($lca["LcaHost"]); 
    62                 //$lcaSTR_HG = getLCAHostStr($lca["LcaHostGroup"]); 
    63         } 
     62        } 
     63         
    6464        (isset($_GET["num"]) && !check_injection($_GET["num"])) ? $num = htmlentities($_GET["num"]) : $num = "0"; 
    6565        (isset($_GET["limit"]) && !check_injection($_GET["limit"])) ? $limit = htmlentities($_GET["limit"]) : $limit = "30"; 
     
    7171        (isset($_GET["multi"]) && !check_injection($_GET["multi"])) ? $multi = htmlentities($_GET["multi"]) : $multi = "-1"; 
    7272         
    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"; 
    13383 
    13484        if ($contact_id){ 
     
    205155         * Print infos.. 
    206156         */ 
     157          
    207158        echo "<infos>"; 
    208159        echo "<multi>".$multi."</multi>"; 
     
    234185        if ($error == 'true') 
    235186                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) 
    239190                $msg_req .= ' AND msg_type IN (' . implode(",",$msg_type_set). ') '; 
    240191         
     
    261212        if (count($msg_status_set) > 0 ){ 
    262213                $msg_req .= ' AND (status IN (' . implode(",",$msg_status_set). ') '; 
    263                 if($error  == 'true' || $notification == 'true') 
     214                if ($error  == 'true' || $notification == 'true') 
    264215                        $msg_req .= 'OR status is null'; 
    265216                $msg_req .=')'; 
     
    278229                foreach ($tab_id as $openid){ 
    279230                        $tab_tmp = split("_",$openid); 
    280                         #$id = $tab_tmp[1]; 
     231                        $id = $tab_tmp[1]; 
    281232                        $type = $tab_tmp[0]; 
    282233 
    283                         if($type == "HG"){ 
     234                        if ($type == "HG"){ 
    284235                                $hosts = getMyHostGroupHosts($id); 
    285                                 foreach($hosts as $h_id)        { 
     236                                foreach ($hosts as $h_id)       { 
    286237                                        $host_name = getMyHostName($h_id); 
    287238                                        array_push ($tab_host_name, "'".$host_name."'"); 
    288239                                } 
    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"){ 
    290252                                $host_name = getMyHostName($id); 
    291253                                array_push ($tab_host_name, "'".$host_name."'");                 
    292                         } else if($type == "HS"){ 
     254                        } else if ($type == "HS"){ 
    293255                                $service_description = getMyServiceName($id); 
    294256                                $host_id = getMyHostIDService($id); 
     
    304266                 */ 
    305267                 
    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"; 
    307269                if      (count($tab_host_name) > 0){ 
    308270                        $req .= " AND (host_name in(".implode(",",$tab_host_name).") "; 
    309                         if($error  == 'true' || $notification == 'true') 
     271                        if ($error  == 'true' || $notification == 'true') 
    310272                                $req .= ' OR host_name is null';                 
    311273                        $req .= ")"; 
     
    314276                        $req .= " AND ( "; 
    315277                        $flag = 0; 
    316                         foreach($tab_svc as $svc){ 
    317                                 if($flag) 
     278                        foreach ($tab_svc as $svc){ 
     279                                if ($flag) 
    318280                                        $req .= " OR "; 
    319281                                $flag = 1;                       
    320282                                $req .= " ((host_name like '".$svc["host_name"]."'"; 
    321                                 if($error  == 'true' || $notification == 'true') 
     283                                if ($error  == 'true' || $notification == 'true') 
    322284                                        $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"]."')) "; 
    326286                        } 
    327287                        $req .= " )"; 
     
    333293                $id = substr($openid, 3, strlen($openid)); 
    334294                $type = substr($openid, 0, 2);   
    335                 if($type == "HG"){ 
     295                if ($type == "HG"){ 
    336296                        $hosts = getMyHostGroupHosts($id); 
    337297                        $tab_host_name= array(); 
    338                         foreach($hosts as $h_id)        { 
     298                        foreach ($hosts as $h_id)       { 
    339299                                $host_name = getMyHostName($h_id); 
    340300                                array_push ($tab_host_name, "'".$host_name."'"); 
    341301                        } 
    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') 
    344304                                $req .= ' OR host_name is null'; 
    345305                        $req .= ")"; 
    346306                } else if($type == "HH") { 
    347307                        $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') 
    350310                                $req .= ' OR host_name is null'; 
    351311                        $req .= ")"; 
     
    355315                        $host_name = getMyHostName($host_id); 
    356316                 
    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') 
    359319                                $req .= ' OR host_name is null';                                 
    360320                        $req .= ")"; 
    361321                        $req .= " AND (service_description like '".$service_description."' "; 
    362322                        $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(); 
    363342                } else {  
    364343                        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"; 
    366345                        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)"; 
    368347                } 
    369348        } 
     
    453432         * Full Request 
    454433         */ 
    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"; 
    457435 
    458436        $DBRESULT =& $pearDBO->query($req);