-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions.php
52 lines (42 loc) · 1.47 KB
/
functions.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
<?php
session_start();
include 'fullcourt.php';
function user_generate_token($username, $phoneNum){
global $accountsid, $authtoken, $fromNumber;
// Create a new password
$password = substr(md5(time().rand(0, 10^10)), 0, 5);
// Store the username and password.
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
/* Set our AccountSid and AuthToken */
$accountsid= "FC20f8676ba75a63ba452784ca5858d217";
$authtoken= "ocYw1LU8A9w64uztN5dKPzwrNH9ynmuXtx";
$fromNumber="FullCourt";
$client = new RestAPI($accountsid, $authtoken);
// Prepare the message with the password embedded
$content = "Your newly generated password is ".$password;
$params = array(
'To' => $phoneNum,
'From' => $fromNumber,
'Body' => $content
);
// Send the message via SMS or Voice
$item = $client->send_message($params);
$message = "A new password has been generated and sent to your phone number.";
return $message;
}
function user_login($username, $submitted) {
// Retrieve the stored password
$stored = $_SESSION['password'];
// Compare the retrieved vs the stored password
if ($stored == $submitted) {
$message = "Hello and welcome back $username";
} else {
$message = "Sorry, that's an invalid username and password combination.";
}
// Clean up after ourselves
unset($_SESSION['username']);
unset($_SESSION['password']);
return $message;
}
?>