aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-15 10:54:14 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-15 10:54:14 +0200
commit4a2912880f0914b456711d695f96ce2ace18c814 (patch)
tree6a2532f63eb1f443f9358f36a76b8427e377abd3
parentca1b0a1a6fb9b331c631df32d132736c9c627ac4 (diff)
downloadwallabag-4a2912880f0914b456711d695f96ce2ace18c814.tar.gz
wallabag-4a2912880f0914b456711d695f96ce2ace18c814.tar.zst
wallabag-4a2912880f0914b456711d695f96ce2ace18c814.zip
more verif while installing
-rw-r--r--inc/poche/Poche.class.php69
-rw-r--r--inc/poche/config.inc.php4
-rw-r--r--tpl/error.twig7
-rw-r--r--tpl/install.twig16
4 files changed, 69 insertions, 27 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';
diff --git a/tpl/error.twig b/tpl/error.twig
new file mode 100644
index 00000000..84c3bc1c
--- /dev/null
+++ b/tpl/error.twig
@@ -0,0 +1,7 @@
1{% extends "layout.twig" %}
2{% block title %}{% trans "error" %}{% endblock %}
3{% block content %}
4 <h1>error</h1>
5 <p>{{ msg|raw }}</p>
6 <p>Don't forget <a href="http://inthepoche.com/?pages/Documentation">the documentation</a>.</p>
7{% endblock %} \ No newline at end of file
diff --git a/tpl/install.twig b/tpl/install.twig
index 8bcede0d..afb5b0f6 100644
--- a/tpl/install.twig
+++ b/tpl/install.twig
@@ -7,21 +7,21 @@
7 <p> 7 <p>
8 {% trans "poche is still not installed. Please fill the below form to install it. Don't hesitate to <a href='http://inthepoche.com/?pages/Documentation'>read the documentation on poche website</a>." %} 8 {% trans "poche is still not installed. Please fill the below form to install it. Don't hesitate to <a href='http://inthepoche.com/?pages/Documentation'>read the documentation on poche website</a>." %}
9 </p> 9 </p>
10 <div class="row"> 10 <p class="row">
11 <label class="col w150p" for="login">{% trans "Login" %}</label> 11 <label class="col w150p" for="login">{% trans "Login" %}</label>
12 <input class="col" type="text" id="login" name="login" placeholder="Login" tabindex="1" autofocus /> 12 <input class="col" type="text" id="login" name="login" placeholder="Login" tabindex="1" autofocus />
13 </div> 13 </p>
14 <div class="row"> 14 <p class="row">
15 <label class="col w150p" for="password">{% trans "Password" %}</label> 15 <label class="col w150p" for="password">{% trans "Password" %}</label>
16 <input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2"> 16 <input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2">
17 </div> 17 </p>
18 <div class="row"> 18 <p class="row">
19 <label class="col w150p" for="password_repeat">{% trans "Repeat your password" %}</label> 19 <label class="col w150p" for="password_repeat">{% trans "Repeat your password" %}</label>
20 <input class="col" type="password" id="password_repeat" name="password_repeat" placeholder="Password" tabindex="3"> 20 <input class="col" type="password" id="password_repeat" name="password_repeat" placeholder="Password" tabindex="3">
21 </div> 21 </p>
22 <div class="row mts txtcenter"> 22 <p class="row mts txtcenter">
23 <button class="bouton" type="submit" tabindex="4">{% trans "Install" %}</button> 23 <button class="bouton" type="submit" tabindex="4">{% trans "Install" %}</button>
24 </div> 24 </p>
25 </fieldset> 25 </fieldset>
26 <input type="hidden" name="token" value="{{ token }}"> 26 <input type="hidden" name="token" value="{{ token }}">
27 </form> 27 </form>