<?php /** DAS proxy. PHP version. * Proxies requests to DAS Registry and DAS servers. Query parameters: * s Server URL * m Method (one of: sequence, features, types, stylesheet, registry) * q DAS segment (only required for sequence and features methods) * t HTTP timeout (default is 5 seconds) * * Author Fernando Martinez <*****@*****.**> */ session_start(); include_once "DasProxy.php"; set_time_limit(300); // modify script execution time (in secs) as needed. Set to 0 for limitless // All responses, including error messages, must be valid XML header('Content-type: text/xml'); $url = DasProxy::getUrl(); $timeout = DasProxy::getTimeout(); echo DasProxy::getResponse($url, $timeout);
/** * Get URL of DAS server or DAS registry */ function getUrl() { // Get query parameters $server = ""; $method = ""; $id = ""; $reg_authority = ""; $reg_label = ""; $reg_type = ""; if (isset($_REQUEST['s'])) { $server = $_REQUEST['s']; $method = $_REQUEST['m']; $id = $_REQUEST['q']; $reg_authority = $_REQUEST['a']; $reg_label = $_REQUEST['l']; $reg_type = $_REQUEST['c']; } elseif (isset($ARGV[0])) { $server = $ARGV[0]; $method = $ARGV[1]; $id = $ARGV[2]; $reg_authority = $ARGV[3]; $reg_label = $ARGV[4]; $reg_type = $ARGV[5]; } // Check DasProxy::checkParam("server", $server); DasProxy::checkParam("method", $method); // Check server has trailing slash $last_char = substr($server, -1, 1); if (!($last_char == "/")) { $server .= "/"; } // Build URL $url = ""; if ($method == "sequence" || $method == "features") { DasProxy::checkParam("id", $id); $url = $server . $method . "?segment=" . $id; } elseif ($method == "pdb") { DasProxy::checkParam("id", $id); $url = $server . $id; } elseif ($method == "alignment") { DasProxy::checkParam("id", $id); $url = $server . $method . "?query=" . $id; } elseif ($method == "ontology") { DasProxy::checkParam("id", $id); $url = $server . $method . "?query=" . $id; error_log("here and url=" . $url . " and id=" . $id); } elseif ($method == "types" || $method == "stylesheet") { $url = $server . $method; } elseif ($method == "registry") { $url = $server; if (strlen($reg_authority) > 0) { $url .= "?authority=" . $reg_authority; } if (strlen($reg_label) > 0) { if (strlen($reg_authority) > 0) { $url .= "&label=" . $reg_label; } else { $url .= "?label=" . $reg_label; } } if (strlen($reg_type) > 0) { if (strlen($reg_authority) > 0 || strlen($reg_label) > 0) { $url .= "&type=" . $reg_type; } else { $url .= "?type=" . $reg_type; } } } else { error_log("Method not allowed: " . $method); } return $url; }