function EditForum() { global $CFG, $dbConn; // What forum do they want to edit? $aForum['id'] = (int) $_REQUEST['forumid']; // Get the forum's information. $dbConn->query("SELECT name, description, disporder, parent FROM board WHERE id={$aForum['id']}"); list($aForum['title'], $aForum['description'], $aForum['displayorder'], $aForum['parent']) = $dbConn->getresult(); // Does the forum exist? if (!$aForum['title']) { Msg("Invalid forum specified.{$CFG['msg']['invalidlink']}"); } // Are they coming for the first time or submitting information? if (isset($_REQUEST['submit'])) { // Submitting information, so store it. $aForum['title'] = trim($_REQUEST['title']); $aForum['description'] = trim($_REQUEST['description']); $aForum['displayorder'] = (int) $_REQUEST['displayorder']; $aForum['parent'] = (int) $_REQUEST['parent']; // Validate the information, and submit it to the database if everything's okay. $aError = EditForumNow($aForum); } // Get the forums. list($aForums) = GetForumInfo(); // Template require "./skins/{$CFG['skin']}/admincp/editforum.tpl.php"; // Send the page. exit; }
function ShowThread() { global $CFG, $dbConn, $aViewedThreads, $aPostIcons, $aGroup; // What thread do they want? $iThreadID = (int) $_REQUEST['threadid']; // How many posts per page do they want to view? $iPostsPerPage = (int) $_REQUEST['perpage']; if ($iPostsPerPage < 1) { // They don't know what they want. Use their value. $iPostsPerPage = $_SESSION['postsperpage']; } // What page do they want to view? $iPage = (int) $_REQUEST['page']; if ($iPage < 1) { // They don't know what they want. Give them the first page. $iPage = 1; } // Calculate the offset. $iOffset = $iPage * $iPostsPerPage - $iPostsPerPage; // Get the thread's information. $dbConn->query("SELECT title, parent, postcount, attachcount, poll, closed, visible, sticky, notes FROM thread WHERE id={$iThreadID}"); if (!($aSQLResult = $dbConn->getresult())) { Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}"); } // Store the thread's information. $aThread[TITLE] = $aSQLResult[0]; $aThread[PARENT] = $aSQLResult[1]; $aThread[POSTCOUNT] = $aSQLResult[2]; $aThread[ATTACHCOUNT] = $aSQLResult[3]; $aThread[POLL] = $aSQLResult[4]; $aThread[CLOSED] = $aSQLResult[5]; $aThread[VISIBLE] = $aSQLResult[6]; $aThread[STICKY] = $aSQLResult[7]; $aThread[NOTES] = $aSQLResult[8]; // Is the thread visible? if (!$aThread[VISIBLE]) { // No. Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}"); } // Calculate the number of pages this thread is made of. $iNumberPages = ceil($aThread[POSTCOUNT] / $iPostsPerPage); // Is the page they asked for out of range? if ($iPage > $iNumberPages) { // Yes, give them the last page and recalculate the offset. $iPage = $iNumberPages; $iOffset = $iPage * $iPostsPerPage - $iPostsPerPage; } // Do they want to go to a specific post? if (isset($_REQUEST['postid'])) { $iPostID = (int) $_REQUEST['postid']; // Get the page the post is on. $dbConn->query("SELECT id FROM post WHERE parent={$iThreadID} ORDER BY datetime_posted"); for ($iPosition = 1; list($iPost) = $dbConn->getresult(); $iPosition++) { if ($iPost == $iPostID) { break; } } // Is the post in this thread? if ($iPosition <= $aThread[POSTCOUNT]) { // Yes, reset the page and recalculate the offset. $iPage = ceil($iPosition / $iPostsPerPage); $iOffset = $iPage * $iPostsPerPage - $iPostsPerPage; } } else { if ($_REQUEST['goto'] == 'newest') { // Yes, so set what the minimum newest post time is. $tNewest = isset($aViewedThreads[$iThreadID]) ? $aViewedThreads[$iThreadID] : $_SESSION['lastactive']; // Get the newest post's ID. $dbConn->query("SELECT id FROM post WHERE parent={$iThreadID} AND datetime_posted > {$tNewest} ORDER BY datetime_posted LIMIT 1"); if (list($iPostID) = $dbConn->getresult()) { // Redirect the user to the newest post. $strSID = SID ? '&' . SID : ''; header("Location: thread.php?threadid={$iThreadID}&postid={$iPostID}{$strSID}#post{$iPostID}"); exit; } } } // Get the information of all the categories and forums. list($aCategories, $aBoards) = GetForumInfo(); // Save our forum name, as well as the ID and name of the category we belong to. $iCategoryID = $aBoards[$aThread[PARENT]][0]; $strCategoryName = $aCategories[$iCategoryID]; $strForumName = $aBoards[$aThread[PARENT]][1]; // Get the information of each post and poster in this thread. $dbConn->query("SELECT post.id, post.author, post.datetime_posted, post.datetime_edited, post.title AS ptitle, post.body, post.icon, post.dsmilies, post.ipaddress, citizen.username, citizen.datejoined, citizen.title AS mtitle, citizen.signature, citizen.residence, citizen.website, citizen.lastactive, citizen.loggedin, citizen.postcount, citizen.usergroup, citizen.invisible FROM post LEFT JOIN citizen ON (post.author = citizen.id) WHERE post.parent={$iThreadID} ORDER BY post.datetime_posted ASC LIMIT {$iPostsPerPage} OFFSET {$iOffset}"); while ($aSQLResult = $dbConn->getresult(TRUE)) { // Store the post information. $iPostID = $aSQLResult['id']; $aPosts[$iPostID][AUTHOR] = $aSQLResult['author']; $aPosts[$iPostID][DT_POSTED] = $aSQLResult['datetime_posted']; $aPosts[$iPostID][DT_EDITED] = $aSQLResult['datetime_edited']; $aPosts[$iPostID][TITLE] = $aSQLResult['ptitle']; $aPosts[$iPostID][BODY] = $aSQLResult['body']; $aPosts[$iPostID][ICON] = $aSQLResult['icon']; $aPosts[$iPostID][DSMILIES] = $aSQLResult['dsmilies']; $aPosts[$iPostID][LOGGEDIP] = $aSQLResult['ipaddress'] === NULL ? FALSE : TRUE; // Store member's information into the Users array. if (!isset($aUsers[$aSQLResult['author']])) { $aUsers[$aPosts[$iPostID][AUTHOR]][USERNAME] = $aSQLResult['username']; $aUsers[$aPosts[$iPostID][AUTHOR]][JOINDATE] = $aSQLResult['datejoined']; $aUsers[$aPosts[$iPostID][AUTHOR]][TITLE] = $aSQLResult['mtitle'] ? $aSQLResult['mtitle'] : $aGroup[$aSQLResult['usergroup']]['usertitle']; $aUsers[$aPosts[$iPostID][AUTHOR]][RESIDENCE] = $aSQLResult['residence']; $aUsers[$aPosts[$iPostID][AUTHOR]][SIGNATURE] = $aSQLResult['signature']; $aUsers[$aPosts[$iPostID][AUTHOR]][WWW] = $aSQLResult['website']; $aUsers[$aPosts[$iPostID][AUTHOR]][LASTACTIVE] = $aSQLResult['lastactive']; $aUsers[$aPosts[$iPostID][AUTHOR]][ONLINE] = $aSQLResult['loggedin']; $aUsers[$aPosts[$iPostID][AUTHOR]][POSTCOUNT] = $aSQLResult['postcount']; $aUsers[$aPosts[$iPostID][AUTHOR]][INVISIBLE] = (bool) $aSQLResult['invisible']; } } // Get the information of any attachments. if ($aThread[ATTACHCOUNT]) { $dbConn->query("SELECT post.id AS parent, attachment.id, attachment.filename, attachment.viewcount FROM post INNER JOIN attachment ON (attachment.parent = post.id) WHERE post.parent={$iThreadID}"); while (list($iPostID, $iAttachmentID, $strFilename, $iViewCount) = $dbConn->getresult()) { // Store the attachments' information into the Attachments array. $aAttachments[$iPostID][$iAttachmentID][0] = $strFilename; $aAttachments[$iPostID][$iAttachmentID][1] = $iViewCount; } } // Tally the votes if we have a poll. if ($aThread[POLL]) { // Get the poll information. $iPollID = $iThreadID; $dbConn->query("SELECT question, answers, multiplechoices, timeout, datetime FROM poll WHERE id={$iPollID}"); list($strPollQuestion, $strPollAnswers, $bMultipleChoices, $iTimeout, $tPosted) = $dbConn->getresult(); $aPollAnswers = unserialize($strPollAnswers); $bClosed = $iTimeout && $CFG['globaltime'] > $tPosted + $iTimeout * 86400 ? TRUE : FALSE; // Get the votes. $dbConn->query("SELECT ownerid, vote FROM pollvote WHERE parent={$iPollID}"); while (list($iOwnerID, $iVote) = $dbConn->getresult()) { // Tally the vote. $aVotes[$iVote]++; // Increment the vote counter. $iVoteCount++; // Is this our vote? if ($iOwnerID == $_SESSION['userid']) { // Yes. $bHasVoted = TRUE; } } } // Add to the thread's viewcount. $dbConn->query("UPDATE thread SET viewcount=viewcount+1 WHERE id={$iThreadID}"); // Update the user's last visit of this thread. $tLastViewed = isset($aViewedThreads[$iThreadID]) ? $aViewedThreads[$iThreadID] : $_SESSION['lastactive']; // Update the user's viewed threads cookie. $aViewedThreads[$iThreadID] = $CFG['globaltime']; setcookie('viewedthreads', base64_encode(serialize($aViewedThreads)), 0, $CFG['paths']['cookies']); // Template require "./skins/{$CFG['skin']}/thread.tpl.php"; // Send the page. exit; }
$aRequest = unserialize($aSQLResult['lastrequest']); // Store the user's information. $aGuests[$iIndex][LOCATION] = GetLocation($strLastLocation, $aRequest); $aGuests[$iIndex][LASTACTIVE] = $aSQLResult['lastactive']; if ($_SESSION['permissions']['cviewips'] && $CFG['iplogging']) { $aGuests[$iIndex][IPADDRESS] = gethostbyaddr(long2ip($aSQLResult['ipaddress'])); } else { $aGuests[$iIndex][IPADDRESS] = NULL; } } // Free memory. unset($aSQLResult); unset($aLocations); unset($aRequest); // Get the information of each forum. list($aCategory, $aForum) = GetForumInfo(); // Template require "./skins/{$CFG['skin']}/online.tpl.php"; // *************************************************************************** \\ function GetLocation($strLastLocation, $aRequest) { global $CFG; // Sanitize the request array. $aRequest = array_map('urlencode', $aRequest); // Location descriptions $aLocations['admincp.php'][NULL] = 'Administrating...'; $aLocations['attachment.php'][NULL] = 'Viewing Attachment'; $aLocations['calendar.php'][NULL] = 'Viewing <a href="calendar.php">Calendar</a>'; $aLocations['calendar.php']['action=addevent'] = 'Adding Event to the <a href="calendar.php">Calendar</a>'; $aLocations['calendar.php']['action=viewevent'] = 'Viewing a Calendar Event'; $aLocations['editpost.php'][NULL] = 'Editing Post';
function Unauthorized() { global $CFG; // Get the information of each forum. list($aCategory, $aForum) = GetForumInfo(); // Template require "./skins/{$CFG['skin']}/unauthorized.tpl.php"; // Send the page. exit; }
function AlreadyRegistered() { global $CFG; // Get the information of each forum, for our Forum Jump later. list($aCategory, $aForum) = GetForumInfo(); // Template require "./skins/{$CFG['skin']}/alreadyregistered.tpl.php"; // Send the page. exit; }
function GetIP() { global $CFG, $dbConn; // Are they authorized to view IP addresses? if (!$_SESSION['permissions']['cviewips']) { // No, so give them the bad news. Unauthorized(); } // What do they want to get an IP address of? if (isset($_REQUEST['postid'])) { // Post $iPostID = (int) $_REQUEST['postid']; $strWhat = 'post'; // Get the IP address and thread ID of the post. $dbConn->query("SELECT ipaddress, parent FROM post WHERE id={$iPostID}"); if (!(list($iIP, $iThreadID) = $dbConn->getresult())) { // Invalid post specified. Msg("Invalid post specified.{$CFG['msg']['invalidlink']}"); } $strIP = long2ip($iIP); $strBackURL = "thread.php?threadid={$iThreadID}&postid={$iPostID}#post{$iPostID}"; } else { if (isset($_REQUEST['messageid'])) { // Private message $iMessageID = (int) $_REQUEST['messageid']; $strWhat = 'PM'; $strBackURL = "private.php?action=viewmessage&id={$iMessageID}"; // Get the IP address of the PM. $dbConn->query("SELECT ipaddress FROM pm WHERE id={$iMessageID}"); if (!(list($iIP) = $dbConn->getresult())) { // Invalid PM specified. Msg("Invalid PM specified.{$CFG['msg']['invalidlink']}"); } $strIP = long2ip($iIP); } else { // Nothing was specified. Msg('You must specify a post or PM for which to get an IP address.'); } } // Was there an IP address stored with the post/PM? if ($iIP === NULL) { // Nope. Msg("No IP address was stored with the specified {$strWhat}. If you believe this is an error, please notify the <a href=\"mailto:{$CFG['general']['admin']['email']}\">Webmaster</a>."); } // Get the information of each forum. list($aCategory, $aForum) = GetForumInfo(); // Template require "./skins/{$CFG['skin']}/getip.tpl.php"; // Send the page. exit; }