且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从目录中删除zip文件?

更新时间:2023-12-04 19:53:04

部分,


{


部分。 LocationPath},

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:

statMsg = stat: cannot stat `/www/html/tools/app/images/doom/*.zip*'':
No such file or directory

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

section,


{


section . ''LocationPath''},