2
0

cms.lottery.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. if(core::getPost("id") == "add"){
  3. db::query("INSERT INTO " . DB_T_LOTTERY . " (md5, titre, description, id_user) VALUES (:md5, :titre, :description, :id_user)");
  4. db::bind(':md5', md5(time().rand(1000000000, 9999999999)));
  5. db::bind(':titre', core::getPost("titre"));
  6. db::bind(':description', core::getPost("description"));
  7. db::bind(':id_user', session::getId());
  8. try {
  9. db::execute();
  10. alert::recSuccess("Le tirage au sort a bien été créé");
  11. } catch (Exception $ex) {
  12. alert::recError("Erreur lors de l'enregistrement du tirage au sort");
  13. header("Location: /add-lottery.html");
  14. exit();
  15. }
  16. header("Location: /lottery-" . lottery::lastLottery().".html");
  17. exit();
  18. } else {
  19. db::query("UPDATE " . DB_T_LOTTERY . " SET "
  20. . "titre = :titre, "
  21. . "description = :description, "
  22. . "sortDate = :sortDate, "
  23. . "id_user = :id_user "
  24. . "WHERE id = :id");
  25. db::bind(':titre', core::getPost("titre"));
  26. db::bind(':description', core::getPost("description"));
  27. db::bind(':sortDate', core::getPost("sortDate"));
  28. db::bind(':id_user', session::getId());
  29. db::bind(':id', core::getPost("id"));
  30. try {
  31. db::execute();
  32. alert::recSuccess("Le tirage au sort a bien été modifié");
  33. } catch (Exception $ex) {
  34. alert::recError("Erreur lors de la modification le tirage au sort");
  35. header("Location: /lottery-" . core::getPost("id").".html");
  36. exit();
  37. }
  38. header("Location: /lottery-" . core::getPost("id").".html");
  39. exit();
  40. }