熱門資訊

function is_valid_page($page) {
$page = str_replace(":", "/", $page);
return is_file(getcwd() . "/data/pages/" . $page . ".txt");
}
{
$REC = array();
$PATH = "/nfs/var/spool/dokuwiki/viewcount";
if (is_dir($PATH)) {
if ($dh = opendir($PATH)) {
while (($file = readdir($dh)) !== false) {
$filename = "$PATH/$file";
if (is_file($filename) && is_valid_page($file)) {
$REC[$file] = file_get_contents($filename);
}
}
closedir($dh);
}
} else {
mkdir($PATH, 0700);
}
arsort($REC);
$i = 0;
echo '<table class="inline">';
echo "<tr><th class=\"centeralign\" nowrap=\"nowrap\">項次</th><th class=\"centeralign\" nowrap=\"nowrap\">標題</th><th class=\"centeralign\" nowrap=\"nowrap\">瀏覽次數</th></tr>\n";
foreach ($REC as $key => $val) {
if ($i >= 30) { break; }
if ($key == "en:nottranslated" ) { continue; } // 2017/03/29 skip this page
if ($key == "viewcount") { continue; }
if ($key == "footer") { continue; }
if ( preg_match('/^private/', $key) ) { continue; }
$i++;
$title = p_get_first_heading($key);
echo "<tr><td class=\"centeralign\">$i</td><td class=\"leftalign\"><a href=\"./$key\"><strong>$title</strong> ($key)</a></td><td class=\"rightalign\">$val</td>\n";
}
echo '</table>';
}