]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - install/index.php
much better fix for #1082
[github/wallabag/wallabag.git] / install / index.php
index 46638f8f02331c4391412c084d67dce25cf28ce3..94cf50ac2d6925cfc8538c3919abb3eff9068f94 100755 (executable)
@@ -17,8 +17,12 @@ require_once('install_functions.php');
 
 if (isset($_GET['clean'])) {
     if (is_dir('install')){
-    delTree('install');
-    header('Location: index.php');      
+        delTree('install');
+        header('Location: index.php');      
+    }
+    if (is_dir('cache')) {
+        delTree('cache', false);
+        header('Location: index.php');      
     }
 }
 
@@ -64,7 +68,7 @@ else if (isset($_POST['install'])) {
 
         if ($_POST['db_engine'] == 'sqlite') {
             if (!copy('install/poche.sqlite', 'db/poche.sqlite')) {
-                $errors[] = 'Impossible to create the SQLite database file.';
+                $errors[] = 'Impossible to create the SQLite database file. Please check your file permissions.';
             }
             else {
                 $db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite';
@@ -83,6 +87,7 @@ else if (isset($_POST['install'])) {
                     $handle = new PDO($db_path, $_POST['mysql_user'], $_POST['mysql_password'], array(
                         PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
                     ));
+                    $content = str_replace("define ('MYSQL_USE_UTF8MB4', FALSE);", "define ('MYSQL_USE_UTF8MB4', TRUE);", $content);
                 } else { // regular UTF8
                     $db_path = 'mysql:host=' . $_POST['mysql_server'] . ';dbname=' . $_POST['mysql_database'];
                     $handle = new PDO($db_path, $_POST['mysql_user'], $_POST['mysql_password']);
@@ -126,6 +131,14 @@ else if (isset($_POST['install'])) {
         }
         }
     }
+
+    $usertest = executeQuery($handle,"SELECT * from users WHERE username = ?", array($username));
+    if (!empty($usertest)) {
+        $continue = false;
+        $errors[] = "An user already exists with this username in database.";
+    }
+
+
     if ($continue) {
         $sql = "INSERT INTO users (username, password, name, email) VALUES (?, ?, ?, '')";
         $params = array($username, $salted_password, $username);
@@ -147,7 +160,7 @@ else if (isset($_POST['install'])) {
         
 
     if (!copy('inc/poche/config.inc.default.php', 'inc/poche/config.inc.php')) {
-        $errors[] = 'Installation aborted, impossible to create inc/poche/config.inc.php file. Maybe you don\'t have write access to create it.';
+        $errors[] = 'Installation aborted, impossible to create inc/poche/config.inc.php file. Maybe you don\'t have write access to create it. Check your file permissions.';
     } else {
         if ($_POST['db_engine'] != 'sqlite') {
             $content = str_replace("define ('STORAGE', 'sqlite');", "define ('STORAGE', '".$_POST['db_engine']."');", $content);
@@ -393,8 +406,10 @@ border: 1px solid #000;
                 <?php if (file_exists('inc/poche/config.inc.php') && is_dir('vendor')) : ?>
                 <div class='messages success install'>
                     <p>
-                        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>.
+                        <a href="index.php?clean=0">Click here to finish update.</a><br>
+                        If it fails, check your file permissions or just delete the install directory.
                     </p>
+                    <p>You may have to clear cache (by going into config screen) after update.</p>
                 </div>
                 <?php endif; ?>    
             <?php endif; ?>
@@ -692,6 +707,7 @@ php composer.phar install</code></pre>
             $(".database_info").hide();
             $(".usersettings").hide();
             <?php endif ?>
+
             /* 
              * Database showing/hiding
              */ 
@@ -721,6 +737,10 @@ php composer.phar install</code></pre>
             endif;
             ?>
 
+            <?php if (file_exists('inc/poche/config.inc.php') && is_dir('vendor')) : ?>
+                $('.technical').hide();
+            <?php endif ?>
+
             $("#mysql_utf8_mb4").click(function() {
                 $("#utf8_mb4_infos").toggle();
             });