function latestcomments($number) { $allcomments = KComments::allcomments(); $amount = 0; foreach ($allcomments as $newsid => $comments) { krsort($comments); reset($comments); foreach ($comments as $commentid => $commentdata) { $latestcomments[$commentid] = $commentdata; $latestcomments[$commentid][parent] = $newsid; $amount++; if ($amount >= $number) { break 2; } } } krsort($latestcomments); reset($latestcomments); return $latestcomments; }
function add($articleid) { $newcommentid = time(); $ip = $_SERVER["REMOTE_ADDR"]; if (!validate_ip($ip)) { $ip = "127.0.0.2"; } $data = array('date' => $newcommentid, 'parentcid' => stripslashes(sanitize_variables($_GET[replyto])), 'name' => stripslashes(sanitize_variables($_POST[comment][name])), 'email' => stripslashes(sanitize_variables($_POST[comment][email])), 'url' => stripslashes(sanitize_variables($_POST[comment][url])), 'ip' => $ip, 'browser' => sanitize_variables($_SERVER["HTTP_USER_AGENT"]), 'content' => stripslashes(sanitize_variables($_POST[comment][content]))); print_r($data); $newcommentid = 'c' . $newcommentid; if (defined("KNIFESQL")) { $class = KComments::connect(); $write_sql = "INSERT INTO comments VALUES ('{$articleid}', '{$newcommentid}', '{$data['parentcid']}', '{$data['name']}', '{$data['email']}', '{$data['url']}', '{$data['ip']}', '{$data['browser']}', '{$data['content']}')"; $result = mysql_query($write_sql) or die('Query failed: ' . mysql_error()); return true; } else { $class = KComments::connect(); $class->settings[$articleid][$newcommentid] = $data; $class->save(); return true; } }
<?php 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);
if (!defined("KNIFE_PATH")) { define("KNIFE_PATH", dirname(__FILE__) . "/"); # Absolute path to current script } include_once KNIFE_PATH . '/config.php'; # load temporary config include_once KNIFE_PATH . '/inc/class.articles.php'; include_once KNIFE_PATH . '/inc/class.comments.php'; include_once KNIFE_PATH . '/inc/class.users.php'; # load userclass - can't live without include_once KNIFE_PATH . '/lang/nb_no.php'; # load a language include_once KNIFE_PATH . '/inc/functions.php'; include_once KNIFE_PATH . '/plugins/markdown.php'; $pathinfo_array = explode("/", $_SERVER[PATH_INFO]); $commentsclass = new KComments(); $Userclass = new KUsers(); $KAclass = new KArticles(); # # Reset some variables # $timestamp = 0; # # Display articles # $settingsdatabase = new SettingsStorage('settings'); $alltemplates = $settingsdatabase->settings['templates']; $allcats = $settingsdatabase->settings['categories']; $allusers = $Userclass->getusers(); if ($template) { $template = $alltemplates[$template];
<?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>';