From: Florian G. <re...@us...> - 2006-09-06 21:58:44
|
Update of /cvsroot/perfparse/_perfparse-phpgui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23096/phpgui Modified Files: utils.php Log Message: schema changes Index: utils.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/utils.php,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** utils.php 7 Jul 2006 13:56:03 -0000 1.20 --- utils.php 6 Sep 2006 21:58:41 -0000 1.21 *************** *** 1,4 **** --- 1,10 ---- <?php + /* + utility functions. + + $Id$ + */ + /* function to get variables from the $_REQUEST array (GET, POST, ...) * and to fix them (if someone manipulates the forms). Therefore one can *************** *** 94,98 **** function get_hosts(&$db) { ! $query='SELECT host_name, group_name FROM perfdata_host ORDER BY group_name, host_name'; $res=$db->Execute($query); $ret=array(); --- 100,107 ---- function get_hosts(&$db) { ! $query='SELECT h.host_name, g.group_name FROM perfdata_host h, ! perfdata_groups g, perfdata_host_groups hg where ! h.host_id=gh.host_id and g.group_id=hg.group_id ! ORDER BY g.group_name, h.host_name'; $res=$db->Execute($query); $ret=array(); *************** *** 122,157 **** function have_service_metric(&$db,$host,$service,$metric) { ! $where=''; $bindvars=array(); if($host != '') { ! $where='WHERE host_name=? '; $bindvars[]=$host; } if($service != '') { ! if($where=='') { ! $where='WHERE service_description=? '; ! } else { ! $where.='and service_description=? '; ! } $bindvars[]=$service; } if($metric != '') { ! if($where=='') { ! $where='WHERE metric=? '; ! } else { ! $where.='and metric=? '; ! } $bindvars[]=$metric; } ! $query ='SELECT count(*) FROM perfdata_service_metric '.$where; $ret=$db->GetOne($query,$bindvars); return($ret); } function get_metrics(&$db,$host) { $query ='SELECT service_description,metric FROM perfdata_service_metric '; --- 131,173 ---- function have_service_metric(&$db,$host,$service,$metric) { ! $where=array(); $bindvars=array(); + $tabs=array(); + $join=''; if($host != '') { ! $tabs[]='perfdata_host h'; ! $tabs[]='perfdata_service s'; // if a host is choosed then we need the join with perfdata_service ! $join="WHERE h.host_id=s.host_id AND s.service_id=m.service_id AND"; ! $where[]='h.host_name=?'; $bindvars[]=$host; } if($service != '') { ! $tabs[]='perfdata_service s'; ! $where[]='s.service_description=?'; $bindvars[]=$service; + if($join='') { + $join="WHERE s.service_id=m.service_id AND"; + } } + // in any case we need that table + $tabs[]='perfdata_service_metric m'; if($metric != '') { ! $where[]='m.metric=?'; $bindvars[]=$metric; } + $tables=implode(', ',array_unique($tabs)); + $wherestr=implode(' AND ',$where); ! $query ='SELECT count(*) FROM '.$tables.' '.$join.' '.$where; $ret=$db->GetOne($query,$bindvars); return($ret); } + // mark: continue here + function get_metrics(&$db,$host) { $query ='SELECT service_description,metric FROM perfdata_service_metric '; |