function edit_category($ID, $cat) { global $scdb; if (intval($ID) != $ID || $ID < 1 || !isset($cat['category'][2])) { $this->category->message = 'Error: You must call $scadmin->edit_category() with an associative array, with at least the "category" value being set.'; return false; } $ID = (int) $ID; $category = safe_text($cat['category'], 50); $nicename = nicename($cat['nicename']); $info = isset($cat['info']) ? safe_text($cat['info'], 200) : ''; $oldcat = $scdb->get_row("SELECT * FROM `{$scdb->categories}` WHERE `ID` = '{$ID}' LIMIT 1"); if ($scdb->num_rows != 1) { $this->category->message = "Can't find category with `ID` = '{$ID}'"; $scdb->debug(); return false; } if (!$scdb->query("UPDATE `{$scdb->categories}` SET `category`='{$category}', `nicename`='{$nicename}', `info`='{$info}' WHERE `ID` = '{$ID}' LIMIT 1")) { $this->category->message = 'Error Updating Category!'; $scdb->debug(); return false; } $folder = IMG_FOLDER . $oldcat->nicename; if (is_dir($folder)) { rename($folder, IMG_FOLDER . $nicename); } else { $this->category->message = 'Error: Category Folder ' . IMG_FOLDER . $oldcat->nicename . ' can't be found!'; return false; } $this->category->message = 'Succesfully Edited Category!'; return true; }
public function publish($values) { if (!is_array($values)) { return false; } if (!isset($values['title'], $values['cat'], $values['content'], $values['author'])) { return false; } $title = safe_text($values['title'], 150); $nicetitle = nicename($title); $content = safe_text($values['content']); $cat = (int) $values['cat']; if ($this->cat_info($cat) === false) { return false; } $comicPID = (int) isset($values['comicPID']) ? $values['comicPID'] : 0; $author = (int) abs($values['author']); if ($this->user_info($author) === false) { return false; } $scdb->query("INSERT INTO `{$scdb->news}` (title, nicetitle, content, cat, comicPID, time, author) VALUES ('{$title}', '{$nicetitle}', '{$content}', {$cat}, {$comicPID}, '" . NOW . "', {$author})"); if ($scdb->rows_affected !== 1) { return false; } return true; }