From a174ec72c7ccf00035fdc2b63e5f00cc93f87c87 Mon Sep 17 00:00:00 2001 From: Achia Rolence Date: Thu, 19 Oct 2017 21:27:35 +0100 Subject: [PATCH] Add files via upload --- README.md | 40 +++++++++++- _gitignore | 2 + create_database.php | 14 +++++ get_votes.php | 13 ++++ handle_incoming_call.xml | 4 ++ handle_incoming_sms.php | 22 +++++++ index.php | 127 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 219 insertions(+), 3 deletions(-) create mode 100644 _gitignore create mode 100644 create_database.php create mode 100644 get_votes.php create mode 100644 handle_incoming_call.xml create mode 100644 handle_incoming_sms.php create mode 100644 index.php diff --git a/README.md b/README.md index a1bdab2..321e56c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,37 @@ -# skysoft -skylabase voip softphones -the project is an open source project aimed at developing voip application for skylabase intercom system +Text-to-Vote +============ + +Text-to-Vote is a simple web app that allows you to do realtime polling through +SMS. + +Text-to-Vote works with the Twilio API, so you'll need an account and phone +number at Twilio before you can get started. Twilio sells simple, pay as you +go phone services, and you can sign up for a free account with $30 of free +credits at [http://www.twilio.com](http://www.twilio.com). + +Installation +============ + +Installation of Text-to-Vote is as simple as copying the folder, making it +writeable, editing the configuration file, creating the database and pointing +Twilio to the correct handlers. + +1. Copy the folder to your server. + +2. Make the folder writeable. + +3. Edit `/include/config.php` + +4. Run `create_database.php` by browsing to `http://yourserver/Text-to-Vote/create_database.php` + +5. Go to your [Twilio numbers page](https://www.twilio.com/user/account/phone-numbers/) + and point the Voice URL to `http://yourserver/Text-to-Vote/handle_incoming_call.xml` + (leave the default POST method selected) and point the SMS URL to + `http://yourserver/Text-to-Vote/handle_incoming_sms.php` + +License +======= + +Copyright (C) 2011 Rahim Sonawalla ([rahim@twilio.com](mailto:rahim@twilio.com) / [@rahims](http://twitter.com/rahims)) and Will Light ([wrl@illest.net](mailto:wrl@illest.net) / [@dudestache](http://twitter.com/dudestache)). + +Released under the [MIT license](http://www.opensource.org/licenses/mit-license.php). diff --git a/_gitignore b/_gitignore new file mode 100644 index 0000000..f31b3e2 --- /dev/null +++ b/_gitignore @@ -0,0 +1,2 @@ +.DS_Store +*.swp diff --git a/create_database.php b/create_database.php new file mode 100644 index 0000000..1813f39 --- /dev/null +++ b/create_database.php @@ -0,0 +1,14 @@ +init(); + + echo 'Database created.'; + } + else { + echo 'Database already exists. Feel free to delete me.'; + } +?> diff --git a/get_votes.php b/get_votes.php new file mode 100644 index 0000000..3dc77cd --- /dev/null +++ b/get_votes.php @@ -0,0 +1,13 @@ +get_teams(); + + foreach ($teams as $team) + { + $votes[] = (int) $team['votes']; + } + + echo json_encode($votes); +?> diff --git a/handle_incoming_call.xml b/handle_incoming_call.xml new file mode 100644 index 0000000..e168b4f --- /dev/null +++ b/handle_incoming_call.xml @@ -0,0 +1,4 @@ + + + Voting is powered by Twilio. Visit www.twilio.com for more information. + diff --git a/handle_incoming_sms.php b/handle_incoming_sms.php new file mode 100644 index 0000000..f0a69e6 --- /dev/null +++ b/handle_incoming_sms.php @@ -0,0 +1,22 @@ +'; + + $phone_number = $_REQUEST['From']; + $team_number = (int) $_REQUEST['Body']; + + if ( (strlen($phone_number) >= 10) && ($team_number > 0) ) + { + $db = new DB(); + + $response = $db->save_vote($phone_number, $team_number); + } + else { + $response = 'Sorry, I didn\'t understand that. Text the team number to vote. For example, texting 1 will vote for Team 1.'; + } + + echo ''.$response.''; + echo ''; +?> diff --git a/index.php b/index.php new file mode 100644 index 0000000..ae67ea2 --- /dev/null +++ b/index.php @@ -0,0 +1,127 @@ + + + + + + + <?php echo POLL_NAME; ?> + + + + + + + + + + +
+

Text team number to

+
+ +
+

+
+ +