diff options
author | Nicolas Lœuillet <nicolas@loeuillet.org> | 2014-03-30 19:57:39 +0200 |
---|---|---|
committer | Nicolas Lœuillet <nicolas@loeuillet.org> | 2014-03-30 19:57:39 +0200 |
commit | 1d0995bb8e09503ad01a877bfef74ef6c29b0dab (patch) | |
tree | e509ab731bb30c397a674c567075d7f41b58789a | |
parent | fecb62a3967eefda9880ce37e13693713385a093 (diff) | |
download | wallabag-1d0995bb8e09503ad01a877bfef74ef6c29b0dab.tar.gz wallabag-1d0995bb8e09503ad01a877bfef74ef6c29b0dab.tar.zst wallabag-1d0995bb8e09503ad01a877bfef74ef6c29b0dab.zip |
[fix] undefined vars in install script
-rw-r--r-- | install/index.php | 64 |
1 files changed, 8 insertions, 56 deletions
diff --git a/install/index.php b/install/index.php index 35c21fbe..599bbe2b 100644 --- a/install/index.php +++ b/install/index.php | |||
@@ -1,27 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | $errors = array(); | 2 | $errors = array(); |
3 | $successes = array(); | 3 | $successes = array(); |
4 | |||
5 | /* Function taken from at http://php.net/manual/en/function.rmdir.php#110489 | ||
6 | * Idea : nbari at dalmp dot com | ||
7 | * Rights unknown | ||
8 | * Here in case of .gitignore files | ||
9 | */ | ||
10 | function delTree($dir) { | ||
11 | $files = array_diff(scandir($dir), array('.','..')); | ||
12 | foreach ($files as $file) { | ||
13 | (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file"); | ||
14 | } | ||
15 | return rmdir($dir); | ||
16 | } | ||
17 | |||
18 | if (isset($_GET['clean'])) { | ||
19 | if (is_dir('install')){ | ||
20 | delTree('install'); | ||
21 | header('Location: index.php'); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | if (isset($_POST['download'])) { | 4 | if (isset($_POST['download'])) { |
26 | if (!file_put_contents("cache/vendor.zip", fopen("http://static.wallabag.org/files/vendor.zip", 'r'))) { | 5 | if (!file_put_contents("cache/vendor.zip", fopen("http://static.wallabag.org/files/vendor.zip", 'r'))) { |
27 | $errors[] = 'Impossible to download vendor.zip. Please <a href="http://wllbg.org/vendor">download it manually<∕a> and unzip it in your wallabag folder.'; | 6 | $errors[] = 'Impossible to download vendor.zip. Please <a href="http://wllbg.org/vendor">download it manually<∕a> and unzip it in your wallabag folder.'; |
@@ -85,11 +64,11 @@ else if (isset($_POST['install'])) { | |||
85 | else { | 64 | else { |
86 | $db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite'; | 65 | $db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite'; |
87 | $handle = new PDO($db_path); | 66 | $handle = new PDO($db_path); |
88 | $sql_structure = ""; | ||
89 | } | 67 | } |
90 | } | 68 | } |
91 | else { | 69 | else { |
92 | $content = file_get_contents('inc/poche/config.inc.php'); | 70 | $content = file_get_contents('inc/poche/config.inc.php'); |
71 | $sql_structure = ''; | ||
93 | 72 | ||
94 | if ($_POST['db_engine'] == 'mysql') { | 73 | if ($_POST['db_engine'] == 'mysql') { |
95 | $db_path = 'mysql:host=' . $_POST['mysql_server'] . ';dbname=' . $_POST['mysql_database']; | 74 | $db_path = 'mysql:host=' . $_POST['mysql_server'] . ';dbname=' . $_POST['mysql_database']; |
@@ -151,7 +130,7 @@ else if (isset($_POST['install'])) { | |||
151 | $params = array($id_user, 'language', 'en_EN.UTF8'); | 130 | $params = array($id_user, 'language', 'en_EN.UTF8'); |
152 | $query = executeQuery($handle, $sql, $params); | 131 | $query = executeQuery($handle, $sql, $params); |
153 | 132 | ||
154 | $successes[] = 'wallabag is now installed. You can now <a href="index.php?clean=0">access it !</a>'; | 133 | $successes[] = 'wallabag is now installed. Don\'t forget to delete install folder. Then, <a href="index.php">reload this page</a>.'; |
155 | } | 134 | } |
156 | } | 135 | } |
157 | } | 136 | } |
@@ -220,18 +199,18 @@ else if (isset($_POST['install'])) { | |||
220 | <?php if (file_exists('inc/poche/config.inc.php') && is_dir('vendor')) : ?> | 199 | <?php if (file_exists('inc/poche/config.inc.php') && is_dir('vendor')) : ?> |
221 | <div class='messages success install'> | 200 | <div class='messages success install'> |
222 | <p> | 201 | <p> |
223 | wallabag seems already installed. If you want to update it, you only have to delete install folder, then <a href="index.php">reload this page</a>. | 202 | wallabag seems already installed. If you want to update it, you only have to delete install folder. |
224 | </p> | 203 | </p> |
225 | </div> | 204 | </div> |
226 | <?php endif; ?> | 205 | <?php endif; ?> |
227 | <?php endif; ?> | 206 | <?php endif; ?> |
228 | <p>To install wallabag, you just have to fill the following fields. That's all.</p> | 207 | <p>To install wallabag, you just have to fill the following fields. That's all.</p> |
229 | <p>Don't forget to check your server compatibility <a href="wallabag_compatibility_test.php?from=install">here</a>.</p> | 208 | <p>Don't forget to check your server compatibility <a href="wallabag_compatibility_test.php">here</a>.</p> |
230 | <form method="post"> | 209 | <form method="post"> |
231 | <fieldset> | 210 | <fieldset> |
232 | <legend><strong>Technical settings</strong></legend> | 211 | <legend><strong>Technical settings</strong></legend> |
233 | <?php if (!is_dir('vendor')) : ?> | 212 | <?php if (!is_dir('vendor')) : ?> |
234 | <div class='messages notice install'>wallabag needs twig, a template engine (<a href="http://twig.sensiolabs.org/">?</a>). Two ways to install it:<br /> | 213 | <div class='messages notice install'>wallabag needs twig, a template engine (<a href="http://twig.sensiolabs.org/">?</a>). Two ways to install it: |
235 | <ul> | 214 | <ul> |
236 | <li>automatically download and extract vendor.zip into your wallabag folder. | 215 | <li>automatically download and extract vendor.zip into your wallabag folder. |
237 | <p><input type="submit" name="download" value="Download vendor.zip" /></p> | 216 | <p><input type="submit" name="download" value="Download vendor.zip" /></p> |
@@ -247,11 +226,7 @@ php composer.phar install</code></pre></li> | |||
247 | <p> | 226 | <p> |
248 | Database engine: | 227 | Database engine: |
249 | <ul> | 228 | <ul> |
250 | <li><label for="sqlite">SQLite</label> <input name="db_engine" type="radio" checked="" id="sqlite" value="sqlite" /> | 229 | <li><label for="sqlite">SQLite</label> <input name="db_engine" type="radio" checked="" id="sqlite" value="sqlite" /></li> |
251 | <div id="pdo_sqlite" class='messages error install'> | ||
252 | <p>You have to enable <a href="http://php.net/manual/ref.pdo-sqlite.php">pdo_sqlite extension</a>.</p> | ||
253 | </div> | ||
254 | </li> | ||
255 | <li> | 230 | <li> |
256 | <label for="mysql">MySQL</label> <input name="db_engine" type="radio" id="mysql" value="mysql" /> | 231 | <label for="mysql">MySQL</label> <input name="db_engine" type="radio" id="mysql" value="mysql" /> |
257 | <ul id="mysql_infos"> | 232 | <ul id="mysql_infos"> |
@@ -267,7 +242,7 @@ php composer.phar install</code></pre></li> | |||
267 | <li><label for="pg_server">Server</label> <input type="text" placeholder="localhost" id="pg_server" name="pg_server" /></li> | 242 | <li><label for="pg_server">Server</label> <input type="text" placeholder="localhost" id="pg_server" name="pg_server" /></li> |
268 | <li><label for="pg_database">Database</label> <input type="text" placeholder="wallabag" id="pg_database" name="pg_database" /></li> | 243 | <li><label for="pg_database">Database</label> <input type="text" placeholder="wallabag" id="pg_database" name="pg_database" /></li> |
269 | <li><label for="pg_user">User</label> <input type="text" placeholder="user" id="pg_user" name="pg_user" /></li> | 244 | <li><label for="pg_user">User</label> <input type="text" placeholder="user" id="pg_user" name="pg_user" /></li> |
270 | <li><label for="pg_password">Password</label> <input type="text" placeholder="p4ssw0rd" id="pg_password" name="pg_password" /></li> | 245 | id <li><label for="pg_password">Password</label> <input type="text" placeholder="p4ssw0rd" id="pg_password" name="pg_password" /></li> |
271 | </ul> | 246 | </ul> |
272 | </li> | 247 | </li> |
273 | </ul> | 248 | </ul> |
@@ -289,49 +264,26 @@ php composer.phar install</code></pre></li> | |||
289 | </p> | 264 | </p> |
290 | </fieldset> | 265 | </fieldset> |
291 | 266 | ||
292 | <input type="submit" id="install_button" value="Install wallabag" name="install" /> | 267 | <input type="submit" value="Install wallabag" name="install" /> |
293 | </form> | 268 | </form> |
294 | </div> | 269 | </div> |
295 | <script> | 270 | <script> |
296 | $("#mysql_infos").hide(); | 271 | $("#mysql_infos").hide(); |
297 | $("#pg_infos").hide(); | 272 | $("#pg_infos").hide(); |
298 | |||
299 | <?php | ||
300 | if (!extension_loaded('pdo_sqlite')) : ?> | ||
301 | $("#install_button").hide(); | ||
302 | <?php | ||
303 | else : | ||
304 | ?> | ||
305 | $("#pdo_sqlite").hide(); | ||
306 | <?php | ||
307 | endif; | ||
308 | ?> | ||
309 | |||
310 | $("input[name=db_engine]").click(function() | 273 | $("input[name=db_engine]").click(function() |
311 | { | 274 | { |
312 | if ( $("#mysql").prop('checked')) { | 275 | if ( $("#mysql").prop('checked')) { |
313 | $("#mysql_infos").show(); | 276 | $("#mysql_infos").show(); |
314 | $("#pg_infos").hide(); | 277 | $("#pg_infos").hide(); |
315 | $("#pdo_sqlite").hide(); | ||
316 | $("#install_button").show(); | ||
317 | } | 278 | } |
318 | else { | 279 | else { |
319 | if ( $("#postgresql").prop('checked')) { | 280 | if ( $("#postgresql").prop('checked')) { |
320 | $("#mysql_infos").hide(); | 281 | $("#mysql_infos").hide(); |
321 | $("#pg_infos").show(); | 282 | $("#pg_infos").show(); |
322 | $("#pdo_sqlite").hide(); | ||
323 | $("#install_button").show(); | ||
324 | } | 283 | } |
325 | else { | 284 | else { |
326 | $("#mysql_infos").hide(); | 285 | $("#mysql_infos").hide(); |
327 | $("#pg_infos").hide(); | 286 | $("#pg_infos").hide(); |
328 | <?php | ||
329 | if (!extension_loaded('pdo_sqlite')) : ?> | ||
330 | $("#pdo_sqlite").show(); | ||
331 | $("#install_button").hide(); | ||
332 | <?php | ||
333 | endif; | ||
334 | ?> | ||
335 | } | 287 | } |
336 | } | 288 | } |
337 | }); | 289 | }); |