WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - השוואת מחירים בסופר
ZeroLag.com
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Directory cleanup - This script was created for those times when you've allowed a directory to be overloaded with temp or cache type files which all need to be deleted.
Categories : PHP, Filesystem Click here to Update Your Picture
Sarah King
Date : Apr 06th 2005
Grade : 3 of 5 (graded 3 times)
Viewed : 15554
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Sarah King
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?PHP
/* Directory Cleanup
* Author: Sarah King
* Date  : 7 April 2005
* http://sarahk.pcpropertymanager.com/blog/directory-clean-up/29/
*
* This script was created for those times when you've allowed a
* directory to be overloaded with temp or cache type files which all
* need to be deleted. I had one so big I couldn't ftp into it!
* This script cleaned it out for me and removed 17MB of 2k files
* - you do the math!
*/
$dir2clean = 'cache';

$test = false;
$more = false;
$output = '';
if (
$handle = opendir($dir2clean))
{
   
$header = "\n";

   
$i = 0;
   
/* This is the correct way to loop over the directory. */
   
while (false !== ($file = readdir($handle)) && $i < 105)
   {
           if (
$i < 100)
           {
           
$output .= "<tr><td>$file</td>\n<td>";
           if (
substr($file, 0, 1) != '.')
           {
                   if (
$test) $output .= 'test';
                elseif (
unlink("{$dir2clean}/{$file}")) $output .= "deleted";
                   else
$output .= "kept";
           }
           else
$output .= ' ';
           
           
$output .= "</td><td>";
           
$output .= date ("F d Y H:i:s.", fileatime("cache/{$file}"));
           
$output .= "</td>\n</tr>\n";
           }
           else
$more = true;

           
$i++;
   }
   
closedir($handle);
}
?>
<html>
<head>
<?PHP
// meta refresh can fail in Internet Explorer but this works like a rocket in Firefox
if ($more && !$test)
{
    echo
"\n<META HTTP-EQUIV='Refresh' CONTENT=\"1; URL=http://{$_SERVER['HTTP_HOST']}{$PHP_SELF}\">\n";
}
?>
</head>
<body>
<h2>Date: <?php echo date('d-m-Y H:i'); ?><br />
    Directory: <?=$dir2clean; ?><br />
    Files:</h2>

<table border='1' cellpadding="4" cellspacing="0">
<?php echo $output; ?>
</table>
</body>
</html>



Using PHP to Delete a directory with all sub directories and files using FTP
Categories : PHP, FTP, Directories, Filesystem
Take multiple text files and do simple formatting on them and add them to a webpage
Categories : HTML, Filesystem, PHP
These 2 functions write and read the contents of a specially designated multi-dimensional array to and from a text file.
Categories : Algorithms, PHP, Filesystem
This script will read all images from a folder and read the files into an array. It uses rand() to get a random number. It will display a random image from the image folder given.
Categories : PHP, Arrays, Graphics, Filesystem
Working with files - putting file contents to a string / var
Categories : PHP, Filesystem, Variables, Strings
QTO File Manager
Categories : Filesystem, filePro, Complete Programs, PHP, Content Management
Keep() - maintenance function for backup folders
Categories : PHP, Filesystem, Maintenance
Compare two texts and display a block of text with the differences between them.
Categories : PHP, PHP Classes, Filesystem, Strings, Arrays
Read a file with strings and create a new file with the first half of each string
Categories : PHP, Strings, Filesystem
windows nt php/3 file upload script
Categories : Filesystem, PHP, IIS, WinNT, Web Servers
Complete NotePad application for Websites (Like Yahoo Notepad)
Categories : PHP, Web Applications, Filesystem, Java Script, Complete Programs
A simple php file uploader
Categories : PHP, Filesystem, HTML and PHP
File Explorer, browse, upload, download and edit your web site files with only a browser and a HTTP connection.
Categories : Complete Programs, Content Management, Filesystem, PHP
3 lines of Code to extract Tar, Zip, Gzip etc..
Categories : PHP, Filesystem, PHP Classes, Compression
Filling an array with files from any given directory. This example is for the current PHP script's directory.
Categories : PHP, Arrays, Filesystem