PHP implementation of the network album Picture anti-theft chain Perfect crack method _php skills

Source: Internet
Author: User
Tags curl explode php programming string format

This article describes the implementation of the PHP network photo album anti-theft chain Perfect Way to crack. Share to everyone for your reference. Specifically as follows:

Network photo album anti-theft chain crack Procedures-PHP version of this anti-theft chain cracked version can be perfect to crack the current more popular: Baidu albums, NetEase albums, 360 I like the site pictures. can also achieve a simple picture anti-theft chain. Because this class is to get the remote image first, and then send the picture to the client, so that is carried out two traffic flow. Therefore, will waste space flow, next, will develop the caching function, this can realize saves the traffic!

<?php/** * Network photo album anti-theft chain crack Procedures-PHP version * * Use method: * * * http://yourdomain/url.php?url=http://hiphotos. baidu.com/verdana/pic/item/baidupicture.jpg&referer= * Where the URL refers to the need to crack the picture URL, and Referer is to be compatible with some do not need to set the routing name to display the album, For example 360 I like the net, must set the antecedents to be empty to be able to browse normally. Therefore, you should set Referer to 1 * * @author Snow Fox Blog * @version 1.0 * @since July, * @URL http://www.xuehuwang.c   
   Om/class Frivoller {/** * HTTP version Number (1.0, 1.1), Baidu is using version 1.1 * * @var string   
  * * protected $version;   
  /** * Data in response to HTTP request * * @var string format/protected $body;   
  /** * need to get the remote URL * * * @var string format/protected $link;   
   /** * An array that containing any of the various components of the URL.   
  * * @var array/protected $components;   
  /** * HTTP Request 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, $refere  
    R= ') {$this->referer = $referer;   
   Parse the HTTP link $this->parselink ($link); Begin to fetch the image $stream = Pfsockopen ($this->host, $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 this file correctly///If no CT is sent, IE7 error (800700DE)/Fl when trying to save the picture   
      Ock, Firefox does not have this problem, Opera does not test 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 Buildheade   
    RS () {$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 (Strpos ($body, ' OK ') > 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;  
 /** * Obtains root domain name * * @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; The 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 ', ' being ', ' 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 '  
    , ' IDs ', ' 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 =n  
    ull) {$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->doma  
  In;  
  /** * 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 ', ' Weib  
O.com ', ' abc.com ');  
  Get the URL, maybe your should check the given URL if (isset ($_get[' url ') and $_get[' url ']!= ') {//Acquire the routing name $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[' r Eferer '])?  
        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 will help you with your PHP programming.

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.