<?php
$sRootPath
= dirname(
__FILE__
);
$dir
=
$sRootPath
.DIRECTORY_SEPARATOR.'upload';
$iTimeLine
=
strtotime
(
"-7 day"
);
$sHandDate
=
date
(
"Ymd"
);
$sLogDir
= dirname(
__FILE__
).DIRECTORY_SEPARATOR.'Imglog';
$sLog
=
$sLogDir
.DIRECTORY_SEPARATOR.
$sHandDate
.'.txt';
if
(!
file_exists
(
$sLogDir
))
mkdir
(
$sLogDir
, 0777,true);
_clearFile(
$dir
,
$iTimeLine
,
$sLog
);
$sEnd
= 'AT'.
"\\t"
.
date
(
"Y-m-d H:i:s"
).
"\\t"
.'
EXEC
OVER'.
"\\n"
;
echo
$sEnd
;
error_log
(
$sEnd
, 3,
$sLog
);
function
_clearFile(
$sPath
,
$iTimeLine
,
$sLog
){
if
(
is_dir
(
$sPath
)){
$fp
= opendir(
$sPath
);
while
(!false == (
$fn
= readdir(
$fp
))){
if
(
$fn
== '.' ||
$fn
=='..')
continue
;
$sFilePath
=
$sPath
.DIRECTORY_SEPARATOR.
$fn
;
_clearFile(
$sFilePath
,
$iTimeLine
,
$sLog
);
}
}
else
{
if
(
$sPath
!= '.' &&
$sPath
!= '..'){
$iLastView
=
fileatime
(
$sPath
);
if
(
$iLastView
<
$iTimeLine
){
if
(@unlink(
$sPath
) === true){
$str
=
date
(
"Y-m-d H:i:s"
).
"\\t"
.'success del file :'.'['.
$sPath
.']'.
"\\n"
;
error_log
(
$str
, 3,
$sLog
);
}
}
}
}
}
?>