5 die( "faltan argumentos! $argv[0] URL EXP PREFIX\n" );
11 preg_match( '|(https?://)?(.*/)([^/]+)?|i', $url, $m );
12 $urlbasepath = ( empty( $m[1] ) ? 'http://' : $m[1] ) . ( empty( $m[2] ) ? '' : $m[2] );
13 preg_match( '|https?://[^/]*|i', $urlbasepath, $m );
16 $file = join( '', file( $url, 'r' ) );
19 die( "No se pudo abrir $url\n" );
21 preg_match_all( '|href="?(([^"]*/)?([^"/]+))"?|i', $file, $m, PREG_SET_ORDER );
23 foreach ( $m as $link ) {
24 list( $href, $url, $path, $file ) = $link;
25 if ( file_exists( "$prefix$file" ) and filesize( "$prefix$file" ) )
27 if ( preg_match( "|$exp|i", $url ) ) {
28 if ( preg_match( '|http://|i', $url ) )
30 elseif ( preg_match( '|^/|i', $url ) )
31 $arch = "$urlbase$path$file";
33 $arch = "$urlbasepath$path$file";
34 $fi = fopen( $arch, 'r' );
35 $fo = fopen( "$prefix$file", 'w' );
36 echo "Bajando $arch ";
37 while ( $fi and !feof( $fi ) ) {
38 fputs( $fo, fread( $fi, 4096 ) );