aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/poche/Poche.class.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 3ecaf084..ac66dfc9 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -412,6 +412,7 @@ class Poche
412 $compare_prod = version_compare(POCHE, $prod); 412 $compare_prod = version_compare(POCHE, $prod);
413 $themes = $this->getInstalledThemes(); 413 $themes = $this->getInstalledThemes();
414 $languages = $this->getInstalledLanguages(); 414 $languages = $this->getInstalledLanguages();
415 $token = $this->user->getConfigValue('token');
415 $http_auth = (isset($_SERVER['PHP_AUTH_USER']))?true:false; 416 $http_auth = (isset($_SERVER['PHP_AUTH_USER']))?true:false;
416 $tpl_vars = array( 417 $tpl_vars = array(
417 'themes' => $themes, 418 'themes' => $themes,
@@ -420,6 +421,8 @@ class Poche
420 'prod' => $prod, 421 'prod' => $prod,
421 'compare_dev' => $compare_dev, 422 'compare_dev' => $compare_dev,
422 'compare_prod' => $compare_prod, 423 'compare_prod' => $compare_prod,
424 'token' => $token,
425 'user_id' => $this->user->getId(),
423 'http_auth' => $http_auth, 426 'http_auth' => $http_auth,
424 ); 427 );
425 Tools::logm('config view'); 428 Tools::logm('config view');
@@ -837,4 +840,52 @@ class Poche
837 } 840 }
838 return $version; 841 return $version;
839 } 842 }
843
844 public function generateToken()
845 {
846 if (ini_get('open_basedir') === '') {
847 $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
848 }
849 else {
850 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
851 }
852
853 $this->store->updateUserConfig($this->user->getId(), 'token', $token);
854 $currentConfig = $_SESSION['poche_user']->config;
855 $currentConfig['token'] = $token;
856 $_SESSION['poche_user']->setConfig($currentConfig);
857 }
858
859 public function generateFeeds($token, $user_id, $type = 'home')
860 {
861 $allowed_types = array('home', 'fav');
862 $config = $this->store->getConfigUser($user_id);
863
864 if (!in_array($type, $allowed_types) ||
865 $token != $config['token']) {
866 die(_('Uh, there is a problem while generating feeds.'));
867 }
868 // Check the token
869
870 $feed = new FeedWriter(ATOM);
871 $feed->setTitle('poche - ' . $type . ' feed');
872 $feed->setLink(Tools::getPocheUrl());
873 $feed->setChannelElement('updated', date(DATE_ATOM , time()));
874 $feed->setChannelElement('author', 'poche');
875
876 $entries = $this->store->getEntriesByView($type, $user_id);
877 if (count($entries) > 0) {
878 foreach ($entries as $entry) {
879 $newItem = $feed->createNewItem();
880 $newItem->setTitle(htmlentities($entry['title']));
881 $newItem->setLink(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']);
882 $newItem->setDate(time());
883 $newItem->setDescription($entry['content']);
884 $feed->addItem($newItem);
885 }
886 }
887
888 $feed->genarateFeed();
889 exit;
890 }
840} 891}