示例#1
0
function form_table($nextstage = WELCOME, $formaction = "install.php")
{
    global $INSTALL, $db;
    $enablenext = true;
    /// Print the standard form if we aren't in the DOWNLOADLANG page
    /// because it has its own form.
    if ($nextstage != DOWNLOADLANG) {
        $needtoopenform = false;
        ?>
        <form id="installform" method="post" action="<?php 
        echo $formaction;
        ?>
">
        <div><input type="hidden" name="stage" value="<?php 
        echo $nextstage;
        ?>
" /></div>

<?php 
    } else {
        $needtoopenform = true;
    }
    ?>
    <table class="install_table" cellspacing="3" cellpadding="3">

<?php 
    /// what we do depends on the stage we're at
    switch ($nextstage) {
        case WELCOME:
            /// Welcome and language settings
            ?>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('language');
            ?>
</p></td>
                <td class="td_right">
                <?php 
            choose_from_menu(get_installer_list_of_languages(), 'language', $INSTALL['language'], '');
            ?>
                </td>
            </tr>

<?php 
            break;
        case COMPATIBILITY:
            /// Compatibilty check
            $compatsuccess = true;
            /// Check that PHP is of a sufficient version
            print_compatibility_row(inst_check_php_version(), get_string('phpversion', 'install'), get_string('phpversionerror', 'install'), 'phpversionhelp');
            $enablenext = $enablenext && inst_check_php_version();
            /// Check session auto start
            print_compatibility_row(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), 'sessionautostarthelp');
            $enablenext = $enablenext && !ini_get_bool('session.auto_start');
            /// Check magic quotes
            print_compatibility_row(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), 'magicquotesruntimehelp');
            $enablenext = $enablenext && !ini_get_bool('magic_quotes_runtime');
            /// Check unsupported PHP configuration
            print_compatibility_row(!ini_get_bool('register_globals'), get_string('globalsquotes', 'install'), get_string('globalswarning', 'install'));
            $enablenext = $enablenext && !ini_get_bool('register_globals');
            /// Check safe mode
            print_compatibility_row(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), 'safemodehelp', true);
            /// Check file uploads
            print_compatibility_row(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), 'fileuploadshelp', true);
            /// Check GD version
            print_compatibility_row(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), 'gdversionhelp', true);
            /// Check memory limit
            print_compatibility_row(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), 'memorylimithelp', true);
            break;
        case DIRECTORY:
            /// Directory settings
            ?>

            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('wwwroot', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40"name="wwwrootform" value="<?php 
            p($INSTALL['wwwrootform'], true);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dirroot', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40" name="dirrootform" disabled="disabled" value="<?php 
            p($INSTALL['dirrootform'], true);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dataroot', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40" name="dataroot" value="<?php 
            p($INSTALL['dataroot'], true);
            ?>
" />
                </td>
            </tr>

<?php 
            break;
        case DATABASE:
            /// Database settings
            ?>

            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dbtype', 'install');
            ?>
</p></td>
                <td class="td_right">
                <?php 
            choose_from_menu(array('mysql' => get_string('mysql', 'install'), 'mysqli' => get_string('mysqli', 'install'), 'oci8po' => get_string('oci8po', 'install'), 'postgres7' => get_string('postgres7', 'install'), 'mssql' => get_string('mssql', 'install'), 'mssql_n' => get_string('mssql_n', 'install'), 'odbc_mssql' => get_string('odbc_mssql', 'install')), 'dbtype', $INSTALL['dbtype'], '', 'toggledbinfo();');
            ?>
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dbhost', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="dbhost" value="<?php 
            p($INSTALL['dbhost']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('database', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="dbname" value="<?php 
            p($INSTALL['dbname']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('user');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="dbuser" value="<?php 
            p($INSTALL['dbuser']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('password');
            ?>
</p></td>
                <td class="td_right">
                    <input type="password" class="input_database" name="dbpass" value="<?php 
            p($INSTALL['dbpass']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dbprefix', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="prefix" value="<?php 
            p($INSTALL['prefix']);
            ?>
" />
                </td>
            </tr>

<?php 
            break;
        case ADMIN:
            /// Administration directory setting
            ?>

            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('admindirname', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40" name="admindirname" value="<?php 
            p($INSTALL['admindirname']);
            ?>
" />
                </td>
            </tr>


<?php 
            break;
        case ENVIRONMENT:
            /// Environment checks
            ?>

            <tr>
                <td colspan="2">
                <?php 
            error_reporting(0);
            // Hide errors
            $dbconnected = $db->Connect($INSTALL['dbhost'], $INSTALL['dbuser'], $INSTALL['dbpass'], $INSTALL['dbname']);
            error_reporting(7);
            // Show errors
            if ($dbconnected) {
                /// Execute environment check, printing results
                @remove_dir($INSTALL['dataroot'] . '/environment');
                /// Always delete downloaded env. info to force use of the released one. MDL-9796
                check_moodle_environment($INSTALL['release'], $environment_results, true);
            } else {
                /// We never should reach this because DB has been tested before arriving here
                $errormsg = get_string('dbconnectionerror', 'install');
                $nextstage = DATABASE;
                echo '<p class="errormsg" style="text-align:center">' . get_string('dbconnectionerror', 'install') . '</p>';
            }
            ?>
                </td>
            </tr>

<?php 
            break;
        case DOWNLOADLANG:
            /// Download language from download.moodle.org
            ?>

            <tr>
                <td colspan="2">
                <?php 
            /// Get array of languages, we are going to use it
            $languages = get_installer_list_of_languages();
            /// Print the download form (button) if necessary
            if ($INSTALL['showdownloadlangpack'] == true && substr($INSTALL['language'], 0, 2) != 'en') {
                $options = array();
                $options['downloadlangpack'] = true;
                $options['stage'] = DOWNLOADLANG;
                $options['same'] = true;
                print_simple_box_start('center');
                print_single_button('install.php', $options, get_string('downloadlanguagebutton', 'install', $languages[$INSTALL['language']]), 'post');
                print_simple_box_end();
            } else {
                /// Show result info
                /// English lang packs aren't downloaded
                if (substr($INSTALL['language'], 0, 2) == 'en') {
                    print_simple_box(get_string('downloadlanguagenotneeded', 'install', $languages[$INSTALL['language']]), 'center', '80%');
                } else {
                    if ($INSTALL['downloadlangpackerror']) {
                        echo "<p class=\"errormsg\" align=\"center\">" . $INSTALL['downloadlangpackerror'] . "</p>\n";
                        print_simple_box(get_string('langdownloaderror', 'install', $languages[$INSTALL['language']]), 'center', '80%');
                    } else {
                        print_simple_box(get_string('langdownloadok', 'install', $languages[$INSTALL['language']]), 'center', '80%');
                    }
                }
            }
            ?>
                </td>
            </tr>

<?php 
            break;
        default:
    }
    ?>

    <tr>
        <td colspan="<?php 
    echo $nextstage == COMPATIBILITY ? 3 : 2;
    ?>
">

<?php 
    if ($needtoopenform) {
        ?>
            <form id="installform" method="post" action="<?php 
        echo $formaction;
        ?>
">
            <div><input type="hidden" name="stage" value="<?php 
        echo $nextstage;
        ?>
" /></div>
<?php 
    }
    $disabled = $enablenext ? '' : 'disabled="disabled"';
    ?>

            <?php 
    echo $nextstage < SAVE ? "<div><input {$disabled} type=\"submit\" name=\"next\" value=\"" . get_string('next') . "  &raquo;\" style=\"float: " . fix_align_rtl("right") . "\"/></div>\n" : "&nbsp;\n";
    ?>
            <?php 
    echo $nextstage > WELCOME ? "<div><input type=\"submit\" name=\"prev\" value=\"&laquo;  " . get_string('previous') . "\" style=\"float: " . fix_align_rtl("left") . "\"/></div>\n" : "&nbsp;\n";
    ?>

<?php 
    if ($needtoopenform) {
        ?>
            </form>
<?php 
    }
    ?>


        </td>

    </tr>

    </table>
<?php 
    if (!$needtoopenform) {
        ?>
    </form>
<?php 
    }
    ?>

<?php 
}
示例#2
0
function form_table($nextstage = WELCOME, $formaction = "install.php")
{
    global $INSTALL, $db;
    $enablenext = true;
    /// Print the standard form
    $needtoopenform = false;
    ?>
    <form id="installform" method="post" action="<?php 
    echo $formaction;
    ?>
">
    <div><input type="hidden" name="stage" value="<?php 
    echo $nextstage;
    ?>
" /></div>

    <table class="install_table" cellspacing="3" cellpadding="3">

<?php 
    /// what we do depends on the stage we're at
    switch ($nextstage) {
        case WELCOME:
            /// Language settings
            ?>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('language');
            ?>
</p></td>
                <td class="td_right">
                <?php 
            choose_from_menu(get_installer_list_of_languages(), 'language', $INSTALL['language'], '', 'this.form.submit();');
            ?>
                </td>
            </tr>

<?php 
            if (file_exists('install/versions.php')) {
                include_once 'install/versions.php';
                echo '<tr><td colspan="2">';
                include_once 'install/welcome.html';
                echo '</td></tr>';
            }
            break;
        case COMPATIBILITY:
            /// Compatibilty check
            $compatsuccess = true;
            /// Check that PHP is of a sufficient version
            print_compatibility_row(inst_check_php_version(), get_string('phpversion', 'install'), get_string('phpversionerror', 'install'), 'phpversionhelp');
            $enablenext = $enablenext && inst_check_php_version();
            /// Check session auto start
            print_compatibility_row(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), 'sessionautostarthelp');
            $enablenext = $enablenext && !ini_get_bool('session.auto_start');
            /// Check magic quotes
            print_compatibility_row(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), 'magicquotesruntimehelp');
            $enablenext = $enablenext && !ini_get_bool('magic_quotes_runtime');
            /// Check unsupported PHP configuration
            print_compatibility_row(!ini_get_bool('register_globals'), get_string('globalsquotes', 'install'), get_string('globalswarning', 'install'));
            $enablenext = $enablenext && !ini_get_bool('register_globals');
            /// Check safe mode
            print_compatibility_row(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), 'safemodehelp', true);
            /// Check file uploads
            print_compatibility_row(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), 'fileuploadshelp', true);
            /// Check GD version
            print_compatibility_row(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), 'gdversionhelp', true);
            /// Check memory limit
            print_compatibility_row(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), 'memorylimithelp', true);
            break;
        case DIRECTORY:
            /// Directory settings
            ?>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('wwwroot', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40" name="wwwrootform" value="<?php 
            p($INSTALL['wwwrootform'], true);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dirroot', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40" name="dirrootform" disabled="disabled" value="<?php 
            p($INSTALL['dirrootform'], true);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dataroot', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" size="40" name="dataroot" value="<?php 
            p($INSTALL['dataroot'], true);
            ?>
" />
                </td>
            </tr>

<?php 
            break;
        case DATABASE:
            /// Database settings
            ?>

            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dbtype', 'install');
            ?>
</p></td>
                <td class="td_right"><input type="hidden" class="input_database" name="dbtype" value="mysql" />mysql</td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dbhost', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="dbhost" value="<?php 
            p($INSTALL['dbhost']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('database', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="dbname" value="<?php 
            p($INSTALL['dbname']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('user');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="dbuser" value="<?php 
            p($INSTALL['dbuser']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('password');
            ?>
</p></td>
                <td class="td_right">
                    <input type="password" class="input_database" name="dbpass" value="<?php 
            p($INSTALL['dbpass']);
            ?>
" />
                </td>
            </tr>
            <tr>
                <td class="td_left"><p class="p_install"><?php 
            print_string('dbprefix', 'install');
            ?>
</p></td>
                <td class="td_right">
                    <input type="text" class="input_database" name="prefix" value="<?php 
            p($INSTALL['prefix']);
            ?>
" />
                </td>
            </tr>

<?php 
            break;
        default:
    }
    ?>

    <tr>
        <td colspan="<?php 
    echo $nextstage == COMPATIBILITY ? '3' : '2';
    ?>
">

<?php 
    if ($needtoopenform) {
        ?>
            <form id="installform" method="post" action="<?php 
        echo $formaction;
        ?>
">
            <div><input type="hidden" name="stage" value="<?php 
        echo $nextstage;
        ?>
" /></div>
<?php 
    }
    $disabled = $enablenext ? '' : 'disabled="disabled"';
    ?>
            <?php 
    echo $nextstage < SAVE ? "<div><input {$disabled} type=\"submit\" name=\"next\" value=\"" . get_string('next') . "  &raquo;\" style=\"float: " . fix_align_rtl("right") . "\"/></div>\n" : "&nbsp;\n";
    ?>
            <?php 
    echo $nextstage > WELCOME ? "<div><input type=\"submit\" name=\"prev\" value=\"&laquo;  " . get_string('previous') . "\" style=\"float: " . fix_align_rtl("left") . "\"/></div>\n" : "&nbsp;\n";
    ?>

<?php 
    if ($needtoopenform) {
        ?>
            </form>
<?php 
    }
    ?>

        </td>

    </tr>

    </table>
<?php 
    if (!$needtoopenform) {
        ?>
    </form>
<?php 
    }
    ?>

<?php 
}
示例#3
0
$interactive =& $INSTALL['interactivelevel'];
$verbose =& $INSTALL['verbose'];
if (!file_exists(dirname(dirname(__FILE__)) . '/config.php')) {
    $configfile = dirname(dirname(__FILE__)) . '/config.php';
    //welcome message
    if ($verbose > CLI_NO) {
        console_write("\n", '', false);
        console_write("\n", '', false);
        console_write('welcometext', 'install');
        console_write("\n", '', false);
        console_write("\n", '', false);
    }
    //============================================================================//
    //Language selection for the installation
    if ($interactive == CLI_FULL || $interactive == CLI_SEMI && !isset($INSTALL['lang'])) {
        $langs = get_installer_list_of_languages();
        console_write("\n", '', false);
        console_write("\n", '', false);
        console_write('selectlanguage', 'install');
        console_write("\n", '', false);
        console_write('availablelangs', 'install');
        console_write("\n", '', false);
        //output available languages
        foreach ($langs as $language) {
            console_write("\t", '', false);
            console_write($language, '', false);
            console_write("\n", '', false);
        }
        console_write("\n", '', false);
        console_write('yourchoice', 'install');
        $short_code_langs = get_short_codes($langs);