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,675 / 52 Page
    [ nanorc를 사용하여 Nano 텍스트 편집기 구성 ] 댓글 1

    nanorc를 사용하여 Nano 텍스트 편집기 구성https://linuxhint.com/configure_nano_text_editor_nan…

    [ Coreelec 의 IPTV m3u 채널 시청을 위한 TVheadend 서버 설치 설정 값 저장 ]

    Coreelec 의 TVheadend 서버 설치 설정 값 저장설정값을 저장 보관 합니다Coreelec addon 에서 설정 조건1) Tvhead…

    [ tvheadnd epg그래버 모듈 상태 보임/안보임 설정 저장 ] 댓글 1

    tvheadnd epg그래버 모듈 상태 보임/안보임설정 할때마다 안되는 설정 조건을 아래와 같이 재설정 합니다superuse 설정 아이디 암호 …

    [ 성공)갤럭시 note8 에 debian 조건 tvheadend_4.3-1896~gce0907705-dirt… ] 댓글 9

    Continuity counter error 발생에 대한 구글링 하여 많은것을 조치 하였습니다http://11q.kr/g5s/bbs/board.…

    [ Coreelec 925에서 neflix video 재생문제 해결 및 1080p 재생 조건 ]

    Coreelec 925에서 neflix video 재생문제 해결및 1080p 재생 조건기설치된 246 버전은 실행 불가능합니다InputStrea…

    [ @펌자료)우분투에서 하드디스크 자동 마운트하기 ]

    심볼릭링크 가 시놀로지에서 간단 합니다마운트 폴더로 이동 cd /volume1/web/www 마운트 data 폴더 다른 이름으로 변경 / dat…

    [ 인증서 만료로 안전하지 않음으로 접속해주세요 ]

    인증서 만료로 안전하지 않음으로 접속해주세요는 저의 서버의Let’s Encrypt SSL 인증서 가 만료 되어 발생함니다11q.kr 사이트는 안…

    [ ● 헤놀로지 부트로더 grub.cfg 설정시 DiskIdxMap SataPortMap 설정값 구성 방법 ] 댓글 4

    ● 헤놀로지 부트로더grub.cfg 설정시DiskIdxMap SataPortMap 설정값 구성 방법1) 부트로더에ds3615 와 ds918p 사…

    [ ● ESXi 7.0 기동 시 가상 시스템 자동 시작 설정 방법 및 메뉴얼 pdf ]

    ●ESXi 7.0 기동 시 가상 시스템 자동 시작 설정 방법ESXi 7.0 기동 시 가상시스템 헤놀로지 자동 시작 설정 방법ESXi 서버를 한 …

    [ ● 시놀로지작업)docker를 사용하여 Synology NAS에 Nextcloud를 설치하기 위한 가이드 ] 댓글 8

    ● 시놀로지작업)docker를 사용하여 Synology NAS에 Nextcloud를 설치하기 위한 가이드작업)nextcloud 시놀로지에 설치 …

    [ ●USB연결 성공사용방법) ESxi 7.0 서버 적용 vm_windows11/해놀의 USB인식이 되지 않는다… ] 댓글 4

    ●USB연결 성공 사용방법) ESxi 7.0 서버 적용 vm_windows11 의 USB인식이 되지 않는다 > 자동으로 연결하기문제점 : …

    [ ★★★ Proxmox 정보 및 PVE 다운로드 하여 설치 테스트 준비 성공 ] 댓글 1

    ●Proxmox 정보 및PVE다운로드 하여 설치 테스트 준비 성공우리는 귀하의 서버 관리를 단순화하기 위해 강력하고 효율적인 오픈 소스 소프트웨…

    [ ● usb작업 빌드 )헤놀로지 RedPill tinyCore 만능부트로더 for Native img 적용 ] 댓글 10

    ● usb작업)헤놀로지 RedPill tinyCore 만능부트로더 for Native img 적용본 작업은 저의 안되는 구형 노트북 system…

    [ ★★★ UEFI 버전)tinycore-redpill-uefi.v0.4.5.img.gz 부팅UEFI 변경 작업… ] 댓글 4

    ● tinycore-redpill-uefi.v0.4.5.img.gz 부팅UEFI 변경 작업기 명령어 초기값 추가 마운트 작업 입니다. uefi로…

    [ ● docker 의 Synology/GitLab 설치작업 ]

    ● docker 의Synology/GitLab 설치작업- 도커이미지 검색작업후 설치 :synology/gitlab 검색 다운로드 다운 docke…

    [ ● LETSENCRYPT SSL 인증서 자동갱신 쉘스크립트 ]

    ●LETSENCRYPT SSL 인증서 자동갱신 쉘스크립트출처:https://ivps.tistory.com/629[iVPS 가상서버호스팅] htt…


    ♥간단_메모글♥


    최근글


    새댓글



    PHP 안에 HTML ☞ 홈페이지 화면갱신 시간은 ♨
    ▶ 2024-06-26 18:46:18

    오늘의 홈 현황


    • 현재 접속자♨ 723 명
    • 오늘 가입자※ 1 명
    • 어제 가입자※ 2 명
    • 주간 가입자※ 8 명
    • 오늘 방문자 2,139 명
    • 어제 방문자 2,051 명
    • 최대 방문자 13,042 명
    • 전체 방문자 4,396,746 명
    • 전체 게시물※ 8,656 개
    • 전체 댓글수※ 24,773 개
    • 전체 회원수 11,069 명

    QR코드


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

    알림 0








    최신글↑