As a veteran and professional Mr Skinner staff, I have accumulated a wealth of Mr Skinner experience since I began to invest in the great Internet from third day. I believe that every programmer who does the web will have a similar experience.
In the Mr Skinner process, it is essential to download the picture in the style file. When you encounter a larger style file, which may have hundreds of images to download, it is most appropriate to use this little code.
Copy the Code code as follows:
< PHP
/*
More & Original PHP framwork
Copyright (c) 2007-2008 Ismole Inc.
Author:kimi
Documentation: Download the picture in the style file, water special Mr Skinner tool
*/
Note Set PHP timeout time
Set_time_limit (0);
Note Get style file content
$styleFileContent = file_get_contents (' images/style.css ');
Note matches the URL address that needs to be downloaded
Preg_match_all ("/url\ (. *) \)/", $styleFileContent, $imagesURLArray);
Note loops need to download the address, download it individually
$imagesURLArray = Array_unique ($imagesURLArray [1]);
foreach ($imagesURLArray as $imagesURL) {
File_put_contents (basename ($imagesURL), file_get_contents ($imagesURL));
}
The above is reproduced in the original text, the following is a revised version, reproduced the words please leave a link.
Copy the Code code as follows:
!--? php set_time_limit (0);
$styleFileContent = file_get_contents (' http://img.jb51.net/skin/newblue/main.css ');
Preg_match_all ("/url\ (. *) \)/", $styleFileContent, $imagesURLArray);
$imagesURLArray = Array_unique ($imagesURLArray [1]);
foreach ($imagesURLArray as $imagesURL) {
$dir =dirname ($imagesURL);
if (!file_exists ($dir))
{
//Create directory
Createdir ($dir);
}
$imagesURL = ' http://www.jb51.net/'. $imagesURL;
File_put_contents (basename ($imagesURL), file_get_contents ($imagesURL));
}
Function Createdir ($path) {
$path = str_replace (' \ \ ', '/', $path);
if (Is_dir ($path)) return true;
if (file_exists ($path)) return false;
$parent = substr ($path, 0, Strrpos ($path, '/'));
if ($parent = = = ' | | $parent = = = '. ' | | createdir ($parent))
return @mkdir ($path);
Else return false;
}
?>
The above describes the download Photoshop software with PHP implementation of the download CSS files in the image of the code, including the download of Photoshop software content, I hope to be interested in PHP tutorial friends helpful.