diff options
author | Christian Vogeley <christian.vogeley@hotmail.de> | 2014-12-07 21:20:52 +0100 |
---|---|---|
committer | Christian Vogeley <christian.vogeley@hotmail.de> | 2014-12-07 21:20:52 +0100 |
commit | 406e97c9ad76975011f639a415b8139352cb23da (patch) | |
tree | 2283d68c5a36465220fca658dc3d57e7c76b4c68 /include | |
parent | f3789b1aeb35d41b4766df26806aed4544cc6006 (diff) | |
download | volse-hubzilla-406e97c9ad76975011f639a415b8139352cb23da.tar.gz volse-hubzilla-406e97c9ad76975011f639a415b8139352cb23da.tar.bz2 volse-hubzilla-406e97c9ad76975011f639a415b8139352cb23da.zip |
Remove channel cloud files from file system when
the channel is removed
Diffstat (limited to 'include')
-rw-r--r-- | include/Contact.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/Contact.php b/include/Contact.php index 64779d45f..9a3b91dc4 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -207,6 +207,7 @@ function account_remove($account_id,$local = true,$unset_session=true) { intval($account_id) ); + if ($unset_session) { unset($_SESSION['authenticated']); unset($_SESSION['uid']); @@ -216,6 +217,28 @@ function account_remove($account_id,$local = true,$unset_session=true) { return $r; } +// recursively delete a directory +function rrmdir($path) +{ + if (is_dir($path) === true) + { + $files = array_diff(scandir($path), array('.', '..')); + + foreach ($files as $file) + { + rrmdir(realpath($path) . '/' . $file); + } + + return rmdir($path); + } + + else if (is_file($path) === true) + { + return unlink($path); + } + + return false; +} function channel_remove($channel_id, $local = true, $unset_session=true) { @@ -311,6 +334,19 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { dbesc($channel['channel_hash']) ); } + + //remove from file system + $r = q("select channel_address from channel where channel_id = %d", + intval($channel_id) + ); + if($r) + $channel_address = $r[0]['channel_address'] ; + if ($channel_address !== '') { + $f = 'store/' . $channel_address.'/'; + logger ('delete '. $f); + if(is_dir($f)) + @rrmdir($f); + } proc_run('php','include/directory.php',$channel_id); |