<?php
require_once('include/config.php');
require_once('include/db.php');
require_once('include/comment.php');

$dirs = get_dir_list();

$dirs_html = '';

foreach ($dirs as $dir) {
	$dirs_html .= '<tr><td><a href="' . $config['basepath'] . 'dir.php?dir=' . urlencode($dir['path']) . '">' . htmlspecialchars($dir['name']) . '</a></td>';
	$dirs_html .= '<td>' . $dir['count'] . '</td>';
	$dirs_html .= '<td>' . date('j.m.Y', $dir['date']) . '</td>';
	$dirs_html .= '<td>' . count_comments($dir['id'], 'dir') . '</td>';
	$dirs_html .= '<td>';

	$comments = count_comments_all_dir_images($dir['id']);
	if ($comments > 0) {
		$dirs_html .= '<a href="' . $config['basepath'] . 'dir.php?dir=' . urlencode($dir['path']) . '&mode=viewcomments">';
	}
	$dirs_html .= $comments;
	if ($comments > 0) {
		$dirs_html .= '</a>';
	}

	$dirs_html .= '</td></tr>';
}

?><!DOCTYPE html>
<html>
<head>
<title>Obrazki</title>
<link rel="stylesheet" href="/obrazki/style.css?<?=$time?>" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h1>Dostępne katalogi z obrazkami</h1>
Uwaga, nowy skrypt. Zgłoś problemy administratorowi.
<table id="dirlist"><tr><th>Nazwa</th><th>Obrazków</th><th>Utworzono</th><th>Komentarzy<br>do katalogu</th><th>Komentarzy<br>do obrazków</th></tr>
<?=$dirs_html?>
</table>
<a class="k4" href="http://k4be.pl/"></a>
</body>
</html>