|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/abtechsci/mmc15/ezupload/cp/ |
Upload File : |
<?php
class DB {
function DB() {
require("configs/config.php");
$this->host = $host_name;
$this->db =$db_name;
$this->user = $user_name;
$this->pass = $password;
$this->rowcount=0;
$this->link = mysql_connect($this->host, $this->user, $this->pass) or die("<br>Could not connect :" . mysql_error());
mysql_select_db($this->db);
}
function query($query) {
$result = mysql_query($query, $this->link) or die ("<br>Could not execute command : ".mysql_error());
if($result !="" )
{
}
else
{ $this->rowcount= 0 ; }
return $result;
}
function thislink() {
return $this->link;
}
function rowcount() {
return $this->rowcount ;
}
function close() {
mysql_close($this->link);
}
}
class DBr {
function DBr() {
/*
$db_setting=new db_setting();
$temp=$db_setting->get();
if(is_array($temp)==true )
{
$host_set=trim($temp[0]);
$db_set=trim($temp[1]);
$port_set=trim($temp[2]);
$user_set=trim($temp[3]);
$pass_set=trim($temp[4]);
}
*/
require("configs/config.php");
$this->host = $host_name;
$this->db =$db_name;
$this->user = $user_name;
$this->pass = $password;
$this->rowcount=0;
$this->result="";
$this->link = mysql_connect($this->host, $this->user, $this->pass) or die("<br>Could not connect :" . mysql_error());
mysql_select_db($this->db) or die("<br>Could not select database :" . mysql_error());
}
function query($query) {
$this->result =mysql_query($query, $this->link) or die ("<br>Could not execute command : ".mysql_error());
if($this->result !="")
{$this->rowcount= mysql_num_rows($this->result);}
else
{ $this->rowcount= 0 ; }
}
function resultset() {
$obj="" ;
if ( $this->rowcount== 0 ){ return ; }
while($row=mysql_fetch_object($this->result))
{
$obj[]=$row;
}
return $obj;
}
function thislink() {
return $this->link;
}
function rowcount() {
return $this->rowcount ;
}
function close() {
mysql_close($this->link);
}
}
class settings {
function settings(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select adminname ,adminpass,adminemail,site_name,base_folder from control_panel");
return $this->selectObj->resultset() ;
}
function update( $adminname , $adminemail , $adminpass ,$base_folder, $site_name ) {
$query="update control_panel set ";
$query="$query adminname='".$adminname."',";
$query="$query adminemail='".$adminemail."',";
$query="$query adminpass='".$adminpass."',";
$query="$query base_folder='".$base_folder."',";
$query="$query site_name='".$site_name."'";
$this->insertObj->query($query);
return;
}
}
class upload_results {
function upload_results(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select subdir , subdir_field , existing , thankyoumsg , redirecturl , moreuploads ,sendconfirmation , confirmtitle , confirmmsg , notification , includelinks , attachments , attachmaxsize, notifyemails from control_panel");
return $this->selectObj->resultset() ;
}
function update( $subdir , $subdir_field , $existing , $thankyoumsg , $redirecturl , $moreuploads ,$sendconfirmation , $confirmtitle , $confirmmsg , $notification , $includelinks , $attachments , $attachmaxsize , $notifyemails) {
$query="update control_panel set ";
$query="$query subdir='".($subdir)."',";
$query="$query subdir_field='".($subdir_field)."',";
$query="$query existing='".($existing)."',";
$query="$query thankyoumsg='".($thankyoumsg)."',";
$query="$query redirecturl='".($redirecturl)."',";
$query="$query moreuploads='".($moreuploads)."',";
$query="$query sendconfirmation='".($sendconfirmation)."',";
$query="$query confirmtitle='".($confirmtitle)."',";
$query="$query confirmmsg='".($confirmmsg)."',";
$query="$query notification='".($notification)."',";
$query="$query includelinks='".($includelinks)."',";
$query="$query attachments='".($attachments)."',";
$query="$query attachmaxsize='".($attachmaxsize)."',";
$query="$query notifyemails='".($notifyemails)."'";
$this->insertObj->query($query);
return ;
}
}
class access_control {
function access_control(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select formprotect , formpass , takeip , banned_ips from control_panel");
return $this->selectObj->resultset() ;
}
function update( $formprotect , $formpass , $takeip , $banned_ips ) {
$query="update control_panel set ";
$query="$query formprotect='".($formprotect)."',";
$query="$query formpass='".($formpass)."',";
$query="$query takeip='".($takeip)."',";
$query="$query banned_ips='".($banned_ips)."'";
$this->insertObj->query($query);
return ;
}
}
class filter {
function filter(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select extmode , extensions , limitsize , sizemin , sizemax , limitdim ,widthmin , widthmax , heightmin , heightmax from control_panel");
return $this->selectObj->resultset() ;
}
function update( $extmode , $extensions , $limitsize , $sizemin , $sizemax , $limitdim ,$widthmin , $widthmax , $heightmin , $heightmax ) {
$query="update control_panel set ";
$query="$query extmode='".($extmode)."',";
$query="$query extensions='".($extensions)."',";
$query="$query limitsize='".($limitsize)."',";
$query="$query sizemin='".($sizemin)."',";
$query="$query sizemax='".($sizemax)."',";
$query="$query limitdim='".($limitdim)."',";
$query="$query widthmin='".($widthmin)."',";
$query="$query widthmax='".($widthmax)."',";
$query="$query heightmin='".($heightmin)."',";
$query="$query heightmax='".($heightmax)."'";
$this->insertObj->query($query);
return ;
}
}
class customize {
function customize(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select phpcode, header, footer, fieldsize, displayinfo, showrequired, fonttype, fontsizel, fontsizes from control_panel");
return $this->selectObj->resultset() ;
}
function update( $phpcode , $header , $footer , $fieldsize , $displayinfo , $showrequired ,$fonttype , $fontsizel , $fontsizes) {
$query="update control_panel set ";
$query="$query phpcode='".($phpcode)."',";
$query="$query header='".($header)."',";
$query="$query footer='".($footer)."',";
$query="$query fieldsize='".($fieldsize)."',";
$query="$query displayinfo='".($displayinfo)."',";
$query="$query showrequired='".($showrequired)."',";
$query="$query fonttype='".($fonttype)."',";
$query="$query fontsizel='".($fontsizel)."',";
$query="$query fontsizes='".($fontsizes)."'";
$this->insertObj->query($query);
return ;
}
}
class user {
function user(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function UsersCount()
{
$query="select count(*) as count from users where code != '0' or code = NULL ";
$this->selectObj->query($query);
$row = $this->selectObj->resultset() ;
return $row[0]->count;
}
function get($uid) {
if( $uid=="" )
{
$query="select * from users";
}
else
{
$query="select * from users where uid='$uid'";
}
$this->selectObj->query($query);
return $this->selectObj->resultset() ;
}
function get_by_username($un) {
if( $uid=="" )
{
$query="select * from users";
}
else
{
$query="select * from users where uid='$un'";
}
$this->selectObj->query($query);
return $this->selectObj->resultset() ;
}
function Get_All_NormalUsers()
{
$query = "select name from users where code != '0' or code = NULL ";
$this->selectObj->query($query);
$arr = $this->selectObj->resultset() ;
return $arr;
}
function find_user($name,$pass) {
$query="select * from users where name='$name' and pass1='$pass' and status=1";
$this->selectObj->query($query);
return $this->selectObj->resultset() ;
}
function check_existence($name) {
$query="select * from users where name='$name'";
$this->selectObj->query($query);
return $this->selectObj->resultset() ;
}
function check_email_existence($email) {
$query="select * from users where email='$email'";
$this->selectObj->query($query);
return $this->selectObj->resultset() ;
}
function update( $name, $email, $pass1,$fname,$lname, $uid ) {
$query="update users set ";
$query="$query name='".($name)."',";
$query="$query email='".($email)."',";
$query="$query pass1='".($pass1)."',";
$query="$query fname='".($fname)."',";
$query="$query lname='".($lname)."'";
$query="$query where uid='".($uid)."'";
$this->insertObj->query($query);
return ;
}
function delete( $uid ) {
$query="delete from users ";
$query="$query where uid='".($uid)."'";
$this->insertObj->query($query);
return ;
}
function insert( $name, $email, $pass1,$fname,$lname,$code,$status=1 ) {
$query="replace into users set ";
$query="$query name='".($name)."',";
$query="$query email='".($email)."',";
$query="$query pass1='".($pass1)."',";
$query="$query fname='".($fname)."',";
$query="$query lname='".($lname)."',";
$query="$query code='".($code)."',";
$query="$query status=".($status)."";
//$query="$query uid='$uid'";
$this->insertObj->query($query);
return ;
}
function activate($email, $code){
$query="update users set ";
$query="$query status=1";
$query="$query where email='".($email)."'";
$query="$query and code='".($code)."'";
return $this->insertObj->query($query);
}
}
class form_association {
function form_association(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select uploademail , uploadname from control_panel");
return $this->selectObj->resultset() ;
}
function update( $uploademail , $uploadname ) {
$query="update control_panel set ";
$query="$query uploademail='".$uploademail."',";
$query="$query uploadname='".$uploadname."'";
$this->insertObj->query($query);
return ;
}
}
class fields {
function fields(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get($fid) {
if( $fid=="" )
{
$query="select * from `fields` order by seq";
}
else
{
$query="select * from `fields` where fid='".($fid)."'";
}
$this->selectObj->query($query);
return $this->selectObj->resultset() ;
}
function update( $fid, $seq, $name, $desc, $type, $req, $value, $dvalue, $min, $max ) {
$query="update `fields` set ";
$query="$query seq='".$seq."',";
$query="$query name='".$name."',";
$query="$query fdesc='".$desc."',";
$query="$query type='".$type."',";
$query="$query req='".$req."',";
$query="$query value='".$value."',";
$query="$query dvalue='".$dvalue."',";
$query="$query min='".$min."',";
$query="$query max='".$max."'";
$query="$query where fid='".$fid."'";
$this->insertObj->query($query);
return ;
}
function update_seq( $fid, $seq ) {
$query="update `fields` set ";
$query="$query seq='".($seq)."'";
$query="$query where fid='".($fid)."'";
$this->insertObj->query($query);
}
function delete( $fid ) {
$query="delete from `fields` ";
$query="$query where fid='".($fid)."'";
$this->insertObj->query($query);
return ;
}
function insert( $fid, $seq, $name, $desc, $type, $req, $value, $dvalue, $min, $max ) {
if($seq==""){
$this->selectObj->query("select max(seq) maxseq from `fields`");
$temp= $this->selectObj->resultset() ;
$seq=$temp[0]->maxseq + 1;
}
$query="replace into `fields` set ";
$query="$query fid='0',";
$query="$query seq='".($seq)."',";
$query="$query name='".($name)."',";
$query="$query fdesc='".($desc)."',";
$query="$query type='".($type)."',";
$query="$query req='".($req)."',";
$query="$query value='".($value)."',";
$query="$query dvalue='".($dvalue)."',";
$query="$query min='".($min)."',";
$query="$query max='".($max)."'";
$this->insertObj->query($query);
return ;
}
}
class browser {
function CheckDbStructure()
{
$query = "create table if not exists `uploadtousers` (UserName varchar(255) NOT NULL, UMId int(11) NOT NULL)" ;
$this->insertObj->query($query);
return;
}
function browser(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get( $lbound, $ubound,$uu="",$isAdmin=True ) {
$this->CheckDbStructure();
if( $isAdmin==True)
$this->selectObj->query("select * from uploads_master order by dt desc limit $lbound , $ubound");
else
$this->selectObj->query("(select uploads_master.id, uploads_master.name, uploads_master.email, uploads_master.dt, uploads_master.desc from uploads_master ,uploadtousers where uploads_master.id=uploadtousers.UMID and uploadtousers.username ='".$uu."') union (select uploads_master.id, uploads_master.name, uploads_master.email, uploads_master.dt, uploads_master.desc from uploads_master where uploads_master.name = '".$uu."' ) order by dt desc limit $lbound , $ubound");
return $this->selectObj->resultset() ;
}
function search($search,$lbound, $ubound, $uu="",$isAdmin=True) {
$this->CheckDbStructure();
if($isAdmin==True)
$this->selectObj->query("SELECT distinct um.id as 'id',um.name as 'name', um.dt as 'dt',um.desc as 'desc' FROM uploads_master as um,uploads WHERE um.id=uploads.upload_id and (um.name like '%$search%' or uploads.value like '%$search%') order by um.dt desc limit $lbound , $ubound ");
else
$this->selectObj->query("(SELECT distinct um.id as 'id',um.name as 'name', um.dt as 'dt',um.desc as 'desc' FROM uploads_master as um,uploads WHERE um.name= '".$uu."' and um.id=uploads.upload_id and ( um.name = '%$search%' or uploads.value like '%$search%'))union (SELECT distinct um.id as 'id',um.name as 'name', um.dt as 'dt',um.desc as 'desc' FROM uploads_master as um,uploads,uploadtousers WHERE um.id=uploads.upload_id and um.id = uploadtousers.umid and uploadtousers.username= '".$uu."' and (uploads.value like '%$search%' or um.name like '%$search%' )) limit $lbound , $ubound ");
return $this->selectObj->resultset() ;
}
function get_files($upload_id) {
$this->selectObj->query("select * from uploads where upload_id='$upload_id' and type ='file' ");
return $this->selectObj->resultset() ;
}
function get_file_info($upload_id) {
$this->selectObj->query("select * from uploads where upload_id='$upload_id' and type != 'file' ");
return $this->selectObj->resultset() ;
}
function get_emaillist() {
$this->selectObj->query("select email from uploads_master where email != '' ");
return $this->selectObj->resultset() ;
}
function get_email($upload_id) {
$this->selectObj->query("select email from uploads_master where id ='$upload_id' ");
return $this->selectObj->resultset() ;
}
function get_uploads_count($search)
{
if(empty($search))
{
$this->selectObj->query("select count(*) as count from uploads_master");
$row = $this->selectObj->resultset() ;
$num_of_rows =$row[0]->count;
}
else
{
$num_of_rows = $this->selectObj->query("SELECT distinct um.id as 'id',um.name as 'name', um.dt as 'dt',um.desc as 'desc' FROM uploads_master as um,uploads WHERE um.id=uploads.upload_id and (um.name like '%$search%' or uploads.value like '%$search%') ");
$num_of_rows = mysql_num_rows($this->selectObj->result);
}
return $num_of_rows;
}
}
class uploads {
function uploads(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function delete_file($file_id) {
//delete actual file
$this->selectObj->query("select * from uploads where id='$file_id'");
$temp = $this->selectObj->resultset() ;
unlink($temp[0]->path . "/" .$temp[0]->value);
//end of delete actual file
$this->insertObj->query("delete from uploads where id='$file_id'");
return ;
}
function delete_upload($upload_id) {
//delete actual file
$this->selectObj->query("select * from uploads where upload_id='$upload_id'");
$temp = $this->selectObj->resultset() ;
for($i=0;$i<count($temp);$i++){
if($temp[$i]->type == "file"){
unlink($temp[$i]->path . "/" .$temp[$i]->value);
}
}
//end of delete actual file
$this->insertObj->query("delete from uploads_master where id='$upload_id' ");
$this->insertObj->query("delete from uploads where upload_id='$upload_id' ");
return ;
}
function insert_master( $id, $name,$email, $dt, $desc,$IsOtherUsers=0 ) {
$query="replace into uploads_master set ";
$query="$query id='0',";
$query="$query name='".($name)."',";
$query="$query email='".($email)."',";
$query="$query dt='".($dt)."',";
$query="$query `desc`='".($desc)."'";
$this->insertObj->query($query);
$ins_id=mysql_insert_id($this->insertObj->thislink());
return $ins_id ;
}
function Share_Files($UmID,$arrUsers)
{
//check if table uploadtousers do exist
$this->CheckDbStructure();
for($i=0;$i<count($arrUsers);$i++)
{
$query = "replace into uploadtousers set ";
$query= "$query username= '".$arrUsers[$i]."',";
$query= "$query UmId = '".$UmID."'";
$this->insertObj->query($query);
$ins_id=mysql_insert_id($this->insertObj->thislink());
}
}
function CheckDbStructure()
{
$query = "create table if not exists `uploadtousers` (UserName varchar(255) NOT NULL, UMId int(11) NOT NULL)" ;
$this->insertObj->query($query);
return;
}
function insert( $id, $upload_id, $name, $value, $type, $dt, $path, $size, $desc ) {
$query="replace into uploads set ";
$query="$query id='0',";
$query="$query upload_id='".($upload_id)."',";
$query="$query name='".($name)."',";
$query="$query value='".($value)."',";
$query="$query type='".($type)."',";
$query="$query dt='".($dt)."',";
$query="$query path='".($path)."',";
$query="$query size='".($size)."',";
$query="$query `desc`='".($desc)."'";
$this->insertObj->query($query);
return ;
}
function update_master( $id, $name ) {
$query="update uploads_master set ";
$query="$query name='".($name)."'";
$query="$query where id='".($id)."'";
$this->insertObj->query($query);
return ;
}
function delete_all_upload()
{
//get upload directory in order to delete all files inside it
$upload_setting=new upload_setting();
$temp=$upload_setting->get();
$upload_dir=$temp[0]->upload_dir;
$del = new deleter();
$del->recursive_remove_directory($upload_dir,true);
$this->insertObj->query("delete from uploads_master");
$this->insertObj->query("delete from uploads");
}
}
//not used anymore
class security {
function security(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select adminname ,adminpass,adminemail,site_name,base_folder from control_panel");
return $this->selectObj->resultset() ;
}
function update( $adminname , $adminemail , $adminpass ,$base_folder, $site_name ) {
$query="update control_panel set ";
$query="$query adminname='".$adminname."',";
$query="$query adminemail='".$adminemail."',";
$query="$query adminpass='".$adminpass."',";
$query="$query base_folder='".$base_folder."',";
$query="$query site_name='".$site_name."'";
$this->insertObj->query($query);
return;
}
}
class smtp_setup {
function smtp_setup(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select smtp_host ,smtp_port ,euname ,epass from control_panel");
return $this->selectObj->resultset() ;
}
function update( $smtp_host ,$smtp_port ,$euname ,$epass ) {
$query="update control_panel set ";
$query="$query smtp_host='$smtp_host',";
$query="$query smtp_port='$smtp_port',";
$query="$query euname='$euname',";
$query="$query epass='$epass'";
$this->insertObj->query($query);
return;
}
}
class upload_setting {
function upload_setting(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select upload_dir,existing, sizemax, extensions , widthmax , heightmax, autodel_files from control_panel");
return $this->selectObj->resultset() ;
}
function update( $upload_dir, $existing , $sizemax , $extensions , $widthmax , $heightmax, $autodel_files ) {
$query="update control_panel set ";
$query="$query upload_dir='".($upload_dir)."',";
$query="$query existing='".($existing)."',";
$query="$query sizemax='".($sizemax)."',";
$query="$query extensions='".($extensions)."',";
$query="$query widthmax='".($widthmax)."',";
//$query="$query autodel_files='".$autodel_files."',";
$query="$query heightmax='".($heightmax)."'";
$this->insertObj->query($query);
return ;
}
}
class db_setting {
function db_setting(){
}
/*
function get() {
if(file_exists("configs/db.config"))
{
$this->config=file("configs/db.config");
}
return $this->config ;
}*/
function update( $host, $db, $user, $pass ) {
$fp=fopen("configs/config.php",w);
$data = "<?php\r\n";
$data .= '$host_name = ' . "'" .$host . "';\r\n";
$data .= '$db_name = ' . "'" . $db . "';\r\n";
$data .= '$user_name = ' . "'" .$user . "';\r\n";
$data .= '$password = ' . "'" .$pass . "';\r\n";
$data .= '?>';
fwrite($fp,$data);
fclose($fp);
return ;
}
}
class backup_setting {
function backup_setting(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select bk_dir,last_bk_date, bk_scheduler from control_panel");
return $this->selectObj->resultset() ;
}
function update( $bdir, $durarion ) {
$query="update control_panel set ";
$query="$query bk_dir='".($bdir)."',";
$query="$query bk_scheduler='".($durarion)."'";
$this->insertObj->query($query);
return ;
}
function get_last_backup() {
$this->selectObj->query("select last_bk_date from control_panel");
$ar = $this->selectObj->resultset() ;
return $ar[0]->last_bk_date;
}
function update_last_backup() {
$data= date("d-M-Y");
$query="update control_panel set";
$query="$query last_bk_date='".($data)."'";
$this->insertObj->query($query);
return ;
}
}
/*class login_setting {
function login_setting(){
$this->config="";
}
function get() {
if(file_exists("configs/login.config"))
{
$this->config=file("configs/login.config");
}
return $this->config ;
}
function update( $user, $pass ) {
$fp=fopen("configs/login.config",w);
$data= "$user\n" .
"$pass\n" ;
fwrite($fp,$data);
fclose($fp);
return ;
}
}*/
class form_setting {
function form_setting(){
$this->insertObj= new DB;//insert and update
$this->selectObj= new DBr;//select only
}
function get() {
$this->selectObj->query("select sty, form_name,location, progress, weather,footer,header, uformprotect,thankyoumsg,notification,redirecturl,uploademail,sendconfirmation,confirmtitle,confirmmsg,public_reg from control_panel");
return $this->selectObj->resultset() ;
}
function update($sty, $form_name,$location, $progress, $weather, $uformprotect,$header,$footer,$thank_you,$notification,$redirecturl,$uploademail,$sendconfirmation,$confirmtitle,$confirmmsg,$public_reg) {
$query="update control_panel set ";
$query="$query sty='".$sty."',";
$query="$query form_name='$form_name',";
$query="$query location='$location',";
$query="$query progress='$progress',";
$query="$query weather='$weather',";
$query="$query uformprotect='$uformprotect',";
$query="$query header='$header',";
$query="$query footer='$footer',";
$query="$query thankyoumsg='$thank_you',";
$query="$query notification='$notification',";
$query="$query redirecturl='$redirecturl',";
$query="$query uploademail='$uploademail',";
$query="$query sendconfirmation='$sendconfirmation',";
$query="$query confirmtitle='$confirmtitle',";
$query="$query confirmmsg='$confirmmsg',";
$query="$query public_reg='$public_reg'";
$this->insertObj->query($query);
return ;
}
}
class deleter
{
//function for deleting folders
function recursive_remove_directory($directory, $empty=FALSE)
{
// if the path has a slash at the end we remove it here
if(substr($directory,-1) == '/')
{
$directory = substr($directory,0,-1);
}
// if the path is not valid or is not a directory ...
if(!file_exists($directory) || !is_dir($directory))
{
// ... we return false and exit the function
return FALSE;
// ... if the path is not readable
}elseif(!is_readable($directory))
{
// ... we return false and exit the function
return FALSE;
// ... else if the path is readable
}else{
// we open the directory
$handle = opendir($directory);
// and scan through the items inside
while (FALSE !== ($item = readdir($handle)))
{
// if the filepointer is not the current directory
// or the parent directory
if($item != '.' && $item != '..')
{
// we build the new path to delete
$path = $directory.'/'.$item;
// if the new path is a directory
if(is_dir($path))
{
// we call this function with the new path
recursive_remove_directory($path);
// if the new path is a file
}else{
// we remove the file
unlink($path);
}
}
}
// close the directory
closedir($handle);
// if the option to empty is not set to true
if($empty == FALSE)
{
// try to delete the now empty directory
if(!rmdir($directory))
{
// return false if not possible
return FALSE;
}
}
// return success
return TRUE;
}
}
}
?>