|
|
|
|
|
|
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.");
|