PHP Classes


Recommend this page to a friend!
  Classes of Pierre Marceau   Deltree   Download  
Role: ???
Content type: text/plain
Description: The class
Class: Deltree
Author: By
Last change:
Date: 21 years ago
Size: 2,202 bytes


Class file image Download
<?php /* ============================================================== This script 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. This file and the whole Deltree distribution is copyright (c) 2001 Pierre Marceau all rights reserved. You may freely use and redistribute under the terms of the GNU General Public License. -------------------------------------------------------------- Deltree - ============================================================== */ class deltree { var $ftp_conn=""; var $ftp_user="pierre"; var $ftp_pass="finland"; var $ftp_server="localhost"; var $parentdir="/change/at/your/own/risk"; function prune($leaf) { if (!is_dir($this->parentdir."/".$leaf)){ echo $this->parentdir."/".$leaf." not found!"; }else{ $this->myFTPConnect($this->parentdir."/".$leaf); $this->treewalk($this->parentdir."/".$leaf); ftp_site($this->ftp_conn,"chmod 755 ".$this->parentdir); ftp_quit($this->ftp_conn); } } function treewalk($branch){ ftp_site($this->ftp_conn,"chmod 777 ".$branch); $mydirectory = opendir($branch); while($entryname=readdir($mydirectory)){ switch (true) { case ($entryname==".") : break; case ($entryname=="..") : break; case (is_dir($branch."/".$entryname)): $this->treewalk($branch."/".$entryname); break; default : unlink ($branch."/".$entryname); } } closedir($mydirectory); rmdir($branch); } function myFTPConnect($branch){ switch (false) { case ($this->ftp_conn = @ftp_connect ($this->ftp_server)) : die($this->ftp_server." FTP - failed to connect!"); case (@ftp_login($this->ftp_conn, $this->ftp_user, $this->ftp_pass)) : ftp_quit($this->ftp_conn); die("FTP - connected, but failed login!"); case (ftp_site($this->ftp_conn,"chmod 777 ".$this->parentdir)) : die ("Failure giving rights to parent directory."); } } } ?>