|
为了方便搜索引擎收录dokuwiki的文章,我写了个dokuwiki所有文章的索引页
例子见http://wiki.dbaman.cn/docs/php/dokuwiki_index
<?php
/**
* dokuwiki 所有主题列表
* all Subject List of dokuwiki
*
* @author 流水孟春 <cmpan(at)qq.com>
* @version 20090322
* @link http://wiki.dbaman.cn/docs/php/dokuwiki_index
*/
function myDir($dir = 'data/pages/') {
$dir = rtrim(str_replace('\\', '/', $dir), '/ ') . '/';
static $links;
$d = dir($dir);
print "\r\n<ul>\r\n";
while (false !== ($entry = $d->read())) {
if($entry[0] != '.') {
if(is_dir($dir . $entry)) {
print "<li class='dir'><a href='" . str_replace('data/pages/', '', $dir . $entry)
. "/' target='_blank'><b>" . urldecode($entry) . "</a></b></li>\r\n";
myDir($dir . $entry);
} else {
$entry = str_replace('.txt', '', $entry);
print "<li class='link'><a href='". str_replace('data/pages/', '', $dir . $entry)
."' target='_blank'>" . urldecode($entry) . "</a></li>\r\n";
}
}
}
$d->close();
print "</ul>\r\n\r\n";
}
// config
$tmp = 'data/tmp/map.tmp.html';
$debug = 0;
$cacheT = 3600; // s
$id = 'meng123.';
// logic
if((!$debug && is_file($tmp) && (time() - filemtime($tmp) < $cacheT))
&& (empty($_GET['id']) || $_GET['id'] != $id)) {
print "<!-- from cache-->\r\n";
print file_get_contents($tmp);
exit;
}
ob_start();
// html ------------------------------------------------------------------------
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> 主题列表(Subject List) </title>
<style type="text/css">
.dir a{color:black;}
.link a {color: blue;}
</style>
</head>
<body>
<div> <a href=./>返回首页(Home Page)</a> <HR> </div>
<dir><b><h3>主题列表(Subject List)</h3></b></div>
<?php myDir(); ?>
<div> <HR> <a href=./>返回首页(Home Page)</a> </div>
</body>
</html>
<?php
// end html ------------------------------------------------------------------------
file_put_contents($tmp, ob_get_contents());
ob_flush();
?> |
|
|