Do not install if tables already exist

This commit is contained in:
Kijin Sung 2016-02-07 10:21:40 +09:00
parent 78cb8aea17
commit 5a7906252e
3 changed files with 13 additions and 1 deletions

View file

@ -40,7 +40,7 @@ class installController extends install
'user' => $config->db_user,
'pass' => $config->db_pass,
'database' => $config->db_database,
'prefix' => $config->db_prefix,
'prefix' => rtrim($config->db_prefix, '_') . '_',
));
// Check connection to the DB.
@ -78,6 +78,16 @@ class installController extends install
$config->db_charset = $oDB->charset;
}
// Check if tables already exist.
$table_check = array('documents', 'comments', 'modules', 'sites');
foreach ($table_check as $table_name)
{
if ($oDB->isTableExists($table_name))
{
return new Object(-1, 'msg_table_already_exists');
}
}
// Save DB config in session.
$_SESSION['db_config'] = $config;

View file

@ -91,6 +91,7 @@ $lang->msg_table_is_exists = 'Table is already created in the DB. Config file is
$lang->msg_install_completed = 'Installation has been completed. Thank you for choosing RhymiX.';
$lang->msg_install_failed = 'An error has occurred while creating installation file.';
$lang->msg_create_table_failed = 'Failed to create database tables.';
$lang->msg_table_already_exists = 'Database tables already exist. Try using a different prefix.';
$lang->ftp_get_list = 'Get List';
$lang->ftp_form_title = 'FTP Account Information';
$lang->ftp = 'FTP';

View file

@ -91,6 +91,7 @@ $lang->msg_table_is_exists = '이미 DB에 테이블이 생성되어 있습니
$lang->msg_install_completed = '설치가 완료되었습니다. 감사합니다.';
$lang->msg_install_failed = '설치 파일 생성 시에 오류가 발생하였습니다.';
$lang->msg_create_table_failed = 'DB 테이블 생성에 실패했습니다.';
$lang->msg_table_already_exists = 'DB 테이블이 이미 존재합니다. 다른 사이트에서 사용중인 DB라면 테이블 접두사를 바꾸어 보십시오.';
$lang->ftp_get_list = '목록 가져오기';
$lang->ftp_form_title = 'FTP 계정 정보 입력';
$lang->ftp = 'FTP';