X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=site%2Fphp%2Fjsmol.php;fp=site%2Fphp%2Fjsmol.php;h=1917b925d3f32f867994ea2af135fa7ebfed1627;hb=4231d40261fef32ce4570a6bbad0d35df44e8baf;hp=0000000000000000000000000000000000000000;hpb=c07eb2c5794833bd0241000d6844d783fe10cb82;p=jalview.git
diff --git a/site/php/jsmol.php b/site/php/jsmol.php
new file mode 100644
index 0000000..1917b92
--- /dev/null
+++ b/site/php/jsmol.php
@@ -0,0 +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();
+?>
+