-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathindex.php
executable file
·113 lines (85 loc) · 2.94 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
<?php
// index.php
require('includes/Twilio.php');
include('config/config.php');
include('includes/functions.php');
include('config/messages.php');
// get all contacts and...
$smsMessages=array();
$twilioMessages=$client->account->messages;
foreach($twilioMessages as $sms) {
if($twilioPhoneNumber!=$sms->from) {
array_push($smsMessages,array("from"=>$sms->from,"to"=>$sms->to,"body"=>$sms->body,"date_sent"=>$sms->date_sent));
}
}
// ...eliminate duplicates
$smsMessages=array_multi_unique($smsMessages,"from");
// Mark Conversation as unread
if($_GET['mode']=="mark"){
markConversationUnread($_GET['no']);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include('config/meta.php');?>
</head>
<body>
<header class="header">
<p class="bold">Project <?php echo $projectName; ?> / <?php echo $projectPhoneNumber; ?></p>
</header>
<section class="wrapper">
<div class="filterBox">
<span>Filter messages by...</span>
<div>
<ul>
<?php
foreach($conversationFilters as $f){
if($f!=$conversationFilters[0]) echo "<li><a href=\"?mode=filter&f=".$f."\">#".$f."</a></li>";
}
if($_GET['mode']=="filter"){
echo "<br><br><a href=\"index.php\">( Show All )</a>";
}
?>
</ul>
</div>
</div>
<section class="main">
<div class="newConvoBox">
<span>Start a conversation with
<input type="tel" name="newConvo" id="newConvo" class="newConvo" placeholder="enter phone number" />
<input type="button" value="go" id="newConvoBtn" class="newConvoBtn bold small" />
</span>
</div>
<?php
// List of all the conversation participants
foreach ($smsMessages as $sms) {
$html="";
$flag=checkReadConversation($sms['from']); // check conversation is read / unread
$thisFilter=getConversationFilter($sms['from']);
$html.="\n<section class=\"conversation\">";
$html.= "\n\t<p class=\"bold\"><a href=\"actions/conversation.php?no=".urlencode($sms['from'])."\">".formatAnonymousPhoneNumber($sms['from'])."</a></p>";
if(!strpos($sms['body'],"#servicemsg")){
if($flag=="unread") $html.="\n\t<p class=\"text bold\">".shortenText($sms['body'],120)."</p>";
else $html.="\n\t<p class=\"text\">".shortenText($sms['body'],120)."</p>";
if(($thisFilter!=$conversationFilters[0])&&($thisFilter!="")) $html.="\n\t<p class=\"ltgrey small bold\">#".$thisFilter."</p>\n";
$html.="\n\t<p class=\"ltgrey small bold\">".convertTime($sms['date_sent'],"UTC","America/New_York")."</p>\n";
}
$html.="</section>";
// if filter mode is on, show only related conversations
if($_GET['mode']=="filter"){
if($thisFilter==$_GET['f']) echo $html;
}
else{
echo $html;
}
}
mysqli_close($dbConnection);
?>
</section>
</section>
<!--Scripts-->
<script src="assets/js/jquery-2.1.3.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>