当前位置: 首页>>代码示例>>PHP>>正文


PHP listBoards函数代码示例

本文整理汇总了PHP中listBoards函数的典型用法代码示例。如果您正苦于以下问题:PHP listBoards函数的具体用法?PHP listBoards怎么用?PHP listBoards使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了listBoards函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: catalog_build

function catalog_build($action, $settings, $board)
{
    global $config;
    // Possible values for $action:
    //	- all (rebuild everything, initialization)
    //	- news (news has been updated)
    //	- boards (board list changed)
    //	- post (a reply has been made)
    //	- post-thread (a thread has been made)
    if ($settings['all']) {
        $boards = listBoards(TRUE);
    } else {
        $boards = explode(' ', $settings['boards']);
    }
    if ($action == 'all') {
        foreach ($boards as $board) {
            $b = new Catalog();
            if ($config['smart_build']) {
                file_unlink($config['dir']['home'] . $board . '/catalog.html');
            } else {
                $b->build($settings, $board);
            }
            if (php_sapi_name() === "cli") {
                echo "Rebuilding {$board} catalog...\n";
            }
        }
    } elseif ($action == 'post-thread' || $settings['update_on_posts'] && $action == 'post' || $settings['update_on_posts'] && $action == 'post-delete' && in_array($board, $boards) | $settings['all']) {
        $b = new Catalog();
        if ($config['smart_build']) {
            file_unlink($config['dir']['home'] . $board . '/catalog.html');
        } else {
            $b->build($settings, $board);
        }
    }
}
开发者ID:odilitime,项目名称:infinity,代码行数:35,代码来源:theme.php

示例2: buildUkko

 /**
  * Build and save the HTML of the catalog for the Ukko theme
  */
 public function buildUkko()
 {
     global $config;
     $ukkoSettings = themeSettings('ukko');
     $queries = array();
     $threads = array();
     $exclusions = explode(' ', $ukkoSettings['exclude']);
     $boards = array_diff(listBoards(true), $exclusions);
     foreach ($boards as $b) {
         if (array_key_exists($b, $this->threadsCache)) {
             $threads = array_merge($threads, $this->threadsCache[$b]);
         } else {
             $queries[] = $this->buildThreadsQuery($b);
         }
     }
     // Fetch threads from boards that haven't beenp processed yet
     if (!empty($queries)) {
         $sql = implode(' UNION ALL ', $queries);
         $res = query($sql) or error(db_error());
         $threads = array_merge($threads, $res->fetchAll(PDO::FETCH_ASSOC));
     }
     // Sort in bump order
     usort($threads, function ($a, $b) {
         return strcmp($b['bump'], $a['bump']);
     });
     // Generate data for the template
     $recent_posts = $this->generateRecentPosts($threads);
     $this->saveForBoard($ukkoSettings['uri'], $recent_posts, $config['root'] . $ukkoSettings['uri']);
 }
开发者ID:anastiel,项目名称:lainchan,代码行数:32,代码来源:theme.php

示例3: fetchThreads

 /**
  * Obtain list of all threads from all non-excluded boards
  */
 private function fetchThreads()
 {
     $query = '';
     $boards = listBoards(true);
     foreach ($boards as $b) {
         if (in_array($b, $this->settings['exclude'])) {
             continue;
         }
         // Threads are those posts that have no parent thread
         $query .= "SELECT *, '{$b}' AS `board` FROM ``posts_{$b}`` " . "WHERE `thread` IS NULL UNION ALL ";
     }
     $query = preg_replace('/UNION ALL $/', 'ORDER BY `bump` DESC', $query);
     $result = query($query) or error(db_error());
     return $result->fetchAll(PDO::FETCH_ASSOC);
 }
开发者ID:anastiel,项目名称:lainchan,代码行数:18,代码来源:theme.php

示例4: news

 public static function news($settings)
 {
     global $config, $board;
     // HTML5
     $body = '<!DOCTYPE html><html>' . '<head>' . '<meta charset="utf-8">' . '<link rel="stylesheet" href="frontpage.css" />' . '<link rel="stylesheet" media="screen" id="stylesheet" href="/stylesheets/style.css">' . '<script type="text/javascript" src="/styleswitch-sidebar.js"></script>' . '<title>' . $settings['title'] . ' - News</title>' . '</head><body>';
     $boardlist = createBoardlist();
     $body .= $boardlist['top'] . '<br />';
     $boards = listBoards();
     $body .= '<div id="maintable"><div id="logo"></div><div id="announcement">Don\'t touch the lights!</div><table style="margin-bottom: 4px; width: 100%;"><tr>';
     // Recent Posts
     $body .= '<td style="width: 100%;"><div class="post_wrap"><div class="post_header"><b>Recent Posts</b></div><div class="post_body"><div class="post_content" style="padding-bottom: 10px;">';
     $query = '';
     foreach ($boards as &$_board) {
         // Block Board
         if ($_board['uri'] != "aurora") {
             $query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` UNION ALL ", $_board['uri'], $_board['uri']);
         }
     }
     $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT 15', $query);
     $query = query($query) or error(db_error());
     while ($post = $query->fetch()) {
         openBoard($post['board']);
         $body .= '<strong>' . $board['name'] . '</strong>: <a href="' . $config['root'] . $board['dir'] . $config['dir']['res'] . ($post['thread'] ? $post['thread'] : $post['id']) . '.html#' . $post['id'] . '">';
         $snip = pm_snippet($post['body'], 95);
         if ($snip === "<em></em>") {
             $body .= '&lt;empty&gt;';
         } else {
             $body .= $snip;
         }
         $body .= '</a><br />';
     }
     // News
     $body .= '</div></div></div></td></tr></table>';
     $query = query("SELECT * FROM `news` ORDER BY `time` DESC LIMIT 5") or error(db_error());
     if ($query->rowCount() == 0) {
         $body .= '<p style="text-align:center" class="unimportant">(No news to show.)</p>';
     } else {
         // List news
         while ($news = $query->fetch()) {
             $body .= '<div class="post_wrap"><div class="post_header">' . (time() - $news['time'] <= 432000 ? '<em><b><span style="color: #D03030;">*NEW*</span></b></em> ' : '') . ($news['subject'] ? $news['subject'] : '<em>no subject</em>') . ' &mdash; by ' . $news['name'] . ' at ' . strftime($config['post_date'], $news['time']) . '</div><div class="post_body"><div class="post_content">' . $news['body'] . '</div></div></div>';
         }
     }
     // Finish page
     $body .= '<br />';
     $body .= '</div></body></html>';
     return $body;
 }
开发者ID:anastiel,项目名称:lainchan,代码行数:47,代码来源:theme.php

示例5: createBoardlist

function createBoardlist($mod = false)
{
    global $config;
    if (!isset($config['boards'])) {
        return array('top' => '', 'bottom' => '');
    }
    $xboards = listBoards();
    $boards = array();
    foreach ($xboards as $val) {
        $boards[$val['uri']] = $val['title'];
    }
    $body = doBoardListPart($config['boards'], $mod ? '?/' : $config['root'], $boards);
    if ($config['boardlist_wrap_bracket'] && !preg_match('/\\] $/', $body)) {
        $body = '[' . $body . ']';
    }
    $body = trim($body);
    // Message compact-boardlist.js faster, so that page looks less ugly during loading
    $top = "<script type='text/javascript'>if (typeof do_boardlist != 'undefined') do_boardlist();</script>";
    return array('top' => '<div class="boardlist">' . $body . '</div>' . $top, 'bottom' => '<div class="boardlist bottom">' . $body . '</div>');
}
开发者ID:2Rainbow,项目名称:fukuro,代码行数:20,代码来源:display.php

示例6: die

<?php

require 'inc/functions.php';
if (!$config['search']['enable']) {
    die(_("Post search is disabled"));
}
$queries_per_minutes = $config['search']['queries_per_minutes'];
$queries_per_minutes_all = $config['search']['queries_per_minutes_all'];
$search_limit = $config['search']['search_limit'];
if (isset($config['search']['boards'])) {
    $boards = $config['search']['boards'];
} else {
    $boards = listBoards(TRUE);
}
$body = Element('search_form.html', array('boards' => $boards, 'b' => isset($_GET['board']) ? $_GET['board'] : false, 'search' => isset($_GET['search']) ? str_replace('"', '&quot;', utf8tohtml($_GET['search'])) : false));
if (isset($_GET['search']) && !empty($_GET['search']) && isset($_GET['board']) && in_array($_GET['board'], $boards)) {
    $phrase = $_GET['search'];
    $_body = '';
    $query = prepare("SELECT COUNT(*) FROM ``search_queries`` WHERE `ip` = :ip AND `time` > :time");
    $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
    $query->bindValue(':time', time() - $queries_per_minutes[1] * 60);
    $query->execute() or error(db_error($query));
    if ($query->fetchColumn() > $queries_per_minutes[0]) {
        error(_('Wait a while before searching again, please.'));
    }
    $query = prepare("SELECT COUNT(*) FROM ``search_queries`` WHERE `time` > :time");
    $query->bindValue(':time', time() - $queries_per_minutes_all[1] * 60);
    $query->execute() or error(db_error($query));
    if ($query->fetchColumn() > $queries_per_minutes_all[0]) {
        error(_('Wait a while before searching again, please.'));
    }
开发者ID:0151n,项目名称:vichan,代码行数:31,代码来源:search.php

示例7: homepage

 public function homepage($settings)
 {
     global $config, $board;
     $recent_images = array();
     $recent_posts = array();
     $stats = array();
     $boards = listBoards();
     $query = '';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `files` IS NOT NULL UNION ALL ", $_board['uri'], $_board['uri']);
     }
     $query = '';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` UNION ALL ", $_board['uri'], $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int) $settings['limit_posts'], $query);
     $query = query($query) or error(db_error());
     while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
         openBoard($post['board']);
         $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post) . '#' . $post['id'];
         if ($post['body'] != "") {
             $post['snippet'] = pm_snippet($post['body'], 128);
         } else {
             $post['snippet'] = "<em>" . _("(no comment)") . "</em>";
         }
         $post['board_name'] = $board['name'];
         $recent_posts[] = $post;
     }
     // Total posts
     $query = 'SELECT SUM(`top`) FROM (';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT MAX(`id`) AS `top` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
     $query = query($query) or error(db_error());
     $stats['total_posts'] = number_format($query->fetchColumn());
     // Unique IPs
     $query = 'SELECT COUNT(DISTINCT(`ip`)) FROM (';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT `ip` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
     $query = query($query) or error(db_error());
     $stats['unique_posters'] = number_format($query->fetchColumn());
     // Active content
     $query = 'SELECT DISTINCT(`files`) FROM (';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT `files` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', ' WHERE `num_files` > 0) AS `posts_all`', $query);
     $query = query($query) or error(db_error());
     $files = $query->fetchAll();
     $stats['active_content'] = 0;
     foreach ($files as &$file) {
         preg_match_all('/"size":([0-9]*)/', $file[0], $matches);
         $stats['active_content'] += array_sum($matches[1]);
     }
     return Element('themes/recent_textonly/recent_textonly.html', array('settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist(), 'recent_posts' => $recent_posts, 'stats' => $stats));
 }
开发者ID:remiscarlet,项目名称:kcad,代码行数:74,代码来源:theme.php

示例8: homepage

 public function homepage($settings)
 {
     global $config, $board;
     $recent_images = array();
     $recent_posts = array();
     $stats = array();
     $boards = listBoards();
     $query = '';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` WHERE `file` IS NOT NULL AND `file` != 'deleted' AND `thumb` != 'spoiler' UNION ALL ", $_board['uri'], $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int) $settings['limit_images'], $query);
     $query = query($query) or error(db_error());
     while ($post = $query->fetch()) {
         openBoard($post['board']);
         // board settings won't be available in the template file, so generate links now
         $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $post['id']) . '#' . $post['id'];
         $post['src'] = $config['uri_thumb'] . $post['thumb'];
         $recent_images[] = $post;
     }
     $query = '';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` UNION ALL ", $_board['uri'], $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int) $settings['limit_posts'], $query);
     $query = query($query) or error(db_error());
     while ($post = $query->fetch()) {
         openBoard($post['board']);
         $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $post['id']) . '#' . $post['id'];
         $post['snippet'] = pm_snippet($post['body'], 30);
         $post['board_name'] = $board['name'];
         $recent_posts[] = $post;
     }
     // Total posts
     $query = 'SELECT SUM(`top`) AS `count` FROM (';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT MAX(`id`) AS `top` FROM `posts_%s` UNION ALL ", $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
     $query = query($query) or error(db_error());
     $res = $query->fetch();
     $stats['total_posts'] = number_format($res['count']);
     // Unique IPs
     $query = 'SELECT COUNT(DISTINCT(`ip`)) AS `count` FROM (';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT `ip` FROM `posts_%s` UNION ALL ", $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
     $query = query($query) or error(db_error());
     $res = $query->fetch();
     $stats['unique_posters'] = number_format($res['count']);
     // Active content
     $query = 'SELECT SUM(`filesize`) AS `count` FROM (';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT `filesize` FROM `posts_%s` UNION ALL ", $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
     $query = query($query) or error(db_error());
     $res = $query->fetch();
     $stats['active_content'] = $res['count'];
     return Element('themes/recent/recent.html', array('settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist(), 'recent_images' => $recent_images, 'recent_posts' => $recent_posts, 'stats' => $stats));
 }
开发者ID:npfriday,项目名称:Tinyboard,代码行数:77,代码来源:theme.php

示例9: mod_debug_recent_posts

function mod_debug_recent_posts()
{
    global $pdo, $config;
    $limit = 500;
    $boards = listBoards();
    // Manually build an SQL query
    $query = 'SELECT * FROM (';
    foreach ($boards as $board) {
        $query .= sprintf('SELECT *, %s AS `board` FROM ``posts_%s`` UNION ALL ', $pdo->quote($board['uri']), $board['uri']);
    }
    // Remove the last "UNION ALL" seperator and complete the query
    $query = preg_replace('/UNION ALL $/', ') AS `all_posts` ORDER BY `time` DESC LIMIT ' . $limit, $query);
    $query = query($query) or error(db_error());
    $posts = $query->fetchAll(PDO::FETCH_ASSOC);
    // Fetch recent posts from flood prevention cache
    $query = query("SELECT * FROM ``flood`` ORDER BY `time` DESC") or error(db_error());
    $flood_posts = $query->fetchAll(PDO::FETCH_ASSOC);
    foreach ($posts as &$post) {
        $post['snippet'] = pm_snippet($post['body']);
        foreach ($flood_posts as $flood_post) {
            if ($flood_post['time'] == $post['time'] && $flood_post['posthash'] == make_comment_hex($post['body_nomarkup']) && $flood_post['filehash'] == $post['filehash']) {
                $post['in_flood_table'] = true;
            }
        }
    }
    mod_page(_('Debug: Recent posts'), 'mod/debug/recent_posts.html', array('posts' => $posts, 'flood_posts' => $flood_posts));
}
开发者ID:vicentil,项目名称:vichan,代码行数:27,代码来源:pages.php

示例10: array

<?php

$theme = array();
// Theme name
$theme['name'] = 'Catalog';
// Description (you can use Tinyboard markup here)
$theme['description'] = 'Show a post catalog.';
$theme['version'] = 'v0.2.1';
// Theme configuration
$theme['config'] = array();
$theme['config'][] = array('title' => 'Title', 'name' => 'title', 'type' => 'text', 'default' => 'Catalog');
$__boards = listBoards();
$__default_boards = array();
foreach ($__boards as $__board) {
    $__default_boards[] = $__board['uri'];
}
$theme['config'][] = array('title' => 'Included boards', 'name' => 'boards', 'type' => 'text', 'comment' => '(space seperated)', 'default' => implode(' ', $__default_boards));
$theme['config'][] = array('title' => 'Update on new posts', 'name' => 'update_on_posts', 'type' => 'checkbox', 'default' => false, 'comment' => 'Without this checked, the catalog only updates on new threads.');
$theme['config'][] = array('title' => 'Enable Ukko catalog', 'name' => 'enable_ukko', 'type' => 'checkbox', 'default' => false, 'comment' => 'Enable catalog for the Ukko theme. This requires the Ukko theme to be enabled.');
$theme['config'][] = array('title' => 'Use tooltipster', 'name' => 'use_tooltipster', 'type' => 'checkbox', 'default' => true, 'comment' => 'Check this if you wish to show a nice tooltip with info about the thread on mouse over.');
// Unique function name for building everything
$theme['build_function'] = 'catalog_build';
开发者ID:anastiel,项目名称:lainchan,代码行数:22,代码来源:info.php

示例11: form_newBan

function form_newBan($ip = null, $reason = '', $continue = false, $delete = false, $board = false, $allow_public = false)
{
    global $config, $mod;
    $boards = listBoards();
    $__boards = '<li><input type="radio" checked="checked" name="board" id="board_*" value=""/> <label style="display:inline" for="board_*"><em>' . _('all boards') . '</em></label></li>';
    foreach ($boards as &$_board) {
        $__boards .= '<li>' . '<input type="radio" name="board" id="board_' . $_board['uri'] . '" value="' . $_board['uri'] . '">' . '<label style="display:inline" for="board_' . $_board['uri'] . '"> ' . ($_board['uri'] == '*' ? '<em>"*"</em>' : sprintf($config['board_abbreviation'], $_board['uri'])) . ' - ' . $_board['title'] . '</label>' . '</li>';
    }
    return '<fieldset><legend>New ban</legend>' . '<form action="?/ban" method="post">' . ($continue ? '<input type="hidden" name="continue" value="' . htmlentities($continue) . '" />' : '') . ($delete || $allow_public ? '<input type="hidden" name="' . (!$allow_public ? 'delete' : 'post') . '" value="' . htmlentities($delete) . '" />' : '') . ($board ? '<input type="hidden" name="board" value="' . htmlentities($board) . '" />' : '') . '<table>' . '<tr>' . '<th><label for="ip">IP ' . ($config['ban_cidr'] ? '<span class="unimportant">(or subnet)' : '') . '</span></label></th>' . '<td><input type="text" name="ip" id="ip" size="30" maxlength="30" ' . (isset($ip) ? 'value="' . htmlentities($ip) . '" ' : '') . '/></td>' . '</tr>' . '<tr>' . '<th><label for="reason">Reason</label></th>' . '<td><textarea name="reason" id="reason" rows="5" cols="30">' . htmlentities($reason) . '</textarea></td>' . '</tr>' . ($mod['type'] >= $config['mod']['public_ban'] && $allow_public ? '<tr>' . '<th><label for="message">Message</label></th>' . '<td><input type="checkbox" id="public_message" name="public_message"/>' . ' <input type="text" name="message" id="message" size="35" maxlength="200" value="' . htmlentities($config['mod']['default_ban_message']) . '" />' . ' <span class="unimportant">(public; attached to post)</span></td>' . '<script type="text/javascript">' . 'document.getElementById(\'message\').disabled = true;' . 'document.getElementById(\'public_message\').onchange = function() {' . 'document.getElementById(\'message\').disabled = !this.checked;' . '}' . '</script>' . '</tr>' : '') . '<tr>' . '<th><label for="length">Length</label></th>' . '<td><input type="text" name="length" id="length" size="20" maxlength="40" />' . ' <span class="unimportant">(eg. "2d1h30m" or "2 days")</span></td>' . '</tr>' . '<tr>' . '<th>Board</th>' . '<td><ul style="list-style:none;padding:2px 5px">' . $__boards . '</tl></td>' . '</tr>' . '<tr>' . '<td></td>' . '<td><input name="new_ban" type="submit" value="New Ban" /></td>' . '</tr>' . '</table>' . '</form>' . '</fieldset>';
}
开发者ID:niksfish,项目名称:Tinyboard,代码行数:10,代码来源:mod.php

示例12: build

 public function build($mod = false)
 {
     global $config, $board;
     $boards = listBoards();
     $body = '';
     $overflow = array();
     $board = array('url' => $this->settings['uri'], 'name' => $this->settings['title'], 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit']));
     $query = '';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], explode(' ', $this->settings['exclude']))) {
             continue;
         }
         $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL UNION ALL ", $_board['uri'], $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', 'ORDER BY `bump` DESC', $query);
     $query = query($query) or error(db_error());
     $count = 0;
     $threads = array();
     while ($post = $query->fetch()) {
         if (!isset($threads[$post['board']])) {
             $threads[$post['board']] = 1;
         } else {
             $threads[$post['board']] += 1;
         }
         if ($count < $this->settings['thread_limit']) {
             $config['uri_thumb'] = '/' . $post['board'] . '/thumb/';
             $config['uri_img'] = '/' . $post['board'] . '/src/';
             $board['dir'] = $post['board'] . '/';
             $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod);
             $posts = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE `thread` = :id ORDER BY `id` DESC LIMIT :limit", $post['board']));
             $posts->bindValue(':id', $post['id']);
             $posts->bindValue(':limit', $post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'], PDO::PARAM_INT);
             $posts->execute() or error(db_error($posts));
             $num_images = 0;
             while ($po = $posts->fetch()) {
                 $config['uri_thumb'] = '/' . $post['board'] . '/thumb/';
                 $config['uri_img'] = '/' . $post['board'] . '/src/';
                 if ($po['files']) {
                     $num_images++;
                 }
                 $thread->add(new Post($po, $mod ? '?/' : $config['root'], $mod));
             }
             if ($posts->rowCount() == ($post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) {
                 $ct = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM ``posts_%s`` WHERE `thread` = :thread UNION ALL SELECT COUNT(`id`) FROM ``posts_%s`` WHERE `files` IS NOT NULL AND `thread` = :thread", $post['board'], $post['board']));
                 $ct->bindValue(':thread', $post['id'], PDO::PARAM_INT);
                 $ct->execute() or error(db_error($count));
                 $c = $ct->fetch();
                 $thread->omitted = $c['num'] - ($post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']);
                 $c = $ct->fetch();
                 $thread->omitted_images = $c['num'] - $num_images;
             }
             $thread->posts = array_reverse($thread->posts);
             $body .= '<h2><a href="' . $config['root'] . $post['board'] . '">/' . $post['board'] . '/</a></h2>';
             $body .= $thread->build(true);
         } else {
             $page = 'index';
             if (floor($threads[$post['board']] / $config['threads_per_page']) > 0) {
                 $page = floor($threads[$post['board']] / $config['threads_per_page']) + 1;
             }
             $overflow[] = array('id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html');
         }
         $count += 1;
     }
     $body .= '<script> var overflow = ' . json_encode($overflow) . '</script>';
     $body .= '<script type="text/javascript" src="/' . $this->settings['uri'] . '/ukko.js"></script>';
     $config['default_stylesheet'] = array('Yotsuba B', $config['stylesheets']['Yotsuba B']);
     return Element('index.html', array('config' => $config, 'board' => $board, 'no_post_form' => true, 'body' => $body, 'mod' => $mod, 'boardlist' => createBoardlist($mod)));
 }
开发者ID:odilitime,项目名称:infinity,代码行数:68,代码来源:theme.php

示例13: homepage

 public function homepage($settings)
 {
     global $config, $board;
     $recent_images = array();
     $recent_posts = array();
     $stats = array();
     $boards = listBoards();
     $query = '';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `files` IS NOT NULL UNION ALL ", $_board['uri'], $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int) $settings['limit_images'], $query);
     if ($query == '') {
         error(_("Can't build the RecentPosts theme, because there are no boards to be fetched."));
     }
     $query = query($query) or error(db_error());
     while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
         openBoard($post['board']);
         if (isset($post['files'])) {
             $files = json_decode($post['files']);
         }
         if ($files[0]->file == 'deleted') {
             continue;
         }
         // board settings won't be available in the template file, so generate links now
         $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post) . '#' . $post['id'];
         if ($files) {
             if ($files[0]->thumb == 'spoiler') {
                 $tn_size = @getimagesize($config['spoiler_image']);
                 $post['src'] = $config['spoiler_image'];
                 $post['thumbwidth'] = $tn_size[0];
                 $post['thumbheight'] = $tn_size[1];
             } else {
                 $post['src'] = $config['uri_thumb'] . $files[0]->thumb;
             }
         }
         $recent_images[] = $post;
     }
     $query = '';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` UNION ALL ", $_board['uri'], $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int) $settings['limit_posts'], $query);
     $query = query($query) or error(db_error());
     while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
         openBoard($post['board']);
         $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post) . '#' . $post['id'];
         if ($post['body'] != "") {
             $post['snippet'] = pm_snippet($post['body'], 30);
         } else {
             $post['snippet'] = "<em>" . _("(no comment)") . "</em>";
         }
         $post['board_name'] = $board['name'];
         $recent_posts[] = $post;
     }
     // Total posts
     $query = 'SELECT SUM(`top`) FROM (';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT MAX(`id`) AS `top` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
     $query = query($query) or error(db_error());
     $stats['total_posts'] = number_format($query->fetchColumn());
     // Unique IPs
     $query = 'SELECT COUNT(DISTINCT(`ip`)) FROM (';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT `ip` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
     $query = query($query) or error(db_error());
     $stats['unique_posters'] = number_format($query->fetchColumn());
     // Active content
     $query = 'SELECT DISTINCT(`files`) FROM (';
     foreach ($boards as &$_board) {
         if (in_array($_board['uri'], $this->excluded)) {
             continue;
         }
         $query .= sprintf("SELECT `files` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
     }
     $query = preg_replace('/UNION ALL $/', ' WHERE `num_files` > 0) AS `posts_all`', $query);
     $query = query($query) or error(db_error());
     $files = $query->fetchAll();
     $stats['active_content'] = 0;
     foreach ($files as &$file) {
         preg_match_all('/"size":([0-9]*)/', $file[0], $matches);
         $stats['active_content'] += array_sum($matches[1]);
     }
     return Element('themes/recent/recent.html', array('settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist(), 'recent_images' => $recent_images, 'recent_posts' => $recent_posts, 'stats' => $stats));
//.........这里部分代码省略.........
开发者ID:0151n,项目名称:vichan,代码行数:101,代码来源:theme.php

示例14: mod_rebuild

function mod_rebuild()
{
    global $config, $twig;
    if (!hasPermission($config['mod']['rebuild'])) {
        error($config['error']['noaccess']);
    }
    if (isset($_POST['rebuild'])) {
        $log = array();
        $boards = listBoards();
        $rebuilt_scripts = array();
        if (isset($_POST['rebuild_cache'])) {
            if ($config['cache']['enabled']) {
                $log[] = 'Flushing cache';
                Cache::flush();
            }
            $log[] = 'Clearing template cache';
            load_twig();
            $twig->clearCacheFiles();
        }
        if (isset($_POST['rebuild_themes'])) {
            $log[] = 'Regenerating theme files';
            rebuildThemes('all');
        }
        if (isset($_POST['rebuild_javascript'])) {
            $log[] = 'Rebuilding <strong>' . $config['file_script'] . '</strong>';
            buildJavascript();
            $rebuilt_scripts[] = $config['file_script'];
        }
        foreach ($boards as $board) {
            if (!(isset($_POST['boards_all']) || isset($_POST['board_' . $board['uri']]))) {
                continue;
            }
            openBoard($board['uri']);
            if (isset($_POST['rebuild_index'])) {
                buildIndex();
                $log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Creating index pages';
            }
            if (isset($_POST['rebuild_javascript']) && !in_array($config['file_script'], $rebuilt_scripts)) {
                $log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding <strong>' . $config['file_script'] . '</strong>';
                buildJavascript();
                $rebuilt_scripts[] = $config['file_script'];
            }
            if (isset($_POST['rebuild_thread'])) {
                $query = query(sprintf("SELECT `id` FROM `posts_%s` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
                while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
                    $log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding thread #' . $post['id'];
                    buildThread($post['id']);
                }
            }
        }
        mod_page(_('Rebuild'), 'mod/rebuilt.html', array('logs' => $log));
        return;
    }
    mod_page(_('Rebuild'), 'mod/rebuild.html', array('boards' => listBoards()));
}
开发者ID:npfriday,项目名称:Tinyboard,代码行数:55,代码来源:pages.php

示例15: sidebar

 public static function sidebar($settings)
 {
     global $config, $board;
     return Element('themes/frameset/sidebar.html', array('settings' => $settings, 'config' => $config, 'boards' => listBoards()));
 }
开发者ID:nabm,项目名称:Tinyboard,代码行数:5,代码来源:theme.php


注:本文中的listBoards函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。