forked from aorti017/CS180-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendMessage.php
More file actions
29 lines (29 loc) · 1.03 KB
/
Copy pathsendMessage.php
File metadata and controls
29 lines (29 loc) · 1.03 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
<?php
include './database.php';
$sender = $_GET['username'];
$receiver = $_GET['recpUser'];
if(!($receiver == "")){
$sqlStatement = "SELECT * FROM Blocked WHERE (username='".$sender."' AND blocked='".$receiver."') OR (username='".$receiver."' AND blocked='".$sender."')";
$results = executeStatement($sqlStatement);
$sqlStatement = "SELECT * FROM Users WHERE username='".$receiver."'";
$realUser = executeStatement($sqlStatement);
if(count($results)<=0 && count($realUser)>0){
$newTimeStamp = $_GET['time'];
$message = $_GET['message'];
$toInsert = "INSERT INTO Messages VALUE ('".$sender."','".$receiver."','".$newTimeStamp."','".$message."')";
executeStatement($toInsert);
$ret = array('status'=>"");
echo json_encode($ret);
}
else{
if(count($results) > 0){
$ret = array('status'=>"Communications are blocked.");
echo json_encode($ret);
}
else{
$ret = array('status'=>"This user does not exist.");
echo json_encode($ret);
}
}
}
?>