if ($User->level < 3) { die(i18n("login_noaccess")); } include_once KNIFE_PATH . '/inc/class.articles.php'; include_once KNIFE_PATH . '/inc/class.comments.php'; # # Show edit for for single article # $KAclass = new KArticles(); $KCclass = new KComments(); $menus["sub_edit"] = "\n<ul><li>proof</li><li>of</li><li>concept</li></ul>\n"; if ($_GET[id] && !$_POST[id] && !$_GET[action]) { $settingsclass = new SettingsStorage('settings'); $currentcats = $settingsclass->settings['categories']; $editentry = $KAclass->getarticle($_GET[id]); $comments = $KCclass->articlecomments($_GET[id]); $moduletitle = i18n("edit_module_edit") . " "{$editentry['title']}""; # form stuff here # set up category checkboxes $editcats = explode(", ", $editentry[category]); foreach ($editcats as $catkey => $catvalue) { $newcats["{$catvalue}"] = $catvalue; } foreach ($currentcats as $catid => $catinfo) { if (array_key_exists($catid, $newcats)) { $selected = 'checked="checked"'; } $catformfields .= "<input {$selected} type=\"checkbox\" name=\"article[category][]\" id=\"catbox{$catid}\" value=\"{$catid}\" />\n\t\t\t\t\t\t\t<label for=\"catbox{$catid}\">{$catinfo['name']}</label><br />"; unset($selected); }
function edit($timestamp, $user) { # Remove unwanted stuff! $_POST[article][content] = html2specialchars(sanitize_variables($_POST[article][content])); $_POST[article][title] = sanitize_variables($_POST[article][title]); $_POST[article][category] = sanitize_variables($_POST[article][category]); $_POST[article][views] = sanitize_variables($_POST[article][views]); $savecats = implode(", ", $_POST[article][category]); # Put the posted and santitized stuff into an array for saving $data = array("date" => stripslashes($_POST[article][date]), "content" => stripslashes($_POST[article][content]), "title" => stripslashes($_POST[article][title]), "author" => "", "lastedit" => stripslashes($user), "category" => stripslashes($savecats), "views" => stripslashes($_POST[article][views])); if (defined("KNIFESQL")) { $db = KArticles::connect(); $oldarticle = KArticles::getarticle($timestamp); $data[author] = $oldarticle[author]; foreach ($data as $key => $value) { $value = addslashes($value); $data[$key] = $value; } $sql = "UPDATE articles SET category='{$data['category']}', author='{$data['author']}', lastedit='{$data['lastedit']}', title='{$data['title']}', content='{$data['content']}', views='{$data['views']}' WHERE articleid = '{$timestamp}'"; $result = mysql_query($sql) or die('Edit Query failed: ' . mysql_error()); return "Article successfully edited!<br /><a href=\"javascript:history.go(-1);\">Go back</a>"; } else { $dataclass = KArticles::connect(); if ($article = KArticles::getarticle($timestamp)) { $data[author] = $article[author]; $dataclass->settings['articles'][$timestamp] = $data; $dataclass->save(); return "Article successfully edited!<br /><a href=\"javascript:history.go(-1);\">Go back</a>"; } else { return "Invalid article."; } } }
<?php $moduletitle = i18n("dashboard_moduletitle"); $statusmessage = i18n("login_YouAre") . $User->nickname; include KNIFE_PATH . '/inc/class.comments.php'; include KNIFE_PATH . '/inc/class.articles.php'; $Commentclass = new KComments(); $Articleclass = new KArticles(); $templates = $settingsdatabase->settings['templates']; $articledatabase = new ArticleStorage('storage'); $allarticles = $articledatabase->settings['articles']; $configuration = $settingsdatabase->settings['configuration']; krsort($allarticles); $totalarticles = count($allarticles); $totalusers = count($users); $main_content = "\n\t<div id=\"dashboard_wrapper\">\n\t\t<div class=\"div_extended\">\n\t\t<fieldset>\n\t\t\t<legend>" . i18n("dashboard_Statistics") . "</legend>\n\t\t" . i18n("dashboard_Articles") . ": {$totalarticles}<br />\n\t\t" . i18n("dashboard_Users") . ": {$totalusers}<br />\n\t\t" . i18n("dashboard_ACS") . ": " . formatsize(filesize("./data/articles.php")) . "<br />\n\t\t\t<acronym title=\"" . i18n("templates") . ", " . i18n("users") . ", etc\">" . i18n("dashboard_SS") . "</acronym>: " . formatsize(filesize("./data/settings.php")) . "\n\t\t</div>"; # # TODO. Remove later. # $main_content .= "\n\t<div class=\"div_normal\">\n\t\t<fieldset>\n\t\t\t<legend>Todo</legend>\n\t\t<ol>\n\t\t\t<li>Users<ul><li><del>Add</del></li><li><del>Edit</del></li><li><del>Delete</del></li><li><del>Passwords encrypted sha1(md5(password+unique_id_generated_on_install))</del></li><li>Non-Admin Profiles</li></ul></li>\n\t\t\t<li>Options</li>\n\t\t\t<li>Templates<ul><li><del>Add template</del></li><li><del>Edit template</del></li><li><del>Delete template</del></li></ul></li>\n\t\t\t<li><del>Login system</del>\n\t\t\t\t<ul>\n\t\t\t\t\t<li>Access levels\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t<li>4 / Admin\n\t\t\t\t\t\t\t<ul><li>Can do anything including deleting other admins</li></ul></li>\n\t\t\t\t\t\t<li>3 / Editor\n\t\t\t\t\t\t\t<ul><li>Add posts</li>\n\t\t\t\t\t\t\t\t<li>Edit all posts</li>\n\t\t\t\t\t\t\t\t<li>Personal options</li>\n\t\t\t\t\t\t\t\t<li>Set up categories</li>\n\t\t\t\t\t\t\t</ul></li>\n\t\t\t\t\t\t<li>2 / Journalist\n\t\t\t\t\t\t\t<ul><li>Add posts</li>\n\t\t\t\t\t\t\t\t<li>Edit <strong>own</strong> posts</li>\n\t\t\t\t\t\t\t</ul></li>\n\t\t\t\t\t\t<li>4 / Commenter\n\t\t\t\t\t\t\t<ul><li>Nick will be registered for commenting</li>\n\t\t\t\t\t\t\t\t<li>Can view/edit personal options</li>\n\t\t\t\t\t\t\t</ul></li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li>Language selected on login, saved in expireless cookie?</li>\n\t\t\t\t</ul>\n\t\t\t</li>\n\t\t\t<li>Categories<ul><li>Add</li><li>Edit</li><li>Delete</li><li>Default template</li></ul></li>\n\t\t\t<li>Plugins</li>\n\t\t\t<li>Comments</li>\n\t\t\t<li><del>Write news</del><ul><li>Custom date</li></ul></li>\n\t\t\t<li><del>Edit news</del><ul><li>Custom date</li><li><del>Delete article</del></li><li><del>Delete articles</del></li></ul></li>\n\t\t\t<li>Generate archive</li>\n\t\t\t<li>Search!</li>\n\t\t\t<li>MySQL</li></ol>\n\t\t</fieldset>\n\t\t<fieldset>\n\t\t\t<legend>Musical drive</legend>\n\t\t<ol>\n\t\t\t<li>The Donnas ( Spend the night )</li>\n\t\t\t<li>Porcupine Tree ( In absentia )</li>\n\t\t\t<li>Ed Harcourt ( From every sphere )</li>\n\t\t\t<li>U2\n\t\t\t\t<ul><li>How to dismantle an atomic bomb</li>\n\t\t\t\t<li>All that you can't leave behind</li></ul></li>\n\t\t\t<li>Kent\n\t\t\t\t<ul><li>Hagnesta Hill</li><li>Isola</li></ul></li>\n\t\t\t<li>Kula Shaker ( K )</li>\n\t\t\t<li>Lisa Miskovsky<ul><li>Lisa Miskovsky</li><li>Fallingwater</li></ul></li>\n\t\t\t<li>Modest Mouse (Good news for people who love bad news)</li>\n\t\t\t</ol>\n\t\t\t</fieldset>\n\t\t</div>\n\t</div>"; $main_content .= '<div class="div_normal"><fieldset><legend>Latest comments</legend>'; $number = 5; $latestcomments = $Commentclass->latestcomments($number); foreach ($latestcomments as $commentid => $commentdata) { $article = $Articleclass->getarticle($commentdata[parent]); $title = $article[title]; $main_content .= date("d/m ", $commentid) . $commentdata[name] . " <small>commenting {$title}</small> <blockquote>" . $commentdata[content] . "</blockquote><br />"; } $main_content .= '</fieldset></div>';