public function removeRelation($userId = -1) { // var_dump(getUserInfo($userId)); $response['user'] = array(); $response['signed'] = false; if (isset($_SESSION["user_id"]) && strlen(trim($_SESSION["user_id"])) > 0 && $userId != -1) { $response['signed'] = true; if (isUserIdExists($userId)) { $response['succeeded'] = deleteRelation($userId); } else { $response['errors'] = ["message" => "user_id does not exists."]; } } echo json_encode($response); }
function acceptFriendRequest($userId) { $user1Id = min($userId, $_SESSION["user_id"]); $user2Id = max($userId, $_SESSION["user_id"]); if (deleteRelation($userId)) { $res = conn()->query("INSERT INTO friends (user1_id, user2_id, relation, requester_id)\n VALUES ('{$user1Id}', '{$user2Id}', 'friend', '{$userId}')"); if ($res) { $user = getUsername($_SESSION["user_id"]); $data['action'] = 'accepted your friend request'; $data['user_id'] = $_SESSION["user_id"]; $data['username'] = $user['username']; $data['full_name'] = $user['full_name']; $data['profile_pic'] = $user['profile_pic']; pusher()->trigger((string) $userId, 'new_friend', $data); return true; } else { return false; } } else { return false; } }
/** * Created by PhpStorm. * User: TipsyCoder * Date: 11/17/15 * Time: 3:01 PM */ require_once '../core/data.php'; if (isset($_SESSION['user']) && isset($_GET)) { if ($_GET['opt'] === 'deleteUser') { deleteMe($_GET['em']); } } if (isset($_SESSION['user']) && isset($_GET)) { if ($_GET['opt'] === 'deleteRelation') { deleteRelation($_GET['pEm'], $_GET['cEm']); } } if (isset($_SESSION['user']) && isset($_GET)) { if ($_GET['opt'] === 'changePassword') { changePassword($_GET['em'], $_GET['pass']); } } function deleteRelation($pEmail, $cEmail) { $con = connectDatabase(); $lastLogin = null; while (1) { $stmt = $con->prepare("CALL deleteRelationship(?,?)"); $stmt->bind_param("ss", $pEmail, $cEmail); $stmt->execute();