diff --git a/README.md b/README.md
index 7af5ee6..d024b0a 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,9 @@
# SMSDemo
-A demo website showing what you can do with the iP.1 PHP SDK in very little time.
-
+A simple secret santa app by SMS using the iP.1 PHP SDK.
## Contributors
* **Hannes Kindströmmer** - _Initial work_
-
-### Thanks to
- * [Unsplash](https://unsplash.com/) for providing the background image
+ * **Erik Wikström**
## License
This software demo is licensed under the MIT license.
diff --git a/background.jpg b/background.jpg
deleted file mode 100644
index 3513e22..0000000
Binary files a/background.jpg and /dev/null differ
diff --git a/composer.json b/composer.json
index 052f3d8..55ed122 100644
--- a/composer.json
+++ b/composer.json
@@ -1,14 +1,21 @@
{
- "name": "ip1sms/smsdemo",
- "description": "A frontend demo using the ip1-php-sdk",
+ "name": "wikxen/sms-secret-santa",
+ "description": "A secret santa app using the ip1-php-sdk",
+ "version": "1.0.0",
"type": "project",
"license": "MIT",
"authors": [
+ {
+ "name": "Erik Wikström",
+ "email": "wikxen@gmail.com",
+ "homepage": "http://wikxen.se",
+ "role": "Developer"
+ },
{
"name": "Hannes Kindströmmer",
"email": "hannes@kindstrommer.se",
"homepage": "http://kindstrommer.se",
- "role": "Developer"
+ "role": "Original Work"
}
],
"minimum-stability": "beta",
diff --git a/index.php b/index.php
deleted file mode 100644
index a5537b6..0000000
--- a/index.php
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SMS Når Långt - iP.1 Networks AB
-
-
-
-
-
-
-
-
-
-
-
-
- SMS Når Långt
-
-
-
-
diff --git a/sendsms.php b/sendsms.php
deleted file mode 100644
index e83f478..0000000
--- a/sendsms.php
+++ /dev/null
@@ -1,63 +0,0 @@
- 160) {
- header("Location:/");
-}
-
-
-// Parse the text string into an array of numbers
-$phoneNumbers = explode("\n", trim($_POST['recipients']));
-$phoneNumbers = array_map(function($number){
- return fixNumber($number);
-}, $phoneNumbers);
-shuffle($phoneNumbers);
-
-// Loop through the numbers sending
-// $i sends an SMS to $i+1
-for ($i=0; $i < count($phoneNumbers); $i++) {
- $sender = $phoneNumbers[$i];
- $recipient = $i != count($phoneNumbers) - 1 ? $phoneNumbers[$i + 1] : $phoneNumbers[0];
-
- $sms = new OutGoingSMS($sender, $_POST['text']);
- $sms->addNumber($recipient);
- $api->add($sms);
-}
-
-header("Location:/?sent=success");
-
-// Turns the numbers into the correct format
-function fixNumber(string $number): string{
- $prefix = '07';
- $alternativePrefix = '+467';
-
- // Remove unnecessary symbols
- $number = str_replace(['-','(',')',' '], '', $number);
- $number = trim($number);
-
- // If a number is invalid
- if (!preg_match('/(07|\+46|46)[0-9]{1,15}/', $number)) {
- header("Location:/");
- }
-// Replace 07 with 467
- if (substr($number, 0, strlen($prefix)) == $prefix) {
- $number = substr($number, strlen($prefix));
- $number = "467" . $number;
- }
- // Replace +467 with 467
- if (substr($number, 0, strlen($alternativePrefix)) == $alternativePrefix) {
- $number = substr($number, strlen($alternativePrefix));
- $number = "467" . $number;
- $number = str_replace(" ", "", $number);
- }
- return $number;
-}
diff --git a/webhook.php b/webhook.php
new file mode 100644
index 0000000..c83858f
--- /dev/null
+++ b/webhook.php
@@ -0,0 +1,45 @@
+addNumber($sender);
+ $api->add($sms);
+} else if (strtolower(substr($msg, 0, 2)) == "go") { // send
+ // Parse the file string into an array of people
+ $file = file_get_contents("santa.txt");
+ $people = explode(PHP_EOL, $file);
+ array_pop($people);
+ $people = array_unique($people);
+ shuffle($people);
+
+ // Loop through the numbers sending
+ // $i sends an SMS to $i+1
+ for ($i=0; $i < count($people); $i++) {
+ $sender = explode(";", $people[$i]);
+ $recipient = explode(";", $i != count($people) - 1 ? $people[$i + 1] : $people[0]);
+
+ $sms = new OutGoingSMS($sender[0], "Hej " . $recipient[1] . "!\nDu fick mig. Köp något bra nu för ungefär 100 kr.\n// " . $sender[1]);
+ $sms->addNumber($recipient[0]);
+ $api->add($sms);
+ }
+}
+
+echo "OK";