Example #1
0
$curpage = $_GET["p"];
$curpage = isset($curpage) && is_numeric($curpage) ? $curpage : 1;
if ($curpage < 1) {
    $curpage = 1;
}
if (strpos($name, "http://") === 0) {
    header('HTTP/1.1 301 Moved Permanently');
    header("Location:" . $name);
}
if (!preg_match("/^.{1,100}\$/", $name)) {
    header("HTTP/1.1 404 Not Found");
    header("Status: 404 Not Found");
    exit;
}
$categorydata = new Category();
$category = $categorydata->GetCategoryByName($name);
if ($category == null) {
    header("HTTP/1.1 404 Not Found");
    header("Status: 404 Not Found");
    exit;
}
if ($category->type == "article") {
    $articledata = new Article();
    $articlecount = $articledata->GetArticleList($category->cid);
    $total = count($articlecount);
    $take = $category->takenumber;
    $skip = ($curpage - 1) * $take;
    $totalpage = (int) ($total % $take == 0 ? $total / $take : $total / $take + 1);
    $articlelist = $articledata->TakeArticleList($category->cid, $skip, $take);
    $tempinfo->assign("articlelist", $articlelist);
} else {
Example #2
0
 function TakeArticleListByName($name = "", $skip = 0, $take = 10, $orderby = "adddate desc", $all = false)
 {
     global $yiqi_db;
     $categorydata = new Category();
     $exist = $categorydata->ExistFilename($name);
     if ($exist == 1) {
         $category = $categorydata->GetCategoryByName($name);
         $cids = array($category->cid);
         $cids = array_merge($cids, $categorydata->GetSubCategoryIDs($category->cid));
         $cids = implode(',', $cids);
         if ($all) {
             return $yiqi_db->get_results(CheckSql("select * from yiqi_article where cid in ({$cids}) order by {$orderby} limit {$skip},{$take} "));
         } else {
             return $yiqi_db->get_results(CheckSql(sprintf("select * from yiqi_article where cid in ({$cids}) and adddate <= '%s' order by {$orderby} limit {$skip},{$take} ", date("Y-m-d H:i:s"))));
         }
     } else {
         if ($all) {
             return $yiqi_db->get_results(CheckSql("select * from yiqi_article order by {$orderby} limit {$skip},{$take}"));
         } else {
             return $yiqi_db->get_results(CheckSql(sprintf("select * from yiqi_article where adddate <= '%s' order by {$orderby} limit {$skip},{$take}", date("Y-m-d H:i:s"))));
         }
     }
 }