daily pastebin goal
54%
SHARE
TWEET

Untitled

a guest Feb 19th, 2013 230 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?
  2.     $base_url=$argv[1]."test.txt";
  3.     $curl=curl_init($base_url);
  4.     $ret=curl_setopt_array($curl,array(CURLOPT_RETURNTRANSFER=>true,CURLOPT_BINARYTRANSFER=>true,CURLOPT_VERBOSE=>false));
  5.     if($ret===FALSE) {
  6.         printf("cURL error: '%s'",curl_error($curl));
  7.         exit;
  8.     }
  9.  
  10.     $buf="deadbeef1337";
  11.     //write buffer to tempfile
  12.     $tmp=tmpfile();
  13.     if($tmp===false) {
  14.         printf("tmpfile failed\n");
  15.         exit;
  16.     }
  17.     fwrite($tmp,$buf);
  18.     fseek($tmp,0);
  19.  
  20.     $ret=curl_setopt_array($curl,array(
  21.         CURLOPT_URL=>$base_url,
  22.         CURLOPT_INFILE=>$tmp,
  23.         CURLOPT_INFILESIZE=>strlen($buf),
  24.         CURLOPT_PUT=>true
  25.     ));
  26.     if($ret===FALSE) {
  27.         printf("cURL error: '%s'",curl_error($curl));
  28.         exit;
  29.     }
  30.  
  31.     printf("Requesting cURL PUT to '%s' for %d bytes\n",$base_url,strlen($buf));
  32.  
  33.     $ret=curl_exec($curl);
  34.  
  35.     if($ret===FALSE) {
  36.         printf("cURL error: '%s'\n",curl_error($curl));
  37.         exit;
  38.     }
  39.  
  40.     fclose($tmp);
  41.  
  42.     $ret=curl_setopt_array($curl,array(
  43.         CURLOPT_URL=>$base_url,
  44.         //          CURLOPT_INFILE=>NULL,
  45.         CURLOPT_INFILESIZE=>0,
  46.         CURLOPT_PUT=>false
  47.     ));
  48.     if($ret===FALSE) {
  49.         printf("cURL error: '%s'",curl_error($curl));
  50.         exit;
  51.     }
  52.  
  53.     printf("Requesting cURL GET from '%s'\n",$base_url);
  54.  
  55.     $ret=curl_exec($curl);
  56.  
  57.     if($ret===FALSE) {
  58.         printf("cURL error: '%s'\n",curl_error($curl));
  59.         exit;
  60.     } else
  61.         printf("Raw data: %s\n",$ret);
  62.  
  63. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top