Пример #1
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 
}
Пример #2
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 
}
Пример #3
0
/**
 * Check PHP option memory_limit
 *
 * @param string $errorMsg Error message if checking failed
 * @param string $value    Actual value of the checked parameter
 *
 * @return bool
 */
function checkPhpMemoryLimit(&$errorMsg, &$value)
{
    $result = true;
    $value = @ini_get("memory_limit");
    if (is_disabled_memory_limit()) {
        $value = xtr('Unlimited');
    } else {
        $result = check_memory_limit($value, constant('LC_PHP_MEMORY_LIMIT_MIN'));
        if (!$result) {
            $errorMsg = xtr('PHP memory_limit option value should be :minval as a minimum', array(':minval' => constant('LC_PHP_MEMORY_LIMIT_MIN')));
        }
    }
    return $result;
}
Пример #4
0
 /// Check that PHP is of a sufficient version
 check_compatibility(inst_check_php_version(), get_string('phpversion', 'install'), get_string('php52versionerror', 'install'), false, $silent);
 /// Check session auto start
 check_compatibility(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), false, $silent);
 /// Check magic quotes
 check_compatibility(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), false, $silent);
 /// Check unsupported PHP configuration
 check_compatibility(ini_get_bool('register_globals'), get_string('globalsquotes', 'install'), get_string('globalswarning', 'install'), false, $silent);
 /// Check safe mode
 check_compatibility(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), true, $silent);
 /// Check file uploads
 check_compatibility(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), true, $silent);
 /// Check GD version
 check_compatibility(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), true, $silent);
 /// Check memory limit
 check_compatibility(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), true, $silent);
 //================================================================================//
 // Moodle directories and web address
 if ($interactive == CLI_FULL || $interactive == CLI_SEMI && (!isset($INSTALL['dirroot']) || !isset($INSTALL['wwwroot']) || !isset($INSTALL['dataroot']))) {
     console_write("\n", '', false);
     console_write("\n", '', false);
     console_write('locationanddirectories', 'install');
     console_write("\n", '', false);
     console_write("\n", '', false);
 }
 //input the web directory
 if ($interactive == CLI_FULL || $interactive == CLI_SEMI && !isset($INSTALL['dirroot'])) {
     console_write('inputwebdirectory', 'install');
     //if directories validation lib is found change this to read_dir() and
     //edit read_dir() in lib/installlib.php to point to validation code
     $INSTALL['dirroot'] = read();