-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkill.php
50 lines (40 loc) · 1.49 KB
/
kill.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
<?php
require_once('libraries/library.php');
require_once('libraries/googlevoice.php');
require_once('/home/webby/fbhackathon/credentials.php');
$gv = new GoogleVoice(VOICE_USER, VOICE_PASS);
// get all new SMSs
$sms = $gv->getNewSMS();
$msgIDs = array();
foreach (array_reverse($sms) as $s) {
if (!in_array($s['msgID'], $msgIDs)) {
$possible_fbid = base_convert(strtolower(trim($s['message'])), 36, 10);
if(userExists($possible_fbid)) {
updatePhoneNumber($possible_fbid, $s['phoneNumber']);
$gv->sendSMS(substr($s['phoneNumber'], 2), "Thanks for activating. Your account now reflects this mobile number.");
echo 'Updated ' . $s['message'] . ' number with ' . $s['phoneNumber'];
} else if($s['message'] !== "Error: this message was not successfully delivered.") {
print_r($s);
$dead_number = $s['phoneNumber'];
$game_name = $s['message'];
$result = killUser($dead_number, $game_name);
if ($result) {
$killer = substr($result['killer']['phone'], 2);
$new_target = $result['newtarget']['name'];
$msgs = "";
if ($result['victory']) {
$msgs = "Congratulations, master assassin! You're the winner of " . $game_name . "!";
} else {
$msgs = "Congratulations, assassin! Your new target is " . $new_target . ". Good luck!";
}
// send killer new target
$gv->sendSMS($killer, $msgs);
echo $msgs;
}
}
// mark the conversation as "read" in google voice
$gv->markSMSRead($s['msgID']);
$msgIDs[] = $s['msgID'];
}
}
?>