]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - install/index.php
1.9.0 version
[github/wallabag/wallabag.git] / install / index.php
index 30bc2f6bce51d5ca79662a2d93149a2b743d4ecb..31c15f89f2850105d2bdcc2d00f7a711eb7ce8ac 100755 (executable)
 $errors = array();
 $successes = array();
 
+$final = false;
+
 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');      
     }
 }
 
@@ -81,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']);
@@ -124,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);
@@ -142,7 +157,7 @@ else if (isset($_POST['install'])) {
         foreach ($moreQueries as $query) {
             executeQuery($handle, $query, array());
         }
-        $successes[] = 'wallabag is now installed. You can now <a href="index.php?clean=0">access it !</a>';
+        
 
     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.';
@@ -153,6 +168,7 @@ else if (isset($_POST['install'])) {
         }
         $content = str_replace("define ('SALT', '');", "define ('SALT', '".$salt."');", $content);
         file_put_contents('inc/poche/config.inc.php', $content);
+        $final = true;
     }
 }
 }
@@ -296,12 +312,12 @@ cursor: pointer;
 }
 .compatibity_result {
        margin: auto;
-       max-width: 300px;
+       max-width: 350px;
        min-height: 50px;
        line-height: 50px;
        text-align: center;
-    margin-bottom: 30px;
-    border-radius: 3px;
+   margin-bottom: 30px;
+   border-radius: 3px;
 }
 
 h2, legend {
@@ -329,6 +345,21 @@ border: 1px solid #000;
     background-color: #FFF;
     color: #000;
 }
+.final {
+   margin-top: 10%;
+   margin-left: 30%;
+   max-width: 400px;
+   text-align: center;
+   border-radius: 6px;
+}
+.final h1 {
+   line-height: 50px;
+}
+
+.final em {
+   margin-top: 40px;
+   font-size: 12px;
+}
 
 </style>
 
@@ -346,7 +377,8 @@ border: 1px solid #000;
                 <li><a href="http://doc.wallabag.org/" target="_blank">Online doc</a></li>
                 <li><a href="http://support.wallabag.org/" target="_blank">help</a></li>
                 <li><a href="http://www.wallabag.org/" target="_blank">wallabag.org</a></li>
-            </ul> 
+            </ul>
+            <?php if (!$final) : ?>
             <?php if (!empty($errors)) : ?>
                 <div class='messages error install'>
                     <p>Errors during installation:</p>
@@ -374,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, 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; ?>
@@ -386,10 +420,10 @@ border: 1px solid #000;
                    <?php if (isOkay()) { ?>
                        <div class="compatibity_result detail good">All good</div>
                            <?php } elseif (isPassing()) { ?>
-                           <div class="compatibity_result detail pass">Some problems, but it's OK !</div>
+                           <div class="compatibity_result detail pass">Some warnings, but the minimum is here !</div>
                            <?php } else  { ?>
                            <div class="compatibity_result detail bad">Bad news : you can't run wallabag</div>
-                           <?php } $status = status(); ?>
+                           <?php } $status = status(); $pdo_drivers = pdoDrivers(); ?>
             </div>
 
             <div class="details">
@@ -503,8 +537,16 @@ border: 1px solid #000;
                             <tr class="<?php echo ($status['allow_url_fopen']) ? 'enabled' : 'disabled'; ?>">
                                 <td><a href="http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen">allow_url_fopen</a></td>
                                 <td>Enabled</td>
-                                <?php echo ($status['allow_url_fopen']) ? '<td class="good">Enabled' : '<td class="bad">Disabled'; ?></td>
-                                <td><?php echo ($status['allow_url_fopen']) ? '<strong>allow_url_fopen:</strong> You have allow_url_fopen enabled.' : '<strong>allow_url_fopen:</strong> Your PHP configuration has allow_url_fopen disabled.  <strong>' . $status['app_name'] . ' will not work here.</strong>' ?></td>
+                                <?php if ($status['allow_url_fopen']) { ?>
+                                <td class="good">Enabled</td>
+                                <td><strong>allow_url_fopen:</strong> You have allow_url_fopen enabled.
+                                <?php } elseif ($status['curl']) { ?>
+                                <td class="pass">Disabled</td>
+                                <td><strong>allow_url_fopen</strong> is disabled, but curl is supported, so it should be ok.</td>
+                                <?php } else { ?>
+                                <td class="bad">Disabled</td>
+                                <td><strong>allow_url_fopen:</strong> Your PHP configuration has allow_url_fopen disabled.
+                                <strong><?php echo $status['app_name']; ?>  will not work here.</strong><?php } ?></td>
                             </tr>
                             <tr class="<?php echo ($status['gettext']) ? 'enabled' : 'disabled'; ?>">
                                 <td><a href="http://php.net/manual/en/book.gettext.php">gettext</a></td>
@@ -569,38 +611,54 @@ php composer.phar install</code></pre>
                     <p>
                         Database engine:
                         <ul>
-                            <li><label for="sqlite">SQLite</label> <input name="db_engine" type="radio" checked="" id="sqlite" value="sqlite" />
-                            <div id="pdo_sqlite" class='messages error install'>
-                                <p>You have to enable <a href="http://php.net/manual/ref.pdo-sqlite.php">pdo_sqlite extension</a>.</p>
-                            </div>
-                            </li>
-                            <li>
-                                <label for="mysql">MySQL</label> <input name="db_engine" type="radio" id="mysql" value="mysql" />
-                                <div id="pdo_mysql" class='messages notice install'>
-                                    <p>All fields have to be filled.</p>
-                                </div>
-                                <ul id="mysql_infos">
-                                    <li><label for="mysql_server">Server</label> <input type="text" placeholder="localhost" id="mysql_server" name="mysql_server" /></li>
-                                    <li><label for="mysql_database">Database</label> <input type="text" placeholder="wallabag" id="mysql_database" name="mysql_database" /></li>
-                                    <li><label for="mysql_user">User</label> <input type="text" placeholder="user" id="mysql_user" name="mysql_user" /></li>
-                                    <li><label for="mysql_password">Password</label> <input type="password" placeholder="p4ssw0rd" id="mysql_password" name="mysql_password" /></li>
-                                    <li><label for="mysql_utf8_mb4">Use UTF-8 MB4</label> <input id="mysql_utf8_mb4" type="checkbox" name="mysql_utf8_mb4">
-                                    <div id="utf8_mb4_infos"><em>Warning :</em> UTF-8 MB4 is used to fully support unicode characters. It is available only with MySQL starting with version 5.5.3. 
+                           <li>
+                              <?php if ($pdo_drivers['sqlite']) { ?>
+                               <label for="sqlite">SQLite</label> <input name="db_engine" type="radio" checked="" id="sqlite" value="sqlite" />
+                               <?php } else { ?>
+                                 <div class="messages notice">
+                                          <p>You have to enable <a href="http://php.net/manual/ref.pdo-sqlite.php">pdo_sqlite extension</a> to use SQLite.</p>
+                                   </div>
+                              <?php } ?>
+                           </li>
+                           <li>
+                              <?php if ($pdo_drivers['mysql']) { ?>
+                              <label for="mysql">MySQL</label> <input name="db_engine" type="radio" id="mysql" value="mysql" />
+                              <div id="pdo_mysql" class='messages notice install'>
+                                 <p>All fields have to be filled.</p>
+                              </div>
+                              <ul id="mysql_infos">
+                                 <li><label for="mysql_server">Server</label> <input type="text" placeholder="localhost" id="mysql_server" name="mysql_server" /></li>
+                                 <li><label for="mysql_database">Database</label> <input type="text" placeholder="wallabag" id="mysql_database" name="mysql_database" /></li>
+                                 <li><label for="mysql_user">User</label> <input type="text" placeholder="user" id="mysql_user" name="mysql_user" /></li>
+                                 <li><label for="mysql_password">Password</label> <input type="password" placeholder="p4ssw0rd" id="mysql_password" name="mysql_password" /></li>
+                                 <li><label for="mysql_utf8_mb4">Use UTF-8 MB4</label> <input id="mysql_utf8_mb4" type="checkbox" name="mysql_utf8_mb4">
+                                 <div id="utf8_mb4_infos"><em>Warning :</em> UTF-8 MB4 is used to fully support unicode characters. It is available only with MySQL starting with version 5.5.3. 
                                     Install will failed if you check this while using an older MySQL server.</div></li>
-                                </ul>
-                            </li>
-                            <li>
-                                <label for="postgres">PostgreSQL</label> <input name="db_engine" type="radio" id="postgres" value="postgres" />
-                                <div id="pdo_postgres" class='messages notice install'>
+                              </ul>
+                              <?php } else { ?>
+                                 <div class="messages notice">
+                                    <p>You have to enable <a href="http://php.net/manual/ref.pdo-mysql.php">pdo_mysql extension</a> to use MySQL.</p>
+                                 </div>
+                              <?php } ?>
+                           </li>
+                           <li>
+                              <?php if ($pdo_drivers['postgres']) { ?>
+                                 <label for="postgres">PostgreSQL</label> <input name="db_engine" type="radio" id="postgres" value="postgres" />
+                                 <div id="pdo_postgres" class='messages notice install'>
                                     <p>All fields have to be filled.</p>
-                                </div>
-                                <ul id="pg_infos">
+                                 </div>
+                                 <ul id="pg_infos">
                                     <li><label for="pg_server">Server</label> <input type="text" placeholder="localhost" id="pg_server" name="pg_server" /></li>
                                     <li><label for="pg_database">Database</label> <input type="text" placeholder="wallabag" id="pg_database" name="pg_database" /></li>
                                     <li><label for="pg_user">User</label> <input type="text" placeholder="user" id="pg_user" name="pg_user" /></li>
                                     <li><label for="pg_password">Password</label> <input type="password" placeholder="p4ssw0rd" id="pg_password" name="pg_password" /></li>
-                                </ul>
-                            </li>
+                                 </ul>
+                              <?php } else { ?>
+                                 <div class="messages notice">
+                                    <p>You have to enable <a href="https://php.net/manual/ref.pdo-pgsql.php">pdo_pgsql extension</a> to use PostgreSQL.</p>
+                                 </div>
+                              <?php } ?>
+                           </li>
                         </ul>
                     </p>
                 </fieldset>
@@ -638,11 +696,18 @@ php composer.phar install</code></pre>
                 </div>
             </form>
         </div>
+     <?php else : ?>
+         <div class="final good">
+            <h1>wallabag is now installed ! :-) </h1>
+            <a href="index.php?clean=0">Click here to access the login form</a><br />
+            <em>The installation will now try to delete the install directory. If this fails, delete it manually.</em></div>
+     <?php endif; ?>
         <script>
             <?php if (!is_dir('vendor')) : ?>
             $(".database_info").hide();
             $(".usersettings").hide();
             <?php endif ?>
+
             /* 
              * Database showing/hiding
              */ 
@@ -672,16 +737,9 @@ php composer.phar install</code></pre>
             endif;
             ?>
 
-            <?php
-            if (!extension_loaded('pdo_sqlite')) : ?>
-            $("#install_button").hide();
-            <?php
-            else :
-            ?>
-            $("#pdo_sqlite").hide();
-            <?php
-            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();
@@ -720,13 +778,6 @@ php composer.phar install</code></pre>
                             $("#sqlite_description").show();
                             $("#mysql_description").hide();
                             $("#postgres_description").hide();
-                            <?php
-                            if (!extension_loaded('pdo_sqlite')) : ?>
-                            $("#pdo_sqlite").show();
-                            $("#install_button").hide();
-                            <?php
-                            endif;
-                            ?>
                         }
                     }
                 });