<?php
	$param = $_GET["ym"];
	
	if ($param) {
		$dir = dir("./wiki/kazuwiki/");
		#	print "Content-Type: text/html\n\n";
		print "<html>";
		print "<head>";
		print "</head>";
		print "<body>";
		while ($item = $dir->read()) {
			if ($item == ".") {
			} else if ($item == "..") {
			} else if ($item == "index.html") {
			} else if ($item == "UpdateIndex.txt") {
			} else if ($item == $param) { 
				get_sub_dir($item);
			}
		}
		$dir->close();
		print "</body>";
		print "</html>";
	} else {
		exit();
	}
function get_sub_dir($dir1) {
	$dir2 = dir("./wiki/kazuwiki/".$dir1);
	print "<p>これは検索エンジン用の一覧です（".substr($dir1,0,4)."年".substr($dir1,4,2)."月）</p>";
	while ($item2 = $dir2->read()) {
		if ($item2 == ".") {
		} else if ($item2 == "..") {
		} else {
			$title = get_first_line("./wiki/kazuwiki/".$dir1."/",$item2);
			$member = substr($item2,0,strlen($item2)-4).".html";
			print "<a href='http://www.excel.studio-kazu.jp/kw/".$member."'>".$title."</a>　　";
		}
	}
	$dir2->close();
	print "<p>これは検索エンジン用の一覧です（".substr($dir1,0,4)."年".substr($dir1,4,2)."月）</p>";
}

function get_first_line($path1,$file1) {
	$fpath = $path1.$file1;
	$title1 = "";
	if (file_exists($fpath)) {
		$fp = fopen($fpath,"r");
		$line = fgets($fp);
		$title1 = $line;
		fclose($fp);
	}
	return $title1;
}

?>