/
index.php
86 lines (69 loc) · 1.59 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
include('include/include.php');
$input = tropoInput();
// Tropo seems to not send the cookie with the recorded file, so we pass it in a query string parameter
if(get('session_id'))
session_id($_GET['session_id']);
session_start();
if(is_object($input))
{
if(property_exists($input, 'session'))
{
$_SESSION['session'] = $input->session;
$_SESSION['callerID'] = (@$input->session->from->id ? $input->session->from->id : '');
ircdebug('Incoming call from ' . $_SESSION['callerID']);
}
else
{
$sessionID = $_SESSION['session']->id;
}
}
else
$sessionID = FALSE;
$tropo = array();
$voice = 'allison';
switch(get('method'))
{
case '':
include('view.php');
die();
break;
case 'incoming':
define('SURVEY_MODE', TRUE);
include('survey.php');
$query = db()->prepare('INSERT INTO `calls` (`date`, `callerID`, `sessionID`) VALUES(:date, :callerID, :sessionID)');
$query->bindValue(':date', date('Y-m-d H:i:s'));
$query->bindValue(':callerID', $_SESSION['callerID']);
$query->bindValue(':sessionID', session_id());
$query->execute();
$_SESSION['callID'] = db()->lastInsertId();
$tropo[] = array(
'say' => array(
'value' => '. . . ' . $firstPrompt,
),
'voice' => $voice
);
askQuestion(array_shift($questions));
break;
default:
define('SURVEY_MODE', TRUE);
include('include/question.php');
break;
}
$json = json_encode(array('tropo'=>$tropo));
header('Content-type: text/plain');
if(get('test'))
{
echo formatJSON($json);
}
else
{
echo $json;
}
if(isset($_SESSION))
{
filedebug("\n\nSession:\n");
filedebug($_SESSION);
}
filedebug($json);
?>