<?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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8130 | 9년 전 | 575 | ||
| 8129 |
|
9년 전 | 688 | |
| 8128 | 9년 전 | 543 | ||
| 8127 |
|
9년 전 | 591 | |
| 8126 | 9년 전 | 524 | ||
| 8125 | 9년 전 | 778 | ||
| 8124 |
|
9년 전 | 537 | |
| 8123 | 9년 전 | 522 | ||
| 8122 | 9년 전 | 455 | ||
| 8121 | 9년 전 | 562 | ||
| 8120 | 9년 전 | 482 | ||
| 8119 | 9년 전 | 570 | ||
| 8118 |
|
9년 전 | 648 | |
| 8117 |
|
9년 전 | 415 | |
| 8116 |
PASKRAN
|
9년 전 | 474 | |
| 8115 | 9년 전 | 469 | ||
| 8114 |
kiplayer
|
9년 전 | 607 | |
| 8113 | 9년 전 | 467 | ||
| 8112 |
|
9년 전 | 575 | |
| 8111 | 9년 전 | 414 | ||
| 8110 | 9년 전 | 456 | ||
| 8109 | 9년 전 | 388 | ||
| 8108 |
|
9년 전 | 564 | |
| 8107 |
|
9년 전 | 453 | |
| 8106 |
|
9년 전 | 455 | |
| 8105 | 9년 전 | 485 | ||
| 8104 |
|
9년 전 | 450 | |
| 8103 |
|
9년 전 | 450 | |
| 8102 |
|
9년 전 | 423 | |
| 8101 |
snshero
|
9년 전 | 808 | |
| 8100 | 9년 전 | 854 | ||
| 8099 | 9년 전 | 831 | ||
| 8098 | 9년 전 | 732 | ||
| 8097 | 9년 전 | 540 | ||
| 8096 | 9년 전 | 736 | ||
| 8095 | 9년 전 | 871 | ||
| 8094 | 9년 전 | 541 | ||
| 8093 | 9년 전 | 822 | ||
| 8092 | 9년 전 | 774 | ||
| 8091 | 9년 전 | 1158 | ||
| 8090 | 9년 전 | 784 | ||
| 8089 | 9년 전 | 998 | ||
| 8088 | 9년 전 | 660 | ||
| 8087 | 9년 전 | 787 | ||
| 8086 | 9년 전 | 535 | ||
| 8085 | 9년 전 | 501 | ||
| 8084 | 9년 전 | 618 | ||
| 8083 | 9년 전 | 592 | ||
| 8082 | 9년 전 | 781 | ||
| 8081 | 9년 전 | 489 | ||
| 8080 | 9년 전 | 586 | ||
| 8079 | 9년 전 | 545 | ||
| 8078 | 9년 전 | 465 | ||
| 8077 | 9년 전 | 554 | ||
| 8076 | 9년 전 | 424 | ||
| 8075 | 9년 전 | 457 | ||
| 8074 | 9년 전 | 419 | ||
| 8073 | 9년 전 | 477 | ||
| 8072 | 9년 전 | 468 | ||
| 8071 |
o1o111
|
9년 전 | 916 | |
| 8070 | 9년 전 | 425 | ||
| 8069 | 9년 전 | 362 | ||
| 8068 | 9년 전 | 615 | ||
| 8067 | 9년 전 | 415 | ||
| 8066 | 9년 전 | 441 | ||
| 8065 | 9년 전 | 400 | ||
| 8064 | 9년 전 | 394 | ||
| 8063 | 9년 전 | 362 | ||
| 8062 | 9년 전 | 332 | ||
| 8061 | 9년 전 | 368 | ||
| 8060 | 9년 전 | 407 | ||
| 8059 | 9년 전 | 342 | ||
| 8058 | 9년 전 | 281 | ||
| 8057 | 9년 전 | 410 | ||
| 8056 | 9년 전 | 327 | ||
| 8055 | 9년 전 | 373 | ||
| 8054 | 9년 전 | 383 | ||
| 8053 | 9년 전 | 434 | ||
| 8052 | 9년 전 | 306 | ||
| 8051 | 9년 전 | 356 | ||
| 8050 | 9년 전 | 413 | ||
| 8049 | 9년 전 | 345 | ||
| 8048 | 9년 전 | 449 | ||
| 8047 | 9년 전 | 388 | ||
| 8046 | 9년 전 | 330 | ||
| 8045 | 9년 전 | 277 | ||
| 8044 | 9년 전 | 364 | ||
| 8043 | 9년 전 | 321 | ||
| 8042 | 9년 전 | 311 | ||
| 8041 | 9년 전 | 372 | ||
| 8040 | 9년 전 | 296 | ||
| 8039 | 9년 전 | 338 | ||
| 8038 | 9년 전 | 281 | ||
| 8037 | 9년 전 | 427 | ||
| 8036 | 9년 전 | 515 | ||
| 8035 | 9년 전 | 446 | ||
| 8034 | 9년 전 | 407 | ||
| 8033 | 9년 전 | 367 | ||
| 8032 | 9년 전 | 471 | ||
| 8031 | 9년 전 | 364 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기