Система за клипове с клипчета от Vbox7.com и YouTube.com

Автор: GodFather2

conf.php

<?php
$user = "user";
$pass = "pass";
$db = "database";
$host = "localhost";
$connection = mysql_connect($host, $user, $pass) or die("Сайтът не може да се свърже към базата данни1");
$db = mysql_select_db($db,$connection)or die("Сайтът не може да се свърже към базата данни2");
$chars="set character set latin1";
mysql_query($chars);
?>

add.php

<?PHP
include('conf.php'); ?><table width="300"><tr><td>
<form method="POST">
URL от vbox7.com или YouTube: <input type="text" name="url"></td></tr><tr><td>
<select name="kategoria">
<option value="">Изберете категория......</option>
<option value="Смях">Забавни</option>
<option value="Музика">Музика</option>
<option value="cars">Коли</option>
<option value="Други">Други</option>
<option value="Новини">Новини</option>
<option value="Erotic">Еротични</option>
</select> <br><input type="submit" class="btn" name="clips" value="Добави">
</form> </td></tr></table>
<?php
if($_POST['clips']){
$video="$_POST[url]";
$pics="$_POST[url]";
$source = file_get_contents($_POST['url']);
$title = explode("<title>", $source);
$title = explode("</title>", $title[1]);
$title=str_replace("YouTube - ","",$title[0]);
$title=iconv('utf-8','windows-1251',urldecode($title));
$imes = "$title";
$video=str_replace("http://youtube.com/watch?v=", "http://cache.googlevideo.com/get_video?video_id=", $video);
$video=str_replace("http://www.youtube.com/watch?v=","http://cache.googlevideo.com/get_video?video_id=", $video);
$url=str_replace("&mode=related&search=", "", $video);
$pics=str_replace("http://youtube.com/watch?v=", "http://img.youtube.com/vi/","$pics");
$pics=str_replace("http://www.youtube.com/watch?v=", "http://img.youtube.com/vi/","$pics/default.jpg");
$pics=str_replace("&mode=related&search=", "", $pics);

$fail = explode(':',$_POST['url']);
$dir = substr($fail[2],0,2);
$source = file_get_contents($_POST['url']);
$title = explode("<title>", $source);
$title = explode("</title>", $title[1]);
$title=str_replace(" / Vbox7","",$title[0]);
$title=iconv('utf-8','windows-1251',urldecode($title));
$ime = "$title";
$clip="http://media.vbox7.com/s/$dir/$fail[2].flv";
$pic="http://i47.vbox7.com/p/$fail[2]3.jpg";
$cat = $_POST['kategoria'];

$number = explode(":", $_POST['url']);
$i = substr($number[2],0 ,2);
$link1 = "http://media.vbox7.com/s/$i/$number[2].flv";
if(@fopen($link1, "r"))
{
$link="$link1";
}
else{
for($x = 2; $x<=5; $x++)
{
$link = "http://media0$x.vbox7.com/s/$i/$number[2].flv";
}
}

$checkurl = mysql_query("SELECT url FROM clips WHERE url='$_POST[url]'");
$checkurl= mysql_num_rows($checkurl);
if ($ime>0) {
echo "Този клип вече е бил добавян";
}
if(eregi('youtube.com',$_POST['url']) && isset($_POST['clips'])){
$query = mysql_query("INSERT INTO `clips` (ime, url, pic, id, kategoria) VALUES('$imes','$url','$pics','NULL','$cat')");
echo "Успешно добави клип от youtube!<br><a href=\"index.php\">Върни се в началната страница</a>";
}
else if(eregi('vbox7.com',$_POST['url']) && isset($_POST['clips'])){
$query = mysql_query("INSERT INTO `clips` (ime, url, pic, id, kategoria) VALUES('$title','$link','$pic','NULL','$cat')");
echo "Успешно добави клип ot vbox!<br><a href=\"index.php\">Върни се в началната страница</a>";?><?
}
}
?>

index.php

<?
include"conf.php";
$pp = "5";
//клипчета на страница
$table = "clips";

$total = mysql_result(mysql_query("SELECT COUNT(id) FROM $table "),0);
$numofpages = $total / $pp;
if (!isset($_GET['page'])) {
$page = 1;
}
else {
$page = $_GET['page'];
}
$limitvalue = $page * $pp - ($pp);


echo"<table align=\"left\" border=\"0\">";

$i="0";
$nared="6";
$query="SELECT * FROM $table ORDER BY id";
$result=mysql_query($query);
while ( $r = mysql_fetch_array( $result )){
$i++;
$width=ceil(100/$nared);
$ime=$r[ime];
$pic=$r[pic];
$klik=$r[klik];
$url=$r[url];
if (strlen($ime)>16)
{$t='...';}
$ime = substr($ime,0,16);
$kat = $r[kategoria];
echo"<td width=\"130\" align=\"center\" border=\"1\" background=\"images/b.gif\">
<a href=\"view.php?id=$r[id]\" onmouseover=\"return overlib('$r[ime]')\" onmouseout=\"return nd();\"><img src=\"$pic\" border=\"0\" width=\"120\" height=\"90\"></div><br><b>$ime$t</a>";
if($kat==""){
echo"<br>Гледан : $klik пъти
<br>Свали : <a href=\"$url\">От Тук</a>
<br>Няма категория<br>";
}else{ echo"
<br>Гледан : $klik пъти
<br>Свали : <a href=\"$url\">От Тук</a>
<br>Категория : <a href=\"cat.php?kategoria=$r[kategoria]\"><b>$kat</a><br>";}
if ($i==$nared)
{
echo "</tr>
<tr>";
$i=0;
}
}
echo"</table>"; ?>

SQL

CREATE TABLE `clips` (
`ime` varchar(255) NOT NULL default '',
`url` varchar(255) NOT NULL default '',
`pic` text NOT NULL,
`id` int(11) NOT NULL auto_increment,
`kategoria` varchar(255) NOT NULL,
`klik` varchar(50) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=547 ;

view.php

<?PHP
include"conf.php";
$query = "SELECT * FROM clips where id='$_GET[id]'";
$result = mysql_query($query);
while($r=mysql_fetch_array($result))
{
$urlz=$r[url];
$url=$r[url];
$ime=$r[ime];
$klik=$r[klik];
$kat=$r[kategoria];
$user=$r[user];


$url1 = "$url";
if(@fopen($url1, "r"))
{
$url="$url1";
}
else{
for($x = 2; $x<=5; $x++)
{
$media="media0$x";
$url1=str_replace('media',$media,$url);

}
if(@fopen($url1, "r"))
{
$url="$url1";
}
else{
for($x = 2; $x<=4; $x++)
{
$media="media0$x";
$url1=str_replace('media05',$media,$url);
}
}
if(@fopen($url1, "r"))
{
$url="$url1";
}
else{
for($x = 2; $x<=3; $x++)
{
$media="media0$x";
$url1=str_replace('media04',$media,$url);
}
}
if(@fopen($url1, "r"))
{
$url="$url1";
}
else{
for($x = 2; $x<=2; $x++)
{
$media="media0$x";
$url1=str_replace('media03',"$media",$url);
}
}
if(@fopen($url1, "r"))
{
$url="$url1";
}
else{
for($x = 2; $x<=1; $x++)
{
$media="media0$x";
$url1=str_replace('media02',$media,$url);
}
}
if(@fopen($url1, "r"))
{
$url="$url1";
}
else{
$url=str_replace('media01','media',$url);
$url=str_replace('media02','media',$url);
$url=str_replace('media03','media',$url);
$url=str_replace('media04','media',$url);
$url=str_replace('media05','media',$url);
}
}
}
?>
<table>
<tr><td align="center"><?PHP echo"$ime"; ?></td></tr><tr><td>
<script type="text/javascript" src="video/js.js"></script>
<div id="fp1"></div><script type="text/javascript">

var fo = new SWFObject("video/video.swf", "v-mania", "400", "320", "9", "#ffffff", true);

fo.addParam("AllowScriptAccess", "never");

fo.addParam("allowFullScreen", "true");


fo.addVariable("config", "{ showPlayListButtons: true, playList: [ { url: '<?="$pic"; ?>', overlayId: 'play' }, { url: '<?="$url";?>' }, { overlayId: 'play' } ], loop: true, initialScale: 'orig', autoBuffering: true, useNativeFullScreen: true }");

fo.write("fp1");

</script><br></td></tr><tr><td class="ss"><?PHP if($kat==""){
echo"Няма категория";
}else{ echo"Категория : <a href=\"cat.php?kategoria=$kat\"><b>$kat</a>";} ?> | Гледания: <?PHP echo"$klik"; ?> | <a href="<?PHP echo"$urlz"; ?>">Свали</a> </td></tr><tr><td align="center">

<?php
include"conf.php";
$chars="set character set latin1";
mysql_query($chars);
$nums = mysql_query("SELECT * FROM `clips` WHERE `id`='$_GET[id]'");
while ($row = mysql_fetch_array($nums)) {
$klik = $row[klik];
$klik++;
$sql = "UPDATE `clips` SET klik='$klik' where id='$row[id]'";
mysql_query($sql);
}
?>

Тва е.. 🙂 ЗАБРАНЯВАМ ПРЕПИСВАНЕТО НА УРОКА В ДРУГИ САЙТОВЕ

Демо за сега немога да дам !

One Reply to “Система за клипове с клипчета от Vbox7.com и YouTube.com”

Вашият коментар