From: Florian G. <re...@us...> - 2007-06-18 22:12:39
|
Update of /cvsroot/perfparse/_perfparse-phpgui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9737/phpgui Modified Files: perfparse.php utils.php Log Message: save graphs Index: utils.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/utils.php,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** utils.php 15 Jun 2007 23:34:30 -0000 1.38 --- utils.php 18 Jun 2007 22:12:38 -0000 1.39 *************** *** 576,581 **** } ! function save_graph(&$db,$grapharray) { // echo "<pre>in utils: save_graph. grapharray: \n";print_r($grapharray);echo "</pre>"; $query='insert into perfdata_graphs (title,descript,refresh_time,metric_id,scale,minin,maxin,timerange,'; --- 576,590 ---- } ! function save_graph(&$db,&$grapharray) { // echo "<pre>in utils: save_graph. grapharray: \n";print_r($grapharray);echo "</pre>"; + // sanatize grapharray + list($grapharray['sizex'],$grapharray['sizey'])=split('x',$grapharray['size'],2); + $notempty=array('graph_name','refresh_time','metric_id','scale','timerange','output','sizex','sizey','s_val','s_war','s_cri','s_sta','g_sigma'); + foreach($notempty as $checkvar) { + if(!isset($grapharray[$checkvar]) || (is_string($grapharray[$checkvar]) && empty($grapharray[$checkvar]))) { + $errormsg="Parameter $checkvar missing in ".__FILE__.":".__LINE__.' '.__FUNCTION__; + return($errormsg); + } + } $query='insert into perfdata_graphs (title,descript,refresh_time,metric_id,scale,minin,maxin,timerange,'; *************** *** 628,633 **** // echo "<pre>q:\n$query\n";print_r($bindarray);echo "</pre>"; if(!$db->Execute($query,$bindarray)) { ! echo "Error saving graph: ".$db->ErrorMsg(); } } --- 637,644 ---- // echo "<pre>q:\n$query\n";print_r($bindarray);echo "</pre>"; if(!$db->Execute($query,$bindarray)) { ! $errormsg="Error saving graph: ".$db->ErrorMsg(); } + if(isset($errormsg)) return($errormsg); + } Index: perfparse.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/perfparse.php,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** perfparse.php 15 Jun 2007 23:34:30 -0000 1.50 --- perfparse.php 18 Jun 2007 22:12:38 -0000 1.51 *************** *** 338,342 **** // handle saving graphs here if(isset($save_graph_metric_id[$metric_id])) { ! save_graph($db,$actgraph); // todo: error handling and feedback to user } --- 338,344 ---- // handle saving graphs here if(isset($save_graph_metric_id[$metric_id])) { ! $actgraph['refresh_time']=0; ! $errorsave[$metric_id]=save_graph($db,$actgraph); ! $smarty->assign_by_ref('errorsave',$errorsave); } |