<? include "db.php";
$kat = @$_GET['kat']; if ($kat=="") {$kat = 1;} 
$aranan = str_replace(" ","+",@$_REQUEST['aranan']);
if ($aranan=="") {$aranan = 'galatasaray';}

	$sayfa = @$_GET['siralama'];
	if ($sayfa=="") {$sayfa=1;} else {$sayfa = @$_GET['siralama'];}?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>İzle6.com Youtube Botu</title>
</head>
<br />
<br />
<br />
<center>
<form action="?arama=sonuclari" method="post">

<table width="600" border="1">
  <tr>
    <th scope="row" width="100">Aranacak Kelime</th>
    <td align="center" width="175"><input  style="background-color:#000; color:#FFF" value="<?=@$_REQUEST['aranan'];?>" size="50" name="aranan" type="text" /></td>
    <td align="center" width="25"><input name="Ara" type="submit" value="Ara" /></td>
  </tr>

  </table><br />

</table><table width="600" border="1">
  <tr>
    <th scope="row" width="100">Eklenecek Kategori</th>
    <td align="center" width="175"> <select onchange="window.open(this.options[this.selectedIndex].title,'_top')" style="background-color:#000; color:#FFF" name="kat">
   
<?php 
$sql=mysql_query("select * from kategoriler");
while ($goster=mysql_fetch_array($sql)){
	$katid = $goster['id']
?>
<option <? if(@$_GET['kat']==$katid) {echo 'selected=selected';}?>  title="?arama=sonuclari&aranan=<?=$aranan;?>&siralama=<?=$sayfa;?>&kat=<?=$goster['id'];?>" value="<?php echo $goster['id'];?>"><?php echo $goster['kat_adi'];?></option>
<?php } ?>
</select></td>
    <td align="center" width="25"></td>
  </tr>
 
</table>
</form>




<? 

//bot kodları
	
if (@$_GET['arama']=='sonuclari') {
$site = file_get_contents("http://www.youtube.com/results?search_query=$aranan&page=$sayfa"); ?>
<h3>Arama Sonuçları "<?=$aranan;?>"</h3>


<div align="right">
<form action="?arama=sonuclari&aranan=<?=$aranan;?>&siralama=<?=$sayfa;?>&kat=<?=$kat;?>&ekle=videolar" method="post">
<input name=""  style="width:300px; height:50px; background-color:#000; color:#FFF; margin-right:200px;" value="Seçilileri Ekle" type="submit" />
</div>

<?

for ($i=1;$i<=15;$i++) {
// video başlık

$a = explode('<ol id="search-results" class="result-list context-data-container">',$site);
$title1 = explode('data-context-item-title="',$a[1]);
$title2 = explode('"',$title1[$i]);



// video aciklama alma

$desc1 = explode('<p class="yt-lockup2-description" dir="ltr">',$a[1]);
$desc2 = explode('</p>',$desc1[$i]);

// video sure alma

$sure1 = explode('data-context-item-time="',$a[1]);
$sure2 = explode('"',$sure1[$i]);


// video resim

$r1 = explode('src="',$a[1]);
$r2 = explode('"',$r1[$i]);



// video url alma

$url1 = explode('data-context-item-id="',$a[1]);
$url2 = explode('"',$url1[$i]);



?>


<table width="1000" border="1">
  <tr>
   <th scope="row">Seç</th>
    <th scope="row">Video Resim</th>
    <td ><b>Video Başlığı</b></td>
    <td><b>Video Süresi</b></td>
     <td><b>Video Açıklama</b></td>
      <td><b>Video Url</b></td>
  </tr>
  <tr>
   <td align="center" width="50"><input name="veriler[]" type="checkbox" value="<?=$i;?>" checked /></td>
    <th scope="row" width="175"><img width="175" height="100" src="http://i2.ytimg.com/vi/<?=$url2[0];?>/mqdefault.jpg" /></th>
    <td width="200"><?=$title2[0]; ?></td>
    <td width="50"><?=$sure2[0];?></td>
     <td width="500"><?=$desc2[0];?></td> 
    <td width="150"><a target="_blank" href="http://youtube.com/watch?v=<?=$url2[0];?>">Video Link</a></td>
  </tr>

</table>
<br/>



<? } ?>

<div align="right">

<input name=""  style="width:300px; height:50px; background-color:#000; color:#FFF; margin-right:200px; margin-top:-15px;" value="Seçilileri Ekle" type="submit" /></form>
</div>
<table align="left" style="margin-left:200px; margin-top:-50px;" width="400" border="1">
  <tr>
    <th scope="row">Sayfa</th>
  
  <td><a href="?arama=sonuclari&aranan=<?=$aranan;?>&siralama=<?=$sayfa-1;?>&kat=<?=$kat;?>">   <b style="color:#F00;" ><< Önceki Sayfa</b></a></td>
      <td><a href="?arama=sonuclari&aranan=<?=$aranan;?>&siralama=<?=$sayfa+1;?>&kat=<?=$kat;?>">  <b style="color:#F00;" > Sonraki Sayfa >></b></a></td>
  </tr>

</table><br />
<? } ?>


</center>
<body>
</body>
</html>




<?php

  if(@$_REQUEST['ekle']=='videolar') {

foreach ($veriler as $veri => $id) {

// video başlık

$a = explode('<ol id="search-results" class="result-list context-data-container">',$site);
$title1 = explode('data-context-item-title="',$a[1]);
$title2 = explode('"',$title1[$id]);



// video aciklama alma

$desc1 = explode('<p class="yt-lockup2-description" dir="ltr">',$a[1]);
$desc2 = explode('</p>',$desc1[$id]);

// video sure alma

$sure1 = explode('data-context-item-time="',$a[1]);
$sure2 = explode('"',$sure1[$id]);


// video resim

$r1 = explode('src="',$a[1]);
$r2 = explode('"',$r1[$id]);



// video url alma

$url1 = explode('data-context-item-id="',$a[1]);
$url2 = explode('"',$url1[$id]);
			
	
	$videoadi = $title2[0];
	$video_embed = 'http://youtube.com/watch?v='.$url2[0].'';
	$video_resim = 'http://i2.ytimg.com/vi/'.$url2[0].'/mqdefault.jpg';
	$content = file_get_contents($video_resim);
	$filename = rand(0, 999999);
	$handle = fopen('../videores/'.$filename.'.jpg', 'w+');
	fwrite($handle, $content);
	$video_sure = $sure2[0];
	$video_aciklama = $desc2[0];
	
	
	  
		
	
		
		 if(!$videoadi=="" || !$video_resim=="" ||!$video_embed=="")
		 {
			 
		
		 
		 $db_yaz	= mysql_query("insert into videolar (video_adi,video_embed,resimcek,video_sure,video_aciklama,video_etiket,video_kat)
		 values('$title2[0]','$video_embed','$filename','$video_sure','$video_aciklama','$video_aciklama','$kat')")or die( mysql_error()); 
		}}}
		
		   if(@$_REQUEST['ekle']=='videolar') {
		
		
/*	echo '<script language="javascript" type="text/javascript">';
	echo "alert('Başarı ile Eklendi');";
  echo '</script>'; */
		
			
			?>
            
           <meta http-equiv="refresh" content="1;URL=youtube.php?arama=sonuclari&aranan=<?=$aranan;?>&siralama=<?=$sayfa+1;?>&kat=<?=$kat;?>&ekle=videolar">
<? }  ?>












