-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
86 lines (80 loc) · 2.39 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
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
<?php
//$xmlPath = "empty.xml";
//$xmlPath = "Narrtrips-fix.xml";
ini_set('display_errors', true);
ini_set('error_reporting', E_ALL);
require_once('_private/timer.inc.php');
$version = 2.2; // to make cache unique between versions
require_once('Cache/Lite.php');
require_once('_private/formatListings.inc.php');
$cacheOptions = array(
'cacheDir' => '/tmp/',
'lifeTime' => 300
);
//$cache = new Cache_Lite_Output($cacheOptions);
$groupID = isset($_REQUEST['c']) ? $_REQUEST['c'] : '';
//include('_private/config.inc.php');
$format = isset($_REQUEST['output']) ? $_REQUEST['output'] : '';
if ($format == 'ics') {
$xslPath = "amc-trips-to-ical.xsl";
$contentType = 'text/calendar;charset=UTF-8';
}
elseif ($format == 'rss') {
$xslPath = "amc-trips-to-rss.xsl";
$contentType = 'application/rss+xml';
}
elseif ($format == 'email') {
$xslPath = "amc-trips-to-html-email.xsl";
$contentType = 'text/html;charset=UTF-8';
}
elseif ($format == 'bostonpage') {
$xslPath = "amc-trips-to-boston-page.xsl";
$contentType = 'text/html;charset=UTF-8';
}
elseif ($groupID == 'worcesterym') {
$xslPath = "amc-trips-to-worcester-page.xsl";
$contentType = 'text/html;charset=UTF-8';
}
elseif ($groupID == 'hbboston') {
$xslPath = "amc-trips-to-boston-hb-page.xsl";
$contentType = 'text/html;charset=UTF-8';
}
elseif ($groupID == 'bostonintro') {
$xslPath = "amc-trips-to-boston-intro-page.xsl";
$contentType = 'text/html;charset=UTF-8';
}
else {
$xslPath = "amc-trips-to-html-page.xsl";
$contentType = 'text/html;charset=UTF-8';
$GLOBALS['showTimer'] = !empty($_REQUEST['timer']);
}
header('Content-Type: '.$contentType);
//if (!empty($_REQUEST['nc']) || !$cache->start($format.$version.$groupID)) {
if (empty($_REQUEST['nc'])) {
$cache = new Cache_Lite($cacheOptions);
$cacheID = $format.$version.$groupID;
$cachedData = $cache->get($cacheID);
}
else {
$cache = $cacheID = $cachedData = null;
}
if (!$cachedData) {
$result = formatListings($groupID, $xslPath);
if (!strlen($result)) {
die('Error: the XML data could not be formatted for display. Please try again later.');
}
if ($cache) {
$cache->save($result, $cacheID);
}
}
else {
$result = $cachedData;
}
echo $result;
if ($format != 'ics') {
echo '<!-- ';
echo strlen($cachedData) ? 'retrieved from cache ' : 'generated ';
timeMilestone('');
echo ' -->';
}
?>