aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/3rdparty/libraries
diff options
context:
space:
mode:
authortcit <tcit@tcit.fr>2014-07-24 21:56:04 +0200
committertcit <tcit@tcit.fr>2014-07-24 21:56:04 +0200
commitfb9df0c269f36703909b8b259abbdbed29881ecd (patch)
tree03069262fe6a7bd5891f5649d31fc057b3ca8541 /inc/3rdparty/libraries
parentc70bfefc68fcc96b1ce57845e5b2942a596239ec (diff)
downloadwallabag-fb9df0c269f36703909b8b259abbdbed29881ecd.tar.gz
wallabag-fb9df0c269f36703909b8b259abbdbed29881ecd.tar.zst
wallabag-fb9df0c269f36703909b8b259abbdbed29881ecd.zip
use directly MOBIClass
Diffstat (limited to 'inc/3rdparty/libraries')
-rw-r--r--inc/3rdparty/libraries/MOBIClass/CharacterEntities.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/CharacterEntities.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/ContentProvider.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/ContentProvider.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/EXTHHelper.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/EXTHHelper.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/FileByte.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/FileByte.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/FileDate.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/FileDate.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/FileElement.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/FileElement.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/FileInt.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/FileInt.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/FileObject.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/FileObject.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/FileRecord.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/FileRecord.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/FileShort.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/FileShort.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/FileString.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/FileString.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/FileTri.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/FileTri.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/Http.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/Http.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/ImageHandler.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/ImageHandler.php)24
-rw-r--r--inc/3rdparty/libraries/MOBIClass/MOBI.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/MOBI.php)27
-rw-r--r--inc/3rdparty/libraries/MOBIClass/MOBIFile.php157
-rw-r--r--inc/3rdparty/libraries/MOBIClass/MultipleFileHandler.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/MultipleFileHandler.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/OnlineArticle.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/OnlineArticle.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/PalmRecord.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/PalmRecord.php)36
-rw-r--r--inc/3rdparty/libraries/MOBIClass/Prc.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/Prc.php)4
-rw-r--r--inc/3rdparty/libraries/MOBIClass/PreprocessedArticle.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/PreprocessedArticle.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/RecognizeURL.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/RecognizeURL.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/Record.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/Record.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/RecordFactory.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/RecordFactory.php)18
-rw-r--r--inc/3rdparty/libraries/MOBIClass/Settings.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/Settings.php)6
-rw-r--r--inc/3rdparty/libraries/MOBIClass/constants.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/constants.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/downloaders/FanFictionNet.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/downloaders/FanFictionNet.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/http_build_url.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/http_build_url.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/readability/JSLikeHTMLElement.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/readability/JSLikeHTMLElement.php)0
-rw-r--r--inc/3rdparty/libraries/MOBIClass/readability/Readability.php (renamed from inc/3rdparty/libraries/send2kindle/MOBIClass/readability/Readability.php)0
-rw-r--r--inc/3rdparty/libraries/mpdf/mpdf.php2
-rw-r--r--inc/3rdparty/libraries/send2kindle/MOBIClass/PEOFRecord.php49
-rw-r--r--inc/3rdparty/libraries/send2kindle/MOBIClass/PFCISRecord.php59
-rw-r--r--inc/3rdparty/libraries/send2kindle/MOBIClass/PFLISRecord.php58
-rw-r--r--inc/3rdparty/libraries/send2kindle/api.php234
-rw-r--r--inc/3rdparty/libraries/send2kindle/images.php136
-rw-r--r--inc/3rdparty/libraries/send2kindle/io.php250
-rw-r--r--inc/3rdparty/libraries/send2kindle/readability.php249
-rw-r--r--inc/3rdparty/libraries/send2kindle/send.php69
-rw-r--r--inc/3rdparty/libraries/send2kindle/storage.php230
-rw-r--r--inc/3rdparty/libraries/send2kindle/utils.php37
41 files changed, 200 insertions, 1445 deletions
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/CharacterEntities.php b/inc/3rdparty/libraries/MOBIClass/CharacterEntities.php
index de896f87..de896f87 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/CharacterEntities.php
+++ b/inc/3rdparty/libraries/MOBIClass/CharacterEntities.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/ContentProvider.php b/inc/3rdparty/libraries/MOBIClass/ContentProvider.php
index dcf9c4de..dcf9c4de 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/ContentProvider.php
+++ b/inc/3rdparty/libraries/MOBIClass/ContentProvider.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/EXTHHelper.php b/inc/3rdparty/libraries/MOBIClass/EXTHHelper.php
index 275142bf..275142bf 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/EXTHHelper.php
+++ b/inc/3rdparty/libraries/MOBIClass/EXTHHelper.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileByte.php b/inc/3rdparty/libraries/MOBIClass/FileByte.php
index 05fc7d04..05fc7d04 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileByte.php
+++ b/inc/3rdparty/libraries/MOBIClass/FileByte.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileDate.php b/inc/3rdparty/libraries/MOBIClass/FileDate.php
index 2284eba2..2284eba2 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileDate.php
+++ b/inc/3rdparty/libraries/MOBIClass/FileDate.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileElement.php b/inc/3rdparty/libraries/MOBIClass/FileElement.php
index 552d04a8..552d04a8 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileElement.php
+++ b/inc/3rdparty/libraries/MOBIClass/FileElement.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileInt.php b/inc/3rdparty/libraries/MOBIClass/FileInt.php
index ebe86f86..ebe86f86 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileInt.php
+++ b/inc/3rdparty/libraries/MOBIClass/FileInt.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileObject.php b/inc/3rdparty/libraries/MOBIClass/FileObject.php
index 0df17df1..0df17df1 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileObject.php
+++ b/inc/3rdparty/libraries/MOBIClass/FileObject.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileRecord.php b/inc/3rdparty/libraries/MOBIClass/FileRecord.php
index 494a72e4..494a72e4 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileRecord.php
+++ b/inc/3rdparty/libraries/MOBIClass/FileRecord.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileShort.php b/inc/3rdparty/libraries/MOBIClass/FileShort.php
index 9921ea82..9921ea82 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileShort.php
+++ b/inc/3rdparty/libraries/MOBIClass/FileShort.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileString.php b/inc/3rdparty/libraries/MOBIClass/FileString.php
index 16e906a6..16e906a6 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileString.php
+++ b/inc/3rdparty/libraries/MOBIClass/FileString.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileTri.php b/inc/3rdparty/libraries/MOBIClass/FileTri.php
index 6cacc0b0..6cacc0b0 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/FileTri.php
+++ b/inc/3rdparty/libraries/MOBIClass/FileTri.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/Http.php b/inc/3rdparty/libraries/MOBIClass/Http.php
index 9e5852e3..9e5852e3 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/Http.php
+++ b/inc/3rdparty/libraries/MOBIClass/Http.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/ImageHandler.php b/inc/3rdparty/libraries/MOBIClass/ImageHandler.php
index f620fc1f..bcb48e9f 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/ImageHandler.php
+++ b/inc/3rdparty/libraries/MOBIClass/ImageHandler.php
@@ -11,18 +11,30 @@ class ImageHandler {
11 $imgFile = @imagecreatefromstring($data); 11 $imgFile = @imagecreatefromstring($data);
12 12
13 if($imgFile !== false){ 13 if($imgFile !== false){
14 @imagefilter($imgFile, IMG_FILTER_GRAYSCALE); 14 $result = self::CreateImage($imgFile);
15 15 imagedestroy($imgFile);
16 return $result;
17 }
18 return false;
19 }
20 /**
21 * Create an image
22 * @param resource $img Create an image created with createimagetruecolor
23 * @return false|string False if failed, else the data of the image (converted to grayscale jpeg)
24 */
25 public static function CreateImage($img){
26 try{
27 imagefilter($img, IMG_FILTER_GRAYSCALE);
28
16 ob_start(); 29 ob_start();
17 @imagejpeg($imgFile); 30 imagejpeg($img);
18 $image = ob_get_contents(); 31 $image = ob_get_contents();
19 ob_end_clean(); 32 ob_end_clean();
20 33
21 @imagedestroy($imgFile);
22
23 return $image; 34 return $image;
35 }catch(Exception $e){
36 return false;
24 } 37 }
25 return false;
26 } 38 }
27} 39}
28?> 40?>
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/MOBI.php b/inc/3rdparty/libraries/MOBIClass/MOBI.php
index 9532bbf1..17e718c1 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/MOBI.php
+++ b/inc/3rdparty/libraries/MOBIClass/MOBI.php
@@ -18,11 +18,9 @@ require_once(dirname(__FILE__).'/FileTri.php');
18require_once(dirname(__FILE__).'/Http.php'); 18require_once(dirname(__FILE__).'/Http.php');
19require_once(dirname(__FILE__).'/http_build_url.php'); 19require_once(dirname(__FILE__).'/http_build_url.php');
20require_once(dirname(__FILE__).'/ImageHandler.php'); 20require_once(dirname(__FILE__).'/ImageHandler.php');
21require_once(dirname(__FILE__).'/MOBIFile.php');
21require_once(dirname(__FILE__).'/OnlineArticle.php'); 22require_once(dirname(__FILE__).'/OnlineArticle.php');
22require_once(dirname(__FILE__).'/PalmRecord.php'); 23require_once(dirname(__FILE__).'/PalmRecord.php');
23require_once(dirname(__FILE__).'/PEOFRecord.php');
24require_once(dirname(__FILE__).'/PFCISRecord.php');
25require_once(dirname(__FILE__).'/PFLISRecord.php');
26require_once(dirname(__FILE__).'/Prc.php'); 24require_once(dirname(__FILE__).'/Prc.php');
27require_once(dirname(__FILE__).'/PreprocessedArticle.php'); 25require_once(dirname(__FILE__).'/PreprocessedArticle.php');
28require_once(dirname(__FILE__).'/RecognizeURL.php'); 26require_once(dirname(__FILE__).'/RecognizeURL.php');
@@ -43,7 +41,7 @@ require_once(dirname(__FILE__).'/Settings.php');
43 * $mobi->setFileSource($file); //Load a local file without any extra changes 41 * $mobi->setFileSource($file); //Load a local file without any extra changes
44 * $mobi->setData($data); //Load data 42 * $mobi->setData($data); //Load data
45 * 43 *
46 * //If you want, you can set some optional settings 44 * //If you want, you can set some optional settings (see Settings.php for all recognized settings)
47 * $options = array( 45 * $options = array(
48 * "title"=>"Insert title here", 46 * "title"=>"Insert title here",
49 * "author"=>"Author" 47 * "author"=>"Author"
@@ -86,7 +84,7 @@ class MOBI {
86 */ 84 */
87 public function setContentProvider($content){ 85 public function setContentProvider($content){
88 $this->setOptions($content->getMetaData()); 86 $this->setOptions($content->getMetaData());
89 $this->images = $content->getImages(); 87 $this->setImages($content->getImages());
90 $this->setData($content->getTextData()); 88 $this->setData($content->getTextData());
91 } 89 }
92 90
@@ -149,16 +147,9 @@ class MOBI {
149 $mobiHeader = new PalmRecord($settings, $dataRecords, $nRecords, $len, sizeof($this->images)); 147 $mobiHeader = new PalmRecord($settings, $dataRecords, $nRecords, $len, sizeof($this->images));
150 array_unshift($dataRecords, $mobiHeader); 148 array_unshift($dataRecords, $mobiHeader);
151 $dataRecords = array_merge($dataRecords, $this->images); 149 $dataRecords = array_merge($dataRecords, $this->images);
152 $mobiFooter1 = new PFLISRecord($len); 150 $dataRecords[] = $rec->createFLISRecord();
153 $mobiFooter2 = new PFCISRecord($len);
154 $mobiFooter3 = new PEOFRecord($len);
155 $dataRecords[] = $mobiFooter1;
156 $dataRecords[] = $mobiFooter2;
157 $dataRecords[] = $mobiFooter3;
158 /*$dataRecords = array_merge($dataRecords, $mobiFooter);
159 *$dataRecords[] = $rec->createFLISRecord();*
160 $dataRecords[] = $rec->createFCISRecord($len); 151 $dataRecords[] = $rec->createFCISRecord($len);
161 $dataRecords[] = $rec->createEOFRecord();*/ 152 $dataRecords[] = $rec->createEOFRecord();
162 $this->prc = new Prc($settings, $dataRecords); 153 $this->prc = new Prc($settings, $dataRecords);
163 return $this->prc; 154 return $this->prc;
164 } 155 }
@@ -183,7 +174,7 @@ class MOBI {
183 $length = strlen($data); 174 $length = strlen($data);
184 175
185 if($this->debug) return; //In debug mode, don't start the download 176 if($this->debug) return; //In debug mode, don't start the download
186/* 177
187 header("Content-Type: application/x-mobipocket-ebook"); 178 header("Content-Type: application/x-mobipocket-ebook");
188 header("Content-Disposition: attachment; filename=\"".$name."\""); 179 header("Content-Disposition: attachment; filename=\"".$name."\"");
189 header("Content-Transfer-Encoding: binary"); 180 header("Content-Transfer-Encoding: binary");
@@ -192,12 +183,8 @@ class MOBI {
192 header('Pragma: private'); 183 header('Pragma: private');
193 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 184 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
194 header("Content-Length: ".$length); 185 header("Content-Length: ".$length);
195 echo $data;*/
196
197 186
198 $hh = fopen("D:\hakuna.mobi", "w"); 187 echo $data;
199 fwrite($hh, $data);
200 fclose($hh);
201 //Finished! 188 //Finished!
202 } 189 }
203 190
diff --git a/inc/3rdparty/libraries/MOBIClass/MOBIFile.php b/inc/3rdparty/libraries/MOBIClass/MOBIFile.php
new file mode 100644
index 00000000..349227ae
--- /dev/null
+++ b/inc/3rdparty/libraries/MOBIClass/MOBIFile.php
@@ -0,0 +1,157 @@
1<?php
2/**
3 * This is the way MOBI files should be created if you want all features (TOC, images).
4 *
5 * File modified by Dawson for use in eBook Creator
6 * Added pagebreaks and a setting to remove table of contents.
7 */
8
9class MOBIFile extends ContentProvider {
10 const PARAGRAPH = 0;
11 const H2 = 1;
12 const H3 = 2;
13 const IMAGE = 3;
14 const PAGEBREAK = 4;
15
16 private $settings = array("title" => "Unknown Title", "toc" => true);
17 private $parts = array();
18 private $images = array();
19
20 /**
21 * Get the text data (the "html" code)
22 */
23 public function getTextData(){
24 $prefix = "<html><head><guide><reference title='CONTENT' type='toc' filepos=0000000000 /></guide></head><body>";
25
26 $title = "<h1>".$this->settings["title"]."</h1>";
27
28 list($text, $entries) = $this->generateText();
29
30 if($this->settings["toc"]) {
31 $toc = $this->generateTOC($entries); //Generate TOC to get the right length
32 $toc = $this->generateTOC($entries, strlen($prefix)+strlen($toc)+strlen($title)); //Generate the real TOC
33 }
34
35 $suffix = "</body></html>";
36
37 return $prefix.$toc.$title.$text.$suffix;
38 }
39
40 /**
41 * Generate the body's text and the chapter entries
42 * @return array($string, $entries) $string is the html data, $entries
43 * contains the level, the title and the position of the titles.
44 */
45 public function generateText(){
46 $str = "";
47 $entries = array();
48
49 for($i = 0; $i < sizeof($this->parts); $i++){
50 list($type, $data) = $this->parts[$i];
51 $id = "title_".$i;
52 switch($type){
53 case self::PARAGRAPH:
54 $str .= "<p>".$data."</p>";
55 break;
56 case self::PAGEBREAK:
57 $str .= '<mbp:pagebreak/>';
58 break;
59 case self::H2:
60 $entries[] = array("level" => 2, "position" => strlen($str), "title" => $data, "id" => $id);
61 $str .= "<h2 id='" . $id . "'>".$data."</h2>";
62 break;
63 case self::H3:
64 $entries[] = array("level" => 3, "position" => strlen($str), "title" => $data, "id" => $id);
65 $str .= "<h3 id='" . $id . "'>".$data."</h3>";
66 break;
67 case self::IMAGE:
68 $str .= "<img recindex=".str_pad($data+1, 10, "0", STR_PAD_LEFT)." />";
69 break;
70 }
71 }
72 return array($str, $entries);
73 }
74
75 /**
76 * Generate a TOC
77 * @param $entries The entries array generated by generateText
78 * @param $base The zero position
79 */
80 public function generateTOC($entries, $base = 0){
81 $toc = "<h2>Contents</h2>";
82 $toc .= "<blockquote><table summary='Table of Contents'><col/><tbody>";
83 for($i = 0, $len = sizeof($entries); $i < $len; $i++){
84 $entry = $entries[$i];
85 $pos = str_pad($entry["position"]+$base, 10, "0", STR_PAD_LEFT);
86 $toc .= "<tr><td><a href='#".$entry["id"]."' filepos='".$pos."'>".$entry["title"]."</a></td></tr>";
87 }
88 return $toc."</tbody></b></table></blockquote><mbp:pagebreak/>";
89 }
90
91 /**
92 * Get the file records of the images
93 */
94 public function getImages(){
95 return $this->images;
96 }
97
98 /**
99 * Get the metadata
100 */
101 public function getMetaData(){
102 return $this->settings;
103 }
104
105 /**
106 * Change the file's settings. For example set("author", "John Doe") or set("title", "The adventures of John Doe").
107 * @param $key Key of the setting to insert.
108 */
109 public function set($key, $value){
110 $this->settings[$key] = $value;
111 }
112
113 /**
114 * Get the file's settings.
115 */
116 public function get($key){
117 return $this->settings[$key];
118 }
119
120 /**
121 * Append a paragraph of text to the file.
122 * @param string $text The text to insert.
123 */
124 public function appendParagraph($text){
125 $this->parts[] = array(self::PARAGRAPH, $text);
126 }
127
128 /**
129 * Append a chapter title (H2)
130 * @param string $title The title to insert.
131 */
132 public function appendChapterTitle($title){
133 $this->parts[] = array(self::H2, $title);
134 }
135
136 /**
137 * Append a section title (H3)
138 * @param string $title The title to insert.
139 */
140 public function appendSectionTitle($title){
141 $this->parts[] = array(self::H3, $title);
142 }
143
144 public function appendPageBreak() {
145 $this->parts[] = array(self::PAGEBREAK, null);
146 }
147
148 /**
149 * Append an image.
150 * @param resource $img An image file (for example, created by `imagecreate`)
151 */
152 public function appendImage($img){
153 $imgIndex = sizeof($this->images);
154 $this->images[] = new FileRecord(new Record(ImageHandler::CreateImage($img)));
155 $this->parts[] = array(self::IMAGE, $imgIndex);
156 }
157} \ No newline at end of file
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/MultipleFileHandler.php b/inc/3rdparty/libraries/MOBIClass/MultipleFileHandler.php
index e9792816..e9792816 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/MultipleFileHandler.php
+++ b/inc/3rdparty/libraries/MOBIClass/MultipleFileHandler.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/OnlineArticle.php b/inc/3rdparty/libraries/MOBIClass/OnlineArticle.php
index ec3182fe..ec3182fe 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/OnlineArticle.php
+++ b/inc/3rdparty/libraries/MOBIClass/OnlineArticle.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/PalmRecord.php b/inc/3rdparty/libraries/MOBIClass/PalmRecord.php
index 29dc978a..d0de8dfe 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/PalmRecord.php
+++ b/inc/3rdparty/libraries/MOBIClass/PalmRecord.php
@@ -38,32 +38,19 @@ class PalmRecord extends FileObject {
38 "huffmanRecordOffset"=>new FileInt(), 38 "huffmanRecordOffset"=>new FileInt(),
39 "huffmanRecordCount"=>new FileInt(), 39 "huffmanRecordCount"=>new FileInt(),
40 "unused3"=>new FileString(8), 40 "unused3"=>new FileString(8),
41 "exthFlags"=>new FileInt(0x50), 41 "exthFlags"=>new FileInt(0x40),
42 "unknown"=>new FileString(32), 42 "unknown"=>new FileString(32),
43 "drmOffset"=>new FileInt(0xFFFFFFFF), 43 "drmOffset"=>new FileInt(0xFFFFFFFF),
44 "drmCount"=>new FileInt(0xFFFFFFFF), 44 "drmCount"=>new FileShort(0xFFFFFFFF),
45 "drmSize"=>new FileInt(), 45 "drmSize"=>new FileShort(),
46 "drmFlags"=>new FileInt(), 46 "drmFlags"=>new FileInt(),
47 "mobiFiller"=>new FileString(12), 47 "mobiFiller"=>new FileString(72),
48 "offset192"=>new FileShort(0x01),
49 "offset194"=>new FileShort(),
50 "offset196"=>new FileInt(0x01),
51 "offset200"=>new FileInt(),
52 "offset204"=>new FileInt(0x01),
53 "offset208"=>new FileInt(),
54 "offset212"=>new FileInt(0x01),
55 "offset216"=>new FileString(8),
56 "offset224"=>new FileInt(0xFFFFFFFF),
57 "offset228"=>new FileInt(),
58 "offset232"=>new FileString(8),
59 "offset240"=>new FileInt(0x01),
60 "offset244"=>new FileInt(0xFFFFFFFF),
61 //EXTH Header 48 //EXTH Header
62 "exthIdentifier"=>new FileString("EXTH", 4), 49 "exthIdentifier"=>new FileString("EXTH", 4),
63 "exthHeaderLength"=>new FileInt(), 50 "exthHeaderLength"=>new FileInt(),
64 "exthRecordCount"=>new FileInt(), 51 "exthRecordCount"=>new FileInt(),
65 "exthRecords"=>new FileElement(), 52 "exthRecords"=>new FileElement(),
66 "exthPadding"=>new FileString(),//added the 2 extra pad bytes that comes before name/title 53 "exthPadding"=>new FileString(),
67 //"fullNamePadding"=>new FileString(100), 54 //"fullNamePadding"=>new FileString(100),
68 "fullName"=>new FileString() 55 "fullName"=>new FileString()
69 )); 56 ));
@@ -96,7 +83,7 @@ class PalmRecord extends FileObject {
96 } 83 }
97 84
98 if($images > 0){ 85 if($images > 0){
99 $this->elements->get("firstImageIndex")->set($textRecords+2); 86 $this->elements->get("firstImageIndex")->set($textRecords+1);
100 } 87 }
101 $this->elements->get("firstNonBookIndex")->set($textRecords+2+$images); 88 $this->elements->get("firstNonBookIndex")->set($textRecords+2+$images);
102 $this->elements->get("reserved")->set(str_pad("", 40, chr(255), STR_PAD_RIGHT)); 89 $this->elements->get("reserved")->set(str_pad("", 40, chr(255), STR_PAD_RIGHT));
@@ -104,21 +91,16 @@ class PalmRecord extends FileObject {
104 $this->elements->set("exthRecords", $exthElems); 91 $this->elements->set("exthRecords", $exthElems);
105 $pad = $l%4; 92 $pad = $l%4;
106 $pad = (4-$pad)%4; 93 $pad = (4-$pad)%4;
107 $this->elements->get("exthPadding")->set(str_pad("", $pad+2, "\0", STR_PAD_RIGHT)); 94 $this->elements->get("exthPadding")->set(str_pad("", $pad, "\0", STR_PAD_RIGHT));
108 $this->elements->get("exthHeaderLength")->set(12+$l+$pad); 95 $this->elements->get("exthHeaderLength")->set(12+$l+$pad);
109 96
110 97
111 $this->elements->get("recordCount")->set($textRecords); 98 $this->elements->get("recordCount")->set($textRecords);
112 99
113 $this->elements->get("fullNameOffset")->set($this->elements->offsetToEntry("fullName"));//need to be checked 100 $this->elements->get("fullNameOffset")->set($this->elements->offsetToEntry("fullName"));
114 $this->elements->get("fullNameLength")->set(strlen($settings->get("title"))); 101 $this->elements->get("fullNameLength")->set(strlen($settings->get("title")));
115 $this->elements->get("fullName")->set($settings->get("title")); 102 $this->elements->get("fullName")->set($settings->get("title"));
116 $this->elements->get("textLength")->set($textLength); 103 $this->elements->get("textLength")->set($textLength);
117
118 $this->elements->get("offset194")->set($textRecords+2+$images);
119 $this->elements->get("offset200")->set($textRecords+4+$images);
120 $this->elements->get("offset208")->set($textRecords+3+$images);
121 $this->elements->get("offset232")->set(str_pad("", 8, chr(255), STR_PAD_RIGHT));
122 } 104 }
123 105
124 public function getByteLength(){ 106 public function getByteLength(){
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/Prc.php b/inc/3rdparty/libraries/MOBIClass/Prc.php
index 1507e24b..c40b5805 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/Prc.php
+++ b/inc/3rdparty/libraries/MOBIClass/Prc.php
@@ -40,7 +40,7 @@ class Prc extends FileElement {
40 foreach($records as $record){ 40 foreach($records as $record){
41 $offset = new FileInt(); 41 $offset = new FileInt();
42 $attr = new FileByte(); 42 $attr = new FileByte();
43 $uniqueID = new FileTri(2*$i); 43 $uniqueID = new FileTri($i);
44 44
45 $this->elements["recordList"]->add("Rec".$i, new FileElement(array( 45 $this->elements["recordList"]->add("Rec".$i, new FileElement(array(
46 "offset"=>$offset, 46 "offset"=>$offset,
@@ -49,7 +49,7 @@ class Prc extends FileElement {
49 ))); 49 )));
50 50
51 $this->elements["records"]->add("Rec".$i, $record); 51 $this->elements["records"]->add("Rec".$i, $record);
52 $i+=1; 52 $i++;
53 } 53 }
54 54
55 $this->updateOffsets($records); 55 $this->updateOffsets($records);
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/PreprocessedArticle.php b/inc/3rdparty/libraries/MOBIClass/PreprocessedArticle.php
index 2e992404..2e992404 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/PreprocessedArticle.php
+++ b/inc/3rdparty/libraries/MOBIClass/PreprocessedArticle.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/RecognizeURL.php b/inc/3rdparty/libraries/MOBIClass/RecognizeURL.php
index 6319ed57..6319ed57 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/RecognizeURL.php
+++ b/inc/3rdparty/libraries/MOBIClass/RecognizeURL.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/Record.php b/inc/3rdparty/libraries/MOBIClass/Record.php
index 3cb39582..3cb39582 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/Record.php
+++ b/inc/3rdparty/libraries/MOBIClass/Record.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/RecordFactory.php b/inc/3rdparty/libraries/MOBIClass/RecordFactory.php
index 8bf0c97d..12806fe3 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/RecordFactory.php
+++ b/inc/3rdparty/libraries/MOBIClass/RecordFactory.php
@@ -62,21 +62,7 @@ class RecordFactory {
62 } 62 }
63 63
64 public function createFLISRecord(){ 64 public function createFLISRecord(){
65 65 $r = "FLIS";
66 $this->elements = new FileElement(array(
67 "offsetL0"=>new FileString("FLIS", 4), //FLIS
68 "offsetL4"=>new FileInt(0x08),
69 "offsetL8"=>new FileShort(0x41),
70 "offsetL10"=>new FileTri(),
71 "offsetL16"=>new FileInt(0xFFFFFFFF),
72 "offsetL20"=>new FileShort(0x01),
73 "offsetL22"=>new FileShort(0x03),
74 "offsetL24"=>new FileInt(0x03),
75 "offsetL28"=>new FileInt(0x01),
76 "offsetL32"=>new FileInt(0xFFFFFFFF)
77 ));
78
79 /*$r = "FLIS";
80 $r .= $this->asString(8, 4); 66 $r .= $this->asString(8, 4);
81 $r .= $this->asString(65, 2); 67 $r .= $this->asString(65, 2);
82 $r .= $this->asString(0, 2); 68 $r .= $this->asString(0, 2);
@@ -87,7 +73,7 @@ class RecordFactory {
87 $r .= $this->asString(3, 4); 73 $r .= $this->asString(3, 4);
88 $r .= $this->asString(1, 4); 74 $r .= $this->asString(1, 4);
89 $r .= $this->asString(-1, 4); 75 $r .= $this->asString(-1, 4);
90 return new Record($r);*/ 76 return new Record($r);
91 } 77 }
92 78
93 private function asString($int, $size){ 79 private function asString($int, $size){
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/Settings.php b/inc/3rdparty/libraries/MOBIClass/Settings.php
index 6bde0ba9..ddcf2054 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/Settings.php
+++ b/inc/3rdparty/libraries/MOBIClass/Settings.php
@@ -19,6 +19,7 @@ class Settings {
19 * be added with a key/value pair format. 19 * be added with a key/value pair format.
20 */ 20 */
21 public function __construct($additionalSettings = array()) { 21 public function __construct($additionalSettings = array()) {
22 // Most values shouldn't be changed (the result will be an invalid file)
22 $this->values = array( 23 $this->values = array(
23 "attributes"=>0, 24 "attributes"=>0,
24 "version"=>0, 25 "version"=>0,
@@ -48,13 +49,14 @@ class Settings {
48 "minimumVersion"=>6, 49 "minimumVersion"=>6,
49 "huffmanRecordOffset"=>0, 50 "huffmanRecordOffset"=>0,
50 "huffmanRecordCount"=>0, 51 "huffmanRecordCount"=>0,
51 "exthFlags"=>0x50, 52 "exthFlags"=>0x40,
52 "drmOffset"=>0xFFFFFFFF, 53 "drmOffset"=>0xFFFFFFFF,
53 "drmCount"=>0xFFFFFFFF, 54 "drmCount"=>0,
54 "drmSize"=>0, 55 "drmSize"=>0,
55 "drmFlags"=>0, 56 "drmFlags"=>0,
56 "extraDataFlags"=>0, 57 "extraDataFlags"=>0,
57 "exthIdentifier"=>"EXTH", 58 "exthIdentifier"=>"EXTH",
59 // These can be changed without any risk
58 "title"=>"Unknown title", 60 "title"=>"Unknown title",
59 "author"=>"Unknown author", 61 "author"=>"Unknown author",
60 "subject"=>"Unknown subject" 62 "subject"=>"Unknown subject"
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/constants.php b/inc/3rdparty/libraries/MOBIClass/constants.php
index bd363118..bd363118 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/constants.php
+++ b/inc/3rdparty/libraries/MOBIClass/constants.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/downloaders/FanFictionNet.php b/inc/3rdparty/libraries/MOBIClass/downloaders/FanFictionNet.php
index 65d5a466..65d5a466 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/downloaders/FanFictionNet.php
+++ b/inc/3rdparty/libraries/MOBIClass/downloaders/FanFictionNet.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/http_build_url.php b/inc/3rdparty/libraries/MOBIClass/http_build_url.php
index b475edb0..b475edb0 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/http_build_url.php
+++ b/inc/3rdparty/libraries/MOBIClass/http_build_url.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/readability/JSLikeHTMLElement.php b/inc/3rdparty/libraries/MOBIClass/readability/JSLikeHTMLElement.php
index 1a8ec88c..1a8ec88c 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/readability/JSLikeHTMLElement.php
+++ b/inc/3rdparty/libraries/MOBIClass/readability/JSLikeHTMLElement.php
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/readability/Readability.php b/inc/3rdparty/libraries/MOBIClass/readability/Readability.php
index 91554243..91554243 100644
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/readability/Readability.php
+++ b/inc/3rdparty/libraries/MOBIClass/readability/Readability.php
diff --git a/inc/3rdparty/libraries/mpdf/mpdf.php b/inc/3rdparty/libraries/mpdf/mpdf.php
index dbe16fef..f12dfec0 100644
--- a/inc/3rdparty/libraries/mpdf/mpdf.php
+++ b/inc/3rdparty/libraries/mpdf/mpdf.php
@@ -7451,7 +7451,7 @@ function Output($name='',$dest='')
7451 // don't use length if server using compression 7451 // don't use length if server using compression
7452 header('Content-Length: '.strlen($this->buffer)); 7452 header('Content-Length: '.strlen($this->buffer));
7453 } 7453 }
7454 header('Content-disposition: inline; filename="'.$name.'"'); 7454 header('Content-disposition: attachment; filename="'.$name.'"');
7455 header('Cache-Control: public, must-revalidate, max-age=0'); 7455 header('Cache-Control: public, must-revalidate, max-age=0');
7456 header('Pragma: public'); 7456 header('Pragma: public');
7457 header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); 7457 header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/PEOFRecord.php b/inc/3rdparty/libraries/send2kindle/MOBIClass/PEOFRecord.php
deleted file mode 100644
index a2b0fee8..00000000
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/PEOFRecord.php
+++ /dev/null
@@ -1,49 +0,0 @@
1<?php
2/**
3 * A Record of a End file
4 *
5 * @author Pratyush
6 */
7 class PEOFRecord extends FileObject {
8 /**
9 * @var FileElement
10 */
11 private $elements;
12
13 public function __construct($leng){
14 $this->elements = new FileElement(array(
15
16 "offset44"=>new FileInt(0xe98e0d0a)
17 ));
18 }
19 public function getByteLength(){
20 return $this->getLength();
21 }
22
23 public function getLength(){
24 return $this->elements->getByteLength();
25 }
26
27 public function get(){
28 return $this;
29 }
30
31 public function set($elements){
32 throw new Exception("Unallowed set");
33 }
34
35 public function serialize() {
36 return $this->elements->serialize();
37 }
38
39 public function unserialize($data) {
40 $this->elements->unserialize($data);
41 }
42
43 public function __toString(){
44 $output = "PalmDoc Record (".$this->getByteLength()." bytes):\n";
45 $output .= $this->elements;
46 return $output;
47 }
48
49} \ No newline at end of file
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/PFCISRecord.php b/inc/3rdparty/libraries/send2kindle/MOBIClass/PFCISRecord.php
deleted file mode 100644
index 9e72cc1c..00000000
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/PFCISRecord.php
+++ /dev/null
@@ -1,59 +0,0 @@
1<?php
2/**
3 * A Record of a End file
4 *
5 * @author Pratyush
6 */
7 class PFCISRecord extends FileObject {
8 /**
9 * @var FileElement
10 */
11 private $elements;
12
13 public function __construct($leng){
14 $this->elements = new FileElement(array(
15 "offset0"=>new FileString("FCIS", 4), //FCIS
16 "offset4"=>new FileInt(0x014),
17 "offset8"=>new FileInt(0x10),
18 "offset12"=>new FileInt(0x01),
19 "offset16"=>new FileInt(),
20 "offset20"=>new FileInt($leng),
21 "offset24"=>new FileInt(),
22 "offset28"=>new FileInt(0x20),
23 "offset32"=>new FileInt(0x08),
24 "offset36"=>new FileShort(0x01),
25 "offset38"=>new FileShort(0x01),
26 "offset40"=>new FileInt()
27 ));
28 }
29 public function getByteLength(){
30 return $this->getLength();
31 }
32
33 public function getLength(){
34 return $this->elements->getByteLength();
35 }
36
37 public function get(){
38 return $this;
39 }
40
41 public function set($elements){
42 throw new Exception("Unallowed set");
43 }
44
45 public function serialize() {
46 return $this->elements->serialize();
47 }
48
49 public function unserialize($data) {
50 $this->elements->unserialize($data);
51 }
52
53 public function __toString(){
54 $output = "PalmDoc Record (".$this->getByteLength()." bytes):\n";
55 $output .= $this->elements;
56 return $output;
57 }
58
59} \ No newline at end of file
diff --git a/inc/3rdparty/libraries/send2kindle/MOBIClass/PFLISRecord.php b/inc/3rdparty/libraries/send2kindle/MOBIClass/PFLISRecord.php
deleted file mode 100644
index dbd8ecf5..00000000
--- a/inc/3rdparty/libraries/send2kindle/MOBIClass/PFLISRecord.php
+++ /dev/null
@@ -1,58 +0,0 @@
1<?php
2/**
3 * A Record of a End file
4 *
5 * @author Pratyush
6 */
7 class PFLISRecord extends FileObject {
8 /**
9 * @var FileElement
10 */
11 private $elements;
12
13 public function __construct($leng){
14 $this->elements = new FileElement(array(
15 "offsetL0"=>new FileString("FLIS", 4), //FLIS
16 "offsetL4"=>new FileInt(0x08),
17 "offsetL8"=>new FileShort(0x41),
18 "offsetL10"=>new FileString(6),
19 "offsetL16"=>new FileInt(0xFFFFFFFF),
20 "offsetL20"=>new FileShort(0x01),
21 "offsetL22"=>new FileShort(0x03),
22 "offsetL24"=>new FileInt(0x03),
23 "offsetL28"=>new FileInt(0x01),
24 "offsetL32"=>new FileInt(0xFFFFFFFF)
25
26 ));
27 }
28 public function getByteLength(){
29 return $this->getLength();
30 }
31
32 public function getLength(){
33 return $this->elements->getByteLength();
34 }
35
36 public function get(){
37 return $this;
38 }
39
40 public function set($elements){
41 throw new Exception("Unallowed set");
42 }
43
44 public function serialize() {
45 return $this->elements->serialize();
46 }
47
48 public function unserialize($data) {
49 $this->elements->unserialize($data);
50 }
51
52 public function __toString(){
53 $output = "PalmDoc Record (".$this->getByteLength()." bytes):\n";
54 $output .= $this->elements;
55 return $output;
56 }
57
58} \ No newline at end of file
diff --git a/inc/3rdparty/libraries/send2kindle/api.php b/inc/3rdparty/libraries/send2kindle/api.php
deleted file mode 100644
index 564c171c..00000000
--- a/inc/3rdparty/libraries/send2kindle/api.php
+++ /dev/null
@@ -1,234 +0,0 @@
1<?php
2/**
3* @author Dimmduh
4* @email dimmduh@gmail.com
5*/
6class API{
7
8 private $service;
9 private $auth;
10 private $token;
11 private $source = 'GoogleReaderAPIClass-0.1';
12 private $client = 'scroll';
13 private $account_type = 'HOSTED_OR_GOOGLE';
14 private $clientlogin_url = 'https://www.google.com/accounts/ClientLogin';
15 private $reader_api_url = 'http://www.google.com/reader/api/0/';
16 private $session_var_auth_name = 'google_auth';
17
18
19 public function __construct( $email, $password, $service = 'reader' ){
20 if (isset( $service ) ){
21 $this -> service = $service;
22 }
23 /* if ( isset($_SESSION[ $this -> session_var_auth_name ] ) ){
24 $this -> auth = $_SESSION[ $this -> session_var_auth_name ];
25 echo "Loading";
26 } else { */
27 $this -> clientLogin( $email, $password );
28 $this -> get_token();
29 /* } */
30 }
31
32
33 private function request( $url, $type = 'get', $headers = false, $fields = false, $cookie = false){
34
35 $curl = curl_init();
36
37 if ( $fields ){
38 if ($type == 'get'){
39 $url .= '?'.http_build_query( $fields );
40 } else {
41 curl_setopt($curl, CURLOPT_POST, true);
42 curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($fields) );
43 }
44 }
45 if ( $headers ){
46 curl_setopt($curl, CURLOPT_HEADER, true);
47 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
48 }
49 if ( $cookie ){
50 curl_setopt($curl, CURLOPT_COOKIE, $cookie);
51 }
52
53 curl_setopt($curl, CURLOPT_URL, $url);
54 if (strpos($url, 'https://') !== false){
55 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
56 }
57 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
58 curl_setopt($curl, CURLINFO_HEADER_OUT, true);
59
60 $response = array();
61 $response['text'] = curl_exec($curl);
62 $response['info'] = curl_getinfo( $curl);
63 $response['code'] = curl_getinfo( $curl, CURLINFO_HTTP_CODE );
64 $response['body'] = substr( $response['text'], $response['info']['header_size'] );
65
66 curl_close( $curl );
67 return $response;
68 }
69
70 private function request2google( $url, $type = 'get', $headers = false, $fields = false ){
71 if ( $this -> auth ){
72 $headers[] = 'Content-type: application/x-www-form-urlencoded';
73 $headers[] = 'Authorization: GoogleLogin auth='.$this -> auth;
74
75 if ( strpos( $url, 'http://') === false && strpos( $url, 'https://' ) === false ){
76 $url = $this -> reader_api_url.$url;
77 }
78
79 $response = $this -> request( $url, $type, $headers, $fields);
80 if ( $response['code'] == 200 ){
81 if ( isset( $fields['output'] ) ){
82 switch ($fields['output']){
83 case 'xml':
84 return (new SimpleXMLElement( $response['body'] ) );
85 break;
86 case 'json':
87 default:
88 return json_decode( $response['body'] );
89 break;
90 }
91 } else {
92 return $response['body'];
93 }
94 } else {
95 Throw new AutentificationException('Auth error: server response '.$response['code'] );
96 }
97
98 } else {
99 Throw new AutentificationException('Auth error: not finded Auth token');
100 }
101 }
102
103 public function get_tag_list( $output = 'json' ){
104 return $this -> request2google('tag/list', "get", false, array(
105 'output' => $output,
106 'ck' => time(),
107 'client' => $this -> client,
108 ));
109 }
110 public function get_subscription_list( $output = 'json' ){
111 return $this -> request2google('subscription/list', "get", false, array(
112 'output' => $output,
113 'ck' => time(),
114 'client' => $this -> client,
115 ));
116 }
117 public function get_preference_list( $output = 'json' ){
118 return $this -> request2google('preference/list', "get", false, array(
119 'output' => $output,
120 'ck' => time(),
121 'client' => $this -> client,
122 ));
123 }
124 public function get_unread_count( $output = 'json' ){
125 return $this -> request2google('unread-count', "get", false, array(
126 'all' => true,
127 'output' => $output,
128 'ck' => time(),
129 'client' => $this -> client,
130 ));
131 }
132 public function get_user_info( $output = 'json' ){
133 return $this -> request2google('user-info', "get", false, array(
134 'output' => $output,
135 'ck' => time(),
136 'client' => $this -> client,
137 ));
138 }
139 private function get_token(){
140 $this -> token = $this -> request2google('token');
141 }
142
143 //get contents functions
144 /*
145 r - order
146 r = n - new items
147 r = o - old items
148 r = a - auto sort
149
150 */
151 private function get_content( $content_url = '', $number = 20, $order = 'n', $exclude_target = '', $start_time = '', $continuation = ''){
152 $fields = array(
153 'ck' => time(),
154 'client' => $this -> client,
155 'n' => $number,
156 'r' => $order,
157 'output' => 'json',
158 );
159 if ( !empty($exclude_target) ){$fields['xt'] = $exclude_target;}
160 if ( !empty($start_time) ){$fields['ot'] = $start_time;}
161 if ( !empty($continuation) ){$fields['c'] = $continuation;}
162
163 return $this -> request2google('stream/contents/'.Utils::urlencode( $content_url ), 'get', false, $fields);
164 }
165
166 public function get_content_feed( $feed_url = '', $number = 20, $order = 'n', $exclude_target = '', $start_time = '', $continuation = ''){
167 return $this -> get_content( $feed_url, $number, $order, $exclude_target, $start_time, $continuation );
168 }
169 public function get_content_by_label( $label = '', $number = 20, $order = 'n', $exclude_target = '', $start_time = '', $continuation = ''){
170 return $this -> get_content( (strpos($label, '/') === false?'user/-/label/':'').$label, $number, $order, $exclude_target, $start_time, $continuation );
171 }
172 public function get_content_by_state( $state = '', $number = 20, $order = 'n', $exclude_target = '', $start_time = '', $continuation = ''){
173 return $this -> get_content( (strpos($state, '/') === false?'user/-/state/com.google/':'').$state, $number, $order, $exclude_target, $start_time, $continuation );
174 }
175
176 public function get_unread( $number = 20, $order = 'n' ){
177 return $this ->get_content_by_state('reading-list', $number, $order, 'user/-/state/com.google/read');
178 }
179
180 public function get_starred($number = 20, $order = 'n'){
181 return $this ->get_content_by_state('starred', $number, $order);
182 }
183
184 /*
185 Edit functions
186 */
187 private function edit_do( $api_function , $post_fields ){
188 $post_fields['T'] = $this -> token;
189 if ( $this -> request2google( $api_function, "post", false, $post_fields ) == "OK"){
190 return true;
191 } else {
192 return false;
193 }
194 }
195
196 /* public function edit_subscription(
197 s return $this -> edit_do( 'subscription/edit',
198 } */
199 public function set_state( $itemId, $state = 'read'){
200 $post_fields = array(
201 "i" => $itemId,
202 "a" => 'user/-/state/com.google/'.$state,
203 );
204 //print_r( $post_fields );
205 return $this ->edit_do('edit-tag?client='.$this -> client, $post_fields);
206 }
207
208 private function clientLogin( $email, $password ){
209
210 $response = $this -> request( $this -> clientlogin_url, 'post', false, array(
211 "accountType" => $this -> account_type,
212 "Email" => $email,
213 "Passwd" => $password,
214 "service" => $this -> service,
215 "source" => $this -> source,
216 ));
217
218 if ( $response['code'] == 200) {
219 preg_match("/Auth=([a-z0-9_\-]+)/i", $response['body'], $matches_auth);
220 if ($matches_auth[1]){
221 $this -> auth = $matches_auth[1];
222 $_SESSION[ $this -> session_var_auth_name ] = $this -> auth;
223 return true;
224 } else {
225 Throw new AutentificationException('Auth error: not finded Auth token in response');
226 }
227 } else {
228 Throw new AutentificationException('Auth error: server response '.$response['code'] );
229 }
230 }
231}
232
233//Exceptions
234class AutentificationException extends Exception {} \ No newline at end of file
diff --git a/inc/3rdparty/libraries/send2kindle/images.php b/inc/3rdparty/libraries/send2kindle/images.php
deleted file mode 100644
index 63f0562a..00000000
--- a/inc/3rdparty/libraries/send2kindle/images.php
+++ /dev/null
@@ -1,136 +0,0 @@
1<?php
2
3/**
4 * Get images from content and prepare to save in articles
5 */
6class Images {
7
8 /**
9 * JPER quality for resize
10 */
11 const JPEG_QUALITY = 80;
12
13 /**
14 * Articles content
15 * @var string
16 */
17 private $_content;
18
19 /**
20 * Storage to keep images
21 * @var object Storage
22 */
23 private $_storage;
24
25 /**
26 * images from content
27 * @var array
28 */
29 private $_images_from_content = array();
30
31 /**
32 * Prepare get images
33 * @param Strage $storage
34 * @param string $article_content
35 */
36 public function __construct(Storage $storage, $article_content)
37 {
38 $this->_storage = $storage;
39 $this->_content = $article_content;
40 $this->_images_from_content = $this->_get_images_from_content($article_content);
41 }
42
43 /**
44 * get images from url
45 * @param string $content
46 * @return array images hashtable
47 */
48 private function _get_images_from_content($content)
49 {
50 $result = array();
51 preg_match_all('/src=\"([a-zA-Z0-9\.\/\-\_\?\+\%\~\&\;\=\:]+)\"/i', $content, $result);
52
53 return $result[1];
54 }
55
56 /**
57 * Start conversion
58 * @return string converted content
59 */
60 public function convert()
61 {
62 foreach ( $this->_images_from_content as $n => $image_url )
63 {
64 $image = $this->_get_image($image_url);
65 $this->_content = str_replace($image_url, '" recindex="'.(int)basename($image), $this->_content);
66 }
67
68 return $this->_content;
69 }
70
71 /**
72 * Resize image
73 * @param string $file path
74 * @param int $new_width max width
75 */
76 private function _resize($file, $new_width = 500)
77 {
78 list($width, $height) = getimagesize($file);
79
80 $new_height = 0;
81
82 //setup the new size of the image
83 if( $width > $new_width )
84 {
85 $ratio = $height/$width;
86 $new_height = $new_width * $ratio;
87 }
88 else
89 {
90 $new_width = $width;
91 $new_height = $height;
92 }
93
94 // resample the image
95 $new_image = imagecreatetruecolor($new_width, $new_height);
96
97 $type = exif_imagetype ( $file );
98
99 switch ( $type )
100 {
101 case IMAGETYPE_JPEG:
102 $old_image = imagecreatefromjpeg($file);
103 imagecopyresampled($new_image, $old_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
104 imagejpeg($new_image, $file, self::JPEG_QUALITY);
105 break;
106 case IMAGETYPE_PNG:
107 $old_image = imagecreatefrompng($file);
108 imagecopyresampled($new_image, $old_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
109 imagepng($new_image, $file);
110 break;
111 case IMAGETYPE_GIF:
112 $old_image = imagecreatefromgif($file);
113 imagecopyresampled($new_image, $old_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
114 imagegif($new_image, $file);
115 break;
116 }
117 }
118
119 /**
120 * Resize image
121 * @return string image path
122 */
123 private function _get_image($url)
124 {
125 $image_data = @file_get_contents($url);
126
127 if ( $image_data !== false )
128 {
129 $image_name = $this->_storage->save_image($image_data);
130 $this->_resize($image_name);
131
132 return $image_name;
133 }
134 }
135
136} \ No newline at end of file
diff --git a/inc/3rdparty/libraries/send2kindle/io.php b/inc/3rdparty/libraries/send2kindle/io.php
deleted file mode 100644
index 284c08cc..00000000
--- a/inc/3rdparty/libraries/send2kindle/io.php
+++ /dev/null
@@ -1,250 +0,0 @@
1<?php
2/**
3 * Simple output message and args prepared
4 *
5 * @author Jakub Westfalewski <jwest@jwest.pl>
6 */
7class IO {
8
9 /**
10 * Max line height
11 */
12 const COMMAND_LENGTH = 50;
13
14 /**
15 * args for run screen
16 * @var array
17 */
18 protected static $_args = array
19 (
20 'help' => array('value' => FALSE, 'description' => 'show help for news2kindle'),
21 'grab' => array('value' => FALSE, 'description' => 'grab articles from google reader'),
22 'mobi' => array('value' => FALSE, 'description' => 'prepare mobi format'),
23 'send' => array('value' => FALSE, 'description' => 'send articles to kindle'),
24 'login' => array('value' => NULL, 'description' => 'your login to google account *requred'),
25 'password' => array('value' => NULL, 'description' => 'your password to google account *required'),
26 'kindle' => array('value' => NULL, 'description' => 'your kindle email *required'),
27 'items' => array('value' => 100, 'description' => 'max items to grab in run'),
28 'render' => array('value' => 'std', 'description' => 'name of html template for newspapper'),
29 //'timeout' => array('value' => FALSE, 'description' => 'timeout is most important than items count'),
30 );
31
32 /**
33 * Write on screen text line
34 * @param string $message
35 * @param bool $broken_line
36 */
37 public static function msg($message, $broken_line = TRUE)
38 {
39 echo ( $broken_line ? "\n" : "" ) . $message;
40 }
41
42 /**
43 * Write command for status
44 * @param string $message
45 */
46 public static function command($message)
47 {
48 $output_whitespaces = '';
49
50 for ($i = strlen($message); $i <= self::COMMAND_LENGTH; ++$i )
51 {
52 $output_whitespaces .= '-';
53 }
54
55 self::msg( $message . ' ' . $output_whitespaces.' ' );
56 }
57
58 /**
59 * Status - OK
60 */
61 public static function ok()
62 {
63 $colored_string = "\033[1;37m" . "\033[42m" . ' OK ' . "\033[0m";
64 self::msg( $colored_string, FALSE );
65 }
66
67 /**
68 * Status - Error
69 */
70 public static function error($message = NULL)
71 {
72 $colored_string = "\033[1;37m" . "\033[41m" . ' ERROR ' . "\033[0m";
73 self::msg( $colored_string, FALSE );
74
75 if ( $message !== NULL )
76 {
77 self::msg( ' - ' . $message );
78 }
79 }
80
81 /**
82 * Get run args
83 * @param string $name key config
84 * @return mixed config value
85 */
86 public static function arg($name)
87 {
88 return self::$_args[$name]['value'];
89 }
90
91 /**
92 * Get config from ini
93 * @param string $path
94 * @return void
95 */
96 protected static function _get_config($path)
97 {
98 $config = parse_ini_file( $path . 'config.ini' );
99
100 foreach($config as $key => $value)
101 {
102 self::$_args[$key]['value'] = $value;
103 }
104 }
105
106 /**
107 * Prepare args for script
108 * (from http://php.net/manual/en/features.commandline.php)
109 * @param array $argv array
110 * @param string $path
111 * @return bool success or error
112 */
113 public static function prepare_args($argv, $path)
114 {
115 self::command('Parse args');
116
117 self::_get_config($path);
118
119 array_shift($argv);
120 $out = array();
121
122 foreach ( $argv as $arg )
123 {
124 if ( substr($arg,0,2) == '--' )
125 {
126 $eqPos = strpos($arg,'=');
127
128 if ( $eqPos === false )
129 {
130 $key = substr($arg,2);
131 $out[$key] = isset($out[$key]) ? $out[$key] : true;
132 }
133 else
134 {
135 $key = substr($arg,2,$eqPos-2);
136 $out[$key] = substr($arg,$eqPos+1);
137 }
138
139 }
140 else if ( substr($arg,0,1) == '-' )
141 {
142 if ( substr($arg,2,1) == '=' )
143 {
144 $key = substr($arg,1,1);
145 $out[$key] = substr($arg,3);
146 }
147 else
148 {
149 $chars = str_split(substr($arg,1));
150
151 foreach ( $chars as $char )
152 {
153 $key = $char;
154 $out[$key] = isset($out[$key]) ? $out[$key] : true;
155 }
156 }
157 }
158 else
159 {
160 $out[] = $arg;
161 }
162 }
163
164 try
165 {
166 $args = self::_validate_args($out);
167
168 foreach ( $args as $key => $value )
169 {
170 self::$_args[$key]['value'] = $value;
171 }
172 }
173 catch(Exception $e)
174 {
175 self::error($e->getMessage());
176 return false;
177 }
178
179 self::ok();
180
181 return true;
182 }
183
184 /**
185 * Validate args for script
186 * (from http://php.net/manual/en/features.commandline.php)
187 * @param array $argv array
188 * @return array args
189 */
190 private static function _validate_args($args)
191 {
192 if( array_key_exists('help', $args) OR array_key_exists('h', $args) )
193 {
194 $args['grab'] = false;
195 $args['mobi'] = false;
196 $args['send'] = false;
197 $args['login'] = false;
198 $args['password'] = false;
199 $args['kindle'] = false;
200 }
201
202 foreach ( $args as $key => $arg )
203 {
204 if ( strlen($key) === 1 )
205 {
206 foreach ( self::$_args as $keyA => $argA )
207 {
208 if($keyA[0] === $key )
209 {
210 unset( $args[$key] );
211 $args[$keyA] = $arg;
212 $key = $keyA;
213 }
214 }
215 }
216
217 if ( ! array_key_exists($key, self::$_args) )
218 {
219 throw new Exception('Param "'.$key.'" is invalid!');
220 }
221 }
222
223 foreach ( self::$_args as $key => $arg )
224 {
225 if( self::$_args[$key]['value'] === NULL AND !array_key_exists($key, $args) )
226 {
227 throw new Exception('Param "'.$key.'" must be declared!');
228 }
229 }
230
231 return $args;
232 }
233
234 /**
235 * Prepare help
236 * @return array
237 */
238 public static function get_help()
239 {
240 $output = array();
241
242 foreach ( self::$_args as $arg => $item )
243 {
244 $output[$arg] = $item['description'];
245 }
246
247 return $output;
248 }
249
250} \ No newline at end of file
diff --git a/inc/3rdparty/libraries/send2kindle/readability.php b/inc/3rdparty/libraries/send2kindle/readability.php
deleted file mode 100644
index 18c2dbde..00000000
--- a/inc/3rdparty/libraries/send2kindle/readability.php
+++ /dev/null
@@ -1,249 +0,0 @@
1<?php
2/**
3 * PHP Readability
4 *
5 * Readability PHP 版本,详见
6 * http://code.google.com/p/arc90labs-readability/
7 *
8 * ChangeLog:
9 *
10 * [+] 2011-02-17 初始化版本
11 *
12 * @author mingcheng<i.feelinglucky#gmail.com>
13 * @date 2011-02-17
14 * @link http://www.gracecode.com/
15 */
16
17define("READABILITY_VERSION", 0.12);
18
19class Readability2 {
20 // 保存判定结果的标记位名称
21 const ATTR_CONTENT_SCORE = "contentScore";
22
23 // DOM 解析类目前只支持 UTF-8 编码
24 const DOM_DEFAULT_CHARSET = "utf-8";
25
26 // 当判定失败时显示的内容
27 const MESSAGE_CAN_NOT_GET = "Sorry, readability was unable to parse this page for content. \n
28 If you feel like it should have been able to,
29 please let me know by mail: lucky[at]gracecode.com";
30
31 // DOM 解析类(PHP5 已内置)
32 protected $DOM = null;
33
34 // 需要解析的源代码
35 protected $source = "";
36
37 // 章节的父元素列表
38 private $parentNodes = array();
39
40 // 需要删除的标签
41 private $junkTags = Array("style", "form", "iframe", "script", "button", "input", "textarea");
42
43 // 需要删除的属性
44 private $junkAttrs = Array("style", "class", "onclick", "onmouseover", "align", "border", "margin");
45
46
47 /**
48 * 构造函数
49 * @param $input_char 字符串的编码。默认 utf-8,可以省略
50 */
51 function __construct($source, $input_char = "utf-8") {
52 $this->source = $source;
53
54 // DOM 解析类只能处理 UTF-8 格式的字符
55 $source = mb_convert_encoding($source, 'HTML-ENTITIES', $input_char);
56
57 // 预处理 HTML 标签,剔除冗余的标签等
58 $source = $this->preparSource($source);
59
60 // 生成 DOM 解析类
61 $this->DOM = new DOMDocument('1.0', $input_char);
62 try {
63 //libxml_use_internal_errors(true);
64 // 会有些错误信息,不过不要紧 :^)
65 if (!@$this->DOM->loadHTML('<?xml encoding="'.Readability2::DOM_DEFAULT_CHARSET.'">'.$source)) {
66 throw new Exception("Parse HTML Error!");
67 }
68
69 foreach ($this->DOM->childNodes as $item) {
70 if ($item->nodeType == XML_PI_NODE) {
71 $this->DOM->removeChild($item); // remove hack
72 }
73 }
74
75 // insert proper
76 $this->DOM->encoding = Readability2::DOM_DEFAULT_CHARSET;
77 } catch (Exception $e) {
78 // ...
79 }
80 }
81
82
83 /**
84 * 预处理 HTML 标签,使其能够准确被 DOM 解析类处理
85 *
86 * @return String
87 */
88 private function preparSource($string) {
89 // 剔除多余的 HTML 编码标记,避免解析出错
90 preg_match("/charset=([\w|\-]+);?/", $string, $match);
91 if (isset($match[1])) {
92 $string = preg_replace("/charset=([\w|\-]+);?/", "", $string, 1);
93 }
94
95 // Replace all doubled-up <BR> tags with <P> tags, and remove fonts.
96 $string = preg_replace("/<br\/?>[ \r\n\s]*<br\/?>/i", "</p><p>", $string);
97 $string = preg_replace("/<\/?font[^>]*>/i", "", $string);
98
99 return trim($string);
100 }
101
102
103 /**
104 * 删除 DOM 元素中所有的 $TagName 标签
105 *
106 * @return DOMDocument
107 */
108 private function removeJunkTag($RootNode, $TagName) {
109 $Tags = $RootNode->getElementsByTagName($TagName);
110
111 $i = 0;
112 while($Tag = $Tags->item($i++)) {
113 $parentNode = $Tag->parentNode;
114 $parentNode->removeChild($Tag);
115 }
116
117 return $RootNode;
118 }
119
120 /**
121 * 删除元素中所有不需要的属性
122 */
123 private function removeJunkAttr($RootNode, $Attr) {
124 $Tags = $RootNode->getElementsByTagName("*");
125
126 $i = 0;
127 while($Tag = $Tags->item($i++)) {
128 $Tag->removeAttribute($Attr);
129 }
130
131 return $RootNode;
132 }
133
134 /**
135 * 根据评分获取页面主要内容的盒模型
136 * 判定算法来自:http://code.google.com/p/arc90labs-readability/
137 *
138 * @return DOMNode
139 */
140 private function getTopBox() {
141 // 获得页面所有的章节
142 $allParagraphs = $this->DOM->getElementsByTagName("p");
143
144 // Study all the paragraphs and find the chunk that has the best score.
145 // A score is determined by things like: Number of <p>'s, commas, special classes, etc.
146 $i = 0;
147 while($paragraph = $allParagraphs->item($i++)) {
148 $parentNode = $paragraph->parentNode;
149 $contentScore = intval($parentNode->getAttribute(Readability2::ATTR_CONTENT_SCORE));
150 $className = $parentNode->getAttribute("class");
151 $id = $parentNode->getAttribute("id");
152
153 // Look for a special classname
154 if (preg_match("/(comment|meta|footer|footnote)/i", $className)) {
155 $contentScore -= 50;
156 } else if(preg_match(
157 "/((^|\\s)(post|hentry|entry[-]?(content|text|body)?|article[-]?(content|text|body)?)(\\s|$))/i",
158 $className)) {
159 $contentScore += 25;
160 }
161
162 // Look for a special ID
163 if (preg_match("/(comment|meta|footer|footnote)/i", $id)) {
164 $contentScore -= 50;
165 } else if (preg_match(
166 "/^(post|hentry|entry[-]?(content|text|body)?|article[-]?(content|text|body)?)$/i",
167 $id)) {
168 $contentScore += 25;
169 }
170
171 // Add a point for the paragraph found
172 // Add points for any commas within this paragraph
173 if (strlen($paragraph->nodeValue) > 10) {
174 $contentScore += strlen($paragraph->nodeValue);
175 }
176
177 // 保存父元素的判定得分
178 $parentNode->setAttribute(Readability2::ATTR_CONTENT_SCORE, $contentScore);
179
180 // 保存章节的父元素,以便下次快速获取
181 array_push($this->parentNodes, $parentNode);
182 }
183
184 $topBox = $this->DOM->createElement('div', Readability2::MESSAGE_CAN_NOT_GET);
185 // Assignment from index for performance.
186 // See http://www.peachpit.com/articles/article.aspx?p=31567&seqNum=5
187 for ($i = 0, $len = sizeof($this->parentNodes); $i < $len; $i++) {
188 $parentNode = $this->parentNodes[$i];
189 $contentScore = intval($parentNode->getAttribute(Readability2::ATTR_CONTENT_SCORE));
190 $orgContentScore = intval($topBox->getAttribute(Readability2::ATTR_CONTENT_SCORE));
191
192 if ($contentScore && $contentScore > $orgContentScore) {
193 $topBox = $parentNode;
194 }
195 }
196
197 // 此时,$topBox 应为已经判定后的页面内容主元素
198 return $topBox;
199 }
200
201
202 /**
203 * 获取 HTML 页面标题
204 *
205 * @return String
206 */
207 public function getTitle() {
208 $title = $this->DOM->getElementsByTagName("title");
209 return $title->item(0);
210 }
211
212
213 /**
214 * 获取页面的主要内容(Readability 以后的内容)
215 *
216 * @return Array
217 */
218 public function getContent() {
219 if (!$this->DOM) return false;
220
221 // 获取页面标题
222 $ContentTitle = $this->getTitle();
223
224 // 获取页面主内容
225 $ContentBox = $this->getTopBox();
226
227 // 复制内容到新的 DOMDocument
228 $Target = new DOMDocument;
229 $Target->appendChild($Target->importNode($ContentBox, true));
230
231 // 删除不需要的标签
232 foreach ($this->junkTags as $tag) {
233 $Target = $this->removeJunkTag($Target, $tag);
234 }
235
236 // 删除不需要的属性
237 foreach ($this->junkAttrs as $attr) {
238 $Target = $this->removeJunkAttr($Target, $attr);
239 }
240
241 // 多个数据,以数组的形式返回
242 return Array(
243 'title' => $ContentTitle ? $ContentTitle->nodeValue : "",
244 'content' => $Target->saveHTML()
245 );
246 }
247
248 function __destruct() { }
249}
diff --git a/inc/3rdparty/libraries/send2kindle/send.php b/inc/3rdparty/libraries/send2kindle/send.php
deleted file mode 100644
index a4861d30..00000000
--- a/inc/3rdparty/libraries/send2kindle/send.php
+++ /dev/null
@@ -1,69 +0,0 @@
1<?php
2/**
3 * Send to kindle email
4 * @author jwest <jwest@jwest.pl>
5 */
6class Send {
7
8 /**
9 * Your kindle email
10 * @var string
11 */
12 private $_kindle_email;
13
14 /**
15 * Your email (must be added on amazon)
16 * @var string
17 */
18 private $_email;
19
20 /**
21 * Prepare mail
22 * @param string $kindle_email your kindle email
23 * @param string $email email for send to kindle
24 */
25 public function __construct($kindle_email, $email)
26 {
27 $this->_kindle_email = $kindle_email;
28 $this->_email = $email;
29 }
30
31 /**
32 * Send file
33 * @param string $file path to file
34 * @return bool
35 */
36 public function send($file)
37 {
38 //prepare file
39 $file_size = filesize($file);
40 $filename = basename($file);
41 $handle = fopen($file, "r");
42 $content = fread($handle, $file_size);
43 fclose($handle);
44 $content = chunk_split(base64_encode($content));
45
46 $uid = md5(uniqid(time()));
47
48 //generate header for mail
49 $header = "From: News2Kindle <".$this->_email.">\r\n";
50 $header .= "MIME-Version: 1.0\r\n";
51 $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
52 $header .= "This is a multi-part message in MIME format.\r\n";
53 $header .= "--".$uid."\r\n";
54 $header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
55 $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
56 $header .= "send via News2Kindle script\r\n\r\n";
57 $header .= "--".$uid."\r\n";
58 $header .= "Content-Type: application/x-mobipocket-ebook; name=\"".$filename."\"\r\n";
59 $header .= "Content-Transfer-Encoding: base64\r\n";
60 $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
61 $header .= $content."\r\n\r\n";
62 $header .= "--".$uid."--";
63
64 //send mail
65 return mail( $this->_kindle_email, '[newsToKindle] ' . $filename, "", $header );
66 }
67}
68
69?> \ No newline at end of file
diff --git a/inc/3rdparty/libraries/send2kindle/storage.php b/inc/3rdparty/libraries/send2kindle/storage.php
deleted file mode 100644
index 5c38ce80..00000000
--- a/inc/3rdparty/libraries/send2kindle/storage.php
+++ /dev/null
@@ -1,230 +0,0 @@
1<?php
2/**
3 * Storage for news2Kindle
4 * @author jwest <jwest@jwest.pl>
5 */
6class Storage {
7
8 /**
9 * Newspapper name
10 * @var string
11 */
12 private $_name;
13
14 /**
15 * Default dir
16 * @var string
17 */
18 private $_default_dir = 'data/';
19
20 /**
21 * Info about newspapper
22 * @var array
23 */
24 private $_info;
25
26 /**
27 * Prepare storage
28 * @param string $newspapper
29 * @param string $default_dir
30 */
31 public function __construct($newspapper, $default_dir = NULL)
32 {
33 $this->_name = $newspapper;
34
35 if ( $default_dir !== NULL )
36 {
37 $this->_default_dir = $default_dir;
38 }
39
40 $this->_info = $this->_get_info();
41 }
42
43 /**
44 * save info before exit from script
45 */
46 public function __destruct()
47 {
48 $this->_save_info($this->_info);
49 }
50
51 /**
52 * Get path
53 * @param bool $newspapper path to newspapper
54 * @return string path to repository
55 */
56 public function get_path($newspapper = true)
57 {
58 $path = $this->_default_dir;
59
60 if ( $newspapper )
61 {
62 $path .= $this->_name . '/';
63 }
64
65 return $path;
66 }
67
68 /**
69 * Get info about newspapper
70 * @return array newspapper info
71 */
72 private function _get_info()
73 {
74 $content = unserialize( $this->_get_file('info.dat') );
75
76 if( $content === FALSE )
77 {
78 $content = (object) array
79 (
80 'images_count' => 0,
81 'articles_count' => 0,
82 'images' => array(),
83 );
84
85 $this->_save_info($content);
86 }
87
88 return $content;
89 }
90
91 /**
92 * Get info key
93 * @param $key
94 * @return mixed
95 */
96 public function info($key)
97 {
98 return $this->_info->$key;
99 }
100
101 /**
102 * Save info
103 * @param array $info info from class
104 */
105 private function _save_info($info)
106 {
107 $this->_save_file( 'info.dat', serialize($info) );
108 }
109
110 /**
111 * Save image in storage
112 * @param resource $image
113 * @param string $name image name, if null create auto name
114 * @return string image name
115 */
116 public function save_image($image, $name = NULL)
117 {
118 if ( $name === NULL )
119 {
120 $image_name = (string) $this->_info->images_count;
121
122 for ($i=strlen($image_name); $i<6; $i++)
123 {
124 $image_name = '0'.$image_name;
125 }
126
127 $this->_info->images_count++;
128 $this->_info->images[$this->_info->images_count] = $image_name;
129
130 $name = $image_name;
131 }
132
133 $this->_save_file($name, $image);
134
135 return $this->_default_dir . $this->_name . '/' . $name;
136 }
137
138 /**
139 * Get image
140 * @param string $name image name
141 * @return resource
142 */
143 public function get_image($name)
144 {
145 return $this->_get_file($name);
146 }
147
148 /**
149 * Put article contents
150 * @param string $id unique id for article
151 * @param string $title
152 * @param string $content article content
153 * @param string $url url for article
154 * @param object $website
155 */
156 public function add_content($id, $title, $content, $url, $website)
157 {
158 $articles = unserialize( $this->_get_file('articles.dat') );
159
160 $articles[$id] = (object) array
161 (
162 'id' => $id,
163 'title' => $title,
164 'content' => $content,
165 'url' => $url,
166 'website' => $website,
167 );
168
169 $this->_save_file( 'articles.dat', serialize($articles) );
170 }
171
172 /**
173 * Get articles contents
174 * @param string $file_name
175 * @param string $file_content
176 */
177 public function get_contents()
178 {
179 return unserialize( $this->_get_file( 'articles.dat' ) );
180 }
181
182 /**
183 * Get file content
184 * @param string $file_name
185 * @param string $file_content
186 */
187 private function _save_file($file_name, $file_content)
188 {
189 if( ! file_exists( $this->_default_dir . $this->_name ) )
190 {
191 mkdir( $this->_default_dir . $this->_name, 0777, TRUE );
192 }
193
194 file_put_contents($this->_default_dir . $this->_name . '/' . $file_name, $file_content);
195 }
196
197 /**
198 * Get file content
199 * @param string $file_name
200 * @param string $default_file_content (if file not exists)
201 * @return string file content
202 */
203 private function _get_file($file_name, $default_file_content = NULL)
204 {
205 $content = @file_get_contents($this->_default_dir . $this->_name . '/' . $file_name);
206
207 if ($content === FALSE)
208 {
209 return $default_file_content;
210 }
211
212 return $content;
213 }
214
215 /**
216 * Clean newspapper after convert to mobi
217 */
218 public function clean()
219 {
220 $files_to_remove = glob($this->_default_dir . $this->_name . '/*');
221
222 foreach ( $files_to_remove as $file )
223 {
224 unlink( $file );
225 }
226
227 rmdir( $this->_default_dir . $this->_name );
228 }
229
230} \ No newline at end of file
diff --git a/inc/3rdparty/libraries/send2kindle/utils.php b/inc/3rdparty/libraries/send2kindle/utils.php
deleted file mode 100644
index 87cc3de0..00000000
--- a/inc/3rdparty/libraries/send2kindle/utils.php
+++ /dev/null
@@ -1,37 +0,0 @@
1<?php
2/**
3 * Utils for news2kindle
4 * @author jwest <jwest@jwest.pl>
5 */
6class Utils
7{
8 /**
9 * URL encode
10 * @param string $url
11 * @return string $ar_url
12 */
13 public static function urlencode( $url )
14 {
15 $ar_url = explode( '/', $url );
16
17 foreach ( $ar_url as $key => $val )
18 {
19 $ar_url[ $key ] = urlencode( $val );
20 }
21
22 return implode('/', $ar_url );
23 }
24
25 /**
26 * Prepare ID for google rss article
27 * @param string $id
28 * @return string
29 */
30 public static function prepare_id($id)
31 {
32 $char_in = array('/', '.', ',', ':');
33 $id = str_replace($char_in, '-', $id);
34
35 return $id;
36 }
37} \ No newline at end of file