Curl to Uploaded.to

Status
Not open for further replies.
18 comments
With that I scrape last upload:

PHP:
$postdata="id=2705986&pw=password";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
  curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, 'http://uploaded.to/io/login');
$result1 = curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, 'http://uploaded.to/io/me/list/files');
$result2 = curl_exec($ch);
 
#echo str_replace("\n","<br>",$result2);
$arr=json_decode($result2,true);
echo 'http://uploaded.to/file/'.$arr['list']['0']['id'];

So I upload 1 file with ftp and if it's all ok I take link.. Right?
 
Here is my code

PHP:
<?php
/*
 * By hover for wjunction. No rights reserved !
 * 
 */


function ultocookie ($username,$password){
$ch = curl_init("http://uploaded.to/io/login");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies");
$ullogin = array(
    'id'=>$username, 
    'pw'=>$password 
    
);
curl_setopt($ch, CURLOPT_POST,1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $ullogin); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result=curl_exec ($ch);
curl_close($ch);
}
function ultogetfilelink ($file){
$ch = curl_init("http://uploaded.to/io/me/list/files");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies");
$getfilelist = array(
    'page'=>'0', 
    'limit'=>'100',
    'order'=>'date',
    'dir'=>'desc',
    'search'=>''
);
curl_setopt($ch, CURLOPT_POST,1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $getfilelist); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result=curl_exec ($ch);
curl_close($ch);
$result = json_decode ($result,true);
foreach ($result['list'] as $key => $value)
{
    if ($value['filename'] == $file)
        break;
    return $value['id'];
}
}
function ulftp ($file,$username,$password)
{
$name = substr ($file, strripos ($file, "/"));
$curlfscmd ="curl -T ".$file." ftp.ul.to --user ".$username.":".$password;    
$succes = false;
while ($succes === false){ 
system ($curlfscmd,$ftpstatus);
if ($ftpstatus === 0) $succes = true;
    }
//get download link (max 10 attemps, if this limit is reached we consider the upload as failed and re-upload it again
$i = 0;
$succes = false;
while ($succes === false)
{
if ( $i === 10) 
break;
//sleep 30 secs before trying to get download link
sleep (30);
ultocookie($username,$password);
$fileid = ultogetfilelink($name);
unlink ("cookies");
if (isset ($fileid) === true)
{
$succes = true;
  $ulto = 'http://ul.to/'.$fileid.$name;
}
else $i++;
}
return $ulto;
}
?>
How to use?

PHP:
$myultolink = ulftp ('file_path','username','password');
 
I got this error

PHP:
PHP Notice:  Undefined variable: ulto in ul.to.php on line 82

If I check at script that is this line

PHP:
return $ulto;

The script error when tried scrape it but the file uploaded to the server if I checked at my account.
 
still same error message but before that print this is from var_dump =)

PHP:
    [17]=>
    array(11) {
      ["id"]=>
      string(8) "*****"
      ["date"]=>
      string(5) "1 day"
      ["filename"]=>
      string(9) "audio.m4a"
      ["desc"]=>
      NULL
      ["size"]=>
      string(7) "6,71 MB"
      ["admin"]=>
      string(12) "******"
      ["file_extension"]=>
      string(4) ".m4a"
      ["dls"]=>
      string(1) "0"
      ["lastdownload"]=>
      string(12) "no entry yet"
      ["privacy"]=>
      string(0) ""
      ["ddl"]=>
      bool(false)
    }
  }
  ["listopts"]=>
  array(4) {
    ["page"]=>
    int(0)
    ["hasPrevious"]=>
    bool(false)
    ["hasNext"]=>
    bool(false)
    ["maxPage"]=>
    int(1)
  }
}
if I check from http://uploaded.to/io/me/list/files the maxPage should be 18 but from var_dump only until 17
PHP:
{"list":[{"id":"*****","date":"8 Minutes","filename":"ul.to.php","desc":null,"size":"2,19 KB","admin":"****","file_extension":".php","dls":"0","lastdownload":"no entry yet","privacy":"","ddl":false}],"listopts":{"page":0,"hasPrevious":false,"hasNext":true,"maxPage":18}}

 
no, can't find it
after the script upload the file, the scrape seem difficult to find the file until it reach 10 times of 30s :D because it wait very long until the script finish
 
Status
Not open for further replies.
Back
Top