<?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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2130 | 17년 전 | 1177 | ||
| 2129 |
ⓧ힘내세요
|
17년 전 | 2234 | |
| 2128 | 17년 전 | 2872 | ||
| 2127 | 17년 전 | 4056 | ||
| 2126 | 17년 전 | 3143 | ||
| 2125 | 17년 전 | 1407 | ||
| 2124 | 17년 전 | 1707 | ||
| 2123 | 17년 전 | 2236 | ||
| 2122 | 17년 전 | 1544 | ||
| 2121 | 17년 전 | 1719 | ||
| 2120 | 17년 전 | 2716 | ||
| 2119 | 17년 전 | 2142 | ||
| 2118 | 17년 전 | 1797 | ||
| 2117 |
아름다운세상
|
17년 전 | 4204 | |
| 2116 | 17년 전 | 3049 | ||
| 2115 | 17년 전 | 1435 | ||
| 2114 |
아름다운세상
|
17년 전 | 3569 | |
| 2113 | 17년 전 | 2794 | ||
| 2112 | 17년 전 | 2074 | ||
| 2111 | 17년 전 | 1290 | ||
| 2110 | 17년 전 | 2327 | ||
| 2109 | 17년 전 | 2065 | ||
| 2108 | 17년 전 | 1983 | ||
| 2107 |
휴전합시다
|
17년 전 | 1919 | |
| 2106 | 17년 전 | 1168 | ||
| 2105 |
|
17년 전 | 1871 | |
| 2104 | 17년 전 | 2925 | ||
| 2103 | 17년 전 | 1427 | ||
| 2102 | 17년 전 | 1669 | ||
| 2101 | 17년 전 | 1354 | ||
| 2100 | 17년 전 | 1598 | ||
| 2099 | 17년 전 | 1574 | ||
| 2098 | 17년 전 | 1444 | ||
| 2097 | 17년 전 | 2556 | ||
| 2096 | 17년 전 | 2323 | ||
| 2095 | 17년 전 | 2109 | ||
| 2094 | 17년 전 | 1421 | ||
| 2093 | 17년 전 | 2430 | ||
| 2092 | 17년 전 | 4261 | ||
| 2091 | 17년 전 | 2748 | ||
| 2090 | 17년 전 | 1663 | ||
| 2089 | 17년 전 | 1856 | ||
| 2088 | 17년 전 | 3234 | ||
| 2087 | 17년 전 | 2234 | ||
| 2086 | 17년 전 | 3830 | ||
| 2085 | 17년 전 | 1678 | ||
| 2084 | 17년 전 | 2278 | ||
| 2083 | 17년 전 | 2101 | ||
| 2082 | 17년 전 | 1613 | ||
| 2081 | 17년 전 | 2128 | ||
| 2080 |
letsgolee
|
17년 전 | 1921 | |
| 2079 | 17년 전 | 1961 | ||
| 2078 | 17년 전 | 3070 | ||
| 2077 | 17년 전 | 2144 | ||
| 2076 | 17년 전 | 1439 | ||
| 2075 | 17년 전 | 1458 | ||
| 2074 | 17년 전 | 2127 | ||
| 2073 | 17년 전 | 3206 | ||
| 2072 | 17년 전 | 2136 | ||
| 2071 |
휴전합시다
|
17년 전 | 1532 | |
| 2070 | 17년 전 | 4242 | ||
| 2069 | 17년 전 | 2038 | ||
| 2068 | 17년 전 | 3460 | ||
| 2067 | 17년 전 | 6032 | ||
| 2066 | 17년 전 | 1483 | ||
| 2065 |
letsgolee
|
17년 전 | 1653 | |
| 2064 | 17년 전 | 1235 | ||
| 2063 | 17년 전 | 1347 | ||
| 2062 |
vicky
|
17년 전 | 2873 | |
| 2061 | 17년 전 | 1909 | ||
| 2060 |
카프카07
|
17년 전 | 2594 | |
| 2059 | 17년 전 | 1305 | ||
| 2058 | 17년 전 | 3184 | ||
| 2057 | 17년 전 | 2164 | ||
| 2056 | 17년 전 | 2609 | ||
| 2055 | 17년 전 | 1405 | ||
| 2054 | 17년 전 | 1752 | ||
| 2053 | 17년 전 | 1145 | ||
| 2052 |
|
17년 전 | 1203 | |
| 2051 | 17년 전 | 1787 | ||
| 2050 | 17년 전 | 1229 | ||
| 2049 | 17년 전 | 4311 | ||
| 2048 | 17년 전 | 1512 | ||
| 2047 | 17년 전 | 2008 | ||
| 2046 |
카프카07
|
17년 전 | 7090 | |
| 2045 | 17년 전 | 1384 | ||
| 2044 | 17년 전 | 1903 | ||
| 2043 | 17년 전 | 3132 | ||
| 2042 | 17년 전 | 1224 | ||
| 2041 |
카프카07
|
17년 전 | 1986 | |
| 2040 | 17년 전 | 1156 | ||
| 2039 |
smilesol
|
17년 전 | 1849 | |
| 2038 | 17년 전 | 2154 | ||
| 2037 |
|
17년 전 | 2969 | |
| 2036 | 17년 전 | 1247 | ||
| 2035 |
|
17년 전 | 1337 | |
| 2034 |
ㅣ곰탱이ㅣ
|
17년 전 | 1563 | |
| 2033 |
|
17년 전 | 1232 | |
| 2032 | 17년 전 | 4355 | ||
| 2031 | 17년 전 | 3898 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기