"OdenseTrack" is a school assignment/project from AspIT https://aspit.dfine.net/odensetrack
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

alter.class.php 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /*
  3. * Alters information in the database. We use this for signup, administration and more.
  4. */
  5. class Alter {
  6. private function __construct() {
  7. }
  8. public static function addNews($author, $title, $content) {
  9. $db = new DBClass();
  10. $time = new DateTime();
  11. $sql = "INSERT INTO `news` (`id`, `author`, `time`, `title`, `type`, `content`, `img`) VALUES (NULL, '$author', '" . $time->getTimestamp() . "', '$title', '1', '$content', '');";
  12. $db->query($sql);
  13. header('Location: ' . Config::$sys_url . '?page=newsadmin');
  14. die("Error, please enable browser-redirects.");
  15. }
  16. public static function editNews($id, $title, $content) {
  17. $db = new DBClass();
  18. $sql = "UPDATE `news` SET `title` = '$title', `content` = '$content' WHERE `news`.`id` = $id;";
  19. $db->query($sql);
  20. header('Location: ' . Config::$sys_url . '?page=newsadmin');
  21. die("Error, please enable browser redirects.");
  22. }
  23. public static function deleteNews($id) {
  24. $db = new DBClass();
  25. $sql = "DELETE FROM `news` WHERE `news`.`id` = $id";
  26. $db->query($sql);
  27. header('Location: ' . Config::$sys_url . '?page=newsadmin');
  28. die("Error, please enable browser redirects.");
  29. }
  30. /* Event functions */
  31. public static function addEvent($title, $content, $type, $eventdate) {
  32. $db = new DBClass();
  33. $sql = "INSERT INTO `events` (`id`, `title`, `img`, `type`, `description`, `time`) VALUES (NULL, '$title', 'image', '$type', '$content', '" . strtotime($eventdate) . "');";
  34. $db->query($sql);
  35. header('Location: ' . Config::$sys_url . '?page=eventadmin');
  36. die("Error, please enable browser-redirects.");
  37. }
  38. public static function editEvent($id, $title, $content, $type, $eventdate) {
  39. $db = new DBClass();
  40. $sql = "UPDATE `events` SET `title` = '$title', `img` = 'images', `type` = '$type', `time` = '" . strtotime($eventdate) . "', `description` = '$content' WHERE `events`.`id` = $id;";
  41. $db->query($sql);
  42. header('Location: ' . Config::$sys_url . '?page=eventadmin');
  43. die("Error, please enable browser redirects.");
  44. }
  45. public static function deleteEvent($id) {
  46. $db = new DBClass();
  47. $sql = "DELETE FROM `events` WHERE `events`.`id` = $id";
  48. $db->query($sql);
  49. header('Location: ' . Config::$sys_url . '?page=eventadmin');
  50. die("Error, please enable browser redirects.");
  51. }
  52. public static function addUser($username, $password, $realname, $mail, $level) {
  53. $db = new DBClass();
  54. $sql = "INSERT INTO `users` (`id`, `realname`, `username`, `password`, `email`, `level`) VALUES (NULL, '$realname', '$username', '" . User::hashPass($password) . "', '$mail', '$level');";
  55. return $db->query($sql);
  56. }
  57. }