<?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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7630 | 10년 전 | 633 | ||
| 7629 |
|
10년 전 | 2331 | |
| 7628 | 10년 전 | 767 | ||
| 7627 |
|
10년 전 | 990 | |
| 7626 |
|
10년 전 | 1752 | |
| 7625 | 10년 전 | 651 | ||
| 7624 | 10년 전 | 680 | ||
| 7623 |
|
10년 전 | 2997 | |
| 7622 | 10년 전 | 682 | ||
| 7621 |
leeleeleelee
|
10년 전 | 561 | |
| 7620 | 10년 전 | 524 | ||
| 7619 | 10년 전 | 445 | ||
| 7618 | 10년 전 | 990 | ||
| 7617 | 10년 전 | 706 | ||
| 7616 | 10년 전 | 602 | ||
| 7615 | 10년 전 | 697 | ||
| 7614 | 10년 전 | 1204 | ||
| 7613 |
|
10년 전 | 2042 | |
| 7612 | 10년 전 | 1112 | ||
| 7611 | 10년 전 | 1375 | ||
| 7610 |
|
10년 전 | 1871 | |
| 7609 |
|
10년 전 | 1282 | |
| 7608 |
mwdkim
|
10년 전 | 1087 | |
| 7607 |
|
10년 전 | 1017 | |
| 7606 |
mwdkim
|
10년 전 | 3892 | |
| 7605 | 10년 전 | 660 | ||
| 7604 | 10년 전 | 998 | ||
| 7603 | 10년 전 | 1623 | ||
| 7602 |
|
10년 전 | 1040 | |
| 7601 |
AniNest
|
10년 전 | 2753 | |
| 7600 |
port443
|
10년 전 | 987 | |
| 7599 | 10년 전 | 914 | ||
| 7598 | 10년 전 | 987 | ||
| 7597 | 10년 전 | 4548 | ||
| 7596 |
SeungYeon
|
10년 전 | 861 | |
| 7595 |
untitled
|
10년 전 | 2382 | |
| 7594 |
프로그래머7
|
10년 전 | 1699 | |
| 7593 |
untitled
|
10년 전 | 2336 | |
| 7592 |
untitled
|
10년 전 | 1905 | |
| 7591 |
untitled
|
10년 전 | 2646 | |
| 7590 |
아리마2001
|
10년 전 | 816 | |
| 7589 | 10년 전 | 1075 | ||
| 7588 |
|
10년 전 | 2884 | |
| 7587 | 10년 전 | 1265 | ||
| 7586 | 10년 전 | 629 | ||
| 7585 | 10년 전 | 1649 | ||
| 7584 | 10년 전 | 1384 | ||
| 7583 |
leeleeleelee
|
10년 전 | 1116 | |
| 7582 |
|
10년 전 | 1067 | |
| 7581 | 10년 전 | 1301 | ||
| 7580 | 10년 전 | 939 | ||
| 7579 |
|
10년 전 | 575 | |
| 7578 | 10년 전 | 1382 | ||
| 7577 |
|
10년 전 | 1849 | |
| 7576 | 10년 전 | 1363 | ||
| 7575 |
멋진남자임
|
10년 전 | 1443 | |
| 7574 | 10년 전 | 2079 | ||
| 7573 | 10년 전 | 3211 | ||
| 7572 | 10년 전 | 741 | ||
| 7571 |
|
10년 전 | 770 | |
| 7570 |
|
10년 전 | 1280 | |
| 7569 | 10년 전 | 1516 | ||
| 7568 |
this1mg
|
10년 전 | 1019 | |
| 7567 |
|
10년 전 | 726 | |
| 7566 | 10년 전 | 886 | ||
| 7565 |
Angel하늘
|
10년 전 | 954 | |
| 7564 |
seoldi
|
10년 전 | 1193 | |
| 7563 |
|
10년 전 | 1344 | |
| 7562 |
멋진남자임
|
10년 전 | 2040 | |
| 7561 | 10년 전 | 678 | ||
| 7560 |
leeleeleelee
|
10년 전 | 874 | |
| 7559 | 10년 전 | 5004 | ||
| 7558 |
RinaP
|
10년 전 | 753 | |
| 7557 |
|
10년 전 | 1215 | |
| 7556 | 10년 전 | 1167 | ||
| 7555 |
hyohyojj1234
|
10년 전 | 1631 | |
| 7554 | 10년 전 | 1065 | ||
| 7553 |
senseme
|
10년 전 | 1318 | |
| 7552 |
ehdltdoit
|
10년 전 | 1412 | |
| 7551 |
|
10년 전 | 1788 | |
| 7550 |
leeleeleelee
|
10년 전 | 1553 | |
| 7549 | 10년 전 | 2391 | ||
| 7548 | 10년 전 | 1811 | ||
| 7547 |
멋진남자임
|
10년 전 | 1919 | |
| 7546 | 10년 전 | 964 | ||
| 7545 |
ILMare1003
|
10년 전 | 1252 | |
| 7544 |
|
10년 전 | 1207 | |
| 7543 | 10년 전 | 860 | ||
| 7542 | 10년 전 | 633 | ||
| 7541 |
울라라라우
|
10년 전 | 841 | |
| 7540 | 10년 전 | 1575 | ||
| 7539 | 10년 전 | 891 | ||
| 7538 |
|
10년 전 | 1803 | |
| 7537 | 10년 전 | 3578 | ||
| 7536 |
Gaumi
|
10년 전 | 1374 | |
| 7535 |
프로그램은어려워
|
10년 전 | 1240 | |
| 7534 |
senseme
|
10년 전 | 1188 | |
| 7533 | 10년 전 | 1163 | ||
| 7532 | 10년 전 | 829 | ||
| 7531 | 10년 전 | 2022 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기