function extractFilename() { // If the argument is model=X, then load that saved tmp or bookmarked model if (isset($_REQUEST["model"])) { $filename = "../ump/" . $_REQUEST["model"] . "/model.ump"; if (!file_exists("ump/" . $filename)) { $destfile = nextFilename("ump"); $filename = "../" . $destfile; file_put_contents($destfile, "// Saved URL ending in " . $_REQUEST["model"] . " cannot be found"); } else { // Check if there is a password lock on the model if (file_exists("ump/" . $_REQUEST["model"] . "/readonlylock.txt")) { // TODO: Open the read only file and check if the // There is an argument with a matching overwrite key // For now, just ensure that the saved URL can only // be overwritten if the argument &overwrite=yes is supplied if (!$_REQUEST["overwrite"] == "yes") { $readOnly = true; $fileToCopy = "ump/" . $filename; $destfile = nextFilename("ump"); $filename = "../" . $destfile; copy($fileToCopy, $destfile); } } } } elseif (isset($_REQUEST['example']) && $_REQUEST["example"] != "") { $fileToCopy = "ump/" . htmlspecialchars($_REQUEST['example']) . ".ump"; if (!file_exists($fileToCopy)) { $fileToCopy = "ump/NullExample.ump"; } $destfile = nextFilename("ump"); $filename = "../" . $destfile; copy($fileToCopy, $destfile); } elseif (isset($_REQUEST['text']) && $_REQUEST["text"] != "") { $destfile = nextFilename("ump"); $filename = "../" . $destfile; file_put_contents($destfile, urldecode($_REQUEST["text"])); } elseif (!isset($_REQUEST['filename']) || $_REQUEST["filename"] == "") { $filename = "../" . nextFilename("ump"); } else { $destfile = nextFilename("ump"); $filename = "../" . $destfile; if (!substr($_REQUEST["filename"], -4) == ".ump") { file_put_contents($destfile, "// URL in filename argument must end in .ump and the initial http:// must be omitted"); } else { file_put_contents($destfile, file_get_contents("http://" . $_REQUEST["filename"])); if (substr($http_response_header[0], -2) != "OK") { // try https file_put_contents($destfile, file_get_contents("https://" . $_REQUEST["filename"])); if (substr($http_response_header[0], -2) != "OK") { file_put_contents($destfile, "// URL of the Umple file to be loaded in the URL after ?filename= must omit the initial http:// and end with .ump.\n// The file must be accessible from our server.\n// Could not load http://" . $_REQUEST["filename"]); } } } } return $filename; }
<?php require_once "scripts/compiler_config.php"; if (!isset($_REQUEST["model"])) { header('HTTP/1.0 404 Not Found'); readfile('../404.shtml'); exit; } $tempModelId = $_REQUEST["model"]; // The following creates a random numbered directory in ump // the result is ump/{dir}/model.ump date_default_timezone_set('UTC'); $savedModel = nextFilename("ump", date("ymd")); $saveModelId = extractModelId($savedModel); $filename = "ump/{$tempModelId}/model.ump"; // If boomkarking is being attempted by a crawler that has no javascript // and has just created a model.ump file, then this is an error. // It is also an error if an attempt is made to later on bookmark some // file that has long since been deleted if (!is_file($filename)) { header('HTTP/1.0 404 Not Found'); readfile('../404.shtml'); if (substr($tempModelId, 0, 3) == "tmp") { recursiveDelete("ump/{$tempModelId}"); } recursiveDelete("ump/{$saveModelId}"); exit; } if (!is_file("ump/{$tempModelId}/model.ump.erroroutput")) { header('HTTP/1.0 412 Precondition Failed'); echo "<html><head><title>Javascript Off</title></head><body><p>You cannot make a bookmarked page when JavaScript is turned off. Please turn it on.</p></body></html>";