private static function get_curl_binary(){
      	$size = self::getRemoteFileSize(self::$flv_url);
		if($size == 0){
			OC_ocDownloaderPB::setError($l->t('Filesize is null'));
			exit();
		}
		$chunkSize = self::getChunkSize($size);
	
	    self::$fp = fopen(self::$flv_url, 'rb');
		$received = $last = 0;
		
	    while(!feof(self::$fp)){
	        $data = @fread(self::$fp, $chunkSize);
	        if($data == ''){
	        	break;
	        }
			$saved = fwrite(self::$fs, $data);
			if($saved > -1){
				$received += $saved;
			}
			if($received >= $size){
                $percent = 100;
            }else{
                $percent = @round(($received/$size)*100, 2);
            }
			if($received > $last + $chunkSize){
				OC_ocDownloaderPB::setProgressBarProgress($percent);
				$last = $received;
			}
			usleep(100);
	    }
		OC_ocDownloaderPB::setProgressBarProgress(100);
		OC_ocDownloader::setUserHistory(self::$final_flv_filename, 1);
		
		fclose(self::$fp);fclose(self::$fs);
    }
Exemplo n.º 2
0
	<body>
		<?php
		OC_ocDownloaderPB::init();
		echo '<div style="width:99%;">';
		OC_ocDownloaderPB::render();
		echo '</div>';
		OC_ocDownloaderPB::setText($l->t('Prepare download ...'));
		
		$pr = urldecode(trim($_GET['p']));
		$url = urldecode(trim($_GET['u']));
		$ow = urldecode(trim($_GET['o']));
		
		if(strcmp(substr($url,0,7), 'http://') != 0 && strcmp(substr($url,0,8), 'https://') != 0){
			$url = 'http://'.$url;
		}

		$purl = parse_url($url);
		if(!isset($purl['query'])){
			OC_ocDownloaderPB::setError($l->t('Provide a good URL !'));
		}else{
			if(strcmp(substr($purl['query'],0,2),'v=') != 0){
				OC_ocDownloaderPB::setError($l->t('Provide a good URL !'));
			}else{
				$filename = substr($purl['query'],2) . '.flv';
				OC_ocDownloaderYT::init($url, $filename, 0, $ow);
			}
		}
		?>
	</body>
</html>