<?php
$disable_tags = "table|td|tr|tbody"; //예제 금지 태그입니다
$tags = explode("|", $disabled_tags);
for($i=0; $i < sizeof($tags); $i++) {
$ntags[] = "@<".$tags[$i]."[^>]*?>@si";
$ntags[] = "@</".$tags[$i].">@si";
}
$str = preg_replace($ntags,"", $str);
?>
정규식에는 문외한이라
걍 아는 php 지식으로 무식? 하게 만들어보았습니다.
만약 게시물이
"<table width=900 align=right>
<td width=100 bgcolor=#ffffff>
게시물 게시물 게시물......
ㄹㅇㄹㅇㄴㅁ러ㅏㅇ널찬ㅇ
</td><td width=1200>dfdfkdsfajdskfds
</td>
";
인 경우
"게시물 게시물 게시물...... ㄹㅇㄹㅇㄴㅁ러ㅏㅇ널찬ㅇdfdfkdsfajdskfds"
이렇게 금지태그 및 관련 attributes를 모두 없애줍니다
울나라 네티즌들은 나쁜 버릇이 하나 있지요?
그건 바로 남이 공들여 등록한 게시물을 걍 긁어다가
다른 사이트에 그대로 붙혀넣기 한다는겁니다.
물론 사이트관리자 입장에선 이러한 행동이 그다지 맘에 들지 않지요
혹여 붙혀넣기 도중 <table>이 끊긴다던지 하면 그 페이지에서는 전체 레이아웃이 영향을 받으니 ..그래서 아예 태그를 막는 분들도 계실테고..
P.S
정규식으로 고수님들이 다시 만들어 주심 감사하겠습니다
참 이건 제가 에디터로 작성한 HTML게시물을 보여줄때 쓰는건데요
다른 사이트에서 복사한 게시물에 달려오는 쓸데없는 태그 및 속성들
없애주는 함수입니다
<?php
function format_rte($str) {
$search = array('@<script[^>]*?>.*?</script>@si', //<script>태그없애기
'@<style[^>]*?>.*?</style>@siU', //<style>태그 없애기
'@onload=(.*?)@si', //<img 태그내에 삽입된 불필요한 속성 없애기
'@onmouseover=(.*?)@si',
'@onclick=(.*?)@si',
'@onmousedown=(.*?)@si',
'@onmouseout=(.*?)@si'
);
$str = preg_replace($search,'', $str);
$str = eregi_replace("<IMG","<img border=\"0\" onLoad=\"imgFix(this)\" onClick=\"imgChkClick(this)\" onError=\"imgError(this)\"", $str);
return $str;
}
?>
//이미지 관련 자바스크립트
<script language="javascript">
//이미지 로딩에러시 이미지object 자체 안보이게 하기
function imgError(obj) {
obj.style.display='none';
}
//이미지 폭이 특정 값 이상일때 폭 조정
function imgFix(obj) {
var maxW = 600; //조절한 특정 이미지 폭 값
var img = document.createElement("img");
img.src = obj.src;
if(img.width > maxW) {
obj.style.width = maxW;
obj.style.height = img.height * (maxW/img.width);
obj.style.cursor = 'url(images/magnify.cur),pointer';
}
}
function imgChkClick(obj) {
var maxW = 600;
var img = document.createElement("img");
img.src = obj.src;
if(img.width > maxW) {
picview(img.src,img.width,img.height);
}
}
//이미지 새 창에서 보기
function picview(src,w,h) {
var iw = screen.width - 16;
var ih = screen.height - 68;
var s = 0;
var scroll = '';
if(w > iw) { w = iw; s += 1; }
if(h > ih) {
h = ih; s += 1;
if(w < iw) w += 20;
}
if(s > 0 ) { scroll = ",scrollbars=1"; }
var opt_mo = "top=5,left=5,width="+w+",status=no,height="+h+",resizable=1"+scroll;
NFW = window.open("","newWin",opt_mo);
NFW.focus();
var string = "<html>" +
"<head><title>Photo</title></head>" +
"<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>" +
"<a href='javascript:window.close()'><img src='" + src + "' border=0></a>" +
"</body></html>";
NFW.document.open();
NFW.document.write(string);
NFW.document.close();
}
</script>
$disable_tags = "table|td|tr|tbody"; //예제 금지 태그입니다
$tags = explode("|", $disabled_tags);
for($i=0; $i < sizeof($tags); $i++) {
$ntags[] = "@<".$tags[$i]."[^>]*?>@si";
$ntags[] = "@</".$tags[$i].">@si";
}
$str = preg_replace($ntags,"", $str);
?>
정규식에는 문외한이라
걍 아는 php 지식으로 무식? 하게 만들어보았습니다.
만약 게시물이
"<table width=900 align=right>
<td width=100 bgcolor=#ffffff>
게시물 게시물 게시물......
ㄹㅇㄹㅇㄴㅁ러ㅏㅇ널찬ㅇ
</td><td width=1200>dfdfkdsfajdskfds
</td>
";
인 경우
"게시물 게시물 게시물...... ㄹㅇㄹㅇㄴㅁ러ㅏㅇ널찬ㅇdfdfkdsfajdskfds"
이렇게 금지태그 및 관련 attributes를 모두 없애줍니다
울나라 네티즌들은 나쁜 버릇이 하나 있지요?
그건 바로 남이 공들여 등록한 게시물을 걍 긁어다가
다른 사이트에 그대로 붙혀넣기 한다는겁니다.
물론 사이트관리자 입장에선 이러한 행동이 그다지 맘에 들지 않지요
혹여 붙혀넣기 도중 <table>이 끊긴다던지 하면 그 페이지에서는 전체 레이아웃이 영향을 받으니 ..그래서 아예 태그를 막는 분들도 계실테고..
P.S
정규식으로 고수님들이 다시 만들어 주심 감사하겠습니다
참 이건 제가 에디터로 작성한 HTML게시물을 보여줄때 쓰는건데요
다른 사이트에서 복사한 게시물에 달려오는 쓸데없는 태그 및 속성들
없애주는 함수입니다
<?php
function format_rte($str) {
$search = array('@<script[^>]*?>.*?</script>@si', //<script>태그없애기
'@<style[^>]*?>.*?</style>@siU', //<style>태그 없애기
'@onload=(.*?)@si', //<img 태그내에 삽입된 불필요한 속성 없애기
'@onmouseover=(.*?)@si',
'@onclick=(.*?)@si',
'@onmousedown=(.*?)@si',
'@onmouseout=(.*?)@si'
);
$str = preg_replace($search,'', $str);
$str = eregi_replace("<IMG","<img border=\"0\" onLoad=\"imgFix(this)\" onClick=\"imgChkClick(this)\" onError=\"imgError(this)\"", $str);
return $str;
}
?>
//이미지 관련 자바스크립트
<script language="javascript">
//이미지 로딩에러시 이미지object 자체 안보이게 하기
function imgError(obj) {
obj.style.display='none';
}
//이미지 폭이 특정 값 이상일때 폭 조정
function imgFix(obj) {
var maxW = 600; //조절한 특정 이미지 폭 값
var img = document.createElement("img");
img.src = obj.src;
if(img.width > maxW) {
obj.style.width = maxW;
obj.style.height = img.height * (maxW/img.width);
obj.style.cursor = 'url(images/magnify.cur),pointer';
}
}
function imgChkClick(obj) {
var maxW = 600;
var img = document.createElement("img");
img.src = obj.src;
if(img.width > maxW) {
picview(img.src,img.width,img.height);
}
}
//이미지 새 창에서 보기
function picview(src,w,h) {
var iw = screen.width - 16;
var ih = screen.height - 68;
var s = 0;
var scroll = '';
if(w > iw) { w = iw; s += 1; }
if(h > ih) {
h = ih; s += 1;
if(w < iw) w += 20;
}
if(s > 0 ) { scroll = ",scrollbars=1"; }
var opt_mo = "top=5,left=5,width="+w+",status=no,height="+h+",resizable=1"+scroll;
NFW = window.open("","newWin",opt_mo);
NFW.focus();
var string = "<html>" +
"<head><title>Photo</title></head>" +
"<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>" +
"<a href='javascript:window.close()'><img src='" + src + "' border=0></a>" +
"</body></html>";
NFW.document.open();
NFW.document.write(string);
NFW.document.close();
}
</script>
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2030 | 17년 전 | 2798 | ||
| 2029 | 17년 전 | 1603 | ||
| 2028 | 17년 전 | 1352 | ||
| 2027 | 17년 전 | 1611 | ||
| 2026 |
진정한승리
|
17년 전 | 2519 | |
| 2025 | 17년 전 | 1742 | ||
| 2024 | 17년 전 | 2020 | ||
| 2023 | 17년 전 | 1313 | ||
| 2022 |
SE7EN
|
17년 전 | 1049 | |
| 2021 | 17년 전 | 1127 | ||
| 2020 | 17년 전 | 2929 | ||
| 2019 | 17년 전 | 2474 | ||
| 2018 | 17년 전 | 2051 | ||
| 2017 | 17년 전 | 2052 | ||
| 2016 | 17년 전 | 1803 | ||
| 2015 | 17년 전 | 2254 | ||
| 2014 | 17년 전 | 2019 | ||
| 2013 | 17년 전 | 1987 | ||
| 2012 | 17년 전 | 1878 | ||
| 2011 | 17년 전 | 1218 | ||
| 2010 | 17년 전 | 1823 | ||
| 2009 | 17년 전 | 2231 | ||
| 2008 | 17년 전 | 2309 | ||
| 2007 | 17년 전 | 1642 | ||
| 2006 |
Arone
|
17년 전 | 1515 | |
| 2005 |
|
17년 전 | 1364 | |
| 2004 | 17년 전 | 2587 | ||
| 2003 |
suerte
|
17년 전 | 2682 | |
| 2002 |
suerte
|
17년 전 | 2083 | |
| 2001 |
suerte
|
17년 전 | 2424 | |
| 2000 |
|
17년 전 | 2729 | |
| 1999 |
|
17년 전 | 1331 | |
| 1998 |
|
17년 전 | 1198 | |
| 1997 | 17년 전 | 6335 | ||
| 1996 | 17년 전 | 1190 | ||
| 1995 | 17년 전 | 1633 | ||
| 1994 | 17년 전 | 1783 | ||
| 1993 | 17년 전 | 1111 | ||
| 1992 | 17년 전 | 1198 | ||
| 1991 | 17년 전 | 1898 | ||
| 1990 |
sdjsu
|
17년 전 | 1526 | |
| 1989 | 17년 전 | 3625 | ||
| 1988 |
smilesol
|
17년 전 | 1215 | |
| 1987 |
|
17년 전 | 1911 | |
| 1986 | 17년 전 | 1192 | ||
| 1985 | 17년 전 | 1394 | ||
| 1984 | 17년 전 | 2369 | ||
| 1983 | 17년 전 | 2028 | ||
| 1982 | 17년 전 | 1043 | ||
| 1981 | 17년 전 | 1049 | ||
| 1980 | 17년 전 | 1107 | ||
| 1979 |
오렌지76
|
17년 전 | 6054 | |
| 1978 |
오렌지76
|
17년 전 | 5852 | |
| 1977 | 17년 전 | 2042 | ||
| 1976 |
없어씨바라
|
17년 전 | 1033 | |
| 1975 | 17년 전 | 1121 | ||
| 1974 | 17년 전 | 2087 | ||
| 1973 | 17년 전 | 1520 | ||
| 1972 | 17년 전 | 1161 | ||
| 1971 |
smilesol
|
17년 전 | 1200 | |
| 1970 | 17년 전 | 1150 | ||
| 1969 |
smilesol
|
17년 전 | 1070 | |
| 1968 |
소행성블루
|
17년 전 | 3973 | |
| 1967 |
소행성블루
|
17년 전 | 2179 | |
| 1966 | 17년 전 | 1654 | ||
| 1965 |
소행성블루
|
17년 전 | 2781 | |
| 1964 |
고양Ol아빠
|
17년 전 | 1484 | |
| 1963 | 17년 전 | 1172 | ||
| 1962 | 17년 전 | 1190 | ||
| 1961 |
choijinhee
|
17년 전 | 1252 | |
| 1960 | 17년 전 | 1136 | ||
| 1959 | 17년 전 | 1256 | ||
| 1958 |
하이웹솔루션
|
17년 전 | 2409 | |
| 1957 | 17년 전 | 4194 | ||
| 1956 | 17년 전 | 1195 | ||
| 1955 | 17년 전 | 3955 | ||
| 1954 | 17년 전 | 4111 | ||
| 1953 | 17년 전 | 1238 | ||
| 1952 | 17년 전 | 2186 | ||
| 1951 | 17년 전 | 1624 | ||
| 1950 | 17년 전 | 3218 | ||
| 1949 | 17년 전 | 1368 | ||
| 1948 | 17년 전 | 3613 | ||
| 1947 | 17년 전 | 3406 | ||
| 1946 | 17년 전 | 2576 | ||
| 1945 | 17년 전 | 2940 | ||
| 1944 | 17년 전 | 2633 | ||
| 1943 | 17년 전 | 1951 | ||
| 1942 | 17년 전 | 3314 | ||
| 1941 | 17년 전 | 2629 | ||
| 1940 | 17년 전 | 3526 | ||
| 1939 |
|
17년 전 | 1166 | |
| 1938 | 17년 전 | 2251 | ||
| 1937 | 17년 전 | 1327 | ||
| 1936 |
smilesol
|
17년 전 | 1200 | |
| 1935 |
AHEEZII
|
17년 전 | 1065 | |
| 1934 |
smilesol
|
17년 전 | 1044 | |
| 1933 | 17년 전 | 1419 | ||
| 1932 | 17년 전 | 2861 | ||
| 1931 | 17년 전 | 3254 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기