die("can only run from cli"); } $options = getopt('fi::'); if (!isset($options['i'])) { die("Usage: php {$argv[0]} [-f] -i SEQUENCCENAME\n"); } $data = array(); // set the type argument if (isset($options['f'])) { $data['type'] = 'full'; } else { $data['type'] = 'seed'; } $data['fmt'] = 'stockholm'; $data['name'] = $options['i']; $response = doPOST('http://rfam.janelia.org/cgi-bin/getalignment', http_build_query($data)); $lines = split("\n", $response); $data = array(); $control = array(); foreach ($lines as $line) { if (strlen($line) > 2 && $line[0] == '#') { // line is a control line $count = preg_match("/^#=([A-Z_]{1,5})[ \t]+([A-Za-z_]+)[ \t]+([^\r]*)\$/", $line, $matches); if ($count > 0) { if (!isset($control[$matches[1]])) { $control[$matches[1]] = array(); } if (!isset($control[$matches[1]][$matches[2]])) { $control[$matches[1]][$matches[2]] = array(); } $control[$matches[1]][$matches[2]][] = $matches[3];
function routeRequest($gpio) { $method = $_SERVER['REQUEST_METHOD']; $request_uri = $_SERVER['REQUEST_URI']; $root = $_SERVER['DOCUMENT_ROOT']; $script = $_SERVER['SCRIPT_FILENAME']; $path = pathinfo($script); $context = substr($path['dirname'], strlen($root)); $uri = substr($request_uri, strlen($context)); $vars = explode('/', $uri); global $SERVER_VERSION; header("Server: " + $SERVER_VERSION); if ($method == "GET") { doGET($gpio, $vars); } else { if ($method == "POST") { doPOST($gpio, $vars); } else { sendError(405, "Not Allowed"); } } }
http_response_code(500); die; } else { $id = $stmt->insert_id; $data = getRecord($conn, $id); printJsonObject($id, $data); http_response_code(201); } } function doGET($conn, $id) { $data = getRecord($conn, $id); printJsonObject($id, $data); } switch ($method) { case 'PUT': doPUT($conn, $req); break; case 'POST': session_start(); doPOST($conn, $req); saveConfigValue($conn, 'add_from', $req['from']); saveConfigValue($conn, 'add_to', $req['to']); saveConfigValue($conn, 'add_from_currency', $req['fromCurrency']); session_write_close(); break; case 'GET': doGET($conn, $_GET["id"]); break; } $conn->close();