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 : Recursive PHP Class to supervise the size of folders.
Categories : PHP, PHP Classes, Filesystem
ROBERTO ALEMAN
Date : Oct 24th 2010
Grade : 3 of 5 (graded 1 times)
Viewed : 7642
File : No file for this code example.
Images : No Images for this code example.
Search : More code by ROBERTO ALEMAN
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
Like this code?
Show the author your appreciation.
 

This class can be used to monitor the size of files in a folder.

It can traverse a given directory recursively and count the size that files are taking on the disk.

The class can repeat the process after a given period of time and display a chart using the
Google Chart API to show the current disk space usage and change over time.


index.php (Example Usage)
<?php
require_once("Supervisor_of_filling_of_folders.php");

$fillfolder = new Supervisor_of_filling_of_folders();
$fillfolder ->supfillfolder("youfolder/",400,250,2,5368709120);// parameters $url, $width_img, $height_img, $interval,$max_value in bytes, example 5368709120 = 5 Gb

echo "<meta http-equiv='refresh' content='2' />"; // use same interval value, you can modifying and apply the AJAX technology
?> 



Supervisor_of_filling_of_folders.php
<?php
/* Supervisor_of_filling_of_folders 0.2.0 by Roberto Aleman, ventics.com,BSD Licence

Hi traffic websites, may have folders holding UGC (User Generated content) such as images and documents
that are uploaded by the users to shared folders. If a quota exists for each user, it would be helpful to have
an alarm that shows an estimate of when it would be needed to intervene and increase the size of the Quota
or disk space.

Using the Google Chart API, you can build interesting and important controls that would relay a visual status
of what is happening on the server to the webmaster.

With a little work, the users of this class may apply to a control panel using AJAX.

This class sends several parameters:

$url to monitor: which should be on the same server running the script.
$width_img and $height_img : chart measures for Google Chart
$time: the time or interval monitoring.
$max_value: critical size reference for the calculations. 
*/



class Supervisor_of_filling_of_folders
{
     function
supfillfolder($url, $width_img,$height_img,$time,$max_value)
    {
            foreach(new
RecursiveIteratorIterator(new RecursiveDirectoryIterator($url)) as $file){
               
$size1+=$file->getSize();  //interator to get real size of directory time 1
           
}
           
sleep($time);
           
            foreach(new
RecursiveIteratorIterator(new RecursiveDirectoryIterator($url)) as $file){
               
$size2+=$file->getSize(); //interator to get real size of directory time 2
           
}

           
$variation = $size2 - $size1;   
           
           
$growth = ($variation / $max_value) *100; //calculate growth between time 1 and time 2
           
           
$average = ($size2 - $size1)/$time; //calculate average bytes/seconds
           
       
echo "<img src='http://chart.apis.google.com/chart?chs=".$width_img."x".$height_img."&cht=gom&chd=t:".$growth.    "&chco=FF0000,FF8040,FFFF00,00FF00,00FFFF,0000FF,800080&chxt=x,y&chxl=0:%7CGrowth%7C1:%7Cslow%7Cfaster%7Ccrazy' alt='Directory Supervisor'>"; //show google chart the growth


echo "<br/><img src='http://chart.apis.google.com/chart?chs=".$width_img."x".$height_img."&cht=gom&chd=t:".$average.    "&chco=FF0000,FF8040,FFFF00,00FF00,00FFFF,0000FF,800080&chxt=x,y&chxl=0:%7CAverage%7C1:%7Cslow%7Cfaster%7Ccrazy' alt='Directory Supervisor'>"; //show google chart the average
   
   
echo "<br/>Disk Critical Limit : ".$max_value." bytes <br/>";
    echo
"Current growth : ".$growth." % of Max Value<br/>";
    echo
"Current Average : ".$average." bytes/seconds<br/>";
   
   
    }

}

?>



Easy upload class
Categories : PHP Classes, Filesystem, HTTP, PHP
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
PHP4 DirectoryIterator Class
Categories : PHP, PHP Classes, Filesystem, Directories
Bs_IniHandler is a class that can read and write ini-style files (and strings)
Categories : PHP, Filesystem, PHP Classes
Search and Replace Text : Searches Files for Specified Text and Replaces It by a Given Text
Categories : PHP, PHP Classes, Search, Filesystem
filesplit : Split big text files in multiple small ones
Categories : PHP, Log Files, Filesystem, PHP Classes
Class that allows the PHP developer to create and manage UNIX like password files suitable for use as Apache authentication password files.
Categories : HTTP, PHP, PHP Classes, Filesystem
PHP Transfer data from text file to Mysql Table
Categories : PHP, PHP Classes, Filesystem, Databases, MySQL
3 lines of Code to extract Tar, Zip, Gzip etc..
Categories : PHP, Filesystem, PHP Classes, Compression
Compare two texts and display a block of text with the differences between them.
Categories : PHP, PHP Classes, Filesystem, Strings, Arrays
Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support
Categories : PHP, FTP, Filesystem, PHP Classes, Compression
A File Browser Class.To Read Drives,Directories and Files .Files writing is also possible
Categories : PHP, PHP Classes, Filesystem
An efficient iterative and buffered text file reader
Categories : PHP, Classes and Objects, Filesystem, PHP Classes, Log Files
A class to draw real 3D graphics with surface area
Categories : Graphics, PHP, PHP Classes
Three Cool Classes and One Trick
Categories : PHP, PHP Classes, Graphics, Email