<?php
	define('PATH', './');
	require(PATH.'lib/conf.php');

	$INDEX = fopen(LOGDIR.'info.idx', 'r');
	$allno = fgets($INDEX, 4096);
	while(!feof($INDEX)) {
		list($no, $flag, $cate, $date, $edate, $item_name) = split('<>', fgets($INDEX, 4096));
		if (!$no || $flag != '0') { continue; }
		if ($date > date("Y/m/d")) { continue; }
		$LOG[] = array(
			'no'		=> $no,
			'flag'		=> $flag,
			'cate'		=> $cate,
			'date'		=> $date,
			'edate'		=> $edate,
			'title'		=> $title
		);
	}
	multisort($LOG, 'date', SORT_DESC);

	//ページング
	$pager_param = array(
		'itemData'		=> $LOG,
		'perPage'		=> PAGEDISPNUM,
		'delta'			=> 5,
		'mode'			=> 'Sliding',
		'separator'		=> '|',
		'prevImg'		=> '&lt;&lt;戻る',
		'nextImg'		=> '次へ&gt;&gt;',
		'firstPageText'	=> '先頭',
		'lastPageText'	=> '最後'
	);
	$pager =& Pager::factory($pager_param);
	$navigation = $pager -> getLinks();
	$LOG = $pager->getPageData();
?>
<?php header('Content-Type: text/html;charset='.mb_internal_encoding());?>
<?php require(PATH.'lib/header.php'); ?>
	<table width="100%" border="0" cellspacing="5" cellpadding="0">
<?php
	if (isset($LOG)) {
		foreach ($LOG as $key => $array) {
//			$XML = XML_unserialize(file_get_contents(LOGDIR."{$array['no']}.xml"));

			$array = json_decode(json_encode(simplexml_load_string(mb_convert_encoding(file_get_contents(LOGDIR."{$array['no']}.xml"), 'UTF8', 'EUC-JP'))), true);
			mb_convert_variables('EUC-JP', 'UTF-8', $array);
			$XML['info'] = $array;

			list($year, $month, $day) = split('/', $XML['info']['date']);
			$XML['info']['date'] = sprintf("%d", $year).'年'.sprintf("%d", $month).'月'.sprintf("%d", $day).'日';
?>
		<tr>
			<td valign="top" nowrap width="156"><a id="<?php echo $XML['info']['no']; ?>" name="<?php echo $XML['info']['no']; ?>"></a><?php echo $XML['info']['date']; ?></td>
			<td valign="top">
				<?php echo $XML['info']['title']; ?><br>
				<br>
				<?php echo $XML['info']['contents']; ?><br>
				<br>
			</td>
		</tr>
<?php
		}
	}
?>
	</table>
<?php require(PATH.'lib/footer.php'); ?>
