Dedecms's dedededown class uses the following function to obtain remote images. it is also valid to pass the previous function when calling the function. However, it is found that the following two calls are blank and the solution cannot be obtained.

Source: Internet
Author: User
The dedecms's dedededown class uses the following functions to obtain remote images. it is also valid when it is called, however, it is found that the following two calls are empty and the dededown class of dedecms cannot be obtained. the Function for obtaining remote images is as follows. it is also valid to pass the call, but the following two statements are blank, the dededown class of dedecms cannot be used to obtain remote images. the following functions are used to obtain remote images. it is also valid when the call is passed. However, it is found that the following two calls are empty and cannot be obtained.
Dedecms's dedededown class uses the following function to obtain remote images. it is also valid to pass the previous function when calling the function. However, the following two statements are found:

Null. cannot be obtained


The function for obtaining remote images is used as follows. it is also valid to pass the previous call. However, the following two statements are blank and cannot be obtained.
$ Htd-> openurl ($ url );

$ Htd-> gethead ("content-type ")

The preceding two statements are empty.


Function getremoteimage ($ url, $ rndtrueName)
{
// Echo $ url; [img] success
$ Revalues = array ();
$ OK = false;
$ Htd = new dedehttpdown ();


$ Htd-> openurl ($ url );
// Echo $ htd-> openurl ($ url );

$ Sparr = array ("image/pjpeg", "image/jpeg", "image/gif", "image/jpg", "image/png ",

"Image/xpng", "image/wbmp ");


If (! In_array ($ htd-> gethead ("content-type"), $ sparr ))
{
Echo "1 ";
Return "";

}


Make_dir (dirname ($ rndtrueName ));
$ Itype = $ htd-> gethead ("content-type ");

$ OK = $ htd-> savetobin ($ rndtrueName );
If ($ OK)
{

$ Data = getimagesize ($ rndtrueName );
$ Revalues [0] = $ rndtrueName;
List (, $ revalues [2], $ revalues [2]) = $ data;
}
$ Htd-> close ();
If ($ OK)
{
Return $ revalues;
}
Return "";
}




// Download an object over Http
Function savetobin ($ savefilename)
{


If (! $ This-> isgetok ())
{

Return false;
}
If (@ feof ($ this-> m_fp ))
{
$ This-> m_error = "The connection has been closed! ";
Return false;
}

$ Fp = fopen ($ savefilename, "w ");
While (! Feof ($ this-> m_fp ))
{
Fwrite ($ fp, fread ($ this-> m_fp, 1024 ));
}
Fclose ($ this-> m_fp );
Fclose ($ fp );
Return true;
}



// Open the specified URL
Function openurl ($ url, $ requestType = "GET ")
{

$ This-> resetany ();
$ This-> JumpCount = 0;
$ This-> m_httphead = array ();
// Print_r ($ this-> m_httphead );
/*
$ Extend = explode (\ ". \", $ url );
$ Va = count ($ extend)-1;
$ Extend [$ va];

$ This-> m_httphead [""] =
*/
$ This-> m_html = "";
$ This-> reTry = 0;
$ This-> close ();

// Initialize the system


$ This-> privateinit ($ url );

$ This-> privatestartsession ();

}

// Start an HTTP session
Function privatestartsession ($ requestType = "GET ")
{
If (! $ This-> privateopenhost ())
{
$ This-> m_error. = "an error occurred while opening the remote host! ";
Return false;
}

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.