-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignprocess.php
65 lines (50 loc) · 1.91 KB
/
signprocess.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
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
include_once "mysql.php";
include_once "common.php";
function setV($var) {
global $conn;
if (!isset($_POST[$var])) { echo json_encode(array("code"=>1)); die(); }
$temp = $conn->real_escape_string($_POST[$var]);
if ($temp == "") { echo json_encode(array("code"=>1)); die(); }
if ($var == "user") {
$q = $conn->query("SELECT id FROM users WHERE username = '$temp'");
if ($q->num_rows != 0) { echo json_encode(array("code"=>2)); die(); }
}
if ($var == "sch" || $var == "level") {
if ($var == "sch") $var = "school"; //Inconsistencies in database ><
$q = $conn->query("SELECT type FROM meta WHERE id = $temp");
if ($q->num_rows == 0) { echo json_encode(array("code"=>5)); die(); }
$r = $q->fetch_assoc();
if ($r['type'] != $var) { echo json_encode(array("code"=>5)); die(); }
}
return $temp;
}
$name = setV("name");
$level = setV("level");
$sch = setV("sch");
$email = setV("email");
$user = setV("user");
$pass = setV("pass");
$pass2 = setV("pass2");
if ($pass != $pass2) {echo json_encode(array("code"=>3)); die();}
$hash = password_hash($pass, PASSWORD_BCRYPT);
$code = sha1(time() . rand() . "saltingnotesacademy");
$q = $conn->query("INSERT INTO users VALUES (NULL, '$name', '$email', '$sch', '$level', '$user', '$hash', 0, '$code')");
if ($conn->error != "") {
echo json_encode(array("code"=>4)); die();
}
include "mail.php";
require 'vendor/autoload.php';
use Mailgun\Mailgun;
# Instantiate the client.
$mgClient = new Mailgun('key-213f48adefd728cc9b8e9fef93db1293');
$domain = "sandboxa292c28717dd4593ac738e7fadcd0de6.mailgun.org";
# Make the call to the client.
$result = $mgClient->sendMessage($domain, array(
'from' => 'NotesAcademy <noreply@notesacademy.org>',
'to' => $email,
'subject' => 'Welcome to NotesAcademy!',
'html' => $str
));
echo json_encode(array("code"=>0)); die();
?>