Example #1
0
function DisplayCategory($iCategoryID, $aCategory)
{
    global $CFG, $dbConn, $aViewedThreads, $aCategories, $aForums;
    $aUsers = array();
    // Get the user's per-page settings.
    $iThreadsPerPage = $_SESSION['threadsperpage'];
    $iPostsPerPage = $_SESSION['postsperpage'];
    // Build a list of our children forums.
    foreach ($aForums as $iForumID => $aForum) {
        // Is this forum our child?
        if ($aForum[PARENT] == $iCategoryID) {
            // Yes, so save the forum to the list.
            $aChildren[$iForumID] = $aForum;
            // Add the last poster to our list of users to get names for.
            if ($aForum[LPOSTER]) {
                $aUsers[] = $aForum[LPOSTER];
            }
        }
    }
    // Get any needed usernames.
    $aUsernames = GetUsernames($aUsers);
    unset($aUsers);
    // Get any new posts.
    $strForums = implode(', ', array_keys($aChildren));
    $dbConn->query("SELECT post.id, post.datetime_posted, post.parent, thread.parent FROM post LEFT JOIN thread ON (thread.id = post.parent) WHERE thread.parent IN ({$strForums}) AND datetime_posted > {$_SESSION['lastactive']} ORDER BY datetime_posted DESC");
    while (list($iPostID, $tPosted, $iThreadID, $iParentID) = $dbConn->getresult()) {
        // If we've read the thread, have we read it since the post was made?
        if (!isset($aViewedThreads[$iThreadID]) || $aViewedThreads[$iThreadID] < $tPosted) {
            // No, so there are unread posts for that forum.
            $aNewPosts[$iParentID] = TRUE;
        }
    }
    // Template
    require "./skins/{$CFG['skin']}/displaycategory.tpl.php";
    // Send the page.
    exit;
}
Example #2
0
function Tracking()
{
    global $CFG, $dbConn, $aPostIcons;
    $aUsers = array();
    $aFolders = array('Inbox', 'Sent Items');
    // Get all messages that we've sent that have tracking enabled.
    $dbConn->query("SELECT id, datetime, recipient, subject, icon, beenread, readtime FROM pm WHERE author={$_SESSION['userid']} AND tracking=1 ORDER BY datetime DESC");
    while ($aSQLResult = $dbConn->getresult(TRUE)) {
        // Has this message been read or unread?
        if ($aSQLResult['beenread']) {
            // Read.
            $iMessageID = $aSQLResult['id'];
            $aRead[$iMessageID][DATETIME] = $aSQLResult['datetime'];
            $aRead[$iMessageID][RECIPIENT] = $aSQLResult['recipient'];
            $aRead[$iMessageID][SUBJECT] = $aSQLResult['subject'];
            $aRead[$iMessageID][ICON][URL] = "{$CFG['paths']['posticons']}{$aPostIcons[$aSQLResult['icon']]['filename']}";
            $aRead[$iMessageID][ICON][ALT] = $aPostIcons[$aSQLResult['icon']]['title'];
            $aRead[$iMessageID][READTIME] = $aSQLResult['readtime'];
        } else {
            // Unread.
            $iMessageID = $aSQLResult['id'];
            $aUnread[$iMessageID][DATETIME] = $aSQLResult['datetime'];
            $aUnread[$iMessageID][RECIPIENT] = $aSQLResult['recipient'];
            $aUnread[$iMessageID][SUBJECT] = $aSQLResult['subject'];
            $aUnread[$iMessageID][ICON][URL] = "{$CFG['paths']['posticons']}{$aPostIcons[$aSQLResult['icon']]['filename']}";
            $aUnread[$iMessageID][ICON][ALT] = $aPostIcons[$aSQLResult['icon']]['title'];
        }
        // Add the author to our list of users to get names for.
        $aUsers[] = $aSQLResult['recipient'];
    }
    // Get the usernames.
    $aUsernames = GetUsernames($aUsers);
    unset($aUsers);
    // Get the folders.
    $dbConn->query("SELECT pmfolders FROM citizen WHERE id={$_SESSION['userid']}");
    list($strFolders) = $dbConn->getresult();
    $aFolders = $aFolders + unserialize($strFolders);
    // Template
    require "./skins/{$CFG['skin']}/pm/tracking.tpl.php";
    // Send the page.
    exit;
}
Example #3
0
File: search.php Project: OvBB/v1.0
function ViewResultPosts($aResultInfo)
{
    global $CFG, $dbConn, $aViewedThreads, $aPostIcons;
    $aUsers = array();
    // Did this user create the result they're trying to view?
    if ($aResultInfo['author']) {
        if ($aResultInfo['author'] != $_SESSION['userid']) {
            // Nope.
            Msg("Invalid search result specified.{$CFG['msg']['invalidlink']}");
        }
    } else {
        if ($aResultInfo['ipaddress'] != $_SESSION['userip'] || $CFG['iplogging'] == FALSE) {
            // Nope.
            Msg("Invalid search result specified.{$CFG['msg']['invalidlink']}");
        }
    }
    // Parse the result information.
    $iResultID = $aResultInfo['id'];
    $strQueryString = $aResultInfo['querystring'];
    $aResults = explode(',', $aResultInfo['results']);
    list($iSortBy, $bSortOrder) = explode(',', $aResultInfo['sortinfo']);
    // Get the user's per-page settings.
    $iPostsPerPage = $_SESSION['postsperpage'];
    // User-specified value takes precedence.
    if ((int) $_REQUEST['perpage']) {
        $iPostsPerPage = abs($_REQUEST['perpage']);
    }
    // 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;
    // Calculate the number of pages this result is made of.
    $iNumberPages = ceil(count($aResults) / $iPostsPerPage);
    // Is the page they asked for out of range?
    if ($iPage > $iNumberPages) {
        // Yes, give them the last page and recalculate offset.
        $iPage = $iNumberPages;
        $iOffset = $iPage * $iPostsPerPage - $iPostsPerPage;
    }
    // Did they specify by what to sort?
    if (isset($_REQUEST['sortby'])) {
        // Yes, so use it.
        $strSortBy = strtolower($_REQUEST['sortby']);
        switch ($strSortBy) {
            // They specified us something valid.
            case 'topic':
            case 'forum':
            case 'author':
            case 'postcount':
            case 'viewcount':
            case 'date':
                break;
                // They don't know what they want. We'll sort by post date.
            // They don't know what they want. We'll sort by post date.
            default:
                $strSortBy = 'date';
                break;
        }
    } else {
        // No, so use what was stored in the search result.
        $aSortBy = array('topic', 'forum', 'author', 'postcount', 'viewcount', 'date');
        $strSortBy = $aSortBy[$iSortBy];
        unset($aSortBy);
    }
    // Did they specify a sort order?
    if (isset($_REQUEST['sortorder'])) {
        // Yes, so use it.
        $strSortOrder = strtoupper($_REQUEST['sortorder']);
        if ($strSortOrder != 'ASC' && $strSortOrder != 'DESC') {
            // They don't know what they want. Are they sorting by post date?
            if ($strSortBy == 'date') {
                // Yes, we'll sort descending.
                $strSortOrder = 'DESC';
            } else {
                // No, we'll sort ascending.
                $strSortOrder = 'ASC';
            }
        }
    } else {
        // No, so use the one stored in the search result.
        $strSortOrder = $bSortOrder ? 'DESC' : 'ASC';
    }
    // Get the posts.
    $strPostIDs = implode(', ', $aResults);
    $dbConn->query("SELECT DISTINCT p.id, p.title AS topic, p.icon, p.body, p.author, p.datetime_posted AS date, t.id, t.title, t.icon, t.postcount, t.viewcount, b.id, b.name AS forum, t.closed, t.lpost FROM post AS p LEFT JOIN thread AS t ON (t.id = p.parent) LEFT JOIN board AS b ON (b.id = t.parent) WHERE p.id IN ({$strPostIDs}) AND t.visible=1 ORDER BY {$strSortBy} {$strSortOrder}, t.id {$strSortOrder} LIMIT {$iPostsPerPage} OFFSET {$iOffset}");
    while ($aSQLResult = $dbConn->getresult()) {
        // Store the post information into the master array.
        $iPostID = $aSQLResult[0];
        $aPosts[$iPostID][TITLE] = $aSQLResult[1];
        $aPosts[$iPostID][ICON][URL] = "{$CFG['paths']['posticons']}{$aPostIcons[$aSQLResult[2]]['filename']}";
        $aPosts[$iPostID][ICON][ALT] = $aPostIcons[$aSQLResult[2]]['title'];
        $aPosts[$iPostID][BODY] = substr(RemoveBBCode($aSQLResult[3]), 0, 255);
        $aPosts[$iPostID][AUTHOR] = $aSQLResult[4];
        $aPosts[$iPostID][POSTDATE] = $aSQLResult[5];
        $aPosts[$iPostID][PARENT] = $aSQLResult[6];
        // Store the thread information into the thread array.
        $iThreadID = $aSQLResult[6];
        if (!isset($aThreads[$iThreadID])) {
            $aThreads[$iThreadID][TITLE] = $aSQLResult[7];
            $aThreads[$iThreadID][ICON][URL] = "{$CFG['paths']['posticons']}{$aPostIcons[$aSQLResult[8]]['filename']}";
            $aThreads[$iThreadID][ICON][ALT] = $aPostIcons[$aSQLResult[8]]['title'];
            $aThreads[$iThreadID][PCOUNT] = $aSQLResult[9];
            $aThreads[$iThreadID][VCOUNT] = $aSQLResult[10];
            $aThreads[$iThreadID][PARENT] = $aSQLResult[11];
            $aThreads[$iThreadID][ISOPEN] = !$aSQLResult[13];
            $aThreads[$iThreadID][NEWPOSTS] = !isset($aViewedThreads[$iThreadID]) && $aSQLResult[14] > $_SESSION['lastactive'] || isset($aViewedThreads[$iThreadID]) && $aViewedThreads[$iThreadID] < $aSQLResult[14] ? TRUE : FALSE;
        }
        // Store the forum in the forum list.
        $iForumID = $aSQLResult[11];
        if (!isset($aForums[$iForumID])) {
            $aForums[$iForumID] = $aSQLResult[12];
        }
        // Is there a post title?
        if ($aPosts[$iPostID][TITLE] == '') {
            // No, so let's use the thread's title.
            $aPosts[$iPostID][TITLE] = $aThreads[$iThreadID][TITLE];
        }
        // Add the post author to our list of users to get names for.
        $aUsers[] = $aPosts[$iPostID][AUTHOR];
    }
    // Get the usernames.
    $aUsernames = GetUsernames($aUsers);
    unset($aUsers);
    // Results page template
    require "./skins/{$CFG['skin']}/search/postresults.tpl.php";
    // Send the page.
    exit;
}
Example #4
0
File: index.php Project: OvBB/v1.0
$dbConn->query("SELECT id, invisible FROM citizen WHERE (lastactive >= {$tOnlineTime}) AND (loggedin = 1)");
while (list($iUserID, $bInvisible) = $dbConn->getresult()) {
    // Yes. Are they visible (or do we have permission to view invisible users)?
    if ($bInvisible == 0 || $_SESSION['permissions']['cviewinvisible']) {
        // Yes. Add them to the list of online users.
        $aOnlineIDs[] = $iUserID;
        $aUserIDs[] = $iUserID;
    }
    // Increment the count of online members.
    $iOnlineMembers++;
}
// Get the online guests.
$dbConn->query("SELECT COUNT(*) FROM guest WHERE lastactive >= {$tOnlineTime}");
list($iOnlineGuests) = $dbConn->getresult();
// Get any usernames we need.
$aUsernames = GetUsernames($aUserIDs);
unset($aUserIDs);
// Get the visible online users.
if (isset($aOnlineIDs) && is_array($aOnlineIDs)) {
    foreach ($aOnlineIDs as $iUserID) {
        $aOnline[$iUserID] = $aUsernames[$iUserID];
    }
    asort($aOnline);
    reset($aOnline);
}
// Get most users stats.
$iOnlineUsers = $iOnlineMembers + $iOnlineGuests;
$iMostUsersCount = (int) $aStats['mostuserscount'];
$iMostUsersDate = (int) $aStats['mostusersdate'];
// Do we have a record number of users?
if ($iOnlineUsers > $iMostUsersCount) {