<?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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 187 | ||
| 8229 | 9년 전 | 169 | ||
| 8228 |
커네드커네드
|
9년 전 | 207 | |
| 8227 | 9년 전 | 247 | ||
| 8226 | 9년 전 | 268 | ||
| 8225 | 9년 전 | 248 | ||
| 8224 | 9년 전 | 254 | ||
| 8223 | 9년 전 | 229 | ||
| 8222 |
|
9년 전 | 293 | |
| 8221 | 9년 전 | 193 | ||
| 8220 | 9년 전 | 233 | ||
| 8219 | 9년 전 | 207 | ||
| 8218 | 9년 전 | 253 | ||
| 8217 |
star3840
|
9년 전 | 215 | |
| 8216 | 9년 전 | 286 | ||
| 8215 | 9년 전 | 227 | ||
| 8214 | 9년 전 | 335 | ||
| 8213 | 9년 전 | 295 | ||
| 8212 | 9년 전 | 208 | ||
| 8211 | 9년 전 | 379 | ||
| 8210 | 9년 전 | 371 | ||
| 8209 | 9년 전 | 453 | ||
| 8208 | 9년 전 | 341 | ||
| 8207 | 9년 전 | 350 | ||
| 8206 |
|
9년 전 | 296 | |
| 8205 | 9년 전 | 271 | ||
| 8204 | 9년 전 | 256 | ||
| 8203 | 9년 전 | 337 | ||
| 8202 | 9년 전 | 250 | ||
| 8201 | 9년 전 | 290 | ||
| 8200 | 9년 전 | 294 | ||
| 8199 | 9년 전 | 315 | ||
| 8198 | 9년 전 | 281 | ||
| 8197 | 9년 전 | 264 | ||
| 8196 | 9년 전 | 686 | ||
| 8195 | 9년 전 | 273 | ||
| 8194 | 9년 전 | 388 | ||
| 8193 | 9년 전 | 302 | ||
| 8192 | 9년 전 | 309 | ||
| 8191 | 9년 전 | 267 | ||
| 8190 | 9년 전 | 250 | ||
| 8189 | 9년 전 | 309 | ||
| 8188 | 9년 전 | 241 | ||
| 8187 | 9년 전 | 260 | ||
| 8186 | 9년 전 | 255 | ||
| 8185 | 9년 전 | 424 | ||
| 8184 | 9년 전 | 209 | ||
| 8183 | 9년 전 | 419 | ||
| 8182 | 9년 전 | 287 | ||
| 8181 | 9년 전 | 245 | ||
| 8180 | 9년 전 | 819 | ||
| 8179 | 9년 전 | 594 | ||
| 8178 | 9년 전 | 452 | ||
| 8177 |
kiplayer
|
9년 전 | 449 | |
| 8176 | 9년 전 | 480 | ||
| 8175 | 9년 전 | 366 | ||
| 8174 | 9년 전 | 358 | ||
| 8173 | 9년 전 | 450 | ||
| 8172 | 9년 전 | 330 | ||
| 8171 | 9년 전 | 291 | ||
| 8170 | 9년 전 | 408 | ||
| 8169 |
커네드커네드
|
9년 전 | 363 | |
| 8168 | 9년 전 | 447 | ||
| 8167 | 9년 전 | 437 | ||
| 8166 | 9년 전 | 337 | ||
| 8165 | 9년 전 | 275 | ||
| 8164 | 9년 전 | 410 | ||
| 8163 | 9년 전 | 414 | ||
| 8162 | 9년 전 | 397 | ||
| 8161 | 9년 전 | 413 | ||
| 8160 |
|
9년 전 | 633 | |
| 8159 | 9년 전 | 579 | ||
| 8158 | 9년 전 | 372 | ||
| 8157 | 9년 전 | 492 | ||
| 8156 | 9년 전 | 362 | ||
| 8155 | 9년 전 | 375 | ||
| 8154 |
00년생용띠
|
9년 전 | 703 | |
| 8153 | 9년 전 | 342 | ||
| 8152 |
|
9년 전 | 520 | |
| 8151 | 9년 전 | 511 | ||
| 8150 | 9년 전 | 630 | ||
| 8149 |
Jangfolk
|
9년 전 | 486 | |
| 8148 | 9년 전 | 303 | ||
| 8147 | 9년 전 | 486 | ||
| 8146 | 9년 전 | 568 | ||
| 8145 | 9년 전 | 523 | ||
| 8144 | 9년 전 | 490 | ||
| 8143 | 9년 전 | 318 | ||
| 8142 | 9년 전 | 537 | ||
| 8141 | 9년 전 | 483 | ||
| 8140 | 9년 전 | 1053 | ||
| 8139 | 9년 전 | 388 | ||
| 8138 |
전갈자리남자
|
9년 전 | 493 | |
| 8137 | 9년 전 | 532 | ||
| 8136 | 9년 전 | 863 | ||
| 8135 |
|
9년 전 | 905 | |
| 8134 |
PlayPixel
|
9년 전 | 645 | |
| 8133 |
|
9년 전 | 550 | |
| 8132 | 9년 전 | 588 | ||
| 8131 | 9년 전 | 943 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기