-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.php
More file actions
49 lines (43 loc) · 1.43 KB
/
Copy pathconnect.php
File metadata and controls
49 lines (43 loc) · 1.43 KB
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
<?php
// Set $password outside of public source control
include "secure.php";
include "JWT.php";
include "getkey.php";
include "config.php";
try {
if ($_REQUEST['id_token']) {
$token = JWT::decode($_REQUEST['id_token'], $oauthKey);
if ($token->aud != '287420793573-8tg9b6aoq8c89ooctbiqmu89uncddfa0.apps.googleusercontent.com') {
http_response_code(500);
header("Content-Type: text/plain");
die("Authentication failed: token was not intended for this application.");
}
$googleid = $token->sub;
} /* else {
http_response_code(403);
header("Content-Type: text/plain");
die("Authentication required.");
}*/
} catch (UnexpectedValueException $e) {
$googleid = null;
}
if (!empty($_REQUEST['username']))
setcookie("username", $_REQUEST['username'], time() + 60 * 60 * 24 * 7, '/drawperator/');
$servername = "mysql.enigmadream.com";
$dbname = "enigmadream";
$dbuser = "enigmadream_tg";
// Moved to secure.php
// $password = "****";
if (!empty($_POST['username']))
$username = $_POST['username'];
elseif (!empty($_REQUEST['username']))
$username = $_REQUEST['username'];
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbuser, $password);
} catch (PDOException $e) {
http_response_code(500);
header("Content-Type: text/plain");
die("Connection failed: " . $e->getMessage());
}
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>