-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb.php
More file actions
110 lines (91 loc) · 3.57 KB
/
db.php
File metadata and controls
110 lines (91 loc) · 3.57 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/*
* Copyright (C) 2017 alexgriffen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// THIS IS THE SETUP FOR CLEARDB,
// WHICH I'LL NEED FOR THIS TO WORK WITH HEROKU
$url = parse_url(getenv("CLEARDB_DATABASE_URL"));
$server = $url["host"];
$username = $url["user"];
$password = $url["pass"];
$db = substr($url["path"], 1);
//$dbadmin = getenv('DB_ADMIN');
//$dbpassword = getenv('DB_PASSWORD');
//$servername = "localhost";
//$dbname = "testdb";
$time = time();
if (isset($signature_request_id)) {
// Create connection
$conn = new mysqli($server, $username, $password, $db);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (isset($signer_email)) {
$sql = "INSERT INTO signature_request VALUES('$signature_request_id','$createdHow','$signer_email','$time')";
} else {
$sql = "INSERT INTO signature_request VALUES('$signature_request_id','$createdHow',NULL,'$time')";
}
if ($conn->query($sql) === TRUE) {
echo "INSERT to signature_request successfull";
} else {
echo "<br />Error INSERTing (lol): " . $conn->error;
}
} elseif (isset($template_id)) {
// Create connection
$conn = new mysqli($server, $username, $password, $db);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO template VALUES('$template_id','$createdHow','$time')";
if ($conn->query($sql) === TRUE) {
echo "INSERT to template successfull";
} else {
echo "<br />Error INSERTing (lol): " . $conn->error;
}
} elseif (isset($_SESSION['fromEmbeddedRequesting']) && $_SESSION['fromEmbeddedRequesting'] == true) {
// Create connection
$conn = new mysqli($server, $username, $password, $db);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$converted = json_encode($signature_request_object->toArray());
$signature_request_id = $_SESSION['signature_request_id'];
$sql = "INSERT INTO signature_request_json VALUES('$signature_request_id','embeddedRequesting','$converted')";
if ($conn->query($sql) === TRUE) {
echo "INSERT to signature_request_json successfull";
} else {
echo "<br />Error INSERTing (lol): " . $conn->error;
}
} elseif (isset($hw_email)) {
// Create connection
$conn = new mysqli($server, $username, $password, $db);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO helloworks VALUES('$hw_instance_id','$hw_name','$hw_email','$hw_sign_url')";
if ($conn->query($sql) === TRUE) {
echo "INSERT to helloworks successfull";
} else {
echo "<br />Error INSERTing (lol): " . $conn->error;
}
// TODO - setup callback server to save state of request
// if same signer comes back to HelloWorks, serve same hw_sign_url
}
$conn->close();