} if ($action == "Add Friend") { $props = array('u_id1' => $_SESSION['loggedInUser']['u_id'], 'u_id2' => $_POST['u_id'], 'r_status' => 'REQUEST_SENT', 'r_updated_at' => date('Y-m-d H:i:s')); $addedFriend = addFriend($props); print json_encode($addedFriend); return; } if ($action == "Decline") { $props = array('u_id' => $_POST['u_id'], 'r_id' => $_POST['r_id'], 'r_updated_at' => date('Y-m-d H:i:s')); declineFriendship($props); print json_encode($_POST['u_id']); return; } if ($action == "Unfriend") { $props = array('u_id' => $_POST['u_id'], 'r_id' => $_POST['r_id']); unFriend($props); print json_encode($_POST['u_id']); return; } if ($action == "Regret button") { $props = array('u_id' => $_POST['u_id'], 'r_id' => $_POST['r_id']); regretAndBecomeFriends($props); print json_encode($_POST['u_id']); return; } if ($action == "Form Filling") { $props = $_POST; $props['u_id'] = isset($_SESSION['loggedInUser']['u_id']) ? $_SESSION['loggedInUser']['u_id'] : null; $props['u_password'] = md5($props['u_password']); if ($_FILES) { $props['u_picture'] = move_files($_FILES['file1']);
<?php include 'include.php'; isAllowed(); if (!isset($_GET['id'])) { setFlash("action impossible.", "danger"); redirect("accueil.php"); die; } $referer = $_SERVER['HTTP_REFERER']; $user = $_SESSION['profil']['id']; $asked = $_GET['id']; $friendship = unFriend($user, $asked); if ($friendship == 400) { setFlash("action impossible.", "danger"); redirect('acceuil.php'); } elseif ($friendship == 500) { setFlash('Nos services sont en panne, nous faisons notre possible pour régler le problème.', 'danger'); redirect('serveur_down.php'); } elseif ($friendship == 200) { setFlash("Cette personne a bien été retiré de votre liste d'amis"); redirect($referer); } else { setFlash('Nos services sont en panne, nous faisons notre possible pour régler le problème.', 'danger'); redirect('serveur_down.php'); }