Merge branch 'master' into lars
This commit is contained in:
27
website/public/API/editFriendship.php
Normal file
27
website/public/API/editFriendship.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/friendship.php");
|
||||
|
||||
if(empty($_POST["usr"]) OR empty($_POST["action"]) OR !in_array($_POST["action"], array("request", "accept", "delete"))) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
$friendship_status = getFriendshipStatus($_POST["usr"]);
|
||||
|
||||
if($_POST["action"] == "request" AND $friendship_status == 0) {
|
||||
if (!requestFriendship($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Query (request) failed');
|
||||
}
|
||||
} else if($_POST["action"] == "delete" AND in_array($friendship_status, array(1, 2, 3))) {
|
||||
if (!removeFriendship($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Query (delete) failed');
|
||||
}
|
||||
} else if ($_POST["action"] == "accept" AND $friendship_status == 3) {
|
||||
if (!acceptFriendship($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Query (accept) failed');
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.1 500 Not the right friendship status');
|
||||
}
|
||||
24
website/public/API/getFriendshipStatus.php
Normal file
24
website/public/API/getFriendshipStatus.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
# -2: Query failed.
|
||||
# -1: user1 and 2 are the same user
|
||||
# 0 : no record found
|
||||
# 1 : confirmed
|
||||
# 2 : user1 sent request (you)
|
||||
# 3 : user2 sent request (other)
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/friendship.php");
|
||||
|
||||
if(empty($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
$friendship_status = getFriendshipStatus($_POST["usr"]);
|
||||
|
||||
if($friendship_status == -2) {
|
||||
header('HTTP/1.1 500 Query failed');
|
||||
}
|
||||
|
||||
echo $friendship_status;
|
||||
12
website/public/API/loadPost.php
Normal file
12
website/public/API/loadPost.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
require_once("../../queries/connect.php");
|
||||
require_once("../../queries/post.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/nicetime.php");
|
||||
|
||||
if(isset($_GET['postID'])) {
|
||||
include("../../views/post-view.php");
|
||||
} else {
|
||||
echo "Failed to load";
|
||||
}
|
||||
Reference in New Issue
Block a user