This file is indexed.

/usr/share/php/sparkline/Sparkline_Bar.php is in libsparkline-php 0.2-6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
/*
 * Sparkline PHP Graphing Library
 * Copyright 2004 James Byers <jbyers@users.sf.net>
 * http://sparkline.org
 *
 * Sparkline is distributed under a BSD License.  See LICENSE for details.
 *
 * $Id: Sparkline_Bar.php,v 1.2 2004/11/09 06:18:52 jbyers Exp $
 *
 */

require_once('Sparkline.php');

class Sparkline_Bar extends Sparkline {

  var $dataSeries;
  var $dataSeriesStats;
  var $dataSeriesConverted;
  var $yMin;
  var $yMax;
  var $barWidth;
  var $barSpacing;
  var $barColorDefault;
  var $barColorUnderscoreDefault;

  ////////////////////////////////////////////////////////////////////////////
  // constructor
  //
  function Sparkline_Bar($catch_errors = true) {
    parent::Sparkline($catch_errors);

    $this->dataSeries                = array();
    $this->dataSeriesStats           = array();
    $this->dataSeriesConverted       = array();
    $this->barWidth                  = 1;
    $this->barSpacing                = 1;
    $this->barColorDefault           = 'black';
    $this->barColorUnderscoreDefault = 'black';
  } // function Sparkline

  ////////////////////////////////////////////////////////////////////////////
  // color, image property setting
  //
  function SetBarWidth($value) {
    $this->Debug("Sparkline_Bar :: SetBarWidth($value)", DEBUG_SET);
    $this->barWidth = $value;
  } // function SetBarWidth

  function SetBarSpacing($value) {
    $this->Debug("Sparkline_Bar :: SetBarSpacing($value)", DEBUG_SET);
    $this->barSpacing = $value;
  } // function SetBarSpacing

  function SetBarColorDefault($value) {
    $this->Debug("Sparkline_Bar :: SetBarColorDefault($value)", DEBUG_SET);
    $this->barColorDefault = $value;
  } // function SetBarColorDefault

  function SetBarColorUnderscoreDefault($value) {
    $this->Debug("Sparkline_Bar :: SetBarColorUnderscoreDefault($value)", DEBUG_SET);
    $this->barColorUnderscoreDefault = $value;
  } // function SetBarColorUnderscoreDefault

  ////////////////////////////////////////////////////////////////////////////
  // data setting
  //
  function SetData($x, $y, $color = null, $underscore = false, $series = 1) {
    $x = trim($x);
    $y = trim($y);

    $this->Debug("Sparkline_Bar :: SetData($x, $y, $series)", DEBUG_SET);

    if (!is_numeric($x) || 
        !is_numeric($y)) {
      $this->Debug("Sparkline_Bar :: SetData rejected values($x, $y) in series $series", DEBUG_WARNING);
      return false;
    } // if

    if ($color == null) {
      $color = $this->barColorDefault;
    }

    $this->dataSeries[$series][$x] = array('value'      => $y,
                                           'color'      => $color,
                                           'underscore' => $underscore);

    if (!isset($this->dataSeriesStats[$series]['min']) ||
        $y < $this->dataSeriesStats[$series]['min']) {
      $this->dataSeriesStats[$series]['min'] = $y;
    }

    if (!isset($this->dataSeriesStats[$series]['max']) ||
        abs($y) > $this->dataSeriesStats[$series]['max']) {
      $this->dataSeriesStats[$series]['max'] = abs($y);
    }
  } // function SetData

  function SetYMin($value) {
    $this->Debug("Sparkline_Bar :: SetYMin($value)", DEBUG_SET);
    $this->yMin = $value;
  }

  function SetYMax($value) {
    $this->Debug("Sparkline_Bar :: SetYMax($value)", DEBUG_SET);
    $this->yMax = $value;
  }
  
  function ConvertDataSeries($series, $xBound, $yBound) {
    $this->Debug("Sparkline_Bar :: ConvertDataSeries($series, $xBound, $yBound)", DEBUG_CALLS);

    if (!isset($this->yMin)) {
      $this->yMin = $this->dataSeriesStats[$series]['min'];
    }

    if (!isset($this->yMax)) {
      $this->yMax = $this->dataSeriesStats[$series]['max'];
    }

    while (list(, $v) = each($this->dataSeries[$series])) {
      $y = floor($v['value'] * ($yBound / (abs($this->yMax) + abs($this->yMin))));
      $this->dataSeriesConverted[$series][] = array('value'      => $y,
                                                    'color'      => $v['color'],
                                                    'underscore' => $v['underscore']);

      if (!isset($this->dataSeriesStats[$series]['min_converted']) ||
          $y < $this->dataSeriesStats[$series]['min_converted']) {
        $this->dataSeriesStats[$series]['min_converted'] = $y;
      }
      
      if (!isset($this->dataSeriesStats[$series]['max_converted']) ||
          abs($y) > $this->dataSeriesStats[$series]['max_converted']) {
        $this->dataSeriesStats[$series]['max_converted'] = abs($y);
      }
    }
    reset($this->dataSeries[$series]);

  } // function ConvertDataSeries

  function CalculateImageWidth() {
    $this->Debug("Sparkline_Bar :: CalculateImageWidth()", DEBUG_CALLS);

    $count = sizeof($this->dataSeries[1]); 
    return (($count - 1) * $this->barSpacing) + ($count * $this->barWidth);
  } // function CalculateImageWidth
  
  ////////////////////////////////////////////////////////////////////////////
  // rendering
  //
  function Render($y) {
    $this->Debug("Sparkline_Bar :: Render($y)", DEBUG_CALLS);

    // calculate size based on sets for init
    //
    if (!parent::Init($this->CalculateImageWidth(), $y)) {
      return false;
    }

    // convert based on actual canvas size
    //
    $this->ConvertDataSeries(1, $this->GetGraphWidth(), $this->GetGraphHeight());

    // stats debugging
    //
    $this->Debug('Sparkline_Bar :: Draw' . 
                 ' series: 1 min: ' . $this->dataSeriesStats[1]['min'] . 
                 ' max: ' . $this->dataSeriesStats[1]['max'] . 
                 ' height: ' . $this->GetGraphHeight() . 
                 ' yfactor: ' . ($this->GetGraphHeight() / (abs($this->dataSeriesStats[1]['max']) + abs($this->dataSeriesStats[1]['min']))));

    $this->DrawBackground();

    $yAxis = abs(min($this->dataSeriesStats[1]['min_converted'], 0));
    for ($i = 0; $i < sizeof($this->dataSeriesConverted[1]); $i++) {
      $this->DrawRectangleFilled($i * ($this->barWidth + $this->barSpacing), 
                                 $yAxis, 
                                 $i * ($this->barWidth + $this->barSpacing) + $this->barWidth - 1, 
                                 $yAxis + $this->dataSeriesConverted[1][$i]['value'], 
                                 $this->dataSeriesConverted[1][$i]['color']);
      if ($this->dataSeriesConverted[1][$i]['underscore']) {
        $this->DrawLine(max(0, $i * ($this->barWidth + $this->barSpacing) - ($this->barSpacing / 2)),
                        $yAxis,
                        min($this->GetGraphWidth(), $i * ($this->barWidth + $this->barSpacing) + ($this->barSpacing / 2)),
                        $yAxis,
                        $this->barColorUnderscoreDefault);
      }
    }
  } // function Render
} // class Sparkline_Bar

?>