Пример #1
0
 protected function soapCall($action, $parameters = null)
 {
     // deep black magic
     $response = $this->soap->{$action}($parameters);
     $response = \Metaclassing\Utility::encodeJson($response);
     $response = \Metaclassing\Utility::decodeJson($response);
     $this->log[] = ['request' => ['action' => $action, 'parameters' => $parameters], 'response' => ['response' => $response]];
     return $response;
 }
Пример #2
0
 public function search($query)
 {
     // Translate the search array into JSON
     $json = \Metaclassing\Utility::encodeJson($query);
     // Post the JSON
     $response = $this->post($this->baseurl . '/information/api/search/', $this->baseurl, $json);
     // return an assoc array with results
     return \Metaclassing\Utility::decodeJson($response);
 }
Пример #3
0
 public function getjson($url, $referer = '')
 {
     if ($this->token) {
         $url .= '?token=' . $this->token;
     }
     curl_setopt($this->curl, CURLOPT_URL, $url);
     curl_setopt($this->curl, CURLOPT_REFERER, $referer);
     $response = $this->curl_exec();
     if (!\Metaclassing\Utility::isJson($response)) {
         throw new \Exception('Did not get JSON response from web service url ' . $url . ', got ' . $response);
     }
     $response = \Metaclassing\Utility::decodeJson($response);
     if (isset($response['status_code']) && $response['status_code'] != 200) {
         throw new \Exception('Did not get a 200 response from web service for last call,' . ' url was ' . $url . ' response was ' . \Metaclassing\Utility::dumperToString($response));
     }
     return $response;
 }
Пример #4
0
 public static function recursiveArrayBinaryValuesToBase64($arr)
 {
     if (is_array($arr)) {
         foreach ($arr as $key => $value) {
             if (is_array($value)) {
                 $arr[$key] = \Metaclassing\Utility::recursiveArrayBinaryValuesToBase64($value);
             } elseif (\Metaclassing\Utility::isBinary($value)) {
                 $arr[$key] = base64_encode($value);
             }
         }
     }
     return $arr;
 }
Пример #5
0
 /**
  * Short description for function.
  *
  * Long description (if any) ...
  *
  * @param string $FOOT_TEXT Parameter description (if any) ...
  * @param string $FOOT_LINK Parameter description (if any) ...
  *
  * @return string Return description (if any) ...
  */
 public function footer($FOOT_TEXT = 'Home', $FOOT_LINK = '/')
 {
     $size = memory_get_usage(true);
     $unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
     $MEMORYUSED = @round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[$i];
     $this->set('MEMORYUSED', $MEMORYUSED);
     $this->set('LOADTIME', number_format($this->timer_diff(), 5));
     $this->set('FOOT_TEXT', $FOOT_TEXT);
     $this->set('FOOT_LINK', $FOOT_LINK);
     global $QUERYCOUNT;
     global $DB;
     $this->set('QUERYCOUNT', $QUERYCOUNT + intval(count($DB->QUERIES)));
     $this->set('RECORDCOUNT', intval($DB->RECORDCOUNT));
     if (isset($_SESSION['DEBUG']) && $_SESSION['DEBUG'] > 5) {
         $this->set('FOOTERDEBUG', \Metaclassing\Utility::dumper($DB));
     }
     return $this->parse(INCLUDEDIR . '/footer.template.html');
 }
Пример #6
0
 protected function httpDelete($uri)
 {
     $this->log[] = ['request' => ['method' => 'DELETE', 'uri' => $uri]];
     $response = \Httpful\Request::delete($uri)->addHeader('X-Auth-Email', $this->email)->addHeader('X-Auth-Key', $this->apikey)->expects(\Httpful\Mime::JSON)->parseWith(function ($body) {
         return \Metaclassing\Utility::decodeJson($body);
     })->send()->body;
     $this->log[count($this->log) - 1]['response'] = $response;
     if ($response['success'] != true) {
         throw new \Exception("delete to {$uri} unsuccessful");
     }
     return $response['result'];
 }