Merhaba,
Bos vaktim'de yazmis oldugum bbcode sinifimi sizlerle paylasmaya karar verdim.
Suanda
5 video sitesi destekliyor ve daha fazla eklenebilir.
Youtube kullanimi :
[youtube]H7rhMqTQ4WI[/youtube]
Dailymotion kullanimi :
[dailymotion]x1hksy[/dailymotion]
Vimeo kullanimi :
[vimeo]24386643[/vimeo]
Izlesene kullanimi :
[izlesene]7139646[/izlesene]
Vidivodo kullanimi :
[vidivodo]BFRFRlpBWVAT[/vidivodo]
Sinif & Örnek Kullanimi :
/**
Coded by Kingofseo
Date : 14.12.2013
**/
class bbcode{
protected $param;
/**
Build the __construct()
@return null;
**/
public function __construct($param){
$this->param=$param;
return null;
}
/**
Build the function apply_bb()
@return $getir;
**/
public function apply_bb(){
Switch(true){
Case (strstr($this->param,"[youtube]") && strstr($this->param,"[/youtube]")):
$getir=preg_replace('/\[youtube](.*?)\[\/youtube\]/i','<iframe width="640" height="390" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>',$this->param);
break;
Case (strstr($this->param,"[dailymotion]") && strstr($this->param,"[/dailymotion]")):
$getir=preg_replace('/\[dailymotion](.*?)\[\/dailymotion\]/i','<iframe width="640" height="390" src="http://www.dailymotion.com/embed/video/$1" frameborder="0" allowfullscreen></iframe>',$this->param);
break;
Case (strstr($this->param,"[vimeo]") && strstr($this->param,"[/vimeo]")):
$getir=preg_replace('/\[vimeo](.*?)\[\/vimeo\]/i','<iframe width="640" height="390" src="//player.vimeo.com/video/$1" frameborder="0" allowfullscreen></iframe>',$this->param);
break;
Case (strstr($this->param,"[izlesene]") && strstr($this->param,"[/izlesene]")):
$getir=preg_replace('/\[izlesene](.*?)\[\/izlesene\]/i','<iframe width="640" height="390" src="http://www.izlesene.com/embedplayer/$1" frameborder="0" allowfullscreen></iframe>',$this->param);
break;
Case (strstr($this->param,"[vidivodo]") && strstr($this->param,"[/vidivodo]")):
$getir=preg_replace('/\[vidivodo](.*?)\[\/vidivodo\]/i','<embed src="http://www.vidivodo.com/VideoPlayerShare.swf?u=$1" type="application/x-shockwave-flash" wmode="window" bgcolor="#090909" width="640" height="390" allowScriptAccess="always" allowfullscreen="true" ></embed>',$this->param);
break;
Default:
return false;
break;
}
return $getir;
}
}
$bbcode=new bbcode("[vidivodo]BFRFRlpBWVAT[/vidivodo]");
echo $bbcode->apply_bb();Form Kullanimi :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>Kingofseo BBcode uygulamasi</title>
</head>
<body>
<?php
if($_POST){
$bbcode=trim($_POST["bbcode"]);
if(!empty($bbcode)){
$bbcode=new bbcode($bbcode);
if(false===$bbcode->apply_bb()) echo "<b> Site bulunamadi ! </b>";
echo $bbcode->apply_bb();
}else{
echo "<b> Lütfen BBkodunu giriniz ! </b>";
}
}
?>
<form action="class.bbcode.php" method="POST">
<b> BBkodu (örnek : [vidivodo]BFRFRlpBWVAT[/vidivodo] ) </b> : <input type="text" name="bbcode" <?php echo !empty($_POST["bbcode"]) ? 'value="'.trim($_POST["bbcode"]).'"' : null;?>>
<input type="submit" value="Gönder !">
</form>
</body>
</html>Güle Güle kullanin ve yararli olmasi dilegiyle.