$fielddefault[$r_table][$fields['Field']] = $fields['Default']; } } $field = $saxdb[$r_table][$r_field]; $altersql = '`' . $field['Field'] . '` ' . $field['Type']; $altersql .= $field['Null'] == 'NO' ? ' NOT NULL' : ''; $altersql .= in_array($fielddefault[$r_table][$field['Field']], array('', '0')) && in_array($field['Default'], array('', '0')) || $field['Null'] == 'NO' && $field['Default'] == '' || preg_match('/text/i', $field['Type']) || preg_match('/auto_increment/i', $field['Extra']) ? '' : ' default \'' . $field['Default'] . '\''; $altersql .= $field['Extra'] != '' ? ' ' . $field['Extra'] : ''; $altersql = $option == 'modify' ? "MODIFY COLUMN " . $altersql : "ADD COLUMN " . $altersql; $alter[$r_table][] = $altersql; } } } foreach ($alter as $r_table => $sqls) { $DB->query("ALTER TABLE `{$db_prefix}{$r_table}` " . implode(',', $sqls), 'SILENT'); if ($sqlerror = $DB->geterrdesc()) { $errorcount += count($sqls); $error .= $sqlerror . '<br /><br />'; } } $alter = array(); foreach ($repairtable as $value) { foreach ($saxdb[$value] as $field) { if (!isset($fielddefault[$value]) && ($fieldsquery = $DB->query("SHOW FIELDS FROM {$db_prefix}{$value}", 'SILENT'))) { while ($fields = $DB->fetch_array($fieldsquery)) { $fielddefault[$value][$fields['Field']] = $fields['Default']; } } $altersql = '`' . $field['Field'] . '` ' . $field['Type']; $altersql .= $field['Null'] == 'NO' ? ' NOT NULL' : ''; $altersql .= in_array($fielddefault[$value][$field['Field']], array('', '0')) && in_array($field['Default'], array('', '0')) || $field['Null'] == 'NO' && $field['Default'] == '' || preg_match('/text/i', $field['Type']) || preg_match('/auto_increment/i', $field['Extra']) ? '' : ' default \'' . $field['Default'] . '\'';
define('IN_SAESPOT', 1); @header("content-Type: text/html; charset=UTF-8"); $sqlfile = dirname(__FILE__) . '/yunbbs_mysql.sql'; if (!is_readable($sqlfile)) { exit('数据库文件不存在或者读取失败'); } $fp = fopen($sqlfile, 'rb'); $sql = fread($fp, 2048000); fclose($fp); include dirname(__FILE__) . '/config.php'; include dirname(__FILE__) . '/include/mysql.class.php'; $DBS = new DB_MySQL(); $DBS->connect($servername, $dbport, $dbusername, $dbpassword, $dbname); unset($servername, $dbusername, $dbpassword); $DBS->select_db($dbname); if ($DBS->geterrdesc()) { if (mysql_get_server_info() > '4.1') { $DBS->query("CREATE DATABASE {$dbname} DEFAULT CHARACTER SET {$dbcharset}"); } else { $DBS->query("CREATE DATABASE {$dbname}"); } if ($DBS->geterrdesc()) { exit('指定的数据库不存在, 系统也无法自动建立, 无法安装.<br />'); } else { $DBS->select_db($dbname); //成功建立指定数据库 } } $query - $DBS->query("SELECT COUNT(*) FROM yunbbs_settings", 'SILENT'); if (!$DBS->geterrdesc()) { header('location: /');
define('IN_SAESPOT', 1); @header("content-Type: text/html; charset=UTF-8"); $sqlfile = dirname(__FILE__) . '/yunbbs_mysql.sql'; if (!is_readable($sqlfile)) { exit('数据库文件不存在或者读取失败'); } $fp = fopen($sqlfile, 'rb'); $sql = fread($fp, 2048000); fclose($fp); include dirname(__FILE__) . '/config.php'; include dirname(__FILE__) . '/include/mysql.class.php'; $DBM = new DB_MySQL(); $DBM->connect($servername_m, $dbport, $dbusername, $dbpassword, $dbname); unset($servername_m, $dbusername, $dbpassword); $DBM->select_db($dbname); if ($DBM->geterrdesc()) { if (mysql_get_server_info() > '4.1') { $DBM->query("CREATE DATABASE {$dbname} DEFAULT CHARACTER SET {$dbcharset}"); } else { $DBM->query("CREATE DATABASE {$dbname}"); } if ($DBM->geterrdesc()) { exit('指定的数据库不存在, 系统也无法自动建立, 无法安装.<br />'); } else { $DBM->select_db($dbname); //成功建立指定数据库 } } $DBM->query("SELECT COUNT(*) FROM `yunbbs_settings`", 'SILENT'); if (!$DBM->geterrdesc()) { // 清空缓存