<?php
    $paper = $_REQUEST['paper'];
    $type = $_REQUEST['type'];
    $reformat = $_REQUEST['reformat']?$_REQUEST['reformat']:0;
    if (!$paper){
        echo "Error! Paper ID is not set\n";
        exit(1);
    }
    if (!$type && ($type != "review") && ($type != "response")){
        echo "Error! Paper type is not correct\n";
        exit(1);
    }
    $my_file = "${type}s/$paper.html";
    if (!file_exists($my_file)){
        echo "Sorry! The review/response file does not exists.\n";
        exit(1);
    }
    $header = <<<HEADER
    <html>
    <head><title>$type for $paper</title></head>
	<link rel="stylesheet" href="nng.css">
    <link rel="icon" 
          type="image/jpg" 
          href="./favicon.ico">
	<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    </head>
    <body>
    <div id="main_box">
        <div id="titlebar">
            <img src="images/nng.jpg">
        </div>

    <div id="navigation">
        <br>
        <p><a href="members.html">Members</a></p>
        <p><a href="publications.html">Publications</a></p>
        <p><a href="research.html">Research</a></p>
        <p><a href="projects.html">Projects</a></p>
        <p><a href="collaborators.html">Collaborators</a></p>
        <p><a href="software.html">Software</a></p>
        <p><a href="sponsors.html">Sponsors</a></p>
        <p><a href="photos.html">Photos</a></p>
    </div>
    <!--- Above is header of html files -->
    <div id="contentbox">
        <div id="text">
            <p>
HEADER;
    $html = file_get_contents($my_file);
    if ($reformat){
        $html = nl2br($html);
    }
//    $content = str_replace("\n", "<br>\n", $raw_txt);
    echo $header;
    echo $html;
//    echo $content;
    echo "</p></div><div></body></html>";
    //phpinfo();

?>
