aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/config.php3
-rw-r--r--inc/poche/pocheCore.php18
-rw-r--r--inc/poche/pochePictures.php12
-rw-r--r--inc/poche/pocheTools.class.php (renamed from inc/poche/pocheTool.class.php)6
4 files changed, 20 insertions, 19 deletions
diff --git a/inc/config.php b/inc/config.php
index 65b2b9cc..58abb535 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -10,6 +10,7 @@
10 10
11define ('POCHE_VERSION', '0.3'); 11define ('POCHE_VERSION', '0.3');
12define ('MODE_DEMO', FALSE); 12define ('MODE_DEMO', FALSE);
13define ('DEBUG_POCHE', TRUE);
13define ('CONVERT_LINKS_FOOTNOTES', FALSE); 14define ('CONVERT_LINKS_FOOTNOTES', FALSE);
14define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); 15define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE);
15define ('DOWNLOAD_PICTURES', FALSE); 16define ('DOWNLOAD_PICTURES', FALSE);
@@ -24,7 +25,7 @@ $storage_type = 'sqlite'; # sqlite or file
24 25
25# /!\ Be careful if you change the lines below /!\ 26# /!\ Be careful if you change the lines below /!\
26 27
27require_once 'poche/pocheTool.class.php'; 28require_once 'poche/pocheTools.class.php';
28require_once 'poche/pocheCore.php'; 29require_once 'poche/pocheCore.php';
29require_once '3rdparty/Readability.php'; 30require_once '3rdparty/Readability.php';
30require_once '3rdparty/Encoding.php'; 31require_once '3rdparty/Encoding.php';
diff --git a/inc/poche/pocheCore.php b/inc/poche/pocheCore.php
index 52c603ac..34c15d84 100644
--- a/inc/poche/pocheCore.php
+++ b/inc/poche/pocheCore.php
@@ -136,10 +136,16 @@ function fetch_url_content($url)
136 136
137function display_view($view, $id = 0, $full_head = 'yes') 137function display_view($view, $id = 0, $full_head = 'yes')
138{ 138{
139 global $tpl, $store, $msg; 139 global $tpl, $store;
140 140
141 switch ($view) 141 switch ($view)
142 { 142 {
143 case 'install':
144 pocheTool::logm('install mode');
145 break;
146 case 'import';
147 pocheTool::logm('import mode');
148 break;
143 case 'export': 149 case 'export':
144 $entries = $store->retrieveAll(); 150 $entries = $store->retrieveAll();
145 $tpl->assign('export', pocheTool::renderJson($entries)); 151 $tpl->assign('export', pocheTool::renderJson($entries));
@@ -157,8 +163,8 @@ function display_view($view, $id = 0, $full_head = 'yes')
157 break; 163 break;
158 case 'view': 164 case 'view':
159 $entry = $store->retrieveOneById($id); 165 $entry = $store->retrieveOneById($id);
160
161 if ($entry != NULL) { 166 if ($entry != NULL) {
167 pocheTool::logm('view link #' . $id);
162 $tpl->assign('id', $entry['id']); 168 $tpl->assign('id', $entry['id']);
163 $tpl->assign('url', $entry['url']); 169 $tpl->assign('url', $entry['url']);
164 $tpl->assign('title', $entry['title']); 170 $tpl->assign('title', $entry['title']);
@@ -177,12 +183,9 @@ function display_view($view, $id = 0, $full_head = 'yes')
177 else { 183 else {
178 pocheTool::logm('error in view call : entry is NULL'); 184 pocheTool::logm('error in view call : entry is NULL');
179 } 185 }
180
181 pocheTool::logm('view link #' . $id);
182 break; 186 break;
183 default: # home view 187 default: # home view
184 $entries = $store->getEntriesByView($view); 188 $entries = $store->getEntriesByView($view);
185
186 $tpl->assign('entries', $entries); 189 $tpl->assign('entries', $entries);
187 190
188 if ($full_head == 'yes') { 191 if ($full_head == 'yes') {
@@ -192,7 +195,6 @@ function display_view($view, $id = 0, $full_head = 'yes')
192 } 195 }
193 196
194 $tpl->draw('entries'); 197 $tpl->draw('entries');
195
196 if ($full_head == 'yes') { 198 if ($full_head == 'yes') {
197 $tpl->draw('js'); 199 $tpl->draw('js');
198 $tpl->draw('footer'); 200 $tpl->draw('footer');
@@ -202,11 +204,11 @@ function display_view($view, $id = 0, $full_head = 'yes')
202} 204}
203 205
204/** 206/**
205 * Appel d'une action (mark as fav, archive, delete) 207 * Call action (mark as fav, archive, delete, etc.)
206 */ 208 */
207function action_to_do($action, $url, $id = 0) 209function action_to_do($action, $url, $id = 0)
208{ 210{
209 global $store, $msg; 211 global $store;
210 212
211 switch ($action) 213 switch ($action)
212 { 214 {
diff --git a/inc/poche/pochePictures.php b/inc/poche/pochePictures.php
index bfc80657..0d73a149 100644
--- a/inc/poche/pochePictures.php
+++ b/inc/poche/pochePictures.php
@@ -15,11 +15,9 @@ function filtre_picture($content, $url, $id)
15{ 15{
16 $matches = array(); 16 $matches = array();
17 preg_match_all('#<\s*(img)[^>]+src="([^"]*)"[^>]*>#Si', $content, $matches, PREG_SET_ORDER); 17 preg_match_all('#<\s*(img)[^>]+src="([^"]*)"[^>]*>#Si', $content, $matches, PREG_SET_ORDER);
18 foreach($matches as $i => $link) 18 foreach($matches as $i => $link) {
19 {
20 $link[1] = trim($link[1]); 19 $link[1] = trim($link[1]);
21 if (!preg_match('#^(([a-z]+://)|(\#))#', $link[1]) ) 20 if (!preg_match('#^(([a-z]+://)|(\#))#', $link[1])) {
22 {
23 $absolute_path = get_absolute_link($link[2],$url); 21 $absolute_path = get_absolute_link($link[2],$url);
24 $filename = basename(parse_url($absolute_path, PHP_URL_PATH)); 22 $filename = basename(parse_url($absolute_path, PHP_URL_PATH));
25 $directory = create_assets_directory($id); 23 $directory = create_assets_directory($id);
@@ -36,8 +34,7 @@ function filtre_picture($content, $url, $id)
36/** 34/**
37 * Retourne le lien absolu 35 * Retourne le lien absolu
38 */ 36 */
39function get_absolute_link($relative_link, $url) 37function get_absolute_link($relative_link, $url) {
40{
41 /* return if already absolute URL */ 38 /* return if already absolute URL */
42 if (parse_url($relative_link, PHP_URL_SCHEME) != '') return $relative_link; 39 if (parse_url($relative_link, PHP_URL_SCHEME) != '') return $relative_link;
43 40
@@ -68,7 +65,6 @@ function get_absolute_link($relative_link, $url)
68/** 65/**
69 * Téléchargement des images 66 * Téléchargement des images
70 */ 67 */
71
72function download_pictures($absolute_path, $fullpath) 68function download_pictures($absolute_path, $fullpath)
73{ 69{
74 $rawdata = get_external_file($absolute_path); 70 $rawdata = get_external_file($absolute_path);
@@ -111,4 +107,4 @@ function remove_directory($directory)
111 } 107 }
112 return rmdir($directory); 108 return rmdir($directory);
113 } 109 }
114} 110} \ No newline at end of file
diff --git a/inc/poche/pocheTool.class.php b/inc/poche/pocheTools.class.php
index cade115e..8907c18e 100644
--- a/inc/poche/pocheTool.class.php
+++ b/inc/poche/pocheTools.class.php
@@ -118,7 +118,9 @@ class pocheTools
118 118
119 public static function logm($message) 119 public static function logm($message)
120 { 120 {
121 $t = strval(date('Y/m/d_H:i:s')).' - '.$_SERVER["REMOTE_ADDR"].' - '.strval($message)."\n"; 121 if (DEBUG_POCHE) {
122 file_put_contents('./log.txt',$t,FILE_APPEND); 122 $t = strval(date('Y/m/d_H:i:s')) . ' - ' . $_SERVER["REMOTE_ADDR"] . ' - ' . strval($message) . "\n";
123 file_put_contents('./log.txt', $t, FILE_APPEND);
124 }
123 } 125 }
124} \ No newline at end of file 126} \ No newline at end of file