瀏覽代碼

Update to newssystem to allow upload and display of thumbnails.

tags/rls1
kenn408k 6 年之前
父節點
當前提交
446554c4b5
共有 1 個檔案被更改,包括 8 行新增4 行删除
  1. 8
    4
      classes/alter.class.php

+ 8
- 4
classes/alter.class.php 查看文件

10
         
10
         
11
     }
11
     }
12
 
12
 
13
-    public static function addNews($author, $title, $content) {
13
+    public static function addNews($author, $title, $content, $image) {
14
         $db = new DBClass();
14
         $db = new DBClass();
15
         $time = new DateTime();
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
         $db->query($sql);
17
         $db->query($sql);
18
         header('Location: ' . Config::$sys_url . '?page=newsadmin');
18
         header('Location: ' . Config::$sys_url . '?page=newsadmin');
19
         die("Error, please enable browser-redirects.");
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
         $db = new DBClass();
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
         $db->query($sql);
29
         $db->query($sql);
26
         header('Location: ' . Config::$sys_url . '?page=newsadmin');
30
         header('Location: ' . Config::$sys_url . '?page=newsadmin');
27
         die("Error, please enable browser redirects.");
31
         die("Error, please enable browser redirects.");

Loading…
取消
儲存