News:
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
2012-02-04, 21:31:03

Login with username, password and session length

Pages: [1]   Go Down
  Print  
Author Topic: [HOW TO] Delete all the .pureftpd-upload .pureftpd-rename files  (Read 498 times)
Piotr GRD
Administrator
Member
*****
Offline Offline

Posts: 20



« on: 2010-12-31, 15:06:02 »

.pureftpd-upload.12345678.15.90ab.cdef1234
.pureftpd-rename.12345.67890abc
What are these files?...

That's temporary files created by FTP software installed on the server created during the processes of upload/rename and other operations made by the user connected through FTP. When the operation is succesfully finished - these files are gone automatically, however if during the process some error occur - the files are still there.
Note: you may find a lot of them especially on your box 13's accounts if you use FTP often, as there are common problems with FTP operations being terminated on it, especially recently (for months already during year 2010).

While this is not any critical problem - you might find it annoying or even a real problem when there are too many of these files on your account. These files can not be deleted through FTP at all. And often there are problems to delete them in 110mb's file manager. So what to do?


Below script is designed to browse all the files on your account, find these that match with the filename to the path of ".pureftpd-upload.*" and ".pureftpd-rename.*" and attempt to delete them. That's right - this will be only attempt to delete them as there is one condition - folders that contain these files have to be properly CHMOD'ed, so if you'll find your files not deleted - try to change the permissions for the folder with these files to 770 or 777.
Script may also fail if you've got lots of files (thousands) on your account so listing them will take more than max_execution_time set on 110mb for 15 seconds. In such case you may try to run script again or better place it inside of some subdirectory, every directory you need, instead of the root (main) directory on your account.

Simply copy below code and paste it in the notepad or other plain text editor on your computer, save as "anyfilename.php" (filename can be whatever you want, but .php extension is important), upload into your account and call it with your browser. After succesfully removing unwanted files - delete this script, too.

Code:
<?php
// Script that will attempt to delete all
// .pureftpd-upload.* and .pureftpd-rename.* files
// 2010-12-31   Made by Piotr GRD    http://grd.net.pl/
// originally posted on   http://110mb.grd.net.pl/forum/index.php/topic,18.0.html
// Free to use and modify as long as you'll keep above info


$directory '.';
$deletedfiles 0;
$notdeletedfiles 0;

function 
browse($dir) {
global 
$deletedfiles$notdeletedfiles;
    if (
$handle opendir($dir)) {
        while (
false !== ($file readdir($handle))) {
            if (
is_file($dir.'/'.$file) && preg_match("#\.pureftpd-(upload|rename)\..*#"$file)) {
                if (@
unlink($dir.'/'.$file))
                {
                  
$deletedfiles $deletedfiles 1;
                  echo 
$dir.'/<span style="color:blue;">'.$file.'</span> &nbsp; <span style="color:green;font-weight:bold;">DELETED</span><br/>'."\n";
                }
                else
                {
                  
$notdeletedfiles $notdeletedfiles 1;
                  echo 
$dir.'/<span style="color:blue;">'.$file.'</span> &nbsp; <span style="color:red;font-weight:bold;">NOT DELETED</span><br/>'."\n";
                }
                
flush();
            }
            else if (
$file != "." && $file != ".." && is_dir($dir.'/'.$file)) {
                
browse($dir.'/'.$file);
            }
        }
        
closedir($handle);
    }

}

browse($directory);

echo 
'<br/><br/>'.$deletedfiles.' file(s) DELETED';
if (
$notdeletedfiles 0)
{ echo 
', <span style="color:red;">'.$notdeletedfiles.' file(s) NOT DELETED</span></br>
Try to check permmissions (CHMOD) for directories that contain undeleted files listed above.'
; }

flush();

?>


Note: If script will be succesfully executed to the very end - you will see the report of how many files were deleted and eventually how many files were not. If you won't see such message with total number of files deleted - script has been interrupted, either because there is too many files on your account or because of instability of the server (this is "normal" now - December 2010 / January 2011 - on box 13) and in such case execute the script once more (or multiple times). Every time you'll see - while script works - that some files are deleted (individual report for every file) - these files are really deleted.


If you found this script useful and it worked for you and you came here from 110mb forum - please, post a link to it in there in relevant topic to help others find it and possibly fix their problem, too. The same you can do in any other place. Thank you.

Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by SMF | SMF © 2006-2009, Simple Machines LLC | Dilber MC Theme by HarzeM modified by Piotr GRD