function cache_process($scope, $forcecachetime, $modifytime, $expiretime) { global $cachemode; //session_cache_limiter($scope); //这个函数只能接受 "nocache" 参数,不能接受 "no-cache" 参数 $cachemode = $scope; if ($scope == "nocache" || $scope == "no-cache") { //兼容 "no-cache" 的写法,不推荐 header("Expires: Thu, 19 Nov 1981 08:52:00 GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Pragma: no-cache"); return FALSE; } @($oldmodified = $_SERVER["HTTP_IF_MODIFIED_SINCE"]); if ($oldmodified != "") { if (($pos = strpos($oldmodified, ';')) !== false) { $oldmodified = substr($oldmodified, 0, $pos); } $oldtime = strtotime($oldmodified) + $forcecachetime; } else { $oldtime = 0; } if ($oldtime >= $modifytime) { header("HTTP/1.1 304 Not Modified"); header("Cache-Control: max-age=" . "{$expiretime}"); return TRUE; } header("Last-Modified: " . gmt_date_format($modifytime)); header("Expires: " . gmt_date_format(time() + $expiretime)); header("Cache-Control: max-age=" . "{$expiretime}"); return FALSE; }
$brdnum = bbs_getboard($brdname, $brdarr); if ($brdnum == 0) { continue; } $brdname = urlencode($brdarr["NAME"]); $gid = find_content($board, "groupid"); $item["title"] = htmlspecialchars("[" . $brdarr["DESC"] . "] " . find_content($board, "title")); $item["link"] = SiteURL . "bbstcon.php?board=" . $brdname . "&gid=" . $gid; $item["author"] = find_content($board, "author"); $item["pubDate"] = gmt_date_format(find_content($board, "time")); $item["guid"] = $item["link"]; $articles = array(); $num = bbs_get_records_from_id($brdname, $gid, $dir_modes["NORMAL"], $articles); if ($num <= 0) { continue; } $article = $articles[1]; if (!$article) { continue; } $contentfile = bbs_get_board_filename($brdname, $article["FILENAME"]); $content = bbs2_readfile_text($contentfile, DESC_CHAR_PER_RSS_ITEM, 0); if (is_string($content)) { $item["description"] = "<![CDATA[" . $content . "]]>"; } else { continue; } $items[] = $item; } $channel["lastBuildDate"] = gmt_date_format($modifytime); output_rss($channel, $items);
$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 . "&id=" . $origin['ID']; //you want the link to always work, so you don't want to add num //if ($ftype == $dir_modes["DIGEST"]) $conurl .= "&ftype=".$ftype."&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"]); $contents = bbs2_readfile_text($filename, DESC_CHAR_PER_RSS_ITEM, 0); if (is_string($contents)) { $item["description"] = "<![CDATA[" . $contents . "]]>"; } $items[] = $item; } } output_rss($channel, $items);
html_error_quit("Blog²»´æÔÚ!"); exit; } if (pc_cache($rows[modifytime])) { return; } $pc = array("NAME" => htmlspecialchars(stripslashes($rows[corpusname])), "USER" => $rows[username], "DESC" => htmlspecialchars(stripslashes($rows[description])), "THEM" => htmlspecialchars(stripslashes($rows[theme])), "UID" => $rows[uid]); $rss = array(); $rss[channel] = array("userid" => $pc["UID"], "siteaddr" => "http://" . $pcconfig["SITE"], "title" => $pc["NAME"], "pcaddr" => pc_personal_domainname($pc["USER"]), "desc" => $pc["DESC"], "email" => $pc["USER"] . ".bbs@" . $pcconfig["SITE"]); $nItems = $pcconfig["ETEMS"]; if (strcmp($currentuser["userid"], $userid) == 0) { $nItems = 100000; } $query = "SELECT * FROM nodes WHERE `uid` = '" . $pc["UID"] . "' AND `access` = 0 ORDER BY `nid` DESC LIMIT 0 , " . $nItems . " ;"; $result = mysql_query($query, $link); $i = 0; while ($rows = mysql_fetch_array($result)) { $rss[etems][$i] = array("addr" => "http://" . $pcconfig["SITE"] . "/pc/pccon.php?id=" . $pc["UID"] . "&nid=" . $rows[nid] . "&tid=" . $rows[tid], "etemcomaddr" => "http://" . $pcconfig["SITE"] . "/pc/pccom.php?act=pst&nid=" . $rows[nid], "etemtitle" => htmlspecialchars(stripslashes($rows[subject])), "etemdesc" => html_format($rows[body], TRUE, $rows[htmltag]), "etemauth" => $pc["USER"], "etemtime" => rss_time_format($rows[created]), "gmttime" => gmt_date_format(strtotime(time_format($rows[created]) . " +0800")), "etemnid" => $rows[nid]); $i++; } mysql_free_result($result); pc_db_close($link); if (isset($_GET["v"]) && $_GET["v"] == "2") { header("Content-Type: text/xml; charset=gb2312"); header("Content-Disposition: inline;filename=rss2.xml"); @pc_rss2_output($rss); } else { header("Content-Type: text/xml"); header("Content-Disposition: inline;filename=rss.xml"); @pc_rss_output($rss); }