forked from AyatsujiTsukasa/Ant-Planner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
syncMessage.php
31 lines (26 loc) · 846 Bytes
/
syncMessage.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
<?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!");
}
$username = $_GET["username"];
$password = $_GET["password"];
$pw = mysqli_fetch_array($conn->query("select password from Users where username='".$username."'"))["password"];
if($pw === $password){
$messages = $conn->query("select * from (select * from Messages where Messages.from='".$username."' or Messages.to='".$username."' order by id desc limit 20) sub order by id asc");
$rows = array();
$i=0;
while($r = mysqli_fetch_assoc($messages)) {
$rows[] = $r;
$i++;
}
echo "{\"contents\": ".json_encode($rows)."}";
}
?>