001002003004005006007008009010011012013014015016017018019020021022023024025026027028029030031032033034035036037038039040041042043044045046047048049050051052053054055056057058059060061062063064065066067068069070071072073074075076077078079080081082083084085086087088089090091092093094095096097098099100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
<?php // (2020.12.19, 차재복, Cha Jae Bok, http://www.ktword.co.kr) # 세션 설정 // 세션 스타트 (매 웹페이지 마다 필요) session_start(); // 세션 변수에 따른 사용자 타입 설정 ('일반사용자' or '테스트편집자' or '정식편집자' or '종합관리자') $_SESSION['user_type'] = ( empty($_SESSION['user_name']) ? '일반사용자' : $_SESSION['user_name'] ); session_start(); // 세션 변수에 따른 사용자 타입 설정 ('일반사용자' or '테스트편집자' or '정식편집자' or '종합관리자') $_SESSION['user_type'] = ( empty($_SESSION['user_name']) ? '일반사용자' : $_SESSION['user_name'] ); # 편집 권한 확인 if ($_SESSION['user_type']!='종합관리자') exit; // ('일반사용자' or '테스트편집자' or '정식편집자' or '종합관리자') # db 접속 include "../base_utils/db_conn.php"; # 전송 입력 매개변수 $no = $_POST['no']; if ( isset($_REQUEST[no]) and !empty($no) and !is_numeric($no) or $no<0 ) exit; // 해킹방지 (수치>0) $id = $_REQUEST['id']; if ( isset($_REQUEST[id]) and !empty($id) and !is_numeric($id) or $id<0 ) exit; // 해킹방지 (수치>0) $msg = $_POST['msg']; // title $msg = trim($msg); $str = $_POST['text']; // content $str = trim($str); $ch = $_POST['ch']; $sub_ch = $_POST['sub_ch']; // 디버깅용 // echo 'ch='.$ch.', sub_ch='.$sub_ch.', id='.$id.', str='.$str; # 항목 이동 갱신 include "reform_move_update.php"; // 항목 이동 // id_move_updown(),id_first_last(),id_level_up(),id_level_down(),id_delete() 등 // id 노드 항목 이동 // id 노드 위 아래로 이동 if ( ($ch=='id_up' or $ch=='id_down') and is_numeric($id) ) id_move_updown($ch, $id, $dbi, 'reform'); // id 노드 맨 위로 이동 if ( ($ch=='id_first' or $ch=='id_last') and is_numeric($id) ) id_first_last($ch, $id, $dbi, 'reform'); // id 노드 레벨업 이동 if ( ($ch=='id_level_up') and is_numeric($id) ) id_level_up($ch, $id, $dbi, 'reform'); // id 노드 레벨다운 이동 if ( ($ch=='id_level_down') and is_numeric($id) ) id_level_down($ch, $id, $dbi, 'reform'); # 항목 생성 및 삭제 include "reform_gen_del_update.php"; // 항목 생성 및 삭제 // id 자식,직전,직후 노드 생성 if ( ($ch=='id_child') and is_numeric($id) and !empty($str) ) id_child ($id, $str, $dbi, $table_name='reform'); if ( ($ch=='id_prepend' || $ch=='id_append') and is_numeric($id) and !empty($str) ) id_prepend_append ($ch, $id, $str, $dbi, $table_name='reform'); // id 노드 삭제 if ( $ch=='id_delete' and is_numeric($id) ) id_delete($ch, $id, $dbi, 'reform'); # 타이틀,요약 갱신 // 타이틀 업데이트 if ( ($ch=='id_title_update') and is_numeric($id) and !empty($sub_ch)) id_title_update($ch, $sub_ch, $id, $str, $dbi, 'reform'); // 요약 업데이트 if ( ($ch=='id_yoyak_update' ) and is_numeric($id) and !empty($sub_ch)) id_yoyak_update($ch, $sub_ch, $id, $str, $dbi, 'reform'); # 메뉴얼 갱신 include "reform_man_update.php"; // 메뉴얼 업데이트 // id_move_updown(),id_first_last(),id_level_up(),id_level_down(),id_delete() 등 // 코드 업데이트 // 코드 항목 업데이트 if ($ch == 'code_update' and !empty($str) and !empty($msg) and is_numeric($no)) code_update($no, $str, $msg, $dbi, 'code'); // 코드 항목 신규 추가 if ( ($ch=='id_more_new_add' and $sub_ch=='1') and is_numeric($id) ) code_new_add($id,$dbi); // 메뉴얼 업데이트 // 메뉴얼 항목 업데이트 if ($ch == 'man_update' and !empty($str) and !empty($msg) and is_numeric($no)) manual_update($no, $str, $msg, $dbi, 'manual'); // 메뉴얼 항목 삭제 if ($ch == 'man_delete' and is_numeric($no) and is_numeric($id)) manual_delete($no, $id, $dbi); // 메뉴얼 항목 바로다음에 추가 if ($ch == 'man_insert' and is_numeric($no) and is_numeric($id) ) manual_insert($id, $no, $dbi); // 메뉴얼 항목 신규 추가 if ( ($ch == 'id_more_new_add' and $sub_ch=='2') and is_numeric($id) ) manual_new_add($id,$dbi); // 메뉴얼 항목 끝에 추가 if ( ($ch == 'man_update' ) and ($sub_ch=='add') and is_numeric($id) ) manual_add($id, $ch, $sub_ch, $msg, $str, $dbi, 'manual'); # title,yoyak 수정 # // 해당 id의 name(title) 업데이트 function id_title_update($ch, $sub_ch, $id, $str, $dbi, $table_name) { // 순수 타이틀명 교체 if ($sub_ch == '1') { // 링크화된 타이틀명은 빈칸으로 교체 $query = "update $table_name set name_2nd = '' where id={$id}"; $result = mysqli_query($dbi,$query); if (mysqli_errno($dbi)) { $err_msg .= mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n"; } // 순수 타이틀명 교체 $name_str = mysqli_real_escape_string($dbi,$str); $query = "update $table_name set name='{$name_str}',date=now() where id={$id}"; $result = mysqli_query($dbi,$query); if (mysqli_errno($dbi)) { $err_msg .= mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n"; } // 링크화된 타이틀명 교체 } else if ($sub_ch == '2') { include "file_transform_v2.php"; $translated_str = string_transform($str, $dbi); $translated_str = mysqli_real_escape_string($dbi, $translated_str); $query = "update $table_name set name_2nd = '{$translated_str}' where id={$id}"; $result = mysqli_query($dbi,$query); if (mysqli_errno($dbi)) { $err_msg .= mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n"; } } if (!empty($err_msg)){ $return = array('err_msg'=>$err_msg .' : 타이틀 업데이트 실패'); } else { if (mysqli_affected_rows($dbi) > 0){ $return = array('notice'=>'타이틀 업데이트 성공 !!!','title'=>$name_str); // 'path2node'=>$path2node,'next_parent'=>$parent,'sub_seq'=>$sub_seq,'nextParentChilds'=>$nextParentChilds); } else { $return = array('notice'=>'타이틀 업데이트 안함'); } } echo json_encode($return, JSON_UNESCAPED_UNICODE); } // 요약 업데이트 function id_yoyak_update($ch, $sub_ch, $id, $str, $dbi, $table_name) { if ($sub_ch == '2') { include "file_transform_v2.php"; $translated_str = string_transform($str, $dbi); } else { $translated_str = $str; } $translated_str = mysqli_real_escape_string($dbi, $translated_str); $query = "update $table_name set yoyak='{$str}', yoyak_2nd='{$translated_str}', date=now() where id={$id}"; $result = mysqli_query($dbi, $query); if (mysqli_errno($dbi)) { $err_msg .= mysqli_errno($dbi)." : ".mysqli_error($dbi)."\n"; } if (!empty($err_msg)){ $return = array('err_msg'=>$err_msg .' : 타이틀 요약 업데이트 실패'); } else { if (mysqli_affected_rows($dbi) > 0){ $return = array('notice'=>'타이틀 요약 업데이트 성공 !!!','yoyak'=>$str,'yoyak_2nd'=>$translated_str); } else { $return = array('notice'=>'타이틀 요약 업데이트 안함'); } } echo json_encode($return, JSON_UNESCAPED_UNICODE); } // cuurnet Li 정보 function currentLiInfo($id, $dbi) { $query = "select a.parent,a.id,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 from reform a left join reform_more b on a.id=b.id where a.id={$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] ); $data = 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] ); } return $data; } ?>