2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/22/2009 *
4 * =================== Last change: 10/22/2009 *
6 * -------------------------------------------------------------------- *
7 * File : install-functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Functions for installation procedure *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Funktionen fuer die Installationsroutine *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isInstallationPhase())) {
44 function initInstaller () {
45 // Initialize installer group array
46 $GLOBALS['installer_groups'] = array(
48 'base_path' => 'base_data',
49 'base_url' => 'base_data',
50 'main_title' => 'base_data',
51 'slogan' => 'base_data',
52 'webmaster' => 'base_data',
54 'mysql_host' => 'database_config',
55 'mysql_dbase' => 'database_config',
56 'mysql_prefix' => 'database_config',
57 'mysql_engine' => 'database_config',
58 'mysql_login' => 'database_config',
59 'mysql_password1' => 'database_config',
60 'mysql_password2' => 'database_config',
62 'smtp_host' => 'smtp_config',
63 'smtp_user' => 'smtp_config',
64 'smtp_password1' => 'smtp_config',
65 'smtp_password2' => 'smtp_config',
67 'output_mode' => 'other_config',
68 'warn_no_pass' => 'other_config',
69 'write_footer' => 'other_config',
70 'enable_backlink' => 'other_config',
74 // Write the local config-local.php file from "template"
75 function doInstallWriteLocalConfigurationFile ($path, $url, $title, $slogan, $email, $noPassword, $writeFooter, $backLink, $databaseHost, $databaseName, $databaseLogin, $databasePassword, $databasePrefix, $databaseType, $smtpHost, $smtpUser, $smtpPassword) {
76 // Copy the config template and verify it
77 copyFileVerified($path . 'inc/config-local.php.dist', $path . getCachePath() . 'config-local.php', 0644);
80 * Ok, all done. So we can write the config data to the php files. Do only
81 * write these if they differ from auto-detected values.
83 if ($path != getPath()) {
84 changeDataInLocalConfigurationFile('SERVER-PATH', "setConfigEntry('PATH', '", "');", $path, 0);
86 if ($url != getUrl()) {
87 changeDataInLocalConfigurationFile('HOST-URL', "setConfigEntry('URL', '", "');", $url, 0);
91 changeDataInLocalConfigurationFile('MAIN-TITLE', "setConfigEntry('MAIN_TITLE', '", "');", $title, 0);
92 changeDataInLocalConfigurationFile('SLOGAN', "setConfigEntry('SLOGAN', '", "');", $slogan, 0);
93 changeDataInLocalConfigurationFile('WEBMASTER', "setConfigEntry('WEBMASTER', '", "');", $email, 0);
94 changeDataInLocalConfigurationFile('NULLPASS-WARNING', "setConfigEntry('WARN_NO_PASS', '", "');", $noPassword, 0);
95 changeDataInLocalConfigurationFile('WRITE-FOOTER', "setConfigEntry('WRITE_FOOTER', '", "');", $writeFooter, 0);
96 changeDataInLocalConfigurationFile('BACKLINK', "setConfigEntry('ENABLE_BACKLINK', '", "');", $backLink, 0);
97 // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestElement('omode'), 0);
98 changeDataInLocalConfigurationFile('MYSQL-HOST', " 'host' => '", "',", $databaseHost, 0);
99 changeDataInLocalConfigurationFile('MYSQL-DBASE', " 'dbase' => '", "',", $databaseName, 0);
100 changeDataInLocalConfigurationFile('MYSQL-LOGIN', " 'login' => '", "',", $databaseLogin, 0);
101 changeDataInLocalConfigurationFile('MYSQL-PASSWORD', " 'password' => '", "',", $databasePassword, 0);
102 changeDataInLocalConfigurationFile('MYSQL-PREFIX', "setConfigEntry('_MYSQL_PREFIX', '", "');", $databasePrefix, 0);
103 changeDataInLocalConfigurationFile('TABLE-TYPE', "setConfigEntry('_TABLE_TYPE', '", "');", $databaseType, 0);
104 changeDataInLocalConfigurationFile('SMTP-HOSTNAME', "setConfigEntry('SMTP_HOSTNAME', '", "');", $smtpHost, 0);
105 changeDataInLocalConfigurationFile('SMTP-USER', "setConfigEntry('SMTP_USER', '", "');", $smtpUser, 0);
106 changeDataInLocalConfigurationFile('SMTP-PASSWORD', "setConfigEntry('SMTP_PASSWORD', '", "');", $smtpPassword, 0);
108 // Generate a long site-key and write it
109 changeDataInLocalConfigurationFile('SITE-KEY', "setConfigEntry('SITE_KEY', '", "');", generatePassword(50), 0);
111 // Script is now installed
112 changeDataInLocalConfigurationFile('INSTALLED', "setConfigEntry('MAILER_INSTALLED', '", "');", 'Y', 0);
115 // Adds a given template with content to install output stream
116 function addTemplateToInstallContent ($template, $content = array()) {
118 $out = loadTemplate($template, TRUE, $content);
121 addToInstallContent($out);
124 // Add it to install content
125 function addToInstallContent ($out) {
127 if (!isset($GLOBALS['install_content'])) {
129 $GLOBALS['install_content'] = $out;
132 $GLOBALS['install_content'] .= $out;
136 // Somewhat getter for installer content
137 function getInstallerContent () {
139 if (isset($GLOBALS['install_content'])) {
141 $content = $GLOBALS['install_content'];
143 // Nothing found, this needs fixing
144 $content = displayMessage('{--INSTALLER_CONTENT_404--}', TRUE);
151 // Read a given SQL dump
152 function readSqlDump ($FQFN) {
154 $content = readFromFile($FQFN);
156 // Remove some unwanted chars
157 $content = str_replace(chr(13), '', $content);
158 $content = str_replace(PHP_EOL . PHP_EOL, PHP_EOL, $content);
160 // Return the content
164 // Generates the installer menu by simply loading another template
165 function generateInstallerMenu () {
166 // Load installer menu template
167 $OUT = loadTemplate('install_menu', TRUE);
169 // Return loaded content
173 // Generate the install footer navigation by simply loading another template
174 function generateInstallerFooterNavigation () {
175 // Load installer menu template
176 $OUT = loadTemplate('install_footer', TRUE);
178 // Return loaded content
182 // Generate an option list for database types for given default value
183 function generateInstallerDatabaseTypeOptions () {
184 return generateOptions(
186 array('MyISAM', 'InnoDB'),
187 array('{--INSTALLER_TABLE_TYPE_MYISAM--}', '{--INSTALLER_TABLE_TYPE_INNODB--}'),
188 getSession('mysql_engine')
192 // Generate an option list for output mode types for given default value
193 function generateInstallerOutputModeOptions ($defaultValue) {
194 return generateOptions(
196 array('render', 'direct'),
197 array('{--INSTALLER_MODE_RENDER--}', '{--INSTALLER_MODE_DIRECT--}'),
202 // Checks whether we have an AJAX-enabled installer which defaults to red pill
203 function isAjaxInstaller () {
204 // Get the session data and compare it against 'ajax'
205 $isAjaxInstaller = (getSession('installer') == 'ajax');
208 return $isAjaxInstaller;
211 // Checks whether we have an plain installer which defaults to red pill
212 function isPlainInstaller () {
213 // Get the session data and compare it against 'plain'
214 $isPlainInstaller = (getSession('installer') == 'plain');
217 return $isPlainInstaller;
220 // Handle all given failed fields
221 function handleInstallerFailedFields ($failedFields) {
222 // Don't do anything with no array or no entries
223 if ((!is_array($failedFields)) || (count($failedFields) == 0)) {
225 reportBug(__FUNCTION__, __LINE__, 'failedFields[]=' . gettype($failedFields) . ' verification failed');
230 foreach ($failedFields as $key => $field) {
232 $out .= '<li>{--INSTALLER_FIELD_FAILED_' . strtoupper($field) . '--}</li>';
240 // Checks given key/value pair if it is valid by a call-back
241 function isInstallerDataValid (&$saveStatus, $key, $value) {
242 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ' - ENTERED!');
243 // Generate call-back function based on given key
244 $callbackName = 'isInstaller' . capitalizeUnderscoreString($key) . 'Valid';
246 // Is the function there?
247 if (!function_exists($callbackName)) {
248 // Not found, which is not bad, but it means this data is always valid
249 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Call-back function ' . $callbackName . ' not found. saveStatus[status]=' . $saveStatus['status'] . ', key=' . $key . ', value=' . $value);
251 // All fine (CAREFULL!)
256 $isValid = (bool) call_user_func($callbackName, trim($value));
259 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',isValid=' . intval($isValid));
260 if ($isValid === FALSE) {
261 // Then add it to saveStatus
262 array_push($saveStatus['failed_fields'], $key);
266 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',isValid=' . intval($isValid) . ' - EXIT!');
270 // Post-check on installer data
271 function doInstallerPostCheck ($currentTab, &$saveStatus) {
273 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentTab=' . $currentTab . ',saveStatus[status]=' . $saveStatus['status'] . ' - ENTERED!');
275 // Create the call-back function on 'tab'
276 $callbackName = 'isInstallerPost' . capitalizeUnderscoreString($currentTab) . 'Valid';
278 // Is the function there?
279 if (!function_exists($callbackName)) {
280 // Not found, which is not bad, but it means the post-check won't be run
281 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Call-back function ' . $callbackName . ' not found. saveStatus[status]=' . $saveStatus['status'] . ', currentTab=' . $currentTab);
287 // Init 'tab-specific error message'
288 $GLOBALS['installer_post_error'][$currentTab] = '';
289 $GLOBALS['installer_failed_fields'][$currentTab] = array();
292 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Calling function ' . $callbackName . ',currentTab=' . $currentTab . ',saveStatus[status]=' . $saveStatus['status']);
295 $isValid = (bool) call_user_func($callbackName, $currentTab);
298 if (($isValid === FALSE) || (count($GLOBALS['installer_failed_fields'][$currentTab]) > 0)) {
299 // Then change status and message
300 $saveStatus['status'] = 'failed';
301 $saveStatus['message'] = '{%message,INSTALLER_POST_CHECK_' . strtoupper($currentTab) . '_FAILED=' . $GLOBALS['installer_post_error'][$currentTab] . '%}';
303 // Is there failed fields?
304 if (count($GLOBALS['installer_failed_fields'][$currentTab]) > 0) {
306 $saveStatus['failed_fields'] = merge_array($saveStatus['failed_fields'], $GLOBALS['installer_failed_fields'][$currentTab]);
311 //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentTab=' . $currentTab . ',saveStatus[status]=' . $saveStatus['status'] . ' - EXIT!');
314 // Determines an installer group by given key
315 function determineInstallerGroupByKey ($key) {
317 if (!isset($GLOBALS['installer_groups'][$key])) {
319 logDebugMessage(__FUNCTION__, __LINE__, 'Cannot determine installer group, returning dummy group. key=' . $key);
321 // Return dummy group
326 return $GLOBALS['installer_groups'][$key];
329 // Adds given key/value pair to an overview group
330 function addKeyValueToInstallerOverviewGroup ($key, $value) {
331 // First determine the group by given key
332 $group = determineInstallerGroupByKey($key);
334 // Depending on the group, add it for later usage (to render the overview page)
335 $GLOBALS['installer_overview'][$group][$key] = $value;
338 //-----------------------------------------------------------------------------
339 // Call-back functions to check validity
340 //-----------------------------------------------------------------------------
342 // ----------------- Base data -----------------
344 // Call-back function to check validity of 'base_path'
345 function isInstallerBasePathValid ($value) {
346 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' - ENTERED!');
347 // Is it a directory and if some typical files could be found
349 // Is it a directory?
350 (isDirectory($value))
352 // Doesn't contain dots
353 (strpos($value, '..') === FALSE)
355 // Is there a trailing slash?
356 (substr($value, -1, 1) == '/')
358 // Is mysql-manager.php there?
359 (isFileReadable($value . 'inc/mysql-manager.php'))
361 // What about gen_sql_patches.php?
362 (isFileReadable($value . 'inc/gen_sql_patches.php'))
364 // And how about referral-functions.php?
365 (isFileReadable($value . 'inc/referral-functions.php'))
369 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ',isValid=' . intval($isValid) . ' - EXIT');
373 // Call-back function to check validity of 'base_url'
374 function isInstallerBaseUrlValid ($value) {
375 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' - ENTERED!');
381 // Starts with http:// or https:// ?
382 ((substr($value, 0, 7) == 'http://') || (substr($value, 0, 8) == 'https://'))
384 // Has no trailing slash?
385 (substr($value, -1, 1) != '/')
387 // And total length is at least 6+8=14 chars long? (https://foo.ba)
388 (strlen($value) >= 14)
395 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ',isValid=' . intval($isValid) . ' - EXIT');
399 // Call-back function to checl validity of 'main_title'
400 function isInstallerMainTitleValid ($value) {
402 // @TODO Comparing with DEFAULT_MAIN_TITLE doesn't work
403 $isValid = ((strlen($value) >= 4) && ($value != getMessage('DEFAULT_MAIN_TITLE')));
409 // Call-back function to checl validity of 'slogan'
410 function isInstallerSloganValid ($value) {
412 $isValid = ((strlen($value) >= 4) && ($value != getMessage('DEFAULT_SLOGAN')));
418 // Call-back function to check validity of 'webmaster'
419 function isInstallerWebmasterValid ($value) {
420 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' - ENTERED!');
421 // Is it a valid email address?
423 // Is it a valid email address?
424 (isEmailValid($value))
426 // Or is there 'localhost/127.0.0.1' as hostname? Then don't check email address (e.g. you@localhost)
427 (in_array(detectServerName(), array('localhost', '127.0.0.1')))
429 // Is not default "email address"
430 $value != getMessage('DEFAULT_WEBMASTER')
434 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ',isValid=' . intval($isValid) . ' - EXIT');
438 // ----------------- Database configuration -----------------
440 // Call-back function to check validity of 'mysql_host'
441 function isInstallerMysqlHostValid ($value) {
442 // This value must match a hostname or IP address
444 // Shall not be empty
445 (!empty($value)) && (
446 // Is localhost/127.0.0.1? (mostly the case)
447 (in_array($value, array('localhost', '127.0.0.1')))
449 // IP number match (this regex was taken from www.regexlib.com)
450 (preg_match('/((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9]))/', $value))
453 (preg_match('/([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}/', $value))
460 // Call-back function to check validity of 'mysql_engine'
461 function isInstallerMysqlEngineValid ($value) {
462 // This value must be 'MyISAM' or 'InnoDB'
463 $isValid = in_array($value, array('MyISAM', 'InnoDB'));
469 // Call-back function to check validity of 'mysql_dbase'
470 function isInstallerMysqlDbaseValid ($value) {
471 // This value must not be empty
472 $isValid = ((!empty($value)) && ($value != 'your_database'));
478 // Call-back function to check validity of 'mysql_login'
479 function isInstallerMysqlLoginValid ($value) {
480 // This value must not be empty
481 $isValid = ((!empty($value)) && ($value != 'your_login'));
487 // Call-back function to check validity of 'mysql_prefix'
488 function isInstallerMysqlPrefixValid ($value) {
489 // This value must not be empty
490 $isValid = !empty($value);
496 // ----------------- SMTP configuration -----------------
498 // ----------------- Other configuration -----------------
500 //-----------------------------------------------------------------------------
501 // Call-back functions to post-check validity
502 //-----------------------------------------------------------------------------
504 // Call-back function to check if base data is valid
505 function isInstallerPostBaseDataValid ($currentTab) {
506 // By default it is not valid
509 // Is the base path valid?
510 if (!isInstallerBasePathValid(postRequestElement('base_path'))) {
512 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_BASE_PATH_INVALID--}';
513 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'base_path');
515 } elseif (!isInstallerBaseUrlValid(postRequestElement('base_url'))) {
517 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_BASE_URL_INVALID--}';
518 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'base_url');
520 } elseif (strlen(postRequestElement('main_title')) < 3) {
522 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_MAIN_TITLE_INVALID--}';
523 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'main_title');
525 } elseif (strlen(postRequestElement('slogan')) < 3) {
527 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_SLOGAN_INVALID--}';
528 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'slogan');
530 } elseif (!isInstallerWebmasterValid(postRequestElement('webmaster'))) {
532 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_WEBMASTER_INVALID--}';
533 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'webmaster');
539 // Remember this tab in session
540 installTabOkay($currentTab);
547 // Call-back function to check if database configuration in POST is valid
548 function isInstallerPostDatabaseConfigValid ($currentTab) {
549 // By default nothing is valid
551 $engineValid = FALSE;
554 // Do both passwords match?
555 if ((!isPostRequestElementSet('mysql_password1')) && (isPostRequestElementSet('mysql_password2'))) {
556 // Password 1 not set
557 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_PASSWORD1_EMPTY--}';
558 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_password1');
560 } elseif ((isPostRequestElementSet('mysql_password1')) && (!isPostRequestElementSet('mysql_password2'))) {
561 // Password 2 not set
562 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_PASSWORD2_EMPTY--}';
563 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_password2');
565 } elseif (postRequestElement('mysql_password1') != postRequestElement('mysql_password2')) {
566 // Passwords mismatch
567 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_PASSWORDS_MISMATCH--}';
568 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_password1', 'mysql_password2');
572 // Try to connect to the database
573 $linkResource = SQL_CONNECT(postRequestElement('mysql_host'), postRequestElement('mysql_login'), postRequestElement('mysql_password1'), __FUNCTION__, __LINE__);
576 if (!is_resource($linkResource)) {
577 // Cannot connect to database
578 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_CONNECT_ERROR--}';
579 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_login', 'mysql_password1', 'mysql_password2');
583 // Then attempt to select the database
584 if (!SQL_SELECT_DB(postRequestElement('mysql_dbase'), __FUNCTION__, __LINE__)) {
585 // Could not find database
586 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_SELECT_FAILED--}';
587 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_dbase');
589 // Disconnect here, we don't need idle database connections laying around
590 SQL_CLOSE(__FUNCTION__, __LINE__);
596 // Set database name and prefix
597 setConfigEntry('__DB_NAME' , postRequestElement('mysql_dbase'));
598 setConfigEntry('_MYSQL_PREFIX', postRequestElement('mysql_prefix'));
600 // Get an array of all supported engines
601 $engines = getArrayFromSupportedSqlEngines(postRequestElement('mysql_engine'));
604 if (!is_array($engines)) {
605 // Something bad happened
606 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_ENGINES_SQL_ERROR--}';
607 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_engine');
609 // Disconnect here, we don't need idle database connections laying around
610 SQL_CLOSE(__FUNCTION__, __LINE__);
614 } elseif (count($engines) == 0) {
615 // No engine is active
616 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_NO_ENGINES_ACTIVE--}';
617 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_engine');
619 // Disconnect here, we don't need idle database connections laying around
620 SQL_CLOSE(__FUNCTION__, __LINE__);
626 // Then check all, if the requested is working
627 foreach ($engines as $engineArray) {
628 // By default the selected engine is not valid
629 $engineValid = FALSE;
631 // Is the engine there?
632 if (strtolower($engineArray['Engine']) == strtolower(postRequestElement('mysql_engine'))) {
633 // Okay, engine is found
639 // So, is the engine found?
640 if ($engineValid === FALSE) {
641 // Requested engine is not active
642 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_ENGINE_UNSUPPORTED--}';
643 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_engine');
645 // Disconnect here, we don't need idle database connections laying around
646 SQL_CLOSE(__FUNCTION__, __LINE__);
652 // Init some known tables
657 'admin_menu' => TRUE,
663 'extensions' => TRUE,
665 'guest_menu' => TRUE,
667 'max_receive' => TRUE,
669 'member_menu' => TRUE,
683 'task_system' => TRUE,
686 // So check if all tables are not there
687 foreach ($tables as $tableName => $isFound) {
689 $tables[$tableName] = ifSqlTableExists($tableName);
691 // Is it (hopefully not) there?
692 if ($tables[$tableName] === FALSE) {
693 // This does not exist
698 // Determine final status (simply compare both counts
699 $isValid = (count($tables) == $missingTables);
701 // Disconnect here, we don't need idle database connections laying around
702 SQL_CLOSE(__FUNCTION__, __LINE__);
704 // If the status is true, disconnect the database
705 if ($isValid === FALSE) {
706 // Still something bad happened (e.g. tables found)
707 $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_IN_USE--}';
708 array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_dbase');
710 // Remember this tab in session
711 installTabOkay($currentTab);
718 // Store given tab in session
719 function installTabOkay ($currentTab) {
721 if (isSessionVariableSet('installer_okay')) {
722 // Is this tab already found?
723 if (strpos(getSession('installer_okay'), $currentTab) === FALSE) {
725 setSession('installer_okay', getSession('installer_okay') . ';' . $currentTab);
729 setSession('installer_okay', $currentTab);
733 // Checks whether at least the required tabs are completed
734 function isInstallationDataCompleted () {
737 (isSessionVariableSet('installer_okay')) &&
738 (strpos(getSession('installer_okay'), 'base_data') !== FALSE) &&
739 (strpos(getSession('installer_okay'), 'database_config') !== FALSE)
743 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCompleted=' . intval($isCompleted) . ',installer_okay=' . getSession('installer_okay'));
747 // Call-back function to check if enable_backlink is Y/N
748 function isInstallerEnableBacklinkValid ($currentTab) {
749 // Check and return it
750 return in_array($currentTab, array('Y', 'N'));
753 // Call-back function to check if warn_no_pass is Y/N
754 function isInstallerWarnNoPassValid ($currentTab) {
755 // Check and return it
756 return in_array($currentTab, array('Y', 'N'));
759 // Call-back function to check if write_footer is Y/N
760 function isInstallerWriteFooterValid ($currentTab) {
761 // Check and return it
762 return in_array($currentTab, array('Y', 'N'));
765 // Call-back function to check if output_mode is Y/N
766 function isInstallerOutputModeValid ($currentTab) {
767 // Check and return it
768 return in_array($currentTab, array('render', 'direct'));
771 // Wrapper to import given installation SQL dump
772 function importInstallSqlDump ($dumpName) {
774 importSqlDump('install', $dumpName);