File name: welboard2/answer.wel (3,946 bytes) Text file viewer v1.2
    1 : #!/bin/wel
    2 : 
    3 : /* file: answer.wel
    4 : 
    5 :    게시판 답변글 쓰기 프로그램 (author: 서광현)
    6 : 
    7 :    Copyright (c) 2001/03/25 by Wesoft
    8 :    All Rights Reserved.
    9 : */
   10 : 
   11 : send_cookie= "NO";
   12 : if(include("include/fileupload.sub")!=OK) return;
   13 : if(write_answer==0)
   14 :  {
   15 :     if(attfile!="") delete_uploadfile();
   16 :     MSG1= "답변글 작성 금지 상태";
   17 :     if(board_name=="") board_name= "이 " ~ prg_title;
   18 :     MSG2= "<font color=#0000c0>" ~ board_name ~ "</font>에서는 "
   19 :         ~ "답변글을 작성 할 수 없도록 환경설정이 되어있습니다!" ~ BACK_BUTTON;
   20 :     formdump(message_form);
   21 :     return disconnect();
   22 :  }
   23 : no= val(no);
   24 : if(no<1)
   25 :  {
   26 :     if(attfile!="") delete_uploadfile();
   27 :     MSG1= "자료번호 오류";
   28 :     MSG2= "자료 번호가 없거나 잘못되었습니다." ~ BACK_BUTTON;
   29 :     formdump(message_form);
   30 :     return disconnect();
   31 :  }
   32 : 
   33 : qstr= "select grpno,answer,subject,content,wemail from " ~ mytable
   34 :     ~ " where selno=" ~ no;
   35 : if( (rt=mysql_getrecord(qstr,"poster_")) < 1 )
   36 :  {
   37 :     if(attfile!="") delete_uploadfile();
   38 :     if(rt==0)
   39 :      {
   40 :         MSG1= "자료가 없습니다!";
   41 :         MSG2= no ~ "번의 게시물이 삭제되었거나 없습니다!" ~ BACK_BUTTON;
   42 :         formdump(message_form);
   43 :      }
   44 :     return disconnect();
   45 :  }
   46 : 
   47 : function too_many_answer(string msg)
   48 :  {
   49 :     if(attfile!="") delete_uploadfile();
   50 :     MSG1= "답변글 작성 오류";
   51 :     MSG2= msg ~ BACK_BUTTON;
   52 :     formdump(message_form);
   53 :     return disconnect();
   54 :  }
   55 : 
   56 : poster_answer_len= len(poster_answer);
   57 : if(poster_answer_len>=20)
   58 :  {
   59 :     msg= "답변에 대한 답변이 20단계를 초과하여 더 이상 추가할 수 없습니다!";
   60 :     return too_many_answer(msg);
   61 :  }
   62 : qstr= "select answer from " ~ mytable ~ " where grpno=" ~ poster_grpno
   63 :     ~ " and substring(answer,1," ~ poster_answer_len ~ ")='" ~ poster_answer
   64 :     ~ "' and length(answer)=" ~ poster_answer_len + 1
   65 :     ~ " order by answer desc limit 0,1";
   66 : if((rt=mysql_getrecord(qstr,"MAX_")) < 0)
   67 :  {
   68 :     if(attfile!="") delete_uploadfile();
   69 :     return;
   70 :  }
   71 : if(rt==0) new_answer= poster_answer ~ "1";
   72 :  else
   73 :   {
   74 :      ch= mid(MAX_answer, poster_answer_len+1, 1);
   75 :      if(ch>="Z")
   76 :       {
   77 :          msg= "게시물의 답변이 너무 많아서 더 이상 추가할 수 없습니다!";
   78 :          return too_many_answer(msg);
   79 :       }
   80 :      new_ch= chr(asc(ch) + 1);
   81 :      if(new_ch>"9" && new_ch<"A") new_ch= "A";
   82 :      new_answer= poster_answer ~ new_ch;
   83 :   }
   84 : 
   85 : if(writeflag<1)
   86 :  {
   87 :     if(attfile!="") delete_uploadfile();
   88 :     action= "answer.wel", answer_flag= "1";
   89 :     wname= ckname, wemail= ckemail;
   90 :     if(wname=="") focus= "wname";
   91 :      else if(wemail=="") focus= "wemail";
   92 :       else focus= "subject";
   93 :     subject= poster_subject;
   94 :     if(toupper(left(subject,3))!="RE:") subject= "Re: " ~ subject;
   95 :     fm= formdump(skin~"write.fom");
   96 :     if(fm==FORM_OPENERR) return err_form("write.fom");
   97 :     return disconnect();
   98 :  }
   99 : 
  100 : subject= strchange(left(lrtrim(subject),60,1), fch, rch);
  101 : content= strchange(content, fch, rch);
  102 : fileseq= val(new_attfile);
  103 : linecnt= strcount(content, "\n");
  104 : if(right(content,1)!="\n") ++linecnt;
  105 : postpass= encode(left(postpass, 12), encodekey(), "", decode_variable);
  106 : 
  107 : wdtime= date(1) ~ " " ~ left(time(1),5);
  108 : wip= getenv("REMOTE_ADDR");
  109 : whost= getenv("REMOTE_HOST");
  110 : wid= ckid;
  111 : wname= strchange(left(lrtrim(wname),20,1), fch, rch);
  112 : wemail= strchange(left(lrtrim(wemail),40,1), fch, rch);
  113 : 
  114 : qstr= "insert into "~mytable~" (grpno,answer,subject,content,attfile,fileseq,"
  115 :    ~ "readcnt,downcnt,linecnt,postpass,wdtime,wip,whost,wname,wemail) values ("
  116 :    ~ strform("{$poster_grpno},'{$new_answer}','{$subject}','{$content}',",
  117 :              "'{$attfile}',{$fileseq},0,0,{$linecnt},'{$postpass}',",
  118 :              "'{$wdtime}','{$wip}','{$whost}','{$wname}','{$wemail}')");
  119 : 
  120 : if(mysql_query(mysql, qstr)==MYSQL_ERR)
  121 :  {
  122 :     if(attfile!="") delete_uploadfile();
  123 :     return err_query();
  124 :  }
  125 : send_cookie(ckid, ckpass, wemail, wname);
  126 : if(mail_to_answer!=0) include("include/mailanswer.sub");
  127 : url= strform("board.wel?db={$db}&pg={$pg}&bp={$bp}&sk={$sk}&no={$no}&k={$k}&cn={$cn}&cs={$cs}&cc={$cc}");
  128 : replace_location(url);
  129 : return disconnect();
File name: welboard2/answer.wel (3,946 bytes) Wesoft Corp. ⓒ 2001 All rights reserved.