| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
-
- /*
- * Alters information in the database. We use this for signup, administration and more.
- */
-
- class Alter {
-
- private function __construct() {
-
- }
-
- public static function addNews($author, $title, $content) {
- $db = new DBClass();
- $time = new DateTime();
- $sql = "INSERT INTO `news` (`id`, `author`, `time`, `title`, `type`, `content`, `img`) VALUES (NULL, '$author', '" . $time->getTimestamp() . "', '$title', '1', '$content', '');";
- $db->query($sql);
- header('Location: ' . Config::$sys_url . '?page=newsadmin');
- die("Error, please enable browser-redirects.");
- }
-
- public static function editNews($id, $title, $content) {
- $db = new DBClass();
- $sql = "UPDATE `news` SET `title` = '$title', `content` = '$content' WHERE `news`.`id` = $id;";
- $db->query($sql);
- header('Location: ' . Config::$sys_url . '?page=newsadmin');
- die("Error, please enable browser redirects.");
- }
-
- public static function deleteNews($id) {
- $db = new DBClass();
- $sql = "DELETE FROM `news` WHERE `news`.`id` = $id";
- $db->query($sql);
- header('Location: ' . Config::$sys_url . '?page=newsadmin');
- die("Error, please enable browser redirects.");
- }
-
-
- /* Event functions */
-
- public static function addEvent($title, $content, $type, $eventdate) {
- $db = new DBClass();
- $sql = "INSERT INTO `events` (`id`, `title`, `img`, `type`, `description`, `time`) VALUES (NULL, '$title', 'image', '$type', '$content', '" . strtotime($eventdate) . "');";
- $db->query($sql);
- header('Location: ' . Config::$sys_url . '?page=eventadmin');
- die("Error, please enable browser-redirects.");
- }
-
- public static function editEvent($id, $title, $content, $type, $eventdate) {
- $db = new DBClass();
- $sql = "UPDATE `events` SET `title` = '$title', `img` = 'images', `type` = '$type', `time` = '" . strtotime($eventdate) . "', `description` = '$content' WHERE `events`.`id` = $id;";
- $db->query($sql);
- header('Location: ' . Config::$sys_url . '?page=eventadmin');
- die("Error, please enable browser redirects.");
- }
-
- public static function deleteEvent($id) {
- $db = new DBClass();
- $sql = "DELETE FROM `events` WHERE `events`.`id` = $id";
- $db->query($sql);
- header('Location: ' . Config::$sys_url . '?page=eventadmin');
- die("Error, please enable browser redirects.");
- }
-
- public static function addUser($username, $password, $realname, $mail, $level) {
- $db = new DBClass();
- $sql = "INSERT INTO `users` (`id`, `realname`, `username`, `password`, `email`, `level`) VALUES (NULL, '$realname', '$username', '" . User::hashPass($password) . "', '$mail', '$level');";
- return $db->query($sql);
- }
-
- }
|