1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
4 * A controller that is sometimes available without authorization.
6 * That is, things here shouldn't expose secrets, but for DoS reasons,
7 * they're still not available from anybody who's both non-localhost (reports)
8 * and non-logged-in (actual users)
10 class Public_Controller
extends Controller
{
11 public function __construct()
14 if (!Auth
::instance()->get_user()) {
15 // And we don't come from ::1 or 127.0.0.0/8
16 if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ||
!($_SERVER['REMOTE_ADDR'] == '::1' ||
(ip2long($_SERVER['REMOTE_ADDR']) & (127 << 24)) !== (127 << 24))) {
17 // So we won't do anything
18 die("Invalid request");
26 public function piechart()
28 $this->auto_render
= false;
30 $graph = new PieChart(300, 200);
31 $graph->set_data($_GET, 'pie');
32 $graph->set_margins(43);
33 $graph->set_legend_precision(3);
42 public function barchart()
44 $this->auto_render
= false;
45 charts
::load('MultipleBar');
46 $graph = new MultipleBarChart(800, 600);
50 foreach ($_GET as $tmpkey => $tmpval) {
51 $barvalues[$tmpkey] = array(
52 str_replace(',', '.', $tmpval[1]),
53 str_replace(',', '.', $tmpval[0])
56 $barcolors[] = $tmpval[2] ? reports
::$colors['red'] : reports
::$colors['green'];
59 $graph->add_bar_colors($barcolors);
60 $graph->set_background_style(null);
61 $graph->set_plot_bg_color('#fff');
62 $graph->set_data($barvalues);
63 $graph->set_margins(7, 20);
64 $graph->set_approx_line_gap(50);
65 $graph->set_legend_y(_('Percent (%)'));
66 $graph->set_legend_x(_('Period'));