aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
m---------inc/3rdparty/site_config0
-rw-r--r--inc/poche/Database.class.php16
-rw-r--r--inc/poche/Poche.class.php293
-rw-r--r--inc/poche/Tools.class.php40
-rwxr-xr-xinc/poche/config.inc.php89
-rwxr-xr-xinc/poche/config.inc.php.new56
-rw-r--r--inc/poche/global.inc.php72
7 files changed, 435 insertions, 131 deletions
diff --git a/inc/3rdparty/site_config b/inc/3rdparty/site_config
deleted file mode 160000
Subproject fe9f0d3f60d44a8701f3ecab0c4077a4ed39bfe
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 84916b83..4d664992 100644
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -60,11 +60,15 @@ class Database {
60 $id_user = intval($this->getLastId($sequence)); 60 $id_user = intval($this->getLastId($sequence));
61 61
62 $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)'; 62 $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)';
63 $params = array($id_user, 'pager', '10'); 63 $params = array($id_user, 'pager', PAGINATION);
64 $query = $this->executeQuery($sql, $params); 64 $query = $this->executeQuery($sql, $params);
65 65
66 $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)'; 66 $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)';
67 $params = array($id_user, 'language', 'en_EN.UTF8'); 67 $params = array($id_user, 'language', LANG);
68 $query = $this->executeQuery($sql, $params);
69
70 $sql = 'INSERT INTO users_config ( user_id, name, value ) VALUES (?, ?, ?)';
71 $params = array($id_user, 'theme', DEFAULT_THEME);
68 $query = $this->executeQuery($sql, $params); 72 $query = $this->executeQuery($sql, $params);
69 73
70 return TRUE; 74 return TRUE;
@@ -101,10 +105,16 @@ class Database {
101 return $user; 105 return $user;
102 } 106 }
103 107
104 public function updatePassword($id, $password) 108 public function updatePassword($userId, $password)
105 { 109 {
106 $sql_update = "UPDATE users SET password=? WHERE id=?"; 110 $sql_update = "UPDATE users SET password=? WHERE id=?";
107 $params_update = array($password, $id); 111 $params_update = array($password, $id);
112 $this->updateUserConfig($userId, 'password', $password);
113 }
114
115 public function updateUserConfig($userId, $key, $value) {
116 $sql_update = "UPDATE users_config SET `value`=? WHERE `user_id`=? AND `name`=?";
117 $params_update = array($value, $userId, $key);
108 $query = $this->executeQuery($sql_update, $params_update); 118 $query = $this->executeQuery($sql_update, $params_update);
109 } 119 }
110 120
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 8770c7f7..67fbd529 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -10,77 +10,200 @@
10 10
11class Poche 11class Poche
12{ 12{
13 public static $canRenderTemplates = true;
14 public static $configFileAvailable = true;
15
13 public $user; 16 public $user;
14 public $store; 17 public $store;
15 public $tpl; 18 public $tpl;
16 public $messages; 19 public $messages;
17 public $pagination; 20 public $pagination;
18 21
19 function __construct() 22 private $currentTheme = '';
23 private $notInstalledMessage = '';
24
25 # @todo make this dynamic (actually install themes and save them in the database including author information et cetera)
26 private $installedThemes = array(
27 'default' => array('requires' => array()),
28 'dark' => array('requires' => array('default')),
29 'dmagenta' => array('requires' => array('default')),
30 'solarized' => array('requires' => array('default')),
31 'solarized-dark' => array('requires' => array('default'))
32 );
33
34 public function __construct()
20 { 35 {
36 if (! $this->configFileIsAvailable()) {
37 return;
38 }
39
40 $this->init();
41
42 if (! $this->themeIsInstalled()) {
43 return;
44 }
45
21 $this->initTpl(); 46 $this->initTpl();
22 if (!$this->checkBeforeInstall()) { 47
23 exit; 48 if (! $this->systemIsInstalled()) {
49 return;
24 } 50 }
51
25 $this->store = new Database(); 52 $this->store = new Database();
26 $this->init();
27 $this->messages = new Messages(); 53 $this->messages = new Messages();
28 54
29 # installation 55 # installation
30 if(!$this->store->isInstalled()) 56 if (! $this->store->isInstalled()) {
31 {
32 $this->install(); 57 $this->install();
33 } 58 }
34 } 59 }
60
61 private function init()
62 {
63 Tools::initPhp();
64 Session::$sessionName = 'poche';
65 Session::init();
66
67 if (isset($_SESSION['poche_user']) && $_SESSION['poche_user'] != array()) {
68 $this->user = $_SESSION['poche_user'];
69 } else {
70 # fake user, just for install & login screens
71 $this->user = new User();
72 $this->user->setConfig($this->getDefaultConfig());
73 }
74
75 # l10n
76 $language = $this->user->getConfigValue('language');
77 putenv('LC_ALL=' . $language);
78 setlocale(LC_ALL, $language);
79 bindtextdomain($language, LOCALE);
80 textdomain($language);
81
82 # Pagination
83 $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p');
84
85 # Set up theme
86 $themeDirectory = $this->user->getConfigValue('theme');
87
88 if ($themeDirectory === false) {
89 $themeDirectory = DEFAULT_THEME;
90 }
91
92 $this->currentTheme = $themeDirectory;
93 }
94
95 public function configFileIsAvailable() {
96 if (! self::$configFileAvailable) {
97 $this->notInstalledMessage = 'You have to rename <strong>inc/poche/config.inc.php.new</strong> to <strong>inc/poche/config.inc.php</strong>.';
98
99 return false;
100 }
35 101
102 return true;
103 }
104
105 public function themeIsInstalled() {
106 # Twig is an absolute requirement for Poche to function. Abort immediately if the Composer installer hasn't been run yet
107 if (! self::$canRenderTemplates) {
108 $this->notInstalledMessage = 'Twig does not seem to be installed. Please initialize the Composer installation to automatically fetch dependencies. Have a look at <a href="http://inthepoche.com/?pages/Documentation">the documentation.</a>';
109
110 return false;
111 }
112
113 # Check if the selected theme and its requirements are present
114 if (! is_dir(THEME . '/' . $this->getTheme())) {
115 $this->notInstalledMessage = 'The currently selected theme (' . $this->getTheme() . ') does not seem to be properly installed (Missing directory: ' . THEME . '/' . $this->getTheme() . ')';
116
117 self::$canRenderTemplates = false;
118
119 return false;
120 }
121
122 foreach ($this->installedThemes[$this->getTheme()]['requires'] as $requiredTheme) {
123 if (! is_dir(THEME . '/' . $requiredTheme)) {
124 $this->notInstalledMessage = 'The required "' . $requiredTheme . '" theme is missing for the current theme (' . $this->getTheme() . ')';
125
126 self::$canRenderTemplates = false;
127
128 return false;
129 }
130 }
131
132 return true;
133 }
134
36 /** 135 /**
37 * all checks before installation. 136 * all checks before installation.
137 * @todo move HTML to template
38 * @return boolean 138 * @return boolean
39 */ 139 */
40 private function checkBeforeInstall() 140 public function systemIsInstalled()
41 { 141 {
42 $msg = ''; 142 $msg = '';
43 $allIsGood = TRUE; 143
44 144 $configSalt = defined('SALT') ? constant('SALT') : '';
45 if (!is_writable(CACHE)) { 145
146 if (empty($configSalt)) {
147 $msg = '<h1>error</h1><p>You have not yet filled in the SALT value in the config.inc.php file.</p>';
148 } else if (! is_writable(CACHE)) {
46 Tools::logm('you don\'t have write access on cache directory'); 149 Tools::logm('you don\'t have write access on cache directory');
47 die('You don\'t have write access on cache directory.'); 150 $msg = '<h1>error</h1><p>You don\'t have write access on cache directory.</p>';
48 } 151 } else if (STORAGE == 'sqlite' && ! file_exists(STORAGE_SQLITE)) {
49 else if (file_exists('./install/update.php') && !DEBUG_POCHE) { 152 Tools::logm('sqlite file doesn\'t exist');
153 $msg = '<h1>error</h1><p>sqlite file doesn\'t exist, you can find it in install folder.</p>';
154 } else if (file_exists(ROOT . '/install/update.php') && ! DEBUG_POCHE) {
50 $msg = '<h1>setup</h1><p><strong>It\'s your first time here?</strong> Please copy /install/poche.sqlite in db folder. Then, delete install folder.<br /><strong>If you have already installed poche</strong>, an update is needed <a href="install/update.php">by clicking here</a>.</p>'; 155 $msg = '<h1>setup</h1><p><strong>It\'s your first time here?</strong> Please copy /install/poche.sqlite in db folder. Then, delete install folder.<br /><strong>If you have already installed poche</strong>, an update is needed <a href="install/update.php">by clicking here</a>.</p>';
51 $allIsGood = FALSE; 156 } else if (is_dir(ROOT . '/install') && ! DEBUG_POCHE) {
52 }
53 else if (file_exists('./install') && !DEBUG_POCHE) {
54 $msg = '<h1>setup</h1><p><strong>If you want to update your poche</strong>, you just have to delete /install folder. <br /><strong>To install your poche with sqlite</strong>, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.</p>'; 157 $msg = '<h1>setup</h1><p><strong>If you want to update your poche</strong>, you just have to delete /install folder. <br /><strong>To install your poche with sqlite</strong>, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.</p>';
55 $allIsGood = FALSE; 158 } else if (STORAGE == 'sqlite' && ! is_writable(STORAGE_SQLITE)) {
56 }
57 else if (STORAGE == 'sqlite' && !is_writable(STORAGE_SQLITE)) {
58 Tools::logm('you don\'t have write access on sqlite file'); 159 Tools::logm('you don\'t have write access on sqlite file');
59 $msg = '<h1>error</h1><p>You don\'t have write access on sqlite file.</p>'; 160 $msg = '<h1>error</h1><p>You don\'t have write access on sqlite file.</p>';
60 $allIsGood = FALSE;
61 } 161 }
62 162
63 if (!$allIsGood) { 163 if (! empty($msg)) {
64 echo $this->tpl->render('error.twig', array( 164 $this->notInstalledMessage = $msg;
65 'msg' => $msg 165
66 )); 166 return false;
67 } 167 }
68 168
69 return $allIsGood; 169 return true;
170 }
171
172 public function getNotInstalledMessage() {
173 return $this->notInstalledMessage;
70 } 174 }
71 175
72 private function initTpl() 176 private function initTpl()
73 { 177 {
74 # template engine 178 $loaderChain = new Twig_Loader_Chain();
75 $loader = new Twig_Loader_Filesystem(TPL); 179
180 # add the current theme as first to the loader chain so Twig will look there first for overridden template files
181 try {
182 $loaderChain->addLoader(new Twig_Loader_Filesystem(THEME . '/' . $this->getTheme()));
183 } catch (Twig_Error_Loader $e) {
184 # @todo isInstalled() should catch this, inject Twig later
185 die('The currently selected theme (' . $this->getTheme() . ') does not seem to be properly installed (' . THEME . '/' . $this->getTheme() .' is missing)');
186 }
187
188 # add all required themes to the loader chain
189 foreach ($this->installedThemes[$this->getTheme()]['requires'] as $requiredTheme) {
190 try {
191 $loaderChain->addLoader(new Twig_Loader_Filesystem(THEME . '/' . DEFAULT_THEME));
192 } catch (Twig_Error_Loader $e) {
193 # @todo isInstalled() should catch this, inject Twig later
194 die('The required "' . $requiredTheme . '" theme is missing for the current theme (' . $this->getTheme() . ')');
195 }
196 }
197
76 if (DEBUG_POCHE) { 198 if (DEBUG_POCHE) {
77 $twig_params = array(); 199 $twig_params = array();
78 } 200 } else {
79 else {
80 $twig_params = array('cache' => CACHE); 201 $twig_params = array('cache' => CACHE);
81 } 202 }
82 $this->tpl = new Twig_Environment($loader, $twig_params); 203
204 $this->tpl = new Twig_Environment($loaderChain, $twig_params);
83 $this->tpl->addExtension(new Twig_Extensions_Extension_I18n()); 205 $this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
206
84 # filter to display domain name of an url 207 # filter to display domain name of an url
85 $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); 208 $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
86 $this->tpl->addFilter($filter); 209 $this->tpl->addFilter($filter);
@@ -88,39 +211,19 @@ class Poche
88 # filter for reading time 211 # filter for reading time
89 $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime'); 212 $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
90 $this->tpl->addFilter($filter); 213 $this->tpl->addFilter($filter);
91 } 214
92 215 # filter for simple filenames in config view
93 private function init() 216 $filter = new Twig_SimpleFilter('getPrettyFilename', function($string) { return str_replace(ROOT, '', $string); });
94 { 217 $this->tpl->addFilter($filter);
95 Tools::initPhp();
96 Session::$sessionName = 'poche';
97 Session::init();
98
99 if (isset($_SESSION['poche_user']) && $_SESSION['poche_user'] != array()) {
100 $this->user = $_SESSION['poche_user'];
101 }
102 else {
103 # fake user, just for install & login screens
104 $this->user = new User();
105 $this->user->setConfig($this->getDefaultConfig());
106 }
107
108 # l10n
109 $language = $this->user->getConfigValue('language');
110 putenv('LC_ALL=' . $language);
111 setlocale(LC_ALL, $language);
112 bindtextdomain($language, LOCALE);
113 textdomain($language);
114
115 # Pagination
116 $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p');
117 } 218 }
118 219
119 private function install() 220 private function install()
120 { 221 {
121 Tools::logm('poche still not installed'); 222 Tools::logm('poche still not installed');
122 echo $this->tpl->render('install.twig', array( 223 echo $this->tpl->render('install.twig', array(
123 'token' => Session::getToken() 224 'token' => Session::getToken(),
225 'theme' => $this->getTheme(),
226 'poche_url' => Tools::getPocheUrl()
124 )); 227 ));
125 if (isset($_GET['install'])) { 228 if (isset($_GET['install'])) {
126 if (($_POST['password'] == $_POST['password_repeat']) 229 if (($_POST['password'] == $_POST['password_repeat'])
@@ -140,13 +243,41 @@ class Poche
140 } 243 }
141 exit(); 244 exit();
142 } 245 }
246
247 public function getTheme() {
248 return $this->currentTheme;
249 }
250
251 public function getInstalledThemes() {
252 $handle = opendir(THEME);
253 $themes = array();
254
255 while (($theme = readdir($handle)) !== false) {
256 # Themes are stored in a directory, so all directory names are themes
257 # @todo move theme installation data to database
258 if (! is_dir(THEME . '/' . $theme) || in_array($theme, array('..', '.'))) {
259 continue;
260 }
261
262 $current = false;
263
264 if ($theme === $this->getTheme()) {
265 $current = true;
266 }
267
268 $themes[] = array('name' => $theme, 'current' => $current);
269 }
270
271 return $themes;
272 }
143 273
144 public function getDefaultConfig() 274 public function getDefaultConfig()
145 { 275 {
146 return array( 276 return array(
147 'pager' => PAGINATION, 277 'pager' => PAGINATION,
148 'language' => LANG, 278 'language' => LANG,
149 ); 279 'theme' => DEFAULT_THEME
280 );
150 } 281 }
151 282
152 /** 283 /**
@@ -231,7 +362,9 @@ class Poche
231 $prod = $this->getPocheVersion('prod'); 362 $prod = $this->getPocheVersion('prod');
232 $compare_dev = version_compare(POCHE_VERSION, $dev); 363 $compare_dev = version_compare(POCHE_VERSION, $dev);
233 $compare_prod = version_compare(POCHE_VERSION, $prod); 364 $compare_prod = version_compare(POCHE_VERSION, $prod);
365 $themes = $this->getInstalledThemes();
234 $tpl_vars = array( 366 $tpl_vars = array(
367 'themes' => $themes,
235 'dev' => $dev, 368 'dev' => $dev,
236 'prod' => $prod, 369 'prod' => $prod,
237 'compare_dev' => $compare_dev, 370 'compare_dev' => $compare_dev,
@@ -316,6 +449,44 @@ class Poche
316 } 449 }
317 } 450 }
318 } 451 }
452
453 public function updateTheme()
454 {
455 # no data
456 if (empty($_POST['theme'])) {
457 }
458
459 # we are not going to change it to the current theme...
460 if ($_POST['theme'] == $this->getTheme()) {
461 $this->messages->add('w', _('still using the "' . $this->getTheme() . '" theme!'));
462 Tools::redirect('?view=config');
463 }
464
465 $themes = $this->getInstalledThemes();
466 $actualTheme = false;
467
468 foreach ($themes as $theme) {
469 if ($theme['name'] == $_POST['theme']) {
470 $actualTheme = true;
471 break;
472 }
473 }
474
475 if (! $actualTheme) {
476 $this->messages->add('e', _('that theme does not seem to be installed'));
477 Tools::redirect('?view=config');
478 }
479
480 $this->store->updateUserConfig($this->user->getId(), 'theme', $_POST['theme']);
481 $this->messages->add('s', _('you have changed your theme preferences'));
482
483 $currentConfig = $_SESSION['poche_user']->config;
484 $currentConfig['theme'] = $_POST['theme'];
485
486 $_SESSION['poche_user']->setConfig($currentConfig);
487
488 Tools::redirect('?view=config');
489 }
319 490
320 /** 491 /**
321 * checks if login & password are correct and save the user in session. 492 * checks if login & password are correct and save the user in session.
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php
index 1ab90be1..8eb988f4 100644
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -84,9 +84,9 @@ class Tools
84 84
85 public static function getTplFile($view) 85 public static function getTplFile($view)
86 { 86 {
87 $tpl_file = 'home.twig'; 87 $default_tpl = 'home.twig';
88 switch ($view) 88
89 { 89 switch ($view) {
90 case 'install': 90 case 'install':
91 $tpl_file = 'install.twig'; 91 $tpl_file = 'install.twig';
92 break; 92 break;
@@ -102,9 +102,20 @@ class Tools
102 case 'view': 102 case 'view':
103 $tpl_file = 'view.twig'; 103 $tpl_file = 'view.twig';
104 break; 104 break;
105
106 case 'login':
107 $tpl_file = 'login.twig';
108 break;
109
110 case 'error':
111 $tpl_file = 'error.twig';
112 break;
113
105 default: 114 default:
106 break; 115 $tpl_file = $default_tpl;
116 break;
107 } 117 }
118
108 return $tpl_file; 119 return $tpl_file;
109 } 120 }
110 121
@@ -228,27 +239,6 @@ class Tools
228 return $minutes; 239 return $minutes;
229 } 240 }
230 241
231
232 public static function createMyConfig()
233 {
234 $myconfig_file = './inc/poche/myconfig.inc.php';
235
236 if (!is_writable('./inc/poche/')) {
237 self::logm('you don\'t have write access to create ./inc/poche/myconfig.inc.php');
238 die('You don\'t have write access to create ./inc/poche/myconfig.inc.php.');
239 }
240
241 if (!file_exists($myconfig_file))
242 {
243 $fp = fopen($myconfig_file, 'w');
244 fwrite($fp, '<?php'."\r\n");
245 fwrite($fp, "define ('POCHE_VERSION', '1.0-beta4');" . "\r\n");
246 fwrite($fp, "define ('SALT', '" . md5(time() . $_SERVER['SCRIPT_FILENAME'] . rand()) . "');" . "\r\n");
247 fwrite($fp, "define ('LANG', 'en_EN.utf8');" . "\r\n");
248 fclose($fp);
249 }
250 }
251
252 public static function getDocLanguage($userlanguage) { 242 public static function getDocLanguage($userlanguage) {
253 $lang = explode('.', $userlanguage); 243 $lang = explode('.', $userlanguage);
254 return str_replace('_', '-', $lang[0]); 244 return str_replace('_', '-', $lang[0]);
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php
index aaa26af8..5c304d14 100755
--- a/inc/poche/config.inc.php
+++ b/inc/poche/config.inc.php
@@ -3,49 +3,54 @@
3 * poche, a read it later open source system 3 * poche, a read it later open source system
4 * 4 *
5 * @category poche 5 * @category poche
6 * @author Nicolas Lœuillet <support@inthepoche.com> 6 * @author Nicolas Lœuillet <nicolas@loeuillet.org>
7 * @copyright 2013 7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file 8 * @license http://www.wtfpl.net/ see COPYING file
9 */ 9 */
10 10
11require_once __DIR__ . '/../../inc/poche/define.inc.php'; 11define ('SALT', ''); # put a strong string here
12 12define ('LANG', 'en_EN.utf8');
13# /!\ Be careful if you change the lines below /!\ 13
14if (!file_exists(__DIR__ . '/../../vendor/autoload.php')) { 14define ('STORAGE', 'sqlite'); # postgres, mysql or sqlite
15 die('Twig does not seem installed. Have a look at <a href="inthepoche.com/doc">the documentation.</a>'); 15
16} 16define ('STORAGE_SQLITE', ROOT . '/db/poche.sqlite'); # if you are using sqlite, where the database file is located
17 17
18require_once __DIR__ . '/../../inc/poche/User.class.php'; 18# only for postgres & mysql
19require_once __DIR__ . '/../../inc/poche/Url.class.php'; 19define ('STORAGE_SERVER', 'localhost');
20require_once __DIR__ . '/../../inc/3rdparty/class.messages.php'; 20define ('STORAGE_DB', 'poche');
21require_once __DIR__ . '/../../inc/poche/Poche.class.php'; 21define ('STORAGE_USER', 'poche');
22require_once __DIR__ . '/../../inc/3rdparty/Readability.php'; 22define ('STORAGE_PASSWORD', 'poche');
23require_once __DIR__ . '/../../inc/poche/PocheReadability.php'; 23
24require_once __DIR__ . '/../../inc/3rdparty/Encoding.php'; 24#################################################################################
25require_once __DIR__ . '/../../inc/poche/Database.class.php'; 25# Do not trespass unless you know what you are doing
26require_once __DIR__ . '/../../vendor/autoload.php'; 26#################################################################################
27require_once __DIR__ . '/../../inc/3rdparty/simple_html_dom.php'; 27
28require_once __DIR__ . '/../../inc/3rdparty/paginator.php'; 28define ('MODE_DEMO', FALSE);
29require_once __DIR__ . '/../../inc/3rdparty/Session.class.php'; 29define ('DEBUG_POCHE', true);
30 30define ('DOWNLOAD_PICTURES', FALSE);
31require_once __DIR__ . '/../../inc/3rdparty/simplepie/SimplePieAutoloader.php'; 31define ('CONVERT_LINKS_FOOTNOTES', FALSE);
32require_once __DIR__ . '/../../inc/3rdparty/simplepie/SimplePie/Core.php'; 32define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE);
33require_once __DIR__ . '/../../inc/3rdparty/content-extractor/ContentExtractor.php'; 33define ('SHARE_TWITTER', TRUE);
34require_once __DIR__ . '/../../inc/3rdparty/content-extractor/SiteConfig.php'; 34define ('SHARE_MAIL', TRUE);
35require_once __DIR__ . '/../../inc/3rdparty/humble-http-agent/HumbleHttpAgent.php'; 35define ('SHARE_SHAARLI', FALSE);
36require_once __DIR__ . '/../../inc/3rdparty/humble-http-agent/SimplePie_HumbleHttpAgent.php'; 36define ('SHAARLI_URL', 'http://myshaarliurl.com');
37require_once __DIR__ . '/../../inc/3rdparty/humble-http-agent/CookieJar.php'; 37define ('FLATTR', TRUE);
38require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedItem.php'; 38define ('FLATTR_API', 'https://api.flattr.com/rest/v2/things/lookup/?url=');
39require_once __DIR__ . '/../../inc/3rdparty/feedwriter/FeedWriter.php'; 39define ('NOT_FLATTRABLE', '0');
40require_once __DIR__ . '/../../inc/3rdparty/feedwriter/DummySingleItemFeed.php'; 40define ('FLATTRABLE', '1');
41require_once __DIR__ . '/../../inc/3rdparty/FlattrItem.class.php'; 41define ('FLATTRED', '2');
42 42define ('ABS_PATH', 'assets/');
43if (DOWNLOAD_PICTURES) { 43
44 require_once __DIR__ . '/../../inc/poche/pochePictures.php'; 44define ('DEFAULT_THEME', 'default');
45} 45
46 46define ('THEME', ROOT . '/themes');
47if (!ini_get('date.timezone') || !@date_default_timezone_set(ini_get('date.timezone'))) { 47define ('LOCALE', ROOT . '/locale');
48 date_default_timezone_set('UTC'); 48define ('CACHE', ROOT . '/cache');
49} 49
50 50define ('PAGINATION', '10');
51$poche = new Poche(); \ No newline at end of file 51
52define ('POCHE_VERSION', '1.0-beta5');
53
54define ('IMPORT_POCKET_FILE', ROOT . '/ril_export.html');
55define ('IMPORT_READABILITY_FILE', ROOT . '/readability');
56define ('IMPORT_INSTAPAPER_FILE', ROOT . '/instapaper-export.html'); \ No newline at end of file
diff --git a/inc/poche/config.inc.php.new b/inc/poche/config.inc.php.new
new file mode 100755
index 00000000..5c304d14
--- /dev/null
+++ b/inc/poche/config.inc.php.new
@@ -0,0 +1,56 @@
1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas Lœuillet <nicolas@loeuillet.org>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
11define ('SALT', ''); # put a strong string here
12define ('LANG', 'en_EN.utf8');
13
14define ('STORAGE', 'sqlite'); # postgres, mysql or sqlite
15
16define ('STORAGE_SQLITE', ROOT . '/db/poche.sqlite'); # if you are using sqlite, where the database file is located
17
18# only for postgres & mysql
19define ('STORAGE_SERVER', 'localhost');
20define ('STORAGE_DB', 'poche');
21define ('STORAGE_USER', 'poche');
22define ('STORAGE_PASSWORD', 'poche');
23
24#################################################################################
25# Do not trespass unless you know what you are doing
26#################################################################################
27
28define ('MODE_DEMO', FALSE);
29define ('DEBUG_POCHE', true);
30define ('DOWNLOAD_PICTURES', FALSE);
31define ('CONVERT_LINKS_FOOTNOTES', FALSE);
32define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE);
33define ('SHARE_TWITTER', TRUE);
34define ('SHARE_MAIL', TRUE);
35define ('SHARE_SHAARLI', FALSE);
36define ('SHAARLI_URL', 'http://myshaarliurl.com');
37define ('FLATTR', TRUE);
38define ('FLATTR_API', 'https://api.flattr.com/rest/v2/things/lookup/?url=');
39define ('NOT_FLATTRABLE', '0');
40define ('FLATTRABLE', '1');
41define ('FLATTRED', '2');
42define ('ABS_PATH', 'assets/');
43
44define ('DEFAULT_THEME', 'default');
45
46define ('THEME', ROOT . '/themes');
47define ('LOCALE', ROOT . '/locale');
48define ('CACHE', ROOT . '/cache');
49
50define ('PAGINATION', '10');
51
52define ('POCHE_VERSION', '1.0-beta5');
53
54define ('IMPORT_POCKET_FILE', ROOT . '/ril_export.html');
55define ('IMPORT_READABILITY_FILE', ROOT . '/readability');
56define ('IMPORT_INSTAPAPER_FILE', ROOT . '/instapaper-export.html'); \ No newline at end of file
diff --git a/inc/poche/global.inc.php b/inc/poche/global.inc.php
new file mode 100644
index 00000000..2437d065
--- /dev/null
+++ b/inc/poche/global.inc.php
@@ -0,0 +1,72 @@
1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas Lœuillet <nicolas@loeuillet.org>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
11# the poche system root directory (/inc)
12define('INCLUDES', dirname(__FILE__) . '/..');
13
14# the poche root directory
15define('ROOT', INCLUDES . '/..');
16
17require_once INCLUDES . '/poche/Tools.class.php';
18require_once INCLUDES . '/poche/User.class.php';
19require_once INCLUDES . '/poche/Url.class.php';
20require_once INCLUDES . '/3rdparty/class.messages.php';
21require_once INCLUDES . '/poche/Poche.class.php';
22
23require_once INCLUDES . '/3rdparty/Readability.php';
24require_once INCLUDES . '/poche/PocheReadability.php';
25
26require_once INCLUDES . '/3rdparty/Encoding.php';
27require_once INCLUDES . '/poche/Database.class.php';
28require_once INCLUDES . '/3rdparty/simple_html_dom.php';
29require_once INCLUDES . '/3rdparty/paginator.php';
30require_once INCLUDES . '/3rdparty/Session.class.php';
31
32require_once INCLUDES . '/3rdparty/simplepie/SimplePieAutoloader.php';
33require_once INCLUDES . '/3rdparty/simplepie/SimplePie/Core.php';
34require_once INCLUDES . '/3rdparty/content-extractor/ContentExtractor.php';
35require_once INCLUDES . '/3rdparty/content-extractor/SiteConfig.php';
36require_once INCLUDES . '/3rdparty/humble-http-agent/HumbleHttpAgent.php';
37require_once INCLUDES . '/3rdparty/humble-http-agent/SimplePie_HumbleHttpAgent.php';
38require_once INCLUDES . '/3rdparty/humble-http-agent/CookieJar.php';
39require_once INCLUDES . '/3rdparty/feedwriter/FeedItem.php';
40require_once INCLUDES . '/3rdparty/feedwriter/FeedWriter.php';
41require_once INCLUDES . '/3rdparty/feedwriter/DummySingleItemFeed.php';
42require_once INCLUDES . '/3rdparty/FlattrItem.class.php';
43
44# Composer its autoloader for automatically loading Twig
45if (! file_exists(ROOT . '/vendor/autoload.php')) {
46 Poche::$canRenderTemplates = false;
47} else {
48 require_once ROOT . '/vendor/autoload.php';
49}
50
51# system configuration; database credentials et cetera
52if (! file_exists(INCLUDES . '/poche/config.inc.php')) {
53 Poche::$configFileAvailable = false;
54} else {
55 require_once INCLUDES . '/poche/config.inc.php';
56}
57
58if (Poche::$configFileAvailable && DOWNLOAD_PICTURES) {
59 require_once INCLUDES . '/poche/pochePictures.php';
60}
61
62if (!ini_get('date.timezone') || !@date_default_timezone_set(ini_get('date.timezone'))) {
63 date_default_timezone_set('UTC');
64}
65
66#XSRF protection with token
67if (!empty($_POST)) {
68 if (!Session::isToken($_POST['token'])) {
69 die(_('Wrong token'));
70 }
71 unset($_SESSION['token']);
72} \ No newline at end of file