$message["status"] = deleteWord($conn, $userID, $wid); break; case "insertlist": $list = $_POST["list"]; $message = insertList($conn, $userID, $list); break; case "listlist": $message["results"] = getListList($conn, $userID, $_GET["first"], $_GET["last"]); $message["success"] = true; break; case "sharelistuser": $message["status"] = shareListUser($conn, $userID, $_POST["user"], $_POST["list"]); break; case "renamelist": $message["status"] = renameList($conn, $userID, $_POST["id"], $_POST["name"]); break; case "deletelist": $message["status"] = deleteList($conn, $userID, $_POST["id"]); break; } } else { $message["status"] = "Invalid token"; } } } } } $response = json_encode($message); echo $response; eventLog($conn, $action, $get, $post, $response); mysqli_close($conn);
<?php header('Content-Type: text/xml; charset=utf-8'); require_once "../includes/session.php"; require_once "../includes/functions.php"; require_once "../includes/connect.php"; if (isset($_GET['item'])) { addList(); } else { if (isset($_GET['delete'])) { deleteList(); showList(); } else { showList(); } } function addList() { global $connection; $day = $_GET['day']; $sql = "SELECT id, name FROM food WHERE id IN (" . $_GET['item'] . ")"; $result_set = mysql_query($sql, $connection); confirm_query($result_set); if (mysql_num_rows($result_set) >= 1) { echo "<foods>"; while ($foods = mysql_fetch_array($result_set)) { $sql = "INSERT INTO food_day (food_id, date) VALUES(" . $foods['id'] . ", '" . get_date_of_day($day) . "')"; $results = mysql_query($sql, $connection); confirm_query($results); echo "<food id='" . mysql_insert_id($connection) . "'>" . $foods['name'] . "</food>"; }
} //delete list from database function deleteList($list) { if ($connexion = mysqli_connect('localhost', 'root', '', 'samirello')) { $requete = "DELETE FROM lists WHERE `listname`='{$list}'; "; // $requete = "DELETE FROM users WHERE `listname`='$list' "; $requete .= "DELETE FROM users WHERE `listname`='{$list}' "; $resultat = mysqli_multi_query($connexion, $requete); echo "resultat : " . ($resultat ? 'deleted' : 'error'); } else { echo "erreur BDD !"; } } if (isset($_GET['deleteList'])) { deleteList($_GET['deleteList']); } // Insert list into DataBase $insertionListVerif; function insertList($list) { if ($connexion = mysqli_connect('localhost', 'root', '', 'samirello')) { $requete = "INSERT INTO lists(`id`,`listname`) VALUES (NULL, '{$list}')"; $resultat = mysqli_query($connexion, $requete); $insertionListVerif = "resultat : " . ($resultat ? 'ok' : 'false'); } else { $insertionListVerif = "erreur BDD !"; } } if (isset($_GET['addedList'])) { insertList($_GET['addedList']);
} else { $_SESSION['error_message'] = "Please enter a list name"; View::render('dashboard.php'); } } if (isset($_POST['list_option'])) { $list_id = $_POST['list_id']; switch ($_POST['list_option']) { case 'save': $new_name = ucwords(strtolower(rtrim($_POST['list_name']))); $editable = $_POST['list_permission']; saveList($list, $new_name, $editable, $list_id, $user_id); echo $new_name; break; case 'delete': deleteList($list, $list_id, $user_id); break; } } if (isset($_POST['share_list_rqst'])) { $list_id = $_POST['shared_list_id']; $contacts_id = $_POST['shared_with_contacts']; $shared_list = new SharedList(); $names = []; foreach ($contacts_id as $contact) { if (!$shared_list->check($user_id, $contact, $list_id)) { $shared_list->create($user_id, $contact, $list_id); $shared_list->save(); $contact_name = getNameForSharedContact($contact); $name = explode(" ", $contact_name['name']); array_push($names, trim(ucfirst($name[0])));
<?php if (isset($_POST['id']) && isset($_POST['langues']) && isset($_POST['langue'])) { include_once 'bdd.php'; $bdd = connexionBdd(); $array = array('success' => updateListLangues($bdd, $_POST['id'], $_POST['langues'])); $req = $bdd->prepare('SELECT id_liste FROM listes WHERE id_membre=:id_membre AND langue=:langue'); $req->execute(array('langue' => $_POST['langue'], 'id_membre' => $_POST['id'])); $listes = $req->fetchAll(); $req->closeCursor(); if ($listes) { foreach ($listes as $liste) { deleteList($bdd, $liste['id_liste'], $_POST['id']); } } $array['listOfList'] = getListOfList($bdd, $_POST['id']); echo json_encode($array); }
<?php if (isset($_POST['idUser']) && isset($_POST['id_liste'])) { include_once 'bdd.php'; $bdd = connexionBdd(); deleteList($bdd, $_POST['id_liste'], $_POST['idUser']); $listOfList = getListOfList($bdd, $_POST['idUser']); echo json_encode($listOfList); } ?>