Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cof_vip
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
houdong
cof_vip
Commits
25e2af78
Commit
25e2af78
authored
Jan 17, 2022
by
houdong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新文件
parent
9df47da9
Pipeline
#146
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
bom.php
bom.php
+53
-0
No files found.
bom.php
0 → 100644
View file @
25e2af78
<?php
// echo "test";exit;
if
(
isset
(
$_GET
[
'dir'
]))
{
//设置文件目录
$basedir
=
$_GET
[
'dir'
];
}
else
{
$basedir
=
'.'
;
}
$auto
=
1
;
checkdir
(
$basedir
);
function
checkdir
(
$basedir
)
{
if
(
$dh
=
opendir
(
$basedir
))
{
while
((
$file
=
readdir
(
$dh
))
!==
false
)
{
if
(
$file
!=
'.'
&&
$file
!=
'..'
)
{
if
(
!
is_dir
(
$basedir
.
"/"
.
$file
))
{
echo
"filename:
$basedir
/
$file
"
.
checkBOM
(
"
$basedir
/
$file
"
)
.
" <br>"
;
}
else
{
$dirname
=
$basedir
.
"/"
.
$file
;
checkdir
(
$dirname
);
}
}
}
closedir
(
$dh
);
}
}
function
checkBOM
(
$filename
)
{
global
$auto
;
$contents
=
file_get_contents
(
$filename
);
$charset
[
1
]
=
substr
(
$contents
,
0
,
1
);
$charset
[
2
]
=
substr
(
$contents
,
1
,
1
);
$charset
[
3
]
=
substr
(
$contents
,
2
,
1
);
if
(
ord
(
$charset
[
1
])
==
239
&&
ord
(
$charset
[
2
])
==
187
&&
ord
(
$charset
[
3
])
==
191
)
{
if
(
$auto
==
1
)
{
$rest
=
substr
(
$contents
,
3
);
rewrite
(
$filename
,
$rest
);
return
(
"<font color='red'>BOM found, automatically removed.</font>"
);
}
else
{
return
(
"<font color='red'>BOM found.</font>"
);
}
}
else
return
(
"BOM Not Found."
);
}
function
rewrite
(
$filename
,
$data
)
{
$filenum
=
fopen
(
$filename
,
"w"
);
flock
(
$filenum
,
LOCK_EX
);
fwrite
(
$filenum
,
$data
);
fclose
(
$filenum
);
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment