Пример #1
0
/**
* This function checks that the mtz being uploaded is the correct format
*   tmpMtz     the (temporary) file where the upload is stored.
*   origName        the name of the file on the user's system.
*/
function addMtz($tmpMtz, $origName)
{
    $outpath = $_SESSION['dataDir'] . '/' . MP_DIR_XRAYDATA;
    if (!file_exists($outpath)) {
        mkdir($outpath, 0777);
    }
    $tasks = getProgressTasks();
    $tasks['mtz_check'] = "Checking the mtz format";
    setProgress($tasks, 'mtz_check');
    $filename = $outpath . '/' . $origName;
    // copy($tmpMtz, $filename);
    $tf = mtzFormatCorrect($tmpMtz);
    if ($tf) {
        copy($tmpMtz, $filename);
    }
}
Пример #2
0
 /**
 * Documentation for this function.
 */
 function onUploadXray()
 {
     $req = $_REQUEST;
     if ($_REQUEST['cmd'] == "Cancel") {
         pageReturn();
     } else {
         $xrayName = censorFileName($_FILES['uploadFile']['name'], array('mtz'));
         // make sure no spaces, etc.
         $xrayPath = "{$_SESSION['dataDir']}/" . MP_DIR_XRAYDATA;
         if (!file_exists($xrayPath)) {
             mkdir($xrayPath, 0777);
         }
         $xrayPath .= "/{$xrayName}";
         $tmpfile = mpTempfile("tmp_mtz");
         if (!$_FILES['uploadFile']['error'] && $_FILES['uploadFile']['size'] > 0 && !file_exists($xrayPath) && move_uploaded_file($_FILES['uploadFile']['tmp_name'], $tmpfile)) {
             $tf = mtzFormatCorrect($tmpfile);
             if ($tf) {
                 mpLog("mtz-upload:User uploaded an mtz file");
                 copy($tmpfile, $xrayPath);
                 $_SESSION['mtzs'][$xrayName] = $xrayName;
                 pageGoto("upload_other_done.php", array('type' => 'xray', 'xrayName' => $xrayName));
             } else {
                 $this->doUploadError('xray', $xrayPath);
             }
         } else {
             $this->doUploadError('xray', $xrayPath);
         }
     }
 }