<?php
$dir = "./sw_archive";
$report = "swdl_report.html";
$watchers = array("davis@csail.mit.edu"); //, "xuegong@csail.mit.edu");
$version = "6.15";
$month = "April 2026";

$passwords = array(
	"DAN" => "WilderPen",
	"LLFS" => "Acorb luaP",
        "FHS" => "Wildebeast",
	"default" => "Acorb luaP",
	);

function passwordValid($org, $password) {
	global $passwords;
	if(isset($passwords[$org])) 
		return $password == $passwords[$org];
	return $password == $passwords["default"];
}

require_once("dataformprocessRDBU.php");

?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta name="robots" content="noindex,nofollow,noarchive" />
        <title>Clocksketch Software Download Site</title>
        <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    <body>
        <div class="centertext">
            <a href="http://web.mit.edu"> <img border="0" id="mit_icon" src="mit_icon.png" /></a> 
            <a href="http://rationale.csail.mit.edu/clocksketch"> <img border="0" id="LaheyLogo" src="LaheyLogo.png"/></a>
			<br /><br />
			<h2>Clock Sketch Software Download Site: Complete Installation</h2>
			<br />
        </div>
        
<?php

if(isset($_POST["Submit"]))
    $error = validate_top_form();

if(!isset($_POST['txtPassword']) || !passwordValid($_POST["hospital"], $_POST["txtPassword"]) || (isset($_POST["Submit"]) && !empty($error)) || empty($_POST['txtPassword'])) {
    
?>
        <div class="indented">
            <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                <table>
                    <?php require_once("dataformRD.php"); ?>
                </table>
                
                <h2>Login</h2>
                <p><label for="txtpassword">Password:</label>
                    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>
                    <p><input type="submit" name="Submit" value="Login" /></p>
            </form>

<?php
	if(isset($_POST["Submit"]) && !empty($error)) {
		echo $error;
	}
    if (!empty($_POST['txtPassword']) && isset($_POST["Submit"]) && !passwordValid($_POST["hospital"], $_POST["txtPassword"])) {
        recordRemoteIPpw($_POST['txtPassword'],FALSE, "access", "new complete version", $version);
?>
            
	       <div>
               <h2>Incorrect Password</h2>
               <p>If you are having trouble getting access, please send email
                   to davis@csail.mit.edu.</p>
	       </div>
        

<?php
    }
	if(isset($_POST["Submit"]) && empty($_POST['txtPassword'])) {
?>
			<div>
               <h2>Please enter a password</h2>
	       (Make sure you have selected the correct organization.)
               <p>If you are having trouble getting access, please send email
                   to davis@csail.mit.edu.</p>
	       </div>
<?php
	}
?>
		</div>
<?php

	
} else {
	// Oct 2015: Everyone else gets the lite version.
	// UNL, UFL, Lahey MIT MGH/BWH and HSHH get Think.
	// Everyone else,  gets CS
	$fileName = "./sw_installationLite/ClockSketchV69Installation2022.exe";
        $docnName = "./sw_installationLite/README-ClockSketchV69Installation2022.pdf";
	//	if($_POST["hospital"] == "DAN") {
	//		$fileName = "./sw_installationLite/ClockSketchV63BInstallation.exe";
	//	} else 
	 if($_POST["hospital"] == "Lahey" || $_POST["hospital"] == "UNL" || $_POST["hospital"] == "UnivFl" || 
            $_POST["hospital"] == "HSHH" || $_POST["hospital"] == "MIT" || $_POST["hospital"] == "MGHFNS" ||
	    $_POST["hospital"] == "KINDRED")  {
	   $fileName = "./sw_installationLite/Think,jar"  // temp hack to allow MGH to get new version
		  //		$fileName = "./sw_installationLite/ThinkV69Installation.exe";
                $docnName = "./sw_installationLite/README-THinkInstallationPC-2025.pdf";
	}

// here in case we need it for another special version
// else if($_POST["hospital"] == "") {
//		$fileName = "";
//	}

?>
        <div class="indented">

            <h2>First-time installation, Version <?=$version?></h2>
            <p>
                This page supplies what you need to install the software on a machine
                with no previous installation; download the installation instructions
                and the self-expanding zip file containing the software. All necessary
                files are in this installation package. To get the files, right click
                and use "Save Target As" or "Save Link As".
            </p>
            <p>
                Note carefully where you put the files, so you can find them again.
                We suggest putting them in your <span class="monospace">My Documents</span> folder 
                (and not just on your desktop).
            </p>
            <p>
                Please be sure to read the installation instructions first, then
                proceed with the installation. Feel free to get in touch if you
                encounter any problems.
            </p>
            <p>
                <ol>
                    <li> Download the installation instructions 
                        <a href="<?=$docnName?>"> here</a>. 
                    </li>
                    <li> Download the self-expanding zip file 
                        <a href="<?=$fileName?>">here</a>.
                    </li>
                </ol>
            </p>
        </div>
    </body>
</html>

<?php
    recordRemoteIPpw($_POST['txtPassword'],TRUE, "access", "new complete version", $version);
}
?> 
