コード例 #1
0
ファイル: functions.php プロジェクト: Cipherwraith/infinity
function buildIndex($global_api = "yes")
{
    global $board, $config, $build_pages;
    if (!$config['smart_build']) {
        $pages = getPages();
        if (!$config['try_smarter']) {
            $antibot = create_antibot($board['uri']);
        }
        if ($config['api']['enabled']) {
            $api = new Api();
            $catalog = array();
        }
    }
    for ($page = 1; $page <= $config['max_pages']; $page++) {
        $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page));
        $jsonFilename = $board['dir'] . ($page - 1) . '.json';
        // pages should start from 0
        if ((!$config['api']['enabled'] || $global_api == "skip" || $config['smart_build']) && $config['try_smarter'] && isset($build_pages) && !empty($build_pages) && !in_array($page, $build_pages)) {
            continue;
        }
        if (!$config['smart_build']) {
            $content = index($page);
            if (!$content) {
                break;
            }
            // json api
            if ($config['api']['enabled']) {
                $threads = $content['threads'];
                $json = json_encode($api->translatePage($threads));
                file_write($jsonFilename, $json);
                $catalog[$page - 1] = $threads;
            }
            if ($config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) && !empty($build_pages) && !in_array($page, $build_pages)) {
                continue;
            }
            if ($config['try_smarter']) {
                $antibot = create_antibot($board['uri'], 0 - $page);
                $content['current_page'] = $page;
            }
            $antibot->reset();
            $content['pages'] = $pages;
            $content['pages'][$page - 1]['selected'] = true;
            $content['btn'] = getPageButtons($content['pages']);
            $content['antibot'] = $antibot;
            file_write($filename, Element('index.html', $content));
        } else {
            file_unlink($filename);
            file_unlink($jsonFilename);
        }
    }
    if (!$config['smart_build'] && $page < $config['max_pages']) {
        for (; $page <= $config['max_pages']; $page++) {
            $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page));
            file_unlink($filename);
            if ($config['api']['enabled']) {
                $jsonFilename = $board['dir'] . ($page - 1) . '.json';
                file_unlink($jsonFilename);
            }
        }
    }
    // json api catalog
    if ($config['api']['enabled'] && $global_api != "skip") {
        if ($config['smart_build']) {
            $jsonFilename = $board['dir'] . 'catalog.json';
            file_unlink($jsonFilename);
            $jsonFilename = $board['dir'] . 'threads.json';
            file_unlink($jsonFilename);
        } else {
            $json = json_encode($api->translateCatalog($catalog));
            $jsonFilename = $board['dir'] . 'catalog.json';
            file_write($jsonFilename, $json);
            $json = json_encode($api->translateCatalog($catalog, true));
            $jsonFilename = $board['dir'] . 'threads.json';
            file_write($jsonFilename, $json);
        }
    }
    if ($config['try_smarter']) {
        $build_pages = array();
    }
}
コード例 #2
0
ファイル: pages.php プロジェクト: vicentil/vichan
function mod_view_board($boardName, $page_no = 1)
{
    global $config, $mod;
    if (!openBoard($boardName)) {
        error($config['error']['noboard']);
    }
    if (!($page = index($page_no, $mod))) {
        error($config['error']['404']);
    }
    $page['pages'] = getPages(true);
    $page['pages'][$page_no - 1]['selected'] = true;
    $page['btn'] = getPageButtons($page['pages'], true);
    $page['mod'] = true;
    $page['config'] = $config;
    echo Element('index.html', $page);
}
コード例 #3
0
ファイル: mod.php プロジェクト: niksfish/Tinyboard
         echo Element('page.html', array('config' => $config, 'title' => 'New board', 'body' => $body, 'mod' => true));
     }
 } elseif (preg_match('/^\\/' . $regex['board'] . '(' . $regex['index'] . '|' . $regex['page'] . ')?$/', $query, $matches)) {
     // Board index
     $boardName =& $matches[1];
     // Open board
     if (!openBoard($boardName)) {
         error($config['error']['noboard']);
     }
     $page_no = empty($matches[2]) || $matches[2] == $config['file_index'] ? 1 : $matches[2];
     if (!($page = index($page_no, $mod))) {
         error($config['error']['404']);
     }
     $page['pages'] = getPages(true);
     $page['pages'][$page_no - 1]['selected'] = true;
     $page['btn'] = getPageButtons($page['pages'], true);
     $page['mod'] = true;
     echo Element('index.html', $page);
 } elseif (preg_match('/^\\/' . $regex['board'] . $regex['res'] . $regex['page'] . '$/', $query, $matches)) {
     // View thread
     $boardName =& $matches[1];
     $thread =& $matches[2];
     // Open board
     if (!openBoard($boardName)) {
         error($config['error']['noboard']);
     }
     $page = buildThread($thread, true, $mod);
     echo $page;
 } elseif (preg_match('/^\\/' . $regex['board'] . 'edit\\/(\\d+)$/', $query, $matches)) {
     // Edit post body
     $boardName =& $matches[1];
コード例 #4
0
ファイル: functions.php プロジェクト: npfriday/Tinyboard
function buildIndex()
{
    global $board, $config;
    $pages = getPages();
    $antibot = create_antibot($board['uri']);
    $page = 1;
    while ($page <= $config['max_pages'] && ($content = index($page))) {
        $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page));
        if (file_exists($filename)) {
            $md5 = md5_file($filename);
        }
        $content['pages'] = $pages;
        $content['pages'][$page - 1]['selected'] = true;
        $content['btn'] = getPageButtons($content['pages']);
        $content['antibot'] = $antibot;
        file_write($filename, Element('index.html', $content));
        if (isset($md5) && $md5 == md5_file($filename)) {
            break;
        }
        $page++;
    }
    if ($page < $config['max_pages']) {
        for (; $page <= $config['max_pages']; $page++) {
            $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page));
            file_unlink($filename);
        }
    }
}