Skip to content

Commit

Permalink
Compatibility with older versions
Browse files Browse the repository at this point in the history
Signed-off-by: Suki <suki@missallsunday.com>
  • Loading branch information
MissAllSunday committed Sep 15, 2013
1 parent de11d55 commit 17240c3
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Sources/Subs.php
Expand Up @@ -3362,6 +3362,12 @@ function getAttachmentFilename($filename, $attachment_id, $dir = null, $new = fa
if ($new)
return sha1(md5($filename . time()) . mt_rand());

// Set the var to return.
$return_file = '';

// Give credit where credit is due...
$FileZilla_ext = '.iso';

// Grab the file hash if it wasn't added.
// @todo: Locate all places that don't call a hash and fix that.
if ($file_hash === '')
Expand Down Expand Up @@ -3395,8 +3401,21 @@ function getAttachmentFilename($filename, $attachment_id, $dir = null, $new = fa
else
$path = $modSettings['attachmentUploadDir'];

// Add a generic extension, kudos to FileZilla!
return $path . '/' . $attachment_id . '_' . $file_hash . '.iso';
// Add a generic extension to the full path
$return_file = $path . '/' . $attachment_id . '_' . $file_hash . $FileZilla_ext;

// Is this an old attachment?
if (!file_exists($return_file))
{
// Lets check if there is one without the extension
if(file_exists($path . '/' . $attachment_id . '_' . $file_hash))
{
// Do the rename and add the generic extension
rename($path . '/' . $attachment_id . '_' . $file_hash, $path . '/' . $attachment_id . '_' . $file_hash . $FileZilla_ext);
}
}

return $return_file;
}

/**
Expand Down

0 comments on commit 17240c3

Please sign in to comment.