/** * Constructor * @since Version 3.0.1 * @version 3.0.1 * @param object $db */ public function __construct() { parent::__construct(); // If memcache is enabled, check there first $mckey = "railpage:forums.index"; if ($this->categories = $this->getCache($mckey)) { // Do nothing } else { // Grab the index from the database $query = "SELECT * FROM nuke_bbcategories ORDER BY cat_order"; if ($this->db instanceof \sql_db) { if ($rs = $this->db->query($query, true)) { while ($row = $rs->fetch_assoc()) { $result[] = $row; } foreach ($result as $row) { $this->categories[$row['cat_id']]['title'] = $row['cat_title']; $this->categories[$row['cat_id']]['order'] = $row['cat_order']; } } else { trigger_error("phpBB_index : Could not fetch list of categories"); } } else { foreach ($this->db->fetchAll($query) as $row) { $this->categories[$row['cat_id']]['title'] = $row['cat_title']; $this->categories[$row['cat_id']]['order'] = $row['cat_order']; } } $this->setCache($mckey, $this->categories, strtotime("+2 hours")); } }
/** * Constructor * @since Version 3.2 * @version 3.2 * @param object $db * @param object $user */ public function __construct($user = false) { if (!$user || !$user instanceof \Railpage\Users\User) { throw new \Exception("Cannot instantiate " . __CLASS__ . "::" . __FUNCTION__ . " - no \$user object given"); return false; } parent::__construct(); $this->user = $user; $query = "SELECT * FROM nuke_bbforums"; if ($this->db instanceof \sql_db) { if ($rs = $this->db->query($query)) { while ($row = $rs->fetch_assoc()) { $forum =& $this->forums[$row['forum_id']]; foreach ($row as $key => $val) { $forum[$key] = $val; } } // Get group permissions for user $query = "SELECT * FROM nuke_bbauth_access WHERE group_id IN (SELECT group_id FROM nuke_bbuser_group WHERE user_id = " . $this->db->real_escape_string($this->user->id) . " AND user_pending = 0)"; if ($rs = $this->db->query($query)) { while ($row = $rs->fetch_assoc()) { foreach ($row as $key => $val) { if (strstr($key, "auth_")) { // This is a permission, so let's check it $forum_perm =& $this->forums[$row['forum_id']][$key]; if ($val > 0 && $forum_perm < $val) { $forum_perm = $val; } } } } } } else { trigger_error("phpBB User permissions : Unable to fetch forum list"); trigger_error($this->db->error); trigger_error($query); } } else { foreach ($this->db->fetchAll($query) as $row) { $forum =& $this->forums[$row['forum_id']]; foreach ($row as $key => $val) { $forum[$key] = $val; } } $query = "SELECT * FROM nuke_bbauth_access WHERE group_id IN (SELECT group_id FROM nuke_bbuser_group WHERE user_id = ? AND user_pending = 0)"; foreach ($this->db->fetchAll($query, $this->user->id) as $row) { foreach ($row as $key => $val) { if (strstr($key, "auth_")) { // This is a permission, so let's check it $forum_perm =& $this->forums[$row['forum_id']][$key]; if ($val > 0 && $forum_perm < $val) { $forum_perm = $val; } } } } } }
<?php // Already done in /sections/ajax/index.php //enforce_login(); if (!empty($LoggedUser['DisableForums'])) { print json_encode(array('status' => 'failure')); die; } else { // Replace the old hard-coded forum categories $ForumCats = Forums::get_forum_categories(); //This variable contains all our lovely forum data $Forums = Forums::get_forums(); if (empty($_GET['type']) || $_GET['type'] == 'main') { include SERVER_ROOT . '/sections/ajax/forum/main.php'; } else { switch ($_GET['type']) { case 'viewforum': include SERVER_ROOT . '/sections/ajax/forum/forum.php'; break; case 'viewthread': include SERVER_ROOT . '/sections/ajax/forum/thread.php'; break; default: print json_encode(array('status' => 'failure')); break; } } }
} if (!empty($ThreadAfterDate)) { $SQL .= " AND t.CreatedTime >= '{$ThreadAfterDate}'"; } if (!empty($ThreadBeforeDate)) { $SQL .= " AND t.CreatedTime <= '{$ThreadBeforeDate}'"; } if (!empty($PostAfterDate)) { $SQL .= " AND p.AddedTime >= '{$PostAfterDate}'"; } if (!empty($PostBeforeDate)) { $SQL .= " AND p.AddedTime <= '{$PostBeforeDate}'"; } $SQL .= "\n\t\tORDER BY p.AddedTime DESC\n\t\tLIMIT {$Limit}"; } else { $SQL = "\n\t\tSELECT\n\t\t\tSQL_CALC_FOUND_ROWS\n\t\t\tt.ID,\n\t\t\tt.Title,\n\t\t\tt.ForumID,\n\t\t\tf.Name,\n\t\t\tt.LastPostTime,\n\t\t\t'',\n\t\t\t'',\n\t\t\tt.CreatedTime\n\t\tFROM forums_topics AS t\n\t\t\tJOIN forums AS f ON f.ID = t.ForumID\n\t\tWHERE " . Forums::user_forums_sql() . ' AND '; $SQL .= "t.Title LIKE '%"; $SQL .= implode("%' AND t.Title LIKE '%", $Words); $SQL .= "%' "; if (isset($SearchForums)) { $SQL .= " AND f.ID IN ({$SearchForums})"; } if (isset($AuthorID)) { $SQL .= " AND t.AuthorID = '{$AuthorID}' "; } if (!empty($ThreadAfterDate)) { $SQL .= " AND t.CreatedTime >= '{$ThreadAfterDate}'"; } if (!empty($ThreadBeforeDate)) { $SQL .= " AND t.CreatedTime <= '{$ThreadBeforeDate}'"; }
} $DB->query("\n\tINSERT INTO users_warnings_forums\n\t\t(UserID, Comment)\n\tVALUES\n\t\t('{$UserID}', '" . db_string($AdminComment) . "')\n\tON DUPLICATE KEY UPDATE\n\t\tComment = CONCAT('" . db_string($AdminComment) . "', Comment)"); Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage); //edit the post $DB->query("\n\tSELECT\n\t\tp.Body,\n\t\tp.AuthorID,\n\t\tp.TopicID,\n\t\tt.ForumID,\n\t\tCEIL(\n\t\t\t(\n\t\t\t\tSELECT COUNT(p2.ID)\n\t\t\t\tFROM forums_posts AS p2\n\t\t\t\tWHERE p2.TopicID = p.TopicID\n\t\t\t\t\tAND p2.ID <= '{$PostID}'\n\t\t\t) / " . POSTS_PER_PAGE . "\n\t\t) AS Page\n\tFROM forums_posts AS p\n\t\tJOIN forums_topics AS t ON p.TopicID = t.ID\n\t\tJOIN forums AS f ON t.ForumID = f.ID\n\tWHERE p.ID = '{$PostID}'"); list($OldBody, $AuthorID, $TopicID, $ForumID, $Page) = $DB->next_record(); // Perform the update $DB->query("\n\tUPDATE forums_posts\n\tSET Body = '" . db_string($Body) . "',\n\t\tEditedUserID = '{$UserID}',\n\t\tEditedTime = '{$SQLTime}'\n\tWHERE ID = '{$PostID}'"); $CatalogueID = floor((POSTS_PER_PAGE * $Page - POSTS_PER_PAGE) / THREAD_CATALOGUE); $Cache->begin_transaction("thread_{$TopicID}" . "_catalogue_{$CatalogueID}"); if ($Cache->MemcacheDBArray[$Key]['ID'] != $PostID) { $Cache->cancel_transaction(); $Cache->delete_value("thread_{$TopicID}" . "_catalogue_{$CatalogueID}"); //just clear the cache for would be cache-screwer-uppers } else { $Cache->update_row($Key, array('ID' => $Cache->MemcacheDBArray[$Key]['ID'], 'AuthorID' => $Cache->MemcacheDBArray[$Key]['AuthorID'], 'AddedTime' => $Cache->MemcacheDBArray[$Key]['AddedTime'], 'Body' => $Body, 'EditedUserID' => $LoggedUser['ID'], 'EditedTime' => $SQLTime, 'Username' => $LoggedUser['Username'])); $Cache->commit_transaction(3600 * 24 * 5); } $ThreadInfo = Forums::get_thread_info($TopicID); if ($ThreadInfo === null) { error(404); } if ($ThreadInfo['StickyPostID'] == $PostID) { $ThreadInfo['StickyPost']['Body'] = $Body; $ThreadInfo['StickyPost']['EditedUserID'] = $LoggedUser['ID']; $ThreadInfo['StickyPost']['EditedTime'] = $SQLTime; $Cache->cache_value("thread_{$TopicID}" . '_info', $ThreadInfo, 0); } $DB->query("\n\tINSERT INTO comments_edits\n\t\t(Page, PostID, EditUser, EditTime, Body)\n\tVALUES\n\t\t('forums', {$PostID}, {$UserID}, '{$SQLTime}', '" . db_string($OldBody) . "')"); $Cache->delete_value("forums_edits_{$PostID}"); header("Location: forums.php?action=viewthread&postid={$PostID}#post{$PostID}");
sleep(10); $DB->query("\n\t\tSELECT t.ID, t.ForumID\n\t\tFROM forums_topics AS t\n\t\t\tJOIN forums AS f ON t.ForumID = f.ID\n\t\tWHERE t.IsLocked = '0'\n\t\t\tAND t.IsSticky = '0'\n\t\t\tAND DATEDIFF(CURDATE(), DATE(t.LastPostTime)) / 7 > f.AutoLockWeeks\n\t\t\tAND f.AutoLock = '1'"); $IDs = $DB->collect('ID'); $ForumIDs = $DB->collect('ForumID'); if (count($IDs) > 0) { $LockIDs = implode(',', $IDs); $DB->query("\n\t\t\tUPDATE forums_topics\n\t\t\tSET IsLocked = '1'\n\t\t\tWHERE ID IN({$LockIDs})"); sleep(2); $DB->query("\n\t\t\tDELETE FROM forums_last_read_topics\n\t\t\tWHERE TopicID IN({$LockIDs})"); foreach ($IDs as $ID) { $Cache->begin_transaction("thread_{$ID}" . '_info'); $Cache->update_row(false, array('IsLocked' => '1')); $Cache->commit_transaction(3600 * 24 * 30); $Cache->expire_value("thread_{$ID}" . '_catalogue_0', 3600 * 24 * 30); $Cache->expire_value("thread_{$ID}" . '_info', 3600 * 24 * 30); Forums::add_topic_note($ID, 'Locked automatically by schedule', 0); } $ForumIDs = array_flip(array_flip($ForumIDs)); foreach ($ForumIDs as $ForumID) { $Cache->delete_value("forums_{$ForumID}"); } } echo "Old threads locked\n"; //------------- Delete dead torrents ------------------------------------// sleep(10); $DB->query("\n\t\tSELECT\n\t\t\tt.ID,\n\t\t\tt.GroupID,\n\t\t\ttg.Name,\n\t\t\tt.Format,\n\t\t\tt.Encoding,\n\t\t\tt.UserID,\n\t\t\tt.Media,\n\t\t\tHEX(t.info_hash) AS InfoHash\n\t\tFROM torrents AS t\n\t\t\tJOIN torrents_group AS tg ON tg.ID = t.GroupID\n\t\tWHERE\n\t\t\t(t.last_action < '" . time_minus(3600 * 24 * 28) . "' AND t.last_action != 0)\n\t\t\tOR\n\t\t\t(t.Time < '" . time_minus(3600 * 24 * 2) . "' AND t.last_action = 0)"); $Torrents = $DB->to_array(false, MYSQLI_NUM, false); echo 'Found ' . count($Torrents) . " inactive torrents to be deleted.\n"; $LogEntries = $DeleteNotes = array(); // Exceptions for inactivity deletion $InactivityExceptionsMade = array();
?> <div class="linkbox"> <a href="forums.php?action=edit_rules&forumid=<?php echo $ForumID; ?> " class="brackets">Change specific rules</a> </div> <?php } if (!empty($Forums[$ForumID]['SpecificRules'])) { ?> <div class="linkbox"> <strong>Forum Specific Rules</strong> <?php foreach ($Forums[$ForumID]['SpecificRules'] as $ThreadIDs) { $Thread = Forums::get_thread_info($ThreadIDs); if ($Thread === null) { error(404); } ?> <br /> <a href="forums.php?action=viewthread&threadid=<?php echo $ThreadIDs; ?> " class="brackets"><?php echo display_str($Thread['Title']); ?> </a> <?php } ?>
public function setForumNotification($postId, $type) { // Notify the members of the group $forums = new Forums(); $forums->prepare_notification($postId, $type); }
<?php $user = new User(); $forums = new Forums(); if (!$user->isAdmLoggedIn() && !$user->data()->group == 3) { Session::flash('error', 'You are not admin/logged in!'); Redirect::to('/admin'); } if (Input::exists()) { if (Token::check(Input::get('token'))) { $val = new Validation(); $validation = $val->check($_POST, array('title' => array('required' => true), 'cat_par' => array('required' => true))); if ($validation->passed()) { $parent = Input::get('cat_par') == "NULL" ? null : Input::get('cat_par'); try { $forums->createCat(array('name' => escape(Input::get('title')), 'parent' => $parent)); Session::flash('complete', 'You added a cat!'); Redirect::to('/admin'); } catch (Exception $e) { } } } } ?> <html> <head> <?php require 'inc/templates/head.php'; ?> </head> <body>
} if ($_GET['catchup']) { $DB->query("UPDATE users_notify_quoted SET UnRead = '0' WHERE UserID = '{$LoggedUser['ID']}'"); $Cache->delete_value('notify_quoted_' . $LoggedUser['ID']); header('Location: userhistory.php?action=quote_notifications'); die; } if (isset($LoggedUser['PostsPerPage'])) { $PerPage = $LoggedUser['PostsPerPage']; } else { $PerPage = POSTS_PER_PAGE; } list($Page, $Limit) = Format::page_limit($PerPage); // Get $Limit last quote notifications // We deal with the information about torrents and requests later on... $sql = "\n\tSELECT\n\t\tSQL_CALC_FOUND_ROWS\n\t\tq.Page,\n\t\tq.PageID,\n\t\tq.PostID,\n\t\tq.QuoterID,\n\t\tq.Date,\n\t\tq.UnRead,\n\t\tf.ID as ForumID,\n\t\tf.Name as ForumName,\n\t\tt.Title as ForumTitle,\n\t\ta.Name as ArtistName,\n\t\tc.Name as CollageName\n\tFROM users_notify_quoted AS q\n\t\tLEFT JOIN forums_topics AS t ON t.ID = q.PageID\n\t\tLEFT JOIN forums AS f ON f.ID = t.ForumID\n\t\tLEFT JOIN artists_group AS a ON a.ArtistID = q.PageID\n\t\tLEFT JOIN collages AS c ON c.ID = q.PageID\n\tWHERE q.UserID = {$LoggedUser['ID']}\n\t\tAND (q.Page != 'forums' OR " . Forums::user_forums_sql() . ")\n\t\tAND (q.Page != 'collages' OR c.Deleted = '0')\n\t\t{$UnreadSQL}\n\tORDER BY q.Date DESC\n\tLIMIT {$Limit}"; $DB->query($sql); $Results = $DB->to_array(false, MYSQLI_ASSOC, false); $DB->query('SELECT FOUND_ROWS()'); list($NumResults) = $DB->next_record(); $TorrentGroups = $Requests = array(); foreach ($Results as $Result) { if ($Result['Page'] == 'torrents') { $TorrentGroups[] = $Result['PageID']; } elseif ($Result['Page'] == 'requests') { $Requests[] = $Result['PageID']; } } $TorrentGroups = Torrents::get_groups($TorrentGroups, true, true, false); $Requests = Requests::get_requests($Requests); //Start printing page
$Topics['topics'] = array(); } $Smarty->assign('Forum', $Topics); $Smarty->assign('Page', Page::Info('forum', array('bodycss' => 'forums view-forum', 'pagetitle' => $Topics['forum_name'] . ' - '))); $Smarty->display('pages/forums_list_topics'); } else { if (String::Match($_REQUEST['lastcategory'], 'topic')) { echo "Создаем топик!"; } else { Page::GenerateErrorPage($Smarty, 404); } } } else { Page::GenerateErrorPage($Smarty, 404); } } else { if (String::Match($_REQUEST['subcategory'], 'topic')) { $TopicData = Forums::GetTopicData($_REQUEST['lastcategory']); $Smarty->assign('TopicData', $TopicData); $Smarty->assign('Page', Page::Info('forum', array('bodycss' => 'forums view-topic logged-in', 'pagetitle' => $TopicData['topic']['name'] . ' - '))); $Smarty->display('pages/forums_view_topic'); } else { Page::GenerateErrorPage($Smarty, 404); } } } break; default: header('Location: /'); break; }
* Page (artist, collages, requests, torrents or forums) * PageID (ArtistID, CollageID, RequestID, GroupID, TopicID) * PostID (of the last read post) * ForumID * ForumName * Name (for artists and collages; carries the topic title for forum subscriptions) * LastPost (PostID of the last post) * LastPostTime * LastReadBody * LastReadEditedTime * LastReadUserID * LastReadUsername * LastReadAvatar * LastReadEditedUserID */ $DB->query("\n\t(SELECT\n\t\tSQL_CALC_FOUND_ROWS\n\t\ts.Page,\n\t\ts.PageID,\n\t\tlr.PostID,\n\t\tnull AS ForumID,\n\t\tnull AS ForumName,\n\t\tIF(s.Page = 'artist', a.Name, co.Name) AS Name,\n\t\tc.ID AS LastPost,\n\t\tc.AddedTime AS LastPostTime,\n\t\tc_lr.Body AS LastReadBody,\n\t\tc_lr.EditedTime AS LastReadEditedTime,\n\t\tum.ID AS LastReadUserID,\n\t\tum.Username AS LastReadUsername,\n\t\tui.Avatar AS LastReadAvatar,\n\t\tc_lr.EditedUserID AS LastReadEditedUserID\n\tFROM users_subscriptions_comments AS s\n\t\tLEFT JOIN users_comments_last_read AS lr ON lr.UserID = {$LoggedUser['ID']} AND lr.Page = s.Page AND lr.PageID = s.PageID\n\t\tLEFT JOIN artists_group AS a ON s.Page = 'artist' AND a.ArtistID = s.PageID\n\t\tLEFT JOIN collages AS co ON s.Page = 'collages' AND co.ID = s.PageID\n\t\tLEFT JOIN comments AS c ON c.ID = (\n\t\t\t\t\tSELECT MAX(ID)\n\t\t\t\t\tFROM comments\n\t\t\t\t\tWHERE Page = s.Page\n\t\t\t\t\t\tAND PageID = s.PageID\n\t\t\t\t)\n\t\tLEFT JOIN comments AS c_lr ON c_lr.ID = lr.PostID\n\t\tLEFT JOIN users_main AS um ON um.ID = c_lr.AuthorID\n\t\tLEFT JOIN users_info AS ui ON ui.UserID = um.ID\n\tWHERE s.UserID = {$LoggedUser['ID']} AND s.Page IN ('artist', 'collages', 'requests', 'torrents') AND (s.Page != 'collages' OR co.Deleted = '0')" . ($ShowUnread ? ' AND c.ID > IF(lr.PostID IS NULL, 0, lr.PostID)' : '') . "\n\tGROUP BY s.PageID)\n\tUNION ALL\n\t(SELECT 'forums', s.TopicID, lr.PostID, f.ID, f.Name, t.Title, p.ID, p.AddedTime, p_lr.Body, p_lr.EditedTime, um.ID, um.Username, ui.Avatar, p_lr.EditedUserID\n\tFROM users_subscriptions AS s\n\t\tLEFT JOIN forums_last_read_topics AS lr ON lr.UserID = {$LoggedUser['ID']} AND s.TopicID = lr.TopicID\n\t\tLEFT JOIN forums_topics AS t ON t.ID = s.TopicID\n\t\tLEFT JOIN forums AS f ON f.ID = t.ForumID\n\t\tLEFT JOIN forums_posts AS p ON p.ID = (\n\t\t\t\t\tSELECT MAX(ID)\n\t\t\t\t\tFROM forums_posts\n\t\t\t\t\tWHERE TopicID = s.TopicID\n\t\t\t\t)\n\t\tLEFT JOIN forums_posts AS p_lr ON p_lr.ID = lr.PostID\n\t\tLEFT JOIN users_main AS um ON um.ID = p_lr.AuthorID\n\t\tLEFT JOIN users_info AS ui ON ui.UserID = um.ID\n\tWHERE s.UserID = {$LoggedUser['ID']}" . ($ShowUnread ? " AND p.ID > IF(t.IsLocked = '1' AND t.IsSticky = '0'" . ", p.ID, IF(lr.PostID IS NULL, 0, lr.PostID))" : '') . ' AND ' . Forums::user_forums_sql() . "\n\tGROUP BY t.ID)\n\tORDER BY LastPostTime DESC\n\tLIMIT {$Limit}"); $Results = $DB->to_array(false, MYSQLI_ASSOC, false); $DB->query('SELECT FOUND_ROWS()'); list($NumResults) = $DB->next_record(); $Debug->log_var($Results, 'Results'); $TorrentGroups = $Requests = array(); foreach ($Results as $Result) { if ($Result['Page'] == 'torrents') { $TorrentGroups[] = $Result['PageID']; } elseif ($Result['Page'] == 'requests') { $Requests[] = $Result['PageID']; } } $TorrentGroups = Torrents::get_groups($TorrentGroups, true, true, false); $Requests = Requests::get_requests($Requests); ?>
<?php enforce_login(); authorize(); if (!check_perms('site_moderate_forums')) { error(403); } $ThreadID = $_GET['threadid']; $PostID = $_GET['postid']; $Delete = !empty($_GET['remove']); if (!$ThreadID || !$PostID || !is_number($ThreadID) || !is_number($PostID)) { error(404); } $DB->query("\n\tSELECT\n\t\tCEIL(COUNT(ID)/" . POSTS_PER_PAGE . ") AS Pages,\n\t\tCEIL(SUM(IF(ID<={$PostID},1,0))/" . POSTS_PER_PAGE . ") AS Page\n\tFROM forums_posts\n\tWHERE TopicID={$ThreadID}\n\tGROUP BY TopicID"); if ($DB->has_results()) { list($Pages, $Page) = $DB->next_record(); if ($Delete) { $DB->query("\n\t\t\tUPDATE forums_topics\n\t\t\tSET StickyPostID = 0\n\t\t\tWHERE ID = {$ThreadID}"); Forums::add_topic_note($ThreadID, "Post {$PostID} unstickied"); } else { $DB->query("\n\t\t\tUPDATE forums_topics\n\t\t\tSET StickyPostID = {$PostID}\n\t\t\tWHERE ID = {$ThreadID}"); Forums::add_topic_note($ThreadID, "Post {$PostID} stickied"); } $Cache->delete_value('thread_' . $ThreadID . '_info'); $ThisCatalogue = floor((POSTS_PER_PAGE * $Page - POSTS_PER_PAGE) / THREAD_CATALOGUE); $LastCatalogue = floor((POSTS_PER_PAGE * $Pages - POSTS_PER_PAGE) / THREAD_CATALOGUE); for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) { $Cache->delete_value('thread_' . $ThreadID . '_catalogue_' . $i); } } header('Location: forums.php?action=viewthread&threadid=' . $ThreadID);
$role->add_cap($cap); } } } /** * Unregister roles on theme switch * * @since 1.2.0 */ public static function remove_caps() { foreach (self::$roles as $role => $caps) { $role = get_role($role); foreach ($caps as $cap) { $role->remove_cap($cap); } } } } // Initialize forums // Forums::init(); /** * Returns true if current page is forums-related. * * @return bool **/ function is_forums() { return is_singular('forum_thread') || is_post_type_archive('forum_thread') || is_tax('forum') || is_tax('forum_tag'); }
<?php $user = new User(); $forums = new Forums(); ?> <!DOCTYPE html> <html lang="en"> <head> <?php include 'inc/templates/head.php'; ?> </head> <body> <?php include 'inc/templates/nav.php'; ?> <div class="container"> <div class="col-md-3"><?php include 'pages/admin/nav.php'; ?> </div> <div class="col-md-9"> <div class="row"><a class="btn btn-md btn-default" href="/admin/addCat"><span class="glyphicon glyphicon-plus"></span></a></div><br/> <?php foreach ($forums->listParentCat() as $parent) { ?> <div class="row"> <div class='panel panel-primary'> <div class='panel-heading'> <a class="white" href="/admin/editCat?c=<?php echo $parent['id'];
/* New post page This is the page that's loaded if someone wants to make a new topic. Information to be expected in $_GET: forumid: The ID of the forum that it's being posted in */ $ForumID = $_GET['forumid']; if (!is_number($ForumID)) { error(404); } $Forum = Forums::get_forum_info($ForumID); if ($Forum === false) { error(404); } if (!Forums::check_forumperm($ForumID, 'Write') || !Forums::check_forumperm($ForumID, 'Create')) { error(403); } View::show_header('Forums > ' . $Forum['Name'] . ' > New Topic', 'comments,bbcode,jquery.validate,form_validate'); ?> <div class="thin"> <h2><a href="forums.php">Forums</a> > <a href="forums.php?action=viewforum&forumid=<?php echo $ForumID; ?> "><?php echo $Forum['Name']; ?> </a> > <span id="newthreadtitle">New Topic</span></h2> <div class="hidden" id="newthreadpreview"> <div class="linkbox"> <div class="center">
<?php $user = new User(); $forums = new Forums(); if (!$cat && !$post_id) { session::flash('error', 'There was no valid page! You have been taken back to the homepage!'); Redirect::to('/'); } $post = $forums->getPost($cat, $post_id); $post = $post[0]; $author = new User($post->post_user); ?> <html> <head> <?php include 'inc/templates/head.php'; ?> </head> <body> <?php include 'inc/templates/nav.php'; ?> <?php if (Session::exists('error')) { ?> <div class="alert alert-danger"><?php echo Session::flash('error'); ?> </div> <?php }
<?php authorize(); if (!check_perms('site_moderate_forums')) { error(403); } if (!isset($_POST['topicid'], $_POST['body']) || !is_number($_POST['topicid']) || $_POST['body'] == '') { error(404); } $TopicID = (int) $_POST['topicid']; Forums::add_topic_note($TopicID, $_POST['body']); header("Location: forums.php?action=viewthread&threadid={$TopicID}#thread_notes"); die;
/** * Returns whether or not the current user has new quote notifications. * @return int Number of unread quote notifications */ public static function has_new_quote_notifications() { $QuoteNotificationsCount = G::$Cache->get_value('notify_quoted_' . G::$LoggedUser['ID']); if ($QuoteNotificationsCount === false) { $sql = "\n\t\t\t\tSELECT COUNT(1)\n\t\t\t\tFROM users_notify_quoted AS q\n\t\t\t\t\tLEFT JOIN forums_topics AS t ON t.ID = q.PageID\n\t\t\t\t\tLEFT JOIN forums AS f ON f.ID = t.ForumID\n\t\t\t\t\tLEFT JOIN collages AS c ON q.Page = 'collages' AND c.ID = q.PageID\n\t\t\t\tWHERE q.UserID = " . G::$LoggedUser['ID'] . "\n\t\t\t\t\tAND q.UnRead\n\t\t\t\t\tAND (q.Page != 'forums' OR " . Forums::user_forums_sql() . ")\n\t\t\t\t\tAND (q.Page != 'collages' OR c.Deleted = '0')"; $QueryID = G::$DB->get_query_id(); G::$DB->query($sql); list($QuoteNotificationsCount) = G::$DB->next_record(); G::$DB->set_query_id($QueryID); G::$Cache->cache_value('notify_quoted_' . G::$LoggedUser['ID'], $QuoteNotificationsCount, 0); } return (int) $QuoteNotificationsCount; }
<?php $forums = new Forums(); $user = new User(); if (!$user->hasPermission('Admin') || !$user->isLoggedIn()) { Session::flash('error', 'You have to be admin/login for that!'); Redirect::to('/'); } if (Input::get('c') == null) { session::flash('error', 'you don\'t have the proper link'); Redirect::to('/admin'); } if (Input::exists()) { if (Token::check(Input::get('token'))) { $val = new Validation(); $validation = $val->check($_POST, array('title' => array('required' => true))); if ($validation->passed()) { $db = DB::getInstance(); $parent = Input::get('cat_par') == "NULL" ? null : Input::get('cat_par'); $update = $db->update('cat', Input::get('c'), array('name' => escape(Input::get('title')), 'parent' => $parent)); if ($update) { session::flash('complete', 'You have updated the category'); Redirect::to('/admin'); } } } } ?> <html> <head> <?php
$Smarty->assign('CSRFToken', Session::GenerateCSRFToken()); $Smarty->assign('TopicData', $TopicData); $Smarty->assign('Page', Page::Info('forum', array('bodycss' => 'forums view-topic logged-in', 'pagetitle' => $TopicData['topic']['name'] . ' - '))); $Smarty->display('pages/forums_view_topic'); } else { switch ($_REQUEST['datatype']) { case 'post': if (Session::ValidateCSRFToken($_REQUEST['csrftoken'])) { Text::Request(); } break; case 'up': Text::Request(); break; case 'report': Text::Request(); break; } } } elseif (Text::Match($_REQUEST['subcategory'], 'quote')) { echo Forums::QuotePost($_REQUEST['forumID'], $_REQUEST['topicID'], $_REQUEST['postID']); } else { Page::GenerateErrorPage($Smarty, 404); } } } break; default: header('Location: /'); break; }
<?php $user = new User(); $forums = new Forums(); ?> <!DOCTYPE html> <html lang="en"> <head> <?php include 'inc/templates/head.php'; ?> </head> <body> <?php require 'inc/templates/nav.php'; ?> <div class="container"> <div class="col-md-9"> <?php if ($cat) { if ($cat != null) { echo "<h1>Posts</h1><a href=\"/forums/create/{$cat}\">Create Post</a>"; ?> <table class='table table-striped table-hover'> <thead> <tr> <th>ID #</th> <th>Name</th> <th>User</th> </tr> </thead>
public function updatetopicAction() { global $mySession; $db = new Db(); $topicId = $this->getRequest()->getParam('topicId'); $this->view->topicId = $topicId; $this->view->pageHeading = "Edit Topic"; if ($this->getRequest()->isPost()) { $request = $this->getRequest(); $myform = new Form_Topic($topicId); if ($myform->isValid($request->getPost())) { $dataForm = $myform->getValues(); $myObj = new Forums(); $Result = $myObj->UpdateTopic($dataForm, $topicId); if ($Result == 1) { $mySession->errorMsg = "Topic updated successfully."; $this->_redirect('forum/index'); } else { $mySession->errorMsg = "Topic name you entered is already exists."; $this->view->myform = $myform; $this->render('edittopic'); } } else { $this->view->myform = $myform; $this->render('edittopic'); } } else { $this->_redirect('forum/edittopic/topicId/' . $topicId); } }
<h3><?php echo $ForumCats[$CategoryID]; ?> </h3> <table class="forum_index"> <tr class="colhead"> <td style="width: 2%;"></td> <td style="width: 25%;">Forum</td> <td>Last Post</td> <td style="width: 7%;">Topics</td> <td style="width: 7%;">Posts</td> </tr> <?php $OpenTable = true; } $Read = Forums::is_unread($Locked, $Sticky, $LastPostID, $LastRead, $LastTopicID, $LastTime) ? 'unread' : 'read'; /* Removed per request, as distracting if ($Locked) { $Read .= '_locked'; } if ($Sticky) { $Read .= '_sticky'; } */ ?> <tr class="row<?php echo $Row; ?> "> <td class="<?php echo $Read;
public static function CreateTopic($ForumID, $PostedBy, $Topic, $Message) { $PostTime = time(); $TopicID = Forums::AddTopic($ForumID, $PostedBy, $Topic, 0, $PostTime); Forums::AddTopicComment($ForumID, $TopicID, 1, $PostedBy, $PostTime, nl2br($Message)); return $TopicID; }
} $Body = $_POST['body']; if (!empty($LoggedUser['DisablePosting'])) { error('Your posting privileges have been removed.'); } $TopicID = $_POST['thread']; $ThreadInfo = Forums::get_thread_info($TopicID); if ($ThreadInfo === null) { error(404); } $ForumID = $ThreadInfo['ForumID']; $SQLTime = sqltime(); if (!Forums::check_forumperm($ForumID)) { error(403); } if (!Forums::check_forumperm($ForumID, 'Write') || $LoggedUser['DisablePosting'] || $ThreadInfo['IsLocked'] == '1' && !check_perms('site_moderate_forums')) { error(403); } if (isset($_POST['subscribe']) && Subscriptions::has_subscribed($TopicID) === false) { Subscriptions::subscribe($TopicID); } //Now lets handle the special case of merging posts, we can skip bumping the thread and all that fun if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID'] && (!check_perms('site_forums_double_post') && !in_array($ForumID, $ForumsDoublePost) || isset($_POST['merge']))) { //Get the id for this post in the database to append $DB->query("\n\t\tSELECT ID, Body\n\t\tFROM forums_posts\n\t\tWHERE TopicID = '{$TopicID}'\n\t\t\tAND AuthorID = '" . $LoggedUser['ID'] . "'\n\t\tORDER BY ID DESC\n\t\tLIMIT 1"); list($PostID, $OldBody) = $DB->next_record(MYSQLI_NUM, false); //Edit the post $DB->query("\n\t\tUPDATE forums_posts\n\t\tSET\n\t\t\tBody = CONCAT(Body,'\n\n" . db_string($Body) . "'),\n\t\t\tEditedUserID = '" . $LoggedUser['ID'] . "',\n\t\t\tEditedTime = '{$SQLTime}'\n\t\tWHERE ID = '{$PostID}'"); //Store edit history $DB->query("\n\t\tINSERT INTO comments_edits\n\t\t\t(Page, PostID, EditUser, EditTime, Body)\n\t\tVALUES\n\t\t\t('forums', {$PostID}, " . $LoggedUser['ID'] . ", '{$SQLTime}', '" . db_string($OldBody) . "')"); $Cache->delete_value("forums_edits_{$PostID}");
"><?php echo $ForumName; ?> </a> > <?php echo $ThreadTitle; ?> </div> <div class="linkbox"> <?php echo $Pages; ?> </div> <?php if (!$ThreadInfo['IsLocked'] || check_perms('site_moderate_forums')) { if (Forums::check_forumperm($ForumID, 'Write') && !$LoggedUser['DisablePosting']) { View::parse('generic/reply/quickreply.php', array('InputTitle' => 'Post reply', 'InputName' => 'thread', 'InputID' => $ThreadID, 'ForumID' => $ForumID, 'TextareaCols' => 90)); } } if (check_perms('site_moderate_forums')) { G::$DB->query("\n\t\t\tSELECT ID, AuthorID, AddedTime, Body\n\t\t\tFROM forums_topic_notes\n\t\t\tWHERE TopicID = {$ThreadID}\n\t\t\tORDER BY ID ASC"); $Notes = G::$DB->to_array(); ?> <br /> <h3 id="thread_notes">Thread notes</h3> <a href="#" onclick="$('#thread_notes_table').gtoggle(); return false;" class="brackets">Toggle</a> <form action="forums.php" method="post"> <input type="hidden" name="action" value="take_topic_notes" /> <input type="hidden" name="auth" value="<?php echo $LoggedUser['AuthKey']; ?> " />
if (isset($_GET['pp'])) { $PerPage = $_GET['pp']; } elseif (isset($LoggedUser['PostsPerPage'])) { $PerPage = $LoggedUser['PostsPerPage']; } else { $PerPage = POSTS_PER_PAGE; } //---------- Get some data to start processing // Thread information, constant across all pages $ThreadInfo = Forums::get_thread_info($ThreadID, true, true); if ($ThreadInfo === null) { json_die('failure', 'no such thread exists'); } $ForumID = $ThreadInfo['ForumID']; // Make sure they're allowed to look at the page if (!Forums::check_forumperm($ForumID)) { print json_encode(array('status' => 'failure')); die; } //Post links utilize the catalogue & key params to prevent issues with custom posts per page if ($ThreadInfo['Posts'] > $PerPage) { if (isset($_GET['post']) && is_number($_GET['post'])) { $PostNum = $_GET['post']; } elseif (isset($_GET['postid']) && is_number($_GET['postid'])) { $DB->query("\n\t\t\tSELECT COUNT(ID)\n\t\t\tFROM forums_posts\n\t\t\tWHERE TopicID = {$ThreadID}\n\t\t\t\tAND ID <= {$_GET['postid']}"); list($PostNum) = $DB->next_record(); } else { $PostNum = 1; } } else { $PostNum = 1;
<?php $forums = new Forums(); $user = new User(); if ($cat && $post_id) { if (!$forums->getPost(escape($cat), escape($post_id))) { Redirect::to('/404'); // TODO MAKE 404 } } else { Redirect::to('/404'); //TODO: MAKE 404 } if (!$user->isLoggedIn()) { Session::flash('error', 'It seems you are not logged in!'); Redirect::to('/'); } $db = DB::getInstance(); $q = $db->get('post', array('id', '=', escape($post_id)))->first(); if (Input::exists()) { if (Input::get('Submit')) { if (Token::check(Input::get('token'))) { $val = new Validation(); $validate = $val->check($_POST, array('title' => array('required' => true), 'content' => array('required' => true))); if ($validate->passed()) { try { $forums->createReply(array('title' => escape(Input::get('title')), 'post_id' => escape($post_id), 'content' => Input::get('content'), 'date' => date('Y-m-d- H:i:s'), 'user_id' => $user->data()->id)); Notifaction::createMessage($user->data()->username . ' posted a reply on your page', $forums->getPost2($post_id)->post_user); session::flash('complete', 'You posted your reply!'); Redirect::to('/forums/view/' . $cat . '/' . $post_id); } catch (Exception $e) {
} $SQL .= ' p.ID, p.AddedTime, p.Body, p.EditedUserID, p.EditedTime, ed.Username, p.TopicID, t.Title, t.LastPostID,'; if ($UserID === $LoggedUser['ID']) { $SQL .= ' l.PostID AS LastRead,'; } $SQL .= "\n\t\t\t\tt.IsLocked,\n\t\t\t\tt.IsSticky\n\t\t\tFROM forums_posts AS p\n\t\t\t\tLEFT JOIN users_main AS um ON um.ID = p.AuthorID\n\t\t\t\tLEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID\n\t\t\t\tLEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID\n\t\t\t\tJOIN forums_topics AS t ON t.ID = p.TopicID\n\t\t\t\tJOIN forums AS f ON f.ID = t.ForumID\n\t\t\t\tLEFT JOIN forums_last_read_topics AS l ON l.UserID = {$UserID} AND l.TopicID = t.ID\n\t\t\tWHERE p.AuthorID = {$UserID}\n\t\t\t\tAND " . Forums::user_forums_sql(); if ($ShowUnread) { $SQL .= ' AND ((t.IsLocked = \'0\' OR t.IsSticky = \'1\') AND (l.PostID < t.LastPostID OR l.PostID IS NULL) ) '; } $SQL .= ' ORDER BY p.ID DESC'; if ($ShowGrouped) { $SQL .= ' ) AS sub GROUP BY TopicID ORDER BY ID DESC'; } $SQL .= "\n\t\tLIMIT {$Limit}";