묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
웹 파일매니저사용중 # 문자가 들어간 파일이 지워지질 않습니다.
2003.08.01 06:42
test#test.zip 이라는 파일이 지워지질 않네요
계속 아래의 오류 메세지가 출력이 됩니다.
Warning: unlink() failed (No such file or directory) in /home/Freehosting/heosang/www/test/dp.php on line 123
아래는 에러가 나는 123번 부근입니다.
elseif($delete) // if the delete button was pressed
{
// delete the file
unlink($path.$delete); =====>123번 라인입니다.
}
테스트 하실분은 아래 링크를 눌러주세요
http://hosting.bcpark.net/~heosang/test/dp.php
여기에는 중요한 파일 없으니까 마음껏 지우시고, 테스트 해보셔도 됩니다.
php소스를 다운받아 보시고 싶으신 분은 아래것을 받으세요
http://hosting.bcpark.net/~heosang/dp.zip
=============아래는 QTO File Manager의 소스입니다.===============================
<?php
/* QTOFileManagerLite 1.0
*
*Copyright (C) 2001 Quentin O'Sullivan <quentin@qto.com> All rights reserved.
*Web Site: http://www.qto.com/fm
*
*This program is free software; you can redistribute it and/or
*modify it under the terms of the GNU General Public License
*as published by the Free Software Foundation; either version 2
*of the License, or (at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program; if not, write to the Free Software
*Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
************************************************************************
*/
// set these configuration variables
$user = ""; // change this to the username you would like to use. leave it empty if you dont want to use authentication
$pass = "";
$MaxFileSize = "20000000"; // max file size in bytes
$HDDSpace = "100000000"; // max total size of all files in directory
$HiddenFiles = array(".htaccess"); // add any file names to this array which should remain invisible
$EditOn = 1; // make this = 0 if you dont want the to use the edit function at all
$EditExtensions = array("htm","html","txt"); // add the extensions of file types that you would like to be able to edit
/********************************************************************/
$ThisFileName = basename(__FILE__); // get the file name
$path = str_replace($ThisFileName,"",__FILE__); // get the directory path
if($login)
{
if(!($u == $user && $password == $pass))
{
$msg = "<font face='Verdana, Arial, Hevetica' size='2' color='#ff0000'>The login details were incorrect</font><br><br>";
$loginfailed = 1;
}
}
if(($user == $u || $user == "") && $edit) // if an edit link was clicked
{
$fp = fopen($path.$edit, "r");
$oldcontent = fread($fp, filesize($path.$edit));
fclose($fp);
$filemanager = <<<content
<center>
<table border="0" cellspacing="0" cellpadding="20" bgcolor="#eeeeee">
<tr>
<td>
<font face="Verdana, Arial, Hevetica" size="4" color="#333333"><b>FILE MANAGER</b></font><br>
<form name="form1" method="post" action="$PHP_SELF">
<center>
<textarea name="newcontent" cols="35" rows="15">$oldcontent</textarea>
<br>
<br>
<input type="submit" name="save" value="Save">
<input type="submit" name="cancel" value="Cancel">
<input type="hidden" name="u" value="$u">
<input type="hidden" name="savefile" value="$edit">
</center>
</form>
</td>
</tr>
</table>
</center>
content;
}
elseif(($user == $u || $user == "") && !$loginfailed)
{
if($save) // if the save button was pressed on the edit screen
{
$newcontent = stripslashes($newcontent);
$fp = fopen($path.$savefile, "w");
fwrite($fp, $newcontent);
fclose($fp);
}
$HDDTotal = dirsize($path); // get the total size of all files in the directory including any sub directorys
if ($upload) // if the upload button was pressed
{
if($HTTP_POST_FILES['uploadedfile']['name']) // if a file was actually uploaded
{
$HTTP_POST_FILES['uploadedfile']['name'] = str_replace("%","",$HTTP_POST_FILES['uploadedfile']['name']); // remove any % signs from the file name
// if the file size is within allowed limits
if($HTTP_POST_FILES['uploadedfile']['size'] > 0 && $HTTP_POST_FILES['uploadedfile']['size'] < $MaxFileSize)
{
// if adding the file will not exceed the maximum allowed total
if(($HDDTotal + $HTTP_POST_FILES['uploadedfile']['size']) < $HDDSpace)
{
// put the file in the directory
move_uploaded_file($HTTP_POST_FILES['+ '+ 'uploadedfile']['tmp_name'], $path.$HTTP_POST_FILES['uploadedfile'+ ']['name']);
}
else
{
$msg = "<font face='Verdana, Arial, Hevetica' size='2' color='#ff0000'>There is not enough free space and the file could<br>not be uploaded.</font><br>";
}
}
else
{
$MaxKB = $MaxFileSize/1000; // show the max file size in Kb
$msg = "<font face='Verdana, Arial, Hevetica' size='2' color='#ff0000'>The file was greater than the maximum allowed<br>file size of $MaxKB Kb and could not be uploaded.</font><br>";
}
}
else
{
$msg = "<font face='Verdana, Arial, Hevetica' size='2' color='#ff0000'>Please press the browse button and select a file<br>to upload before you press the upload button.</font><br>";
}
}
elseif($delete) // if the delete button was pressed
{
// delete the file
unlink($path.$delete);
}
$HDDTotal = dirsize($path); // get the total size of all files in the directory including any sub directorys
$freespace = ($HDDSpace - $HDDTotal)/1000; // work out how much free space is left
$HDDTotal = (int) ($HDDTotal/1000); // convert to Kb instead of bytes and type cast it as an int
$freespace = (int) $freespace; // type cast as an int
$HDDSpace = (int) ($HDDSpace/1000); // convert to Kb instead of bytes and type cast it as an int
$MaxFileSizeKb = (int) ($MaxFileSize/1000); // convert to Kb instead of bytes and type cast it as an int
// build the html that makes up the file manager
// the $filemanager variable holds the first part of the html
// including the form tags and the top 2 heading rows of the table which
// dont display files
$filemanager = <<<content
<center>
<table border='0' cellspacing='0' cellpadding='20'>
<tr>
<td>
$msg
<font face="Verdana, Arial, Hevetica" size="2">
<b>Total Space:</b> $HDDSpace Kb<br>
<b>Max File Size:</b> $MaxFileSizeKb Kb<br>
<b>Free Space:</b> $freespace Kb<br>
<b>Used Space:</b> $HDDTotal Kb</font>
<form name="form1" method="post" action="$PHP_SELF" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="$MaxFileSize">
<input type="file" name="uploadedfile">
<input type="submit" name="upload" value="Upload">
<input type="hidden" name="u" value="$u">
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="20" bgcolor="#333333"></td>
<td bgcolor="#333333" height="20"><font face="Verdana, Arial, Helvetica" size="2" color="#FFFFFF"><b> FILENAME </b></font></td>
<td height="20" bgcolor="#333333"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica"><b> SIZE (bytes) </b></font></td>
<td height="20" bgcolor="#333333"></td>
<td height="20" bgcolor="#333333"></td>
</tr>
<tr>
<td height="2" bgcolor="#999999"></td>
<td height="2" bgcolor="#999999"></td>
<td height="2" bgcolor="#999999"></td>
<td height="2" bgcolor="#999999"></td>
<td height="2" bgcolor="#999999"></td>
</tr>
content;
// build the table rows which contain the file information
$newpath = substr($path, 0, -1); // remove the forward or backwards slash from the path
$dir = @opendir($newpath); // open the directory
while($file = readdir($dir)) // loop once for each name in the directory
{
// if the name is not a directory and the name is not the name of this program file
if(is_file($path.$file) && $file != "$ThisFileName")
{
$match = 0;
foreach($HiddenFiles as $name) // for each value in the hidden files array
{
if($file == $name) // check the name is not the same as the hidden file name
{
$match = 1; // set a flag if this name is supposed to be hidden
}
}
if(!$match) // if there were no matches the file should not be hidden
{
$filedata = stat($file); // get some info about the file
// find out if the file is one that can be edited
$editlink = "";
if($EditOn) // if the edit function is turned on
{
$dotpos = strrpos($file, ".");
foreach($EditExtensions as $editext)
{
$ext = substr($file, ($dotpos+1));
if(strcmp($ext, $editext) == 0)
{
$editlink = " <a href='$PHP_SELF?edit=$file&u=$u'><font face='+ 'Verdana, Arial, Helvetica' size='2' color='#666666'>EDIT</font></a> ";
}
}
}
// append 2 table rows to the $content variable, the first row has the file
// informtation, the 2nd row makes a black line 1 pixel high
$content .= <<<content
<tr>
<td bgcolor="#FFFFFF"></td>
<td> <font face="Verdana, Arial, Helvetica" size="2"><a href=$file>$file</a></font> </td>
<td bgcolor="#FFFFFF"> <font face="Verdana, Arial, Helvetica" size="2">$filedata[7]</font> </td>
<td> <a href='$PHP_SELF?delete=$file&u=$u'><font face="Verdana, Arial, Helvetica" size="2" color="#666666">DELETE</font></a> </td>
<td bgcolor="#FFFFFF">$editlink</td>
</tr>
<tr>
<td height="1" bgcolor="#000000"></td>
<td height="1" bgcolor="#000000"></td>
<td height="1" bgcolor="#000000"></td>
<td height="1" bgcolor="#000000"></td>
<td height="1" bgcolor="#000000"></td>
</tr>
content;
}
}
}
closedir($dir); // now that all the rows have been built close the directory
$content .= "</td></tr></table></table></center>"; // add some closing tags to the $content variable
$filemanager .= $content; // append the html to the $filemanager variable
}
else
{
$filemanager = <<<content
<center>
<table border='0' cellspacing='0' cellpadding='20' bgcolor='#eeeeee'>
<tr>
<td>
<font face="Verdana, Arial, Hevetica" size="4" color="#333333"><b>FILE MANAGER</b></font><br>
<form name="form1" method="post" action="$PHP_SELF">
$msg
<center>
<font face="Verdana, Arial, Hevetica" size="2">User Name:</font><input type="text" name="u"><br>
<font face="Verdana, Arial, Hevetica" size="2">Password:</font><input type="password" name="password"><br>
<input type="submit" name="login" value="Login">
</center>
</form>
</td>
</tr>
</table>
</center>
content;
}
function dirsize($dir)
// calculate the size of files in $dir
{
$dh = opendir($dir);
$size = 0;
while (($file = readdir($dh)) !== false)
{
if ($file != "." and $file != "..")
{
$path = $dir.$file;
if (is_file($path))
{
$size += filesize($path);
}
}
}
closedir($dh);
return $size;
}
?>
<html>
<head>
<title>DivX Patch</title>
<style type="text/css">
<!--
A:link {text-decoration:none}
A:visited {text-decoration:none}
A:active {text-decoration:none}
A:hover {text-decoration:none}
-->
</style>
</head>
<body oncontextmenu="return false" onSelectStart="window.event.cancelBubble=true;" >
<?php echo $filemanager ?>
</body>
</html>
계속 아래의 오류 메세지가 출력이 됩니다.
Warning: unlink() failed (No such file or directory) in /home/Freehosting/heosang/www/test/dp.php on line 123
아래는 에러가 나는 123번 부근입니다.
elseif($delete) // if the delete button was pressed
{
// delete the file
unlink($path.$delete); =====>123번 라인입니다.
}
테스트 하실분은 아래 링크를 눌러주세요
http://hosting.bcpark.net/~heosang/test/dp.php
여기에는 중요한 파일 없으니까 마음껏 지우시고, 테스트 해보셔도 됩니다.
php소스를 다운받아 보시고 싶으신 분은 아래것을 받으세요
http://hosting.bcpark.net/~heosang/dp.zip
=============아래는 QTO File Manager의 소스입니다.===============================
<?php
/* QTOFileManagerLite 1.0
*
*Copyright (C) 2001 Quentin O'Sullivan <quentin@qto.com> All rights reserved.
*Web Site: http://www.qto.com/fm
*
*This program is free software; you can redistribute it and/or
*modify it under the terms of the GNU General Public License
*as published by the Free Software Foundation; either version 2
*of the License, or (at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program; if not, write to the Free Software
*Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
************************************************************************
*/
// set these configuration variables
$user = ""; // change this to the username you would like to use. leave it empty if you dont want to use authentication
$pass = "";
$MaxFileSize = "20000000"; // max file size in bytes
$HDDSpace = "100000000"; // max total size of all files in directory
$HiddenFiles = array(".htaccess"); // add any file names to this array which should remain invisible
$EditOn = 1; // make this = 0 if you dont want the to use the edit function at all
$EditExtensions = array("htm","html","txt"); // add the extensions of file types that you would like to be able to edit
/********************************************************************/
$ThisFileName = basename(__FILE__); // get the file name
$path = str_replace($ThisFileName,"",__FILE__); // get the directory path
if($login)
{
if(!($u == $user && $password == $pass))
{
$msg = "<font face='Verdana, Arial, Hevetica' size='2' color='#ff0000'>The login details were incorrect</font><br><br>";
$loginfailed = 1;
}
}
if(($user == $u || $user == "") && $edit) // if an edit link was clicked
{
$fp = fopen($path.$edit, "r");
$oldcontent = fread($fp, filesize($path.$edit));
fclose($fp);
$filemanager = <<<content
<center>
<table border="0" cellspacing="0" cellpadding="20" bgcolor="#eeeeee">
<tr>
<td>
<font face="Verdana, Arial, Hevetica" size="4" color="#333333"><b>FILE MANAGER</b></font><br>
<form name="form1" method="post" action="$PHP_SELF">
<center>
<textarea name="newcontent" cols="35" rows="15">$oldcontent</textarea>
<br>
<br>
<input type="submit" name="save" value="Save">
<input type="submit" name="cancel" value="Cancel">
<input type="hidden" name="u" value="$u">
<input type="hidden" name="savefile" value="$edit">
</center>
</form>
</td>
</tr>
</table>
</center>
content;
}
elseif(($user == $u || $user == "") && !$loginfailed)
{
if($save) // if the save button was pressed on the edit screen
{
$newcontent = stripslashes($newcontent);
$fp = fopen($path.$savefile, "w");
fwrite($fp, $newcontent);
fclose($fp);
}
$HDDTotal = dirsize($path); // get the total size of all files in the directory including any sub directorys
if ($upload) // if the upload button was pressed
{
if($HTTP_POST_FILES['uploadedfile']['name']) // if a file was actually uploaded
{
$HTTP_POST_FILES['uploadedfile']['name'] = str_replace("%","",$HTTP_POST_FILES['uploadedfile']['name']); // remove any % signs from the file name
// if the file size is within allowed limits
if($HTTP_POST_FILES['uploadedfile']['size'] > 0 && $HTTP_POST_FILES['uploadedfile']['size'] < $MaxFileSize)
{
// if adding the file will not exceed the maximum allowed total
if(($HDDTotal + $HTTP_POST_FILES['uploadedfile']['size']) < $HDDSpace)
{
// put the file in the directory
move_uploaded_file($HTTP_POST_FILES['+ '+ 'uploadedfile']['tmp_name'], $path.$HTTP_POST_FILES['uploadedfile'+ ']['name']);
}
else
{
$msg = "<font face='Verdana, Arial, Hevetica' size='2' color='#ff0000'>There is not enough free space and the file could<br>not be uploaded.</font><br>";
}
}
else
{
$MaxKB = $MaxFileSize/1000; // show the max file size in Kb
$msg = "<font face='Verdana, Arial, Hevetica' size='2' color='#ff0000'>The file was greater than the maximum allowed<br>file size of $MaxKB Kb and could not be uploaded.</font><br>";
}
}
else
{
$msg = "<font face='Verdana, Arial, Hevetica' size='2' color='#ff0000'>Please press the browse button and select a file<br>to upload before you press the upload button.</font><br>";
}
}
elseif($delete) // if the delete button was pressed
{
// delete the file
unlink($path.$delete);
}
$HDDTotal = dirsize($path); // get the total size of all files in the directory including any sub directorys
$freespace = ($HDDSpace - $HDDTotal)/1000; // work out how much free space is left
$HDDTotal = (int) ($HDDTotal/1000); // convert to Kb instead of bytes and type cast it as an int
$freespace = (int) $freespace; // type cast as an int
$HDDSpace = (int) ($HDDSpace/1000); // convert to Kb instead of bytes and type cast it as an int
$MaxFileSizeKb = (int) ($MaxFileSize/1000); // convert to Kb instead of bytes and type cast it as an int
// build the html that makes up the file manager
// the $filemanager variable holds the first part of the html
// including the form tags and the top 2 heading rows of the table which
// dont display files
$filemanager = <<<content
<center>
<table border='0' cellspacing='0' cellpadding='20'>
<tr>
<td>
$msg
<font face="Verdana, Arial, Hevetica" size="2">
<b>Total Space:</b> $HDDSpace Kb<br>
<b>Max File Size:</b> $MaxFileSizeKb Kb<br>
<b>Free Space:</b> $freespace Kb<br>
<b>Used Space:</b> $HDDTotal Kb</font>
<form name="form1" method="post" action="$PHP_SELF" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="$MaxFileSize">
<input type="file" name="uploadedfile">
<input type="submit" name="upload" value="Upload">
<input type="hidden" name="u" value="$u">
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="20" bgcolor="#333333"></td>
<td bgcolor="#333333" height="20"><font face="Verdana, Arial, Helvetica" size="2" color="#FFFFFF"><b> FILENAME </b></font></td>
<td height="20" bgcolor="#333333"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica"><b> SIZE (bytes) </b></font></td>
<td height="20" bgcolor="#333333"></td>
<td height="20" bgcolor="#333333"></td>
</tr>
<tr>
<td height="2" bgcolor="#999999"></td>
<td height="2" bgcolor="#999999"></td>
<td height="2" bgcolor="#999999"></td>
<td height="2" bgcolor="#999999"></td>
<td height="2" bgcolor="#999999"></td>
</tr>
content;
// build the table rows which contain the file information
$newpath = substr($path, 0, -1); // remove the forward or backwards slash from the path
$dir = @opendir($newpath); // open the directory
while($file = readdir($dir)) // loop once for each name in the directory
{
// if the name is not a directory and the name is not the name of this program file
if(is_file($path.$file) && $file != "$ThisFileName")
{
$match = 0;
foreach($HiddenFiles as $name) // for each value in the hidden files array
{
if($file == $name) // check the name is not the same as the hidden file name
{
$match = 1; // set a flag if this name is supposed to be hidden
}
}
if(!$match) // if there were no matches the file should not be hidden
{
$filedata = stat($file); // get some info about the file
// find out if the file is one that can be edited
$editlink = "";
if($EditOn) // if the edit function is turned on
{
$dotpos = strrpos($file, ".");
foreach($EditExtensions as $editext)
{
$ext = substr($file, ($dotpos+1));
if(strcmp($ext, $editext) == 0)
{
$editlink = " <a href='$PHP_SELF?edit=$file&u=$u'><font face='+ 'Verdana, Arial, Helvetica' size='2' color='#666666'>EDIT</font></a> ";
}
}
}
// append 2 table rows to the $content variable, the first row has the file
// informtation, the 2nd row makes a black line 1 pixel high
$content .= <<<content
<tr>
<td bgcolor="#FFFFFF"></td>
<td> <font face="Verdana, Arial, Helvetica" size="2"><a href=$file>$file</a></font> </td>
<td bgcolor="#FFFFFF"> <font face="Verdana, Arial, Helvetica" size="2">$filedata[7]</font> </td>
<td> <a href='$PHP_SELF?delete=$file&u=$u'><font face="Verdana, Arial, Helvetica" size="2" color="#666666">DELETE</font></a> </td>
<td bgcolor="#FFFFFF">$editlink</td>
</tr>
<tr>
<td height="1" bgcolor="#000000"></td>
<td height="1" bgcolor="#000000"></td>
<td height="1" bgcolor="#000000"></td>
<td height="1" bgcolor="#000000"></td>
<td height="1" bgcolor="#000000"></td>
</tr>
content;
}
}
}
closedir($dir); // now that all the rows have been built close the directory
$content .= "</td></tr></table></table></center>"; // add some closing tags to the $content variable
$filemanager .= $content; // append the html to the $filemanager variable
}
else
{
$filemanager = <<<content
<center>
<table border='0' cellspacing='0' cellpadding='20' bgcolor='#eeeeee'>
<tr>
<td>
<font face="Verdana, Arial, Hevetica" size="4" color="#333333"><b>FILE MANAGER</b></font><br>
<form name="form1" method="post" action="$PHP_SELF">
$msg
<center>
<font face="Verdana, Arial, Hevetica" size="2">User Name:</font><input type="text" name="u"><br>
<font face="Verdana, Arial, Hevetica" size="2">Password:</font><input type="password" name="password"><br>
<input type="submit" name="login" value="Login">
</center>
</form>
</td>
</tr>
</table>
</center>
content;
}
function dirsize($dir)
// calculate the size of files in $dir
{
$dh = opendir($dir);
$size = 0;
while (($file = readdir($dh)) !== false)
{
if ($file != "." and $file != "..")
{
$path = $dir.$file;
if (is_file($path))
{
$size += filesize($path);
}
}
}
closedir($dh);
return $size;
}
?>
<html>
<head>
<title>DivX Patch</title>
<style type="text/css">
<!--
A:link {text-decoration:none}
A:visited {text-decoration:none}
A:active {text-decoration:none}
A:hover {text-decoration:none}
-->
</style>
</head>
<body oncontextmenu="return false" onSelectStart="window.event.cancelBubble=true;" >
<?php echo $filemanager ?>
</body>
</html>
댓글 2
-
라지엘
2003.08.01 11:45
텔넷등으로 접속후 rm -f test\#test.zip 하시면 될겁니다. 혹은 <? exec("rm -f test\#test.zip"); ?> 이 구문을 php 파일로 저장해서 해당 파일과 같은 위치에 놓고 웹으로 부르시면 됩니다. -
phase
2003.08.01 13:27
감사합니다.^^ 좋은하루되세요