Changeset 263fbcefa4e7c9542382400747df4c4ef671996d

Show
Ignore:
Timestamp:
01/28/11 18:05:31 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1296237931 +0000
git-parent:

[4fae03b83820a0c88604a1591dc30859440f6623]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1296237931 +0000
Message:

reviewed patch from Michal Taborsky to make the PHP clean under E_ALL error setting

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ui/web/htdocs/datapoint_browse_json.php

    rf561a33 r263fbce  
    1010$l3 = $_GET['l3']; 
    1111$l4 = $_GET['l4']; 
    12 $l5 = $_GET['l5']
     12$l5 = !empty($_GET['l5'])?$_GET['l5']:false
    1313 
    14 if ($_REQUEST['root'] == 'source'){ 
     14if (!empty($_REQUEST['root']) && $_REQUEST['root'] == 'source'){ 
    1515  $want = $l1; 
    1616} 
    17 else if($_REQUEST[$l1]) { 
     17else if(!empty($_REQUEST[$l1])) { 
    1818  $want = $l2; 
    19   if($_REQUEST[$l2]) { 
     19  if(!empty($_REQUEST[$l2])) { 
    2020    $want = $l3; 
    21     if($_REQUEST[$l3]) { 
     21    if(!empty($_REQUEST[$l3])) { 
    2222      $want = $l4; 
    23       if($_REQUEST[$l4]) { 
     23      if(!empty($_REQUEST[$l4])) { 
    2424        $want = $l5; 
    25         if($_REQUEST[$l5]
     25        if(!empty($_REQUEST[$l5])
    2626          $want = ''; 
    2727      } 
     
    4141    } 
    4242    $jitem = array('id'          => $item['id'], 
    43                    'text'        => $item['ptr']
     43                   'text'        => !empty($item['ptr'])
    4444                                      $item[$want] . "(" . $item['ptr'] . ")" : 
    4545                                      $item[$want], 
  • ui/web/htdocs/drawing_board.php

    r21720f4 r263fbce  
    22$otype = $_GET['otype']; 
    33$id = $_GET['id']; 
    4 $start = $_GET['start']
    5 $end = $_GET['end']
     4$start = !empty($_GET['start'])?$_GET['start']:null
     5$end = !empty($_GET['end'])?$_GET['end']:null
    66$gran = $_GET['gran']; 
    77 
  • ui/web/htdocs/json_graph_flot.php

    raa9764c r263fbce  
    6464$autounits = 0; 
    6565foreach($graph['datapoints'] as $k => $d) { 
     66  if (!isset($d['math1'])) $d['math1']=''; 
     67  if (!isset($d['math2'])) $d['math2']=''; 
    6668  if($d['metric_type'] == 'guide') { 
    6769    $color = isset($d['color']) ? $d['color'] : '#ff0000'; 
     70     
    6871    if ($guideType[$k]=='percentile') { 
    6972    $driver->addPercentileGuide($d['name'], $d['math2'], 
     
    8689    $settings['color'] = isset($d['color']) ? $d['color'] : $settings['color']; 
    8790    if($d['hidden'] == "true") $settings['hidden'] = "true"; 
    88     if($d['math1']) $settings['expression'] = $d['math1']; 
     91    if(!empty($d['math1'])) $settings['expression'] = $d['math1']; 
    8992    $settings['axis'] = ($d['axis'] == 'l') ? 'left' : 'right'; 
    9093    $settings['title'] = $d['name']; 
     
    106109  'xaxis' => array ( 'mode' => 'time' ), 
    107110  'yaxis' => array ( 'suffix' => $driver->autounit() . '' ), 
    108   'legend' => array ( 'noColumns' => 4, position => 'sw' ), 
     111  'legend' => array ( 'noColumns' => 4, 'position' => 'sw' ), 
    109112  'selection' => array ( 'mode' => 'x' ), 
    110113  'shadowSize' => 0, 
  • ui/web/htdocs/template_browse_json.php

    rf561a33 r263fbce  
    2727$template; 
    2828 
    29 if($_REQUEST[$l1]){ 
     29if(!empty($_REQUEST[$l1])){ 
    3030        $templateid = $_REQUEST[$l1]; 
    3131        $template = new Reconnoiter_GraphTemplate($templateid); 
  • ui/web/lib/Reconnoiter_DB.php

    rdbd0c9d r263fbce  
    341341    foreach ($p as $wanted) { 
    342342      $idx = max(ceil((count($full)-1) * ($wanted/100.0)), 0); 
    343       $rv[$wanted] = $full[$idx]
     343      $rv[$wanted] = !empty($full[$idx])?$full[$idx] : null
    344344    } 
    345345    return $rv; 
     
    372372      if($nonnull == 1) $full[] = $sum; 
    373373    } 
    374     if (in_array('avg',$p)) { 
     374    if ( in_array('avg',$p) && count($full) > 0 ) { 
    375375        $rv['avg']=array_sum($full) / count($full);      
    376376    } 
    377377    if (in_array('stddev',$p) || in_array('stddev+',$p) || in_array('stddev-',$p)) { 
    378378   
    379                 function sd_square($x, $mean) { return pow($x - $mean,2); } 
     379                function sd_square($x, $mean) {  
     380                  return pow($x - $mean,2);  
     381                } 
    380382 
    381383                function sd($array) { 
    382                         return sqrt(array_sum(array_map("sd_square", $array, array_fill(0,count($array), (array_sum($array) / count($array)) ) ) ) / (count($array)-1) ); 
     384                  if ( count($array) > 0 ) { // make sure we do not divide by zero 
     385                    return sqrt(array_sum(array_map("sd_square", $array, array_fill(0,count($array), (array_sum($array) / count($array)) ) ) ) / (count($array)-1) ); 
     386                  } else { 
     387                    return 0; 
     388                  } 
    383389                } 
    384390                 
     
    388394                } 
    389395                if (in_array('stddev+', $p)) { 
    390                         if (empty($rv['avg'])) { 
     396                        if ( empty($rv['avg']) && count($full)>0 ) { 
    391397                                $avg=array_sum($full) / count($full); 
    392398                        } else { 
     
    396402                } 
    397403                if (in_array('stddev-', $p)) { 
    398                         if (empty($rv['avg'])) { 
     404                        if ( empty($rv['avg']) && count($full)>0 ) { 
    399405                                $avg=array_sum($full) / count($full); 
    400406                        } else { 
  • ui/web/lib/Reconnoiter_DataContainer.php

    raa9764c r263fbce  
    2323  protected $sets_config; 
    2424  protected $guides; 
    25  
     25  protected $auto_units_on = false; 
     26   
    2627  function __construct($start, $end, $cnt, $type) { 
    2728    $this->start = $start; 
     
    101102      $this->percentile[$p] = $v; 
    102103    } 
    103     foreach($db->aggregate(array_values($this->sets), 
     104    if (is_array($this->agg_to_calc)) { 
     105        foreach($db->aggregate(array_values($this->sets), 
    104106                                                array_keys($this->agg_to_calc)) as $p => $v) { 
    105       $this->aggregate[$p] = $v; 
     107            $this->aggregate[$p] = $v; 
     108        } 
    106109    } 
    107110    $this->units = pow(1000,floor(log($this->percentile[100], 1000))); 
  • ui/web/lib/Reconnoiter_flot_Driver.php

    r5b62a23 r263fbce  
    4141      $ds = array ( 
    4242        'reconnoiter_source_expression' => $set->expression(), 
    43         'reconnoiter_display_expression' => $this->sets_config[$name]['expression']
    44         'dataname' => $this->sets_config[$name]['title'] ? $this->sets_config[$name]['title'] : $name, 
     43        'reconnoiter_display_expression' => !empty($this->sets_config[$name]['expression']) ? $this->sets_config[$name]['expression'] : null
     44        'dataname' => !empty($this->sets_config[$name]['title']) ? $this->sets_config[$name]['title'] : $name, 
    4545        'data' => $this->graphdataset($set, $this->sets_config[$name]), 
    4646        'yaxis' => ($this->sets_config[$name]['axis'] == 'right') ? 2 : 1, 
     
    4949        'metric_name' => $m_name[1],     
    5050        'metric_type' => $metric_type, 
    51         'hidden' => ($this->sets_config[$name]['hidden'] == "true") ? 1: 0, 
     51        'hidden' => (!empty($this->sets_config[$name]['hidden']) && $this->sets_config[$name]['hidden'] == "true") ? 1: 0, 
    5252      ); 
    53       $show_set = ($this->sets_config[$name]['hidden'] != "true") ? 1: 0; 
     53      $show_set = (empty($this->sets_config[$name]['hidden']) || $this->sets_config[$name]['hidden'] != "true") ? 1: 0; 
    5454      if($show_set) { 
    5555        $ds['label'] = $ds['dataname']; 
     
    6262        $opacity = isset($this->sets_config[$name]['opacity']) ? 
    6363                     $this->sets_config[$name]['opacity'] : '0.3'; 
    64         $ds['lines'] = array ( 'show' => ($show_set) ? 1:0, 'fill' => $opacity, 'lineWidth' => '1' , radius => 1 ); 
     64        $ds['lines'] = array ( 'show' => ($show_set) ? 1:0, 'fill' => $opacity, 'lineWidth' => '1' , 'radius' => 1 ); 
    6565      } 
    6666      //if we have a text metric type, draw points 
    6767      else if($metric_type == 'text'){ 
    68         $ds['points'] = array ( 'show' => ($show_set) ? 1:0, 'fill' => 'false', 'lineWidth' => 1, radius => 5 ); 
     68        $ds['points'] = array ( 'show' => ($show_set) ? 1:0, 'fill' => 'false', 'lineWidth' => 1, 'radius' => 5 ); 
    6969      } 
    7070