FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tools/get_css_image.php at master · comboyzq/framework · GitHub
comboyzq
framework
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
framework
/
tools
/
get_css_image.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (63 loc) · 1.53 KB
Breadcrumbs
framework
/
tools
/
get_css_image.php
Copy path
File metadata and controls
67 lines (63 loc) · 1.53 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* 此工具可以将css中的图片路径下载到本地
*/
if
(
$
argc
<
5
)
{
echo
"
php
"
.
basename
(
__FILE__
),
"
css文件目录 远程URL 目标文件夹 目标本地路径
\n"
;
exit
;
}
$
dir
=
$
argv
[
1
];
$
remote
=
$
argv
[
2
];
$
dest
=
$
argv
[
3
];
$
csspath
=
$
argv
[
4
];
$
files
=
scandir
(
$
dir
);
foreach
(
$
files
as
$
f
)
{
if
(
substr
(
$
f
, -
4
,
4
) ==
'
.css
'
)
{
parseCssFile
(
$
dir
.
'
/
'
.
$
f
);
}
}
function
parseCssFile
(
$
f
)
{
global
$
remote
,
$
dest
,
$
csspath
;
$
patten
=
'
#url\s*\(\s*(.*)\s*\)#
'
;
$
content
=
file_get_contents
(
$
f
);
$
match
=
array
();
$
n
=
preg_match_all
(
$
patten
,
$
content
,
$
match
);
if
(
$
n
>
0
)
{
foreach
(
$
match
[
1
]
as
$
_m
)
{
$
m
=
trim
(
$
_m
,
"
'
\"
\r\n"
);
if
(
$
m
[
0
] !=
'
/
'
)
{
$
m
=
'
/
'
.
$
m
;
}
$
_fd
=
$
dest
.
$
m
;
$
_fs
=
$
remote
.
$
m
;
if
(!
is_dir
(
dirname
(
$
_fd
)))
{
mkdir
(
dirname
(
$
_fd
),
0777
,
true
);
}
if
(
is_file
(
$
_fd
))
{
echo
"
file exists.[
$
_fd
]
\n"
;
continue
;
}
str_replace
(
$
m
,
$
csspath
.
$
m
,
$
content
);
if
(
copy
(
$
_fs
,
$
_fd
))
{
echo
"
download remote file[
$
_fs
] to [
$
_fd
].
\n"
;
//var_dump($m, $csspath.$m);
}
else
{
echo
"
download fail.file[
$
_fs
] to [
$
_fd
].
\n"
;
}
}
}
file_put_contents
(
$
f
,
$
content
);
echo
"
parse ok. [
$
f
]
\n"
;
}
Back
|
FazBrowse Home
|
New Git URL