function updateConfig($dirarray = array()) { //将其转换为配置写入文件 $configfile = DEDEDATA . '/config.file.inc.php'; $old_config = @file_get_contents($configfile); $config_str = makeConfig($dirarray); //替换配置项 $new_config = preg_replace("/#<s_config>(.*)#<e_config>/s", "#<s_config>\n\n{$config_str}#<e_config>", $old_config); file_put_contents($configfile, $new_config); }
function printConfig() { $carry = enumPostItems('ddb', 'duser', 'dpass', 'dhost', 'dprefix', 'txprefix', 'txpath', 'doc_root', 'ftphost', 'ftplogin', 'ftpass', 'ftpath'); $carry['txpath'] = preg_replace("/^(.*)\\/\$/", "\$1", $carry['txpath']); $carry['doc_root'] = preg_replace("/^(.*)\\/\$/", "\$1", $carry['doc_root']); $carry['ftpath'] = preg_replace("/^(.*)\\/\$/", "\$1", $carry['ftpath']); extract($carry); echo graf("Checking database connection..."); if (!($mylink = mysql_connect($dhost, $duser, $dpass))) { exit(graf("Can't connect to the database with the values entered.")); } echo graf('Connected.'); if (!($mydb = mysql_select_db($ddb))) { exit(graf("Database " . strong($ddb) . " doesn't exist. Please create it or choose another.")); } echo graf("Using database " . strong($ddb)), graf(strong('Before you proceed') . ', open <code>config.php</code> in the <code>/textpattern/</code> directory and replace its contents with the following:'), '<textarea style="width:400px;height:200px" name="config" rows="1" cols="1">', makeConfig($carry), '</textarea>', '<form action="setup.php" method="post">', fInput('submit', 'submit', 'I did it', 'smallbox'), sInput('getTxpLogin'), hInput('carry', postEncode($carry)), '</form>'; }
function getTxpLogin() { $carry = postDecode(ps('carry')); extract($carry); $GLOBALS['textarray'] = setup_load_lang($lang); @(include txpath . '/config.php'); if (!isset($txpcfg) || $txpcfg['db'] != $ddb || $txpcfg['table_prefix'] != $dprefix) { echo graf(strong(gTxt('before_you_proceed')) . ', ' . gTxt('create_config', array('{txpath}' => txpath))), '<textarea style="width:400px;height:200px" name="config" rows="1" cols="1">', makeConfig($carry), '</textarea>', '<form action="' . $GLOBALS['rel_siteurl'] . '/textpattern/setup/index.php" method="post">', fInput('submit', 'submit', gTxt('did_it'), 'smallbox'), sInput('getTxpLogin'), hInput('carry', postEncode($carry)), '</form>'; return; } echo '<form action="' . $GLOBALS['rel_siteurl'] . '/textpattern/setup/index.php" method="post">', startTable('edit'), tr(tda(graf(gTxt('thanks')) . graf(gTxt('about_to_create')), ' width="400" colspan="2" align="center"')), tr(fLabelCell(gTxt('your_full_name')) . fInputCell('RealName')), tr(fLabelCell(gTxt('setup_login')) . fInputCell('name')), tr(fLabelCell(gTxt('choose_password')) . fInputCell('pass')), tr(fLabelCell(gTxt('your_email')) . fInputCell('email')), tr(td() . td(fInput('submit', 'Submit', gTxt('next'), 'publish'))), endTable(), sInput('createTxp'), hInput('lang', htmlspecialchars($lang)), hInput('siteurl', htmlspecialchars($siteurl)), '</form>'; }
function setup_config_contents() { return hed(setup_gTxt('creating_config'), 2) . graf(strong(setup_gTxt('before_you_proceed')) . ' ' . setup_gTxt('create_config', array('{txpath}' => txpspecialchars(txpath)))) . '<textarea class="code" readonly="readonly" name="config" cols="' . INPUT_LARGE . '" rows="' . INPUT_MEDIUM . '">' . makeConfig() . '</textarea>' . '<form action="' . txpspecialchars($_SERVER['PHP_SELF']) . '" method="post">' . graf(fInput('submit', 'submit', setup_gTxt('did_it'), 'publish')) . sInput('getTxpLogin') . '</form>'; }
function printConfig() { $carry = enumPostItems('ddb', 'duser', 'dpass', 'dhost', 'dprefix', 'txprefix', 'txpath', 'siteurl', 'ftphost', 'ftplogin', 'ftpass', 'ftpath', 'lang'); $carry['txpath'] = preg_replace("/^(.*)\\/\$/", "\$1", $carry['txpath']); $carry['ftpath'] = preg_replace("/^(.*)\\/\$/", "\$1", $carry['ftpath']); extract($carry); $GLOBALS['textarray'] = setup_load_lang($lang); echo graf(gTxt("checking_database")); if (!($mylink = mysql_connect($dhost, $duser, $dpass))) { exit(graf(gTxt('db_cant_connect'))); } echo graf(gTxt('db_connected')); if (!($mydb = mysql_select_db($ddb))) { exit(graf(str_replace("{dbname}", strong($ddb), gTxt("db_doesnt_exist")))); } // On 4.1 or greater use utf8-tables $version = mysql_get_server_info(); if (intval($version[0]) >= 5 || preg_match('#^4\\.[1-9]#', $version)) { if (mysql_query("SET NAMES utf8")) { $carry['dbcharset'] = "utf8"; $carry['dbcollate'] = "utf8_general_ci"; } else { $carry['dbcharset'] = "latin1"; } } else { $carry['dbcharset'] = "latin1"; } echo graf(str_replace("{dbname}", strong($ddb), gTxt('using_db')) . ' (' . $carry['dbcharset'] . ')'), graf(strong(gTxt('before_you_proceed')) . ', ' . gTxt('create_config')), '<textarea style="width:400px;height:200px" name="config" rows="1" cols="1">', makeConfig($carry), '</textarea>', '<form action="setup.php" method="post">', fInput('submit', 'submit', gTxt('did_it'), 'smallbox'), sInput('getTxpLogin'), hInput('carry', postEncode($carry)), '</form>'; }
function printConfig() { $carry = enumPostItems('ddb', 'duser', 'dpass', 'dhost', 'dprefix', 'txprefix', 'txpath', 'siteurl', 'ftphost', 'ftplogin', 'ftpass', 'ftpath', 'lang'); $carry['txpath'] = preg_replace("/^(.*)\\/\$/", "\$1", $carry['txpath']); $carry['ftpath'] = preg_replace("/^(.*)\\/\$/", "\$1", $carry['ftpath']); extract($carry); $GLOBALS['textarray'] = setup_load_lang($lang); echo graf(gTxt("checking_database")); if (!($mylink = mysql_connect($dhost, $duser, $dpass))) { exit(graf(gTxt('db_cant_connect'))); } echo graf(gTxt('db_connected')); if (!($mydb = mysql_select_db($ddb))) { exit(graf(str_replace("{dbname}", strong($ddb)), gTxt("db_doesnt_exist"))); } echo graf(str_replace("{dbname}", strong($ddb), gTxt('using_db'))), graf(strong(gTxt('before_you_proceed')) . ', ' . gTxt('create_config')), '<textarea style="width:400px;height:200px" name="config" rows="1" cols="1">', makeConfig($carry), '</textarea>', '<form action="setup.php" method="post">', fInput('submit', 'submit', 'I did it', 'smallbox'), sInput('getTxpLogin'), hInput('carry', postEncode($carry)), '</form>'; }