PHP implementation of Network album picture Anti-theft chain perfect hack method, _php tutorial

Source: Internet
Author: User

PHP implementation of the network album picture Anti-Theft chain perfect crack method,


This article describes the PHP implementation of the network album picture Anti-Theft chain perfect crack method. Share to everyone for your reference. Specific as follows:

Network album pictures anti-theft chain hack program-PHP version of this anti-theft chain cracked version can be perfect to crack the current more popular: Baidu album, NetEase album, 360 I like the site pictures. Can also implement a simple picture anti-theft chain. Because this class is the first to get the remote picture, and then send the picture to the client, so it is the transfer of two traffic. Therefore, the space flow will be wasted, next, will develop the cache function, so you can achieve savings in traffic!

<?php/** * Network album image Anti-theft chain hack program-PHP version * * Use: * * HTTP://YOURDOMAIN/URL.PHP?URL=HTTP://HIPHOTOS.BAIDU.C om/verdana/pic/item/baidupicture.jpg&referer= * URL refers to the need to crack the image URL, and Referer is to be compatible with some do not need to set the routing domain name to display the album, such as 360 I like the net, You must set the route to empty to browse normally.    So, at this time should be set referer 1 * * @author Snow Fox Blog * @version 1.0 * @since July, * @URL http://www.xuehuwang.com */class Frivoller {/** * HTTP version Number (1.0, 1.1), Baidu is using version 1.1 * * @var String */protecte     D $version;     /** * Data in response to HTTP requests * * @var string format */protected $body;     /** * need to get the remote URL * * @var string format * */protected $link;      /** * An array, containing any of the various, the URL.     * * @var Array */protected $components;     /** * HTTP request when host data * * @var String */protected $host;      /** * The path of required file.   * (e.g. '/verdana/abpic/item/mygirl.png ') * * @var string   */protected $path;     /** * The HTTP referer, extra it from original URL * * @var String */protected $referer;     /** * The HTTP method, ' get ' for default * * @var String */protected $method = ' get ';     /** * The HTTP port, for default * * @var int */protected $port = 80;     /** * Timeout period on a stream * * @var int */protected $timeout = 100;     /** * The filename of image * * @var String */protected $filename;      /** * The ContentType of image file.     * Image/jpeg, Image/gif, image/png, image * * @var String */protected $contentType;      /** * Frivoller Constructor * * @param string $link */Public function __construct ($link, $referer = ")      {$this->referer = $referer;       Parse the HTTP link $this->parselink ($link); Begin to fetch the image $stream = Pfsockopen ($thisHost, $this->port, $errno, $errstr, $this->timeout);         if (! $stream) {header ("Content-type: $this->contenttype;");       echo $this->curlget ($link);         }else{fwrite ($stream, $this->buildheaders ());         $this->body = "";        $img _size = Get_headers ($link, true);           while (!feof ($stream)) {$this->body. = Fgets ($stream, $img _size[' content-length ']);        Fwrite ($jpg, Fread ($stream, $img _size[' content-length '));         } $content = Explode ("\r\n\r\n", $this->body, 2);        $this->body = $content [1];          Fclose ($stream); Send ' ContentType ' header for saving the this file correctly//If the CT is not sent, an error occurred while trying to save the picture (800700DE)//Floc         K, Firefox does not have this problem, Opera did not test the header ("Content-type: $this->contenttype;");        Header ("cache-control:max-age=315360000");            Echo $this->body;       Save Picture//file_put_contents (' hello.jpg ', $this->body);   } }/** * Compose HTTP Request Header * * @return String */Private Function buildheaders () {       $request = "$this->method $this->path http/1.1\r\n";       $request. = "Host: $this->host\r\n";      $request. = "Accept-encoding:gzip, deflate\r\n"; $request. = "user-agent:mozilla/5.0 (Windows; U Windows NT 6.0; ZH-CN;    rv:1.9.0.1) gecko/2008070208 firefox/3.0.1\r\n ";       $request. = "content-type:image/jpeg\r\n";       $request. = "Accept: */*\r\n";       $request. = "keep-alive:300\r\n";       $request. = "Referer: $this->referer\r\n";       $request. = "cache-control:max-age=315360000\r\n";       $request. = "connection:close\r\n\r\n";     return $request;         }/** * Strip initial header and filesize info * * Private function Extractbody (& $body) { The status of link if ($body, ' Strpos ') > 0) {//Strip header $endpos = Strpos ($body,         "\r\n\r\n"); $body = suBSTR ($body, $endpos + 4);       Strip filesize at nextline $body = substr ($body, Strpos ($body, "\ r \ n") + 2);       }}/** * Extra the HTTP URL * * @param $link */Private Function Parselink ($link) {       $this->link = $link;       $this->components = Parse_url ($this->link);       $this->host = $this->components[' host ');       $this->path = $this->components[' path '); if (Empty ($this->referer)) {$this->referer = $this->components[' scheme ']. '://' .       $this->components[' host '];      }elseif ($this->referer = = ' 1 ') {$this->referer = ';       } $this->filename = basename ($this->path);       Extract the content type $ext = substr (STRRCHR ($this->path, '. '), 1);       if ($ext = = ' jpg ' or $ext = = ' jpeg ') {$this->contenttype = ' image/pjpeg ';       } elseif ($ext = = ' gif ') {$this->contenttype = ' image/gif ';   }    ElseIf ($ext = = ' png ') {$this->contenttype = ' image/x-png ';       } elseif ($ext = = ' bmp ') {$this->contenttype = ' image/bmp ';       } else {$this->contenttype = ' Application/octet-stream ';       }}//Crawl Web content function Curlget ($url) {$url = Str_replace (' & ', ' & ', $url);       $curl = Curl_init ();       curl_setopt ($curl, Curlopt_url, $url);       curl_setopt ($curl, Curlopt_header, false);       curl_setopt ($curl, Curlopt_referer, $url); curl_setopt ($curl, Curlopt_useragent, "mozilla/4.0 (compatible; MSIE 6.0; seaport/1.2; Windows NT 5.1; SV1;       infopath.2) ");       curl_setopt ($curl, Curlopt_cookiejar, ' cookie.txt ');       curl_setopt ($curl, Curlopt_cookiefile, ' cookie.txt ');       curl_setopt ($curl, Curlopt_returntransfer, 1);       curl_setopt ($curl, curlopt_followlocation, 0);       $values = curl_exec ($curl);       Curl_close ($curl);     return $values;  }}/** * get root domain * * @author lonely * @create 2011-3-11 * @version 0.11 * @lastupdate lonely * @package Sl */class rootdomain{private static    $self;    Private $domain =null;    Private $host =null;    Private $state _domain;    Private $top _domain;        /** * Get Domain name Analysis instance * Enter description here ... */public static function Instace () {if (!self:: $self)      Self:: $self =new self ();    Return self:: $self; } public Function __construct () {$this->state_domain=array (' al ', ' dz ', ' af ', ' ar ', ' ae ', ' aw ', ' om ', ' az ', ' eg ') , ' et ', ' ie ', ' ee ', ' ad ' ao ', ' ai ', ' ag ', ' at ', ' au ', ' Mo ', ' BB ', ' pg ', ' BS ', ' PK ', ' py ', ' ps ', ' bh ', ' pa ', ' BR ', ' by ', ' BM ', ' BG ' , ' MP ', ' BJ ', ' be ', ' is ', ' PR ', ' ba ', ' pl ', ' bo ', ' BZ ', ' bw ', ' BT ', ' BF ', ' bi ', ' bv ', ' KP ', ' gq ', ' dk ', ' de ', ' tl ', ' TP ', ' TG ', ' DM ' , ' Do ', ' ru ', ' ec ', ' er ', ' fr ', ' fo ', ' pf ', ' gf ', ' tf ', ' va ', ' ph ', ' fj ', ' fi ', ' CV ', ' FK ', ' GM ', ' CG ', ' CD ', ' Co ', ' Cr ', ' GG ', ' GD ' , ' GL ', ' ge ', ' cu ', ' GP ', ' gu ', ' Gy ', ' KZ ', ' ht ', ' kr ', ' nl ', ' an ', ' HM ', ' hn ', ' ki ', ' DJ ', ' kg ', ' gn ', ' GW ', ' CA ', ' gh ', ' ga ', ' kh ' , ' CZ ', ' ZW ', ' cm ', ' QA ', ' ky ', ' km ', ' CI ', ' kw ', ' cc ', ' hr ', ' ke ', ' ck ', ' lv ', ' ls ', ' la ', ' lb ', ' lt ', ' LR ', ' ly ', ' Li ', ' re ', ' Lu ', ' rw ', ' ro ', ' mg ', ' im ', ' mv ', ' Mt ', ' MW ', ' my ', ' ml ', ' mk ', ' MH ', ' MQ ', ' yt ', ' mu ', ' Mr ', ' US ', ' um ', ' as ', ' VI ', ' mn ', ' Ms ', ' BD ', ' PE ', ' FM ', ' mm ', ' MD ', ' Ma ', ' MC ', ' Mz ', ' mx ', ' nr ', ' np ', ' ni ', ' ne ', ' ng ', ' nu ', ' No ', ' nf ', ' na ', ' za ', ' aq ', ' GS ', ' EU ', ' pw ', ' pn ', ' pt ', ' JP ', ' se ', ' ch ', ' SV ', ' ws ', ' Yu ', ' sl ', ' SN ', ' cy ', ' SC ', ' sa ', ' cx ', ' st ', ' sh ', ' kn ', ' LC ', ' sm ', ' pm ', ' VC ', ' lk ', ' sk ', ' si ', ' sj ', ' sz ', ' SD ', ' SR ', ' SB ', ' so ', ' TJ ', ' tw ', ' th ', ' tz ', ' to ', ' TC ', ' TT ', ' tn ', ' TV ', ' tr ', ' TM ', ' TK ', ' wf ', ' vu ', ' GT ', ' ve ', ' bn ', ' ug ', ' ua ', ' uy ', ' Uz ', ' es ', ' eh ', ' gr ', ' HK ', ' SG ', ' NC ', ' NZ ', ' Hu ', ' sy ', ' JM ', ' am ', ' ac ', ' ye ', ' iq ', ' ir ', ' il ', ' it ', ' in ', ' id ', ' UK ', ' VG ', '      Io ', ' Jo ', ' vn ', ' zm ', ' je ', ' TD ', ' GI ', ' cl ', ' CF ', ' cn ', ' yr '); $this->top_domain=array (' com ', ' arpa ', ' edu ', ' gov ', ' int ', ' mil ', ' net ', ' org ', ' biz ', ' info ', ' pro ', ' name ', ' museum '      , ' Coop ', ' aero ', ' xxx ', ' idv ', ' Me ', ' mobi ');    $this->url=$_server[' Http_host '];  }/** * Set URL * Enter description here ... * @param string $url   * * Public Function SetUrl ($url =null) {$url = $url? $url: $this->url;      if (empty ($url)) return $this;      if (!preg_match ("/^http:/is", $url)) $url = "http://". $url;      $url =parse_url (Strtolower ($url));      $urlarr =explode (".", $url [' Host ']);      $count =count ($urlarr);      if ($count <=2) {$this->domain= $url [' Host '];        }else if ($count >2) {$last =array_pop ($urlarr);        $last _1=array_pop ($urlarr); if (In_array ($last, $this->top_domain)) {$this->domain= $last _1. '.          $last;        $this->host=implode ('. ', $urlarr);          }else if (In_array ($last, $this->state_domain)) {$last _2=array_pop ($urlarr); if (In_array ($last _1, $this->top_domain)) {$this->domain= $last _2. '. $last _1.            $last;          $this->host=implode ('. ', $urlarr);            }else{$this->host=implode ('. ', $urlarr). $last _2; $this->domain= $last _1.          $last; }}} REturn $this;    }/** * Get domain name * Enter description here ... */public Function GetDomain () {return $this->domain;    }/** * Get host * Enter description here ... */public Function gethost () {return $this->host; }} $referer = Array (' xuehuwang.com ', ' zangbala.cn ', ' qianzhebaikou.net ', ' sinaapp.com ', ' 163.com ', ' sina.com.cn ', '  Weibo.com ', ' abc.com '); Get the URL, maybe you should check the given URL if (isset ($_get[' url ')) and $_get[' URL ']! = ') {//Get the route domain $ Site = (isset ($_server[' http_referer ')) &&!empty ($_server[' http_referer '])?  $_server[' http_referer ': '; Whether the match is a picture link if (Preg_match ('/(HTTP|HTTPS|FTP|RTSP|MMS):(\/\/|\\\\) {1} ((\w) +[.]) {1,} ([a-za-z]| [0-9] {1,3}) (\s*\/) ((\s) +[.] {1} (gif|jpg|png|bmp))        /I ', $_get[' url ')) {if (!empty ($site)) {$tempu = Parse_url ($site);        $host = $tempu [' Host '];        $root = new Rootdomain ();        $root->seturl ($site); if (In_array ($root->getdomain (), $refeRER) {$img _referer = (isset ($_get[' referer ') &&!empty ($_get[' Referer '])) trim ($_get[' referer ']): ";         New Frivoller ($_get[' url '), $img _referer); }}else{$img _referer = (isset ($_get[' referer ') &&!empty ($_get[' Referer '])) trim ($_get[' referer '))        : '';       New Frivoller ($_get[' url '), $img _referer); }}}?>

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/1024917.html www.bkjia.com true http://www.bkjia.com/PHPjc/1024917.html techarticle PHP Implementation of the network album picture Anti-Theft chain perfect crack method, this article describes the PHP implementation of the network album picture Anti-Theft chain perfect method. Share to everyone for your reference. Specific as ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.