I have been using PHP for a long time.

Source: Internet
Author: User
Why are there too many attacks in PHP? When g was just getting started then :? Php Cute cute $ picSizearray (100_1001, 200_1001); $ imagePath .. image; functionparseUrl ($ url) {preg_match ((? Pname [ G networksWhen g then when else:


// Just give me a try.
$ PicSize = array (
'1970 _ 100' => 1,
'2017 _ 000000' => 1
);
$ ImagePath = "../image /";
Function parseUrl ($ url ){
Preg_match ("/(? P [\ W \ d] +) _ w (? P \ D +) _ h (? P \ D + )\.(? P \ W +)/", $ url, $ match );
Return $ match;
}
$ UrlArr = explode ("/", $ _ SERVER ['request _ URI ']);
$ ImgName = $ urlArr [count ($ urlArr)-1];
$ PicInfo = parseUrl ($ imgName );
// Please try again
If (empty ($ picInfo ['width']) | empty ($ picInfo ['height']) |
! Array_key_exists ($ picInfo ['width']. '_'. $ picInfo ['height'], $ picSize) die ');
$ OriginalPic = $ imagePath. $ picInfo ['name']. '/'. $ picInfo ['name']. '.'. $ picInfo ['ext '];
// When a sentence is reported
If (! File_exists ($ originalPic) die ("Zookeeper ");
/**
* Why are there too many other users? BR>*/
Switch ($ picInfo ['ext ']) {
Case 'jpg ':
$ OrgImg = ImageCreateFromJpeg ($ originalPic );
Break;
Default:
Break;
}
$ Owidth = ImageSX ($ orgImg ); // Please try again
$ Oheight = ImageSY ($ orgImg );
$ TW = $ picInfo ['width'];
$ TH = $ picInfo ['height'];
// When the peak traffic is reached, why are you afraid? BR>If ($ owidth/$ oheight> $ tW/$ tH ){
$ TH = intval ($ tW * $ oheight/$ owidth );
} Else {
$ TW = intval ($ tH * $ owidth/$ oheight );
}
// What is the cause? BR>$ New_img = ImageCreateTrueColor ($ picInfo ['width'], $ picInfo ['height']);
$ BgColor = imagecolorallocate ($ new_img, 255,255,255 );
If (! @ Imagefilledrectangle ($ new_img, 0, 0, $ picInfo ['width']-1, $ picInfo ['height']-1, $ bgColor )){
Echo "too many slow response ?; // @ Todo logging board
Exit (0 );
}
If (! @ Imagecopyresampled ($ new_img, $ orgImg, ($ picInfo ['width']-$ tW)/2, ($ picInfo ['height']-$ tH)/2, 0, 0, $ tW, $ tH, $ owidth, $ oheight )){
Echo ";
Exit (0 );
}
// Skip
Ob_start ();
Imagejpeg ($ new_img );
$ _ NewImg = ob_get_contents ();
Ob_end_clean ();
File_put_contents ($ imagePath. $ picInfo ['name']. "/". $ imgName, $ _ newImg );
Header ("Content-type: image/jpeg; charsets = utf-8 ");
Imagejpeg ($ new_img );
?>


When does the cross-region authentication fail? When enterror 404 was reached andler, how was it? BR>

Too many g has been too many :? Php // why? $ picSize = array ('2017 _ 000000' = 1, '2017 _ 000000' = 1 ); $ imagePath = ".. /image/"; function parseUrl ($ url) {preg_match ("/(? Pname [\...

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.