diff options
author | mrjive <mrjive@mrjive.it> | 2014-12-08 08:51:21 +0100 |
---|---|---|
committer | mrjive <mrjive@mrjive.it> | 2014-12-08 08:51:21 +0100 |
commit | ec1a8d4e106e3ddd366b0744c4af5d9a66aebeb2 (patch) | |
tree | 98e4fb1a2d20369e284b8b3b10df313a864e4620 /include | |
parent | f1367cb9f9b86379fe5a80c69691414483e58bad (diff) | |
parent | 10d5f0eed7d3708ca5a33f426baddfdfc138ba4f (diff) | |
download | volse-hubzilla-ec1a8d4e106e3ddd366b0744c4af5d9a66aebeb2.tar.gz volse-hubzilla-ec1a8d4e106e3ddd366b0744c4af5d9a66aebeb2.tar.bz2 volse-hubzilla-ec1a8d4e106e3ddd366b0744c4af5d9a66aebeb2.zip |
Merge pull request #728 from cvogeley/master
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..4fd43db44 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 limit 1", + 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); |