function display_topic($forum, $topic_id, $content_only = 1) { global $db, $myts, $xoopsUser, $xoopsModule, $forumTable, $meta; if ($content_only == 0) { include_once XOOPS_ROOT_PATH . "/header.php"; } $q = "select * from " . $forumTable['forums'] . " WHERE forum_id=" . $forum; $result = $db->query($q); $forumdata = $db->fetch_array($result); $q = "select * from " . $forumTable['topics'] . " WHERE topic_id=" . $topic_id; $result = $db->query($q); $topicdata = $db->fetch_array($result); echo "<table border='0' width='100%' cellpadding='5'>"; echo "<tr><td align='left'>" . newbb_displayImage('f_open') . " <a href='" . $forumPath['url'] . "archive.php'>"; echo _MD_FORUM_ARCHIVE . "</a>"; if ($forumdata['parent_forum'] == 0) { echo "<br /> " . newbb_displayImage('f_open') . " <a href='archive.php?forum={$forum}'>" . $myts->htmlSpecialChars($forumdata['forum_name']) . "</a>"; echo "<br />" . newbb_displayImage('f_content') . " <strong>" . $myts->htmlSpecialChars($topicdata['topic_title']) . "</strong><br />"; } else { $q = "select forum_name from " . $forumTable['forums'] . " WHERE forum_id=" . $forumdata['parent_forum']; $row = $db->fetch_array($db->query($q)); echo "<br /> " . newbb_displayImage('f_open') . " <a href='" . $forumPath['url'] . "archive.php?forum=" . $forumdata['parent_forum'] . "'>" . $myts->htmlSpecialChars($row['forum_name']) . "</a>"; echo "<br /> " . newbb_displayImage('f_open') . " <a href='archive.php?forum={$forum}'>" . $myts->htmlSpecialChars($forumdata['forum_name']) . "</a>"; echo "<br /> " . newbb_displayImage('f_content') . " <strong>" . $myts->htmlSpecialChars($topicdata['topic_title']) . "</strong><br />"; } echo "</td></tr></table><br />"; // =============== LINK HEADER =============== echo "<table border='0' width='640' cellpadding='5' cellspacing='0' bgcolor='#FFFFFF' align=center><tr><td>"; echo "<h3>" . _MD_FORUM . " : " . $forumdata['forum_name'] . "</h3>"; echo "<h3>" . _MD_SUBJECT . " : " . $topicdata['topic_title'] . "</h3>"; echo "<i><strong>" . $meta['copyright'] . "<br /><a href=" . XOOPS_URL . ">" . XOOPS_URL . "</a>\r\n<br /><br />" . _MD_PRINT_TOPIC_LINK . "<br />\r\n<a href='" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/viewtopic.php?topic_id={$topic_id}&forum={$forum}'>" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/viewtopic.php?topic_id={$topic_id}&forum={$forum}</a>\r\n</strong></i><br /><br />"; // ============= END LINK HEADER ============= $forumpost = new ForumPosts(); $forumpost->setOrder("post_time ASC"); $forumpost->setTopicId($topic_id); $forumpost->setParent(0); $postsArray = $forumpost->getAllPosts(); $count = 0; echo "<table border='0' width='100%' cellpadding='5' cellspacing='0' bgcolor='#FFFFFF'><tr><td>"; foreach ($postsArray as $obj) { if (!($count % 2)) { $row_color = 1; } else { $row_color = 2; } echo "<tr><td>"; $forumpost->setType($obj->type); $obj->showPostForPrint($order); $count++; echo "</td></tr>"; } echo "</table>"; echo "</td></tr></table>"; if ($content_only == 0) { include_once XOOPS_ROOT_PATH . "/footer.php"; } }
<?php if (!defined('XOOPS_ROOT_PATH')) { exit; } // get (object)$forumpost $forumpost = new ForumPosts(intval(@$_GET['post_id'])); $post_id = intval($forumpost->postid()); if (empty($post_id)) { die(_MD_XHNEWBB_ERRORPOST); } $topic_id = intval($forumpost->topic()); $forum = intval($forumpost->forum()); // lock check (even admin cannot post into locked topic) if (xhnewbb_is_locked($topic_id)) { die(_MD_XHNEWBB_TOPICLOCKED); }
} } } else { $accesserror = 1; } } elseif ($forumdata['forum_access'] == 1 && !$xoopsUser) { $accesserror = 1; } if ($accesserror == 1) { redirect_header("viewtopic.php?topic_id={$topic_id}&post_id={$post_id}&order={$order}&viewmode={$viewmode}&pid={$pid}&forum={$forum}", 2, _MD_NORIGHTTOPOST); exit; } } include XOOPS_ROOT_PATH . '/header.php'; include_once 'class/class.forumposts.php'; $forumpost = new ForumPosts($post_id); $r_message = $forumpost->text(); $r_date = formatTimestamp($forumpost->posttime()); $r_name = $forumpost->uid() != 0 ? XoopsUser::getUnameFromId($forumpost->uid()) : $xoopsConfig['anonymous']; $r_content = _MD_BY . " " . $r_name . " " . _MD_ON . " " . $r_date . "<br /><br />"; $r_content .= $r_message; $r_subject = $forumpost->subject(); if (!preg_match("/^Re:/i", $r_subject)) { $subject = 'Re: ' . $myts->htmlSpecialChars($r_subject); } else { $subject = $myts->htmlSpecialChars($r_subject); } $q_message = $forumpost->text("Quotes"); $hidden = "[quote]\n"; $hidden .= sprintf(_MD_USERWROTE, $r_name); $hidden .= "\n" . $q_message . "[/quote]";
/** * Toggle post status */ public function actiontogglepost() { if (!Yii::app()->user->checkAccess('op_forum_posts')) { throw new CHttpException(403, Yii::t('forum', 'Sorry, You are not allowed to perform that operation.')); } if (isset($_GET['id']) && ($model = ForumPosts::model()->findByPk($_GET['id']))) { $model->visible = $model->visible == 1 ? 0 : 1; $model->update(); Yii::app()->user->setFlash('success', Yii::t('forum', 'Post Status Changed.')); $this->redirect(Yii::app()->request->getUrlReferrer()); } else { $this->redirect(Yii::app()->request->getUrlReferrer()); } }
$post_image = '<a name="' . $eachpost->postid() . '"><img src="' . XOOPS_URL . '/images/icons/posticon.gif" alt="" /></a>'; } $xoopsTpl->append('topic_posts', array_merge($posterarr, array('post_id' => $eachpost->postid(), 'post_parent_id' => $eachpost->parent(), 'post_date' => formatTimestamp($eachpost->posttime(), 'm'), 'post_poster_ip' => $eachpost->posterip(), 'post_image' => $post_image, 'post_title' => $eachpost->subject(), 'post_text' => $post_text, 'can_edit' => @$can_edit, 'can_delete' => @$can_delete, 'can_reply' => @$can_reply))); } $newObjArr[$key1]['obj'] = $eachpost; $key2 = $eachpost->parent(); $newObjArr[$key2]['replies'][] = $key1; $newObjArr[$key2]['leaf'] = $key1; } xhnewbb_show_tree($newObjArr, $post_id); $xoopsTpl->assign(array('lang_subject' => _MD_XHNEWBB_SUBJECT, 'lang_date' => _MD_XHNEWBB_DATE)); } else { // FLAT MODE $xoopsTpl->assign(array('topic_viewmode' => 'flat', 'lang_top' => _MD_XHNEWBB_TOP, 'lang_subject' => _MD_XHNEWBB_SUBJECT, 'lang_bottom' => _MD_XHNEWBB_BOTTOM)); $xoopsTpl->assign('topic_order', $order); $postsArray = ForumPosts::getAllPosts($topic_id, $order, $forumdata['posts_per_page'], $start, $post_id); $foundusers = array(); foreach ($postsArray as $eachpost) { $post_text = $eachpost->text(); $posterarr = array(); if (0 != $eachpost->uid()) { if (!isset($foundusers['user' . $eachpost->uid()])) { $eachposter = new XoopsUser($eachpost->uid()); $foundusers['user' . $eachpost->uid()] =& $eachposter; } else { $eachposter =& $foundusers['user' . $eachpost->uid()]; } $poster_rank = $eachposter->rank(); if (!empty($poster_rank['image'])) { $poster_rank['image'] = '<img src="' . XOOPS_UPLOAD_URL . '/' . $poster_rank['image'] . '" alt="" />'; }
$isnew = 1; if ($xoopsUser && empty($HTTP_POST_VARS['noname'])) { $uid = $xoopsUser->getVar("uid"); } else { if ($forumdata['forum_access'] == 2) { $uid = 0; } else { if (!empty($topic_id)) { redirect_header("viewtopic.php?topic_id=" . $topic_id . "&order=" . $order . "&viewmode=" . $viewmode . "&pid=" . $pid . "&forum=" . $forum, 2, _MD_ANONNOTALLOWED); } else { redirect_header("viewforum.php?forum=" . $forum, 2, _MD_ANONNOTALLOWED); } exit; } } $forumpost = new ForumPosts(); $forumpost->setForum($forum); if (isset($pid) && $pid != "") { $forumpost->setParent($pid); } if (!empty($topic_id)) { $forumpost->setTopicId($topic_id); $isreply = 1; } $forumpost->setIp($HTTP_SERVER_VARS['REMOTE_ADDR']); $forumpost->setUid($uid); } $subject = xoops_trim($HTTP_POST_VARS['subject']); $subject = $subject == '' ? _NOTITLE : $subject; $forumpost->setSubject($subject); $forumpost->setText($HTTP_POST_VARS['message']);
$children[] = $post_id; if ($pid == 0) { // create a new topic $sql = "INSERT INTO " . $xoopsDB->prefix("xhnewbb_topics") . " SET topic_title='" . addslashes($forumpost->subject) . "', topic_poster='" . addslashes($forumpost->uid()) . "', forum_id='{$forum}', topic_time=UNIX_TIMESTAMP(), topic_solved=0"; if (!$xoopsDB->query($sql)) { die(_MD_XHNEWBB_DATABASEERROR); } $new_topic_id = intval($xoopsDB->getInsertId()); $new_forum = $forum; $sql = "UPDATE " . $xoopsDB->prefix("xhnewbb_posts") . " SET pid=0 WHERE post_id={$post_id}"; if (!$xoopsDB->query($sql)) { die(_MD_XHNEWBB_DATABASEERROR); } } else { // get topic_id from post_id $targetpost = new ForumPosts($pid); $pid = intval($targetpost->postid()); // loop check if (in_array($pid, $children)) { die(_MD_XHNEWBB_ERROR_PIDLOOP); } $new_forum = intval($targetpost->forum()); if (empty($pid)) { die(_MD_XHNEWBB_ERRORPOST); } $new_topic_id = intval($targetpost->topic()); $sql = "UPDATE " . $xoopsDB->prefix("xhnewbb_posts") . " SET pid={$pid} WHERE post_id={$post_id}"; if (!$xoopsDB->query($sql)) { die(_MD_XHNEWBB_DATABASEERROR); } }
// POST // if ($mode != 'edit') { // NEWTOPIC or REPLY if (is_object(@$xoopsUser)) { // user's post $uid = $xoopsUser->getVar('uid'); } else { // guest's post $uid = 0; // Insert guest name into the top of message (origined from Ryuji) if (!empty($_POST['guestname'])) { $_POST['message'] = sprintf(_MD_XHNEWBB_FMT_GUESTSPOSTHEADER, $_POST['guestname']) . @$_POST['message']; } } $forumpost = new ForumPosts(); $forumpost->setForum($forum); if ($mode == 'reply') { $forumpost->setParent($pid); $forumpost->setTopicId($topic_id); } $forumpost->setIp(@$_SERVER['REMOTE_ADDR']); $forumpost->setUid($uid); } $subject = xoops_trim(@$_POST['subject']); $subject = $subject ? $subject : _NOTITLE; $icon = preg_match('/^icon[1-7]\\.gif$/', @$_POST['icon']) ? $_POST['icon'] : 'icon7.gif'; $solved = empty($_POST['solved']) ? 0 : 1; $forumpost->setSubject($subject); $forumpost->setText(@$_POST['message']); $forumpost->setNohtml(@$_POST['nohtml']);
} } } else { $accesserror = 1; } } elseif ($forumdata['forum_access'] == 1 && !$xoopsUser) { $accesserror = 1; } if ($accesserror == 1) { redirect_header("viewtopic.php?topic_id={$topic_id}&post_id={$post_id}&order={$order}&viewmode={$viewmode}&pid={$pid}&forum={$forum}", 2, _MD_NORIGHTTOPOST); exit; } } include XOOPS_ROOT_PATH . "/header.php"; include_once 'class/class.forumposts.php'; $forumpost = new ForumPosts($post_id); $editerror = false; if ($forumpost->islocked()) { if ($xoopsUser) { if (!$xoopsUser->isAdmin($xoopsModule->mid()) || !is_moderator($forum, $xoopsUser->uid())) { $editerror = true; } } else { $editerror = true; } } if ($editerror) { redirect_header("viewtopic.php?topic_id={$topic_id}&post_id={$post_id}&order={$order}&viewmode={$viewmode}&pid={$pid}&forum={$forum}", 2, _MD_NORIGHTTOPOST); exit; } $nohtml = $forumpost->nohtml();
?> </td> <td><?php echo Yii::app()->format->number(Yii::app()->db->createCommand('SELECT COUNT(id) as total FROM {{forumposts}} WHERE visible = 0')->queryScalar()); ?> </td> </tr> <tr> <td><?php echo Yii::t('adminindex', 'Last Posts'); ?> </td> <td> <ul> <?php $lastforumposts = ForumPosts::model()->with(array('topic'))->findAll(array('order' => 't.dateposted DESC', 'limit' => 5)); ?> <?php foreach ($lastforumposts as $postcomm) { ?> <li><?php echo $postcomm->topic->getLink(); ?> </li> <?php } ?> </ul> </td> </tr> </table>
} if ($xoopsUser) { if (!$xoopsUser->isAdmin($xoopsModule->mid())) { if (!is_moderator($forum, $xoopsUser->uid())) { redirect_header("viewtopic.php?topic_id={$topic_id}&order={$order}&viewmode={$viewmode}&pid={$pid}&forum={$forum}", 2, _MD_DELNOTALLOWED); exit; } } } else { redirect_header("viewtopic.php?topic_id={$topic_id}&order={$order}&viewmode={$viewmode}&pid={$pid}&forum={$forum}", 2, _MD_DELNOTALLOWED); exit; } include_once 'class/class.forumposts.php'; if (!empty($_POST['ok'])) { if (!empty($post_id)) { $post = new ForumPosts($post_id); $post->delete(); sync($post->forum(), "forum"); sync($post->topic(), "topic"); } if ($post->istopic()) { redirect_header("viewforum.php?forum={$forum}", 2, _MD_POSTSDELETED); exit; } else { redirect_header("viewtopic.php?topic_id={$topic_id}&order={$order}&viewmode={$viewmode}&pid={$pid}&forum={$forum}", 2, _MD_POSTSDELETED); exit; } } else { include XOOPS_ROOT_PATH . "/header.php"; xoops_confirm(array('post_id' => $post_id, 'viewmode' => $viewmode, 'order' => $order, 'forum' => $forum, 'topic_id' => $topic_id, 'ok' => 1), 'delete.php', _MD_AREUSUREDEL); }