]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - install/index.php
fix #1078
[github/wallabag/wallabag.git] / install / index.php
index 8fdc998c96ad0a6ac3a3ef3abb66651d27f3faf5..46638f8f02331c4391412c084d67dce25cf28ce3 100755 (executable)
@@ -11,7 +11,9 @@
 $errors = array();
 $successes = array();
 
-require_once('wallabag_compatibility_test.php');
+$final = false;
+
+require_once('install_functions.php');
 
 if (isset($_GET['clean'])) {
     if (is_dir('install')){
@@ -142,7 +144,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 +155,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 +299,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 +332,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 +364,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>
@@ -386,10 +405,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 +522,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 +596,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,6 +681,12 @@ 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();
@@ -672,17 +721,6 @@ php composer.phar install</code></pre>
             endif;
             ?>
 
-            <?php
-            if (!extension_loaded('pdo_sqlite')) : ?>
-            $("#install_button").hide();
-            <?php
-            else :
-            ?>
-            $("#pdo_sqlite").hide();
-            <?php
-            endif;
-            ?>
-
             $("#mysql_utf8_mb4").click(function() {
                 $("#utf8_mb4_infos").toggle();
             });
@@ -720,13 +758,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;
-                            ?>
                         }
                     }
                 });