aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--inc/poche/Poche.class.php30
-rw-r--r--inc/poche/Tools.class.php26
-rwxr-xr-x[-rw-r--r--]inc/poche/config.inc.php57
-rw-r--r--inc/poche/define.inc.php30
-rw-r--r--index.php3
-rw-r--r--install/update.php78
6 files changed, 175 insertions, 49 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 4371c3d3..cb865a2a 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -41,15 +41,23 @@ class Poche
41 { 41 {
42 $msg = ''; 42 $msg = '';
43 $allIsGood = TRUE; 43 $allIsGood = TRUE;
44 if (file_exists('./install') && !DEBUG_POCHE) { 44
45 Tools::logm('folder /install exists'); 45 if (file_exists('./install/update.php') && !DEBUG_POCHE) {
46 $msg = 'A poche update is needed. Please execute this update <a href="install/update.php">by clicking here</a>. If you have already do the update, please delete /install folder.';
47 $allIsGood = FALSE;
48 }
49 else if (file_exists('./install') && !DEBUG_POCHE) {
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.'; 50 $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; 51 $allIsGood = FALSE;
48 } 52 }
49 53 else if (STORAGE == 'sqlite' && !is_writable(STORAGE_SQLITE)) {
50 if (STORAGE == 'sqlite' && !is_writable(STORAGE_SQLITE)) { 54 Tools::logm('you don\'t have write access on sqlite file');
51 Tools::logm('you don\'t have write access on db file'); 55 $msg = 'You don\'t have write access on sqlite file.';
52 $msg = 'You don\'t have write access on ' . STORAGE_SQLITE . ' file.'; 56 $allIsGood = FALSE;
57 }
58 else if (!is_writable(CACHE)) {
59 Tools::logm('you don\'t have write access on cache directory');
60 $msg = 'You don\'t have write access on cache directory.';
53 $allIsGood = FALSE; 61 $allIsGood = FALSE;
54 } 62 }
55 63
@@ -118,10 +126,12 @@ class Poche
118 if (($_POST['password'] == $_POST['password_repeat']) 126 if (($_POST['password'] == $_POST['password_repeat'])
119 && $_POST['password'] != "" && $_POST['login'] != "") { 127 && $_POST['password'] != "" && $_POST['login'] != "") {
120 # let's rock, install poche baby ! 128 # let's rock, install poche baby !
121 $this->store->install($_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login'])); 129 if ($this->store->install($_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login'])))
122 Session::logout(); 130 {
123 Tools::logm('poche is now installed'); 131 Session::logout();
124 Tools::redirect(); 132 Tools::logm('poche is now installed');
133 Tools::redirect();
134 }
125 } 135 }
126 else { 136 else {
127 Tools::logm('error during installation'); 137 Tools::logm('error during installation');
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php
index 0eb0d9ea..1baf745d 100644
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -233,4 +233,30 @@ class Tools
233 233
234 return $minutes; 234 return $minutes;
235 } 235 }
236
237
238 public static function createMyConfig()
239 {
240 $myconfig_file = './inc/poche/myconfig.inc.php';
241
242 if (version_compare(POCHE_VERSION, '1.0-beta3') == 1) {
243 # $myconfig_file is only created with poche > 1.0-beta3
244 # in 1.0-beta3, the update script creates $myconfig_file
245
246 if (!is_writable('./inc/poche/')) {
247 self::logm('you don\'t have write access to create ./inc/poche/myconfig.inc.php');
248 die('You don\'t have write access to create ./inc/poche/myconfig.inc.php.');
249 }
250
251 if (!file_exists($myconfig_file))
252 {
253 $fp = fopen($myconfig_file, 'w');
254 fwrite($fp, '<?php'."\r\n");
255 fwrite($fp, "define ('POCHE_VERSION', '1.0-beta3');" . "\r\n");
256 fwrite($fp, "define ('SALT', '" . md5(time() . $_SERVER['SCRIPT_FILENAME'] . rand()) . "');" . "\r\n");
257 fwrite($fp, "define ('LANG', 'en_EN.utf8');" . "\r\n");
258 fclose($fp);
259 }
260 }
261 }
236} \ No newline at end of file 262} \ No newline at end of file
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php
index ecbf1ce6..4122ff10 100644..100755
--- a/inc/poche/config.inc.php
+++ b/inc/poche/config.inc.php
@@ -8,51 +8,30 @@
8 * @license http://www.wtfpl.net/ see COPYING file 8 * @license http://www.wtfpl.net/ see COPYING file
9 */ 9 */
10 10
11# storage 11require_once __DIR__ . '/../../inc/poche/define.inc.php';
12define ('STORAGE','sqlite'); # postgres, mysql, sqlite
13define ('STORAGE_SERVER', 'localhost'); # leave blank for sqlite
14define ('STORAGE_DB', 'poche'); # only for postgres & mysql
15define ('STORAGE_SQLITE', './db/poche.sqlite');
16define ('STORAGE_USER', 'postgres'); # leave blank for sqlite
17define ('STORAGE_PASSWORD', 'postgres'); # leave blank for sqlite
18
19define ('POCHE_VERSION', '1.0-beta2');
20define ('MODE_DEMO', FALSE);
21define ('DEBUG_POCHE', FALSE);
22define ('CONVERT_LINKS_FOOTNOTES', FALSE);
23define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE);
24define ('DOWNLOAD_PICTURES', FALSE);
25define ('SHARE_TWITTER', TRUE);
26define ('SHARE_MAIL', TRUE);
27define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX');
28define ('ABS_PATH', 'assets/');
29define ('TPL', './tpl');
30define ('LOCALE', './locale');
31define ('CACHE', './cache');
32define ('LANG', 'en_EN.UTF8');
33define ('PAGINATION', '10');
34define ('THEME', 'light');
35 12
36# /!\ Be careful if you change the lines below /!\ 13# /!\ Be careful if you change the lines below /!\
37if (!file_exists('./vendor/autoload.php')) { 14if (!file_exists(__DIR__ . '/../../vendor/autoload.php')) {
38 die('Twig does not seem installed. Have a look at <a href="http://inthepoche.com/?pages/Documentation">the documentation.</a>'); 15 die('Twig does not seem installed. Have a look at <a href="http://inthepoche.com/?pages/Documentation">the documentation.</a>');
39} 16}
40 17
41require_once './inc/poche/User.class.php'; 18if (file_exists(__DIR__ . '/../../inc/poche/myconfig.inc.php')) {
42require_once './inc/poche/Tools.class.php'; 19 require_once __DIR__ . '/../../inc/poche/myconfig.inc.php';
43require_once './inc/poche/Url.class.php'; 20}
44require_once './inc/3rdparty/class.messages.php'; 21require_once __DIR__ . '/../../inc/poche/User.class.php';
45require_once './inc/poche/Poche.class.php'; 22require_once __DIR__ . '/../../inc/poche/Url.class.php';
46require_once './inc/3rdparty/Readability.php'; 23require_once __DIR__ . '/../../inc/3rdparty/class.messages.php';
47require_once './inc/3rdparty/Encoding.php'; 24require_once __DIR__ . '/../../inc/poche/Poche.class.php';
48require_once './inc/poche/Database.class.php'; 25require_once __DIR__ . '/../../inc/3rdparty/Readability.php';
49require_once './vendor/autoload.php'; 26require_once __DIR__ . '/../../inc/3rdparty/Encoding.php';
50require_once './inc/3rdparty/simple_html_dom.php'; 27require_once __DIR__ . '/../../inc/poche/Database.class.php';
51require_once './inc/3rdparty/paginator.php'; 28require_once __DIR__ . '/../../vendor/autoload.php';
52require_once './inc/3rdparty/Session.class.php'; 29require_once __DIR__ . '/../../inc/3rdparty/simple_html_dom.php';
30require_once __DIR__ . '/../../inc/3rdparty/paginator.php';
31require_once __DIR__ . '/../../inc/3rdparty/Session.class.php';
53 32
54if (DOWNLOAD_PICTURES) { 33if (DOWNLOAD_PICTURES) {
55 require_once './inc/poche/pochePictures.php'; 34 require_once __DIR__ . '/../../inc/poche/pochePictures.php';
56} 35}
57 36
58$poche = new Poche(); 37$poche = new Poche();
diff --git a/inc/poche/define.inc.php b/inc/poche/define.inc.php
new file mode 100644
index 00000000..c32ca098
--- /dev/null
+++ b/inc/poche/define.inc.php
@@ -0,0 +1,30 @@
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 ('STORAGE','sqlite'); # postgres, mysql, sqlite
12define ('STORAGE_SERVER', 'localhost'); # leave blank for sqlite
13define ('STORAGE_DB', 'poche'); # only for postgres & mysql
14define ('STORAGE_SQLITE', __DIR__ . '/../../db/poche.sqlite');
15define ('STORAGE_USER', 'postgres'); # leave blank for sqlite
16define ('STORAGE_PASSWORD', 'postgres'); # leave blank for sqlite
17
18define ('MODE_DEMO', FALSE);
19define ('DEBUG_POCHE', FALSE);
20define ('CONVERT_LINKS_FOOTNOTES', FALSE);
21define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE);
22define ('DOWNLOAD_PICTURES', FALSE);
23define ('SHARE_TWITTER', TRUE);
24define ('SHARE_MAIL', TRUE);
25define ('ABS_PATH', 'assets/');
26define ('TPL', __DIR__ . '/../../tpl');
27define ('LOCALE', __DIR__ . '/../../locale');
28define ('CACHE', __DIR__ . '/../../cache');
29define ('PAGINATION', '10');
30define ('THEME', 'light'); \ No newline at end of file
diff --git a/index.php b/index.php
index a60e4e94..51a33d71 100644
--- a/index.php
+++ b/index.php
@@ -8,6 +8,9 @@
8 * @license http://www.wtfpl.net/ see COPYING file 8 * @license http://www.wtfpl.net/ see COPYING file
9 */ 9 */
10 10
11require_once './inc/poche/Tools.class.php';
12Tools::createMyConfig();
13
11include dirname(__FILE__).'/inc/poche/config.inc.php'; 14include dirname(__FILE__).'/inc/poche/config.inc.php';
12 15
13# Parse GET & REFERER vars 16# Parse GET & REFERER vars
diff --git a/install/update.php b/install/update.php
new file mode 100644
index 00000000..392ab801
--- /dev/null
+++ b/install/update.php
@@ -0,0 +1,78 @@
1<?php
2require_once dirname(__FILE__).'/../inc/poche/Tools.class.php';
3include dirname(__FILE__).'/../inc/poche/define.inc.php';
4require_once __DIR__ . '/../inc/poche/Database.class.php';
5$store = new Database();
6$old_salt = '464v54gLLw928uz4zUBqkRJeiPY68zCX';
7?>
8<!DOCTYPE html>
9<!--[if lte IE 6]> <html class="no-js ie6 ie67 ie678" lang="en"> <![endif]-->
10<!--[if lte IE 7]> <html class="no-js ie7 ie67 ie678" lang="en"> <![endif]-->
11<!--[if IE 8]> <html class="no-js ie8 ie678" lang="en"> <![endif]-->
12<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
13<html>
14 <head>
15 <meta charset="utf-8">
16 <title>updating poche</title>
17 </head>
18 <body>
19 <h1>update poche to 1.0-beta3</h1>
20
21 <h2>Changelog</h2>
22 <p>
23 <ul>
24 <li>this awesome updating step</li>
25 <li>error message when install folder exists</li>
26 <li>more tests before installation (write access, etc.)</li>
27 <li>updated README to make installation easier</li>
28 <li>german language thanks to HLFH</li>
29 <li>spanish language thanks to Nitche</li>
30 <li>new file ./inc/poche/myconfig.inc.php created to store language and salt</li>
31 <li><a href="https://github.com/inthepoche/poche/issues/119">#119</a>: salt is now created when installing poche</li>
32 <li><a href="https://github.com/inthepoche/poche/issues/130">#130</a>: robotx.txt added</li>
33 <li><a href="https://github.com/inthepoche/poche/issues/136">#136</a>: error during readability import</li>
34 <li><a href="https://github.com/inthepoche/poche/issues/137">#137</a>: mixed content alert in https</li>
35 <li><a href="https://github.com/inthepoche/poche/issues/138">#138</a>: change pattern to parse url with #</li>
36 </ul>
37 </p>
38 <p>
39 <form name="update" method="post">
40 <div><label for="login">login:</label> <input type="text" name="login" id="login" /></div>
41 <div><label for="password">password:</label> <input type="password" name="password" id="password" /></div>
42 <div><input type="hidden" name="go" value="ok" /><input type="submit" value="update" /></div>
43 </form>
44 </p>
45<?php
46if (isset($_POST['go'])) {
47 if (!empty($_POST['login']) && !empty($_POST['password'])) {
48 $user = $store->login($_POST['login'], sha1($_POST['password'] . $_POST['login'] . $old_salt));
49 if ($user != array()) {
50 $new_salt = md5(time() . $_SERVER['SCRIPT_FILENAME'] . rand());
51 $myconfig_file = '../inc/poche/myconfig.inc.php';
52 if (!is_writable('../inc/poche/')) {
53 die('You don\'t have write access to create ./inc/poche/myconfig.inc.php.');
54 }
55
56 if (!file_exists($myconfig_file))
57 {
58 $fp = fopen($myconfig_file, 'w');
59
60 fwrite($fp, '<?php'."\r\n");
61 fwrite($fp, "define ('POCHE_VERSION', '1.0-beta3');" . "\r\n");
62 fwrite($fp, "define ('SALT', '" . $new_salt . "');" . "\r\n");
63 fwrite($fp, "define ('LANG', 'en_EN.utf8');" . "\r\n");
64 fclose($fp);
65 }
66 # faire une mise à jour de la table users en prenant en compte le nouveau SALT généré
67 $store->updatePassword($user['id'], sha1($_POST['password'] . $_POST['login'] . $new_salt));
68?>
69 <p><span style="color: green;">your poche is up to date!</span></p>
70 <p><span style="color: red;">don't forget to delete ./install/ folder after the update.</span></p>
71 <p><a href="../">go back to your poche</a></p>
72<?php
73 }
74 }
75}
76?>
77 </body>
78</html> \ No newline at end of file