<?php switch ($uri[1]) { case "add": DBDriver::execute("INSERT INTO `kb_article`(`title`, `permalink`, `category`, `content`, `featuredimage`, `dateadd`, `published`)" . "VALUES (:title, :permalink, :category, :content, :filename, NOW(), :publish)", array(':title' => $_POST['title'], ':permalink' => str_replace(" ", "-", strtolower($_POST['title'])), ':category' => $_POST['category'], ':content' => $_POST['editor'], ':filename' => $_POST['image'], ':publish' => $_POST['publish'])); Response::redirect($uri[0] . "/all"); break; case "update": DBDriver::execute("UPDATE kb_article SET title=:title, permalink=:permalink, content=:content, category=:category, datemodified=NOW(), featuredimage=:filename, published=:published WHERE id=:id", array(':title' => $_POST['title'], ':permalink' => str_replace(" ", "-", strtolower($_POST['title'])), ':category' => $_POST['category'], ':content' => $_POST['editor'], ':filename' => $_POST['image'], ':published' => $_POST['published'], ':id' => (int) $_POST['id'])); Response::redirect($uri[0] . "/all"); break; case "delete": DBDriver::execute('DELETE FROM posts WHERE id = :id', array(':id' => (int) $_POST['id'])); Response::redirect($uri[0] . "/all"); break; }
/** * * delete user */ static function deleteUser($username) { // // use database // if (gatorconf::get('use_database')) { $db = new DBDriver(); $username = $db->escape($username); $sql = "DELETE FROM users WHERE username = '******'"; return $db->execute($sql); } // // use user_config_file // $current_users = gator::getAllUsers(); foreach ($current_users as $key => $user) { if ($user['username'] == $username) { unset($current_users[$key]); $json_config = json_encode($current_users); file_put_contents(gatorconf::get('user_config_file'), $json_config, LOCK_EX); break; } } return; }
<?php switch ($uri[1]) { case "add": DBDriver::execute("INSERT INTO `kb_category`(`title`, `description`, `permalink`, `dateadd`, `published`) VALUES (:title,:description,:permalink,NOW(),:published)", array(':title' => $_POST['category'], ':description' => $_POST['description'], ':permalink' => str_replace(" ", "-", strtolower($_POST['category'])), ':published' => $_POST['published'])); Response::redirect($uri[0] . "/all"); break; case "update": DBDriver::execute("UPDATE `kb_category` SET `title`=:title, `description`=:description, `permalink`=:permalink, `datemodified`=NOW(), `published`=:published WHERE id=:id", array(':title' => $_POST['category'], ':description' => $_POST['description'], ':permalink' => str_replace(" ", "-", strtolower($_POST['category'])), ':published' => $_POST['published'], ':id' => (int) $_POST['id'])); Response::redirect($uri[0] . "/all"); break; case "delete": DBDriver::execute('DELETE FROM `kb_category` WHERE `id` = :id', array(':id' => (int) $_POST['id'])); Response::redirect($uri[0] . "/all"); break; }