PHP Collection Code-anti-theft chain Collection _php Tutorial

Source: Internet
Author: User
Many novice PHP in the development of their own site collection function will be directly used to file_get_contents to read or fopen, yes, we download the collection function to strengthen a little bit is to each other's anti-theft chain can not prevent the collection function.

Many novice PHP in the development of their own site collection function will be directly used to file_get_contents to read or fopen, yes, we download the collection function to strengthen a little bit is to each other's anti-theft chain can not prevent the collection function.

function Retrieveurlcontentbysocket ($url,
$host = "",
$port = 80,
$timeout =30) {
if ($host = = "") {
if (! ( $pos = Strpos ($url, '://'))) {
return false;
}
$host = substr ($url,
$pos +3,
Strpos ($url, '/', $pos +3)-$pos-3);
$uri = substr ($url, Strpos ($url, '/', $pos +3));
}
else{
$uri = $url;
}

$request = "GET". $uri. " Http/1.0rn "
." Host: ". $host." Rn
." Accept: */*rn "
." User-agent:zealgetrn "
." RN ";
$sHnd = @fsockopen ($host, $port, $errno, $errstr, $timeout);
if (! $sHnd) {
return false;
}


@fputs ($sHnd, $request);

Get Source
$result = "";
while (!feof ($sHnd)) {
$result. = Fgets ($sHnd, 4096);
}
Fclose ($SHND);

$headerend = Strpos ($result, "rnrn");
if (Is_bool ($headerend))
{
return $result;
}
else{
Return substr ($result, $headerend +4);
}


http://www.bkjia.com/PHPjc/445057.html www.bkjia.com true http://www.bkjia.com/PHPjc/445057.html techarticle many novice PHP in the development of their own site collection function will be directly used to file_get_contents to read or fopen Yes, yes, we download the acquisition function to strengthen a little bit is to each other ...

  • 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.