bbs_view.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <?php
  2. include $_SERVER['DOCUMENT_ROOT'].'/common/lib/comm.php';
  3. include $_SERVER['DOCUMENT_ROOT'].ADMIN_PATH.'/common/auth_chk.php';
  4. if($cd_board == "01"){$mp="50";}else if($cd_board == "02"){$mp="51";}else if($cd_board == "03"){$mp="52";}else{$mp="53";};
  5. if($cd_board<>"01" && $cd_board <> "03" && $cd_board <> "02" && $cd_board <> "04"){
  6. AlertRedirect("잘못된 요청입니다.",ADMIN_PATH."/index.php");
  7. }
  8. if($cd_seq =="" || $cd_seq ==null){
  9. AlertRedirect("잘못된 요청입니다.",ADMIN_PATH."/index.php");
  10. }
  11. /*조회수 */
  12. $hitsql="update board_master
  13. set
  14. no_hit= no_hit+1
  15. WHERE cd_seq =$cd_seq";
  16. $result = mysql_query($hitsql,$connect);
  17. $sql ="SELECT
  18. cd_seq , cd_board ,cd_user ,cd_userid , nm_title , nm_name, ds_top, ds_main, ds_kind
  19. ,no_hit, ds_open, nm_content, nm_file, nm_updir, nm_reply, dt_insert, ds_delind ,nm_etc1, nm_etc2, nm_etc3, nm_etc4, nm_etc5
  20. FROM board_master
  21. WHERE
  22. cd_board='$cd_board' AND cd_seq='$cd_seq' AND ds_delind='N'";
  23. $col=mysql_fetch_array(mysql_query($sql));
  24. if (!empty($col['cd_seq'])){ //일반회원
  25. $cd_seq = $col['cd_seq'];
  26. $cd_board = $col['cd_board'];
  27. $cd_user = $col['cd_user'];
  28. $cd_userid = $col['cd_userid'];
  29. $nm_title = $col['nm_title'];
  30. $no_hit = $col['no_hit'];
  31. $ds_open = $col['ds_open'];
  32. $nm_content = $col['nm_content'];
  33. $nm_file = $col['nm_file'];
  34. $nm_updir = $col['nm_updir'];
  35. $nm_reply = $col['nm_reply'];
  36. $dt_insert = $col['dt_insert'];
  37. $ds_delind = $col['ds_delind'];
  38. $ds_top = $col['ds_top'];
  39. $ds_main = $col['ds_main'];
  40. $ds_kind = $col['ds_kind'];
  41. $nm_name = $col['nm_name'];
  42. $nm_etc1 = $col['nm_etc1'];
  43. $nm_etc2 = $col['nm_etc2'];
  44. $nm_etc3 = $col['nm_etc3'];
  45. $nm_etc4 = $col['nm_etc4'];
  46. $nm_etc5 = $col['nm_etc5'];
  47. //if($_SESSION[cd_userid] != $cd_userid){
  48. // AlertBack("게시물을 수정할 권한이 없습니다.");
  49. //}
  50. $mode="Update";
  51. }else{
  52. AlertBack("게시물을 가져오지 못하였습니다.");
  53. }
  54. $PageNo = $PageNo;
  55. //이전글
  56. $presql ="SELECT
  57. cd_seq , cd_board ,cd_userid , nm_title ,
  58. no_hit, ds_open, nm_content, nm_file, nm_updir, dt_insert, ds_delind
  59. FROM board_master
  60. WHERE
  61. cd_board='$cd_board' AND ds_delind='N'
  62. AND cd_seq < (SELECT cd_seq FROM board_master WHERE cd_board='$cd_board' AND ds_delind='N' AND cd_seq = $cd_seq)
  63. ORDER BY cd_seq DESC LIMIT 1";
  64. $preCol=mysql_fetch_array(mysql_query($presql));
  65. //다음글
  66. $nextSql ="SELECT
  67. cd_seq , cd_board ,cd_userid , nm_title ,
  68. no_hit, ds_open, nm_content, nm_file, nm_updir, dt_insert, ds_delind
  69. FROM board_master
  70. WHERE
  71. cd_board='$cd_board' AND ds_delind='N'
  72. AND cd_seq > (SELECT cd_seq FROM board_master WHERE cd_board='$cd_board' AND ds_delind='N' AND cd_seq = $cd_seq)
  73. ORDER BY cd_seq DESC LIMIT 1";
  74. $nextCol=mysql_fetch_array(mysql_query($nextSql));
  75. ?>
  76. <? include("../inc/inc_top.php") ?>
  77. <? include("../inc/inc_header.php") ?>
  78. <script type="text/javascript" src="/common/smarteditor/js/HuskyEZCreator.js" charset="utf-8"></script>
  79. <section id="contents">
  80. <h2>커뮤니티</h2>
  81. <h3><em>▶</em> 1:1문의</h3>
  82. <form id="frmProc" name="frmProc" method="post">
  83. <div class="tbl_wrap">
  84. <table class="tbl_list2">
  85. <colgroup>
  86. <col width="7%">
  87. <col width="32%">
  88. <col width="*">
  89. </colgroup>
  90. <tr>
  91. <th>제목</th>
  92. <td><?=$nm_title?>&nbsp;[등록일:<?=$dt_insert?> &nbsp;조회수:<?=$no_hit?>]</td>
  93. </tr>
  94. <?
  95. if($cd_board == "02"){
  96. ?>
  97. <tr>
  98. <th>작성자</th>
  99. <td><?=$nm_name?></td>
  100. </tr>
  101. <?
  102. }
  103. ?>
  104. <?
  105. if($cd_board == "04"){
  106. ?>
  107. <tr>
  108. <th>문의유형</th>
  109. <td><?=$nm_etc1?></td>
  110. </tr>
  111. <tr>
  112. <th>이름</th>
  113. <td><?=$nm_name?></td>
  114. </tr>
  115. <tr>
  116. <th>연락처</th>
  117. <td><?=$nm_etc2?></td>
  118. </tr>
  119. <tr>
  120. <th>이메일</th>
  121. <td><?=$nm_etc3?></td>
  122. </tr>
  123. <?
  124. }
  125. ?>
  126. <tr>
  127. <th>내용</th>
  128. <td class="text_height pd"><?=nl2br($nm_content)?></td>
  129. </tr>
  130. <?
  131. if($cd_board == "01" || $cd_board == "04"){
  132. ?>
  133. <tr>
  134. <th>파일</th>
  135. <td><? if($nm_file!=""){?><a href="/common/lib/download.php?nm_file=<?=urlencode($nm_file)?>&type=board&cd_board=<?=$cd_board?>"><?=$nm_file?></a><?}else{?>첨부파일없음<?}?></td>
  136. </tr>
  137. <?
  138. }
  139. ?>
  140. </table>
  141. </div>
  142. <?
  143. if($_SESSION['admin_cd_userid'] && $cd_board == "02"){
  144. ?>
  145. <h3><em>▶</em> 답변하기</h3>
  146. <div class="tbl_wrap">
  147. <table class="tbl_list2">
  148. <colgroup>
  149. <col width="7%">
  150. <col width="32%">
  151. <col width="*">
  152. </colgroup>
  153. <!--tr>
  154. <th>제목</th>
  155. <td><input type="text" class="inp_txt" style="width:90%;"></td>
  156. </tr-->
  157. <tr>
  158. <th>작성자</th>
  159. <td>관리자</td>
  160. </tr>
  161. <tr>
  162. <th>내용</th>
  163. <td class="pd"><textarea cols="70" rows="10" style="height:230px;" name="nm_reply" id="nm_reply"><?=$nm_reply?></textarea></td>
  164. </tr>
  165. </table>
  166. </div>
  167. <?
  168. }
  169. ?>
  170. <div class="btn_right">
  171. <?
  172. if($_SESSION['admin_cd_userid']){
  173. ?>
  174. <a href="#" class="rnd_btn ty2 gray" onclick="fnList('<?=$cd_board?>');return false;">취소</a>
  175. <?
  176. if($cd_board == "02"){
  177. ?>
  178. <a href="#" class="rnd_btn ty2 black" id="btn_write">답변</a>
  179. <?
  180. }else if($cd_board == "04"){
  181. ?>
  182. <?
  183. }else{
  184. ?>
  185. <a href="#" class="rnd_btn ty2 black" id="btn_write" onclick="fnProc('Update');return false;">수정</a>
  186. <?
  187. }
  188. ?>
  189. <a href="#" class="rnd_btn ty2 black" id="btn_write" onclick="fnProc('Delete');return false;">삭제</a>
  190. <?
  191. }
  192. ?>
  193. </div>
  194. <input type="hidden" name="mode" id="mode" value="Update"/>
  195. <input type="hidden" name="cd_board" id="cd_board" value="<?=$cd_board?>"/>
  196. <input type="hidden" name="cd_userid" id="cd_userid" value="<?=$cd_userid?>"/>
  197. <input type="hidden" name="cd_seq" id="cd_seq" value="<?=$cd_seq?>"/>
  198. <input type="hidden" name="PageNo" id="PageNo" value="<?=$PageNo?>"/>
  199. </form>
  200. <?
  201. if($_SESSION['admin_cd_userid'] && $cd_board == "02"){
  202. ?>
  203. <script language="javascript" type="text/javascript">
  204. $(document).ready(function() {
  205. $("#btn_write").bind("click",function(){
  206. oEditors.getById["nm_reply"].exec("UPDATE_CONTENTS_FIELD", []);
  207. var fieldlist = [["nm_reply","답변"]];
  208. if (!fnCheckForm(fieldlist)){
  209. return false;
  210. }else{
  211. var c = confirm("처리하시겠습니까?");
  212. if(c){
  213. $("#frmProc").attr("action","./board_proc.php");
  214. $("#mode").val("ReplyInquiry");
  215. $("#frmProc").submit();
  216. }else{
  217. return false;
  218. }
  219. }
  220. });
  221. });
  222. </script>
  223. <script type="text/javascript">
  224. var oEditors = [];
  225. nhn.husky.EZCreator.createInIFrame({
  226. oAppRef: oEditors,
  227. elPlaceHolder: "nm_reply",
  228. sSkinURI: "/common/smarteditor/SmartEditor2Skin.html",
  229. htParams : {
  230. bUseToolbar : true,
  231. bUseVerticalResizer : true,
  232. bUseModeChanger : true,
  233. fOnBeforeUnload : function(){}
  234. }, //boolean
  235. fOnAppLoad : function(){},
  236. fCreator: "createSEditor2"
  237. });
  238. function pasteHTML(fcode,objKey){
  239. var sHTML = '<span style="color:#FF0000;"><img src="'+fcode+'"></span>';
  240. oEditors.getById[objKey].exec("PASTE_HTML", [sHTML]);
  241. }
  242. function delHTML(source){
  243. oEditors.getById[source].exec("SET_CONTENTS", [""]);
  244. }
  245. function copyHTML(source,dest) {
  246. var sHTML = getHTML(source);
  247. oEditors.getById[dest].exec("PASTE_HTML", [sHTML]);
  248. }
  249. function getHTML(source){
  250. return oEditors.getById[source].getIR();
  251. }
  252. </script>
  253. <?
  254. }
  255. ?>
  256. <script language="javascript" type="text/javascript">
  257. function fnList(param){
  258. location.replace("./bbs_list.php?cd_board="+param);
  259. }
  260. function fnProc(param){
  261. if(param=="Update"){
  262. $("#frmProc").attr("action","./bbs_write.php");
  263. $("#mode").val("Update");
  264. $("#frmProc").submit();
  265. }
  266. else if(param=="Reply"){
  267. $("#frmProc").attr("action","./bbs_write.php");
  268. $("#mode").val("Reply");
  269. $("#frmProc").submit();
  270. }
  271. else{
  272. var custom_opts = {
  273. title : '',
  274. btn_close_show : false,
  275. }
  276. custom_opts.title = '선택하신 글을 정말로 삭제하시겠습니까?';
  277. custom_modal_confirm(custom_opts, function(confirm) {
  278. if(confirm) {
  279. $("#frmProc").attr("action","./board_proc.php");
  280. $("#mode").val("Delete");
  281. var data = $("#frmProc").serialize();
  282. $.ajax({
  283. url : 'board_proc.php',
  284. type: 'POST',
  285. dataType : 'json',
  286. data: data,
  287. success: function(res) {
  288. custom_modal_confirm_close();
  289. $("#btn_write").show();
  290. //세션 종료시 로그인 페이지로 이동
  291. if(res.CODE != "0000") {
  292. custom_opts.title = res.MSG;
  293. if(res.CODE == "4444") {
  294. window.location.href = res.DATAS.URL;
  295. }
  296. custom_modal_alert(custom_opts);
  297. return false;
  298. }
  299. custom_opts.title = '처리되었습니다.';
  300. custom_opts.event_esc_key = false;
  301. custom_modal_alert(custom_opts, function() {
  302. link("bbs_list.php?cd_board=<?=$cd_board?>");
  303. });
  304. },
  305. error:function(request,status,error){
  306. $("#btn_write").show();
  307. custom_modal_confirm_close();
  308. alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
  309. }
  310. });
  311. }
  312. });
  313. // var c=confirm("선택하신 글을 정말로 삭제하시겠습니까?");
  314. // if(c){
  315. // $("#frmProc").submit();
  316. // }
  317. }
  318. }
  319. $("#content_view_area img").each(function() {
  320. var imgObj = new Image();
  321. var content_width = $("#content_view_area").width();
  322. imgObj.src = $(this).attr("src");
  323. if(imgObj.width > content_width) {
  324. $(this).width(content_width);
  325. }
  326. });
  327. </script>
  328. <? include("../inc/inc_footer.php") ?>
  329. <? include("../inc/inc_bottom.php") ?>