Esempio n. 1
0
function transitionNextStep()
{
    if (installerStep() === STEP_PHP_REQUIREMENTS) {
        if (phpRequirementsMet()) {
            installerStepSet(nextStep(STEP_PHP_REQUIREMENTS));
        }
    } else {
        if (installerStep() === STEP_DB_CONFIG) {
            if (dbConfigValid()) {
                installerStepSet(nextStep(STEP_DB_CONFIG));
            }
        } else {
            if (installerStep() === STEP_DB_REQUIREMENTS) {
                if (dbRequirementsMet()) {
                    installerStepSet(nextStep(STEP_DB_REQUIREMENTS));
                }
            } else {
                if (installerStep() === STEP_CONFIG) {
                    if (configCheck()) {
                        installerStepSet(nextStep(STEP_CONFIG));
                    }
                } else {
                    if (installerStep() === STEP_PERMISSION) {
                        if (permissionCheck()) {
                            if (!is_writable(dirname(INSTALL_LOCK_FILE))) {
                                userMessage('error', "Insufficient permission for lockfile " . INSTALL_LOCK_FILE);
                            } else {
                                installerStepSet(nextStep(STEP_PERMISSION));
                            }
                        }
                    } else {
                        if (installerStep() === STEP_WRITE) {
                            installerStepSet(nextStep(STEP_WRITE));
                            setLock();
                        }
                    }
                }
            }
        }
    }
}
Esempio n. 2
0
/**
* execute()
*
* @return
*/
function execute()
{
    global $smcFunc, $execute, $table_prefix;
    checkSession();
    if (empty($_POST['agree']) || empty($_POST['submit_ok'])) {
        fatal_error('How did you get here?', false);
    }
    // how many actioins to do on each loop
    $chunk = 5;
    // Only do these steps if we have not already started our loop
    if (!isset($_SESSION['db_cleaner'])) {
        // init
        $execute = array('tables' => array(), 'columns' => array(), 'indexes' => array(), 'settings' => array(), 'results' => array(), 'actions' => array());
        // build our to do arrays based on what the user selected.
        if (!empty($_POST['columns'])) {
            foreach ($_POST['columns'] as $table_name => $table) {
                if (!preg_match('~^[A-Za-z0-9_]+$~', $table_name)) {
                    continue;
                }
                foreach ($table as $column) {
                    if (preg_match('~^[A-Za-z0-9_]+$~', $column)) {
                        $execute['columns'][$table_name][] = $column;
                    }
                }
            }
        }
        if (!empty($_POST['indexes'])) {
            foreach ($_POST['indexes'] as $table_name => $table) {
                if (!preg_match('~^[A-Za-z0-9_]+$~', $table_name)) {
                    continue;
                }
                foreach ($table as $index) {
                    if (preg_match('~^[A-Za-z0-9_]+$~', $index)) {
                        $execute['indexes'][$table_name][] = $index;
                    }
                }
            }
        }
        if (!empty($_POST['tables'])) {
            foreach ($_POST['tables'] as $table) {
                if (preg_match('~^[A-Za-z0-9_]+$~', $table)) {
                    $execute['tables'][] = $table;
                }
            }
        }
        if (!empty($_POST['settings'])) {
            foreach ($_POST['settings'] as $table) {
                if (preg_match('~^[A-Za-z0-9_]+$~', $table)) {
                    $execute['settings'][] = $table;
                }
            }
        }
        // Step 1: build the remove data for extra index's
        foreach ($execute['indexes'] as $table_name => $table) {
            foreach ($table as $index) {
                $execute['actions'][] = array('prefix' => $table_prefix, 'table' => $table_name, 'index' => $index);
            }
        }
        // Step 2: build the remove data for extra columns
        foreach ($execute['columns'] as $table_name => $table) {
            foreach ($table as $column) {
                $execute['actions'][] = array('prefix' => $table_prefix, 'table' => $table_name, 'column' => $column);
            }
        }
        // Step 3: build the drop data for tables
        foreach ($execute['tables'] as $table) {
            $execute['actions'][] = array('prefix' => $table_prefix, 'table' => $table);
        }
        // Step 4: All those unused settings
        $execute['actions'][] = array('prefix' => $table_prefix, 'settings' => $execute['settings']);
        // save the data for future generations
        $_SESSION['db_cleaner']['execute'] = $execute;
        $_SESSION['db_cleaner']['work'] = count($execute['actions']);
        $_SESSION['db_cleaner']['done'] = 0;
    }
    // load up where we are on this pass
    $execute = $_SESSION['db_cleaner']['execute'];
    $done = $_SESSION['db_cleaner']['done'];
    $work = $_SESSION['db_cleaner']['work'];
    // Do some database work, but not to much :)
    $this_loop = 0;
    $done = isset($_SESSION['db_cleaner']['done']) ? $_SESSION['db_cleaner']['done'] : 0;
    for ($i = $done; $i < $work && $this_loop < $chunk; $i++, $this_loop++) {
        // lazy and don't want to type the whole thing in :)
        $todo = $execute['actions'][$i];
        // remove index, then columns, then tables
        if (isset($todo['index'])) {
            $execute['results']['index'][$todo['table']][$todo['index']] = $smcFunc['db_remove_index']($todo['prefix'] . $todo['table'], $todo['index']);
        }
        if (isset($todo['column'])) {
            $execute['results']['column'][$todo['table']][$todo['column']] = $smcFunc['db_remove_column']($todo['prefix'] . $todo['table'], $todo['column']);
        }
        if (isset($todo['table'])) {
            $execute['results']['table'][$todo['table']] = $smcFunc['db_drop_table']($todo['prefix'] . $todo['table']);
        }
        if (isset($todo['settings']) && count($todo['settings']) != 0) {
            global $modSettings;
            // Settings, do these as a 'single' step, first remove them from memory
            foreach ($todo['settings'] as $setting) {
                if (isset($modSettings[$setting])) {
                    unset($modSettings[$setting]);
                }
            }
            // And now from sight
            $execute['results']['settings'] = $smcFunc['db_query']('', 'DELETE FROM ' . $todo['prefix'] . 'settings WHERE variable IN ({array_string:variables})', array('variables' => $todo['settings']));
            // And let SMF know we have been mucking about
            updateSettings(array('settings_updated' => time()));
        }
    }
    // Are we done yet?? ... if not go round again
    $_SESSION['db_cleaner']['execute'] = $execute;
    if ($i < $work) {
        nextStep('db_cleaner', $i);
    } else {
        unset($_SESSION['db_cleaner']);
    }
}
Esempio n. 3
0
                <tr>
                    <td>install.sql</td>
                    <td>可讀</td>
                    <td>
                        <?php 
check(is_writable('install.sql'));
?>
                    </td>
                </tr>
                <tr>
                    <td>/file</td>
                    <td>可寫</td>
                    <td>
                        <?php 
check(is_writable(dirname(dirname(__FILE__)) . '/file'));
?>
                    </td>
                </tr>
            </table>
            <p>
                <?php 
nextStep();
?>
                    <!--當然你可以用直接瀏覽 install-method.php 的方式來繞過檢測,但是到時無法正常運作是你家的事,我不負責-->
            </p>
        </div>
        <p class="text-center text-info">Proudly Powered by <a href="http://ad.allenchou.cc/">Allen Disk</a></p>
    </body>

    </html>