Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.34 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class curl
  5. {
  6.     private $options;
  7.     public $errno;
  8.     public $errmsg;
  9.     public $content;
  10.     public $headers;
  11.     public $httpcode;
  12.  
  13.     public function __construct()
  14.     {
  15.         global $config;
  16.         $this->options = array(
  17.             CURLOPT_RETURNTRANSFER => true,
  18.             CURLOPT_FOLLOWLOCATION => true,
  19.             CURLOPT_SSL_VERIFYHOST => 2,
  20.             CURLOPT_SSL_VERIFYPEER => false,
  21.             CURLOPT_TIMEOUT => 10,
  22.             CURLOPT_AUTOREFERER => true,
  23.             CURLOPT_COOKIEFILE => $config['cookie_file'],
  24.             CURLOPT_COOKIEJAR => $config['cookie_file']);
  25.     }
  26.  
  27.     public function setopt($key, $val)
  28.     {
  29.         eval('$opt = CURLOPT_' . strtoupper($key) . ';');
  30.         $this->options[$opt] = $val;
  31.     }
  32.  
  33.     public function removeopt($key)
  34.     {
  35.         switch (strtolower($key))
  36.         {
  37.             case 'post':
  38.                 unset($this->options[CURLOPT_POST]);
  39.                 unset($this->options[CURLOPT_POSTFIELDS]);
  40.                 break;
  41.             case 'sock5':
  42.                 unset($this->options[CURLOPT_HTTPPROXYTUNNEL]);
  43.                 unset($this->options[CURLOPT_PROXY]);
  44.                 unset($this->options[CURLOPT_PROXYTYPE]);
  45.                 break;
  46.             default:
  47.                 eval('$opt = CURLOPT_' . strtoupper($key) . ';');
  48.                 unset($this->options[$opt]);
  49.         }
  50.     }
  51.  
  52.     public function sock5($sock)
  53.     {
  54.         $this->options[CURLOPT_HTTPPROXYTUNNEL] = true;
  55.         $this->options[CURLOPT_PROXY] = $sock;
  56.         $this->options[CURLOPT_PROXYTYPE] = CURLPROXY_SOCKS5;
  57.     }
  58.  
  59.     public function ref($ref)
  60.     {
  61.         $this->options[CURLOPT_REFERER] = $ref;
  62.     }
  63.  
  64.     public function httpheader($headers)
  65.     {
  66.         $this->options[CURLOPT_HTTPHEADER] = $headers;
  67.     }
  68.  
  69.     public function cookies($cookies)
  70.     {
  71.         $this->options[CURLOPT_COOKIE] = $cookies;
  72.         $this->removeopt('cookiefile');
  73.         $this->removeopt('cookiejar');
  74.     }
  75.  
  76.     public function header($val = false)
  77.     {
  78.         $this->options[CURLOPT_HEADER] = $val;
  79.     }
  80.  
  81.     public function nobody($val = false)
  82.     {
  83.         $this->options[CURLOPT_NOBODY] = $val;
  84.     }
  85.  
  86.     public function ua($ua)
  87.     {
  88.         $this->options[CURLOPT_USERAGENT] = $ua;
  89.     }
  90.  
  91.     public function postdata($postdata)
  92.     {
  93.         if (is_array($postdata))
  94.         {
  95.             $post_array = array();
  96.             foreach ($postdata as $key => $value)
  97.             {
  98.                 $post_array[] = urlencode($key) . '=' . urlencode($value);
  99.             }
  100.             $post_string = implode('&', $post_array);
  101.         } else
  102.         {
  103.             $post_string = $postdata;
  104.         }
  105.         $this->options[CURLOPT_POST] = true;
  106.         $this->options[CURLOPT_POSTFIELDS] = $post_string;
  107.     }
  108.  
  109.     public function page($url)
  110.     {
  111.         $ch = curl_init($url);
  112.         curl_setopt_array($ch, $this->options);
  113.         $this->content = curl_exec($ch);
  114.         $this->errno = curl_errno($ch);
  115.         $this->errmsg = curl_error($ch);
  116.         $this->headers = curl_getinfo($ch);
  117.         $this->httpcode = $this->headers['http_code'];
  118.         curl_close($ch);
  119.         $this->removeopt('post');
  120.     }
  121.  
  122.     public function validate()
  123.     {
  124.         if ($this->errno)
  125.         {
  126.             return false;
  127.         }
  128.         return true;
  129.     }
  130.  
  131.     public function display($m, $t = 1, $d = 0)
  132.     {
  133.         if ($t == 1)
  134.         {
  135.             echo '<div>' . $m . '</div>';
  136.         } else
  137.         {
  138.             echo $m;
  139.         }
  140.         if ($d)
  141.         {
  142.             exit;
  143.         }
  144.     }
  145. }
  146.  
  147. set_time_limit(0);
  148. $dir = dirname(__file__);
  149. $config['cookie_file'] = $dir . '/cookies/MoreArt_' . md5($_SERVER['REMOTE_ADDR']) .
  150.     '_ebay.txt';
  151.  
  152. if (!file_exists($dir . '/cookies/index.html'))
  153. {
  154.     $f = fopen($dir . '/cookies/index.html', 'w');
  155.     fwrite($f, 'Fuck You ^_^');
  156.     fclose($f);
  157. }
  158.  
  159. if (!file_exists($config['cookie_file']))
  160. {
  161.     delete_cookies();
  162. }
  163.  
  164. function delete_cookies()
  165. {
  166.     global $config;
  167.     $f = fopen($config['cookie_file'], 'w');
  168.     fwrite($f, '');
  169.     fclose($f);
  170. }
  171.  
  172. function get($list)
  173. {
  174.     preg_match_all("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}/", $list, $socks);
  175.     return $socks[0];
  176. }
  177.  
  178. function xflush()
  179. {
  180.     static $output_handler = null;
  181.     if ($output_handler === null)
  182.     {
  183.         $output_handler = @ini_get('output_handler');
  184.     }
  185.     if ($output_handler == 'ob_gzhandler')
  186.     {
  187.         return;
  188.     }
  189.     flush();
  190.     if (function_exists('ob_flush') and function_exists('ob_get_length') and
  191.         ob_get_length() !== false)
  192.     {
  193.         @ob_flush();
  194.     } else
  195.         if (function_exists('ob_end_flush') and function_exists('ob_start') and
  196.             function_exists('ob_get_length') and ob_get_length() !== false)
  197.         {
  198.             @ob_end_flush();
  199.             @ob_start();
  200.         }
  201. }
  202. function getCookies($str){
  203.     preg_match_all('/Set-Cookie: ([^; ]+)(;| )/si', $str, $matches);
  204.     $cookies = implode(";", $matches[1]);
  205.     return $cookies;
  206. }
  207. function fetch_value($str, $find_start = '', $find_end = '')
  208. {
  209.     if ($find_start == '')
  210.     {
  211.         return '';
  212.     }
  213.     $start = strpos($str, $find_start);
  214.     if ($start === false)
  215.     {
  216.         return '';
  217.     }
  218.     $length = strlen($find_start);
  219.     $substr = substr($str, $start + $length);
  220.     if ($find_end == '')
  221.     {
  222.         return $substr;
  223.     }
  224.     $end = strpos($substr, $find_end);
  225.     if ($end === false)
  226.     {
  227.         return $substr;
  228.     }
  229.     return substr($substr, 0, $end);
  230. }
  231.  
  232. function array_remove_empty($arr)
  233. {
  234.     $narr = array();
  235.     while (list($key, $val) = each($arr))
  236.     {
  237.         if (is_array($val))
  238.         {
  239.             $val = array_remove_empty($val);
  240.             // does the result array contain anything?
  241.             if (count($val) != 0)
  242.             {
  243.                 // yes :-)
  244.                 $narr[$key] = trim($val);
  245.             }
  246.         } else
  247.         {
  248.             if (trim($val) != "")
  249.             {
  250.                 $narr[$key] = trim($val);
  251.             }
  252.         }
  253.     }
  254.     unset($arr);
  255.     return $narr;
  256. }
  257.  
  258. function display($m, $t = 1, $d = 0)
  259. {
  260.     if ($t == 1)
  261.     {
  262.         echo '<div>' . $m . '</div>';
  263.     } else
  264.     {
  265.         echo $m;
  266.     }
  267.     if ($d)
  268.     {
  269.         exit;
  270.     }
  271. }
  272. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement