<td class="content">
<?php

// $Date: 2004/01/15 02:34:22 $
// $Revision: 1.6 $
// $Author: jcrocholl $

function links($text) {
    global
$links;
    if (!
$links) return $text;
    foreach (
$links as $caption => $link) {
        
$replace = "<a href=\"$link\">$caption</a>";
        
// only available with PHP >= 5
        // $text = str_ireplace($caption, $replace, $text);
        
$caption = str_replace('/', '\/', $caption);
        if (
preg_match("/^(.*)$caption(.*)$/si", $text, $m))
            return
links($m[1]) . $replace . links($m[2]);
    }
    return
$text;
}

if (
file_exists("$fileroot$stem" . "Abstract")) {
    
// print "$fileroot$stem" . "Abstract";
    
$text = $stem;
    print
h(1, $text);
    print
links(format_file("$fileroot$stem" . "Abstract", false));
}

if (
file_exists("$fileroot$stem" . "Links")) {
    
$input = file("$fileroot$stem" . "Links");
    foreach (
$input as $line) {
        if (
preg_match('/^\s*(\S+)\s+(\S.*\S)\s*$/', $line, $m))
            
$links[$m[2]] = $m[1];
    }
}

if (
file_exists("$fileroot$stem" . "Readme")) {
    
// print "$fileroot$stem" . "Readme";
    
print links(format_file("$fileroot$stem" . "Readme"));
}

if (
$absort) {
    
// print "abstracts";
    
foreach ($absort as $name) {
        
$text = $abstracts[$name];
        
$name .= '/';
        
$h2 = "<a href=\"$links[$name]\">$name</a>";
        print
h(2, $h2);
        print
links($text);
    }
}

function
scan_releases($dir) {
    global
$fileroot;
    if (
$dh = opendir("$fileroot$dir")) {
        while ((
$file = readdir($dh)) !== false) {
            if (
is_file("$fileroot$dir$file")
                and
substr($file, 0, 7) == 'roemer-')
                
$release_files[] = $file;
        }
        
closedir($dh);
    }
    if (
$release_files) {
        
asort($release_files);
        return
$release_files;
    }
    return
false;
}

// print implode('-', $path);
// print "$fileroot$stem";
if ($path[0] == 'release' and count($path) == 3) {
    
$release_files = scan_releases($stem);
    if (
$release_files)
        foreach (
$release_files as $file)
            
$release_text .= "<a href=\"$file\">$file</a><br/>\n";

    if (
$dh = opendir("$fileroot$stem")) {
        while ((
$dir = readdir($dh)) !== false) {
            if (
is_dir("$fileroot$stem$dir")
                and
$dir[0] != '.' and $dir != 'CVS')
            {
                
// print "$fileroot$stem$dir";
                
$release_files = scan_releases("$stem$dir/");
                if (
$release_files) {
                    
$release_text .= "<h3>$dir/</h3>\n";
                    if (
file_exists("$fileroot$stem$dir/Abstract"))
                        
$release_text .= format_file("$fileroot$stem$dir/Abstract", false);
                    foreach (
$release_files as $file) {
                        
$size = (int) (filesize("$fileroot$stem$dir/$file") / 1024);
                        
$size .= 'KB';
                        
$release_text .= "<a href=\"$dir/$file\">$file</a> ($size)<br/>\n";
                    }
                }
            }
        }
        
closedir($dh);
    }
    
    if (
$release_text) {
        print
"<h2>Development Snapshots</h2>\n";
        print
"<p>\n";
        print
$release_text;
        print
"</p>\n";
    }
}

?>
</td>