Exemplo n.º 1
0
 /**
  * function getInstance get a Article object via $board & $id
  * suggest using this method to get a ref of article
  * it will check the board mode to decide use which method to get article
  * if board is in non-sort mode ,article is got by its position
  *
  * @param int $id
  * @param Board $board
  * @return Article object
  * @static
  * @access public
  * @throws ArticleNullException
  */
 public static function getInstance($id, $board)
 {
     if ($board->isSortMode()) {
         $info = array();
         $num = bbs_get_records_from_id($board->NAME, $id, 0, $info);
         if ($num == 0) {
             $num = bbs_get_records_from_id($board->NAME, $id, 11, $info);
             if ($num == 0) {
                 throw new ArticleNullException();
             }
         }
         $info = $info[1];
     } else {
         $info = bbs_getarticles($board->NAME, $id, 1, $board->getMode());
         if (!is_array($info)) {
             throw new ArticleNullException();
         }
         $info = $info[0];
     }
     return new Article($info, $board, $id);
 }
Exemplo n.º 2
0
    $page = $pagecount;
}
if ($page == 0) {
    $page = $pagecount;
}
$start = ($page - 1) * PAGE_SIZE + 1;
$count = PAGE_SIZE;
if ($page == $pagecount) {
    cache_header("nocache");
} else {
    $origin_if = bbs_get_board_index($bname, $dir_modes["ORIGIN"]);
    if (cache_header("public", @filemtime($origin_if), 10)) {
        exit;
    }
}
$articles = bbs_getarticles($bname, $start, $count, $dir_modes["ORIGIN"]);
if ($articles == FALSE) {
    ie("cannot read index.");
}
$response->pagecount = $pagecount;
$arr = array();
$i = 0;
foreach ($articles as $article) {
    $response->topic[$i]->id = $article["ID"];
    $response->topic[$i]->title = int_string(htmlspecialchars($article["TITLE"]));
    $response->topic[$i]->author = $article["OWNER"];
    $response->topic[$i]->reply = $article["REPLYCOUNT"];
    $response->topic[$i]->last_reply_time = $article["LAST_POSTTIME"];
    $response->topic[$i]->last_reply_author = $article["LAST_OWNER"];
    $filename = bbs_get_board_filename($bname, $article["FILENAME"]);
    $ret = bbs_parse_article($filename, $arr, 1);
Exemplo n.º 3
0
Arquivo: rss.php Projeto: bianle/www2
$channel["link"] = SiteURL . "frames.html?mainurl=" . urlencode("bbsdoc.php?board=" . $board);
/* TODO: ftype? */
$channel["language"] = "zh-cn";
$channel["generator"] = "KBS RSS Generator";
$channel["lastBuildDate"] = gmt_date_format($modifytime);
$total = bbs_countarticles($brdnum, $ftype);
$items = array();
if ($total > 0) {
    $artcnt = ARTICLE_PER_RSS;
    if ($total <= $artcnt) {
        $start = 1;
        $artcnt = $total;
    } else {
        $start = $total - $artcnt + 1;
    }
    $articles = bbs_getarticles($board, $start, $artcnt, $ftype) or die;
    $cc = count($articles);
    for ($i = $cc - 1; $i >= 0; $i--) {
        $origin = $articles[$i];
        $item = array();
        $item["title"] = htmlspecialchars($origin['TITLE'], ENT_QUOTES) . " ";
        $conurl = "bbscon.php?bid=" . $brdnum . "&amp;id=" . $origin['ID'];
        //you want the link to always work, so you don't want to add num
        //if ($ftype == $dir_modes["DIGEST"]) $conurl .= "&amp;ftype=".$ftype."&amp;num=".($start+$i);
        $item["link"] = SiteURL . $conurl;
        $item["author"] = $origin['OWNER'];
        $item["pubDate"] = gmt_date_format($origin['POSTTIME']);
        $item["guid"] = $item["link"];
        //TODO
        //$item["comments"] = ?? //TODO
        $filename = bbs_get_board_filename($board, $origin["FILENAME"]);
Exemplo n.º 4
0
if (cache_header("public", @filemtime($dotdirname), 300)) {
    return;
}
if (isset($_GET["start"])) {
    $start = $_GET["start"];
} elseif (isset($_POST["start"])) {
    $start = $_POST["start"];
} else {
    $start = 0;
}
settype($start, "integer");
$artcnt = 20;
/*
 * 这里存在一个时间差的问题,可能会导致序号变乱。
 * 原因在于两次调用 bbs_countarticles() 和 bbs_getarticles()。
 */
if ($start == 0 || $start > $total - $artcnt + 1) {
    $start = $total - $artcnt + 1;
}
if ($start < 0) {
    $start = 1;
}
$articles = bbs_getarticles($board, $start, $artcnt, $dir_modes["DIGEST"]);
if ($articles == FALSE) {
    html_error_quit("读取文章列表失败");
}
$brd_encode = urlencode($brdarr["NAME"]);
page_header("推荐文章");
display_g_articles($brdarr, $articles, $start, $order = FALSE);
display_navigation_bar($brdarr, $brdnum, $start, $total, $order_articles);
page_footer();
Exemplo n.º 5
0
        $start = 0;
    }
    /*
     * 这里存在一个时间差的问题,可能会导致序号变乱。
     * 原因在于两次调用 bbs_countarticles() 和 bbs_getarticles()。
     */
    if ($start == 0 || $start > $total - ARTCNT + 1) {
        if ($total <= ARTCNT) {
            $start = 1;
            $page = 1;
        } else {
            $start = $total - ARTCNT + 1;
            $page = ($start + ARTCNT - 1) / ARTCNT + 1;
        }
    } else {
        $page = ($start + ARTCNT - 1) / ARTCNT;
    }
    settype($page, "integer");
    $articles = bbs_getarticles($brdarr["NAME"], $start, ARTCNT, $ftype);
    if ($articles == FALSE) {
        html_error_quit("读取文章列表失败");
    }
} else {
    $articles = 0;
    $start = 1;
    $page = 1;
}
bbs_safe_getboard($brdnum, $board, $brdarr);
bbs_board_header($brdarr, $ftype, $managemode, $isnormalboard);
display_articles($brdarr, $articles, $start, $ftype, $managemode, $page, $total, defined('BBS_NEWPOSTSTAT') && !$managemode && $isnormalboard && !$ftype, $isnormalboard);
page_footer();
Exemplo n.º 6
0
        html_error_quit("错误的文章号,原文可能已经被删除<script>clearArticleDiv(" . $id . ");</script>");
    }
    if ($ftype == $dir_modes["ZHIDING"]) {
        $num = 0;
    }
    // for caching the same url
    if (bbs_is_member_read($brdarr) && no_member_read_perm($articles[1])) {
        html_error_quit("本版驻版可读,非本版驻版用户不能查看本版文章!");
    }
    $article = $articles[1];
} else {
    $num = @intval($_GET["num"]);
    if ($num <= 0 || $num > $total) {
        html_error_quit("错误的文章号,原文可能已经被删除");
    }
    if (($articles = bbs_getarticles($brdarr["NAME"], $num, 1, $ftype)) === false) {
        html_error_quit("错误的文章号,原文可能已经被删除");
    }
    if ($id != $articles[0]["ID"]) {
        html_error_quit("错误的文章号,原文可能已经被删除");
    }
    if (bbs_is_member_read($brdarr) && no_member_read_perm($articles[0])) {
        html_error_quit("本版驻版可读,非本版驻版用户不能查看本版文章!");
    }
    $article = $articles[0];
}
if (!$ftype && $ptr == 'p' && $articles[0]["ID"] != 0) {
    if ($isnormalboard && cache_header("public", $indexModify, 10)) {
        exit;
    }
    bbs_brcaddread($brdarr["NAME"], $articles[0]["ID"]);
Exemplo n.º 7
0
function atomic_article()
{
    global $currentuser, $atomic_board, $atomic_brdarr, $atomic_brdnum, $dir_modes, $atomic_ftype;
    atomic_get_board();
    $id = @intval($_GET["id"]);
    if ($id <= 0) {
        atomic_error("错误的文章号");
    }
    $url = "?act=article&board=" . $atomic_board . "&id=";
    @($ptr = $_GET["p"]);
    // 同主题的指示在这里处理
    if ($ptr == "tn" || $ptr == "tp") {
        $articles = bbs_get_threads_from_id($atomic_brdnum, $id, $dir_modes["NORMAL"], $ptr == "tp" ? -1 : 1);
        if ($articles == FALSE) {
            $redirt_id = $id;
        } else {
            $redirt_id = $articles[0]["ID"];
        }
        header("Location: atomic.php" . $url . $redirt_id);
        exit;
    }
    $total = bbs_countarticles($atomic_brdnum, $atomic_ftype);
    if ($total <= 0) {
        atomic_error("错误的文章号,原文可能已经被删除");
    }
    if (!$atomic_ftype) {
        $articles = array();
        $num = bbs_get_records_from_id($atomic_board, $id, $atomic_ftype, $articles);
        if ($num <= 0) {
            atomic_error("错误的文章号,原文可能已经被删除");
        }
        $article = $articles[1];
    } else {
        $num = @intval($_GET["num"]);
        if ($num <= 0 || $num > $total) {
            atomic_error("错误的文章号,原文可能已经被删除");
        }
        if (($articles = bbs_getarticles($atomic_board, $num, 1, $atomic_ftype)) === false) {
            atomic_error("错误的文章号,原文可能已经被删除");
        }
        if ($id != $articles[0]["ID"]) {
            atomic_error("错误的文章号,原文可能已经被删除");
        }
        $article = $articles[0];
    }
    $filename = bbs_get_board_filename($atomic_board, $article["FILENAME"]);
    $isnormalboard = bbs_normalboard($atomic_board);
    if ($isnormalboard) {
        if (cache_header("public", @filemtime($filename), 300)) {
            return;
        }
    }
    if (!$atomic_ftype) {
        $idx = $ptr == 'p' ? 0 : ($ptr == 'n' ? 2 : -1);
        if ($idx != -1 && $articles[$idx]["ID"] != 0) {
            header("Location: atomic.php" . $url . $articles[$idx]["ID"]);
            exit;
        }
        bbs_brcaddread($atomic_board, $article["ID"]);
    }
    atomic_header();
    $html = '<p>';
    if (!$atomic_ftype) {
        $html .= '<a href="' . $url . $article["ID"] . '&p=tn">主题下篇</a> ';
        $html .= '<a href="' . $url . $article["GROUPID"] . '">楼主</a> ';
        $html .= '<a href="?act=post&board=' . $atomic_board . '">发表</a> <a href="?act=post&board=' . $atomic_board . '&reid=' . $id . '">回复</a> ';
        if (atomic_uploadable()) {
            $html .= '<a href="?act=post&board=' . $atomic_board . '&reid=' . $id . '&upload=1">带附件回复</a> ';
        }
        $html .= '<a href="' . $url . $article["ID"] . '&p=p">上篇</a> ';
        $html .= '<a href="' . $url . $article["ID"] . '&p=n">下篇</a> ';
        $html .= '<a href="' . $url . $article["ID"] . '&p=tp">主题上篇</a> ';
        $html .= '<a href="' . $url . $article["REID"] . '">溯源</a> ';
    }
    $html .= '<a href="?act=board&board=' . $atomic_board . '&page=' . intval(($num + ARTCNT - 1) / ARTCNT) . ($atomic_ftype ? "&ftype=" . $atomic_ftype : "") . '">回版面</a> ';
    $ourl = 'bbscon.php?bid=' . $atomic_brdnum . '&id=' . $article["ID"];
    if ($atomic_ftype) {
        $ourl .= "&ftype=" . $atomic_ftype . "&num=" . $num;
    }
    $html .= '<a href="' . $ourl . '">原文</a> ';
    $html .= '</p>';
    echo $html;
    echo bbs2_readfile_text($filename, MAXCHAR, 2);
    if ($article["ATTACHPOS"]) {
        echo '<p>本文含有附件: <a href="' . $ourl . '">原文链接</a></p>';
    }
    atomic_footer();
}
Exemplo n.º 8
0
 /**
  * function getTypeArticles get a range of articles via $type
  * $NORMAL get articles like in telnet
  * $DIGEST digest articles
  * $DELETED delete articles
  * $JUNK junk articles
  * $ORIGIN same threads mode
  * $ZHIDING top articles
  *
  * @param int $start start with zero
  * @param int $num
  * @param int $type
  * @return array
  * @access public
  */
 public function getTypeArticles($start, $num, $type = null)
 {
     if (is_null($type)) {
         $type = self::$NORMAL;
     }
     $totalNum = $this->getTypeNum($type);
     $start = $totalNum - $num - $start + 1;
     $ret = bbs_getarticles($this->NAME, $start, $num, $type);
     if (!is_array($ret)) {
         return array();
     }
     foreach ($ret as $k => &$v) {
         $v = new Article($v, $this, $k + $start);
     }
     return $ret;
 }
Exemplo n.º 9
0
Arquivo: att.php Projeto: bianle/www2
if ($total <= 0) {
    go_die();
}
$articles = array();
if ($dir_perm == 1) {
    //sorted
    $articles = array();
    $num = bbs_get_records_from_id($board, $id, $ftype, $articles);
    if ($num <= 0) {
        go_die();
    }
    $article = $articles[1];
} else {
    if ($num <= 0 || $num > $total) {
        go_die();
    }
    if (($articles = bbs_getarticles($board, $num, 1, $ftype)) === false) {
        go_die();
    }
    if ($id != $articles[0]["ID"]) {
        go_die();
    }
    $article = $articles[0];
}
$filename = bbs_get_board_filename($board, $article["FILENAME"]);
if ($isnormalboard && $ftype != $dir_modes["DELETED"]) {
    if (cache_header("public", @filemtime($filename), 3600)) {
        return;
    }
}
bbs_file_output_attachment($filename, $ap);