Buying Php Job Remote Get file

Discussion in 'Programming' started by caspermz, May 22, 2011.

  1. #1
    Hello i have a filehosting site and thie is my remote get file.

    Currently is not working i want to re code it also when downloading the file is saving it in /tmp/ i want to chose where to save it because my /tmp/ folder is only 2GB and it get full pretty quick.

    So basically recode this file what it should have?,

    -File size check
    -File name check with clean filename

    I will pay 20 bucks by paypal i need this for today basically you have the job done you just have to see the actual file and recode it the best you can.


    <?php $page = "remote";
    
    function get_remote_file_size($url, $readable = true){
       $parsed = parse_url($url);
       $host = $parsed["host"];
       $fp = @fsockopen($host, 80, $errno, $errstr, 20);
       if(!$fp) return false;
       else {
           @fputs($fp, "HEAD $url HTTP/1.1\r\n");
           @fputs($fp, "HOST: $host\r\n");
           @fputs($fp, "Connection: close\r\n\r\n");
           $headers = "";
           while(!@feof($fp))$headers .= @fgets ($fp, 128);
       }
       @fclose ($fp);
       $return = false;
       $arr_headers = explode("\n", $headers);
       foreach($arr_headers as $header) {
    			// follow redirect
    			$s = 'Location: ';
    			if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s)) {
    				$url = trim(substr($header, strlen($s)));
    				return get_remote_file_size($url, $readable);
    			}
    
    			// parse for content length
           $s = "Content-Length: ";
           if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s)) {
               $return = trim(substr($header, strlen($s)));
               break;
           }
       }
       if($return && $readable) {
    			$size = round($return / 1024 / 1024, 2);
    			$return = $size;
       }
       $details = array();
       $details['url'] = $url;
       $details['size'] = $size;
       return $details;
    }
    
    function gen_uid() {
    	$random_id_length = 8;
    	$rnd_id = crypt(uniqid(rand(),1));
    	$rnd_id = strip_tags(stripslashes($rnd_id));
    	$rnd_id = str_replace(".","",$rnd_id);
    	$rnd_id = strrev(str_replace("/","",$rnd_id));
    	$rnd_id = substr($rnd_id,0,$random_id_length);
    	$rnd_id = strtoupper($rnd_id);
    	return $rnd_id;
    }
    
    function cleanfilename($name) {
    	$name = strtolower($name);
    	$name = str_replace(" ", "_", str_replace("%20", "_", $name) );
    	$name = ereg_replace("[^a-z0-9._]", "", $name);
    	if ($name[0] == '.') { // first char is dot
    		$name = "_".$name;
    	}
    	if (!strlen($name)) { // if all chars were stripped out by regex
    		$name = 'uploaded_file';
    	}
    	return $name;
    }	
    
    $user_id = '';
    if ($session->logged_in)
    	$user_id = mysql_real_escape_string($session->username);
    
    if (!empty($_POST['url'])) {
    	if(filter_var($_POST['url'], FILTER_VALIDATE_URL)) {
    		$url = $_POST['url'];
    		$details = get_remote_file_size($url);
    		$url = $details['url'];
    		$size = $details['size'];
    		//$size = 5;
    		if ($size >= 1 && $size < 850) {			
    			define('BUFSIZ', 4095);
    			$file_name = basename($url);
    			$file_name = cleanfilename($file_name);
    			$target = "uploads/".$file_name;
    			$rfile = fopen($url, 'r');
    			$lfile = fopen($target, 'w');
    			while(!feof($rfile)) 
    				fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
    			fclose($rfile);
    			fclose($lfile);				
    			$file_size = filesize($target);
    			
    			if ($file_size < 854857600) {
    				require 'includes/db.php';
    				$file_uid = gen_uid();
    				$file_ip = $_SERVER['REMOTE_ADDR'];
    				
    				if (isset($_POST['mail']) && filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL)) {
    					$mail_id = $_POST['mail'];
    					mysql_query("INSERT INTO file (uid, name, size, utime, ip, mail, url, user_id) VALUES ('$file_uid', '$file_name', '$file_size', NOW(), '$file_ip', '$mail_id', '$url', '$user_id')") or die(mysql_error());
    				}
    				else
    					mysql_query("INSERT INTO file (uid, name, size, utime, ip, url, user_id) VALUES ('$file_uid', '$file_name', '$file_size', NOW(), '$file_ip', '$url', '$user_id')") or die(mysql_error());
    				require 'includes/exec.php';
    				echo '<div id="main-content">
    						<h1 id="page-title">Files Successfully Uploaded</h1>
    						<div id="upload_slots_container">
    							<div class="upfile_label">
    								<span class="upfile_name">Links to Your Uploaded Files:</span>
    							</div>
    							<div class="upfile_label"><span class="upfile_name"><a href="'.$site_url.'/files/'.$file_uid.'/'.$file_name.'">'.$file_name.'</a></span><span title="Success" class="upfile_tick"></span></div>
    						</div>
    					</div><!-- End Main Content -->';
    			}
    			
    			else 
    				echo "File is too big";
    		}
    		else
    			echo "Donload Error/ Error because of file size";
    	}
    	else
    		echo "Invalid URL...";
    }
    
    else {
    ?>
    PHP:
     
    caspermz, May 22, 2011 IP
  2. miroddinz

    miroddinz Active Member

    Messages:
    248
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Please add me on skype miroddinz
     
    miroddinz, May 22, 2011 IP
  3. dazst

    dazst Active Member

    Messages:
    115
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    78
    As Seller:
    100% - 1
    As Buyer:
    100% - 0
    #3
    Already fixed this problem - but you did not pay what you promised.
     
    dazst, May 22, 2011 IP
  4. saddam111

    saddam111 Member

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    hello i have script like this site http://qooy.com
    but page remote.php does not work
    look here http://qooy.com/remote.php
    look here this like my problem
    https://forums.digitalpoint.com/threads/php-job-remote-get-file.2184815/

    if you can fix it this my email :

    I will pay a sum of money
     
    saddam111, May 6, 2013 IP