问题描述
再一次,我认为我的类方法deleteZip()可以做到这一点,
但是它永远不会删除目录中的任何.zip *文件:
[PHP]
/ **
*删除此相册中的所有潜在ZIP文件。这种方法是由所有列表类继承
以允许
*列表范围内删除潜在服务器创建的ZIP文件以保证安全
用途
*
* @access私人
* @see actual_path
* @see is_class
* /
function& deleteZip(){// STATIC VOID METHOD
global $ section,$ {$ section。 ''LocationPath''},$ projectFullName;
$ album = $ _REQUEST [''album''];
$ locationPath =($ album)? $ {$ section。 LocationPath} / $专辑" :
$ {$ section。 ''LocationPath''};
if(@!is_class($ this-> dbAP,''DBActionPerformer''))$ this-> dbAP =&新的
DBActionPerformer(); //本地实施,除非已经存在
if(!$ _ ENV [''windir'']){// UNIX VERSION
$ statMsg = exec(" stat \\ \\" .actual_path($ locationPath)。" / * .zip * \"
2>& 1"); //使用UNIX检查''stat''用于定位任何ZIP文件,请
删除如果至少找到一个
}否则{// WINDOWS VERSION
list($ lsKommand,$ lsRedirect)=
@array_values($ this-> dbAP-> getKommandOSArray(''ls''));
$ statMsg = exec(" $ lsKommand \"" .actual_path($ locationPath)。
" / * .zip * \" $ lsRedirect");
}
if(@!unlink(actual_path($ locationPath)。''/ *。zip *'')&&
!preg_match (''/没有这样的文件/我',$ statMsg)){// WEB服务器不能
删除ZIP文件
list($ removeKommand,$ removeRedirect)=
@array_values($ this-> dbAP-> getKommandOSArray(''rmdir-force''));
$ msg = exec(" $ removeKommand \\ \\" .actual_path($ locationPath)。
" / * .zip * \" $ removeRedirect"); //允许服务器本身
删除它们
if(preg_match(''/ ^ rm:/ i'',$ msg)||($ _ENV [ ''windir'']&& $ msg))
die(" $ projectFullName由于安全问题而关闭
可能会损坏\中的ZIP文件$ locationPath \,请联系
管理员< p>错误:$ msg");
}
}
[/ PHP]
这就是:
um,对不起但是* * * * * * * * * * $ $ $ $ $ $ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / >
自动生成并且在我执行ls -l时确实存在通过命令行,
0644的权限。
这会有效,请不要,请帮助
比谢谢
phil
Once again, I thought my class method deleteZip() would do the trick,
but it never deletes any .zip* file found in a directory:
[PHP]
/**
* Delete any latent ZIP files found in this album. This method is to
be inherited by all listing classes to allow for
* list-wide deletion of latent server-created ZIP files for security
purposes
*
* @access private
* @see actual_path
* @see is_class
*/
function &deleteZip() {// STATIC VOID METHOD
global $section, ${$section . ''LocationPath''}, $projectFullName;
$album = $_REQUEST[''album''];
$locationPath = ($album) ? "${$section . ''LocationPath''}/$album" :
${$section . ''LocationPath''};
if (@!is_class($this->dbAP, ''DBActionPerformer'')) $this->dbAP =& new
DBActionPerformer();// LOCAL INSTANTIATION UNLESS ALREADY EXISTING
if (!$_ENV[''windir'']) {// UNIX VERSION
$statMsg = exec("stat \"" . actual_path($locationPath) . "/*.zip*\"
2>&1");// USE UNIX CHECK ''stat'' FOR LOCATING ANY ZIP FILES, DO
DELETION IF AT LEAST 1 FOUND
} else {// WINDOWS VERSION
list($lsKommand, $lsRedirect) =
@array_values($this->dbAP->getKommandOSArray(''ls''));
$statMsg = exec("$lsKommand \"" . actual_path($locationPath) .
"/*.zip*\" $lsRedirect");
}
if (@!unlink(actual_path($locationPath) . ''/*.zip*'') &&
!preg_match(''/no such file/i'', $statMsg)) {// WEB SERVER CANNOT
DELETE ZIP FILES
list($removeKommand, $removeRedirect) =
@array_values($this->dbAP->getKommandOSArray(''rmdir-force''));
$msg = exec("$removeKommand \"" . actual_path($locationPath) .
"/*.zip*\" $removeRedirect");// ALLOW FOR THE SERVER ITSELF TO
DELETE THEM
if (preg_match(''/^rm:/i'', $msg) || ($_ENV[''windir''] && $msg))
die("$projectFullName shut down due to security issue with
potentially damaging ZIP file in \"$locationPath\", please contact
administrator<p>Error: $msg");
}
}
[/PHP]
This is what happens:
um, sorry but there *IS* at lease 1 zip file in
/www/html/tools/app/images/doom called images_of_doom.zip that is
auto-generated and does exist when I do "ls -l" via command line,
permissions of 0644.
How do I delete it and any other ZIP file, plain and simple, I thought
this would work and it doesn''t, please help
thanx
phil
这篇关于如何从目录中删除zip文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!