AJAX installation is 'basicly finished' :) Plus I threw in a small christmas present...
[mailer.git] / inc / ajax / ajax_installer.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/24/2012 *
4  * ===================                          Last change: 06/24/2012 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ajax_installer.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : AJAX-related functions for installer             *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : AJAX-bezogene Funktionen fuer Installer          *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAjaxOutputMode()) || (!isInstallationPhase())) {
40         die();
41 } // END - if
42
43 //-----------------------------------------------------------------------------
44 //         Generic call-back functions, they all rely on session data
45 //-----------------------------------------------------------------------------
46
47 // Establish a database link
48 function establishAjaxInstallerDatabaseLink () {
49         // This requires some session data
50         if (!isSessionDataSet(array('mysql_host', 'mysql_dbase', 'mysql_prefix', 'mysql_login', 'mysql_password1', 'mysql_password2', 'mysql_engine'))) {
51                 // Some required session data is not set
52                 reportBug(__FUNCTION__, __LINE__, 'Required session data for this step not found.');
53         } // END - if
54
55         // Establish link
56         $linkResource = SQL_CONNECT(getSession('mysql_host'), getSession('mysql_login'), getSession('mysql_password1'), __FUNCTION__, __LINE__);
57
58         // Is this a link resource?
59         if (!is_resource($linkResource)) {
60                 // Is not a resource
61                 reportBug(__FUNCTION__, __LINE__, 'linkResource[]=' . gettype($linkResource) . ', expected: link resource');
62         } // END - if
63
64         // Does selecting the database work?
65         if (!SQL_SELECT_DB(getSession('mysql_dbase'), __FUNCTION__, __LINE__)) {
66                 // Could not be selected
67                 reportBug(__FUNCTION__, __LINE__, 'Could not select database ' . getSession('mysql_dbase'));
68         } elseif ((!isFileReadable(getSession('base_path') . 'install/tables.sql')) || (!isFileReadable(getSession('base_path') . 'install/menu-'.getLanguage().'.sql'))) {
69                 // Installation area not found
70                 reportBug(__FUNCTION__, __LINE__, 'SQL dumps not found. Please extract ALL files from the archive or checkout all files out from SVN.');
71         } elseif (ifFatalErrorsDetected()) {
72                 // Some other fatal error occured
73                 reportBug(__FUNCTION__, __LINE__, 'Some fatal error detected, please check debug.log for details.');
74         } // END - if
75
76         // Set type, prefix from POST data and database name for later queries
77         setConfigEntry('_TABLE_TYPE'  , getSession('mysql_engine'));
78         setConfigEntry('_MYSQL_PREFIX', getSession('mysql_prefix'));
79         setConfigEntry('__DB_NAME'    , getSession('mysql_dbase'));
80 }
81
82 //-----------------------------------------------------------------------------
83 //             Call-back functions for processing AJAX requests
84 //-----------------------------------------------------------------------------
85
86 // Processes AJAX requests for installer
87 function doAjaxProcessInstall () {
88         // 'do' must always be set and installation phase must be true
89         if (!isInstallationPhase()) {
90                 // This shall not happen
91                 reportBug(__FUNCTION__, __LINE__, 'This AJAX request handler was called outside the installer.');
92         } elseif (!isPostRequestElementSet('do')) {
93                 // This shall not happen
94                 reportBug(__FUNCTION__, __LINE__, 'The JavaScript did not send "do" which is fatal.');
95         } // END - if
96
97         // Notify all modules that we are installing
98         $GLOBALS['__mailer_installing'] = TRUE;
99
100         // Again we do a call-back, so generate a function name depending on 'do'
101         $callbackName = 'doAjaxInstaller' . capitalizeUnderscoreString(postRequestElement('do'));
102
103         // Is the call-back function there?
104         if (!function_exists($callbackName)) {
105                 // This shall not happen
106                 reportBug(__FUNCTION__, __LINE__, 'AJAX call-back ' . $callbackName . ' does not exist.');
107         } // END - if
108
109         // Call the function
110         call_user_func($callbackName);
111
112         // Is the status fine or template not found (404)?
113         sendAjaxContent();
114 }
115
116 // Processes installer request for testing
117 function doAjaxInstallerTest () {
118         // Load the "test passed" template
119         setAjaxReplyContent(loadTemplate('ajax_test_passed', TRUE));
120
121         // All okay if we reach this point
122         setHttpStatus('200 OK');
123 }
124
125 // Processes installer requests for footer navigation
126 function doAjaxInstallerFooterNavigation () {
127         // 'tab' must always be set to determine which navigation buttons shall be visible
128         if (!isPostRequestElementSet('tab')) {
129                 // This shall not happen
130                 reportBug(__FUNCTION__, __LINE__, 'The JavaScript did not send "tab" which is fatal.');
131         } // END - if
132
133         // Init array for footer navigation
134         $enabledNavigations = array();
135
136         // "Detect" the 'tab' value
137         switch (postRequestElement('tab')) {
138                 case 'base_data': // Also 'previous' is valid
139                 case 'database_config':
140                 case 'smtp_config':
141                 case 'other_config':
142                 case 'extensions':
143                         array_push($enabledNavigations, 'previous');
144                 case 'welcome': // Only 'next' works for welcome page
145                         array_push($enabledNavigations, 'next');
146                         break;
147
148                 case 'overview': // Enable only 'previous'
149                         array_push($enabledNavigations, 'previous');
150                         if (isInstallationDataCompleted()) {
151                                 // Add 'finish'
152                                 array_push($enabledNavigations, 'finish');
153                         } // END - if
154                         break;
155
156                 default: // Unsupported value
157                         // This shall not happen
158                         reportBug(__FUNCTION__, __LINE__, 'Unsupported "tab" value ' . postRequestElement('tab') . ' detected.');
159
160                         // This will never be reached
161                         break;
162         } // END - switch
163
164         // Output the array for JSON reply
165         setAjaxReplyContent(encodeJson($enabledNavigations));
166
167         // All okay if we reach this point
168         setHttpStatus('200 OK');
169 }
170
171 // Processes installer AJAX calls for content-requests
172 function doAjaxInstallerDoStep () {
173         // 'step' must be there
174         if (!isPostRequestElementSet('step')) {
175                 // This shall not happen
176                 reportBug(__FUNCTION__, __LINE__, 'The JavaScript did not send "step" which is fatal.');
177         } // END - if
178
179         // Construct call-back name
180         $callbackName = 'doAjaxInstallerStep' . capitalizeUnderscoreString(postRequestElement('step'));
181
182         // Is the function there?
183         if (function_exists($callbackName)) {
184                 // Call it for setting values in session
185                 call_user_func($callbackName);
186         } else {
187                 // Log missing functions
188                 reportBug(__FUNCTION__, __LINE__, 'Call-back function ' . $callbackName . ' does not exist.');
189         }
190
191         // Set dummy content
192         setAjaxReplyContent(encodeJson(postRequestElement('step').'=OK'));
193
194         // All okay if we reach this point
195         setHttpStatus('200 OK');
196 }
197
198 // Processes installer AJAX calls for content-requests
199 function doAjaxInstallerRequestContent () {
200         // 'tab' must be there
201         if (!isPostRequestElementSet('tab')) {
202                 // This shall not happen
203                 reportBug(__FUNCTION__, __LINE__, 'The JavaScript did not send "tab" which is fatal.');
204         } // END - if
205
206         // Construct call-back name for value-preset
207         $callbackName = 'doAjaxPrepareInstaller' . capitalizeUnderscoreString(postRequestElement('tab'));
208
209         // Is the function there?
210         if (function_exists($callbackName)) {
211                 // Call it for setting values in session
212                 call_user_func($callbackName);
213         } else {
214                 // Log missing functions
215                 reportBug(__FUNCTION__, __LINE__, 'Call-back function ' . $callbackName . ' does not exist.');
216         }
217
218         // Is the HTTP status still the same? (204 No Content)
219         if (getHttpStatus() == '204 No Content') {
220                 // We use the current access level 'install' as prefix and construct a template name
221                 setAjaxReplyContent(loadTemplate('install_page_' . trim(postRequestElement('tab')), TRUE));
222
223                 // Has the template been loaded?
224                 if (isset($GLOBALS['template_content']['html']['install_page_' . trim(postRequestElement('tab'))])) {
225                         // All okay if we reach this point
226                         setHttpStatus('200 OK');
227                 } else {
228                         // Set 404 error
229                         setHttpStatus('404 Not Found');
230                 }
231         } // END - if
232 }
233
234 // Process installer AJAX call for change-warning
235 function doAjaxInstallerChangeWarning () {
236         // 'elements' and 'button' must be there
237         if ((!isPostRequestElementSet('elements')) || (!isPostRequestElementSet('button'))) {
238                 // This shall not happen
239                 reportBug(__FUNCTION__, __LINE__, 'The JavaScript did not send "elements" and/or "button" which is fatal.');
240         } // END - if
241
242         // "Walk" through all elements
243         $OUT = '<ol>';
244         foreach (explode(':', postRequestElement('elements')) as $element) {
245                 // Is it an extension?
246                 if (substr($element, 0, 4) == 'ext_') {
247                         // Add row for extension
248                         $OUT .= '<li>{%message=INSTALLER_CHANGED_ELEMENT_EXTENSION=' . str_replace('_', '-', $element) . '%}</li>';
249                 } else {
250                         // Add generic row
251                         $OUT .= '<li>{--INSTALLER_CHANGED_ELEMENT_' . strtoupper($element) . '--}</li>';
252                 }
253         } // END - foreach
254         $OUT .= '</ol>';
255
256         // Prepare content
257         $content = array(
258                 'out'     => $OUT,
259                 'button'  => postRequestElement('button'),
260                 'message' => '{--INSTALLER_TAB_NAVIGATION_' . strtoupper(postRequestElement('button')) . '_LINK--}',
261         );
262
263         if (in_array(postRequestElement('button'), array('previous', 'next'))) {
264                 // Load 'prefixed' template
265                 setAjaxReplyContent(loadTemplate('install_warning_' . postRequestElement('button'), TRUE, $content));
266         } else {
267                 // Load 'tab' template
268                 setAjaxReplyContent(loadTemplate('install_warning_tab', TRUE, $content));
269         }
270
271         // All okay if we reach this point
272         setHttpStatus('200 OK');
273 }
274
275 // Process installer AJAC call for saving changes
276 function doAjaxInstallerSaveChanges () {
277         // 'tab' must always be set to create a post-check-callback
278         if (!isPostRequestElementSet('tab')) {
279                 // This shall not happen
280                 reportBug(__FUNCTION__, __LINE__, 'The JavaScript did not send "tab" which is fatal.');
281         } // END - if
282
283         // Save the tab for pre-"filtering"
284         $currentTab = postRequestElement('tab');
285
286         // Remove some elements which should not be saved
287         foreach (array('tab', 'do', 'level') as $removedElement) {
288                 // Remove this element from POST data
289                 unsetPostRequestElement($removedElement);
290         } // END - foreach
291
292         // Default is failed save attempt (e.g. nothing to save)
293         $saveStatus = array(
294                 'status'        => 'failed',
295                 'message'       => '{--INSTALLER_SAVE_CHANGES_FAILED--}',
296                 // Don't set this to false, or else it will be returned as 'failed' but is saved
297                 'is_saved'      => TRUE,
298                 'failed_fields' => array()
299         );
300
301         // Init overall status
302         $isAllSaved = TRUE;
303
304         // Now set all remaining data in session
305         foreach (postRequestArray() as $key => $value) {
306                 // Set it, if it is valid, else it will be added to $saveStatus (call-by-reference)
307                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value[' . gettype($value) . '=' . $value);
308                 $saveStatus['is_saved'] = (
309                         // Is the data valid?
310                         (isInstallerDataValid($saveStatus, $key, $value))
311                 &&
312                         // And can it be stored in session?
313                         (setSession($key, $value))
314                 );
315
316                 // Save the overall status for below final check
317                 $isAllSaved = (($isAllSaved === TRUE) && ($saveStatus['is_saved'] === TRUE));
318                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value[' . gettype($value) . '=' . $value . ',is_saved=' . intval($saveStatus['is_saved']) . ',isAllSaved=' . intval($isAllSaved));
319         } // END - foreach
320
321         // 'is_saved' is still true?
322         if ($isAllSaved === TRUE) {
323                 // Set 'done' and message
324                 $saveStatus['status']  = 'done';
325                 $saveStatus['message'] = '{--INSTALLER_SAVE_CHANGES_DONE--}';
326
327                 // Then do the post-check
328                 doInstallerPostCheck($currentTab, $saveStatus);
329         } // END - if
330
331         // Output the status array for JSON reply
332         setAjaxReplyContent(encodeJson($saveStatus));
333
334         // All okay if we reach this point
335         setHttpStatus('200 OK');
336 }
337
338 // ----------------------------------------------------------------------------
339 //          Call-back functions for preparing installer page requests
340 // ----------------------------------------------------------------------------
341
342 // Prepare AJAX request 'welcome'
343 function doAjaxPrepareInstallerWelcome () {
344         // Kept empty to prevent logfile entry
345 }
346
347 // Prepare AJAX request 'base_data'
348 function doAjaxPrepareInstallerBaseData () {
349         // Is 'base_path' not set?
350         if (!isSessionVariableSet('base_path')) {
351                 // Then set it from PATH
352                 setSession('base_path', getPath());
353         } // END - if
354
355         // Is 'base_url' not set?
356         if (!isSessionVariableSet('base_url')) {
357                 // Then set it from URL
358                 setSession('base_url', getUrl());
359         } // END - if
360
361         // Is 'main_title' not set?
362         if (!isSessionVariableSet('main_title')) {
363                 // Then set it from default main title
364                 setSession('main_title', '{--DEFAULT_MAIN_TITLE--}');
365         } // END - if
366
367         // Is 'slogan' not set?
368         if (!isSessionVariableSet('slogan')) {
369                 // Then set it from default slogan
370                 setSession('slogan', '{--DEFAULT_SLOGAN--}');
371         } // END - if
372
373         // Is 'webmaster' not set?
374         if (!isSessionVariableSet('webmaster')) {
375                 // Then set it from default webmaster email address
376                 setSession('webmaster', '{--DEFAULT_WEBMASTER--}');
377         } // END - if
378 }
379
380 // Prepare AJAX request 'database_config'
381 function doAjaxPrepareInstallerDatabaseConfig () {
382         // Is 'mysql_host' not set?
383         if (!isSessionVariableSet('mysql_host')) {
384                 // Then set it directly
385                 setSession('mysql_host', 'localhost');
386         } // END - if
387
388         // Is 'mysql_dbase' not set?
389         if (!isSessionVariableSet('mysql_dbase')) {
390                 // Then set it directly
391                 setSession('mysql_dbase', 'your_database');
392         } // END - if
393
394         // Is 'mysql_prefix' not set?
395         if (!isSessionVariableSet('mysql_prefix')) {
396                 // Then set it directly
397                 setSession('mysql_prefix', 'mailer');
398         } // END - if
399
400         // Is 'mysql_login' not set?
401         if (!isSessionVariableSet('mysql_login')) {
402                 // Then set it directly
403                 setSession('mysql_login', 'your_login');
404         } // END - if
405
406         // Is 'mysql_dbase' not set?
407         if (!isSessionVariableSet('mysql_password1')) {
408                 // Then set it directly
409                 setSession('mysql_password1', '');
410         } // END - if
411
412         // Is 'mysql_password2' not set?
413         if (!isSessionVariableSet('mysql_password2')) {
414                 // Then set it directly
415                 setSession('mysql_password2', '');
416         } // END - if
417
418         // Is 'mysql_engine' not set?
419         if (!isSessionVariableSet('mysql_engine')) {
420                 // Then set it directly
421                 setSession('mysql_engine', 'MyISAM');
422         } // END - if
423 }
424
425 // Prepare AJAX request 'smtp_config'
426 function doAjaxPrepareInstallerSmtpConfig () {
427         // Kept empty to prevent logfile entry because SMTP settings are optional
428 }
429
430 // Prepare AJAX request 'other_config'
431 function doAjaxPrepareInstallerOtherConfig () {
432         // Is 'output_mode' not set?
433         if (!isSessionVariableSet('output_mode')) {
434                 // Then set it directly
435                 setSession('output_mode', 'render');
436         } // END - if
437
438         // Is 'warn_no_pass' not set?
439         if (!isSessionVariableSet('warn_no_pass')) {
440                 // Then set it directly
441                 setSession('warn_no_pass', 'Y');
442         } // END - if
443
444         // Is 'write_footer' not set?
445         if (!isSessionVariableSet('write_footer')) {
446                 // Then set it directly
447                 setSession('write_footer', 'Y');
448         } // END - if
449
450         // Is 'enable_backlink' not set?
451         if (!isSessionVariableSet('enable_backlink')) {
452                 // Then set it directly
453                 setSession('enable_backlink', 'Y');
454         } // END - if
455 }
456
457 // Prepare AJAX request 'extensions'
458 function doAjaxPrepareInstallerExtensions () {
459         // Is 'extensions' set?
460         if (!isSessionVariableSet('extensions')) {
461                 /*
462                  * At least ext-sql_patches and ext-task should be installed
463                  *(ext-sql_patches is a must!)
464                  */
465                 setSession('extensions', 'admins:sql_patches:task');
466         } elseif (strpos(getSession('extensions'), 'sql_patches') === FALSE) {
467                 // Add missing ext-sql_patches
468                 setSession('extensions', getSession('extensions') . ':sql_patches');
469         }
470 }
471
472 // Prepare AJAX request 'overview'
473 function doAjaxPrepareInstallerOverview () {
474         // 'tab' must always be set to create a post-check-callback
475         if (!isPostRequestElementSet('tab')) {
476                 // This shall not happen
477                 reportBug(__FUNCTION__, __LINE__, 'The JavaScript did not send "tab" which is fatal.');
478         } // END - if
479
480         // Save the tab for pre-"filtering"
481         $currentTab = postRequestElement('tab');
482
483         // Default is failed save attempt (e.g. nothing to save)
484         $verificationStatus = array(
485                 // Status code, can be 'failed' or 'done'
486                 'status'        => 'failed',
487                 // Status message (e.g. for output)
488                 'message'       => '{--INSTALLER_OVERVIEW_FINAL_CHECK_FAILED--}',
489                 // Don't set this to false, or else it will be returned as 'failed' but is saved
490                 'is_valid'      => TRUE,
491                 // Failed fields
492                 'failed_fields' => array()
493         );
494
495         // Init overall status and final output
496         $isAllValid = TRUE;
497         $output     = '';
498
499         // Check all data in session
500         foreach (array_keys($GLOBALS['installer_groups']) as $key) {
501                 // Get values from session
502                 $value = getSession($key);
503
504                 // Is the data valid?
505                 $verificationStatus['is_valid'] = (isInstallerDataValid($verificationStatus, $key, $value));
506
507                 // Is this step okay?
508                 if ($verificationStatus['is_valid'] === TRUE) {
509                         // Add this key/value pair to a overview group
510                         addKeyValueToInstallerOverviewGroup($key, $value);
511                 } // END - if
512
513                 // Save the overall status for below final check
514                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',is_valid=' . intval($verificationStatus['is_valid']) . ',isAllValid=' . intval($isAllValid));
515                 $isAllValid = (($isAllValid === TRUE) && ($verificationStatus['is_valid'] === TRUE));
516         } // END - foreach
517
518         // Is it still true?
519         if ((isInstallationDataCompleted()) && ($isAllValid === TRUE)) {
520                 // Set 'done' and message
521                 $verificationStatus['status']  = 'done';
522                 $verificationStatus['message'] = '{--INSTALLER_OVERVIEW_FINAL_CHECK_DONE--}';
523
524                 // Then do the post-check
525                 doInstallerPostCheck($currentTab, $verificationStatus);
526         } // END - if
527
528         // Is it still valid?
529         if ($verificationStatus['status'] != 'done') {
530                 // Log message away
531                 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Final check on all stored data failed. message=' . $verificationStatus['message']);
532
533                 // Process failed fields
534                 $verificationStatus['failed_fields'] = handleInstallerFailedFields($verificationStatus['failed_fields']);
535
536                 // Output the array for JSON reply
537                 setAjaxReplyContent(loadTemplate('install_overview_failed', TRUE, $verificationStatus));
538
539                 /*
540                  * Something went wrong, this might happen when e.g. the user has tried
541                  * to save invalid database login data but hit reload button on error
542                  * message.
543                  */
544                 setHttpStatus('200 OK');
545
546                 // Abort here
547                 return;
548         } // END - if
549 }
550
551 // ----------------------------------------------------------------------------
552 //            Call-back functions for doing installation steps
553 // ----------------------------------------------------------------------------
554
555 // Call-back function to import first tables.sql file
556 function doAjaxInstallerStepImportTablesSql () {
557         // Establish database link
558         establishAjaxInstallerDatabaseLink();
559
560         // Init SQL array
561         initSqls();
562
563         // Import tables.sql
564         importInstallSqlDump('tables');
565
566         // Are some SQLs found?
567         if (countSqls() == 0) {
568                 // Abort here
569                 reportBug(__FUNCTION__, __LINE__, '{--INSTALLER_SQL_IMPORT_FAILED--}');
570         } // END - if
571
572         // Now run all queries through
573         runFilterChain('run_sqls');
574
575         // Close SQL link
576         SQL_CLOSE(__FUNCTION__, __LINE__);
577 }
578
579 // Call-back function to import menu SQL file
580 function doAjaxInstallerStepImportMenuSql () {
581         // Establish database link
582         establishAjaxInstallerDatabaseLink();
583
584         // Init SQL array
585         initSqls();
586
587         // Import tables.sql
588         importInstallSqlDump('menu-' . getLanguage());
589
590         // Are some SQLs found?
591         if (countSqls() == 0) {
592                 // Abort here
593                 reportBug(__FUNCTION__, __LINE__, '{--INSTALLER_SQL_IMPORT_FAILED--}');
594         } // END - if
595
596         // Now run all queries through
597         runFilterChain('run_sqls');
598
599         // Close SQL link
600         SQL_CLOSE(__FUNCTION__, __LINE__);
601 }
602
603 // Call-back function to install some important extensions
604 function doAjaxInstallerStepInstallExtensions () {
605         // Only one element is required
606         if (!isSessionVariableSet('extensions')) {
607                 // Some required session data is not set
608                 reportBug(__FUNCTION__, __LINE__, 'Required session data for this step not found.');
609         } // END - if
610
611         // Establish database link
612         establishAjaxInstallerDatabaseLink();
613
614         // Get all extensions
615         $extensions = explode(':', getSession('extensions'));
616
617         // Make sure ext-sql_patches is first
618         array_unshift($extensions, 'sql_patches');
619
620         // "Walk" through all extensions
621         foreach ($extensions as $key => $ext_name) {
622                 // Is ext-sql_patches not at key=0?
623                 if (($key == 0) && ($ext_name == 'sql_patches')) {
624                         // Then skip this entry
625                         continue;
626                 } elseif ((!loadExtension($ext_name, 'test', '0.0.0', TRUE)) || (!registerExtension($ext_name, NULL))) {
627                         // Didn't work
628                         reportBug(__FUNCTION__, __LINE__, 'Cannot load/register extension ' . $ext_name . '.');
629                 } // END - if
630         } // END - foreach
631
632         // Close SQL link
633         SQL_CLOSE(__FUNCTION__, __LINE__);
634 }
635
636 // Call-back function to write local configuration file
637 function doAjaxInstallerStepWriteLocalConfig () {
638         // Is all set?
639         if (!isSessionDataSet(array('base_path', 'base_url', 'main_title', 'slogan', 'webmaster', 'mysql_host', 'mysql_dbase', 'mysql_prefix', 'mysql_login', 'mysql_password1', 'mysql_password2', 'mysql_engine', 'output_mode', 'warn_no_pass', 'write_footer', 'enable_backlink'))) {
640                 // Some required session data is not set
641                 reportBug(__FUNCTION__, __LINE__, 'Required session data for this step not found.');
642         } // END - if
643
644         // Write config file
645         if (!doInstallWriteLocalConfigurationFile(
646                 getSession('base_path'),
647                 getSession('base_url'),
648                 getSession('main_title'),
649                 getSession('slogan'),
650                 getSession('webmaster'),
651                 getSession('warn_no_pass'),
652                 getSession('write_footer'),
653                 getSession('enable_backlink'),
654                 getSession('mysql_host'),
655                 getSession('mysql_dbase'),
656                 getSession('mysql_login'),
657                 getSession('mysql_password1'),
658                 getSession('mysql_prefix'),
659                 getSession('mysql_engine'),
660                 getSession('smtp_host'),
661                 getSession('smtp_user'),
662                 getSession('smtp_password1')
663         )) {
664                 // Something bad went wrong
665                 removeFile(getSession('base_path') . getCachePath() . 'config-local.php');
666                 reportBug(__FUNCTION__, __LINE__, 'Did not fully write config-local.php .');
667         }
668 }
669
670 // [EOF]
671 ?>