Have any of you noticed a bug in the version 1.0.1 when after editing a post with an image, the image vanishes from that post even if you didn't mean to delete it?
After some re-engineering Tobi's code in file edit.php I found next:
// MOD IMAGEPOST
if((isset($_POST['delete_userimage']) and $_POST['delete_userimage'] == 1) or is_uploaded_file($_FILES['userimage']['tmp_name'])) {
include_once(PUN_ROOT.'/include/mod_imagepost.php');
@unlink($userdir .'/'. $_POST['current_userimage']);
}
if(is_uploaded_file($_FILES['userimage']['tmp_name'])) {
include_once(PUN_ROOT.'/include/mod_imagepost.php');
$name = uploadImage();
}
else $name = '';
That means that if you saving your editing post without any pointing to an image (even if you had one), the name of your image becomes blank (see the last line of code).
OK. All you should do to correct the problem, I am showing you the correct example (if Tobi doesn't' mind, of course):
// MOD IMAGEPOST
$b_deleted = true;
if((isset($_POST['delete_userimage']) && $_POST['delete_userimage'] == 1) || is_uploaded_file($_FILES['userimage']['tmp_name'])) {
include_once(PUN_ROOT.'/include/mod_imagepost.php');
@unlink($userdir .'/'. $_POST['current_userimage']);
$b_deleted=false;
}
if(is_uploaded_file($_FILES['userimage']['tmp_name'])) {
include_once(PUN_ROOT.'/include/mod_imagepost.php');
$name = uploadImage();
}
elseif ($b_deleted && isset($_POST['current_userimage'])) $name = $_POST['current_userimage'];
else $name = '';
You will never lose an image of your editing post from that time on!