]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - settings/install.php
Users: get rid of "user modes" column. Similar to previous, at least for now.
[irc/unrealircd/unrealircd-webpanel.git] / settings / install.php
index 353c16507437dd1de83b36e29b52e73bc4821e65..d215ed912dbd601332d7f2e5f30f3542206708ac 100644 (file)
@@ -96,11 +96,11 @@ $writable = (is_writable("../config/")) ? true: false;
                $auth_method_name = NULL;
                switch($auth_method)
                {
-                       case "sql_auth":
-                               $auth_method_name = "SQLAuth";
+                       case "sql_db":
+                               $auth_method_name = "SQLDB";
                                break;
-                       case "file_auth":
-                               $auth_method_name = "FileAuth";
+                       case "file_db":
+                               $auth_method_name = "FileDB";
                                break;
                }
                if ($auth_method)
@@ -118,7 +118,7 @@ $writable = (is_writable("../config/")) ? true: false;
 
                $config["base_url"] = BASE_URL;
                $config["plugins"] = Array("$auth_method");
-               if ($auth_method == "sql_auth")
+               if ($auth_method == "sql_db")
                {
                        $config["mysql"] = [
                                "host" => $opts->sql_host,
@@ -134,9 +134,15 @@ $writable = (is_writable("../config/")) ? true: false;
                /* First, write only the config file */
                write_config_file();
 
-               if ($auth_method == "sql_auth")
-                       if (!sql_auth::create_tables())
+               if ($auth_method == "sql_db")
+               {
+                       sql_db::delete_tables();
+                       if (!sql_db::create_tables())
                                Message::Fail("Could not create SQL tables");
+               } else if ($auth_method == "file_db")
+               {
+                       file_db::delete_db();
+               }
 
                $user = [
                        "user_name" => $opts->account_user,
@@ -187,22 +193,22 @@ $writable = (is_writable("../config/")) ? true: false;
 <!-- Form start -->
 <form method="post">
 <div id="page3" class="container">
-       <h5>Authentication Backend</h5>
+       <h5>Database Backend</h5>
        <br>
-       Which authentication backend would you like to use?
+       Which database backend would you like to use?
        <br><br>
        Please choose from the available options:
        <div class="form-group">
                <div class="form-check">
-                       <input class="form-check-input" type="radio" name="auth_method" id="file_auth_radio" value="file_auth">
-                       <label class="form-check-label" for="file_auth_radio">
-                               File-based Authentication (Uses local files as a database, no setup needed)
+                       <input class="form-check-input" type="radio" name="auth_method" id="file_db_radio" value="file_db">
+                       <label class="form-check-label" for="file_db_radio">
+                               File-based database (Uses local files as a database, no additional setup needed)
                        </label>
                </div>
                <div class="form-check">
-                       <input class="form-check-input" type="radio" name="auth_method" id="sql_auth_radio" value="sql_auth">
-                       <label class="form-check-label" for="sql_auth_radio">
-                               SQL Authentication (Requires an SQL database)
+                       <input class="form-check-input" type="radio" name="auth_method" id="sql_db_radio" value="sql_db">
+                       <label class="form-check-label" for="sql_db_radio">
+                               SQL Database (Requires an SQL database)
                        </label>
                </div>
        </div>
@@ -279,6 +285,8 @@ $writable = (is_writable("../config/")) ? true: false;
        </div>
 </div>
 </form>
+
+<!-- Database overwrite prompt -->
 <div class="modal fade" id="db_overwrite_modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
@@ -289,7 +297,7 @@ $writable = (is_writable("../config/")) ? true: false;
                        </button>
                </div>
                <div class="modal-body">
-                       The database already contains tables with webpanel data. 
+                       The database already exists and contains data.
                        If you continue then this existing data will be deleted.
                </div>
                <div class="modal-footer">
@@ -301,6 +309,27 @@ $writable = (is_writable("../config/")) ? true: false;
        </div>
 </div>
 
+<!-- Database error dialog -->
+<div class="modal fade" id="db_error_modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
+       <div class="modal-dialog modal-dialog-centered" role="document">
+               <div class="modal-content">
+               <div class="modal-header">
+                       <h5 class="modal-title" id="myModalLabel">Database server error</h5>
+                       <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                       <span aria-hidden="true">&times;</span>
+                       </button>
+               </div>
+               <div class="modal-body" id="db_error_text">
+                       Unable to connect to the database.
+               </div>
+               <div class="modal-footer">
+                               <button id="CloseButton" type="button" class="btn btn-primary" data-dismiss="modal">Ok</button>
+                       </form>
+               </div>
+               </div>
+       </div>
+</div>
+
 <script>
        let BASE_URL = '<?php echo BASE_URL; ?>';
        let chmod_help = document.getElementById('chmod_help');
@@ -313,8 +342,8 @@ $writable = (is_writable("../config/")) ? true: false;
        let page3 = document.getElementById('page3');
        let page4 = document.getElementById('page4');
 
-       let file_auth_radio = document.getElementById('file_auth_radio');
-       let sql_auth_radio = document.getElementById('sql_auth_radio');
+       let file_db_radio = document.getElementById('file_db_radio');
+       let sql_db_radio = document.getElementById('sql_db_radio');
        let sql_form = document.getElementById('sql_form');
        let sql_host = document.getElementById('sql_host');
        let sql_db = document.getElementById('sql_db');
@@ -340,20 +369,25 @@ $writable = (is_writable("../config/")) ? true: false;
        }
 
        page3_next.addEventListener('click', e => {
+<?php if (file_exists(UPATH.'/data/database.php')) { ?>
+               $('#db_overwrite_modal').modal();
+               e.preventDefault();
+               return false;
+<?php } ?>
                page3.style.display = 'none';
                page4.style.display = '';
        });
 
-       file_auth_radio.addEventListener('click', e => {
-               if (file_auth_radio.checked){
+       file_db_radio.addEventListener('click', e => {
+               if (file_db_radio.checked){
                        sql_form.style.display = 'none';
                        sql_test_conn.style.display = 'none';
                        page3_next.style.display = '';
                }
        });
 
-       sql_auth_radio.addEventListener('click', e => {
-               if (!file_auth_radio.checked){
+       sql_db_radio.addEventListener('click', e => {
+               if (!file_db_radio.checked){
                        sql_form.style.display = '';
                        sql_test_conn.style.display = '';
                        page3_next.style.display = 'none';
@@ -390,6 +424,8 @@ $writable = (is_writable("../config/")) ? true: false;
                        else
                        {
                                sql_test_conn.innerHTML = "Failed!";
+                               $('#db_error_text').html(data.error ? data.error : 'An error occured while connecting to the DB server');
+                               $('#db_error_modal').modal();
                                setTimeout(function() {
                                        sql_test_conn.innerHTML = "Test connection";
                                        sql_test_conn.classList.remove('disabled');
@@ -471,7 +507,8 @@ $writable = (is_writable("../config/")) ? true: false;
        function nextstep()
        {
                $('#db_overwrite_modal').modal('hide');
-               page3_next.click();
+               page3.style.display = 'none';
+               page4.style.display = '';
                window.scrollTo(0,0);
        }
 </script>
\ No newline at end of file