Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 94 lines (85 sloc) 2.977 kB
0d31346 Hanging the app code
Mitchell Hislop authored
1 <?php
ae34ec9 most of response done. Waiting for site to integrate it into
Mitchell Hislop authored
2 include 'config.php';
3 $dbconnect=mysql_connect('localhost', $mysql_user, $mysql_pass);
4 if(!$dbconnect){
5 die('Could Not Connect:' .mysql_error());
6 }
7 mysql_select_db('twilio_app');
6bc555f RESPONSE IS DONE. Just doing some outbound left
Mitchell Hislop authored
8 $from=$_REQUEST['From'];
9 $case = $_REQUEST['Body'];
10 //$case = "EVENT";
7e155bd adding in the interactive. Cases are done, need to add in the DB inte…
Mitchell Hislop authored
11 $case=strtoupper($case);
ae34ec9 most of response done. Waiting for site to integrate it into
Mitchell Hislop authored
12
7e155bd adding in the interactive. Cases are done, need to add in the DB inte…
Mitchell Hislop authored
13 if ($case == "ADD")
ae34ec9 most of response done. Waiting for site to integrate it into
Mitchell Hislop authored
14 { $new_number=$_REQUEST['From'];
15 $number = ereg_replace("[^0-9]", "", $new_number );
112b6b0 all interactions except for events are done.
Mitchell Hislop authored
16
17 $dupecheck="SELECT * FROM numbers WHERE number='".mysql_real_escape_string($number)."' AND active='1'";
18
ae34ec9 most of response done. Waiting for site to integrate it into
Mitchell Hislop authored
19 $result=mysql_query($dupecheck);
112b6b0 all interactions except for events are done.
Mitchell Hislop authored
20 $num_rows=mysql_num_rows($result);
21 if ($num_rows == 0)
ae34ec9 most of response done. Waiting for site to integrate it into
Mitchell Hislop authored
22 {
112b6b0 all interactions except for events are done.
Mitchell Hislop authored
23 $query="INSERT INTO numbers (number, active) VALUES ('".mysql_real_escape_string($number)."','1')";
24 $results=mysql_query($query);
7e155bd adding in the interactive. Cases are done, need to add in the DB inte…
Mitchell Hislop authored
25 $message="You have been added. Thank you for supporting Project 515";
ae34ec9 most of response done. Waiting for site to integrate it into
Mitchell Hislop authored
26 }
27 else
112b6b0 all interactions except for events are done.
Mitchell Hislop authored
28 {
29 $message="You are already subscribed. Thank you for supporting Project 515";
ae34ec9 most of response done. Waiting for site to integrate it into
Mitchell Hislop authored
30 }
31
7e155bd adding in the interactive. Cases are done, need to add in the DB inte…
Mitchell Hislop authored
32 }
33 else if ($case == "STOP")
ae34ec9 most of response done. Waiting for site to integrate it into
Mitchell Hislop authored
34 { $new_number=$_REQUEST['From'];
35 $number = ereg_replace("[^0-9]", "", $new_number );
112b6b0 all interactions except for events are done.
Mitchell Hislop authored
36
37 $query = "DELETE FROM numbers WHERE number='".mysql_real_escape_string($number)."'";
38 $result=mysql_query($query);
7e155bd adding in the interactive. Cases are done, need to add in the DB inte…
Mitchell Hislop authored
39 $message = "You have been unsubscribed. Txt Add to subscribe again";
6bc555f RESPONSE IS DONE. Just doing some outbound left
Mitchell Hislop authored
40
7e155bd adding in the interactive. Cases are done, need to add in the DB inte…
Mitchell Hislop authored
41 }
42 else if($case=="NEWS"){
112b6b0 all interactions except for events are done.
Mitchell Hislop authored
43 mysql_select_db('fcw_wp_00');
44 $query="SELECT max(id) as id FROM wp_posts WHERE post_type='post'"; //WHERE type="blast this shit yo"
45 $result=mysql_query($query);
46 $row = mysql_fetch_assoc($result);
47 $row=$row['id'];
48 $query="SELECT post_title, guid FROM wp_posts WHERE id=$row";
49 $result=mysql_query($query);
50 $row=mysql_fetch_array($result);
51 $link=$row['guid'];
52 $title=$row['post_title'];
53 //bit.ly api goes here
54 $login="project515";
55 $appkey="R_315ad1d93fff05076a8f9d7e053c6257";
56 $format="xml";
57 $url=$link;
58 $bitly = 'http://api.bit.ly/v3/shorten?longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$appkey.'&format='.$format;
59 //get the url
60 //could also use cURL here
61 $response = file_get_contents($bitly);
62 //parse depending on desired format
63 $xml = simplexml_load_string($response);
64 $link = $xml->data->url;
65 $message = "The most recent news item is: $title $link";
0d31346 Hanging the app code
Mitchell Hislop authored
66 }
7e155bd adding in the interactive. Cases are done, need to add in the DB inte…
Mitchell Hislop authored
67 else if ($case=="EVENT" OR $case=="EVENTS")
0d31346 Hanging the app code
Mitchell Hislop authored
68 {
7e155bd adding in the interactive. Cases are done, need to add in the DB inte…
Mitchell Hislop authored
69 //pull most recent event
6bc555f RESPONSE IS DONE. Just doing some outbound left
Mitchell Hislop authored
70 mysql_select_db('fcw_wp_00');
71 $query="SELECT * from `wp_em_events` where `event_start_date` > NOW() ORDER BY `event_start_date` LIMIT 1";
72 $result=mysql_query($query);
73 $result=mysql_fetch_assoc($result);
74 $event = $result['event_name'];
75 $date=$result['event_start_date'];
76 $loc_id=$result['location_id'];
77 $query2="SELECT location_name FROM wp_em_locations WHERE location_id=$loc_id ";
78 $result2=mysql_query($query2);
79 $result2=mysql_fetch_assoc($result2);
80 $location=$result2['location_name'];
81 $message="Next Event: $event on $date at $location.";
82
83 }
0d31346 Hanging the app code
Mitchell Hislop authored
84 else {
6bc555f RESPONSE IS DONE. Just doing some outbound left
Mitchell Hislop authored
85 $message="I didn't understand that. Try Add, News, Event, or Stop";
86 }
112b6b0 all interactions except for events are done.
Mitchell Hislop authored
87 header("content-type: text/xml");
0d31346 Hanging the app code
Mitchell Hislop authored
88 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
25eceb3 more updates. Waiting for sync
Mitchell Hislop authored
89
0d31346 Hanging the app code
Mitchell Hislop authored
90 ?>
91 <Response>
112b6b0 all interactions except for events are done.
Mitchell Hislop authored
92 <Sms><?php echo $message;?></Sms>
6bc555f RESPONSE IS DONE. Just doing some outbound left
Mitchell Hislop authored
93 </Response>
Something went wrong with that request. Please try again.