@@ -117,8 +117,7 @@ function start()
117
117
'file ' => $ this ->url2file ($ v ),
118
118
'isDownload ' => false
119
119
)
120
- ),
121
- array (
120
+ ), array (
122
121
$ this ,
123
122
'onProcess '
124
123
));
@@ -170,15 +169,15 @@ function onProcess($r, $args)
170
169
$ doParse = ! $ args ['isDownload ' ];
171
170
// Download file may need to be parsed.
172
171
if (! $ doParse && ! isset ($ args ['type ' ]) &&
173
- false !== strpos ($ r ['info ' ]['content_type ' ], 'text/html ' )) {
172
+ false !== strpos ($ r ['info ' ]['content_type ' ], 'text/html ' )) {
174
173
$ r ['body ' ] = file_get_contents ($ args ['file ' ]);
175
174
$ doParse = true ;
176
175
}
177
176
if ($ doParse ) {
178
177
$ r ['body ' ] = trim ($ r ['body ' ]);
179
178
while (substr ($ r ['body ' ], 0 , 3 ) ===
180
- chr (239 ) . chr (187 ) . chr (191 )) {
181
- $ r ['body ' ] = substr ($ r ['body ' ], 3 );
179
+ chr (239 ) . chr (187 ) . chr (191 )) {
180
+ $ r ['body ' ] = substr ($ r ['body ' ], 3 );
182
181
}
183
182
$ r ['body ' ] = $ this ->htmlEncode ($ r ['body ' ]);
184
183
$ urlCurrent = $ r ['info ' ]['url ' ];
@@ -293,7 +292,7 @@ function onProcess($r, $args)
293
292
$ v = pq ($ v );
294
293
$ href = $ v ->attr ('href ' );
295
294
if (empty ($ href ) ||
296
- strtolower (substr (ltrim ($ href ), 0 , 11 )) == 'javascript: ' ) {
295
+ strtolower (substr (ltrim ($ href ), 0 , 11 )) == 'javascript: ' ) {
297
296
continue ;
298
297
}
299
298
$ url = $ this ->uri2url ($ href , $ urlCurrent );
@@ -304,8 +303,7 @@ function onProcess($r, $args)
304
303
} else {
305
304
$ urlParse [$ url ] = array ();
306
305
}
307
- $ v ->attr ('href ' ,
308
- $ this ->url2src ($ url , $ urlCurrent , true ));
306
+ $ v ->attr ('href ' , $ this ->url2src ($ url , $ urlCurrent , true ));
309
307
} else {
310
308
$ v ->attr ('href ' ,
311
309
$ this ->url2src ($ url , $ urlCurrent , false ));
@@ -361,11 +359,10 @@ function onProcess($r, $args)
361
359
'isDownload ' => $ isDownload
362
360
)
363
361
);
364
- $ this ->getCurl ()->add ($ item ,
365
- array (
366
- $ this ,
367
- 'onProcess '
368
- ));
362
+ $ this ->getCurl ()->add ($ item , array (
363
+ $ this ,
364
+ 'onProcess '
365
+ ));
369
366
}
370
367
}
371
368
}
@@ -394,6 +391,7 @@ protected function parseLinks(&$content, $urlCurrent)
394
391
'/\s*url\(( \'|")?(.+?) \\1?\)/i '
395
392
);
396
393
foreach ($ patterns as $ pattern ) {
394
+ $ matches = [];
397
395
preg_match_all ($ pattern , $ content , $ matches );
398
396
if (! empty ($ matches [2 ])) {
399
397
if (! is_array ($ matches [2 ])) {
@@ -408,10 +406,9 @@ protected function parseLinks(&$content, $urlCurrent)
408
406
}
409
407
$ ext = pathinfo (parse_url ($ v , PHP_URL_PATH ),
410
408
PATHINFO_EXTENSION );
411
- if (in_array ($ ext ,
412
- array (
413
- 'css '
414
- ))) {
409
+ if (in_array ($ ext , array (
410
+ 'css '
411
+ ))) {
415
412
$ vUrl = array (
416
413
'type ' => 'css '
417
414
);
@@ -502,7 +499,7 @@ public function url2uri($url, $urlCurrent)
502
499
$ arr2 = explode ('/ ' , rtrim ($ path2 , '/ ' ));
503
500
}
504
501
$ path = '../ ' ;
505
- foreach ($ arr2 as $ v ) {
502
+ for ($ v = 0 ; $ v < count ( $ arr2 ); $ v ++ ) {
506
503
$ path .= '../ ' ;
507
504
}
508
505
$ path .= $ path1 ;
@@ -528,7 +525,7 @@ protected function url2file($url)
528
525
}
529
526
if (file_exists ($ file )) {
530
527
if (! isset ($ this ->expire ) ||
531
- time () - filemtime ($ file ) < $ this ->expire ) {
528
+ time () - filemtime ($ file ) < $ this ->expire ) {
532
529
$ file = null ;
533
530
}
534
531
}
@@ -594,10 +591,9 @@ protected function getPath($url)
594
591
"lpt9 "
595
592
);
596
593
}
597
- $ invalidNameReplace = array_map (
598
- function ($ v ) {
599
- return '_ ' . $ v ;
600
- }, $ invalidName );
594
+ $ invalidNameReplace = array_map (function ($ v ) {
595
+ return '_ ' . $ v ;
596
+ }, $ invalidName );
601
597
$ path = str_replace ($ invalid , '- ' , $ path );
602
598
$ path = str_replace ($ invalidName , $ invalidNameReplace , $ path );
603
599
return $ path ;
@@ -693,7 +689,7 @@ protected function fixPath($path)
693
689
} else {
694
690
if (in_array ($ pathArr ['extension ' ], $ this ->htmlExt )) {
695
691
$ path = rtrim ($ pathArr ['dirname ' ], ' / ' ) . '/ ' .
696
- $ pathArr ['filename ' ] . '.html ' ;
692
+ $ pathArr ['filename ' ] . '.html ' ;
697
693
}
698
694
}
699
695
return $ path . $ query . $ fragment ;
0 commit comments