소스 파일 : /reform/reform_item.php (2020-11-21)     소스 설명 : (개선중) reform 항목 보여주기
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php // (2020.7.21, 차재복, Cha Jae Bok, http://www.ktword.co.kr) 

# 세션 설정
	// 세션 스타트 (매 웹페이지 마다 필요)
	session_start();

# db 접속
	include "../base_utils/db_conn.php";

# 전송 매개변수
	$id = $_REQUEST['id'];
		if ( isset($_REQUEST[id]) and !empty($id) and !is_numeric($id) or $id<0 ) exit; // 해킹방지 (수치>0)

	$id_list = $_REQUEST['id_list'];
		if (!empty($id_list) and !preg_match('/^\d[,\d]*\d$|^\d$/',$id_list)) exit ("해킹방어");	// 해킹방지 

	$ch = $_REQUEST['ch'];

	$str = $_REQUEST['str'];

# db 쿼리 실행 
	// 해당 id의 table 내용 표출
	if ($ch == 'table_show' or empty($ch)) {
		$query = "select * from reform where depth=1 and id={$id}";
		$result = mysqli_query($dbi,$query);
			if (mysqli_errno($dbi)) { echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
		while ($matched = mysqli_fetch_assoc($result)) {
			$output = $matched[translated];
		}
		echo $output;

	} else if ($ch == 'show' or empty($ch)) {
		$query = "select * from reform where id={$id} order by sub_seq";
		$result = mysqli_query($dbi,$query);
			if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
		$matched = mysqli_fetch_assoc($result);
		$output = str_replace('&','&amp;',$matched[merged]); // &nbsp; => &amp;nbsp;
		echo $output;

	// 해당 id의 table 내용 update
	} else if ($ch == 'edit' and isset($_REQUEST['str'])) {

		$clean_str = mysqli_real_escape_string($dbi, $str);
		$query = "update reform set merged='$clean_str',date=now() where id={$id}";
		$result = mysqli_query($dbi,$query);
			if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
//		if (mysqli_affected_rows($dbi) == 1) echo "1 row updated !!! <br>";

		include "file_transform_v2.php";
		
		$translated_str = string_transform($str, $dbi);
		$translated_str = mysqli_real_escape_string($dbi, $translated_str);
		$query = "update reform set translated='$translated_str' where id={$id}";
		$result = mysqli_query($dbi,$query);
			if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
//		if (mysqli_affected_rows($dbi) == 1) echo "1 row translated !!!";

		echo "<meta http-equiv='refresh' content='0; url=../reform/special.php?gr={$id}&ch=reform'>";

	} else if ($ch == 'tr_show') {
		$query = "select path2node from reform where id={$id}";
		$result = mysqli_query($dbi,$query);
			if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
		$matched = mysqli_fetch_assoc($result);

		$query = "select * from reform where parent in ({$matched[path2node]})";
		$result = mysqli_query($dbi,$query);
			if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
		while ($matched = mysqli_fetch_assoc($result)) {
			$arr[] = array('parent'=>$matched[parent],'title'=>$matched[title],'id'=>$matched[id]);
		} 
		echo json_encode($arr, JSON_UNESCAPED_UNICODE);

	// 매 id별 하위 ol 구축을 위한, 직하위 li 레코드들 쿼리
	} else if ($ch == 'ol') {
		$query = "select * from reform where parent={$id} order by sub_seq";
		$result = mysqli_query($dbi,$query);
			if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
		while ($matched = mysqli_fetch_assoc($result)) {
			$title = ( empty($matched[name_2nd]) ? $matched[name] : $matched[name_2nd] );
			$arr[$matched[parent]][] = 
			array('id'=>$matched[id], 'parent'=>$matched[parent],
					'title'=>$title, 'title_orig'=>$matched[name],
					'path2node'=>$matched[path2node], 'child'=>$matched[child],'yoyak'=>$matched[yoyak],
					'more_type'=>$matched[more_type], 'more_subtype'=>$matched[more_subtype],
					'more_ptr'=>$matched[more_ptr],
					'table'=>$matched[translated]);
		} 
		echo json_encode($arr, JSON_UNESCAPED_UNICODE);

	// 매 id별 하위 ol 구축을 위한, 직하위 li 레코드들 쿼리 (Ver.2)
	// reform 및 reform_more 조인
	} else if ($ch == 'ol_v2') {
		$query = "select a.id,a.parent,a.sub_seq,a.name,a.name_2nd,
						a.path2node,a.child,a.yoyak,
						b.more_type,b.more_subtype,b.more_ptr,b.dir,b.file,b.func,b.parm
						from reform a left join reform_more b on a.id=b.id 
						where a.parent={$id} order by a.sub_seq";
		$result = mysqli_query($dbi,$query);
			if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
		while ($matched = mysqli_fetch_assoc($result)) {
			$title = ( empty($matched[name_2nd]) ? $matched[name] : $matched[name_2nd] );
			$arr[$matched[parent]][$matched[sub_seq]] = 
				array('id'=>$matched[id], 'parent'=>$matched[parent], 'sub_seq'=>$matched[sub_seq],
					'title'=>$title, 'title_orig'=>$matched[name],
					'path2node'=>$matched[path2node], 'child'=>$matched[child],'yoyak'=>$matched[yoyak],
					'more_type'=>$matched[more_type], 'more_subtype'=>$matched[more_subtype],
					'more_ptr'=>$matched[more_ptr], 'dir'=>$matched[dir], 'file'=>$matched[file], 
					'func'=>$matched[func], 'parm'=>$matched[parm]
					 );
		} 
		echo json_encode($arr, JSON_UNESCAPED_UNICODE);

	// id list에 열거된 id 정보들을 돌려줌
	} else if ($ch == 'id_list') {
		$query = "select a.id,a.parent,a.name,a.name_2nd,
						a.path2node,a.child,a.yoyak,
						b.more_type,b.more_subtype,b.more_ptr,b.dir,b.file
						from reform a left join reform_more b on a.id=b.id 
						where a.parent in ($id_list) order by a.sub_seq";
		$result = mysqli_query($dbi,$query);
			if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
		while ($matched = mysqli_fetch_assoc($result)) {
			$title = ( empty($matched[name_2nd]) ? $matched[name] : $matched[name_2nd] );
			$arr[$matched[parent]][] = 
				array('id'=>$matched[id], 'parent'=>$matched[parent],
					'title'=>$title, 'title_orig'=>$matched[name],
					'path2node'=>$matched[path2node], 'child'=>$matched[child],'yoyak'=>$matched[yoyak],
					'more_type'=>$matched[more_type], 'more_subtype'=>$matched[more_subtype],
					'more_ptr'=>$matched[more_ptr], 'dir'=>$matched[dir], 'file'=>$matched[file]
					 );
		} 
		echo json_encode($arr, JSON_UNESCAPED_UNICODE);

	// 해당 id 관련 모든 하위 레코드들 쿼리
	} else if ($ch == 'all_ol') {
		$query = "select * from reform where id!={$id} and (concat(',',path2node,',') like '%,{$id},%') order by depth,sub_seq";
		$result = mysqli_query($dbi,$query);
			if (mysqli_errno($dbi)) {echo mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n";}
		while ($matched = mysqli_fetch_assoc($result)) {
			$title = ( empty($matched[name_2nd]) ? $matched[name] : $matched[name_2nd] );
			$arr[$matched[parent]][] = 
//			$arr[$matched[parent]][$matched[id]] = 
			array('id'=>$matched[id],'parent'=>$matched[parent],
					'title'=>$title,'title_orig'=>$matched[name],
					'path2node'=>$matched[path2node],'child'=>$matched[child],'yoyak'=>$matched[yoyak],
					'more_type'=>$matched[more_type],'more_subtype'=>$matched[more_subtype],
					'more_ptr'=>$matched[more_ptr]);
			}
		echo json_encode($arr, JSON_UNESCAPED_UNICODE);
	}

?>


Copyrightⓒ written by 차재복 (Cha Jae Bok)
"본 웹사이트 내 모든 저작물은 원출처를 밝히는 한 자유롭게 사용(상업화포함) 가능합니다"