-
-
/* - More & Original PHP Framwork
- Copyright (c) 2007 - 2008 IsMole Inc.
Author: kimi
- Documentation : Download the pictures in the style file, Shuishui’s special peeling tool
- */
//note Set the PHP timeout
- set_time_limit(0);
// note Get the content of the style file
- $styleFileContent = file_get_contents('images/style.css');
//note Match the URL address that needs to be downloaded
- preg_match_all("/url((.* ))/", $styleFileContent, $imagesURLArray);
//note Loop through the addresses to be downloaded and download them one by one
- $imagesURLArray = array_unique($imagesURLArray[1]);
- foreach($ imagesURLArray as $imagesURL) {
- file_put_contents(basename($imagesURL), file_get_contents($imagesURL));
- }
Example 2, modified version:
- set_time_limit (0) ;
- $styleFileContent = file_get_contents ( 'http://img.jbxue.com/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://bbs.it-home.org/'.$imagesURL;
- file_put_contents ( basename ( $imagesURL ), file_get_contents ( $imagesURL ) );
- }< ;/p>
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 ;
- }
- ?>
-
Copy code
|