Пример #1
0
$arrOutLink[] = '<a href="http://' . $indexCache->baseUrl . '">' . $indexCache->key . '</a>';
//上层链接
$arrOutLink[] = '1';
$arrOutLink[] = '2';
$arrOutLink[] = '3';
$arrOutLink[] = '';
$outLink = implode('|', $arrOutLink);
$db->close();
//--------------------生成外链完毕--------------------------------------------
$randArticle = new randArticle($cfg->isMemcached);
$randArticle->SetKey($indexCache->key);
$randArticle->SetKeys($indexCache->keys);
$randArticle->SetStroyPath($cfg->storyPath);
$randArticle->SetOutLink($outLink);
$randArticle->InitFeature($indexCache->baseUrl . $viewID);
$randArticle->GenerateTitle();
$randArticle->GenerateBody();
//--------------------生成上下页--------------------------------------------
$dayAfterCreate = (int) ((time() - $createTime) / 86400) + 1;
$maxRandArticleId = $dayAfterCreate + 3;
$nextLink = '<p><a href="./read-' . ($viewID + 1) . '.html">下一篇</a></p>';
$lastLink = '<p><a href="./read-' . ($viewID - 1) . '.html">上一篇</a></p>';
if ($viewID >= $maxRandArticleId) {
    $nextLink = '';
}
if ($viewID <= 1) {
    $lastLink = '';
}
$randLink = '<p><a href="./read-' . rand(1, $maxRandArticleId) . '.html">推荐文章</a></p>';
$additionLinks = $lastLink . $nextLink . $randLink;
//--------------------输出--------------------------------------------