Avatar upload directory not writeable

Started by Cccddd, February 25, 2008, 05:01:30 PM

Previous topic - Next topic

Cccddd

I am using SMF 2.0 beta 2.1
Mozilla firefox latest stable

When I installed this SMF, it was to a different folder (fresh install) than it currently sits. I then moved it and changed all the urls and folder pointers everywhere that I could find. I'm not sure if this has ANY bearing on the problem below, but I thought I should mention it since it has to do with file paths.

I tried to upload an avatar today and it said that the attachments folder was not writeable. It was. I checked all the paths and everything was fine.

So I went into Profile-Modify.php and did some digging around.


function profileSaveAvatarData(&$value)
{
        global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context;

        $memID = $context['id_member'];
        if (empty($memID) && !empty($context['password_auth_failed']))
                return false;

        // Reset the attach ID.
        $cur_profile['id_attach'] = 0;
        $cur_profile['attachment_type'] = 0;
        $cur_profile['filename'] = '';

        require_once($sourcedir . '/ManageAttachments.php');

        // We need to know where we're going to be putting it..
        if (!empty($modSettings['custom_avatar_enabled']))
        {
                $uploadDir = $modSettings['custom_avatar_dir'];
                $id_folder = 1;
        }


This is the part that I eventually pinpointed as the problem. Basically I don't use a custom avatar folder. I just use the server's attachment folder. Well apparently if you don't use a custom avatar folder, it has no idea where to upload to! Or at least I think that's what happened.

Anyways I modified the code and added this:

function profileSaveAvatarData(&$value)
{
        global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context;

        $memID = $context['id_member'];
        if (empty($memID) && !empty($context['password_auth_failed']))
                return false;

        // Reset the attach ID.
        $cur_profile['id_attach'] = 0;
        $cur_profile['attachment_type'] = 0;
        $cur_profile['filename'] = '';

        require_once($sourcedir . '/ManageAttachments.php');

        // We need to know where we're going to be putting it..
        if (!empty($modSettings['custom_avatar_enabled']))
        {
                $uploadDir = $modSettings['custom_avatar_dir'];
                $id_folder = 1;
        }
        else
        {
                $uploadDir = $modSettings['attachmentUploadDir'];
                $id_folder = $modSettings['currentAttachmentUploadDir'];
        }


You'll notice the else statement at the bottom there. Basically I told it to use the attachment directory. It really should be checking for this sort of thing, and I think it's possible that it IS actually checking somewhere, but for some reason it just didn't work properly on my server.

Anyways this little else statement cleared up my problem but it's a hack job. There needs to be something better in place to actually check the server settings that are entered into the admin page.

SleePy

This was fixed in SVN.. Though I just noticed a related bug to this..  :P
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Cccddd


Advertisement: