Advertisement
BinPaste

old-php-curl-test

Nov 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.95 KB | None | 0 0
  1. <?php
  2.  
  3. ini_set('display_errors',1);
  4. error_reporting(E_ALL);
  5.  
  6. function exception_error_handler($severity, $message, $file, $line) {
  7.     if (!error_reporting()) {
  8.         return;
  9.     }
  10.     error_log("$severity, $message, $file, $line");
  11.     $exception = new ErrorException($message, 0, $severity, $file, $line);
  12.     var_dump($exception);
  13.     throw $exception;
  14.     exit();
  15. }
  16. set_error_handler("exception_error_handler");
  17.  
  18.  
  19. $url = 'https://api.wordpress.org/themes/update-check/1.1/';
  20. $r = array (
  21.   "method"=>
  22.    "POST",
  23.   "timeout"=>
  24.   3,
  25.   "redirection"=>
  26.   5,
  27.   "httpversion"=>
  28.    "1.0",
  29.   "blocking"=>
  30.   true,
  31.   "headers"=>
  32.   array(
  33.     "Accept-Encoding"=>
  34.      "deflate;q=1.0, compress;q=0.5, gzip;q=0.5",
  35.     "Content-Type"=>
  36.      "application/x-www-form-urlencoded; charset=UTF-8",
  37.     "Content-Length"=>
  38.     899
  39.   ),
  40.   "body"=>
  41.    "plugins=%7B%22plugins%22%3A%5B%5D%2C%22active%22%3A%5B%5D%7D&translations=%7B%22akismet%22%3A%7B%22en_GB%22%3A%7B%22POT-Creation-Date%22%3A%22%22%2C%22PO-Revision-Date%22%3A%222016-05-12+18%3A04%3A18%2B0000%22%2C%22Project-Id-Version%22%3A%22Stable+%28latest+release%29%22%2C%22X-Generator%22%3A%22GlotPress%5C%2F2.1.0-alpha%22%7D%7D%2C%22woocommerce%22%3A%7B%22en_GB%22%3A%7B%22POT-Creation-Date%22%3A%22%22%2C%22PO-Revision-Date%22%3A%222016-05-18+11%3A04%3A13%2B0000%22%2C%22Project-Id-Version%22%3A%22Stable+%28latest+release%29%22%2C%22X-Generator%22%3A%22GlotPress%5C%2F2.1.0-alpha%22%7D%7D%2C%22wp-super-cache%22%3A%7B%22en_GB%22%3A%7B%22POT-Creation-Date%22%3A%22%22%2C%22PO-Revision-Date%22%3A%222016-05-09+15%3A03%3A03%2B0000%22%2C%22Project-Id-Version%22%3A%22Stable+%28latest+release%29%22%2C%22X-Generator%22%3A%22GlotPress%5C%2F2.1.0-alpha%22%7D%7D%7D&locale=%5B%22en_GB%22%5D&all=true",
  42.   "cookies"=>
  43.   array(),
  44.   "user-agent"=>
  45.    "WordPress/4.5.2; https://www.domain.con/wordpress",
  46.   "reject_unsafe_urls"=>
  47.   false,
  48.   "compress"=>
  49.   false,
  50.   "decompress"=>
  51.   true,
  52.   "sslverify"=>
  53.   false,
  54.   "sslcertificates"=>
  55.    dirname(__FILE__)."/wordpress/wp-includes/certificates/ca-bundle.crt",
  56.   "stream"=>
  57.   false,
  58.   "filename"=>
  59.   NULL,
  60.   "limit_response_size"=>
  61.   NULL,
  62.   "_redirection"=>
  63.   5,
  64.   "ssl"=>
  65.   true,
  66.   "local"=>
  67.   false
  68. );
  69.  
  70. $handle = curl_init();
  71.  
  72. $timeout = (int) ceil( $r['timeout'] );
  73. $ssl_verify = isset($r['sslverify']) && $r['sslverify'];
  74. curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout );
  75. curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout );
  76. curl_setopt( $handle, CURLOPT_URL, $url);
  77. curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true );
  78. curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, ( $ssl_verify === true ) ? 2 : false );
  79. curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify );
  80. curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, false );
  81. curl_setopt( $handle, CURLOPT_POST, true );
  82. curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] );
  83. curl_setopt( $handle, CURLOPT_HEADER, false );
  84. $res = curl_exec( $handle );
  85. var_dump($res);
  86. $a = curl_errno( $handle );
  87. var_dump($a);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement