score.php 873 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. //Recup de la session
  3. if(!isset($_COOKIE['salon']) || !isset($_COOKIE['common-sess'])){
  4. exit(json_encode(['etat' => 'err']));
  5. }
  6. if($_COOKIE['common-sess'] != $_COOKIE['salon']){
  7. exit(json_encode(['etat' => 'err']));
  8. }
  9. //Lancement session
  10. session_name('common-sess');
  11. session_start();
  12. //Generation tableau
  13. $roll = array_reverse($_SESSION['roll']);
  14. $html = '';
  15. foreach ($roll as $val) {
  16. $html .= '<tr><td>' . $val['name'] . '</td>';
  17. $html .= '<td>' . $val['roll'] . '</td>';
  18. $html .= '<td>' . $val['dice'] . '</td></tr>';
  19. }
  20. //Generation nom joueur
  21. $name = '<option value="" disabled selected>Selectionnez un lanceur</option>';
  22. foreach ($_SESSION['user'] as $val) {
  23. $name .= '<option>' . $val . '</option>';
  24. }
  25. //Envoi
  26. echo json_encode(['etat' => 'ok', 'html' => $html, 'savename' => $name, 'uniqId' => count($_SESSION['roll'])]);