Improve installer validation and error handling
This commit is contained in:
@@ -7,6 +7,8 @@ include_once('../lib/common.lib.php'); // 공통 라이브러리
|
||||
include_once('../lib/hook.lib.php'); // hook 함수 파일
|
||||
include_once('../lib/get_data.lib.php'); // 데이터 가져오는 함수 모음
|
||||
|
||||
@header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$data_path = '../'.G5_DATA_DIR;
|
||||
|
||||
// 파일이 존재한다면 설치할 수 없다.
|
||||
@@ -30,29 +32,32 @@ $ajax_token = md5($tmp_str.$_SERVER['REMOTE_ADDR'].dirname(dirname(__FILE__).'/'
|
||||
|
||||
$bool_ajax_token = (isset($_POST['ajax_token']) && ($ajax_token == $_POST['ajax_token'])) ? true : false;
|
||||
|
||||
if (!($mysql_host && $mysql_user && $mysql_pass && $mysql_db && $table_prefix && $bool_ajax_token)) {
|
||||
if (!($mysql_host && $mysql_user && $mysql_db && $table_prefix && $bool_ajax_token)) {
|
||||
die(install_json_msg('잘못된 요청입니다.'));
|
||||
}
|
||||
|
||||
try {
|
||||
$dblink = sql_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db);
|
||||
} catch (Exception $e) {
|
||||
$connect = install_db_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db);
|
||||
$dblink = $connect['link'];
|
||||
|
||||
if (!$dblink || $connect['message']) {
|
||||
if ($connect['error']) {
|
||||
install_error_log($connect['message'].' | '.$connect['error']);
|
||||
}
|
||||
die(install_json_msg($connect['message'] ? $connect['message'] : 'MySQL 정보를 확인해 주십시오.'));
|
||||
}
|
||||
|
||||
if (!isset($dblink)) {
|
||||
die(install_json_msg('MySQL Host, User, Password 를 확인해 주십시오.'));
|
||||
$db_check = install_check_db_capability($dblink, $table_prefix);
|
||||
if (!$db_check[0]) {
|
||||
die(install_json_msg($db_check[1]));
|
||||
}
|
||||
|
||||
try {
|
||||
$select_db = sql_select_db($mysql_db, $dblink);
|
||||
} catch (Exception $e) {
|
||||
$table_check_error = '';
|
||||
$table_exists = install_table_exists($dblink, $table_prefix.'config', $table_check_error);
|
||||
if ($table_check_error) {
|
||||
die(install_json_msg('테이블 존재 여부를 확인하지 못했습니다. DB 계정 권한을 확인해 주십시오.'));
|
||||
}
|
||||
|
||||
if (!isset($select_db)) {
|
||||
die(install_json_msg('MySQL DB 를 확인해 주십시오.'));
|
||||
}
|
||||
|
||||
if (sql_query("SHOW TABLES LIKE `{$table_prefix}config`", G5_DISPLAY_SQL_ERROR, $dblink)) {
|
||||
if ($table_exists) {
|
||||
die(install_json_msg('주의! 이미 테이블이 존재하므로, 기존 DB 자료가 망실됩니다. 계속 진행하겠습니까?', 'exists'));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ include_once ('./install.inc.php');
|
||||
if ($exists_data_dir && $write_data_dir) {
|
||||
// 필수 모듈 체크
|
||||
require_once('./library.check.php');
|
||||
if (empty($install_library_required_missing)) {
|
||||
?>
|
||||
<form action="./install_config.php" method="post" onsubmit="return frm_submit(this);">
|
||||
|
||||
@@ -48,6 +49,7 @@ function frm_submit(f)
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
} // if
|
||||
?>
|
||||
|
||||
|
||||
@@ -56,4 +56,398 @@ if( ! function_exists('install_json_msg') ){
|
||||
|
||||
return json_encode(array('error'=>$error_msg, 'success'=>$success_msg, 'exists'=>$exists_msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_error_log') ){
|
||||
function install_error_log($message) {
|
||||
$err_file = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '';
|
||||
@error_log('[g5 install] '.$message.' | file: '.$err_file);
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_html_escape') ){
|
||||
function install_html_escape($str) {
|
||||
return htmlspecialchars((string) $str, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_db_error') ){
|
||||
function install_db_error($link=null) {
|
||||
if (function_exists('mysqli_connect') && G5_MYSQLI_USE) {
|
||||
if ($link) {
|
||||
return mysqli_errno($link).' : '.mysqli_error($link);
|
||||
}
|
||||
return mysqli_connect_errno().' : '.mysqli_connect_error();
|
||||
}
|
||||
|
||||
if (function_exists('mysql_error')) {
|
||||
return $link ? mysql_errno($link).' : '.mysql_error($link) : mysql_errno().' : '.mysql_error();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_db_query') ){
|
||||
function install_db_query($sql, $link) {
|
||||
if (function_exists('mysqli_query') && G5_MYSQLI_USE) {
|
||||
return @mysqli_query($link, $sql);
|
||||
}
|
||||
|
||||
return @mysql_query($sql, $link);
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_db_fetch_row') ){
|
||||
function install_db_fetch_row($result) {
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (function_exists('mysqli_fetch_row') && G5_MYSQLI_USE) {
|
||||
return mysqli_fetch_row($result);
|
||||
}
|
||||
|
||||
return mysql_fetch_row($result);
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_db_num_rows') ){
|
||||
function install_db_num_rows($result) {
|
||||
if (!$result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (function_exists('mysqli_num_rows') && G5_MYSQLI_USE) {
|
||||
return mysqli_num_rows($result);
|
||||
}
|
||||
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_db_connect') ){
|
||||
function install_db_connect($host, $user, $pass, $db) {
|
||||
$result = array('link'=>false, 'error'=>'', 'message'=>'');
|
||||
|
||||
if (function_exists('mysqli_connect') && G5_MYSQLI_USE) {
|
||||
if (function_exists('mysqli_report')) {
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
}
|
||||
|
||||
$link = @mysqli_connect($host, $user, $pass);
|
||||
if (!$link) {
|
||||
$result['error'] = install_db_error();
|
||||
$result['message'] = 'MySQL Host, User, Password 정보를 확인해 주십시오.';
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!@mysqli_select_db($link, $db)) {
|
||||
$result['link'] = $link;
|
||||
$result['error'] = install_db_error($link);
|
||||
$result['message'] = 'MySQL DB 정보를 확인해 주십시오.';
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result['link'] = $link;
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!function_exists('mysql_connect')) {
|
||||
$result['message'] = 'MySQL 확장(mysqli/mysql)이 설치되어 있지 않습니다.';
|
||||
return $result;
|
||||
}
|
||||
|
||||
$link = @mysql_connect($host, $user, $pass);
|
||||
if (!$link) {
|
||||
$result['error'] = install_db_error();
|
||||
$result['message'] = 'MySQL Host, User, Password 정보를 확인해 주십시오.';
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!@mysql_select_db($db, $link)) {
|
||||
$result['link'] = $link;
|
||||
$result['error'] = install_db_error($link);
|
||||
$result['message'] = 'MySQL DB 정보를 확인해 주십시오.';
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result['link'] = $link;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_sql_like_escape') ){
|
||||
function install_sql_like_escape($str) {
|
||||
return str_replace(array('\\', '%', '_'), array('\\\\', '\%', '\_'), $str);
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_sql_escape') ){
|
||||
function install_sql_escape($str, $link) {
|
||||
if (function_exists('mysqli_real_escape_string') && G5_MYSQLI_USE) {
|
||||
return mysqli_real_escape_string($link, $str);
|
||||
}
|
||||
|
||||
return mysql_real_escape_string($str, $link);
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_table_exists') ){
|
||||
function install_table_exists($link, $table, &$error='') {
|
||||
$error = '';
|
||||
$table_like = install_sql_escape(install_sql_like_escape($table), $link);
|
||||
$result = install_db_query("SHOW TABLES LIKE '{$table_like}'", $link);
|
||||
|
||||
if (!$result) {
|
||||
$error = install_db_error($link);
|
||||
install_error_log('table exists check failed: '.$error.' | table: '.$table);
|
||||
return false;
|
||||
}
|
||||
|
||||
return install_db_num_rows($result) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_get_existing_tables') ){
|
||||
function install_get_existing_tables($link, $prefixes) {
|
||||
$tables = array();
|
||||
|
||||
foreach ($prefixes as $prefix) {
|
||||
if (!$prefix) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$table_like = install_sql_escape(install_sql_like_escape($prefix).'%', $link);
|
||||
$result = install_db_query("SHOW TABLES LIKE '{$table_like}'", $link);
|
||||
|
||||
while ($row = install_db_fetch_row($result)) {
|
||||
if (isset($row[0])) {
|
||||
$tables[$row[0]] = $row[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksort($tables);
|
||||
|
||||
return array_values($tables);
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_fail_page') ){
|
||||
function install_fail_page($message, $link=null, $prefixes=array()) {
|
||||
global $install_progress_started;
|
||||
|
||||
install_error_log($message);
|
||||
|
||||
if (!empty($install_progress_started)) {
|
||||
$install_progress_started = false;
|
||||
?>
|
||||
</ol>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div class="ins_inner">
|
||||
<h2>설치를 계속할 수 없습니다.</h2>
|
||||
<p><?php echo nl2br(install_html_escape($message)); ?></p>
|
||||
<?php
|
||||
if ($link && $prefixes) {
|
||||
$tables = install_get_existing_tables($link, $prefixes);
|
||||
if ($tables) {
|
||||
?>
|
||||
<p>설치가 중간에 멈춘 경우 아래 테이블이 일부 생성되었을 수 있습니다. 다시 설치하려면 DB에서 해당 테이블을 정리하거나, 재설치 옵션을 선택한 뒤 진행해 주십시오.</p>
|
||||
<ul>
|
||||
<?php
|
||||
for ($i=0; $i<count($tables); $i++) {
|
||||
?>
|
||||
<li><?php echo install_html_escape($tables[$i]); ?></li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="inner_btn"><a href="./install_config.php">뒤로가기</a></div>
|
||||
</div>
|
||||
<?php
|
||||
include_once('./install.inc2.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_query_or_fail') ){
|
||||
function install_query_or_fail($sql, $link, $message, $prefixes=array()) {
|
||||
$result = install_db_query($sql, $link);
|
||||
|
||||
if (!$result) {
|
||||
install_error_log($message.' | '.install_db_error($link).' | SQL: '.$sql);
|
||||
install_fail_page($message."\n서버 오류 로그를 확인해 주십시오.", $link, $prefixes);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_check_db_capability') ){
|
||||
function install_check_db_capability($link, $table_prefix) {
|
||||
$suffix = substr(md5(uniqid('', true)), 0, 12);
|
||||
$table = $table_prefix.'install_check_'.$suffix;
|
||||
$charset = preg_replace('/[^0-9a-z_]/i', '', G5_DB_CHARSET);
|
||||
$engine = '';
|
||||
|
||||
if (!$charset) {
|
||||
$charset = 'utf8';
|
||||
}
|
||||
|
||||
if (in_array(strtolower(G5_DB_ENGINE), array('innodb', 'myisam'))) {
|
||||
$engine = ' ENGINE='.G5_DB_ENGINE;
|
||||
}
|
||||
|
||||
$checks = array(
|
||||
"CREATE TABLE `{$table}` (`id` int(11) NOT NULL){$engine} DEFAULT CHARSET={$charset}",
|
||||
"INSERT INTO `{$table}` (`id`) VALUES (1)",
|
||||
"ALTER TABLE `{$table}` ADD `memo` varchar(20) NOT NULL DEFAULT ''",
|
||||
"DROP TABLE `{$table}`"
|
||||
);
|
||||
|
||||
for ($i=0; $i<count($checks); $i++) {
|
||||
if (!install_db_query($checks[$i], $link)) {
|
||||
$error = install_db_error($link);
|
||||
install_db_query("DROP TABLE IF EXISTS `{$table}`", $link);
|
||||
install_error_log('DB capability check failed: '.$error.' | SQL: '.$checks[$i]);
|
||||
|
||||
return array(false, 'DB 계정에 테이블 생성/입력/수정/삭제 권한이 있는지, DB 문자셋('.G5_DB_CHARSET.')을 사용할 수 있는지 확인해 주십시오.');
|
||||
}
|
||||
}
|
||||
|
||||
return array(true, '');
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_split_sql') ){
|
||||
function install_split_sql($sql) {
|
||||
$queries = array();
|
||||
$query = '';
|
||||
$quote = '';
|
||||
$len = strlen($sql);
|
||||
|
||||
for ($i=0; $i<$len; $i++) {
|
||||
$char = $sql[$i];
|
||||
$next = ($i + 1 < $len) ? $sql[$i + 1] : '';
|
||||
|
||||
if ($quote) {
|
||||
$query .= $char;
|
||||
|
||||
if ($quote !== '`' && $char === '\\' && $next !== '') {
|
||||
$query .= $next;
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($char === $quote) {
|
||||
$quote = '';
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($char === "'" || $char === '"' || $char === '`') {
|
||||
$quote = $char;
|
||||
$query .= $char;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($char === '-' && $next === '-' && ($i === 0 || preg_match('/\s/', $sql[$i - 1]))) {
|
||||
while ($i < $len && $sql[$i] !== "\n") {
|
||||
$i++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($char === '#') {
|
||||
while ($i < $len && $sql[$i] !== "\n") {
|
||||
$i++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($char === '/' && $next === '*') {
|
||||
$i += 2;
|
||||
while ($i < $len - 1 && !($sql[$i] === '*' && $sql[$i + 1] === '/')) {
|
||||
$i++;
|
||||
}
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($char === ';') {
|
||||
$trimmed = trim($query);
|
||||
if ($trimmed !== '') {
|
||||
$queries[] = $trimmed;
|
||||
}
|
||||
$query = '';
|
||||
continue;
|
||||
}
|
||||
|
||||
$query .= $char;
|
||||
}
|
||||
|
||||
$trimmed = trim($query);
|
||||
if ($trimmed !== '') {
|
||||
$queries[] = $trimmed;
|
||||
}
|
||||
|
||||
return $queries;
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_load_sql_file') ){
|
||||
function install_load_sql_file($file, $from_prefix, $to_prefix) {
|
||||
if (!is_readable($file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = file_get_contents($file);
|
||||
if ($sql === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = preg_replace('/`'.preg_quote($from_prefix, '/').'([^`]+`)/', '`'.$to_prefix.'$1', $sql);
|
||||
|
||||
return install_split_sql($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_ensure_dir') ){
|
||||
function install_ensure_dir($dir) {
|
||||
if (!is_dir($dir) && !@mkdir($dir, G5_DIR_PERMISSION)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@chmod($dir, G5_DIR_PERMISSION);
|
||||
|
||||
return is_dir($dir) && is_writable($dir);
|
||||
}
|
||||
}
|
||||
|
||||
if( ! function_exists('install_file_write') ){
|
||||
function install_file_write($handle, $content) {
|
||||
global $install_file_write_error;
|
||||
|
||||
if ($install_file_write_error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = @fwrite($handle, $content);
|
||||
|
||||
if ($result === false || $result < strlen($content)) {
|
||||
$install_file_write_error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +135,56 @@ $ajax_token = md5($tmp_str.$_SERVER['REMOTE_ADDR'].dirname(dirname(__FILE__).'/'
|
||||
|
||||
<script src="../js/jquery-1.8.3.min.js"></script>
|
||||
<script>
|
||||
function get_install_check_error_message(xhr)
|
||||
{
|
||||
var status = (xhr && xhr.status) ? ' (HTTP ' + xhr.status + ')' : '';
|
||||
var default_msg = 'DB 연결 점검 중 오류가 발생했습니다.' + status + '\n'
|
||||
+ 'MySQL Host/User/Password/DB 정보가 올바른지, DB 서버가 동작 중인지 확인해 주십시오.\n'
|
||||
+ '문제가 계속되면 PHP 오류 로그를 확인하시기 바랍니다.';
|
||||
var response_text = xhr ? (xhr.responseText || '') : '';
|
||||
|
||||
if (response_text && window.jQuery) {
|
||||
try {
|
||||
var data = jQuery.parseJSON(response_text);
|
||||
if (data && data.error) {
|
||||
return data.error;
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
response_text = response_text.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ');
|
||||
response_text = window.jQuery ? jQuery.trim(response_text) : response_text;
|
||||
|
||||
return response_text || default_msg;
|
||||
}
|
||||
|
||||
function set_install_submit_state(f, submitting)
|
||||
{
|
||||
var submit_btn = f.querySelector ? f.querySelector('input[type="submit"]') : null;
|
||||
|
||||
if (submitting) {
|
||||
f.setAttribute('data-install-submitting', '1');
|
||||
if (submit_btn) {
|
||||
submit_btn.setAttribute('data-original-value', submit_btn.value);
|
||||
submit_btn.disabled = true;
|
||||
submit_btn.value = '점검 중...';
|
||||
}
|
||||
} else {
|
||||
f.removeAttribute('data-install-submitting');
|
||||
if (submit_btn) {
|
||||
submit_btn.disabled = false;
|
||||
submit_btn.value = submit_btn.getAttribute('data-original-value') || '다음';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function frm_install_submit(f)
|
||||
{
|
||||
if (f.getAttribute('data-install-submitting') == '1') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (f.mysql_host.value == '')
|
||||
{
|
||||
alert('MySQL Host 를 입력하십시오.'); f.mysql_host.focus(); return false;
|
||||
@@ -194,25 +242,46 @@ function frm_install_submit(f)
|
||||
f.admin_id.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (f.g5_install.checked) {
|
||||
var reinstall_msg = '재설치를 선택했습니다.\n\n'
|
||||
+ 'DB: ' + f.mysql_db.value + '\n'
|
||||
+ 'TABLE명 접두사: ' + f.table_prefix.value + '\n'
|
||||
+ '쇼핑몰 TABLE명 접두사: ' + f.g5_shop_prefix.value + '\n\n'
|
||||
+ '기존 테이블과 자료가 삭제되거나 덮어써질 수 있습니다. 계속 진행하시겠습니까?';
|
||||
|
||||
if (!confirm(reinstall_msg)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
set_install_submit_state(f, true);
|
||||
|
||||
if (window.jQuery) {
|
||||
|
||||
var jqxhr = jQuery.post( "ajax.install.check.php", $(f).serialize(), function(data) {
|
||||
|
||||
if( data.error ){
|
||||
set_install_submit_state(f, false);
|
||||
alert(data.error);
|
||||
} else if( data.exists ) {
|
||||
if( confirm(data.exists) ){
|
||||
if( f.g5_install.checked || confirm(data.exists) ){
|
||||
f.submit();
|
||||
} else {
|
||||
set_install_submit_state(f, false);
|
||||
}
|
||||
} else if( data.success ) {
|
||||
f.submit();
|
||||
} else {
|
||||
set_install_submit_state(f, false);
|
||||
alert(get_install_check_error_message());
|
||||
}
|
||||
|
||||
}, "json");
|
||||
|
||||
jqxhr.fail(function(xhr) {
|
||||
alert( xhr.responseText );
|
||||
set_install_submit_state(f, false);
|
||||
alert(get_install_check_error_message(xhr));
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
+173
-151
@@ -37,17 +37,17 @@ $admin_name = isset($_POST['admin_name']) ? $_POST['admin_name'] : '';
|
||||
$admin_email = isset($_POST['admin_email']) ? $_POST['admin_email'] : '';
|
||||
|
||||
if (preg_match("/[^0-9a-z_]+/i", $table_prefix) ) {
|
||||
die('<div class="ins_inner"><p>TABLE명 접두사는 영문자, 숫자, _ 만 입력하세요.</p><div class="inner_btn"><a href="./install_config.php">뒤로가기</a></div></div>');
|
||||
install_fail_page('TABLE명 접두사는 영문자, 숫자, _ 만 입력하세요.');
|
||||
}
|
||||
|
||||
if (preg_match("/[^0-9a-z_]+/i", $admin_id)) {
|
||||
die('<div class="ins_inner"><p>관리자 아이디는 영문자, 숫자, _ 만 입력하세요.</p><div class="inner_btn"><a href="./install_config.php">뒤로가기</a></div></div>');
|
||||
install_fail_page('관리자 아이디는 영문자, 숫자, _ 만 입력하세요.');
|
||||
}
|
||||
|
||||
// 관리자 이메일 형식 검증
|
||||
$admin_email = trim($admin_email);
|
||||
if (!$admin_email || !filter_var($admin_email, FILTER_VALIDATE_EMAIL)) {
|
||||
die('<div class="ins_inner"><p>올바른 관리자 E-mail 주소를 입력하세요.</p><div class="inner_btn"><a href="./install_config.php">뒤로가기</a></div></div>');
|
||||
install_fail_page('올바른 관리자 E-mail 주소를 입력하세요.');
|
||||
}
|
||||
|
||||
$g5_install = isset($_POST['g5_install']) ? (int) $_POST['g5_install'] : 0;
|
||||
@@ -55,36 +55,29 @@ $g5_shop_prefix = isset($_POST['g5_shop_prefix']) ? safe_install_string_check($_
|
||||
$g5_shop_install = isset($_POST['g5_shop_install']) ? (int) $_POST['g5_shop_install'] : 0;
|
||||
|
||||
if (preg_match("/[^0-9a-z_]+/i", $g5_shop_prefix)) {
|
||||
die('<div class="ins_inner"><p>쇼핑몰 TABLE명 접두사는 영문자, 숫자, _ 만 입력하세요.</p><div class="inner_btn"><a href="./install_config.php">뒤로가기</a></div></div>');
|
||||
install_fail_page('쇼핑몰 TABLE명 접두사는 영문자, 숫자, _ 만 입력하세요.');
|
||||
}
|
||||
|
||||
$dblink = sql_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db);
|
||||
if (!$dblink) {
|
||||
?>
|
||||
$install_table_prefixes = array($table_prefix);
|
||||
if ($g5_shop_install) {
|
||||
$install_table_prefixes[] = $g5_shop_prefix;
|
||||
}
|
||||
|
||||
<div class="ins_inner">
|
||||
<p>MySQL Host, User, Password 를 확인해 주십시오.</p>
|
||||
<div class="inner_btn"><a href="./install_config.php">뒤로가기</a></div>
|
||||
</div>
|
||||
$connect = install_db_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db);
|
||||
$dblink = $connect['link'];
|
||||
|
||||
<?php
|
||||
include_once('./install.inc2.php');
|
||||
exit;
|
||||
if (!$dblink || $connect['message']) {
|
||||
if ($connect['error']) {
|
||||
install_error_log($connect['message'].' | '.$connect['error']);
|
||||
}
|
||||
install_fail_page($connect['message'] ? $connect['message'] : 'MySQL 정보를 확인해 주십시오.', $dblink, $install_table_prefixes);
|
||||
}
|
||||
|
||||
$g5['connect_db'] = $dblink;
|
||||
$select_db = sql_select_db($mysql_db, $dblink);
|
||||
if (!$select_db) {
|
||||
?>
|
||||
|
||||
<div class="ins_inner">
|
||||
<p>MySQL DB 를 확인해 주십시오.</p>
|
||||
<div class="inner_btn"><a href="./install_config.php">뒤로가기</a></div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
include_once('./install.inc2.php');
|
||||
exit;
|
||||
$db_check = install_check_db_capability($dblink, $table_prefix);
|
||||
if (!$db_check[0]) {
|
||||
install_fail_page($db_check[1], $dblink, $install_table_prefixes);
|
||||
}
|
||||
|
||||
$mysql_set_mode = 'false';
|
||||
@@ -93,57 +86,52 @@ sql_set_charset(G5_DB_CHARSET, $dblink);
|
||||
// 관리자 입력값 SQL escape — sql_set_charset 이후 적용
|
||||
$admin_name = sql_real_escape_string(trim($admin_name), $dblink);
|
||||
$admin_email = sql_real_escape_string($admin_email, $dblink);
|
||||
$result = sql_query(" SELECT @@sql_mode as mode ", true, $dblink);
|
||||
$result = install_query_or_fail(" SELECT @@sql_mode as mode ", $dblink, 'DB SQL 모드를 확인하지 못했습니다.', $install_table_prefixes);
|
||||
$row = sql_fetch_array($result);
|
||||
if($row['mode']) {
|
||||
sql_query("SET SESSION sql_mode = ''", true, $dblink);
|
||||
install_query_or_fail("SET SESSION sql_mode = ''", $dblink, 'DB SQL 모드를 변경하지 못했습니다.', $install_table_prefixes);
|
||||
$mysql_set_mode = 'true';
|
||||
}
|
||||
unset($result);
|
||||
unset($row);
|
||||
?>
|
||||
|
||||
<?php $install_progress_started = true; ?>
|
||||
<div class="ins_inner">
|
||||
<h2><?php echo G5_VERSION ?> 설치가 시작되었습니다.</h2>
|
||||
|
||||
<ol>
|
||||
<?php
|
||||
$sql = "SHOW TABLES LIKE '{$table_prefix}config'";
|
||||
$is_install = sql_query($sql, false, $dblink)->num_rows > 0;
|
||||
$table_check_error = '';
|
||||
$is_install = install_table_exists($dblink, $table_prefix.'config', $table_check_error);
|
||||
if ($table_check_error) {
|
||||
install_fail_page('기존 테이블 존재 여부를 확인하지 못했습니다. DB 계정 권한을 확인해 주십시오.', $dblink, $install_table_prefixes);
|
||||
}
|
||||
|
||||
// 그누보드5 재설치에 체크하였거나 그누보드5가 설치되어 있지 않다면
|
||||
if ($g5_install || $is_install === false) {
|
||||
// 테이블 생성 ------------------------------------
|
||||
$file = implode('', file('./gnuboard5.sql'));
|
||||
eval("\$file = \"$file\";");
|
||||
$queries = install_load_sql_file('./gnuboard5.sql', 'g5_', $table_prefix);
|
||||
if ($queries === false) {
|
||||
install_fail_page('gnuboard5.sql 파일을 읽을 수 없습니다.', $dblink, $install_table_prefixes);
|
||||
}
|
||||
|
||||
$file = preg_replace('/^--.*$/m', '', $file);
|
||||
$file = preg_replace('/`g5_([^`]+`)/', '`'.$table_prefix.'$1', $file);
|
||||
$f = explode(';', $file);
|
||||
for ($i=0; $i<count($f); $i++) {
|
||||
if (trim($f[$i]) == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql = get_db_create_replace($f[$i]);
|
||||
sql_query($sql, true, $dblink);
|
||||
for ($i=0; $i<count($queries); $i++) {
|
||||
$sql = get_db_create_replace($queries[$i]);
|
||||
install_query_or_fail($sql, $dblink, '그누보드 기본 테이블 생성 중 오류가 발생했습니다.', $install_table_prefixes);
|
||||
}
|
||||
}
|
||||
|
||||
// 쇼핑몰 테이블 생성 -----------------------------
|
||||
if($g5_shop_install) {
|
||||
$file = implode('', file('./gnuboard5shop.sql'));
|
||||
$queries = install_load_sql_file('./gnuboard5shop.sql', 'g5_shop_', $g5_shop_prefix);
|
||||
if ($queries === false) {
|
||||
install_fail_page('gnuboard5shop.sql 파일을 읽을 수 없습니다.', $dblink, $install_table_prefixes);
|
||||
}
|
||||
|
||||
$file = preg_replace('/^--.*$/m', '', $file);
|
||||
$file = preg_replace('/`g5_shop_([^`]+`)/', '`'.$g5_shop_prefix.'$1', $file);
|
||||
$f = explode(';', $file);
|
||||
for ($i=0; $i<count($f); $i++) {
|
||||
if (trim($f[$i]) == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql = get_db_create_replace($f[$i]);
|
||||
sql_query($sql, true, $dblink);
|
||||
for ($i=0; $i<count($queries); $i++) {
|
||||
$sql = get_db_create_replace($queries[$i]);
|
||||
install_query_or_fail($sql, $dblink, '쇼핑몰 테이블 생성 중 오류가 발생했습니다.', $install_table_prefixes);
|
||||
}
|
||||
}
|
||||
// 테이블 생성 ------------------------------------
|
||||
@@ -233,14 +221,14 @@ if ($g5_install || $is_install === false) {
|
||||
cf_stipulation = '해당 홈페이지에 맞는 회원가입약관을 입력합니다.',
|
||||
cf_privacy = '해당 홈페이지에 맞는 개인정보처리방침을 입력합니다.'
|
||||
";
|
||||
sql_query($sql, true, $dblink);
|
||||
install_query_or_fail($sql, $dblink, '기본 환경설정을 저장하지 못했습니다.', $install_table_prefixes);
|
||||
|
||||
// 1:1문의 설정
|
||||
$sql = " insert into `{$table_prefix}qa_config`
|
||||
( qa_title, qa_category, qa_skin, qa_mobile_skin, qa_use_email, qa_req_email, qa_use_hp, qa_req_hp, qa_use_editor, qa_subject_len, qa_mobile_subject_len, qa_page_rows, qa_mobile_page_rows, qa_image_width, qa_upload_size, qa_insert_content )
|
||||
values
|
||||
( '1:1문의', '회원|포인트', 'basic', 'basic', '1', '0', '1', '0', '1', '60', '30', '15', '15', '600', '1048576', '' ) ";
|
||||
sql_query($sql, true, $dblink);
|
||||
install_query_or_fail($sql, $dblink, '1:1문의 설정을 저장하지 못했습니다.', $install_table_prefixes);
|
||||
|
||||
// 관리자 회원가입
|
||||
$sql = " insert into `{$table_prefix}member`
|
||||
@@ -257,15 +245,15 @@ if ($g5_install || $is_install === false) {
|
||||
mb_datetime = '".G5_TIME_YMDHIS."',
|
||||
mb_ip = '{$_SERVER['REMOTE_ADDR']}'
|
||||
";
|
||||
sql_query($sql, true, $dblink);
|
||||
install_query_or_fail($sql, $dblink, '관리자 회원 정보를 저장하지 못했습니다.', $install_table_prefixes);
|
||||
|
||||
// 내용관리 생성
|
||||
sql_query(" insert into `{$table_prefix}content` set co_id = 'company', co_html = '1', co_subject = '회사소개', co_content= '<p align=center><b>회사소개에 대한 내용을 입력하십시오.</b></p>', co_skin = 'basic', co_mobile_skin = 'basic' ", true, $dblink);
|
||||
sql_query(" insert into `{$table_prefix}content` set co_id = 'privacy', co_html = '1', co_subject = '개인정보 처리방침', co_content= '<p align=center><b>개인정보 처리방침에 대한 내용을 입력하십시오.</b></p>', co_skin = 'basic', co_mobile_skin = 'basic' ", true, $dblink);
|
||||
sql_query(" insert into `{$table_prefix}content` set co_id = 'provision', co_html = '1', co_subject = '서비스 이용약관', co_content= '<p align=center><b>서비스 이용약관에 대한 내용을 입력하십시오.</b></p>', co_skin = 'basic', co_mobile_skin = 'basic' ", true, $dblink);
|
||||
install_query_or_fail(" insert into `{$table_prefix}content` set co_id = 'company', co_html = '1', co_subject = '회사소개', co_content= '<p align=center><b>회사소개에 대한 내용을 입력하십시오.</b></p>', co_skin = 'basic', co_mobile_skin = 'basic' ", $dblink, '회사소개 기본 내용을 저장하지 못했습니다.', $install_table_prefixes);
|
||||
install_query_or_fail(" insert into `{$table_prefix}content` set co_id = 'privacy', co_html = '1', co_subject = '개인정보 처리방침', co_content= '<p align=center><b>개인정보 처리방침에 대한 내용을 입력하십시오.</b></p>', co_skin = 'basic', co_mobile_skin = 'basic' ", $dblink, '개인정보 처리방침 기본 내용을 저장하지 못했습니다.', $install_table_prefixes);
|
||||
install_query_or_fail(" insert into `{$table_prefix}content` set co_id = 'provision', co_html = '1', co_subject = '서비스 이용약관', co_content= '<p align=center><b>서비스 이용약관에 대한 내용을 입력하십시오.</b></p>', co_skin = 'basic', co_mobile_skin = 'basic' ", $dblink, '서비스 이용약관 기본 내용을 저장하지 못했습니다.', $install_table_prefixes);
|
||||
|
||||
// FAQ Master
|
||||
sql_query(" insert into `{$table_prefix}faq_master` set fm_id = '1', fm_subject = '자주하시는 질문' ", true, $dblink);
|
||||
install_query_or_fail(" insert into `{$table_prefix}faq_master` set fm_id = '1', fm_subject = '자주하시는 질문' ", $dblink, 'FAQ 기본 정보를 저장하지 못했습니다.', $install_table_prefixes);
|
||||
|
||||
// 그누보드, 영카트 통합으로 인하여 게시판그룹을 커뮤니티(community)로 생성 (NaviGator님,210624)
|
||||
// $tmp_gr_id = defined('G5_YOUNGCART_VER') ? 'shop' : 'community';
|
||||
@@ -274,7 +262,7 @@ if ($g5_install || $is_install === false) {
|
||||
$tmp_gr_subject = '커뮤니티';
|
||||
|
||||
// 게시판 그룹 생성
|
||||
sql_query(" insert into `{$table_prefix}group` set gr_id = '$tmp_gr_id', gr_subject = '$tmp_gr_subject' ", true, $dblink);
|
||||
install_query_or_fail(" insert into `{$table_prefix}group` set gr_id = '$tmp_gr_id', gr_subject = '$tmp_gr_subject' ", $dblink, '게시판 그룹을 생성하지 못했습니다.', $install_table_prefixes);
|
||||
|
||||
// 게시판 생성
|
||||
$tmp_bo_subject = array ("공지사항", "질문답변", "자유게시판", "갤러리");
|
||||
@@ -359,10 +347,14 @@ if ($g5_install || $is_install === false) {
|
||||
bo_use_search = '0',
|
||||
bo_order = '0'
|
||||
";
|
||||
sql_query($sql, true, $dblink);
|
||||
install_query_or_fail($sql, $dblink, '게시판 기본 설정을 저장하지 못했습니다.', $install_table_prefixes);
|
||||
|
||||
// 게시판 테이블 생성
|
||||
$file = file("../".G5_ADMIN_DIR."/sql_write.sql");
|
||||
$file = @file("../".G5_ADMIN_DIR."/sql_write.sql");
|
||||
if ($file === false) {
|
||||
install_fail_page(G5_ADMIN_DIR."/sql_write.sql 파일을 읽을 수 없습니다.", $dblink, $install_table_prefixes);
|
||||
}
|
||||
|
||||
$file = get_db_create_replace($file);
|
||||
$sql = implode("\n", $file);
|
||||
|
||||
@@ -372,7 +364,7 @@ if ($g5_install || $is_install === false) {
|
||||
$source = array("/__TABLE_NAME__/", "/;/");
|
||||
$target = array($create_table, "");
|
||||
$sql = preg_replace($source, $target, $sql);
|
||||
sql_query($sql, false, $dblink);
|
||||
install_query_or_fail($sql, $dblink, '게시판 글쓰기 테이블을 생성하지 못했습니다.', $install_table_prefixes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,7 +522,7 @@ if($g5_shop_install) {
|
||||
de_sms_cont4 = '{이름}님 입금 감사합니다.\n{입금액}원\n주문번호:\n{주문번호}\n{회사명}',
|
||||
de_sms_cont5 = '{이름}님 배송합니다.\n택배:{택배회사}\n운송장번호:\n{운송장번호}\n{회사명}'
|
||||
";
|
||||
sql_query($sql, true, $dblink);
|
||||
install_query_or_fail($sql, $dblink, '쇼핑몰 기본 설정을 저장하지 못했습니다.', $install_table_prefixes);
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -554,15 +546,17 @@ $dir_arr = array (
|
||||
);
|
||||
|
||||
for ($i=0; $i<count($dir_arr); $i++) {
|
||||
@mkdir($dir_arr[$i], G5_DIR_PERMISSION);
|
||||
@chmod($dir_arr[$i], G5_DIR_PERMISSION);
|
||||
if (!install_ensure_dir($dir_arr[$i])) {
|
||||
install_fail_page($dir_arr[$i]." 디렉토리를 생성하거나 쓸 수 없습니다.\ndata 디렉토리 권한을 확인해 주십시오.", $dblink, $install_table_prefixes);
|
||||
}
|
||||
}
|
||||
|
||||
// 게시판 디렉토리 생성 (작은별님,211206)
|
||||
for ($i=0; $i<count($tmp_bo_table); $i++) {
|
||||
$board_dir = $data_path.'/file/'.$tmp_bo_table[$i];
|
||||
@mkdir($board_dir, G5_DIR_PERMISSION);
|
||||
@chmod($board_dir, G5_DIR_PERMISSION);
|
||||
if (!install_ensure_dir($board_dir)) {
|
||||
install_fail_page($board_dir." 디렉토리를 생성하거나 쓸 수 없습니다.\ndata 디렉토리 권한을 확인해 주십시오.", $dblink, $install_table_prefixes);
|
||||
}
|
||||
}
|
||||
|
||||
if($g5_shop_install) {
|
||||
@@ -574,8 +568,9 @@ if($g5_shop_install) {
|
||||
);
|
||||
|
||||
for ($i=0; $i<count($dir_arr); $i++) {
|
||||
@mkdir($dir_arr[$i], G5_DIR_PERMISSION);
|
||||
@chmod($dir_arr[$i], G5_DIR_PERMISSION);
|
||||
if (!install_ensure_dir($dir_arr[$i])) {
|
||||
install_fail_page($dir_arr[$i]." 디렉토리를 생성하거나 쓸 수 없습니다.\ndata 디렉토리 권한을 확인해 주십시오.", $dblink, $install_table_prefixes);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -587,84 +582,92 @@ if($g5_shop_install) {
|
||||
|
||||
// DB 설정 파일 생성
|
||||
$file = '../'.G5_DATA_DIR.'/'.G5_DBCONFIG_FILE;
|
||||
$f = @fopen($file, 'a');
|
||||
$install_file_write_error = false;
|
||||
$f = @fopen($file, 'w');
|
||||
|
||||
fwrite($f, "<?php\n");
|
||||
fwrite($f, "if (!defined('_GNUBOARD_')) exit;\n");
|
||||
fwrite($f, "define('G5_MYSQL_HOST', '".addcslashes($mysql_host, "\\'")."');\n");
|
||||
fwrite($f, "define('G5_MYSQL_USER', '".addcslashes($mysql_user, "\\'")."');\n");
|
||||
fwrite($f, "define('G5_MYSQL_PASSWORD', '".addcslashes($mysql_pass, "\\'")."');\n");
|
||||
fwrite($f, "define('G5_MYSQL_DB', '".addcslashes($mysql_db, "\\'")."');\n");
|
||||
fwrite($f, "define('G5_MYSQL_SET_MODE', {$mysql_set_mode});\n\n");
|
||||
fwrite($f, "define('G5_TABLE_PREFIX', '{$table_prefix}');\n\n");
|
||||
fwrite($f, "define('G5_TOKEN_ENCRYPTION_KEY', '".get_random_token_string(16)."'); // 토큰 암호화에 사용할 키\n\n");
|
||||
fwrite($f, "\$g5['write_prefix'] = G5_TABLE_PREFIX.'write_'; // 게시판 테이블명 접두사\n\n");
|
||||
fwrite($f, "\$g5['auth_table'] = G5_TABLE_PREFIX.'auth'; // 관리권한 설정 테이블\n");
|
||||
fwrite($f, "\$g5['config_table'] = G5_TABLE_PREFIX.'config'; // 기본환경 설정 테이블\n");
|
||||
fwrite($f, "\$g5['group_table'] = G5_TABLE_PREFIX.'group'; // 게시판 그룹 테이블\n");
|
||||
fwrite($f, "\$g5['group_member_table'] = G5_TABLE_PREFIX.'group_member'; // 게시판 그룹+회원 테이블\n");
|
||||
fwrite($f, "\$g5['board_table'] = G5_TABLE_PREFIX.'board'; // 게시판 설정 테이블\n");
|
||||
fwrite($f, "\$g5['board_file_table'] = G5_TABLE_PREFIX.'board_file'; // 게시판 첨부파일 테이블\n");
|
||||
fwrite($f, "\$g5['board_good_table'] = G5_TABLE_PREFIX.'board_good'; // 게시물 추천,비추천 테이블\n");
|
||||
fwrite($f, "\$g5['board_new_table'] = G5_TABLE_PREFIX.'board_new'; // 게시판 새글 테이블\n");
|
||||
fwrite($f, "\$g5['login_table'] = G5_TABLE_PREFIX.'login'; // 로그인 테이블 (접속자수)\n");
|
||||
fwrite($f, "\$g5['mail_table'] = G5_TABLE_PREFIX.'mail'; // 회원메일 테이블\n");
|
||||
fwrite($f, "\$g5['member_table'] = G5_TABLE_PREFIX.'member'; // 회원 테이블\n");
|
||||
fwrite($f, "\$g5['member_auto_login_table'] = G5_TABLE_PREFIX.'member_auto_login'; // 자동 로그인 토큰 테이블\n");
|
||||
fwrite($f, "\$g5['memo_table'] = G5_TABLE_PREFIX.'memo'; // 메모 테이블\n");
|
||||
fwrite($f, "\$g5['poll_table'] = G5_TABLE_PREFIX.'poll'; // 투표 테이블\n");
|
||||
fwrite($f, "\$g5['poll_etc_table'] = G5_TABLE_PREFIX.'poll_etc'; // 투표 기타의견 테이블\n");
|
||||
fwrite($f, "\$g5['point_table'] = G5_TABLE_PREFIX.'point'; // 포인트 테이블\n");
|
||||
fwrite($f, "\$g5['popular_table'] = G5_TABLE_PREFIX.'popular'; // 인기검색어 테이블\n");
|
||||
fwrite($f, "\$g5['scrap_table'] = G5_TABLE_PREFIX.'scrap'; // 게시글 스크랩 테이블\n");
|
||||
fwrite($f, "\$g5['visit_table'] = G5_TABLE_PREFIX.'visit'; // 방문자 테이블\n");
|
||||
fwrite($f, "\$g5['visit_sum_table'] = G5_TABLE_PREFIX.'visit_sum'; // 방문자 합계 테이블\n");
|
||||
fwrite($f, "\$g5['uniqid_table'] = G5_TABLE_PREFIX.'uniqid'; // 유니크한 값을 만드는 테이블\n");
|
||||
fwrite($f, "\$g5['autosave_table'] = G5_TABLE_PREFIX.'autosave'; // 게시글 작성시 일정시간마다 글을 임시 저장하는 테이블\n");
|
||||
fwrite($f, "\$g5['cert_history_table'] = G5_TABLE_PREFIX.'cert_history'; // 인증내역 테이블\n");
|
||||
fwrite($f, "\$g5['qa_config_table'] = G5_TABLE_PREFIX.'qa_config'; // 1:1문의 설정테이블\n");
|
||||
fwrite($f, "\$g5['qa_content_table'] = G5_TABLE_PREFIX.'qa_content'; // 1:1문의 테이블\n");
|
||||
fwrite($f, "\$g5['content_table'] = G5_TABLE_PREFIX.'content'; // 내용(컨텐츠)정보 테이블\n");
|
||||
fwrite($f, "\$g5['faq_table'] = G5_TABLE_PREFIX.'faq'; // 자주하시는 질문 테이블\n");
|
||||
fwrite($f, "\$g5['faq_master_table'] = G5_TABLE_PREFIX.'faq_master'; // 자주하시는 질문 마스터 테이블\n");
|
||||
fwrite($f, "\$g5['new_win_table'] = G5_TABLE_PREFIX.'new_win'; // 새창 테이블\n");
|
||||
fwrite($f, "\$g5['menu_table'] = G5_TABLE_PREFIX.'menu'; // 메뉴관리 테이블\n");
|
||||
fwrite($f, "\$g5['social_profile_table'] = G5_TABLE_PREFIX.'member_social_profiles'; // 소셜 로그인 테이블\n");
|
||||
fwrite($f, "\$g5['member_cert_history_table'] = G5_TABLE_PREFIX.'member_cert_history'; // 본인인증 변경내역 테이블\n");
|
||||
|
||||
if($g5_shop_install) {
|
||||
fwrite($f, "\n");
|
||||
fwrite($f, "define('G5_USE_SHOP', true);\n\n");
|
||||
fwrite($f, "define('G5_SHOP_TABLE_PREFIX', '{$g5_shop_prefix}');\n\n");
|
||||
fwrite($f, "\$g5['g5_shop_default_table'] = G5_SHOP_TABLE_PREFIX.'default'; // 쇼핑몰설정 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_banner_table'] = G5_SHOP_TABLE_PREFIX.'banner'; // 배너 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_cart_table'] = G5_SHOP_TABLE_PREFIX.'cart'; // 장바구니 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_category_table'] = G5_SHOP_TABLE_PREFIX.'category'; // 상품분류 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_event_table'] = G5_SHOP_TABLE_PREFIX.'event'; // 이벤트 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_event_item_table'] = G5_SHOP_TABLE_PREFIX.'event_item'; // 상품, 이벤트 연결 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_item_table'] = G5_SHOP_TABLE_PREFIX.'item'; // 상품 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_item_option_table'] = G5_SHOP_TABLE_PREFIX.'item_option'; // 상품옵션 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_item_use_table'] = G5_SHOP_TABLE_PREFIX.'item_use'; // 상품 사용후기 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_item_qa_table'] = G5_SHOP_TABLE_PREFIX.'item_qa'; // 상품 질문답변 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_item_relation_table'] = G5_SHOP_TABLE_PREFIX.'item_relation'; // 관련 상품 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_order_table'] = G5_SHOP_TABLE_PREFIX.'order'; // 주문서 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_order_delete_table'] = G5_SHOP_TABLE_PREFIX.'order_delete'; // 주문서 삭제 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_wish_table'] = G5_SHOP_TABLE_PREFIX.'wish'; // 보관함(위시리스트) 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_coupon_table'] = G5_SHOP_TABLE_PREFIX.'coupon'; // 쿠폰정보 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_coupon_zone_table'] = G5_SHOP_TABLE_PREFIX.'coupon_zone'; // 쿠폰존 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_coupon_log_table'] = G5_SHOP_TABLE_PREFIX.'coupon_log'; // 쿠폰사용정보 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_sendcost_table'] = G5_SHOP_TABLE_PREFIX.'sendcost'; // 추가배송비 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_personalpay_table'] = G5_SHOP_TABLE_PREFIX.'personalpay'; // 개인결제 정보 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_order_address_table'] = G5_SHOP_TABLE_PREFIX.'order_address'; // 배송지이력 정보 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_item_stocksms_table'] = G5_SHOP_TABLE_PREFIX.'item_stocksms'; // 재입고SMS 알림 정보 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_post_log_table'] = G5_SHOP_TABLE_PREFIX.'order_post_log'; // 주문요청 로그 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_order_data_table'] = G5_SHOP_TABLE_PREFIX.'order_data'; // 모바일 결제정보 임시저장 테이블\n");
|
||||
fwrite($f, "\$g5['g5_shop_inicis_log_table'] = G5_SHOP_TABLE_PREFIX.'inicis_log'; // 이니시스 모바일 계좌이체 로그 테이블\n");
|
||||
if (!$f) {
|
||||
install_fail_page($file." 파일을 생성할 수 없습니다.\ndata 디렉토리 쓰기 권한을 확인해 주십시오.", $dblink, $install_table_prefixes);
|
||||
}
|
||||
|
||||
fwrite($f, "?>");
|
||||
install_file_write($f, "<?php\n");
|
||||
install_file_write($f, "if (!defined('_GNUBOARD_')) exit;\n");
|
||||
install_file_write($f, "define('G5_MYSQL_HOST', '".addcslashes($mysql_host, "\\'")."');\n");
|
||||
install_file_write($f, "define('G5_MYSQL_USER', '".addcslashes($mysql_user, "\\'")."');\n");
|
||||
install_file_write($f, "define('G5_MYSQL_PASSWORD', '".addcslashes($mysql_pass, "\\'")."');\n");
|
||||
install_file_write($f, "define('G5_MYSQL_DB', '".addcslashes($mysql_db, "\\'")."');\n");
|
||||
install_file_write($f, "define('G5_MYSQL_SET_MODE', {$mysql_set_mode});\n\n");
|
||||
install_file_write($f, "define('G5_TABLE_PREFIX', '{$table_prefix}');\n\n");
|
||||
install_file_write($f, "define('G5_TOKEN_ENCRYPTION_KEY', '".get_random_token_string(16)."'); // 토큰 암호화에 사용할 키\n\n");
|
||||
install_file_write($f, "\$g5['write_prefix'] = G5_TABLE_PREFIX.'write_'; // 게시판 테이블명 접두사\n\n");
|
||||
install_file_write($f, "\$g5['auth_table'] = G5_TABLE_PREFIX.'auth'; // 관리권한 설정 테이블\n");
|
||||
install_file_write($f, "\$g5['config_table'] = G5_TABLE_PREFIX.'config'; // 기본환경 설정 테이블\n");
|
||||
install_file_write($f, "\$g5['group_table'] = G5_TABLE_PREFIX.'group'; // 게시판 그룹 테이블\n");
|
||||
install_file_write($f, "\$g5['group_member_table'] = G5_TABLE_PREFIX.'group_member'; // 게시판 그룹+회원 테이블\n");
|
||||
install_file_write($f, "\$g5['board_table'] = G5_TABLE_PREFIX.'board'; // 게시판 설정 테이블\n");
|
||||
install_file_write($f, "\$g5['board_file_table'] = G5_TABLE_PREFIX.'board_file'; // 게시판 첨부파일 테이블\n");
|
||||
install_file_write($f, "\$g5['board_good_table'] = G5_TABLE_PREFIX.'board_good'; // 게시물 추천,비추천 테이블\n");
|
||||
install_file_write($f, "\$g5['board_new_table'] = G5_TABLE_PREFIX.'board_new'; // 게시판 새글 테이블\n");
|
||||
install_file_write($f, "\$g5['login_table'] = G5_TABLE_PREFIX.'login'; // 로그인 테이블 (접속자수)\n");
|
||||
install_file_write($f, "\$g5['mail_table'] = G5_TABLE_PREFIX.'mail'; // 회원메일 테이블\n");
|
||||
install_file_write($f, "\$g5['member_table'] = G5_TABLE_PREFIX.'member'; // 회원 테이블\n");
|
||||
install_file_write($f, "\$g5['member_auto_login_table'] = G5_TABLE_PREFIX.'member_auto_login'; // 자동 로그인 토큰 테이블\n");
|
||||
install_file_write($f, "\$g5['memo_table'] = G5_TABLE_PREFIX.'memo'; // 메모 테이블\n");
|
||||
install_file_write($f, "\$g5['poll_table'] = G5_TABLE_PREFIX.'poll'; // 투표 테이블\n");
|
||||
install_file_write($f, "\$g5['poll_etc_table'] = G5_TABLE_PREFIX.'poll_etc'; // 투표 기타의견 테이블\n");
|
||||
install_file_write($f, "\$g5['point_table'] = G5_TABLE_PREFIX.'point'; // 포인트 테이블\n");
|
||||
install_file_write($f, "\$g5['popular_table'] = G5_TABLE_PREFIX.'popular'; // 인기검색어 테이블\n");
|
||||
install_file_write($f, "\$g5['scrap_table'] = G5_TABLE_PREFIX.'scrap'; // 게시글 스크랩 테이블\n");
|
||||
install_file_write($f, "\$g5['visit_table'] = G5_TABLE_PREFIX.'visit'; // 방문자 테이블\n");
|
||||
install_file_write($f, "\$g5['visit_sum_table'] = G5_TABLE_PREFIX.'visit_sum'; // 방문자 합계 테이블\n");
|
||||
install_file_write($f, "\$g5['uniqid_table'] = G5_TABLE_PREFIX.'uniqid'; // 유니크한 값을 만드는 테이블\n");
|
||||
install_file_write($f, "\$g5['autosave_table'] = G5_TABLE_PREFIX.'autosave'; // 게시글 작성시 일정시간마다 글을 임시 저장하는 테이블\n");
|
||||
install_file_write($f, "\$g5['cert_history_table'] = G5_TABLE_PREFIX.'cert_history'; // 인증내역 테이블\n");
|
||||
install_file_write($f, "\$g5['qa_config_table'] = G5_TABLE_PREFIX.'qa_config'; // 1:1문의 설정테이블\n");
|
||||
install_file_write($f, "\$g5['qa_content_table'] = G5_TABLE_PREFIX.'qa_content'; // 1:1문의 테이블\n");
|
||||
install_file_write($f, "\$g5['content_table'] = G5_TABLE_PREFIX.'content'; // 내용(컨텐츠)정보 테이블\n");
|
||||
install_file_write($f, "\$g5['faq_table'] = G5_TABLE_PREFIX.'faq'; // 자주하시는 질문 테이블\n");
|
||||
install_file_write($f, "\$g5['faq_master_table'] = G5_TABLE_PREFIX.'faq_master'; // 자주하시는 질문 마스터 테이블\n");
|
||||
install_file_write($f, "\$g5['new_win_table'] = G5_TABLE_PREFIX.'new_win'; // 새창 테이블\n");
|
||||
install_file_write($f, "\$g5['menu_table'] = G5_TABLE_PREFIX.'menu'; // 메뉴관리 테이블\n");
|
||||
install_file_write($f, "\$g5['social_profile_table'] = G5_TABLE_PREFIX.'member_social_profiles'; // 소셜 로그인 테이블\n");
|
||||
install_file_write($f, "\$g5['member_cert_history_table'] = G5_TABLE_PREFIX.'member_cert_history'; // 본인인증 변경내역 테이블\n");
|
||||
|
||||
fclose($f);
|
||||
if($g5_shop_install) {
|
||||
install_file_write($f, "\n");
|
||||
install_file_write($f, "define('G5_USE_SHOP', true);\n\n");
|
||||
install_file_write($f, "define('G5_SHOP_TABLE_PREFIX', '{$g5_shop_prefix}');\n\n");
|
||||
install_file_write($f, "\$g5['g5_shop_default_table'] = G5_SHOP_TABLE_PREFIX.'default'; // 쇼핑몰설정 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_banner_table'] = G5_SHOP_TABLE_PREFIX.'banner'; // 배너 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_cart_table'] = G5_SHOP_TABLE_PREFIX.'cart'; // 장바구니 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_category_table'] = G5_SHOP_TABLE_PREFIX.'category'; // 상품분류 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_event_table'] = G5_SHOP_TABLE_PREFIX.'event'; // 이벤트 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_event_item_table'] = G5_SHOP_TABLE_PREFIX.'event_item'; // 상품, 이벤트 연결 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_item_table'] = G5_SHOP_TABLE_PREFIX.'item'; // 상품 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_item_option_table'] = G5_SHOP_TABLE_PREFIX.'item_option'; // 상품옵션 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_item_use_table'] = G5_SHOP_TABLE_PREFIX.'item_use'; // 상품 사용후기 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_item_qa_table'] = G5_SHOP_TABLE_PREFIX.'item_qa'; // 상품 질문답변 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_item_relation_table'] = G5_SHOP_TABLE_PREFIX.'item_relation'; // 관련 상품 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_order_table'] = G5_SHOP_TABLE_PREFIX.'order'; // 주문서 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_order_delete_table'] = G5_SHOP_TABLE_PREFIX.'order_delete'; // 주문서 삭제 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_wish_table'] = G5_SHOP_TABLE_PREFIX.'wish'; // 보관함(위시리스트) 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_coupon_table'] = G5_SHOP_TABLE_PREFIX.'coupon'; // 쿠폰정보 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_coupon_zone_table'] = G5_SHOP_TABLE_PREFIX.'coupon_zone'; // 쿠폰존 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_coupon_log_table'] = G5_SHOP_TABLE_PREFIX.'coupon_log'; // 쿠폰사용정보 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_sendcost_table'] = G5_SHOP_TABLE_PREFIX.'sendcost'; // 추가배송비 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_personalpay_table'] = G5_SHOP_TABLE_PREFIX.'personalpay'; // 개인결제 정보 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_order_address_table'] = G5_SHOP_TABLE_PREFIX.'order_address'; // 배송지이력 정보 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_item_stocksms_table'] = G5_SHOP_TABLE_PREFIX.'item_stocksms'; // 재입고SMS 알림 정보 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_post_log_table'] = G5_SHOP_TABLE_PREFIX.'order_post_log'; // 주문요청 로그 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_order_data_table'] = G5_SHOP_TABLE_PREFIX.'order_data'; // 모바일 결제정보 임시저장 테이블\n");
|
||||
install_file_write($f, "\$g5['g5_shop_inicis_log_table'] = G5_SHOP_TABLE_PREFIX.'inicis_log'; // 이니시스 모바일 계좌이체 로그 테이블\n");
|
||||
}
|
||||
|
||||
install_file_write($f, "?>");
|
||||
|
||||
$install_file_closed = @fclose($f);
|
||||
if ($install_file_write_error || !$install_file_closed) {
|
||||
install_fail_page($file." 파일에 DB 설정을 저장하지 못했습니다.\ndata 디렉토리 용량과 쓰기 권한을 확인해 주십시오.", $dblink, $install_table_prefixes);
|
||||
}
|
||||
@chmod($file, G5_FILE_PERMISSION);
|
||||
?>
|
||||
|
||||
@@ -672,7 +675,14 @@ fclose($f);
|
||||
|
||||
<?php
|
||||
// data 디렉토리 및 하위 디렉토리에서는 .htaccess .htpasswd .php .phtml .html .htm .inc .cgi .pl .phar 파일을 실행할수 없게함.
|
||||
$f = fopen($data_path.'/.htaccess', 'w');
|
||||
$htaccess_file = $data_path.'/.htaccess';
|
||||
$install_file_write_error = false;
|
||||
$f = @fopen($htaccess_file, 'w');
|
||||
|
||||
if (!$f) {
|
||||
install_fail_page($htaccess_file." 파일을 생성할 수 없습니다.\ndata 디렉토리 쓰기 권한을 확인해 주십시오.", $dblink, $install_table_prefixes);
|
||||
}
|
||||
|
||||
$str = <<<EOD
|
||||
<FilesMatch "\.(htaccess|htpasswd|[Pp][Hh][Pp]|[Pp][Hh][Tt]|[Ss]?[Pp]?[Hh][Tt][Mm][Ll]?|[Ii][Nn][Cc]|[Cc][Gg][Ii]|[Pp][Ll]|[Pp][Hh][Aa][Rr]|[Ss][Vv][Gg][Zz]?)">
|
||||
Order allow,deny
|
||||
@@ -680,14 +690,26 @@ Deny from all
|
||||
</FilesMatch>
|
||||
RedirectMatch 403 /session/.*
|
||||
EOD;
|
||||
fwrite($f, $str);
|
||||
fclose($f);
|
||||
install_file_write($f, $str);
|
||||
|
||||
$install_file_closed = @fclose($f);
|
||||
if ($install_file_write_error || !$install_file_closed) {
|
||||
install_fail_page($htaccess_file." 파일을 저장하지 못했습니다.\ndata 디렉토리 용량과 쓰기 권한을 확인해 주십시오.", $dblink, $install_table_prefixes);
|
||||
}
|
||||
|
||||
if($g5_shop_install) {
|
||||
@copy('./logo_img', $data_path.'/common/logo_img');
|
||||
@copy('./logo_img', $data_path.'/common/logo_img2');
|
||||
@copy('./mobile_logo_img', $data_path.'/common/mobile_logo_img');
|
||||
@copy('./mobile_logo_img', $data_path.'/common/mobile_logo_img2');
|
||||
$copy_files = array(
|
||||
array('./logo_img', $data_path.'/common/logo_img'),
|
||||
array('./logo_img', $data_path.'/common/logo_img2'),
|
||||
array('./mobile_logo_img', $data_path.'/common/mobile_logo_img'),
|
||||
array('./mobile_logo_img', $data_path.'/common/mobile_logo_img2')
|
||||
);
|
||||
|
||||
for ($i=0; $i<count($copy_files); $i++) {
|
||||
if (!@copy($copy_files[$i][0], $copy_files[$i][1])) {
|
||||
install_fail_page($copy_files[$i][1]." 파일을 복사하지 못했습니다.\ndata 디렉토리 권한을 확인해 주십시오.", $dblink, $install_table_prefixes);
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
?>
|
||||
|
||||
@@ -1,8 +1,74 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||
|
||||
if(!extension_loaded('gd') || !function_exists('gd_info')) {
|
||||
echo '<script>'.PHP_EOL;
|
||||
echo 'alert("'.G5_VERSION.'의 정상적인 사용을 위해서는 GD 라이브러리가 필요합니다.\nGD 라이브러리가 없을 경우 자동등록방지 문자와 썸네일 기능이 작동하지 않습니다.");'.PHP_EOL;
|
||||
echo '</script>'.PHP_EOL;
|
||||
}
|
||||
$install_library_required_missing = false;
|
||||
$install_library_checks = array(
|
||||
array(
|
||||
'name' => 'MySQL 확장',
|
||||
'required' => true,
|
||||
'ok' => (function_exists('mysqli_connect') && G5_MYSQLI_USE) || function_exists('mysql_connect'),
|
||||
'message' => 'MySQL DB 연결에 필요합니다.'
|
||||
),
|
||||
array(
|
||||
'name' => 'JSON',
|
||||
'required' => true,
|
||||
'ok' => function_exists('json_encode') && function_exists('json_decode'),
|
||||
'message' => '설치 전 DB 점검 응답 처리에 필요합니다.'
|
||||
),
|
||||
array(
|
||||
'name' => 'iconv 또는 mbstring',
|
||||
'required' => true,
|
||||
'ok' => function_exists('iconv') || function_exists('mb_convert_encoding'),
|
||||
'message' => '문자열 인코딩 처리에 필요합니다.'
|
||||
),
|
||||
array(
|
||||
'name' => 'GD',
|
||||
'required' => false,
|
||||
'ok' => extension_loaded('gd') && function_exists('gd_info'),
|
||||
'message' => '자동등록방지 문자와 썸네일 기능에 필요합니다.'
|
||||
),
|
||||
array(
|
||||
'name' => 'OpenSSL',
|
||||
'required' => false,
|
||||
'ok' => extension_loaded('openssl'),
|
||||
'message' => '암호화, 외부 연동, 보안 통신 기능 사용 시 권장됩니다.'
|
||||
),
|
||||
array(
|
||||
'name' => 'cURL',
|
||||
'required' => false,
|
||||
'ok' => function_exists('curl_init'),
|
||||
'message' => '외부 API, 결제, 소셜 연동 사용 시 권장됩니다.'
|
||||
),
|
||||
array(
|
||||
'name' => 'Fileinfo',
|
||||
'required' => false,
|
||||
'ok' => function_exists('finfo_open'),
|
||||
'message' => '업로드 파일의 MIME 타입 확인에 권장됩니다.'
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($install_library_checks as $check) {
|
||||
if ($check['required'] && !$check['ok']) {
|
||||
$install_library_required_missing = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="ins_inner">
|
||||
<h2>서버 환경 점검</h2>
|
||||
<ul>
|
||||
<?php for ($i=0; $i<count($install_library_checks); $i++) { ?>
|
||||
<li>
|
||||
<strong><?php echo $install_library_checks[$i]['ok'] ? '확인' : ($install_library_checks[$i]['required'] ? '필수 누락' : '권장 누락'); ?></strong>
|
||||
- <?php echo $install_library_checks[$i]['name']; ?>
|
||||
(<?php echo $install_library_checks[$i]['required'] ? '필수' : '권장'; ?>)
|
||||
: <?php echo $install_library_checks[$i]['message']; ?>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php if ($install_library_required_missing) { ?>
|
||||
<p>필수 서버 환경이 준비되지 않아 설치를 진행할 수 없습니다. 누락된 PHP 확장을 설치한 뒤 새로고침해 주십시오.</p>
|
||||
<?php } else { ?>
|
||||
<p>필수 서버 환경을 확인했습니다. 권장 항목은 설치 후 일부 기능 사용에 영향을 줄 수 있습니다.</p>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user