diff --git a/cron.php b/cron.php deleted file mode 100644 index 8fbf421..0000000 --- a/cron.php +++ /dev/null @@ -1,53 +0,0 @@ -getConfigUser($user_id); - -if ($token != $config['token']) { - die(_('Uh, there is a problem with the cron.')); -} - -$items = $store->retrieveUnfetchedEntries($user_id, $limit); - -foreach ($items as $item) { - $url = new Url(base64_encode($item['url'])); - $content = Tools::getPageContent($url); - - $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'); - $body = $content['rss']['channel']['item']['description']; - - // // clean content from prevent xss attack - $config = HTMLPurifier_Config::createDefault(); - $purifier = new HTMLPurifier($config); - $title = $purifier->purify($title); - $body = $purifier->purify($body); - - - $store->updateContentAndTitle($item['id'], $title, $body, $user_id); -} \ No newline at end of file diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index ee3b2ac..a662f69 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -368,31 +368,23 @@ class Poche switch ($action) { case 'add': - if (!$import) { - $content = Tools::getPageContent($url); - $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'); - $body = $content['rss']['channel']['item']['description']; + $content = Tools::getPageContent($url); + $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'); + $body = $content['rss']['channel']['item']['description']; - // clean content from prevent xss attack - $config = HTMLPurifier_Config::createDefault(); - $config->set('Cache.SerializerPath', CACHE); - $purifier = new HTMLPurifier($config); - $title = $purifier->purify($title); - $body = $purifier->purify($body); - } - else { - $title = ''; - $body = ''; - } + // clean content from prevent xss attack + $config = HTMLPurifier_Config::createDefault(); + $config->set('Cache.SerializerPath', CACHE); + $purifier = new HTMLPurifier($config); + $title = $purifier->purify($title); + $body = $purifier->purify($body); //search for possible duplicate $duplicate = NULL; - if (!$import) { - $duplicate = $this->store->retrieveOneByURL($url->getUrl(), $this->user->getId()); - } + $duplicate = $this->store->retrieveOneByURL($url->getUrl(), $this->user->getId()); $last_id = $this->store->add($url->getUrl(), $title, $body, $this->user->getId()); - if ( $last_id && !$import ) { + if ( $last_id ) { Tools::logm('add link ' . $url->getUrl()); if (DOWNLOAD_PICTURES) { $content = filtre_picture($body, $url->getUrl(), $last_id); @@ -416,18 +408,14 @@ class Poche $this->messages->add('s', _('the link has been added successfully')); } else { - if (!$import) { - $this->messages->add('e', _('error during insertion : the link wasn\'t added')); - Tools::logm('error during insertion : the link wasn\'t added ' . $url->getUrl()); - } + $this->messages->add('e', _('error during insertion : the link wasn\'t added')); + Tools::logm('error during insertion : the link wasn\'t added ' . $url->getUrl()); } - if (!$import) { - if ($autoclose == TRUE) { - Tools::redirect('?view=home'); - } else { - Tools::redirect('?view=home&closewin=true'); - } + if ($autoclose == TRUE) { + Tools::redirect('?view=home'); + } else { + Tools::redirect('?view=home&closewin=true'); } break; case 'delete': @@ -448,33 +436,21 @@ class Poche case 'toggle_fav' : $this->store->favoriteById($id, $this->user->getId()); Tools::logm('mark as favorite link #' . $id); - if (!$import) { - Tools::redirect(); - } + Tools::redirect(); break; case 'toggle_archive' : $this->store->archiveById($id, $this->user->getId()); Tools::logm('archive link #' . $id); - if (!$import) { - Tools::redirect(); - } + Tools::redirect(); break; case 'archive_all' : $this->store->archiveAll($this->user->getId()); Tools::logm('archive all links'); - if (!$import) { - Tools::redirect(); - } + Tools::redirect(); break; case 'add_tag' : - if($import){ - $entry_id = $id; - $tags = explode(',', $tags); - } - else{ - $tags = explode(',', $_POST['value']); - $entry_id = $_POST['entry_id']; - } + $tags = explode(',', $_POST['value']); + $entry_id = $_POST['entry_id']; $entry = $this->store->retrieveOneById($entry_id, $this->user->getId()); if (!$entry) { $this->messages->add('e', _('Article not found!')); @@ -509,9 +485,7 @@ class Poche $this->store->setTagToEntry($tag_id, $entry_id); } } - if(!$import) { - Tools::redirect(); - } + Tools::redirect(); break; case 'remove_tag' : $tag_id = $_GET['tag_id']; @@ -844,206 +818,19 @@ class Poche Tools::redirect(); } - /** - * import from Instapaper. poche needs a ./instapaper-export.html file - * @todo add the return value - * @param string $targetFile the file used for importing - * @return boolean - */ - private function importFromInstapaper($targetFile) - { - # TODO gestion des articles favs - $html = new simple_html_dom(); - $html->load_file($targetFile); - Tools::logm('starting import from instapaper'); - - $read = 0; - $errors = array(); - foreach($html->find('ol') as $ul) - { - foreach($ul->find('li') as $li) - { - $a = $li->find('a'); - $url = new Url(base64_encode($a[0]->href)); - $this->action('add', $url, 0, TRUE); - if ($read == '1') { - $sequence = ''; - if (STORAGE == 'postgres') { - $sequence = 'entries_id_seq'; - } - $last_id = $this->store->getLastId($sequence); - $this->action('toggle_archive', $url, $last_id, TRUE); - } - } - - # the second
'; - //var_dump($record); - // foreach ($record as $key=>$val) { - // echo "\n=================\n$i: $key: $val\n"; - // } - // exit; - - $url = trim($record['url']); + $url = trim( isset($record['article__url']) ? $record['article__url'] : (isset($record['url']) ? $record['url'] : '') ); if ( $url ) { $title = (isset($record['title']) ? $record['title'] : _('Untitled - Import - ').' '._('click to finish import').''); $body = (isset($record['content']) ? $record['content'] : ''); - $isRead = (isset($record['is_read']) ? intval($record['is_read']) : 0); - $isFavorite = (isset($record['is_fav']) ? intval($record['is_fav']) : 0); + $isRead = (isset($record['is_read']) ? intval($record['is_read']) : (isset($record['archive'])?intval($record['archive']):0)); + $isFavorite = (isset($record['is_fav']) ? intval($record['is_fav']) : (isset($record['favorite'])?intval($record['favorite']):0) ); //insert new record $id = $this->store->add($url, $title, $body, $this->user->getId(), $isFavorite, $isRead); if ( $id ) { @@ -1146,22 +938,6 @@ class Poche return array('includeImport'=>true, 'import'=>array('recordsDownloadRequired'=>$recordsDownloadRequired, 'recordsUnderDownload'=> IMPORT_LIMIT, 'delay'=> IMPORT_DELAY * 1000) ); } - public function uploadFile() { - if (isset($_FILES['file'])) - { - $dir = CACHE . '/'; - $file = basename($_FILES['file']['name']); - if(move_uploaded_file($_FILES['file']['tmp_name'], $dir . $file)) { - $this->messages->add('s', _('File uploaded. You can now execute import.')); - } - else { - $this->messages->add('e', _('Error while importing file. Do you have access to upload it?')); - } - } - - Tools::redirect('?view=config'); - } - /** * export poche entries in json * @return json all poche entries