1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | | PHP-Quelltext <?php
class parse {
var $urldetect=1;
var $urlcut=1;
var $urlmaxwidth=60;
var $urlwidth1=45;
var $urlwidth2=-15;
var $censoruse=1;
var $censorreplace='*';
var $bbhash='';
var $smiliehash='';
// Flash
var $flashtag=array('tag'=>'flash','html'=>'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/caps/flash/swflash.cab#version=8,0,22,0" {option}><param name="movie" value="{text}" /><param name="play" value="true" /><param name="loop" value="false" /><param name="quality" value="autohigh" /><param name="bgcolor" value="{rowbgcolor}" /><param name="scale" value="exactfit" /><param name="salign" value="tl" /><param name="menu" value="true" /><embed src="{text}" {option} play="true" loop="false" quality="autohigh" bgcolor="{rowbgcolor}" scale="showall" salign="tl" menu="true"></embed></object>');
// Flash
var $urltag=array('tag'=>'url','html'=>'<a target="_blank" href="{option}">{text}</a>');
var $imagetags=array(
array('tag'=>'img','html'=>'<img border="0" alt="" src="{image}" />'),
array('tag'=>'imgr','html'=>'<img border="0" alt="" src="{image}" align="right" />'),
array('tag'=>'imgl','html'=>'<img border="0" alt="" src="{image}" align="left" />'));
function bbdefine () {
global $lang;
$this->bbhash=array(
array('tag'=>'myvideo','html'=>'<object style="width:450px;height:325px;" type="application/x-shockwave-flash" data="http://www.myvideo.de/movie/{text}"><param name="movie" value="http://www.myvideo.de/movie/{text}"/><param name="FlashVars" value="DESTSERVER=http://www.myvideo.de&LINKTEXT=MyVideo"/> <param name="AllowFullscreen" value="true" /></object><br/><a href="http://www.myvideo.de/watch/{text}"></a>'),
array('tag'=>'youtube','html'=>'<object width="450" height="325"><param name="movie" value="http://www.youtube.com/v/{text}&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/{text}&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="450" height="325"></embed></object>'),
array('tag'=>'gametrailer','html'=>'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="gtembed" width="450" height="325"> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="true" /> <param name="movie" value="http://www.gametrailers.com/remote_wrap.php?mid={text}"/> <param name="quality" value="high" /> <embed src="http://www.gametrailers.com/remote_wrap.php?mid={text}" swLiveConnect="true" name="gtembed" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="450" height="325"></embed> </object>'),
array('tag'=>'clipfish','html'=>'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="450" height="325" id="player" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="http://www.clipfish.de/videoplayer.swf?as=0&videoid={text}=&r=1&c=0067B3" /> <param name="quality" value="high" /><param name="bgcolor" value="#0067B3" /><param name="allowFullScreen" value="true" /><embed src="http://www.clipfish.de/videoplayer.swf?as=0&videoid={text}=&r=1&c=transparent" quality="high" bgstyle="color: transparent" width="450" height="325" name="player" align="middle" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>'),
array('tag'=>'stage6','html'=>'<object codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab" height="325" width="450" classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616"><param name="autoplay" value="false"><param name="src" value="http://video.stage6.com/{text}/.divx" /><param name="custommode" value="Stage6" /><param name="showpostplaybackad" value="false" /><embed type="video/divx" src="http://video.stage6.com/{text}/.divx" pluginspage="http://go.divx.com/plugin/download/" showpostplaybackad="false" custommode="Stage6" autoplay="false" height="325" width="450" /></object>'),
array('tag'=>'hr','html'=>'<hr />'),
array('tag'=>'\*','html'=>'<li>'),
array('tag'=>'list','html'=>'<ul>{text}</ul>'),
array('tag'=>'list=1','html'=>'<ol type="1">{text}</ol>'),
array('tag'=>'list=a','html'=>'<ol type="a">{text}</ol>'),
array('tag'=>'b','html'=>'<b>{text}</b>'),
array('tag'=>'i','html'=>'<i>{text}</i>'),
array('tag'=>'u','html'=>'<u>{text}</u>'),
array('tag'=>'d','html'=>'<strike>{text}</strike>'),
array('tag'=>'h2','html'=>'<h2>{text}</h2>'),
array('tag'=>'h3','html'=>'<h3>{text}</h3>'),
array('tag'=>'h4','html'=>'<h4>{text}</h4>'),
array('tag'=>'p','html'=>'<p>{text}</p>'),
array('tag'=>'sub','html'=>'<sub>{text}</sub>'),
array('tag'=>'sup','html'=>'<sup>{text}</sup>'),
array('tag'=>'left','html'=>'<div align="left">{text}</div>'),
array('tag'=>'center','html'=>'<div align="center">{text}</div>'),
array('tag'=>'right','html'=>'<div align="right">{text}</div>'),
array('tag'=>'block','html'=>'<div align="justify">{text}</div>'),
array('tag'=>'code','html'=>'<code>{text}</code>'),
array('tag'=>'quote','html'=>'<table class="quote" width="98%" cellpadding="4" cellspacing="1" align="center"><tr><td class="quote"><b>'.$lang['quote'].'</b><br /><font class="quote">{text}</font></td></tr></table><br />'),
array('tag'=>'white','html'=>'<font style="color: #FFFFFF">{text}</font>'),
array('tag'=>'gray','html'=>'<font style="color: #CCCCCC">{text}</font>'),
array('tag'=>'dimgray','html'=>'<font style="color: #333333">{text}</font>'),
array('tag'=>'navy','html'=>'<font style="color: #003399">{text}</font>'),
array('tag'=>'royalblue','html'=>'<font style="color: #0099FF">{text}</font>'),
array('tag'=>'red','html'=>'<font style="color: #FF3333">{text}</font>'),
array('tag'=>'orange','html'=>'<font style="color: #FF7F00">{text}</font>'),
array('tag'=>'yellow','html'=>'<font style="color: #FFFF00">{text}</font>'),
array('tag'=>'green','html'=>'<font style="color: #00FF00">{text}</font>'),
array('tag'=>'white','html'=>'<font style="color: #333333">{text}</font>'),
array('tag'=>'color','html'=>'<font style="color: {option}">{text}</font>'),
array('tag'=>'email','html'=>'<a href="mailto:{text}">{text}</a>'),
array('tag'=>'email','html'=>'<a href="mailto:{option}">{text}</a>'));
}
function definesmilies() {
global $DB, $db_tab;
$getsmilies=$DB->query("SELECT * FROM ".$db_tab['smilies']);
while ($smilies=$DB->fetch_array($getsmilies)) {$this->smiliehash[$smilies['smilie_id']]=$smilies;}
}
function parse($text='', $html='', $bb='', $smilies='',$images='',$censor='') {
$text=trim($text);
if ($text!='') {
$text=preg_replace('/[&|?]'.session_name().'=([a-z0-9A-Z]{0,32})[^&|\w|\n|\#|\]|\[]*/','',$text);
if ($censor==1) $text=$this->textcensor($text);
if ($this->urldetect==1) $text=$this->urldetect($text);
if ($html!=1) $text=htmlentities($text);
else $text=$this->preparehtml($text);
if ($images!=1) $text=$this->removeimages($text);
if ($bb==1) $text=$this->bbcode($text);
if ($smilies==1) $text=$this->smilies($text);
$text=$this->parseimages($text);
$text=$this->flashparse($text);
$text=$this->urlparse($text);
$text=$this->returntext($text);
if ($html==1) $text=str_replace('"','"',$text);
return $text;
}
else return FALSE;
}
function urldetect($text) {
$text=eregi_replace("([ \r\n])http://([^ ,\r\n]*)","\\1http://\\2",$text);
$text=eregi_replace("([ \r\n])https://([^ ,\r\n]*)","\\1https://\\2",$text);
$text=eregi_replace("([ \r\n])ftp://([^ ,\r\n]*)","\\1ftp://\\2",$text);
$text=eregi_replace("([ \r\n])www\\.([^ ,\r\n]*)","\\1http://www.\\2",$text);
$text=eregi_replace("^http://([^ ,\r\n]*)","http://\\1",$text);
$text=eregi_replace("^https://([^ ,\r\n]*)","https://\\1",$text);
$text=eregi_replace("^ftp://([^ ,\r\n]*)","ftp://\\1",$text);
$text=eregi_replace("^www\\.([^ ,\r\n]*)","http://www.\\1",$text);
return $text;
}
function urlparse($text='') {
$code=$this->urltag;
$text=preg_replace("#\[".$code['tag']."=(.*)\]([^\]|\[]*)\[/".$code['tag']."\]#eiU","\$this->urlrewrite('$code[html]','\\1','\\2')",$text);
$text=preg_replace("#\[".$code['tag']."\](.*)\[/".$code['tag']."\]#esiU","\$this->urlrewrite('$code[html]','\\1')",$text);
return $text;
}
function urlrewrite($html='', $url='', $text='') {
if ($text=='') $text=$url;
if ($this->urlcut==1 && strlen(trim($text) && preg_match("([^<>\[\]])",$text))>$this->urlmaxwidth) $text=substr(trim($text),0,$this->urlwidth1)."...".substr(trim($text),$this->urlwidth2);
$rewritedurl=str_replace("\\\"","\"",str_replace("{option}",trim($url),str_replace("{text}",trim($text),$html)));
return $rewritedurl;
}
// Flash
function flashparse($text='') {
$code=$this->flashtag;
$text=preg_replace("#[".$code['tag']."=(.*)]([^]|[]*)[/".$code['tag']."]#eiU","$this->flashrewrite('$code[html]','2','1')",$text);
$text=preg_replace("#[".$code['tag']."](.*)[/".$code['tag']."]#esiU","$this->flashrewrite('$code[html]','1')",$text);
return $text;
}
function flashrewrite($html='', $text='', $option='') {
global $row,$style;
if(trim($option) != "") {
$optionexp = explode(",",$option);
$option = 'width="'.$optionexp[0].'"';
if($optionexp[1] != "") $option .= 'height="'.$optionexp[1].'"';
} else {
//$option = 'width="300" height="100"';
}
// hintergrundfarbe übernehmen
if(trim($row) != "") {
eval("$rowbgcolor = "$style[td".trim($row)."bgcolor]";");
$rowbgcolor = "#".$rowbgcolor;
} else {
$rowbgcolor = "#990000"; // alternative farbe
}
$rewritedflash=str_replace(""",""",str_replace("{rowbgcolor}",trim($rowbgcolor),str_replace("{option}",trim($option),str_replace("{text}",trim($text),$html))));
return $rewritedflash;
}
// Flash
function parseimages ($text='') {
$tags=$this->imagetags;
foreach ($tags as $code) {
$text=preg_replace("#\[".$code['tag']."]([^\"\?\&]*\.(gif|jpg|jpeg|bmp|png))\[\/".$code['tag']."\]#eiU","\$this->image('$code[html]','\\1')",$text);
}
return $text;
}
function bbcode($text='') {
if ($this->bbhash=='') $this->bbdefine();
if (is_array($this->bbhash)) {
foreach($this->bbhash as $code) {
if (strstr($code['html'],'{option}')) $text=preg_replace("#\[".$code['tag']."=(.*)\](.*)\[/".$code['tag']."\]#eisUS","\$this->bbreplace('$code[html]','\\2','\\1')",$text);
elseif (strstr($code['html'],'{text}')) {
$pattern="#\[".$code['tag']."\](.*)\[/".$code['tag']."\]#eisUS";
while(preg_match($pattern,$text)) {$text=preg_replace($pattern,"\$this->bbreplace('$code[html]','\\1')",$text);}
}
else $text=preg_replace("/\[".$code['tag']."\]/",$code['html'],$text);
}
}
return $text;
}
function bbreplace($html='',$text='',$option='') {
if ($option!='') $text=str_replace("{option}",$option,str_replace("{text}",$text,$html));
else $text=str_replace("{text}",$text,$html);
return $text;
}
function image($html='', $url='') {
return str_replace("{image}",$url,$html);
}
function removeimages($text='') {
return preg_replace("#\[[img|imgr|imgl]\]#i",",preg_replace("#\[/[img|imgr|imgl]\]#i","" class="hidelink" target="_blank">",preg_replace("#\[/[img|imgr|imgl]\]#i","",$text));
}
function smilies ($text='') {
if ($this->smiliehash=='') $this->definesmilies();
if (is_array($this->smiliehash)) {
foreach ($this->smiliehash as $smilie) {
if ($smilie_size=@getimagesize($smilie['smilie_path'])) $smilie_size=$smilie_size[3];
else unset($smilie_size);
$text=str_replace($smilie['smilie_code'],'<img src="'.$smilie['smilie_path'].'" border="0" alt="'.$smilie['smilie_title'].'" '.$smilie_size.' />',$text);
}
}
return $text;
}
function textcensor($text='') {
global $config;
if ($config['censor_badword']!='' && $this->censoruse==1) {
$r=$this->censorreplace;
$censorlist=explode("\n",$config['censor_badword']);
foreach($censorlist as $c) {
$c=trim($c);
if ($c!='') {
$cc=strlen($c);
if (preg_match("#\{(.*)\}#isU",$c)) {
$cc=$cc-2;
while($cc>0) {$rr.=$r; $cc--;}
$text=preg_replace($c," ".$rr." ",$text);
}
else {
while($cc>0) {$rr.=$r; $cc--;}
$text=eregi_replace($c,$rr,$text);
}
}
unset($cc); unset($rr);
}
}
return $text;
}
function preparehtml($text='') {
$text=preg_replace("#<table(.*)>([ |\n|\r\s]{1,})<tr#iUs","<table\\1><tr",$text);
$text=preg_replace("#<tr(.*)>([ |\n|\r\s]{1,})<td#iUs","<tr\\1><td",$text);
$text=preg_replace("#</td>([ |\n|\r\s]{1,})</tr>#iUs","</td></tr>",$text);
$text=preg_replace("#</tr>([ |\n|\r\s]{1,})</table>#iUs","</tr></table>",$text);
return str_replace('"',""",$text);
}
function returntext($text='') {
return preg_replace("/javascript:/i","java script:",preg_replace("/vb script:/i","vb script:",nl2br($text)));
}
}
?> |