The version of vichan running on lainchan.org
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

58 Zeilen
1.9KB

  1. <?php
  2. require '/var/www/html/inc/functions.php';
  3. $method = $_SERVER['REQUEST_METHOD'];
  4. if ($method == 'POST') {
  5. // Method is POST
  6. $type = $_POST['type'];
  7. switch ($type) {
  8. case "add":
  9. $title = $_POST['title'];
  10. $description = $_POST['description'];
  11. $start = $_POST['start'];
  12. $end = $_POST['end'];
  13. $url = $_POST['url'];
  14. $color = $_POST['color'];
  15. $query = prepare("INSERT INTO calendar_events (title, description, start, end,url,color) VALUES (:title,:description, :start, :end,:url, :color )");
  16. $query->bindValue(':title', $title);
  17. $query->bindValue(':description', $description);
  18. $query->bindValue(':start', $start);
  19. $query->bindValue(':end', $end);
  20. $query->bindValue(':url', $url);
  21. $query->bindValue(':color', $color);
  22. $query->execute() or error(db_error($query));
  23. break;
  24. case "delete":
  25. $id = $_POST['id'];
  26. $query = prepare("DELETE from calendar_events WHERE id = :id");
  27. $query->bindValue(':id', $id);
  28. $query->execute() or error(db_error($query));
  29. break;
  30. case "update":
  31. $id = $_POST['id'];
  32. $title = $_POST['title'];
  33. $description = $_POST['description'];
  34. $start = $_POST['start'];
  35. $end = $_POST['end'];
  36. $color = $_POST['color'];
  37. $url = $_POST['url'];
  38. $query = prepare(" UPDATE calendar_events SET title = :title, description = :description, start = :start, end = :end, url = :url, color =:color WHERE id = :id");
  39. $query->bindValue(':id', $id);
  40. $query->bindValue(':title', $title);
  41. $query->bindValue(':description', $description);
  42. $query->bindValue(':start', $start);
  43. $query->bindValue(':end', $end);
  44. $query->bindValue(':url', $url);
  45. $query->bindValue(':color', $color);
  46. $query->execute() or error(db_error($query));
  47. break;
  48. default:
  49. }
  50. } elseif ($method == 'GET') {
  51. // Method is GET
  52. $query = query("SELECT * FROM calendar_events ORDER BY id") or error(db_error());
  53. echo json_encode($query->fetchAll(PDO::FETCH_ASSOC));
  54. }
  55. ?>