• 05-01-2013, 23:06:09
    #1
    Bi'tane scriptim var, flv ve resimleri alıp ftp'ye kayıt ediyor, sorna da mysql'e yazıyor.

    ama zamandan tasarruf etmek için sadece 30mb'ın altındaki videoları download ediyorum.

    videoları alt alta sıralayıp yanlarına dosya boyutlarını yazdırıyorum, 30mb'tan ufak ise indiriyor ve mysql'e yazıyor.

    ama asıl sorun şu: eğer şarta uyuyorsa ftpye çektikten sonra diğer dosyaya sıra gelince dosya boyutunu bi' önceki dosya boyutu ile aynı gösteriyor. dolayısı ile belki de 100mb olan dosya 30mb'tan az olarak görünüyor ve inmeye başlıyor

    kodlar burada:

    for($i=0; $i<$say; $i++){ 
    	$gelen=$m1[$i][1]; 
    	$ekle=$gelen; 
    	 
    	$ilk = rand(10,59);
    	$iki = rand(10,59);
    	
    			$cekkat=mysql_query("SELECT * FROM kat ORDER  BY RAND() limit 1");
    				while($veri=mysql_fetch_array($cekkat))
    						{
    						$nos=$veri['tr'];
    						$nos2=$veri['title'];
    
    						}
    				$kategori = $nos;
    				$seo = cevir(str_replace($tr,$eng,$gelen));
    				$title = str_replace($tr,$eng,$gelen);
    				$suresi = $ilk.":".$iki;
    				$aciklama = $title;
    				$thumb = "http://www.hedefsite.com/".$ekle2;
    				$cek = "http://www.hedefsite.com/".$gelen; 
    				$site2 = file_get_contents($cek);
    			
    							echo "<table border=\"1\"><td>".$i."Adres: ".$cek."<br />";
    							echo "Baslik: ".$title."<br />";
    							echo "Aciklama: ".$aciklama."<br />";
    							echo "Kategori: ".$kategori."<br />";
    							echo "Suresi: ".$suresi."<br />";
    							$flv = ara("'file','", "'", $site2);
    							$video = "http://www.hedefsite.com/".$flv[0];
    							$image = ara("'image',\"", "\"", $site2);
    							echo "FLV: ".$video."<br />";
    							echo "Thumb: ".$image[0]."<br />";
    							echo "Tags: ".$title."<br />";
    							echo "Seo: ".$seo."<br />";
    							echo "Tagsbaslik: ".$title."<br />";
    							echo "TRtag: ".$seo."<br />";
    														// URL to file (link)
    														$files = $video;
    
    														$ch22 = curl_init($files);
    														curl_setopt($ch22, CURLOPT_NOBODY, true);
    														curl_setopt($ch22, CURLOPT_RETURNTRANSFER, true);
    														curl_setopt($ch22, CURLOPT_HEADER, true);
    														curl_setopt($ch22, CURLOPT_FOLLOWLOCATION, true);
    
    														$data = curl_exec($ch22);
    														curl_close($ch22);
    
    														if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
    
    															// Contains file size in bytes
    															$contentLength = (int)$matches[1];
    														}
    							echo "Boyut: ".$contentLength."<br>";
    																	
    
    								
    						
    						if ($contentLength<31457280)
    						{
    						
    														$kontrol2=mysql_query("select * from ... where seo='$seo'");
    														if(mysql_num_rows($kontrol2)==0)
    														{
    
    														$rand =substr(md5(uniqid(rand())),0,30);
    														$dosya_adi2 = $rand.".jpg";
    														$dosya_adi = $rand.".flv";
    
    													/*
    														$chi = curl_init($video);
    														$fpi = fopen("../files/$dosya_adi", "w");
    														curl_setopt($chi, CURLOPT_REFERER, "http://www.hedefsite.com/"); 
    														curl_setopt($chi, CURLOPT_FOLLOWLOCATION, true); 
    														curl_setopt($chi, CURLOPT_FILE, $fpi); 
    														curl_setopt($chi, CURLOPT_HEADER, 0); 
    														curl_exec($chi); 
    														curl_close($chi); 
    														fclose($fpi);
    
    
    														$chi2 = curl_init($image[0]);
    														$fpi2 = fopen("../files/$dosya_adi2", "w");
    														curl_setopt($chi2, CURLOPT_REFERER, "http://www.hedefsite.com/"); 
    														curl_setopt($chi2, CURLOPT_FILE, $fpi2); 
    														curl_setopt($chi2, CURLOPT_HEADER, 0); 
    														curl_exec($chi2); 
    														curl_close($chi2); 
    														fclose($fpi2);*/
    
    														$thumb2 = "http://www.benimsite.com/files/".$dosya_adi2;
    														$flv2 = "http://www.benimsite.com/files/"".$dosya_adi;
    
    														//mysql_query("insert into ... (...) values (...) ");
    														//mysql_query("insert into ... (...) values (...) ");
    														echo "Video basariyla eklendi.</td></table><br />";
    														}else{
    														echo "Video mevcut.</td></table><br />";
    														}
    						
    						}else{
    						
    						echo "Video boyutu uygunsuz.</table><br />";
    						
    						}
     }

    Umarım yeterince açıklayıcı olabilmişimdir. Niye böyle bi' sorun verir ki?

    --R10.NET; Flood Engellendi -->-> Yeni yazılan mesaj 23:06:09 -->-> Daha önceki mesaj 22:58:42 --

    EDİT:

    30MB'ın altında bir tane video ekledikten sonra diğer videoya geçince şu iki tane hatayı veriyor ve eski videonun boyutu ile aynı gösteriyor:

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxx/public_html/xxx/u.php on line 71
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxx/public_html/xxx/u.php on line 126

    Bahsi geçen satırlar:
    while($veri=mysql_fetch_array($cekkat))

    ve

    if(mysql_num_rows($kontrol2)==0)
  • 05-01-2013, 23:19:45
    #2
    if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {

    // Contains file size in bytes
    $contentLength = (int)$matches[1];
    }

    Eger preg_match bulunamadi dondururse, contentLength i duzenleyecek bir girisim yok. Bir onceki dongu elemaninin set settigi contentLength kalir. Sorun orda mi bilemiyorum ama bir else ile contentLength i unset edebilirsin veya kontrol edebilirsin.

    Ayrica zamandan pek tasarruf etmiyorsun cunku boyutu ogrenebilmek icin zaten dosyayi curl ile aciyorsun. acmisken kayit et sadece boyutu ogrenmek icin http socket acip content length i gordugun an soketi kapatman gerekiyor.