This repository has been archived by the owner on Sep 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
149 lines (127 loc) · 3.26 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
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
<?
require_once('lib/init.php');
require_once('lib/template.php');
require_once('contrib/tropo/tropo.class.php');
require_once('contrib/simplepie/simplepie.inc');
require_once('lib/simplepie_snowrss.php');
if ( isset($_REQUEST['f']) ) {
if ( $_REQUEST['f'] == 'voice' ) {
# tropo
$format = 'voice';
}
elseif ( $_REQUEST['f'] == 'rss' ) {
# defunct?
$format = 'rss';
}
elseif ( $_REQUEST['f'] == 'html' ) {
# html
$format = 'html';
}
else {
# html
$format = 'html';
}
}
else {
# html
$format = 'html';
}
$feeds = $resort_names = array();
foreach ($resorts as $code => $info) {
$url = $info['url'];
$feeds[$code] = new SimplePie_SnowRSS($url, sys_get_temp_dir());
$feeds[$code]->set_item_class('SimplePie_Item_SnowRSS');
$feeds[$code]->init();
$feeds[$code]->handle_content_type();
$resort_names[$info['name']] = $code;
}
if ($format == 'html') {
if ( $mobile ) {
$body_tpl = 'templates/mobile/home.php';
$page_tpl = 'templates/mobile/default.php';
}
else {
$body_tpl = 'templates/home.php';
$page_tpl = 'templates/default.php';
}
$Body = new Template($body_tpl);
$Body->set('feeds', $feeds);
$T = new Template($page_tpl);
$T->set('title', 'SnowLine');
$T->set('tagline', 'A SnowRSS Aggregator');
$T->set('body', $Body);
echo($T->fetch());
exit;
}
if ($format == 'voice') {
$tropo = new Tropo();
if ( ! $_REQUEST['goto'] ) {
// Welcome prompt.
$tropo->say('Welcome to Snow Line');
// Set up options for input.
$options = array(
"attempts" => 3,
"bargein" => true,
"choices" => 'Mount Rose, Blueberry Hill, Mount Marley',
"name" => "resort",
"timeout" => 30,
"voice" => $tropo_voice
);
// Ask the caller for input, pass in options.
$tropo->ask('Please speak the name of a ski resort',
$options
);
# Tell Tropo what to do when the user has entered input,
# or if there's an error.
$tropo->on(array(
"event" => "continue",
"next" => "index.php?f=voice&goto=choice",
"say" => "One moment."
));
$tropo->on(array(
"event" => "error",
"next" => "index.php?f=voice&goto=incomplete"
));
}
elseif ( $_REQUEST['goto'] == 'choice' ) {
$result = new Result();
$choice = $result->getValue();
if ( isset($resort_names[$choice])) {
$resort_name = $choice;
$code = $resort_names[$choice];
$feed =& $feeds[$code];
$conditions = $resort_name . ' is currently ';
if ( strtolower($feed->get_snowrss_status()) == 'open' ) {
$conditions .= ' open';
if ($close_date = $feed->get_snowrss_scheduled_close_date('F jS') ) {
$conditions .= ', but is scheduled to close on '
. $close_date;
}
}
elseif ( strtolower($feed->get_snowrss_status()) == 'closed' ) {
$conditions .= ' closed';
if ($open_date = $feed->get_snowrss_scheduled_open_date() ) {
$conditions .= ', but is scheduled to open on '
. $open_date;
}
}
else {
$conditions .= ' unknown';
}
$tropo->say(
"You chose " . $resort_name . '. ' . $conditions,
array("voice" => $tropo_voice)
);
}
else {
$tropo->say("I'm confused again.");
}
}
elseif ( $_REQUEST['goto'] == 'error' ) {
$tropo->say("I'm confused now", array("voice" => $tropo_voice));
}
$tropo->RenderJson();
echo("\n");
exit;
}
?>