Example #1
0
/**
 * Check the password given on a certain forum for validity
 *
 * @param int The forum ID
 * @param boolean The Parent ID
 */
function check_forum_password_archive($fid, $pid = 0)
{
    global $forum_cache;
    if (!is_array($forum_cache)) {
        $forum_cache = cache_forums();
        if (!$forum_cache) {
            return false;
        }
    }
    // Loop through each of parent forums to ensure we have a password for them too
    $parents = explode(',', $forum_cache[$fid]['parentlist']);
    rsort($parents);
    if (!empty($parents)) {
        foreach ($parents as $parent_id) {
            if ($parent_id == $fid || $parent_id == $pid) {
                continue;
            }
            if ($forum_cache[$parent_id]['password'] != "") {
                check_forum_password_archive($parent_id, $fid);
            }
        }
    }
    $password = $forum_cache[$fid]['password'];
    if ($password) {
        if (!$mybb->cookies['forumpass'][$fid] || $mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'] . $password) != $mybb->cookies['forumpass'][$fid]) {
            archive_error_no_permission();
        }
    }
}
Example #2
0
         $plugins->run_hooks("archive_thread_post");
         // Finally show the post
         echo "<div class=\"post\">\n<div class=\"header\">\n<div class=\"author\"><h2>{$post['username']}</h2></div>";
         echo "<div class=\"dateline\">{$post['date']}</div>\n</div>\n<div class=\"message\">{$post['message']}</div>\n</div>\n";
     }
     archive_multipage($postcount, $perpage, $page, "{$base_url}thread-{$id}");
     $plugins->run_hooks("archive_thread_end");
     archive_footer();
     break;
     // Display a category or a forum.
 // Display a category or a forum.
 case "forum":
     // Check if we have permission to view this forum
     $forumpermissions = forum_permissions($forum['fid']);
     if ($forumpermissions['canview'] != 1) {
         archive_error_no_permission();
     }
     check_forum_password_archive($forum['fid']);
     $useronly = "";
     if ($forumpermissions['canonlyviewownthreads'] == 1) {
         $useronly = "AND uid={$mybb->user['uid']}";
     }
     // Paginate this forum
     $query = $db->simple_select("threads", "COUNT(tid) AS threads", "fid='{$id}' AND visible='1' {$useronly}");
     $threadcount = $db->fetch_field($query, "threads");
     // Build the navigation
     build_forum_breadcrumb($forum['fid'], 1);
     // No threads and not a category? Error!
     if (($threadcount < 1 || $forumpermissions['canviewthreads'] != 1) && $forum['type'] != 'c') {
         archive_header(strip_tags($forum['name']), $forum['name'], $mybb->settings['bburl'] . "/" . get_forum_link($id, $page) . "");
         archive_error($lang->error_nothreads);