• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP updateSettingsFile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中updateSettingsFile函数的典型用法代码示例。如果您正苦于以下问题:PHP updateSettingsFile函数的具体用法?PHP updateSettingsFile怎么用?PHP updateSettingsFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了updateSettingsFile函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: AdminAccount

function AdminAccount()
{
    global $txt, $db_type, $db_connection, $incontext, $db_prefix, $db_passwd, $sourcedir;
    $incontext['sub_template'] = 'admin_account';
    $incontext['page_title'] = $txt['user_settings'];
    $incontext['continue'] = 1;
    // Skipping?
    if (!empty($_POST['skip'])) {
        return true;
    }
    // Need this to check whether we need the database password.
    require dirname(__FILE__) . '/Settings.php';
    load_database();
    if (!isset($_POST['username'])) {
        $_POST['username'] = '';
    }
    if (!isset($_POST['email'])) {
        $_POST['email'] = '';
    }
    $incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
    $incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
    $incontext['require_db_confirm'] = empty($db_type) || $db_type != 'sqlite';
    // Only allow skipping if we think they already have an account setup.
    $request = smf_db_query('
		SELECT id_member
		FROM {db_prefix}members
		WHERE id_group = {int:admin_group} OR FIND_IN_SET({int:admin_group}, additional_groups) != 0
		LIMIT 1', array('db_error_skip' => true, 'admin_group' => 1));
    if (mysql_num_rows($request) != 0) {
        $incontext['skip'] = 1;
    }
    mysql_free_result($request);
    // Trying to create an account?
    if (isset($_POST['password1']) && !empty($_POST['contbutt'])) {
        // Wrong password?
        if ($incontext['require_db_confirm'] && $_POST['password3'] != $db_passwd) {
            $incontext['error'] = $txt['error_db_connect'];
            return false;
        }
        // Not matching passwords?
        if ($_POST['password1'] != $_POST['password2']) {
            $incontext['error'] = $txt['error_user_settings_again_match'];
            return false;
        }
        // No password?
        if (strlen($_POST['password1']) < 4) {
            $incontext['error'] = $txt['error_user_settings_no_password'];
            return false;
        }
        if (!file_exists($sourcedir . '/lib/Subs.php')) {
            $incontext['error'] = $txt['error_subs_missing'];
            return false;
        }
        // Update the main contact email?
        if (!empty($_POST['email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
            updateSettingsFile(array('webmaster_email' => $_POST['email']));
        }
        // Work out whether we're going to have dodgy characters and remove them.
        $invalid_characters = preg_match('~[<>&"\'=\\\\]~', $_POST['username']) != 0;
        $_POST['username'] = preg_replace('~[<>&"\'=\\\\]~', '', $_POST['username']);
        $result = smf_db_query('
			SELECT id_member, password_salt
			FROM {db_prefix}members
			WHERE member_name = {string:username} OR email_address = {string:email}
			LIMIT 1', array('username' => stripslashes($_POST['username']), 'email' => stripslashes($_POST['email']), 'db_error_skip' => true));
        if (mysql_num_rows($result) != 0) {
            list($incontext['member_id'], $incontext['member_salt']) = mysql_fetch_row($result);
            mysql_free_result($result);
            $incontext['account_existed'] = $txt['error_user_settings_taken'];
        } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) {
            // Try the previous step again.
            $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
            return false;
        } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) {
            // Try the previous step again.
            $incontext['error'] = $txt['error_invalid_characters_username'];
            return false;
        } elseif (empty($_POST['email']) || preg_match('~^[0-9A-Za-z=_+\\-/][0-9A-Za-z=_\'+\\-/\\.]*@[\\w\\-]+(\\.[\\w\\-]+)*(\\.[\\w]{2,6})$~', stripslashes($_POST['email'])) === 0 || strlen(stripslashes($_POST['email'])) > 255) {
            // One step back, this time fill out a proper email address.
            $incontext['error'] = sprintf($txt['error_valid_email_needed'], $_POST['username']);
            return false;
        } elseif ($_POST['username'] != '') {
            $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
            // Format the username properly.
            $_POST['username'] = preg_replace('~[\\t\\n\\r\\x0B\\0\\xA0]+~', ' ', $_POST['username']);
            $ip = isset($_SERVER['REMOTE_ADDR']) ? substr($_SERVER['REMOTE_ADDR'], 0, 255) : '';
            $request = smf_db_insert('insert', $db_prefix . 'members', array('member_name' => 'string-25', 'real_name' => 'string-25', 'passwd' => 'string', 'email_address' => 'string', 'id_group' => 'int', 'posts' => 'int', 'date_registered' => 'int', 'hide_email' => 'int', 'password_salt' => 'string', 'lngfile' => 'string', 'personal_text' => 'string', 'avatar' => 'string', 'member_ip' => 'string', 'member_ip2' => 'string', 'buddy_list' => 'string', 'pm_ignore_list' => 'string', 'message_labels' => 'string', 'location' => 'string', 'signature' => 'string', 'usertitle' => 'string', 'secret_question' => 'string', 'additional_groups' => 'string', 'ignore_boards' => 'string', 'openid_uri' => 'string'), array(stripslashes($_POST['username']), stripslashes($_POST['username']), sha1(strtolower(stripslashes($_POST['username'])) . stripslashes($_POST['password1'])), stripslashes($_POST['email']), 1, 0, time(), 0, $incontext['member_salt'], '', '', '', $ip, $ip, '', '', '', '', '', '', '', '', '', ''), array('id_member'));
            // Awww, crud!
            if ($request === false) {
                $incontext['error'] = $txt['error_user_settings_query'] . '<br />
				<div style="margin: 2ex;">' . nl2br(htmlspecialchars(mysql_error($db_connection))) . '</div>';
                return false;
            }
            $incontext['member_id'] = smf_db_insert_id("{$db_prefix}members", 'id_member');
        }
        // If we're here we're good.
        return true;
    }
    return false;
}
开发者ID:norv,项目名称:EosAlpha,代码行数:100,代码来源:install.php


示例2: smf_db_error

function smf_db_error($db_string, $connection = null)
{
    global $txt, $context, $sourcedir, $webmaster_email, $modSettings;
    global $forum_version, $db_connection, $db_last_error, $db_persist;
    global $db_server, $db_user, $db_passwd, $db_name, $db_show_debug, $ssi_db_user, $ssi_db_passwd;
    global $smcFunc;
    // Get the file and line numbers.
    list($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
    // Decide which connection to use
    $connection = $connection == null ? $db_connection : $connection;
    // This is the error message...
    $query_error = mysql_error($connection);
    $query_errno = mysql_errno($connection);
    // Error numbers:
    //    1016: Can't open file '....MYI'
    //    1030: Got error ??? from table handler.
    //    1034: Incorrect key file for table.
    //    1035: Old key file for table.
    //    1205: Lock wait timeout exceeded.
    //    1213: Deadlock found.
    //    2006: Server has gone away.
    //    2013: Lost connection to server during query.
    // Log the error.
    if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) {
        log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n{$db_string}" : ''), 'database', $file, $line);
    }
    // Database error auto fixing ;).
    if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) {
        // Force caching on, just for the error checking.
        $old_cache = @$modSettings['cache_enable'];
        $modSettings['cache_enable'] = '1';
        if (($temp = cache_get_data('db_last_error', 600)) !== null) {
            $db_last_error = max(@$db_last_error, $temp);
        }
        if (@$db_last_error < time() - 3600 * 24 * 3) {
            // We know there's a problem... but what?  Try to auto detect.
            if ($query_errno == 1030 && strpos($query_error, ' 127 ') !== false) {
                preg_match_all('~(?:[\\n\\r]|^)[^\']+?(?:FROM|JOIN|UPDATE|TABLE) ((?:[^\\n\\r(]+?(?:, )?)*)~s', $db_string, $matches);
                $fix_tables = array();
                foreach ($matches[1] as $tables) {
                    $tables = array_unique(explode(',', $tables));
                    foreach ($tables as $table) {
                        // Now, it's still theoretically possible this could be an injection.  So backtick it!
                        if (trim($table) != '') {
                            $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
                        }
                    }
                }
                $fix_tables = array_unique($fix_tables);
            } elseif ($query_errno == 1016) {
                if (preg_match('~\'([^\\.\']+)~', $query_error, $match) != 0) {
                    $fix_tables = array('`' . $match[1] . '`');
                }
            } elseif ($query_errno == 1034 || $query_errno == 1035) {
                preg_match('~\'([^\']+?)\'~', $query_error, $match);
                $fix_tables = array('`' . $match[1] . '`');
            }
        }
        // Check for errors like 145... only fix it once every three days, and send an email. (can't use empty because it might not be set yet...)
        if (!empty($fix_tables)) {
            // Subs-Admin.php for updateSettingsFile(), Subs-Post.php for sendmail().
            require_once $sourcedir . '/Subs-Admin.php';
            require_once $sourcedir . '/Subs-Post.php';
            // Make a note of the REPAIR...
            cache_put_data('db_last_error', time(), 600);
            if (($temp = cache_get_data('db_last_error', 600)) === null) {
                updateSettingsFile(array('db_last_error' => time()));
            }
            // Attempt to find and repair the broken table.
            foreach ($fix_tables as $table) {
                $smcFunc['db_query']('', "\r\n\t\t\t\t\tREPAIR TABLE {$table}", false, false);
            }
            // And send off an email!
            sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair']);
            $modSettings['cache_enable'] = $old_cache;
            // Try the query again...?
            $ret = $smcFunc['db_query']('', $db_string, false, false);
            if ($ret !== false) {
                return $ret;
            }
        } else {
            $modSettings['cache_enable'] = $old_cache;
        }
        // Check for the "lost connection" or "deadlock found" errors - and try it just one more time.
        if (in_array($query_errno, array(1205, 1213, 2006, 2013))) {
            if (in_array($query_errno, array(2006, 2013)) && $db_connection == $connection) {
                // Are we in SSI mode?  If so try that username and password first
                if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) {
                    if (empty($db_persist)) {
                        $db_connection = @mysql_connect($db_server, $ssi_db_user, $ssi_db_passwd);
                    } else {
                        $db_connection = @mysql_pconnect($db_server, $ssi_db_user, $ssi_db_passwd);
                    }
                }
                // Fall back to the regular username and password if need be
                if (!$db_connection) {
                    if (empty($db_persist)) {
                        $db_connection = @mysql_connect($db_server, $db_user, $db_passwd);
                    } else {
                        $db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd);
//.........这里部分代码省略.........
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:101,代码来源:Subs-Db-mysql.php


示例3: ConvertUtf8


//.........这里部分代码省略.........
        return;
    }
    // After this point we're starting the conversion. But first: session check.
    checkSession();
    // Translation table for the character sets not native for MySQL.
    $translation_tables = array('windows-1255' => array('0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '\'\'', '0xFC' => '\'\'', '0xFF' => '\'\'', '0xC2' => '0xFF', '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', '0xFA' => '0xD7AA', '0xFF' => '0xD6B2', '0xFC' => '0xE282AC', '0xFB' => '0xD792'), 'windows-1253' => array('0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', '0xD2' => '\'\'', '0xFF' => '\'\'', '0xCE' => '0xCE9E', '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', '0xFF' => '0xCE92', '0xD2' => '0xE282AC'));
    // Make some preparations.
    if (isset($translation_tables[$_POST['src_charset']])) {
        $replace = '%field%';
        foreach ($translation_tables[$_POST['src_charset']] as $from => $to) {
            $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')';
        }
    }
    // Grab a list of tables.
    if (preg_match('~^`(.+?)`\\.(.+?)$~', $db_prefix, $match) === 1) {
        $queryTables = $smcFunc['db_query']('', '
			SHOW TABLE STATUS
			FROM `' . strtr($match[1], array('`' => '')) . '`
			LIKE {string:table_name}', array('table_name' => str_replace('_', '\\_', $match[2]) . '%'));
    } else {
        $queryTables = $smcFunc['db_query']('', '
			SHOW TABLE STATUS
			LIKE {string:table_name}', array('table_name' => str_replace('_', '\\_', $db_prefix) . '%'));
    }
    while ($table_info = $smcFunc['db_fetch_assoc']($queryTables)) {
        // Just to make sure it doesn't time out.
        if (function_exists('apache_reset_timeout')) {
            @apache_reset_timeout();
        }
        $table_charsets = array();
        // Loop through each column.
        $queryColumns = $smcFunc['db_query']('', '
			SHOW FULL COLUMNS
			FROM ' . $table_info['Name'], array());
        while ($column_info = $smcFunc['db_fetch_assoc']($queryColumns)) {
            // Only text'ish columns have a character set and need converting.
            if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) {
                $collation = empty($column_info['Collation']) || $column_info['Collation'] === 'NULL' ? $table_info['Collation'] : $column_info['Collation'];
                if (!empty($collation) && $collation !== 'NULL') {
                    list($charset) = explode('_', $collation);
                    if (!isset($table_charsets[$charset])) {
                        $table_charsets[$charset] = array();
                    }
                    $table_charsets[$charset][] = $column_info;
                }
            }
        }
        $smcFunc['db_free_result']($queryColumns);
        // Only change the column if the data doesn't match the current charset.
        if (count($table_charsets) === 1 && key($table_charsets) !== $charsets[$_POST['src_charset']] || count($table_charsets) > 1) {
            $updates_blob = '';
            $updates_text = '';
            foreach ($table_charsets as $charset => $columns) {
                if ($charset !== $charsets[$_POST['src_charset']]) {
                    foreach ($columns as $column) {
                        $updates_blob .= '
							CHANGE COLUMN ' . $column['Field'] . ' ' . $column['Field'] . ' ' . strtr($column['Type'], array('text' => 'blob', 'char' => 'binary')) . ($column['Null'] === 'YES' ? ' NULL' : ' NOT NULL') . (strpos($column['Type'], 'char') === false ? '' : ' default \'' . $column['Default'] . '\'') . ',';
                        $updates_text .= '
							CHANGE COLUMN ' . $column['Field'] . ' ' . $column['Field'] . ' ' . $column['Type'] . ' CHARACTER SET ' . $charsets[$_POST['src_charset']] . ($column['Null'] === 'YES' ? '' : ' NOT NULL') . (strpos($column['Type'], 'char') === false ? '' : ' default \'' . $column['Default'] . '\'') . ',';
                    }
                }
            }
            // Change the columns to binary form.
            $smcFunc['db_query']('', '
				ALTER TABLE {raw:table_name}{raw:updates_blob}', array('table_name' => $table_info['Name'], 'updates_blob' => substr($updates_blob, 0, -1)));
            // Convert the character set if MySQL has no native support for it.
            if (isset($translation_tables[$_POST['src_charset']])) {
                $update = '';
                foreach ($table_charsets as $charset => $columns) {
                    foreach ($columns as $column) {
                        $update .= '
							' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ',';
                    }
                }
                $smcFunc['db_query']('', '
					UPDATE {raw:table_name}
					SET {raw:updates}', array('table_name' => $table_info['Name'], 'updates' => substr($update, 0, -1)));
            }
            // Change the columns back, but with the proper character set.
            $smcFunc['db_query']('', '
				ALTER TABLE {raw:table_name}{raw:updates_text}', array('table_name' => $table_info['Name'], 'updates_text' => substr($updates_text, 0, -1)));
        }
        // Now do the actual conversion (if still needed).
        if ($charsets[$_POST['src_charset']] !== 'utf8') {
            $smcFunc['db_query']('', '
				ALTER TABLE {raw:table_name}
				CONVERT TO CHARACTER SET utf8', array('table_name' => $table_info['Name']));
        }
    }
    $smcFunc['db_free_result']($queryTables);
    // Let the settings know we have a new character set.
    updateSettings(array('global_character_set' => 'UTF-8', 'previousCharacterSet' => empty($translation_tables[$_POST['src_charset']]) ? $charsets[$_POST['src_charset']] : $translation_tables[$_POST['src_charset']]));
    // Store it in Settings.php too because it's needed before db connection.
    require_once $sourcedir . '/Subs-Admin.php';
    updateSettingsFile(array('db_character_set' => '\'utf8\''));
    // The conversion might have messed up some serialized strings. Fix them!
    require_once $sourcedir . '/Subs-Charset.php';
    fix_serialized_columns();
    redirectexit('action=admin;area=maintain;done=convertutf8');
}
开发者ID:chenhao6593,项目名称:smf,代码行数:101,代码来源:ManageMaintenance.php


示例4: action_adminAccount

/**
 * Ask for the administrator login information.
 */
function action_adminAccount()
{
    global $txt, $db_type, $db_connection, $databases, $incontext, $db_prefix, $db_passwd;
    $incontext['sub_template'] = 'admin_account';
    $incontext['page_title'] = $txt['user_settings'];
    $incontext['continue'] = 1;
    // Need this to check whether we need the database password.
    require dirname(__FILE__) . '/Settings.php';
    if (!defined('ELK')) {
        define('ELK', 1);
    }
    definePaths();
    // These files may be or may not be already included, better safe than sorry for now
    require_once SOURCEDIR . '/Subs.php';
    require_once SUBSDIR . '/Util.class.php';
    $db = load_database();
    if (!isset($_POST['username'])) {
        $_POST['username'] = '';
    }
    if (!isset($_POST['email'])) {
        $_POST['email'] = '';
    }
    $incontext['username'] = htmlspecialchars(stripslashes($_POST['username']), ENT_COMPAT, 'UTF-8');
    $incontext['email'] = htmlspecialchars(stripslashes($_POST['email']), ENT_COMPAT, 'UTF-8');
    $incontext['require_db_confirm'] = empty($db_type) || !empty($databases[$db_type]['require_db_confirm']);
    // Only allow create an admin account if they don't have one already.
    $request = $db->query('', '
		SELECT id_member
		FROM {db_prefix}members
		WHERE id_group = {int:admin_group} OR FIND_IN_SET({int:admin_group}, additional_groups) != 0
		LIMIT 1', array('db_error_skip' => true, 'admin_group' => 1));
    // Skip the step if an admin already exists
    if ($db->num_rows($request) != 0) {
        return true;
    }
    $db->free_result($request);
    // Trying to create an account?
    if (isset($_POST['password1']) && !empty($_POST['contbutt'])) {
        // Wrong password?
        if ($incontext['require_db_confirm'] && $_POST['password3'] != $db_passwd) {
            $incontext['error'] = $txt['error_db_connect'];
            return false;
        }
        // Not matching passwords?
        if ($_POST['password1'] != $_POST['password2']) {
            $incontext['error'] = $txt['error_user_settings_again_match'];
            return false;
        }
        // No password?
        if (strlen($_POST['password1']) < 4) {
            $incontext['error'] = $txt['error_user_settings_no_password'];
            return false;
        }
        if (!file_exists(SOURCEDIR . '/Subs.php')) {
            $incontext['error'] = $txt['error_subs_missing'];
            return false;
        }
        // Update the main contact email?
        if (!empty($_POST['email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
            updateSettingsFile(array('webmaster_email' => $_POST['email']));
        }
        // Work out whether we're going to have dodgy characters and remove them.
        $invalid_characters = preg_match('~[<>&"\'=\\\\]~', $_POST['username']) != 0;
        $_POST['username'] = preg_replace('~[<>&"\'=\\\\]~', '', $_POST['username']);
        $result = $db->query('', '
			SELECT id_member, password_salt
			FROM {db_prefix}members
			WHERE member_name = {string:username} OR email_address = {string:email}
			LIMIT 1', array('username' => stripslashes($_POST['username']), 'email' => stripslashes($_POST['email']), 'db_error_skip' => true));
        if ($db->num_rows($result) != 0) {
            list($incontext['member_id'], $incontext['member_salt']) = $db->fetch_row($result);
            $db->free_result($result);
            $incontext['account_existed'] = $txt['error_user_settings_taken'];
        } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) {
            // Try the previous step again.
            $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
            return false;
        } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) {
            // Try the previous step again.
            $incontext['error'] = $txt['error_invalid_characters_username'];
            return false;
        } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) {
            // One step back, this time fill out a proper email address.
            $incontext['error'] = sprintf($txt['error_valid_email_needed'], $_POST['username']);
            return false;
        } elseif ($_POST['username'] != '') {
            require_once SUBSDIR . '/Auth.subs.php';
            $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
            // Format the username properly.
            $_POST['username'] = preg_replace('~[\\t\\n\\r\\x0B\\0\\xA0]+~', ' ', $_POST['username']);
            $ip = isset($_SERVER['REMOTE_ADDR']) ? substr($_SERVER['REMOTE_ADDR'], 0, 255) : '';
            // Get a security hash for this combination
            $password = stripslashes($_POST['password1']);
            $incontext['passwd'] = validateLoginPassword($password, '', $_POST['username'], true);
            $request = $db->insert('', $db_prefix . 'members', array('member_name' => 'string-25', 'real_name' => 'string-25', 'passwd' => 'string', 'email_address' => 'string', 'id_group' => 'int', 'posts' => 'int', 'date_registered' => 'int', 'hide_email' => 'int', 'password_salt' => 'string', 'lngfile' => 'string', 'personal_text' => 'string', 'avatar' => 'string', 'member_ip' => 'string', 'member_ip2' => 'string', 'buddy_list' => 'string', 'pm_ignore_list' => 'string', 'message_labels' => 'string', 'website_title' => 'string', 'website_url' => 'string', 'location' => 'string', 'signature' => 'string', 'usertitle' => 'string', 'secret_question' => 'string', 'additional_groups' => 'string', 'ignore_boards' => 'string', 'openid_uri' => 'string'), array(stripslashes($_POST['username']), stripslashes($_POST['username']), $incontext['passwd'], stripslashes($_POST['email']), 1, 0, time(), 0, $incontext['member_salt'], '', '', '', $ip, $ip, '', '', '', '', '', '', '', '', '', '', '', ''), array('id_member'));
            // Awww, crud!
            if ($request === false) {
//.........这里部分代码省略.........
开发者ID:joshuaadickerson,项目名称:Elkarte,代码行数:101,代码来源:install.php


示例5: saveSettings

function saveSettings(&$config_vars)
{
    global $boarddir, $sc, $cookiename, $modSettings, $user_settings;
    global $sourcedir, $context, $cachedir;
    // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
    if (isset($_POST['cookiename'])) {
        $_POST['cookiename'] = preg_replace('~[,;\\s\\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
    }
    // Fix the forum's URL if necessary.
    if (isset($_POST['boardurl'])) {
        if (substr($_POST['boardurl'], -10) == '/index.php') {
            $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
        } elseif (substr($_POST['boardurl'], -1) == '/') {
            $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
        }
        if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
            $_POST['boardurl'] = 'http://' . $_POST['boardurl'];
        }
    }
    // Any passwords?
    $config_passwords = array('db_passwd', 'ssi_db_passwd');
    // All the strings to write.
    $config_strs = array('mtitle', 'mmessage', 'language', 'mbname', 'boardurl', 'cookiename', 'webmaster_email', 'db_name', 'db_user', 'db_server', 'db_prefix', 'ssi_db_user', 'boarddir', 'sourcedir', 'cachedir');
    // All the numeric variables.
    $config_ints = array();
    // All the checkboxes.
    $config_bools = array('db_persist', 'db_error_send', 'maintenance');
    // Now sort everything into a big array, and figure out arrays and etc.
    $new_settings = array();
    foreach ($config_passwords as $config_var) {
        if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) {
            $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
        }
    }
    foreach ($config_strs as $config_var) {
        if (isset($_POST[$config_var])) {
            $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\'';
        }
    }
    foreach ($config_ints as $config_var) {
        if (isset($_POST[$config_var])) {
            $new_settings[$config_var] = (int) $_POST[$config_var];
        }
    }
    foreach ($config_bools as $key) {
        if (!empty($_POST[$key])) {
            $new_settings[$key] = '1';
        } else {
            $new_settings[$key] = '0';
        }
    }
    // Save the relevant settings in the Settings.php file.
    require_once $sourcedir . '/Subs-Admin.php';
    updateSettingsFile($new_settings);
    // Now loopt through the remaining (database-based) settings.
    $new_settings = array();
    foreach ($config_vars as $config_var) {
        // We just saved the file-based settings, so skip their definitions.
        if (!is_array($config_var) || $config_var[2] == 'file') {
            continue;
        }
        // Rewrite the definition a bit.
        $new_settings[] = array($config_var[3], $config_var[0]);
    }
    // Save the new database-based settings, if any.
    if (!empty($new_settings)) {
        saveDBSettings($new_settings);
    }
}
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:69,代码来源:ManageServer.php


示例6: doStep2

function doStep2()
{
    global $txt, $db_prefix, $db_connection, $HTTP_SESSION_VARS, $cookiename;
    global $func, $db_character_set, $mbname, $context, $scripturl, $boardurl;
    global $current_smf_version;
    // Load the SQL server login information.
    require_once dirname(__FILE__) . '/Settings.php';
    if (!isset($_POST['password3'])) {
        return doStep2a();
    }
    $db_connection = @mysql_connect($db_server, $db_user, $_POST['password3']);
    if (!$db_connection) {
        echo '
				<div class="error_message">
					<div style="color: red;">', $txt['error_mysql_connect'], '</div>
				</div>';
        return doStep2a();
    }
    if (!mysql_select_db($db_name, $db_connection)) {
        echo '
				<div class="error_message">
					<div style="color: red;">', sprintf($txt['error_mysql_database'], $db_name), '</div>
				</div>
				<br />';
        return doStep2a();
    }
    // Let them try again...
    if ($_POST['password1'] != $_POST['password2']) {
        echo '
				<div class="error_message">
					<div style="color: red;">', $txt['error_user_settings_again_match'], '</div>
				</div>
				<br />';
        return doStep2a();
    }
    if (!file_exists($sourcedir . '/Subs.php')) {
        echo '
				<div class="error_message">
					<div style="color: red;">', $txt['error_subs_missing'], '</div>
				</div>
				<br />';
        return doStep2a();
    }
    updateSettingsFile(array('webmaster_email' => $_POST['email']));
    chdir(dirname(__FILE__));
    define('SMF', 1);
    require_once $sourcedir . '/Subs.php';
    require_once $sourcedir . '/Load.php';
    require_once $sourcedir . '/Security.php';
    require_once $sourcedir . '/Subs-Auth.php';
    // Define the sha1 function, if it doesn't exist.
    if (!function_exists('sha1')) {
        require_once $sourcedir . '/Subs-Compat.php';
    }
    if (isset($db_character_set)) {
        mysql_query("\n\t\t\tSET NAMES {$db_character_set}");
    }
    $result = mysql_query("\n\t\tSELECT ID_MEMBER, passwordSalt\n\t\tFROM {$db_prefix}members\n\t\tWHERE memberName = '{$_POST['username']}' OR emailAddress = '{$_POST['email']}'\n\t\tLIMIT 1");
    if (mysql_num_rows($result) != 0) {
        list($id, $salt) = mysql_fetch_row($result);
        mysql_free_result($result);
        echo '
				<div class="error_message">
					<div style="color: red;">', $txt['error_user_settings_taken'], '</div>
				</div>
				<br />';
    } elseif (preg_match('~[<>&"\'=\\\\]~', $_POST['username']) != 0 || strlen($_POST['username']) > 25 || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) {
        // Initialize some variables needed for the language file.
        $context = array('forum_name' => $mbname);
        $modSettings = array('lastActive' => '15', 'hotTopicPosts' => '15', 'hotTopicVeryPosts' => '25', 'smfVersion' => $current_smf_version);
        $scripturl = $boardurl . '/index.php';
        require_once dirname(__FILE__) . '/Themes/default/languages/' . strtr($_SESSION['installer_temp_lang'], array('Install' => 'index'));
        echo '
				<div class="error_message">
					<div style="color: red;">', $txt[240], '</div>
				</div>
				<br />';
        // Try the previous step again.
        return doStep2a();
    } elseif (empty($_POST['email']) || preg_match('~^[0-9A-Za-z=_+\\-/][0-9A-Za-z=_\'+\\-/\\.]*@[\\w\\-]+(\\.[\\w\\-]+)*(\\.[\\w]{2,6})$~', stripslashes($_POST['email'])) === 0 || strlen(stripslashes($_POST['email'])) > 255) {
        // Artificially fill some of the globals needed for the language files.
        $context = array('forum_name' => $mbname);
        $modSettings = array('lastActive' => '15', 'hotTopicPosts' => '15', 'hotTopicVeryPosts' => '25', 'smfVersion' => $current_smf_version);
        $scripturl = $boardurl . '/index.php';
        require_once dirname(__FILE__) . '/Themes/default/languages/' . strtr($_SESSION['installer_temp_lang'], array('Install' => 'index'));
        require_once dirname(__FILE__) . '/Themes/default/languages/' . strtr($_SESSION['installer_temp_lang'], array('Install' => 'Login'));
        echo '
				<div class="error_message">
					<div style="color: red;">', sprintf($txt[500], $_POST['username']), '</div>
				</div>
				<br />';
        // One step back, this time fill out a proper email address.
        return doStep2a();
    } elseif ($_POST['username'] != '') {
        $salt = substr(md5(mt_rand()), 0, 4);
        // Format the username properly.
        $_POST['username'] = preg_replace('~[\\t\\n\\r\\x0B\\0\\xA0]+~', ' ', $_POST['username']);
        $ip = isset($_SERVER['REMOTE_ADDR']) ? addslashes(substr(stripslashes($_SERVER['REMOTE_ADDR']), 0, 255)) : '';
        $request = mysql_query("\n\t\t\tINSERT INTO {$db_prefix}members\n\t\t\t\t(memberName, realName, passwd, emailAddress, ID_GROUP, posts, dateRegistered, hideEmail, passwordSalt, lngfile, personalText, avatar, memberIP, memberIP2, buddy_list, pm_ignore_list, messageLabels, websiteTitle, websiteUrl, location, ICQ, MSN, signature, usertitle, secretQuestion, additionalGroups)\n\t\t\tVALUES (SUBSTRING('{$_POST['username']}', 1, 25), SUBSTRING('{$_POST['username']}', 1, 25), '" . sha1(strtolower($_POST['username']) . $_POST['password1']) . "', '{$_POST['email']}', 1, '0', '" . time() . "', '0', '{$salt}', '', '', '', '{$ip}', '{$ip}', '', '', '', '', '', '', '', '', '', '', '', '')");
        // Awww, crud!
//.........这里部分代码省略.........
开发者ID:bbon,项目名称:mjncms,代码行数:101,代码来源:install.php


示例7: mysql_query

                    <div style="margin: 2.5ex; font-family: monospace;"><b>', $mysql_error, '</b></div>

                    <a href="', $_SERVER['PHP_SELF'], '?step=0&amp;overphp=true">', $install_lang['error_message_click'], '</a> ', $install_lang['error_message_try_again'], '
                </div>';
        return false;
    }
    // Let's try that database on for size...
    if ($database != '') {
        mysql_query("\r\n            CREATE DATABASE IF NOT EXISTS `{$database}`", $db_connection);
    }
    // Okay, let's try the prefix if it didn't work...
    if (!mysql_select_db($database, $db_connection) && $database != '') {
        mysql_query("\r\n            CREATE DATABASE IF NOT EXISTS `{$TABLE_PREFIX}{$database}`", $db_connection);
        if (mysql_select_db($TABLE_PREFIX . $database, $db_connection)) {
            $db_name = $TABLE_PREFIX . $db_name;
            updateSettingsFile(array('database' => $database));
        }
    }
    // Okay, now let's try to connect...
    if (!mysql_select_db($database, $db_connection)) {
        echo '
                <div class="error_message">
                    <div style="color: red;">', sprintf($install_lang['error_mysql_database'], $database), '</div>
                    <br />
                    <a href="', $_SERVER['PHP_SELF'], '?step=0&amp;overphp=true">', $install_lang['error_message_click'], '</a> ', $install_lang['error_message_try_again'], '
                </div>';
        return false;
    }
    $replaces = array('{$db_prefix}' => $TABLE_PREFIX);
    foreach ($install_lang as $key => $value) {
        if (substr($key, 0, 8) == 'default_') {
开发者ID:ne0lite,项目名称:xbtit-tracker,代码行数:31,代码来源:install.php


示例8: show_db_error

function show_db_error($loadavg = false)
{
    global $sourcedir, $mbname, $maintenance, $mtitle, $mmessage, $modSettings;
    global $db_connection, $webmaster_email, $db_last_error, $db_error_send, $smcFunc;
    // Don't cache this page!
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Cache-Control: no-cache');
    // Send the right error codes.
    header('HTTP/1.1 503 Service Temporarily Unavailable');
    header('Status: 503 Service Temporarily Unavailable');
    header('Retry-After: 3600');
    if ($loadavg == false) {
        // For our purposes, we're gonna want this on if at all possible.
        $modSettings['cache_enable'] = '1';
        if (($temp = cache_get_data('db_last_error', 600)) !== null) {
            $db_last_error = max($db_last_error, $temp);
        }
        if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) {
            require_once $sourcedir . '/Subs-Admin.php';
            // Avoid writing to the Settings.php file if at all possible; use shared memory instead.
            cache_put_data('db_last_error', time(), 600);
            if (($temp = cache_get_data('db_last_error', 600)) === null) {
                updateSettingsFile(array('db_last_error' => time()));
            }
            // Language files aren't loaded yet :(.
            $db_error = @$smcFunc['db_error']($db_connection);
            @mail($webmaster_email, $mbname . ': SMF Database Error!', 'There has been a problem with the database!' . ($db_error == '' ? '' : "\n" . $smcFunc['db_title'] . ' reported:' . "\n" . $db_error) . "\n\n" . 'This is a notice email to let you know that SMF could not connect to the database, contact your host if this continues.');
        }
    }
    if (!empty($maintenance)) {
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta name="robots" content="noindex" />
		<title>', $mtitle, '</title>
	</head>
	<body>
		<h3>', $mtitle, '</h3>
		', $mmessage, '
	</body>
</html>';
    } elseif ($loadavg) {
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta name="robots" content="noindex" />
		<title>Temporarily Unavailable</title>
	</head>
	<body>
		<h3>Temporarily Unavailable</h3>
		Due to high stress on the server the forum is temporarily unavailable.  Please try again later.
	</body>
</html>';
    } else {
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta name="robots" content="noindex" />
		<title>Connection Problems</title>
	</head>
	<body>
		<h3>Connection Problems</h3>
		Sorry, SMF was unable to connect to the database.  This may be caused by the server being busy.  Please try again later.
	</body>
</html>';
    }
    die;
}
开发者ID:Kheros,项目名称:MMOver,代码行数:69,代码来源:Subs-Auth.php


示例9: ModifyCoreSettings2

function ModifyCoreSettings2()
{
    global $boarddir, $sc, $cookiename, $modSettings, $user_settings, $sourcedir;
    global $context;
    // Strip the slashes off of the post vars.
    foreach ($_POST as $key => $val) {
        $_POST[$key] = stripslashes__recursive($val);
    }
    // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
    if (isset($_POST['cookiename'])) {
        $_POST['cookiename'] = preg_replace('~[,;\\s\\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
    }
    // Fix the forum's URL if necessary.
    if (substr($_POST['boardurl'], -10) == '/index.php') {
        $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
    } elseif (substr($_POST['boardurl'], -1) == '/') {
        $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
    }
    if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
        $_POST['boardurl'] = 'http://' . $_POST['boardurl'];
    }
    // Any passwords?
    $config_passwords = array('db_passwd');
    // All the strings to write.
    $config_strs = array('mtitle', 'mmessage', 'language', 'mbname', 'boardurl', 'cookiename', 'webmaster_email', 'db_name', 'db_user', 'db_server', 'db_prefix', 'boarddir', 'sourcedir');
    // All the numeric variables.
    $config_ints = array();
    // All the checkboxes.
    $config_bools = array('db_persist', 'db_error_send', 'maintenance');
    // Now sort everything into a big array, and figure out arrays and etc.
    $config_vars = array();
    foreach ($config_passwords as $config_var) {
        if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) {
            $config_vars[$config_var] = '\'' . addcslashes($_POST[$config_var][0], "'\\") . '\'';
        }
    }
    foreach ($config_strs as $config_var) {
        if (isset($_POST[$config_var])) {
            $config_vars[$config_var] = '\'' . addcslashes($_POST[$config_var], "'\\") . '\'';
        }
    }
    foreach ($config_ints as $config_var) {
        if (isset($_POST[$config_var])) {
            $config_vars[$config_var] = (int) $_POST[$config_var];
        }
    }
    foreach ($config_bools as $key) {
        if (!empty($_POST[$key])) {
            $config_vars[$key] = '1';
        } else {
            $config_vars[$key] = '0';
        }
    }
    require_once $sourcedir . '/Admin.php';
    updateSettingsFile($config_vars);
    // If the cookie name was changed, reset the cookie.
    if (isset($config_vars['cookiename']) && $cookiename != $_POST['cookiename']) {
        include_once $sourcedir . '/Subs-Auth.php';
        $cookiename = $_POST['cookiename'];
        setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['ID_MEMBER'], sha1($user_settings['passwd'] . $user_settings['passwordSalt']));
        redirectexit('action=serversettings;sa=core;sesc=' . $sc, $context['server']['needs_login_fix']);
    }
    redirectexit('action=serversettings;sa=core;sesc=' . $sc);
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:64,代码来源:ManageServer.php


示例10: ModifyLanguage


//.........这里部分代码省略.........
                if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) {
                    unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php');
                }
            }
            // Check for the email template.
            if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) {
                unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
            }
        }
        // Third, the agreement file.
        if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) {
            unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');
        }
        // Fourth, a related images folder?
        foreach ($images_dirs as $curPath) {
            if (is_dir($curPath)) {
                deltree($curPath);
            }
        }
        // Members can no longer use this language.
        $smcFunc['db_query']('', '
			UPDATE {db_prefix}members
			SET lngfile = {string:empty_string}
			WHERE lngfile = {string:current_language}', array('empty_string' => '', 'current_language' => $context['lang_id']));
        // Fifth, update getLanguages() cache.
        if (!empty($modSettings['cache_enable'])) {
            cache_put_data('known_languages', null, !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
            cache_put_data('known_languages_all', null, !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
        }
        // Sixth, if we deleted the default language, set us back to english?
        if ($context['lang_id'] == $language) {
            require_once $sourcedir . '/Subs-Admin.php';
            $language = 'english';
            updateSettingsFile(array('language' => '\'' . $language . '\''));
        }
        // Seventh, get out of here.
        redirectexit('action=admin;area=languages;sa=edit;' . $context['session_var'] . '=' . $context['session_id']);
    }
   

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP updateSitePath函数代码示例发布时间:2022-05-23
下一篇:
PHP updateSettings函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap