X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fphp%2Fjsmol.php;fp=site%2Fphp%2Fjsmol.php;h=1917b925d3f32f867994ea2af135fa7ebfed1627;hp=5871d4a58e14bbf28534e9987ec4c758ca5aff25;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/php/jsmol.php b/site/php/jsmol.php index 5871d4a..1917b92 100644 --- a/site/php/jsmol.php +++ b/site/php/jsmol.php @@ -1,198 +1,198 @@ -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(); -?> - +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(); +?> +