묻고답하기

초보라서 잘 모르겠습니다.

해킹의 우려가 있어서

php, html 등의 파일을 첨부 하지 못하게 할려면

어떻게 고쳐 줘야 되는지요?   모르니깐 답답하군요..........-.-;

한 수 가르쳐 주세요...

==========================================================


<?php
require "../inc/config.php3";

function error($reason) {
    echo " <script>
           window.alert('$reason')
           history.go(-1)
           </script>";
    exit;
}

if (!pub) {     error('어떤 게시판을 사용합니까? 게시판을 선택하세요'); }
if($email) {
    if (!ereg("([a-zA-Z0-9,_,-]{2,15})@([a-zA-Z0-9,_,-]{2,15}).([a-zA-Z0-9,_,-]{2,15})",$email,$regs))
    {error('E-Mail을 올바르게 기록하세요'); }
  }

if (!$subject) {     error('글 제목을 입력해 주세요'); }
if (!$comment) {error('글 내용을 입력해 주세요'); }
if($userfile_name) {
   if (file_exists("./files/$userfile_name")) {error('동일한 파일이 존재합니다.');}
}

if($action=="ans"||!$action) {
   if(!$depth){
        $dbresult = mysql_query("select num from board where title='pub' order by num desc",$dbconn);
//        $filenum = mysql_num_rows($dbresult1);
        mysql_data_seek($dbresult,0);
        $row=mysql_fetch_array($dbresult);
        $depth = $row[num]+1;  
        $main = "$depth";
     }else {$main = "0";}
   if($action=="ans"){
       $ques = "select email,name from board where title='pub' and num='$num'";
       $results = mysql_query($ques, $dbconn);
       $rows = mysql_fetch_row($results);
       if($rows[0]) {
         $text = "답변 등록됨n$rows[1] 님이 등록한 글에 대한 답이 등록되었습니다.n$home_url 을 방문하시어 글을 확인하세요";
         mail("$rows[0]","답변이 등록됨","$text","From: $admin_mail");
        }
     }

     if($userfile_name){
       $temp = $userfile_name;

                /**
                //2001.11.13 수정전 코드.
                copy($userfile, "./files/$temp");
        chmod("./files/$temp");
        unlink($userfile);
                **/

                //2001.11.13 수정,추가 ->
           $filepath = "./files/$temp";

                if(!copy($userfile, $filepath )){
                        echo "<script> alert("파일업로드가 실패하였습니다.");</script>";
                        unset( $userfile_name );
                }
           if (file_exists( $filepath )){
                        chmod("$filepath",0777);    // 파일권한 변경(사용자 읽기만 가능;보완땜시)
                }
                // <- 2001.11.13 추가.

       unlink($userfile);
       }

       $comment = htmlspecialchars($comment);
       $subject = htmlspecialchars($subject);
       $comment = nl2br(addslashes($comment));
           $comment = str_replace("'","''",$comment);
           $subject = str_replace("'","''",$subject);
       $dbinsert = mysql_query("insert into board(num,title,name,subject,email,depth,comment,rdate,view,main,userfile,passwd,ip) values('','pub','$name','$subject','$email','$depth','$comment',now(),'0','$main','$userfile_name','$passwd','$ip')",$dbconn);
}

if($action=="mod") {
       $comment = htmlspecialchars($comment);

       $subject = htmlspecialchars($subject);
                //2001.11.14 추가된 코드
           $crnl = Chr(13).Chr( 10 );
           $comment = str_replace( $crnl , "<br>", $comment);
           //<-2001.11.14 추가된 코드
           //수정전 코드
       //$comment = nl2br(addslashes($comment));

          
          $dbinsert = mysql_query("update board set title='pub',name='+ '+ '$name',subject='$subject',email='$email',comment='$comment',passwd='$passwd' where num='$num' ",$dbconn);
  }
        echo "<meta http-equiv='Refresh' content='0; URL=./index.php3?btitle=pub&page=$page&upload=$upload'>";
        exit;

        mysql_close($dbconn);
               
?>
<p> </p>
글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
제플™ 자바스크립트 난수에 대한 질문이예요..^^ [2] 2007.08.10
김성미 스킨에 웹정체 설정 워떻게.. [3] 2007.08.10
무돌이 파일의 경로에 대해서...  
정희천 mms:// 다운로드받기 [3] 2007.08.10
limey php관련 폼메일에서.. [1] 2007.08.10
구욱서 홈페이지 제작시! 위,아래,좌,우! 생기는 여백 없애는 법좀 알려주세요 [2] 2007.08.10
오픈소스 [re] 폰트 관련 질문.  
뜨레 폰트 관련 질문.  
정혜선 로그인이 안되는데요. [1] 2007.08.10
김지혁 자바 시계와 php구문 연결에 대한 질문입니당. [1] 2007.08.10
순수주의 제로보드의 회원가입시 생년월일 문제에대해서..  
김윤희 컴에 저장되어있는 이미지들의 연결프로그램이 삭제되었대요........?????? [2] 2007.08.10
보경&경임 포토샵 질문입니다.. 포샵 잘하시는분 도와주세요!! [3] 2007.08.10
송진혁 창내리기 소스를 구하고 싶어요  
Jizon Pain 웹호스팅 하기 조은 곳 추천좀... [1] 2007.08.10
쭈니 다시한번 질문드립니다. 해답이 아직 안나와서요!  
함태준 제발.. 좀 알려주시면 안될까요?  
바보 드림위버에서여 [2] 2007.08.10
ⓢky가조아^^* 페인트샵 고수분...점 가르쳐주세요...^^;;;  
가고일 제로카운터 php파일을 삭제하면 DB MySQL 기록도 다 삭제되나요? [1] 2007.08.10