diff options
author | Kate Arzamastseva <pshns@ukr.net> | 2011-05-26 14:23:33 +0300 |
---|---|---|
committer | Kate Arzamastseva <pshns@ukr.net> | 2011-05-26 14:23:33 +0300 |
commit | e4f389ef1728a0f86164a0e4b88626be9860dabb (patch) | |
tree | e2a01458fe3e04fceccb80986f61fe2a25330e0d /inc/media.php | |
parent | f05345511bace85889aa9be5a83820897d322007 (diff) | |
download | rpg-e4f389ef1728a0f86164a0e4b88626be9860dabb.tar.gz rpg-e4f389ef1728a0f86164a0e4b88626be9860dabb.tar.bz2 |
media version saving
Diffstat (limited to 'inc/media.php')
-rw-r--r-- | inc/media.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/inc/media.php b/inc/media.php index 3c9340d51..6be66dedc 100644 --- a/inc/media.php +++ b/inc/media.php @@ -346,6 +346,13 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov global $conf; global $lang; + $old = @filemtime($fn); + // + if(!@file_exists(mediaFN($id, $old)) && @file_exists($fn)) { + // add old revision to the attic if missing + saveOldMediaRevision($id); + } + // prepare directory io_createNamespace($id, 'media'); @@ -369,6 +376,26 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov } /** + * moves the current version to the media_attic and returns its + * revision date + */ +function saveOldMediaRevision($id, $move = 'copy'){ + global $conf; + $oldf = mediaFN($id); + if(!@file_exists($oldf)) return ''; + $date = filemtime($oldf); + $newf = mediaFN($id,$date); + io_makeFileDir($newf); + if($move($oldf, $newf)) { + // Set the correct permission here. + // Always chmod media because they may be saved with different permissions than expected from the php umask. + // (Should normally chmod to $conf['fperm'] only if $conf['fperm'] is set.) + chmod($newf, $conf['fmode']); + } + return $date; +} + +/** * This function checks if the uploaded content is really what the * mimetype says it is. We also do spam checking for text types here. * |