Changeset 263fbcefa4e7c9542382400747df4c4ef671996d
- Timestamp:
- 01/28/11 18:05:31
(2 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
| rf561a33 |
r263fbce |
|
| 10 | 10 | $l3 = $_GET['l3']; |
|---|
| 11 | 11 | $l4 = $_GET['l4']; |
|---|
| 12 | | $l5 = $_GET['l5']; |
|---|
| | 12 | $l5 = !empty($_GET['l5'])?$_GET['l5']:false; |
|---|
| 13 | 13 | |
|---|
| 14 | | if ($_REQUEST['root'] == 'source'){ |
|---|
| | 14 | if (!empty($_REQUEST['root']) && $_REQUEST['root'] == 'source'){ |
|---|
| 15 | 15 | $want = $l1; |
|---|
| 16 | 16 | } |
|---|
| 17 | | else if($_REQUEST[$l1]) { |
|---|
| | 17 | else if(!empty($_REQUEST[$l1])) { |
|---|
| 18 | 18 | $want = $l2; |
|---|
| 19 | | if($_REQUEST[$l2]) { |
|---|
| | 19 | if(!empty($_REQUEST[$l2])) { |
|---|
| 20 | 20 | $want = $l3; |
|---|
| 21 | | if($_REQUEST[$l3]) { |
|---|
| | 21 | if(!empty($_REQUEST[$l3])) { |
|---|
| 22 | 22 | $want = $l4; |
|---|
| 23 | | if($_REQUEST[$l4]) { |
|---|
| | 23 | if(!empty($_REQUEST[$l4])) { |
|---|
| 24 | 24 | $want = $l5; |
|---|
| 25 | | if($_REQUEST[$l5]) |
|---|
| | 25 | if(!empty($_REQUEST[$l5])) |
|---|
| 26 | 26 | $want = ''; |
|---|
| 27 | 27 | } |
|---|
| … | … | |
| 41 | 41 | } |
|---|
| 42 | 42 | $jitem = array('id' => $item['id'], |
|---|
| 43 | | 'text' => $item['ptr'] ? |
|---|
| | 43 | 'text' => !empty($item['ptr']) ? |
|---|
| 44 | 44 | $item[$want] . "(" . $item['ptr'] . ")" : |
|---|
| 45 | 45 | $item[$want], |
|---|
| r21720f4 |
r263fbce |
|
| 2 | 2 | $otype = $_GET['otype']; |
|---|
| 3 | 3 | $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; |
|---|
| 6 | 6 | $gran = $_GET['gran']; |
|---|
| 7 | 7 | |
|---|
| raa9764c |
r263fbce |
|
| 64 | 64 | $autounits = 0; |
|---|
| 65 | 65 | foreach($graph['datapoints'] as $k => $d) { |
|---|
| | 66 | if (!isset($d['math1'])) $d['math1']=''; |
|---|
| | 67 | if (!isset($d['math2'])) $d['math2']=''; |
|---|
| 66 | 68 | if($d['metric_type'] == 'guide') { |
|---|
| 67 | 69 | $color = isset($d['color']) ? $d['color'] : '#ff0000'; |
|---|
| | 70 | |
|---|
| 68 | 71 | if ($guideType[$k]=='percentile') { |
|---|
| 69 | 72 | $driver->addPercentileGuide($d['name'], $d['math2'], |
|---|
| … | … | |
| 86 | 89 | $settings['color'] = isset($d['color']) ? $d['color'] : $settings['color']; |
|---|
| 87 | 90 | if($d['hidden'] == "true") $settings['hidden'] = "true"; |
|---|
| 88 | | if($d['math1']) $settings['expression'] = $d['math1']; |
|---|
| | 91 | if(!empty($d['math1'])) $settings['expression'] = $d['math1']; |
|---|
| 89 | 92 | $settings['axis'] = ($d['axis'] == 'l') ? 'left' : 'right'; |
|---|
| 90 | 93 | $settings['title'] = $d['name']; |
|---|
| … | … | |
| 106 | 109 | 'xaxis' => array ( 'mode' => 'time' ), |
|---|
| 107 | 110 | 'yaxis' => array ( 'suffix' => $driver->autounit() . '' ), |
|---|
| 108 | | 'legend' => array ( 'noColumns' => 4, position => 'sw' ), |
|---|
| | 111 | 'legend' => array ( 'noColumns' => 4, 'position' => 'sw' ), |
|---|
| 109 | 112 | 'selection' => array ( 'mode' => 'x' ), |
|---|
| 110 | 113 | 'shadowSize' => 0, |
|---|
| rf561a33 |
r263fbce |
|
| 27 | 27 | $template; |
|---|
| 28 | 28 | |
|---|
| 29 | | if($_REQUEST[$l1]){ |
|---|
| | 29 | if(!empty($_REQUEST[$l1])){ |
|---|
| 30 | 30 | $templateid = $_REQUEST[$l1]; |
|---|
| 31 | 31 | $template = new Reconnoiter_GraphTemplate($templateid); |
|---|
| rdbd0c9d |
r263fbce |
|
| 341 | 341 | foreach ($p as $wanted) { |
|---|
| 342 | 342 | $idx = max(ceil((count($full)-1) * ($wanted/100.0)), 0); |
|---|
| 343 | | $rv[$wanted] = $full[$idx]; |
|---|
| | 343 | $rv[$wanted] = !empty($full[$idx])?$full[$idx] : null; |
|---|
| 344 | 344 | } |
|---|
| 345 | 345 | return $rv; |
|---|
| … | … | |
| 372 | 372 | if($nonnull == 1) $full[] = $sum; |
|---|
| 373 | 373 | } |
|---|
| 374 | | if (in_array('avg',$p)) { |
|---|
| | 374 | if ( in_array('avg',$p) && count($full) > 0 ) { |
|---|
| 375 | 375 | $rv['avg']=array_sum($full) / count($full); |
|---|
| 376 | 376 | } |
|---|
| 377 | 377 | if (in_array('stddev',$p) || in_array('stddev+',$p) || in_array('stddev-',$p)) { |
|---|
| 378 | 378 | |
|---|
| 379 | | function sd_square($x, $mean) { return pow($x - $mean,2); } |
|---|
| | 379 | function sd_square($x, $mean) { |
|---|
| | 380 | return pow($x - $mean,2); |
|---|
| | 381 | } |
|---|
| 380 | 382 | |
|---|
| 381 | 383 | 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 | } |
|---|
| 383 | 389 | } |
|---|
| 384 | 390 | |
|---|
| … | … | |
| 388 | 394 | } |
|---|
| 389 | 395 | if (in_array('stddev+', $p)) { |
|---|
| 390 | | if (empty($rv['avg'])) { |
|---|
| | 396 | if ( empty($rv['avg']) && count($full)>0 ) { |
|---|
| 391 | 397 | $avg=array_sum($full) / count($full); |
|---|
| 392 | 398 | } else { |
|---|
| … | … | |
| 396 | 402 | } |
|---|
| 397 | 403 | if (in_array('stddev-', $p)) { |
|---|
| 398 | | if (empty($rv['avg'])) { |
|---|
| | 404 | if ( empty($rv['avg']) && count($full)>0 ) { |
|---|
| 399 | 405 | $avg=array_sum($full) / count($full); |
|---|
| 400 | 406 | } else { |
|---|
| raa9764c |
r263fbce |
|
| 23 | 23 | protected $sets_config; |
|---|
| 24 | 24 | protected $guides; |
|---|
| 25 | | |
|---|
| | 25 | protected $auto_units_on = false; |
|---|
| | 26 | |
|---|
| 26 | 27 | function __construct($start, $end, $cnt, $type) { |
|---|
| 27 | 28 | $this->start = $start; |
|---|
| … | … | |
| 101 | 102 | $this->percentile[$p] = $v; |
|---|
| 102 | 103 | } |
|---|
| 103 | | foreach($db->aggregate(array_values($this->sets), |
|---|
| | 104 | if (is_array($this->agg_to_calc)) { |
|---|
| | 105 | foreach($db->aggregate(array_values($this->sets), |
|---|
| 104 | 106 | array_keys($this->agg_to_calc)) as $p => $v) { |
|---|
| 105 | | $this->aggregate[$p] = $v; |
|---|
| | 107 | $this->aggregate[$p] = $v; |
|---|
| | 108 | } |
|---|
| 106 | 109 | } |
|---|
| 107 | 110 | $this->units = pow(1000,floor(log($this->percentile[100], 1000))); |
|---|
| r5b62a23 |
r263fbce |
|
| 41 | 41 | $ds = array ( |
|---|
| 42 | 42 | '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, |
|---|
| 45 | 45 | 'data' => $this->graphdataset($set, $this->sets_config[$name]), |
|---|
| 46 | 46 | 'yaxis' => ($this->sets_config[$name]['axis'] == 'right') ? 2 : 1, |
|---|
| … | … | |
| 49 | 49 | 'metric_name' => $m_name[1], |
|---|
| 50 | 50 | '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, |
|---|
| 52 | 52 | ); |
|---|
| 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; |
|---|
| 54 | 54 | if($show_set) { |
|---|
| 55 | 55 | $ds['label'] = $ds['dataname']; |
|---|
| … | … | |
| 62 | 62 | $opacity = isset($this->sets_config[$name]['opacity']) ? |
|---|
| 63 | 63 | $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 ); |
|---|
| 65 | 65 | } |
|---|
| 66 | 66 | //if we have a text metric type, draw points |
|---|
| 67 | 67 | 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 ); |
|---|
| 69 | 69 | } |
|---|
| 70 | 70 | |
|---|