[Test] PHP image moderation method ..

Source: Internet
Author: User

Alas, a picture moderation method was found on the project all night and quickly went to the server to detect the problem.

 
<?PHP$ Img_exists=Get_headers($ PIC, 1);If(!Empty($ Img_exists)&&$ Img_exists[0] = 'HTTP/1.1 200 OK '&&$ Img_exists['Content-length']! = 18771){$ Model_show. = '$ PIC. '"Width =" 438 "type =" codeph "text ="/codeph "/>';}?>

 

It is strange that it is very slow to go to the server. Previously, the system used file_get_contents to change it to get_header. After the program went online, it was slow.

Baidu curl _ is much faster than get_header. A try is really good.

<? PHP  $ Ch = Curl_init (); //  Start a curl session Curl_setopt ( $ Ch , Curlopt_header, 1 ); //  The returned header area is not displayed. Curl_setopt ( $ Ch , Curlopt_nobody, True  ); Curl_setopt (  $ Ch , Curlopt_returntransfer, True ); Curl_setopt (  $ Ch , Curlopt_url, $ PIC  );  $ HD = Curl_exec ( $ Ch  );  If (! Empty ( $ HD )&&! Strpos ( $ HD , 'Content-length: 18771' )){  $ Model_show . = ' $ PIC . '"Width =" 438 "type =" codeph "text ="/codeph "/>' ;} ?>

The efficiency of recommended getimagesize is also good. However, you can try it if you have time limitations.

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.