diff options
author | tcit <tcit@tcit.fr> | 2014-09-28 17:20:35 +0200 |
---|---|---|
committer | tcit <tcit@tcit.fr> | 2014-09-28 17:20:35 +0200 |
commit | 9f86454b48dec3c9ecfee8da224112eef0f61441 (patch) | |
tree | 22dc93b1e48a26aba9b30fce507b33865d765b7c /inc/poche/WallabagEBooks.class.php | |
parent | b852df020c68ad6bc94df73cb1025c6b64ec10a6 (diff) | |
download | wallabag-9f86454b48dec3c9ecfee8da224112eef0f61441.tar.gz wallabag-9f86454b48dec3c9ecfee8da224112eef0f61441.tar.zst wallabag-9f86454b48dec3c9ecfee8da224112eef0f61441.zip |
deleting send to kindle function
Diffstat (limited to 'inc/poche/WallabagEBooks.class.php')
-rw-r--r-- | inc/poche/WallabagEBooks.class.php | 69 |
1 files changed, 4 insertions, 65 deletions
diff --git a/inc/poche/WallabagEBooks.class.php b/inc/poche/WallabagEBooks.class.php index 9dc545df..2ddece61 100644 --- a/inc/poche/WallabagEBooks.class.php +++ b/inc/poche/WallabagEBooks.class.php | |||
@@ -165,7 +165,7 @@ class WallabagMobi extends WallabagEBooks | |||
165 | * @author Sander Kromwijk | 165 | * @author Sander Kromwijk |
166 | */ | 166 | */ |
167 | 167 | ||
168 | public function produceMobi($sendByMail = FALSE) | 168 | public function produceMobi() |
169 | { | 169 | { |
170 | 170 | ||
171 | Tools::logm('Starting to produce Mobi file'); | 171 | Tools::logm('Starting to produce Mobi file'); |
@@ -194,70 +194,9 @@ class WallabagMobi extends WallabagEBooks | |||
194 | } | 194 | } |
195 | $mobi->setContentProvider($content); | 195 | $mobi->setContentProvider($content); |
196 | 196 | ||
197 | if (!$sendByMail) { | 197 | // we offer file to download |
198 | // we offer file to download | 198 | $mobi->download($this->bookFileName.'.mobi'); |
199 | $mobi->download($this->bookFileName.'.mobi'); | 199 | Tools::logm('Mobi file produced'); |
200 | Tools::logm('Mobi file produced'); | ||
201 | } | ||
202 | else { | ||
203 | ## ## | ||
204 | # Not working yet !!! # | ||
205 | ## ## | ||
206 | // we send file to kindle | ||
207 | |||
208 | Tools::logm('Preparing to send file by email'); | ||
209 | |||
210 | $error = FALSE; | ||
211 | # testing Mail function | ||
212 | if (!function_exists('mail')) { | ||
213 | $error = _("Mail function is disabled. You can't send emails from your server"); | ||
214 | } | ||
215 | |||
216 | $char_in = array('/', '.', ',', ':', '|'); # we sanitize filename to avoid conflicts with special characters (for instance, / goes for a directory) | ||
217 | $mobiExportName = preg_replace('/\s+/', '-', str_replace($char_in, '-', $this->bookFileName)) . '.mobi'; | ||
218 | |||
219 | $file = 'cache/' . $mobiExportName; | ||
220 | $mobi->save($file); | ||
221 | |||
222 | $file_size = filesize($file); | ||
223 | $filename = basename($file); | ||
224 | $handle = fopen($file, "r"); | ||
225 | $content = fread($handle, $file_size); | ||
226 | fclose($handle); | ||
227 | $content = chunk_split(base64_encode($content)); | ||
228 | |||
229 | $uid = md5(uniqid(time())); | ||
230 | |||
231 | //generate header for mail | ||
232 | $header = "From: wallabag <". $this->wallabag->user->email .">\r\n"; | ||
233 | $header .= "MIME-Version: 1.0\r\n"; | ||
234 | $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; | ||
235 | $header .= "This is a multi-part message in MIME format.\r\n"; | ||
236 | $header .= "--".$uid."\r\n"; | ||
237 | $header .= "Content-type:text/plain; charset=iso-8859-1\r\n"; | ||
238 | $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; | ||
239 | $header .= "send via wallabag\r\n\r\n"; | ||
240 | $header .= "--".$uid."\r\n"; | ||
241 | $header .= "Content-Type: application/x-mobipocket-ebook; name=\"".$filename."\"\r\n"; | ||
242 | $header .= "Content-Transfer-Encoding: base64\r\n"; | ||
243 | $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"; | ||
244 | $header .= $content."\r\n\r\n"; | ||
245 | $header .= "--".$uid."--"; | ||
246 | |||
247 | # trying to get the kindle email adress | ||
248 | if (!$this->wallabag->user->getConfigValue('kindleemail')) | ||
249 | { | ||
250 | $error = _("You didn't set your kindle's email adress !"); | ||
251 | } | ||
252 | if (!$error) { | ||
253 | mail($this->wallabag->user->getConfigValue('kindleemail'), '[wallabag] ' . $this->bookTitle, "", $header ); | ||
254 | $messages->add('s', _('The email has been sent to your kindle !')); | ||
255 | Tools::logm('Email sent'); | ||
256 | } else { | ||
257 | $messages->add('e', $error); | ||
258 | Tools::logm($error); | ||
259 | } | ||
260 | } | ||
261 | } | 200 | } |
262 | } | 201 | } |
263 | 202 | ||