aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/poche/Poche.class.php69
-rw-r--r--inc/poche/config.inc.php4
2 files changed, 54 insertions, 19 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 82f0228e..1d8aaca2 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -18,11 +18,10 @@ class Poche
18 18
19 function __construct() 19 function __construct()
20 { 20 {
21 if (file_exists('./install') && !DEBUG_POCHE) { 21 $this->initTpl();
22 Tools::logm('folder /install exists'); 22 if (!$this->checkBeforeInstall()) {
23 die('If you want to update your poche, you just have to delete /install folder. <br />To install your poche with sqlite, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.'); 23 exit;
24 } 24 }
25
26 $this->store = new Database(); 25 $this->store = new Database();
27 $this->init(); 26 $this->init();
28 $this->messages = new Messages(); 27 $this->messages = new Messages();
@@ -34,27 +33,37 @@ class Poche
34 } 33 }
35 } 34 }
36 35
37 private function init() 36 /**
37 * all checks before installation.
38 * @return boolean
39 */
40 private function checkBeforeInstall()
38 { 41 {
39 Tools::initPhp(); 42 $msg = '';
40 Session::init(); 43 $allIsGood = TRUE;
44 if (file_exists('./install') && !DEBUG_POCHE) {
45 Tools::logm('folder /install exists');
46 $msg = 'If you want to update your poche, you just have to delete /install folder. <br />To install your poche with sqlite, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.';
47 $allIsGood = FALSE;
48 }
41 49
42 if (isset($_SESSION['poche_user']) && $_SESSION['poche_user'] != array()) { 50 if (STORAGE == 'sqlite' && !is_writable(STORAGE_SQLITE)) {
43 $this->user = $_SESSION['poche_user']; 51 Tools::logm('you don\'t have write access on db file');
52 $msg = 'You don\'t have write access on ' . STORAGE_SQLITE . ' file.';
53 $allIsGood = FALSE;
44 } 54 }
45 else { 55
46 # fake user, just for install & login screens 56 if (!$allIsGood) {
47 $this->user = new User(); 57 echo $this->tpl->render('error.twig', array(
48 $this->user->setConfig($this->getDefaultConfig()); 58 'msg' => $msg
59 ));
49 } 60 }
50 61
51 # l10n 62 return $allIsGood;
52 $language = $this->user->getConfigValue('language'); 63 }
53 putenv('LC_ALL=' . $language);
54 setlocale(LC_ALL, $language);
55 bindtextdomain($language, LOCALE);
56 textdomain($language);
57 64
65 private function initTpl()
66 {
58 # template engine 67 # template engine
59 $loader = new Twig_Loader_Filesystem(TPL); 68 $loader = new Twig_Loader_Filesystem(TPL);
60 if (DEBUG_POCHE) { 69 if (DEBUG_POCHE) {
@@ -72,6 +81,28 @@ class Poche
72 # filter for reading time 81 # filter for reading time
73 $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime'); 82 $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
74 $this->tpl->addFilter($filter); 83 $this->tpl->addFilter($filter);
84 }
85
86 private function init()
87 {
88 Tools::initPhp();
89 Session::init();
90
91 if (isset($_SESSION['poche_user']) && $_SESSION['poche_user'] != array()) {
92 $this->user = $_SESSION['poche_user'];
93 }
94 else {
95 # fake user, just for install & login screens
96 $this->user = new User();
97 $this->user->setConfig($this->getDefaultConfig());
98 }
99
100 # l10n
101 $language = $this->user->getConfigValue('language');
102 putenv('LC_ALL=' . $language);
103 setlocale(LC_ALL, $language);
104 bindtextdomain($language, LOCALE);
105 textdomain($language);
75 106
76 # Pagination 107 # Pagination
77 $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p'); 108 $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p');
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php
index ba8a9fa0..ecbf1ce6 100644
--- a/inc/poche/config.inc.php
+++ b/inc/poche/config.inc.php
@@ -34,6 +34,10 @@ define ('PAGINATION', '10');
34define ('THEME', 'light'); 34define ('THEME', 'light');
35 35
36# /!\ Be careful if you change the lines below /!\ 36# /!\ Be careful if you change the lines below /!\
37if (!file_exists('./vendor/autoload.php')) {
38 die('Twig does not seem installed. Have a look at <a href="http://inthepoche.com/?pages/Documentation">the documentation.</a>');
39}
40
37require_once './inc/poche/User.class.php'; 41require_once './inc/poche/User.class.php';
38require_once './inc/poche/Tools.class.php'; 42require_once './inc/poche/Tools.class.php';
39require_once './inc/poche/Url.class.php'; 43require_once './inc/poche/Url.class.php';