Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class curl {
- var $ch, $agent, $error, $info, $cookiefile, $savecookie;
- function curl() {
- $this->agent = $this->get_agent(rand(0,44));
- $this->ch = curl_init();
- curl_setopt ($this->ch, CURLOPT_USERAGENT, $this->agent);
- curl_setopt ($this->ch, CURLOPT_HEADER, 1);
- curl_setopt ($this->ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt ($this->ch, CURLOPT_SSL_VERIFYHOST, 1);
- curl_setopt ($this->ch, CURLOPT_FOLLOWLOCATION,true);
- curl_setopt ($this->ch, CURLOPT_TIMEOUT, 30);
- curl_setopt ($this->ch, CURLOPT_CONNECTTIMEOUT,30);
- }
- function in_string($s,$as) {
- $s=strtoupper($s);
- if(!is_array($as)) $as=array($as);
- for($i=0;$i<count($as);$i++) if(strpos(($s),strtoupper($as[$i]))!==false) return true;
- return false;
- }
- function put($action, $data) {
- curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, "PUT");
- curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($this->ch, CURLOPT_ENCODING, "gzip");
- return $this->getPage($action);
- }
- function http_code() {
- return curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
- }
- function timeout($time){
- curl_setopt ($this->ch, CURLOPT_TIMEOUT, $time);
- curl_setopt ($this->ch, CURLOPT_CONNECTTIMEOUT,$time);
- }
- function ssl($veryfyPeer, $verifyHost){
- curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, $veryfyPeer);
- curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, $verifyHost);
- }
- function header($header) {
- curl_setopt ($this->ch, CURLOPT_HTTPHEADER, $header);
- }
- function ambil($string,$start,$end){
- $str = explode($start,$string);
- $str = explode($end,$str[1]);
- return $str[0];
- }
- function login($user, $pass) {
- curl_setopt ($this->ch, CURLOPT_USERPWD, "$user:$pass");
- }
- function cookies($cookie_file_path) {
- //$fp = fopen($this->cookiefile,'s');
- //fclose($fp);
- $this->cookiefile = $cookie_file_path;
- curl_setopt ($this->ch, CURLOPT_COOKIEJAR, getcwd() . '/' . $this->cookiefile);
- curl_setopt ($this->ch, CURLOPT_COOKIEFILE, getcwd() . '/' . $this->cookiefile);
- }
- function ref($ref) {
- curl_setopt ($this->ch, CURLOPT_REFERER,$ref);
- }
- function socks($sock) {
- curl_setopt ($this->ch, CURLOPT_HTTPPROXYTUNNEL, true);
- curl_setopt ($this->ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- curl_setopt ($this->ch, CURLOPT_PROXY, $sock);
- }
- function post($url, $data) {
- curl_setopt($this->ch, CURLOPT_POST, 1);
- curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);
- return $this->getPage($url);
- }
- function data($url, $data, $hasHeader=true, $hasBody=true) {
- curl_setopt ($this->ch, CURLOPT_POST, 1);
- curl_setopt ($this->ch, CURLOPT_POSTFIELDS, http_build_query($data));
- return $this->getPage($url, $hasHeader, $hasBody);
- }
- function get($url, $hasHeader=true, $hasBody=true) {
- curl_setopt ($this->ch, CURLOPT_POST, 0);
- return $this->getPage($url, $hasHeader, $hasBody);
- }
- function getPage($url, $hasHeader=true, $hasBody=true) {
- curl_setopt($this->ch, CURLOPT_HEADER, false);
- curl_setopt($this->ch, CURLOPT_NOBODY, $hasBody ? 0 : 1);
- curl_setopt ($this->ch, CURLOPT_URL, $url);
- $data = curl_exec ($this->ch);
- $this->error = curl_error ($this->ch);
- $this->info = curl_getinfo ($this->ch);
- return $data;
- }
- function close() {
- unlink($this->cookiefile);
- curl_close ($this->ch);
- }
- function get_agent($z){
- return 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement