Beispiel #1
0
function initialize_inputs()
{
    global $smcFunc, $db_connection, $sourcedir, $db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_type, $context, $sources_exist, $sources_found_path;
    // Turn off magic quotes runtime and enable error reporting.
    @set_magic_quotes_runtime(0);
    error_reporting(E_ALL);
    if (ini_get('session.save_handler') == 'user') {
        ini_set('session.save_handler', 'files');
    }
    @session_start();
    if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0) {
        foreach ($_POST as $k => $v) {
            if (is_array($v)) {
                foreach ($v as $k2 => $v2) {
                    $_POST[$k][$k2] = stripslashes($v2);
                }
            } else {
                $_POST[$k] = stripslashes($v);
            }
        }
    }
    foreach ($_POST as $k => $v) {
        if (is_array($v)) {
            foreach ($v as $k2 => $v2) {
                $_POST[$k][$k2] = addcslashes($v2, '\'\\');
            }
        } else {
            $_POST[$k] = addcslashes($v, '\'\\');
        }
    }
    // This is really quite simple; if ?delete is on the URL, delete the installer...
    if (isset($_GET['delete'])) {
        @unlink(__FILE__);
        // Now just redirect to a blank.gif...
        header('Location: http://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.gif');
        exit;
    }
    $db_connection = false;
    $sources_exist = false;
    $sources_found_path = '';
    if (isset($sourcedir) && file_exists(dirname(__FILE__) . '/Sources/Load.php')) {
        $sources_exist = true;
    } else {
        //Find Sources folder!
        $sourcedir = findSources();
        $sources_found_path = $sourcedir;
        $sources_exist = !empty($sourcedir);
    }
    if ($sources_exist) {
        if (!defined('SMF')) {
            define('SMF', 1);
        }
        if (empty($smcFunc)) {
            $smcFunc = array();
        }
        // Default the database type to MySQL.
        if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php') || $db_type == 'mysqli') {
            $db_type = 'mysql';
        }
        //require_once($sourcedir . '/Load.php');
        //require_once($sourcedir . '/Subs-Auth.php');
        // compat mode. Active!
        $context['is_legacy'] = true;
        if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php') && $db_type == 'mysql') {
            $db_connection = smc_compat_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
        } else {
            // Far as I know, this is 2.0.
            $context['is_legacy'] = false;
            require_once $sourcedir . '/Subs-Db-' . $db_type . '.php';
            require_once $sourcedir . '/DbExtra-' . $db_type . '.php';
            $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
            db_extra_init();
            //Fixes error with $db_connection not false if database name is incorrect. This is because the connection is established
            //without this parameter, thus performing incorrectly.
            if ($db_connection == true) {
                if (!$smcFunc['db_select_db']($db_name, $db_connection)) {
                    $db_connection = null;
                } else {
                    $tables = $smcFunc['db_list_tables']($db_name);
                    if (!(is_array($tables) && in_array($db_prefix . 'settings', $tables))) {
                        $db_connection = null;
                    }
                }
            } else {
                $db_connection = null;
            }
        }
    }
}
Beispiel #2
0
function initialize_inputs()
{
    global $smcFunc, $db_connection, $sourcedir, $db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_type, $context;
    // Turn off magic quotes runtime and enable error reporting.
    @set_magic_quotes_runtime(0);
    error_reporting(E_ALL);
    if (ini_get('session.save_handler') == 'user') {
        ini_set('session.save_handler', 'files');
    }
    @session_start();
    // Slashes as soo old-fashion...
    if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0) {
        foreach ($_POST as $k => $v) {
            if (is_array($v)) {
                foreach ($v as $k2 => $v2) {
                    $_POST[$k][$k2] = stripslashes($v2);
                }
            } else {
                $_POST[$k] = stripslashes($v);
            }
        }
    }
    foreach ($_POST as $k => $v) {
        if (is_array($v)) {
            foreach ($v as $k2 => $v2) {
                $_POST[$k][$k2] = addcslashes($v2, '\'');
            }
        } else {
            $_POST[$k] = addcslashes($v, '\'');
        }
    }
    // This is really quite simple; if ?delete is on the URL, delete the installer...
    if (isset($_GET['delete'])) {
        @unlink(__FILE__);
        // Now just redirect to a blank.gif...
        header('Location: http://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.gif');
        exit;
    }
    $db_connection = false;
    if (isset($sourcedir)) {
        define('SMF', 1);
        if (empty($smcFunc)) {
            $smcFunc = array();
        }
        // Default the database type to MySQL.
        if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) {
            $db_type = 'mysql';
        }
        require_once $sourcedir . '/Load.php';
        require_once $sourcedir . '/Subs-Auth.php';
        // compat mode. Active!
        $context['is_legacy'] = true;
        if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php') && $db_type == 'mysql') {
            $db_connection = smc_compat_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
        } else {
            // Far as I know, this is 2.0.
            $context['is_legacy'] = false;
            require_once $sourcedir . '/Subs-Db-' . $db_type . '.php';
            require_once $sourcedir . '/DbExtra-' . $db_type . '.php';
            $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true));
            db_extra_init();
        }
    }
}