1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8require_once('tiki-setup.php');
9$access->check_feature('feature_stats');
10$access->check_permission('tiki_p_view_stats');
11require_once("lib/graph-engine/gd.php");
12require_once("lib/graph-engine/graph.multiline.php");
13
14//Define the object
15$renderer = new GD_GRenderer(450, 300);
16$graph = new MultilineGraphic;
17$graph->setTitle(tra('Pageviews'));
18//Set some data
19if (! isset($_REQUEST["days"])) {
20	$_REQUEST["days"] = 7;
21}
22
23$statslib = TikiLib::lib('stats');
24$data = $statslib->get_pv_chart_data($_REQUEST["days"]);
25
26foreach ($data['xdata'] as $key => $date) {
27	 $data['xdata'][$key] = strtotime($date) / 24 / 3600;
28}
29$graph->setData(['x' => $data['xdata'], 'y0' => $data['ydata']]);
30$graph->setParam('grid-independant-major-font', false);
31$graph->setParam('grid-independant-major-guide', false);
32$graph->draw($renderer);
33$renderer->httpOutput('stats.png');
34