11.Nas_1


새창 작성 수정 목록 링크 Edit G카랜다 HDD HDD HDD 게시물 주소 복사


[ClassicASP] 모든 태그 제거 & 허용태그 외의 모든 html 태그 제거 (2012-04-18 수정)

♨ 카랜더 일정 :
  • 링크

  • 첨부

  • 컨텐츠 정보

    본문

    \r\n
    \r\n
    [ClassicASP] 모든 태그 제거 & 허용태그 외의 모든 html 태그 제거 (2012-04-18 수정)글자 확대 글자 축소
    \r\n
      2012-04-17 22:22 Hit.560 트랙백주소 게시글을 twitter로 보내기 게시글을 facebook으로 보내기 게시글을 Me2Day로 보내기 이 게시글을 요즘으로 보내기 게시글을 구글로 북마크 하기 게시글을 네이버로 북마크 하기
    \r\n
    \r\n
    \r\n
    \r\n
    <% Option Explicit %>
    \r\n

    <%
    \r\n
    \r\n
    ' =========================================================
    \r\n
    ' 패턴으로 치환할수 있는 eregi_replace()함수
    \r\n
    ' PHP에는 있으나 ASP에는 없기 때문
    \r\n
    ' =========================================================
    \r\n
    Function eregi_replace(pattern, replace, text)
    \r\n
     Dim eregObj
    \r\n
     
    \r\n
     Set eregObj = New RegExp
    \r\n
     
    \r\n
     eregObj.Pattern = pattern '패턴 설정
    \r\n
     eregObj.IgnoreCase = True '대소문자 구분 여부
    \r\n
     eregObj.Global = True '전체 문서에서 검색
    \r\n
     
    \r\n
     eregi_replace = eregObj.Replace(text, replace) 'Replace String
    \r\n
    End Function
    \r\n
     
    \r\n
     
    \r\n
    ' =========================================================
    \r\n
    ' 모든 태그제거
    \r\n
    ' 사용법 : strip_tags1(content)
    \r\n
    ' content = "....."
    \r\n
    ' strip_tags2(content)
    \r\n
    ' =========================================================
    \r\n
    Function strip_tags1(str)
    \r\n
      Dim content
    \r\n

      content = str  
    \r\n
      content = eregi_replace("<(/)?([a-zA-Z]*)(\\s[a-zA-Z]*=[^>]*)?(\\s)*(/)?>","",content)  ' all
    \r\n
      content = eregi_replace("<(no)?script[^>]*>.*?</(no)?script>","",content)  ' scripts
    \r\n
      content = eregi_replace("<style[^>]*>.*</style>", "", content)  ' style
    \r\n
      content = eregi_replace("<(\""[^\""]*\""|\'[^\']*\'|[^\'\"">])*>","",content)  ' TAGS
    \r\n
      content = eregi_replace("<\\w+\\s+[^<]*\\s*>","",content)  ' nTAGS
    \r\n
      content = eregi_replace("&[^;]+;","",content)  ' entity_refs
    \r\n
      content = eregi_replace("\\s\\s+","",content)  ' whitespace
    \r\n

      strip_tags1 = content
    \r\n
    End Function
    \r\n
     
    \r\n
     
    \r\n
    ' =========================================================
    \r\n
    ' 허용태그 외의 모든 태그제거
    \r\n
    ' 사용법 : strip_tags2(content, allowtags)
    \r\n
    ' content = "....."
    \r\n
    ' allowtags = "br,a,img,table,b,font,div,center,embed"  ' 허용 ※ 태그 붙여서 연속으로, 공백 오류발생
    \r\n
    ' strip_tags2(content, allowtags)
    \r\n
    ' =========================================================
    \r\n
    Function strip_tags2(str,allowtags)
    \r\n
      Dim content, tags
    \r\n
     
    \r\n
      content = str
    \r\n
      tags = replace(allowtags,",","|")
    \r\n
      content = eregi_replace("<(/?)(?!/|" & tags & ")([^<>]*)?>","<$1$2&gt",content)
    \r\n
      content = eregi_replace("(javascript|vbscript)+","$1//",content)
    \r\n
      content = eregi_replace("(.location|location.|onload=|.cookie|alert|window.open|onmouse|onkey|onclick|view-source)+","//",content) '//자바스크립트 실행방지
    \r\n
     
    \r\n
      strip_tags2 = content
    \r\n
    End Function
    \r\n
     
    \r\n
     
    \r\n
    '사용예
    \r\n
    Dim allowtags, content
    \r\n
    allowtags = "br,a,img,b,font,div,center,embed"  ' 허용 ※ 태그 붙여서 연속으로, 공백 오류발생
    \r\n
     
    \r\n
    content = "<font color=red>허용하지 않은 태그</font>가<br />잘 <b>보이나요?</b><br /><script></script>"
    \r\n
    content = content & "<table><div align=center>아주 유용할꺼에요~</div><body><html><xmp><pre>"
    \r\n
     
    \r\n
    response.write "strip_tags1 결과<br />"& strip_tags1(content) &"<br /><br />"
    \r\n
    response.write "strip_tags2 결과<br />"& strip_tags2(content, allowtags)
    \r\n
    %>
    \r\n

    결과


    <소스보기>
    \r\n
    strip_tags1 결과
    \r\n
    허용하지 않은 태그가잘 보이나요?아주 유용할꺼에요~
    \r\n
     
    \r\n
    strip_tags2 결과
    \r\n
    <font color=red>허용하지 않은 태그</font>가<br />잘 <b>보이나요?</b><br /><script&gt</script&gt<table&gt<div align=center>아주 유용할꺼에요~</div><body><html&gt<xmp&gt<pre&gt


    참고자료
    http://flashcafe.org/3717 
    http://dualist.tistory.com/115
    \r\n

    \n
    [이 게시물은 관리자님에 의해 2013-11-18 21:29:50 11.H_BBS에서 이동 됨]
    [ 추가 정보 ... 더보기) ]
    뷰PDF 1,2



    office view

    관련자료

    댓글목록

    등록된 댓글이 없습니다.

    목록

    새창 작성 수정 목록 링크 Edit G카랜다 HDD HDD HDD 게시물 주소 복사




    Total 1,677 / 83 Page
    [ Ubuntu 16.04에서 최대 절전 모드를 해제하려면 어떻게해야합니까? ]

    Ubuntu 16.04에서 최대 절전 모드를 해제하려면 어떻게해야합니까?askubuntu.comhttps://askubuntu.com/quest…

    [ 해결완료)HYPER Backup error 증상 응용프로그램 건너뜀 해결 / 응용프로그램을 건너뜀 백업에… ] 댓글 2

    해결완료)질문)hyper backup 응용프로그램 백업에러 실패함장비: 해놀사용중버전: DSM 6.2.3-25426 Update 2 최신 버전 …

    [ 입문자에게 추천하는 HTML, CSS 첫걸음 ]

    입문자에게 추천하는 HTML, CSS 첫걸음입문자에게 추천하는 HTML, CSS 첫걸음 | HEROPY■ ▶ ☞ 정보찾아 공유 드리며 출처는 링…

    [ 시놀로지 python3 beautifulsoup 설치 작업으로 epg xmltv.xml만들기 ] 댓글 1

    시놀로지 python3 beautifulsoup 설치 작업으로 epg xmltv.xml만들기시놀로지 beautifulsoup 설치 작업시놀로지 …

    [ 이미지 추가로 신규 생성 ]

    ■ ▶ ☞ 정보찾아 공유 드리며 출처는 링크 참조 바랍니다 ♠ . ☞ 본자료는 https://11q.kr 에 등록 된 자료 입니다♠.

    [ ● synology mail server 설치에 mailplus 설정 진행 공유기/보안/서버작업 설정 값 저… ]

    ●synology mail server 설치에 mailplus 설정 진행 공유기/보안/서버작업 설정 값 저장- 사용버전 : dsm623 진행 작…

    [ ● 시놀로지 dsm 7.0에서 그누보드 5.4.5.5 초기 그누보드 설치 gd 라이브러리 설정 ] 댓글 2

    ● 시놀로지 dsm 7.0에서그누보드 5.4.5.12 초기 그누보드 설치 gd 라이브러리 설정 그누보드 설치조건 : 다른 시스템에서 2번째 설치…

    [ ● VMRC 클라이언트와 Windows/Linux 가상 시스템 간에 콘텐츠 복사/붙여넣기 활성화(57122) ]

    ●VMRC 클라이언트와 Windows/Linux 가상 시스템 간에 콘텐츠 복사/붙여넣기 활성화(57122) 증상VMRC를 사용하여 가상 시스템에…

    [ ● 추천)Piwigo 11.5.0 버전 시놀로지서버에 Photo 사진관리 sw 설치 작업 ] 댓글 2

    ●Piwigo 11.5.0 버전 시놀로지서버에 Photo 사진관리 sw 설치 작업 1> 썸네일 작업이 필요 없다2> 파일 업로드 간편…

    [ ● 정보) esxi에 vib파일로 된 드라이버 설치방법. ]

    ●esxi에 vib파일로 된 드라이버 설치방법.파일이름이 driver.vib 라고 할 경우..1. web에서ESXi 접속2. 유지보수 모드로 변…

    [ ● img vmdk 마운트 수정하기 )헤놀로지 RedPill tinyCore 만능부트로더 for Native… ] 댓글 1

    ● img vmdk 마운트 수정하기 )헤놀로지 RedPill tinyCore 만능부트로더 for Native img 적용파일 수정하기헤놀로지 R…

    [ ● 시놀로지 알림 설정으로 이밴트 카톡으로 받기 지메일/카카오메일 설정하기 ]

    ● 시놀로지 알림 설정으로 이밴트 카톡으로 받기 (1) 이밴트에 지메일 설정 > 이메일 수신 테스트 설정입니다(2) 구글 이메일 2단계 인…

    [ ●●● dsm 7.1빌드작업 esxi 서버의 tinycore 에 myv.sh 적용하여 랜인식을 위한 수… ] 댓글 20

    ● dsm 7.1빌드작업 esxi 서버의 tinycore 에 myv.sh 적용하여 랜인식을 위한 수정작업 boot loader updated:\…

    [ ● android-studio-2021.2.1.14-windows.exe 설치작업 ]

    ●android-studio-2021.2.1.14-windows.exe 설치작업android-studio 검색 다운로드 exe 파일 다운로드 합…

    [ ● Amcrest 카메라를 시놀로지 NAS에 설정하는 방법 ]

    ●Amcrest카메라를시놀로지NAS에 설정하는 방법 정보출처:https://support.amcrest.com/hc/en-us/articles/…

    [ ● ubuntu 설치된 패키지 apt-clone 저장 백업 복원하기 ]

    ● ubuntu 설치된 패키지apt-clone 저장 백업 복원하기Apt-clone, Ubuntu에 설치된 패키지 복제https://github.…


    ♥간단_메모글♥


    최근글


    새댓글



    PHP 안에 HTML ☞ 홈페이지 화면갱신 시간은 ♨
    ▶ 2024-06-29 00:38:02

    오늘의 홈 현황


    • 현재 접속자♨ 531 명
    • 오늘 가입자※ 0 명
    • 어제 가입자※ 4 명
    • 주간 가입자※ 8 명
    • 오늘 방문자 611 명
    • 어제 방문자 2,007 명
    • 최대 방문자 13,042 명
    • 전체 방문자 4,401,773 명
    • 전체 게시물※ 8,663 개
    • 전체 댓글수※ 24,782 개
    • 전체 회원수 11,074 명

    QR코드


    ☞ QR코드 스캔은 kakao앱 자체 QR코드

    알림 0








    최신글↑