diff --git a/inc/config.php b/inc/config.php index 65b2b9c..58abb53 100644 --- a/inc/config.php +++ b/inc/config.php @@ -10,6 +10,7 @@ define ('POCHE_VERSION', '0.3'); define ('MODE_DEMO', FALSE); +define ('DEBUG_POCHE', TRUE); define ('CONVERT_LINKS_FOOTNOTES', FALSE); define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); define ('DOWNLOAD_PICTURES', FALSE); @@ -24,7 +25,7 @@ $storage_type = 'sqlite'; # sqlite or file # /!\ Be careful if you change the lines below /!\ -require_once 'poche/pocheTool.class.php'; +require_once 'poche/pocheTools.class.php'; require_once 'poche/pocheCore.php'; require_once '3rdparty/Readability.php'; require_once '3rdparty/Encoding.php'; diff --git a/inc/poche/pocheCore.php b/inc/poche/pocheCore.php index 52c603a..34c15d8 100644 --- a/inc/poche/pocheCore.php +++ b/inc/poche/pocheCore.php @@ -136,10 +136,16 @@ function fetch_url_content($url) function display_view($view, $id = 0, $full_head = 'yes') { - global $tpl, $store, $msg; + global $tpl, $store; switch ($view) { + case 'install': + pocheTool::logm('install mode'); + break; + case 'import'; + pocheTool::logm('import mode'); + break; case 'export': $entries = $store->retrieveAll(); $tpl->assign('export', pocheTool::renderJson($entries)); @@ -157,8 +163,8 @@ function display_view($view, $id = 0, $full_head = 'yes') break; case 'view': $entry = $store->retrieveOneById($id); - if ($entry != NULL) { + pocheTool::logm('view link #' . $id); $tpl->assign('id', $entry['id']); $tpl->assign('url', $entry['url']); $tpl->assign('title', $entry['title']); @@ -177,12 +183,9 @@ function display_view($view, $id = 0, $full_head = 'yes') else { pocheTool::logm('error in view call : entry is NULL'); } - - pocheTool::logm('view link #' . $id); break; default: # home view $entries = $store->getEntriesByView($view); - $tpl->assign('entries', $entries); if ($full_head == 'yes') { @@ -192,7 +195,6 @@ function display_view($view, $id = 0, $full_head = 'yes') } $tpl->draw('entries'); - if ($full_head == 'yes') { $tpl->draw('js'); $tpl->draw('footer'); @@ -202,11 +204,11 @@ function display_view($view, $id = 0, $full_head = 'yes') } /** - * Appel d'une action (mark as fav, archive, delete) + * Call action (mark as fav, archive, delete, etc.) */ function action_to_do($action, $url, $id = 0) { - global $store, $msg; + global $store; switch ($action) { diff --git a/inc/poche/pochePictures.php b/inc/poche/pochePictures.php index bfc8065..0d73a14 100644 --- a/inc/poche/pochePictures.php +++ b/inc/poche/pochePictures.php @@ -15,11 +15,9 @@ function filtre_picture($content, $url, $id) { $matches = array(); preg_match_all('#<\s*(img)[^>]+src="([^"]*)"[^>]*>#Si', $content, $matches, PREG_SET_ORDER); - foreach($matches as $i => $link) - { + foreach($matches as $i => $link) { $link[1] = trim($link[1]); - if (!preg_match('#^(([a-z]+://)|(\#))#', $link[1]) ) - { + if (!preg_match('#^(([a-z]+://)|(\#))#', $link[1])) { $absolute_path = get_absolute_link($link[2],$url); $filename = basename(parse_url($absolute_path, PHP_URL_PATH)); $directory = create_assets_directory($id); @@ -36,8 +34,7 @@ function filtre_picture($content, $url, $id) /** * Retourne le lien absolu */ -function get_absolute_link($relative_link, $url) -{ +function get_absolute_link($relative_link, $url) { /* return if already absolute URL */ if (parse_url($relative_link, PHP_URL_SCHEME) != '') return $relative_link; @@ -68,7 +65,6 @@ function get_absolute_link($relative_link, $url) /** * Téléchargement des images */ - function download_pictures($absolute_path, $fullpath) { $rawdata = get_external_file($absolute_path); @@ -111,4 +107,4 @@ function remove_directory($directory) } return rmdir($directory); } -} +} \ No newline at end of file diff --git a/inc/poche/pocheTool.class.php b/inc/poche/pocheTools.class.php similarity index 94% rename from inc/poche/pocheTool.class.php rename to inc/poche/pocheTools.class.php index cade115..8907c18 100644 --- a/inc/poche/pocheTool.class.php +++ b/inc/poche/pocheTools.class.php @@ -118,7 +118,9 @@ class pocheTools public static function logm($message) { - $t = strval(date('Y/m/d_H:i:s')).' - '.$_SERVER["REMOTE_ADDR"].' - '.strval($message)."\n"; - file_put_contents('./log.txt',$t,FILE_APPEND); + if (DEBUG_POCHE) { + $t = strval(date('Y/m/d_H:i:s')) . ' - ' . $_SERVER["REMOTE_ADDR"] . ' - ' . strval($message) . "\n"; + file_put_contents('./log.txt', $t, FILE_APPEND); + } } } \ No newline at end of file