Ejemplo n.º 1
0
 /**
  * Execute the request to get the ebook binary string, in case of success, the file
  * will be outputed and forced to download.
  * @throws Exception
  */
 public function download()
 {
     // GENERATE THE CURL HANDLER
     $request = new Server\Request(Server\Config\SysConfig::$BASE_CONNECT_URI . Server\Config\SysConfig::$BASE_DOWNLOAD . 'get.php', $this->verbose);
     $request->authenticate(false);
     $request->create();
     $request->setPost($this->data);
     try {
         // SEND IT, IF OKAY, THE __TOSTRING WILL BE THE EBOOK BINARY STRING
         $request->execute();
     } catch (Exception $e) {
         throw new Exception($e->getMessage(), $e->getCode());
     }
     // SET THE HEADERS, IF YOU WANT TO PUT ANOTHER NAME TO THE FILE,
     // HERE IS THE PLACE
     if (!$this->verbose) {
         if (!strpos($request->__toString(), "urn:uuid:")) {
             header('Content-Type: application/epub+zip');
             header('Content-Disposition: attachment; filename="' . md5(time()) . '.epub"');
         } else {
             header('Content-Type: application/vnd.adobe.adept+xml');
             header('Content-Disposition: attachment; filename="' . md5(time()) . '.acsm"');
         }
         header("Content-Transfer-Encoding: binary");
         header('Expires: 0');
         header('Pragma: no-cache');
         header("Content-Length: " . strlen($request));
         // EXIT THE PROGRAM WITH THE BINARY REQUEST.
         $request = utf8_decode($request->__toString());
         exit($request);
     }
 }
Ejemplo n.º 2
0
 /**
  * Get the XML STRING from our server, we do not handle the XML data, only output this
  * string, YOU MUST HANDLE THIS AND INSERT INTO YOUR DATABASE, see the manual if needed.
  *
  * @return String // ONIX XML STRING
  * @throws Exception
  */
 public function get()
 {
     // GENERATE THE CURL HANDLER
     $request = new Server\Request(Server\Config\SysConfig::$BASE_CONNECT_URI . Server\Config\SysConfig::$BASE_DOWNLOAD . 'list.php', $this->verbose);
     $request->authenticate(false);
     $request->create();
     // IF HAS FILTERS, ADD THEN TO THE POST
     if (isset($this->filter)) {
         $this->data['filter']['items'] = $this->filter;
     }
     $request->setPost($this->data);
     try {
         // SEND IT, IF OKAY, THE __TOSTRING WILL BE THE ONIX XML RESPONSE
         $request->execute();
     } catch (Exception $e) {
         throw new Exception($e->getMessage(), $e->getCode());
     }
     return $request->__toString();
 }