From d0e4f6bc6bdcc926882899d54eb0b2318696d725 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Mon, 17 Dec 2012 10:06:04 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.services.php | 59 +++++++++++++++++++----- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 17e039e76..fed986163 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -12,15 +12,61 @@ class wsServices extends cubeFlashGateway { } public function sendEmail() { + if (!$this->_checkHash()) { + return; + } + // Send the email + $mail = new cubeMail(); + $mail->returnPath = 'postmaster@fluidbook.com'; + $mail->acknowledge = isset($this->args['askAcknowledge']) && $this->args['askAcknowledge']; + $mail->charset = 'UTF-8'; + $mail->to = $this->args['email']; + $mail->from = $this->args['fromname'] . '<' . $this->args['fromemail'] . '>'; + $mail->subject = $this->args['subject']; + $mail->body = $this->args['body']; + $this->xml->addChild('ok', $mail->send() ? '1' : '0'); + } + + protected function _checkHash() { // Check protection hash $hash = md5(substr($this->args['fromemail'], 2, 6) . substr($this->args['email'], 3, 5) . 'SFGHF566!S' . $this->args['id']); if ($hash != $this->args['hash']) { $this->xml->addChild('hashOK', '0'); $this->xml->addChild('ok', '0'); + return false; + } + $this->xml->addChild('hashOK', '1'); + return true; + } + + public function sendBookmarks() { + if (!$this->_checkHash()) { return; - } else { - $this->xml->addChild('hashOK', '1'); } + + $bookmarks = json_decode(base64_decode($this->args['bookmarks'])); + $files = array(); + foreach ($bookmarks as $b) { + $file = $this->getPDFComplex($this->args['book_id'], $b['page'] . '-' . $b['page'] + $b['nb']); + $files[] = array('name' => $b['name'], 'file' => $file['file']); + } + + $limit = 5 * 1024 * 1024; + $groups = array(); + $group = array(); + $groupsize=array(); + foreach ($files as $f) { + $group[]=$f; + $groupsize+=filesize($f['file']); + + if($groupsize>$limit){ + + } + } + + + + // Send the email $mail = new cubeMail(); $mail->returnPath = 'postmaster@fluidbook.com'; @@ -29,15 +75,6 @@ class wsServices extends cubeFlashGateway { $mail->to = $this->args['email']; $mail->from = $this->args['fromname'] . '<' . $this->args['fromemail'] . '>'; $mail->subject = $this->args['subject']; - if (isset($this->args['bookmarks'])) { - $pdf = $this->getPDFComplex($this->args['id'], $this->args['bookmarks']); - $mail->addFile('bookmarks.pdf', $pdf['file']); - } - /* if ($this->args['attachPDFInEmail'] == '1') { - $doc_name = isset($this->args['attachmentName'])?$this->args['attachmentName']:'document.pdf'; - $file = fwsConverter::extractPages($this->args['id'], $this->args['attachPDFInEmail'], false); - $mail->addFile($doc_name, $file); - } */ $mail->body = $this->args['body']; $this->xml->addChild('ok', $mail->send() ? '1' : '0'); } -- 2.39.5