public function queryGet($query) { $url = $this->getUrl(); $data = array('topicmap' => $this->getTopicMap(), 'tolog' => $query); if ($this->getSyntax() != '') { $data['syntax'] = $this->getSyntax(); } KBIDebug::info(array($url, $data)); return $this->requestCurl($url, $data); }
/** * Generates final query from skeleton using parameters and/or XSLT transformation. * * @return string */ public function proccessQuery(&$options) { $parameters = $this->getParameters(); $xslt = $this->getXslt(); /* output parameter */ $options = array_merge($this->getOptions('GET'), $this->getOptions('POST')); if (!empty($parameters)) { if (is_array($parameters)) { $delimiter = $this->getDelimiter(); $replace_pairs = array(); foreach ($parameters as $name => $value) { $replace_pairs[$delimiter . $name . $delimiter] = $value; } KBIDebug::log($replace_pairs, 'Applying parameters.'); $this->query = strtr($this->query, $replace_pairs); } elseif (empty($this->query) && is_string($parameters)) { // in case query is empty and parameters is string then we assume parameters to be query itself KBIDebug::info('Parameters considered as query.'); $this->setQuery($parameters); } } if (!empty($xslt)) { $xml = new DOMDocument(); if ($xml->loadXML($this->query)) { // Create XSLT document $xsl_document = new DOMDocument(); $xsl_document->loadXML($xslt, LIBXML_NOCDATA); // Process XSLT $xslt = new XSLTProcessor(); $xslt->importStylesheet($xsl_document); KBIDebug::info('Applying pre-query transformation.'); $this->query = $xslt->transformToXML($xml); } else { KBIDebug::info('Query is not valid XML therefore XSLT could not be executed.'); } } return $this->getQuery(); }
public function cancelTask($taskName) { $request_xml = new \SimpleXMLElement("<CancelationRequest></CancelationRequest>"); $server_id = $this->getMinerId(); if ($this->getMinerId() === null) { throw new \Exception('LISpMiner ID was not provided.'); } $url = trim($this->getUrl(), '/'); $client = $this->getRestClient(); $credentials = $this->getUser(); switch ($this->getPooler()) { case 'grid': $url = "{$url}/miners/{$server_id}/tasks/grid/{$taskName}"; break; case 'proc': $url = "{$url}/miners/{$server_id}/tasks/proc/{$taskName}"; break; case 'task': default: $url = "{$url}/miners/{$server_id}/tasks/task/{$taskName}"; } KBIDebug::info(array($url), 'Canceling task'); $response = $client->put($url, $request_xml->asXML(), $credentials); if ($response->isSuccess()) { return $response->getBody(); } return $this->parseResponse($response); }
public function getDataDescription() { $postdata = array('action' => 'getDescription', 'id' => '', 'content' => ''); $url = $this->getUrl(); KBIDebug::info(array($url, $postdata)); $dd = $this->requestCurlPost($url, $postdata); $replace1 = '<?xml version="1.0" encoding="UTF-8"?>'; $replace2 = '</result>'; $replace3 = '/\\<result milisecs=".*">/U'; //$replace3 = '/\<!-- kbiLink({.*\}) \/kbiLink -->/U'; $dd = str_replace($replace1, '', $dd); $dd = str_replace($replace2, '', $dd); $dd = preg_replace($replace3, '', $dd); return trim($dd); }
public function requestGet($url, $_data) { $data = array(); while (list($n, $v) = each($_data)) { $data[] = "{$n}=" . urlencode($v); } $data = implode('&', $data); $p = file_get_contents("{$url}?{$data}"); KBIDebug::info("{$url}?{$data}", 'GET'); return $p; }
public function cancelTask($taskName) { $url = trim($this->getUrl(), '/'); switch ($this->getPooler()) { case 'grid': $url = "{$url}/TaskGen/GridPool/Cancel"; break; case 'proc': $url = "{$url}/TaskGen/ProcPool/Cancel"; break; case 'task': default: $url = "{$url}/TaskGen/TaskPool/Cancel"; } $data = array('guid' => $this->getMinerId(), 'taskName' => $taskName); KBIDebug::info(array($url, $data)); $dd = $this->requestCurl($url, $data); return trim($dd); }
function requestCurl($url, $_data) { $data = array(); while (list($n, $v) = each($_data)) { $data[] = "{$n}=" . urlencode($v); } $data = implode('&', $data); KBIDebug::info("{$url}?{$data}"); $ch = curl_init("{$url}?{$data}"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); //optionally you can check the response and see what the HTTP Code returned was $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $response; }