This repository was archived by the owner on Dec 10, 2024. It is now read-only.
forked from jdorn/php-reports
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
60 lines (44 loc) · 1.45 KB
/
index.php
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
<?php
session_start();
//set php ini so the page doesn't time out for long requests
ini_set('max_execution_time', 300);
//sets up autoloading of composer dependencies
include 'vendor/autoload.php';
//sets up autoload (looks in classes/local/, classes/, and lib/ in that order)
require 'lib/PhpReports/PhpReports.php';
Flight::route('/',function() {
PhpReports::listReports();
});
Flight::route('/dashboards',function() {
PhpReports::listDashboards();
});
Flight::route('/dashboard/@name',function($name) {
PhpReports::displayDashboard($name);
});
//JSON list of reports (used for typeahead search)
Flight::route('/report-list-json',function() {
header("Content-Type: application/json");
header("Cache-Control: max-age=3600");
echo PhpReports::getReportListJSON();
});
//if no report format is specified, default to html
Flight::route('/report',function() {
PhpReports::displayReport($_REQUEST['report'],'html');
});
//reports in a specific format (e.g. 'html','csv','json','xml', etc.)
Flight::route('/report/@format',function($format) {
PhpReports::displayReport($_REQUEST['report'],$format);
});
Flight::route('/edit',function() {
PhpReports::editReport($_REQUEST['report']);
});
Flight::route('/set-environment',function() {
header("Content-Type: application/json");
$_SESSION['environment'] = $_REQUEST['environment'];
echo '{ "status": "OK" }';
});
//email report
Flight::route('/email',function() {
PhpReports::emailReport();
});
Flight::start();