예제 #1
0
    if ($tmpfile == null) {
        $_SESSION['bgjob']['newModel'] = null;
    } else {
        $id = addModelOrEnsemble($tmpfile, strtolower("{$code}.pdb"), $_SESSION['bgjob']['isCnsFormat'], $_SESSION['bgjob']['ignoreSegID'], false);
        if (isset($_SESSION['bgjob']['xray'])) {
            addXraydata(strtolower($code), $id);
        }
        // Clean up temp files
        unlink($tmpfile);
        if (preg_match('/^[0-9A-Z]{4}$/i', $code) && ($_SESSION['bgjob']['eds_2fofc'] || $_SESSION['bgjob']['eds_fofc'])) {
            getMaps($code);
        }
    }
} else {
    // Remove illegal chars from the upload file name
    $origName = censorFileName($_SESSION['bgjob']['origName'], array("pdb", "ent", "xyz", "mtz"));
    $fileSource = "local disk";
    if (isset($_SESSION['bgjob']['tmpPdb'])) {
        $id = addModelOrEnsemble($_SESSION['bgjob']['tmpPdb'], $origName, $_SESSION['bgjob']['isCnsFormat'], $_SESSION['bgjob']['ignoreSegID'], true);
        // Clean up temp files
        unlink($_SESSION['bgjob']['tmpPdb']);
    } elseif (isset($_SESSION['bgjob']['tmpMtz'])) {
        addMtz($_SESSION['bgjob']['tmpMtz'], $origName);
        // Clean up temp files
        unlink($_SESSION['bgjob']['tmpMtz']);
    }
}
// Automatic labbook entry
if (isset($id)) {
    // this is now the "working model" until overriden (could also be an ensemble)
    $_SESSION['lastUsedModelID'] = $id;
예제 #2
0
mpSessReadOnly();
// could occur while a background job is running...
#{{{ a_function_definition - sumary_statement_goes_here
############################################################################
/**
* Documentation for this function.
*/
//function someFunctionName() {}
#}}}########################################################################
# MAIN - the beginning of execution for this page
############################################################################
if (!isset($_REQUEST['fileName']) || !isset($_REQUEST['fileContents'])) {
    die("This page for file uploads only");
}
// First make sure this is a legal file name with no weird chars, ending in .kin
$outname = censorFileName($_REQUEST['fileName'], "kin");
// Now make sure we have a directory to put it in
$outpath = $_SESSION['dataDir'] . '/' . MP_DIR_KINS;
if (!file_exists($outpath)) {
    mkdir($outpath, 0777);
}
// Finally, make sure we don't overwrite anything already in existance!
while (file_exists("{$outpath}/{$outname}" . $serial)) {
    $serial++;
}
$outpath = "{$outpath}/{$outname}" . $serial;
$h = fopen($outpath, 'wb');
fwrite($h, $_REQUEST['fileContents']);
fclose($h);
$size = strlen($_REQUEST['fileContents']);
echo "OK name={$outpath}; size={$size}\n";
예제 #3
0
 /**
 * Documentation for this function.
 */
 function onUploadMapFile()
 {
     if ($_REQUEST['cmd'] == "Cancel") {
         pageReturn();
     } else {
         // List of allowed map extensions taken from KiNG's EDMapPlugin
         $mapName = censorFileName($_FILES['uploadFile']['name'], array('map', 'omap', 'xmap', 'dn6', 'dsn6', 'ccp4', 'mbk', 'xplor', 'brix', 'map.gz', 'omap.gz', 'xmap.gz', 'dn6.gz', 'dsn6.gz', 'ccp4.gz', 'mbk.gz', 'xplor.gz', 'brix.gz'));
         // make sure no spaces, etc.
         $mapPath = "{$_SESSION['dataDir']}/" . MP_DIR_EDMAPS;
         if (!file_exists($mapPath)) {
             mkdir($mapPath, 0777);
         }
         $mapPath .= "/{$mapName}";
         if (!$_FILES['uploadFile']['error'] && $_FILES['uploadFile']['size'] > 0 && !file_exists($mapPath) && move_uploaded_file($_FILES['uploadFile']['tmp_name'], $mapPath)) {
             // Uploaded file probably has restrictive permissions
             chmod($mapPath, 0666 & ~MP_UMASK);
             $_SESSION['edmaps'][$mapName] = $mapName;
             mpLog("edmap-upload:User uploaded an electron density map file");
             pageGoto("upload_other_done.php", array('type' => 'map', 'mapName' => $mapName));
         } else {
             $this->doUploadError('map', $mapPath);
         }
     }
 }