Esempio n. 1
0
 /**
  *
  * @param string $strFileDebug
  */
 public function setFileDebug($strFileDebug)
 {
     $this->objDebug->setFileDebug($strFileDebug);
 }
Esempio n. 2
0
 /**
  * @todo Update the error class or better make a implementation of it
  * @return IO
  */
 public function InputResponse($strResponse, $objCodifyEngine)
 {
     $objDebug = Debug::getInstance();
     // Check for start and end tag
     if (strpos($strResponse, "<|@|") === false || strpos($strResponse, "|@|>") === false) {
         $objDebug->addDebug("Error CtoComIOImpl_Default", substr($strResponse, 0, 4096));
         throw new \RuntimeException("Could not find start or endtag from response.");
     }
     // Find position of start/end - tag
     $intStart = intval(strpos($strResponse, "<|@|") + 4);
     $intLength = intval(strpos($strResponse, "|@|>") - $intStart);
     $strResponse = substr($strResponse, $intStart, $intLength);
     $strResponse = base64_decode($strResponse);
     $strResponse = @gzuncompress($strResponse);
     // Check if uncompress works
     if ($strResponse === false) {
         throw new \RuntimeException("Error on uncompressing the response. Maybe wrong API-Key or ctoCom version.");
     }
     // Decrypt
     $strResponse = $objCodifyEngine->Decrypt($strResponse);
     // Deserialize response
     $arrResponse = unserialize($strResponse);
     // Check if we have a array
     if (is_array($arrResponse) == false) {
         $objDebug->addDebug("Error CtoComIOImpl_Default", substr($arrResponse, 0, 4096));
         throw new \RuntimeException("Response is not an array. Maybe wrong API-Key or cryptionengine.");
     }
     // Clean array
     $arrResponse = $this->cleanUp($arrResponse);
     $objContainer = new IO();
     $objContainer->setSuccess($arrResponse["success"]);
     $objContainer->setResponse($arrResponse["response"]);
     $objContainer->setSplitcontent($arrResponse["splitcontent"]);
     $objContainer->setSplitcount($arrResponse["splitcount"]);
     $objContainer->setSplitname($arrResponse["splitname"]);
     // Set error
     if ($arrResponse["error"] != "") {
         $objError = new Error();
         $objError->setID($arrResponse["error"]["id"]);
         $objError->setObject($arrResponse["error"]["object"]);
         $objError->setMessage($arrResponse["error"]["msg"]);
         $objError->setRPC($arrResponse["error"]["rpc"]);
         $objError->setClass($arrResponse["error"]["class"]);
         $objError->setFunction($arrResponse["error"]["function"]);
         $objError->setException($arrResponse["error"]["exception"]);
         $objContainer->setError($objError);
     }
     return $objContainer;
 }