Bläddra i källkod

Update to newssystem to allow upload and display of thumbnails.

tags/rls1
kenn408k 6 år sedan
förälder
incheckning
446554c4b5
1 ändrade filer med 8 tillägg och 4 borttagningar
  1. 8
    4
      classes/alter.class.php

+ 8
- 4
classes/alter.class.php Visa fil

@@ -10,18 +10,22 @@ class Alter {
10 10
         
11 11
     }
12 12
 
13
-    public static function addNews($author, $title, $content) {
13
+    public static function addNews($author, $title, $content, $image) {
14 14
         $db = new DBClass();
15 15
         $time = new DateTime();
16
-        $sql = "INSERT INTO `news` (`id`, `author`, `time`, `title`, `type`, `content`, `img`) VALUES (NULL, '$author', '" . $time->getTimestamp() . "', '$title', '1', '$content', '');";
16
+        $sql = "INSERT INTO `news` (`id`, `author`, `time`, `title`, `type`, `content`, `img`) VALUES (NULL, '$author', '" . $time->getTimestamp() . "', '$title', '1', '$content', '$image');";
17 17
         $db->query($sql);
18 18
         header('Location: ' . Config::$sys_url . '?page=newsadmin');
19 19
         die("Error, please enable browser-redirects.");
20 20
     }
21 21
 
22
-    public static function editNews($id, $title, $content) {
22
+    public static function editNews($id, $title, $content, $image) {
23 23
         $db = new DBClass();
24
-        $sql = "UPDATE `news` SET `title` = '$title', `content` = '$content' WHERE `news`.`id` = $id;";
24
+        if ($image != false) {
25
+            $sql = "UPDATE `news` SET `title` = '$title', `img` = '$image', `content` = '$content' WHERE `news`.`id` = $id;";
26
+        } else {
27
+            $sql = "UPDATE `news` SET `title` = '$title', `content` = '$content' WHERE `news`.`id` = $id;";
28
+        }
25 29
         $db->query($sql);
26 30
         header('Location: ' . Config::$sys_url . '?page=newsadmin');
27 31
         die("Error, please enable browser redirects.");

Laddar…
Avbryt
Spara