Example #1
0
 /**
 * FUNKY: This turns into a binary file download rather than an HTML page,
 * and then calls die(), leaving the user on the original HTML page.
 *
 * This code has been shown to cause cancer in lab rats.
 */
 function onDownloadPopularZip()
 {
     if (isset($_SESSION['ensembles'][$_SESSION['lastUsedModelID']])) {
         $model = $_SESSION['ensembles'][$_SESSION['lastUsedModelID']];
     } else {
         $model = $_SESSION['models'][$_SESSION['lastUsedModelID']];
     }
     $files = array(MP_DIR_MODELS . '/' . $model['pdb']);
     $files = array_merge($files, $model['primaryDownloads']);
     $zipfile = makeZipForFiles($_SESSION['dataDir'], $files);
     // These lines may be required by Internet Explorer
     header("Pragma: public");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     // See PHP manual on header() for how this works.
     header('Content-type: application/zip');
     header('Content-Disposition: attachment; filename="' . $model['id'] . '.zip"');
     mpReadfile($zipfile);
     unlink($zipfile);
     die;
     // don't output the HTML version of this page into that nice file!
 }
Example #2
0
 /**
 * FUNKY: This turns into a binary file download rather than an HTML page,
 * and then calls die(), leaving the user on the original HTML page.
 *
 * This code has been shown to cause cancer in lab rats.
 */
 function onDownloadMarkedZip()
 {
     // Input files come with absolute paths, so we have to check them against
     // our session directory to avoid security holes!
     $basedir = realpath($_SESSION['dataDir']);
     $files = array();
     foreach ($_REQUEST['zipfiles'] as $file) {
         $file = realpath($file);
         if (!$file || !startsWith($file, $basedir)) {
             continue;
         }
         $files[] = substr($file, strlen($basedir) + 1);
     }
     //print_r($files);
     $zipfile = makeZipForFiles($basedir, $files);
     // These lines may be required by Internet Explorer
     header("Pragma: public");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     // See PHP manual on header() for how this works.
     header('Content-type: application/zip');
     header('Content-Disposition: attachment; filename="molprobity.zip"');
     mpReadfile($zipfile);
     unlink($zipfile);
     die;
     // don't output the HTML version of this page into that nice file!
 }