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
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
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 : 14420
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>



Keep() - maintenance function for backup folders
Categories : PHP, Filesystem, Maintenance
Handle multiple file upload
Categories : Complete Programs, Filesystem, PHP, HTML and PHP
Directory viewer, customize how you display the file structure, easy to understand. Found out about PHP 3 days ago, and this is my first prog.
Categories : HTML and PHP, Complete Programs, Directories, Filesystem, PHP
Relative Path
Categories : PHP, Filesystem
basename -- Returns filename component of path
Categories : PHP, PHP Functions, Filesystem
Complete NotePad application for Websites (Like Yahoo Notepad)
Categories : PHP, Web Applications, Filesystem, Java Script, Complete Programs
Directory Viewer, Directory Content Viewer, Directory Structure to HTML. This code will basically create a complete set of HTMLs to let a user navigate through any directory you want. Excellent code for large file sharing pages.
Categories : Directories, Filesystem, PHP
Checking to see if a file exists with PHP
Categories : PHP, Filesystem, Perl
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
Link Submition - Allow your visitors to submit links to the site.
Categories : PHP, Arrays, Filesystem, Beginner Guides
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
Contents Page - a script to build contents pages.
Categories : Complete Programs, PHP, Utilities, Filesystem
Open directory and File download
Categories : PHP, Filesystem, Directories, HTML and PHP
3 lines of Code to extract Tar, Zip, Gzip etc..
Categories : PHP, Filesystem, PHP Classes, Compression