/** * Forhåndsvisning av forumtråd * * Inndata: * - topic_id [optional] * - text */ require "../../../app/ajax.php"; ajax::require_user(); // kontroller lås ajax::validate_lock(true); global $_base, $_game; // sett opp tekst $text = postval("text"); if (empty($text)) { $text = "Mangler innhold."; } // forhåndsviser vi en redigert forumtråd? if (isset($_POST['topic_id'])) { // hent forumtråden $topic = new \Kofradia\Forum\TopicAjax($_POST['topic_id']); // sett opp data $data = $topic->extended_info(); $data['ft_text'] = $text; $data['ft_last_edit'] = time(); $data['ft_last_edit_up_id'] = login::$user->player->id; } else { // sett opp data $data = array("ft_text" => $text); } ajax::html(parse_html(\Kofradia\Forum\Category::template_topic_preview($data)));
<?php /** * Hent raw data for et forumsvar * * Inndata: * - sid * - topic_id * - reply_id */ require "../../../app/ajax.php"; ajax::validate_sid(); // kontroller lås ajax::validate_lock(true); // hent forumtråd $topic = new \Kofradia\Forum\TopicAjax(postval("topic_id")); // hent forumsvaret $reply = $topic->get_reply(postval("reply_id")); // fant ikke forumsvaret? if (!$reply) { ajax::text("ERROR:404-REPLY", ajax::TYPE_INVALID); } // krev tilgang til forumsvaret $reply->require_access(); // send tilbake data ajax::text($reply->info['fr_text']);
$time_last = $row['fr_time']; // lagre tidspunktet for sist endret slik at man unngår å skrive over endringer uten å være klar over det når man redigerer $new_last_edit[$row['fr_id']] = $data['fr_last_edit']; } // oppdatere sist sett? if ($time_last && login::$logged_in) { // oppdater \Kofradia\DB::get()->exec("UPDATE forum_seen SET fs_time = GREATEST(fs_time, {$time_last}) WHERE fs_ft_id = {$id} AND fs_u_id = " . login::$user->id); } } // generer XML $xml = ' <topic id="' . $id . '" time="' . time() . '">'; // forumtråden oppdatert? if ((int) $topic['ft_last_edit'] != $topic_last_edit) { $topic_obj = new \Kofradia\Forum\TopicAjax($id, $forum); $xml .= ' <tupdated last_edit="' . $topic_obj->info['ft_last_edit'] . '">' . htmlspecialchars(parse_html($forum->template_topic($topic_obj->extended_info()))) . '</tupdated>'; } $xml .= ' <new>'; // noen nye? if (count($new) > 0) { $new = parse_html_array($new); foreach ($new as $id => $html) { $xml .= ' <post id="' . $id . '" last_edit="' . intval($new_last_edit[$id]) . '">' . htmlspecialchars($html) . '</post>'; } $xml .= ' '; }
ajax::require_user(); // kontroller lås ajax::validate_lock(true); global $_base, $_game; // mangler forumtråd id? if (!isset($_POST['topic_id'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } $text = postval("text"); if (empty($text)) { $text = "Mangler innhold."; } // forhåndsviser vi et redigert forumsvar? if (isset($_POST['reply_id'])) { // hent forumtråden og forumsvaret $topic = new \Kofradia\Forum\TopicAjax($_POST['topic_id']); $reply = $topic->get_reply($_POST['reply_id']); // fant ikke forumsvaret? if (!$reply) { ajax::text("ERROR:404-REPLY", ajax::TYPE_INVALID); } // sett opp data $data = $reply->extended_info(); $data['fr_text'] = $text; $data['fr_last_edit'] = time(); $data['fr_last_edit_up_id'] = login::$user->player->id; } else { // sett opp data $data = array("ft_id" => (int) $_POST['topic_id'], "fr_text" => $text, "fr_up_id" => login::$user->player->id, "up_name" => login::$user->player->data['up_name'], "up_access_level" => login::$user->player->data['up_access_level'], "up_points" => login::$user->player->data['up_points'], "upr_rank_pos" => login::$user->player->data['upr_rank_pos'], "up_forum_signature" => login::$user->player->data['up_forum_signature'], "up_profile_image_url" => login::$user->player->data['up_profile_image_url'], "fs_new" => \Kofradia\Forum\Category::$fs_check); } ajax::html(parse_html(\Kofradia\Forum\Category::template_topic_reply_preview($data)));
* - locked [optional forum mod] */ require "../../../app/ajax.php"; ajax::validate_sid(); // kontroller lås ajax::validate_lock(true); global $_base, $_game; // mangler forumtråd-id? if (!isset($_POST['topic_id'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // mangler data? if (!isset($_POST['title']) || !isset($_POST['text'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // mangler sist redigert? if (!isset($_POST['last_edit'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // hent forumtråden $topic = new \Kofradia\Forum\TopicAjax($_POST['topic_id']); // kontroller at forumtråden ikke har blitt endret siden sist oppdatert $last_edit = (int) $_POST['last_edit']; if ($topic->info['ft_last_edit'] && $topic->info['ft_last_edit'] > $last_edit) { ajax::text("ERROR:TOPIC-ALREADY-EDITED:{$topic->info['ft_last_edit']}", ajax::TYPE_INVALID); } // forsøk å utfør endringer $type = isset($_POST['type']) && $topic->forum->fmod ? $_POST['type'] : NULL; $locked = isset($_POST['locked']) && $topic->forum->fmod ? $_POST['locked'] : NULL; $section = isset($_POST['section']) ? $_POST['section'] : NULL; $topic->edit($_POST['title'], $_POST['text'], $section, $type, $locked);
<?php /** * Legg til nytt forumsvar * * Inndata: * - sid * - topic_id * - text */ require "../../../app/ajax.php"; ajax::validate_sid(); // kontroller lås ajax::validate_lock(true); global $_base, $_game; // mangler forum id? if (!isset($_POST['topic_id'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // hent forumtråd $topic = new \Kofradia\Forum\TopicAjax($_POST['topic_id']); // forsøk å legg til forumsvaret $topic->add_reply(postval("text"), postval("no_concatenate") == "1", postval("announce") == "1");