// modified: 12/11/2003 by Oleg Baranovsky
//
// This is a core of the document system at nic.ua.net
// looks for one of the sections at /source directory
// and shows directory index or actuall file (if specified)
// if shows directory, then includes top.php first and
// bottom.php last.
// Uses directory index from the /cache directory
//
// At this point the cached index is created manually. It is
// in the plan for nearest future to generate cached directory
// index automatically, based on the control record within each
// document. Cache will be regenerated automatically if
// directory date is newer than the cached index file.
//
$section = $_GET['section'];
if ($section == "") { $section = "documents"; }
$page = $_GET['page'];
$print = $_GET['print'];
$buffer = "";
$title = "";
$subtitle = "";
$is_myfile = false;
if ( ! is_dir($_SERVER['DOCUMENT_ROOT'] . "/source/" . $section ) ){
$buffer = "Error! Wrong/nonexistent section $section.
\n";
} else {
$subtitle = "home / $section";
if ($page != "") {
$fpage = $_SERVER['DOCUMENT_ROOT'] . "/source/" . $section . "/" . $page;
if (is_readable($fpage . ".txt")) {
$is_myfile = true;
$fhandle = fopen ($fpage. ".txt", "r");
$params = fgets($fhandle);
list ($title, $category, $sort_key, $url, $junk) = split ("\|", $params, 5);
while (!feof ($fhandle)) {
$line = fgets($fhandle);
if ($line == "" || $line == "\r" || $line == "\r\n" || $line == "\n") { $line = "
\n"; }
$buffer .= $line;
}
fclose ($fhandle);
} elseif (is_readable($fpage . ".html")) {
$is_myfile = true;
$fhandle = fopen ($fpage. ".html", "r");
$params = fgets($fhandle);
list ($title, $category, $sort_key, $url, $junk) = split ("\|", $params, 5);
while (!feof ($fhandle)) {
$line = fgets($fhandle);
$buffer .= $line;
}
fclose ($fhandle);
}
if ( ! $is_myfile ) {
$buffer = "Error! Document $section/$page was not found.
\n";
} else {
$subtitle .= " / $page";
}
}
}
if ($print) {
include $_SERVER['DOCUMENT_ROOT'] . "/include/header_print.inc.php";
} else {
include $_SERVER['DOCUMENT_ROOT'] . "/include/header.inc.php";
print "