org.pdb.query.simple.AdvancedKeywordQueryText Search$query"; $context = stream_context_create(array('http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => $xml)) ); $output = file_get_contents($restQueryUrl, false, $context); $n = strlen($output)/5; if ($n == 0) { $output = "ERROR: \"$query\" not found"; } else { if (strlen($query) == 4 && $n != 1) { $QQQQ = strtoupper($query); if (strpos("123456789", substr($QQQQ, 0, 1)) == 0 && strpos($output, $QQQQ) > 0) { $output = "$QQQQ\n".$output.str_replace("$QQQQ\n", "",$output); } } if ($n > 50) { $output = substr($output, 0, 250); } $output = str_replace("\n",",",$output); //http://www.rcsb.org/pdb/rest/customReport?pdbids=1crn,1d66,1blu,&customReportColumns=structureId,structureTitle $output = $restReportUrl."?pdbids=".$output."&customReportColumns=structureId,structureTitle"; $output = "".file_get_contents($output).""; } } else { $myerror = "jsmol.php cannot use $call with $database"; } } else if ($call == "getRawDataFromDatabase") { $isBinary = (strpos(".gz", $query) >= 0); if ($database != "_") $query = $database.$query; if (strpos($query, '://') == 0) { $output = ""; } else if (strpos($query, '?POST?') > 0) { list($query,$data) = explode('?POST?', $query, 2); $context = stream_context_create(array('http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => $data)) ); $output = file_get_contents($query, false, $context); } else { $output = file_get_contents($query); } } else if ($call == "saveFile") { $imagedata = $_REQUEST["data"];//getValueSimple($values, "data", ""); don't want to convert " to _ here $filename = getValueSimple($values, "filename", ""); $contentType = getValueSimple($values, "mimetype", "application/octet-stream"); if ($encoding == "base64") { $imagedata = base64_decode($imagedata); $encoding = ""; } } else { $myerror = "jsmol.php unrecognized call: $call"; } ob_start(); if ($myerror != "") { $output = $myerror; } else { if ($imagedata != "") { $output = $imagedata; header('Content-Type: '.$contentType); if ($filename != "") { header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename=\"$filename\""); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); } } else { header('Access-Control-Allow-Origin: *'); if ($isBinary) { header('Content-Type: text/plain; charset=x-user-defined'); } else { header('Content-Type: application/json'); } } if ($encoding == "base64") { $output = ";base64,".base64_encode($output); } } header('Last-Modified: '.date('r')); header('Accept-Ranges: bytes'); header('Content-Length: '.strlen($output)); print($output); ob_end_flush(); ?>