also prevent it in .htacces. You may want to add this to one of your files in /etc...
[mailer.git] / js / install-common.js
1 /**
2  * JavaScript for common installer functions
3  * --------------------------------------------------------------------
4  * Copyright (c) 2003 - 2009 by Roland Haeder
5  * Copyright (c) 2009 - 2016 by Mailer Developer Team
6  * For more information visit: http://mxchange.org
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21  * MA  02110-1301  USA
22  */
23
24 // Installation steps array
25 var installationSteps = new Array();
26
27 // Failed step
28 var failedStep = '';
29
30 // Init all installation steps
31 installationSteps[0] = 'import_tables_sql';
32 installationSteps[1] = 'import_menu_sql';
33 installationSteps[2] = 'install_extensions';
34 installationSteps[3] = 'register_first_admin';
35
36 // Always keep as last step
37 installationSteps[installationSteps.length] = 'write_local_config';
38
39 // Switches instaler by redirecting
40 function switchInstaller (installer) {
41         // Switch installer
42         document.location.href = 'install.php?installer=' + installer;
43 }
44
45 // User has clicked on 'finish'
46 function doFinishInstallation () {
47         // First disable all buttons button
48         resetFooterNavigation();
49
50         // Display progress window
51         displayProgressWindow('install', 'Init ...');
52
53         // Wait for window fader
54         $().ready(function () {
55                 // Start installation loop delayed
56                 window.setTimeout('doInstallationLoop()', 500);
57
58                 // Wait here
59                 $('body').delay(500);
60         });
61 }
62
63 // Does the "installation loop"
64 function doInstallationLoop () {
65         // Reset counter
66         counterSuccess = 0;
67
68         // For-loop for all installation steps
69         for (var i = 0; i < installationSteps.length; i++) {
70                 // Output message
71                 outputInstallationStepMessage(installationSteps[i]);
72
73                 // Initialize next step
74                 if (sendInstallationStepRequest(i) === false) {
75                         // Failed step, so remember it for later display
76                         failedStep = installationSteps[i];
77
78                         // Stop here
79                         break;
80                 } // END - if
81
82                 // Wait a little
83                 $('body').delay(500);
84
85                 // Update progress bar
86                 updateProgressBar(installationSteps.length);
87         } // END - for
88
89         // Is success counter same as array size
90         if (counterSuccess != installationSteps.length) {
91                 // Display error message
92                 displayErrorWindow('install', getAjaxContent() + ':' + counterSuccess + '/' + installationSteps.length + ':' + failedStep);
93         } else {
94                 // Redirect to admin.php
95                 document.location.href = 'admin.php';
96         }
97 }
98
99 // Sends an "installation step" request out
100 function sendInstallationStepRequest (i) {
101         // Is it set?
102         if (installationSteps[i] == undefined) {
103                 // Not set installation step, so don't send it out
104                 throw new 'installationSteps[' + i + '] is not set.';
105         } // END - if
106
107         // Send out the request
108         return sendAjaxRequest('install', 'do_step', '&step=' + installationSteps[i], false);
109 }
110
111 // Outputs a "step message"
112 function outputInstallationStepMessage (step) {
113         // Set content
114         // @TODO Progress bar is out-of-order: + '<div id="progressbar"></div>'
115         setProgressContent('install', step);
116 }