forked from AyatsujiTsukasa/Ant-Planner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crxLogin.php
43 lines (36 loc) · 1.12 KB
/
crxLogin.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
<?php
$servername = "localhost";
$name = "antinc";
$password = "AntInc_AntInc123";
$dbname = "Ant_Planner";
$conn = mysqli_connect($servername, $name, $password, $dbname);
if (!$conn) {
die("Connection failed: ".mysqli_connect_error());
}
if(!$_GET) {
die("This file cannot be accessed directly!");
}
$email = isset($_GET["email"])?$_GET["email"]:"";
$username = isset($_GET["username"])?$_GET["username"]:"";
$password = $_GET["password"];
$verified = false;
$PWResult = $conn->query("select password, id, username from Users where email='".$email."' or username='".$username."'");
if($PWResult->num_rows > 0){
$user = mysqli_fetch_array($PWResult);
$ownerId = $user['id'];
$username = $user['username'];
if($user['password'] === $password) {
$verified = true;
}
}
if($verified){
$result = $conn->query("select id, name, due, customTags, url, rep from Plans where ownerId = '".$ownerId."'");
$rows = array();
while($r = mysqli_fetch_assoc($result)) {
$rows[] = $r;
}
echo "{\"username\": \"".$username."\", \"ownerId\": \"".$ownerId."\", \"contents\": ".json_encode($rows)."}";
} else {
echo "Not verified";
}
?>