<?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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 360 | ||
| 7929 | 9년 전 | 252 | ||
| 7928 | 9년 전 | 360 | ||
| 7927 | 9년 전 | 286 | ||
| 7926 | 9년 전 | 637 | ||
| 7925 | 9년 전 | 305 | ||
| 7924 | 9년 전 | 268 | ||
| 7923 | 9년 전 | 316 | ||
| 7922 | 9년 전 | 331 | ||
| 7921 | 9년 전 | 367 | ||
| 7920 | 9년 전 | 290 | ||
| 7919 | 9년 전 | 303 | ||
| 7918 | 9년 전 | 471 | ||
| 7917 | 9년 전 | 309 | ||
| 7916 | 9년 전 | 373 | ||
| 7915 | 9년 전 | 356 | ||
| 7914 | 9년 전 | 377 | ||
| 7913 | 9년 전 | 494 | ||
| 7912 | 9년 전 | 369 | ||
| 7911 | 9년 전 | 325 | ||
| 7910 | 9년 전 | 350 | ||
| 7909 | 9년 전 | 459 | ||
| 7908 | 9년 전 | 363 | ||
| 7907 | 9년 전 | 311 | ||
| 7906 | 9년 전 | 326 | ||
| 7905 | 9년 전 | 322 | ||
| 7904 | 9년 전 | 283 | ||
| 7903 | 9년 전 | 282 | ||
| 7902 | 9년 전 | 503 | ||
| 7901 |
|
9년 전 | 712 | |
| 7900 | 9년 전 | 535 | ||
| 7899 | 9년 전 | 339 | ||
| 7898 | 9년 전 | 334 | ||
| 7897 | 9년 전 | 293 | ||
| 7896 | 9년 전 | 310 | ||
| 7895 | 9년 전 | 419 | ||
| 7894 | 9년 전 | 343 | ||
| 7893 | 9년 전 | 269 | ||
| 7892 | 9년 전 | 310 | ||
| 7891 | 9년 전 | 698 | ||
| 7890 | 9년 전 | 1164 | ||
| 7889 | 9년 전 | 725 | ||
| 7888 |
limsy1987
|
9년 전 | 516 | |
| 7887 | 9년 전 | 498 | ||
| 7886 | 9년 전 | 375 | ||
| 7885 | 9년 전 | 354 | ||
| 7884 | 9년 전 | 360 | ||
| 7883 | 9년 전 | 336 | ||
| 7882 | 9년 전 | 350 | ||
| 7881 | 9년 전 | 372 | ||
| 7880 | 9년 전 | 505 | ||
| 7879 | 9년 전 | 408 | ||
| 7878 | 9년 전 | 1141 | ||
| 7877 | 9년 전 | 701 | ||
| 7876 | 9년 전 | 427 | ||
| 7875 | 9년 전 | 498 | ||
| 7874 |
|
9년 전 | 769 | |
| 7873 | 9년 전 | 475 | ||
| 7872 | 9년 전 | 601 | ||
| 7871 | 9년 전 | 439 | ||
| 7870 | 9년 전 | 558 | ||
| 7869 | 9년 전 | 383 | ||
| 7868 | 9년 전 | 367 | ||
| 7867 | 9년 전 | 370 | ||
| 7866 | 9년 전 | 428 | ||
| 7865 | 9년 전 | 390 | ||
| 7864 | 9년 전 | 451 | ||
| 7863 | 9년 전 | 441 | ||
| 7862 | 9년 전 | 419 | ||
| 7861 | 9년 전 | 583 | ||
| 7860 | 9년 전 | 589 | ||
| 7859 | 9년 전 | 360 | ||
| 7858 | 9년 전 | 664 | ||
| 7857 | 9년 전 | 1017 | ||
| 7856 | 9년 전 | 470 | ||
| 7855 | 9년 전 | 691 | ||
| 7854 | 9년 전 | 691 | ||
| 7853 | 9년 전 | 521 | ||
| 7852 | 9년 전 | 465 | ||
| 7851 | 9년 전 | 437 | ||
| 7850 | 9년 전 | 533 | ||
| 7849 | 9년 전 | 308 | ||
| 7848 | 9년 전 | 346 | ||
| 7847 | 9년 전 | 571 | ||
| 7846 | 9년 전 | 399 | ||
| 7845 | 9년 전 | 363 | ||
| 7844 | 9년 전 | 355 | ||
| 7843 | 9년 전 | 365 | ||
| 7842 | 9년 전 | 360 | ||
| 7841 | 9년 전 | 348 | ||
| 7840 | 9년 전 | 351 | ||
| 7839 | 9년 전 | 385 | ||
| 7838 | 9년 전 | 471 | ||
| 7837 | 9년 전 | 313 | ||
| 7836 | 9년 전 | 353 | ||
| 7835 | 9년 전 | 431 | ||
| 7834 |
|
9년 전 | 1166 | |
| 7833 | 9년 전 | 372 | ||
| 7832 | 9년 전 | 358 | ||
| 7831 | 9년 전 | 492 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기