Model.php 806 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Public Printer Control System
  4. *
  5. * Copyright © 2018 - 2019, Aaron Speer, aaron.speerfamily.ie ajamesspeer@gmail.com.
  6. * All Rights Reserved.
  7. */
  8. namespace App;
  9. class Model {
  10. public function sanitiseData($data)
  11. {
  12. global $conn;
  13. $data = mysqli_real_escape_string($conn, $data);
  14. $data = htmlspecialchars($data);
  15. return $data;
  16. }
  17. public function getMessages()
  18. {
  19. return json_decode($_COOKIE["messages"]);
  20. $_SESSION["messages"] = "";
  21. }
  22. public function setMessage($name, $content, $type)
  23. {
  24. global $_SESSION;
  25. $passed = [$name, $content, $type];
  26. $messages = json_decode($_SESSION["messages"]);
  27. $messages[] = $passed;
  28. $_SESSION["messages"] = json_encode($messages);
  29. setcookie("messages", json_encode($messages), time() + 1, "/");
  30. }
  31. }