News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Attachment path error in log file

Started by EL34, April 19, 2014, 10:45:37 AM

Previous topic - Next topic

EL34

Recently I created a 2nd attachments folder on the server.
So now I have attachments and attachments2 folders

Attachments are being uploaded to the new attachments2 folder and they are being displayed in the topics, no problems there

However, I just noticed that I am getting an error in the log when I access Attachment settings in Admin - Maintenance - attachment settings.

It says not within the allowed path
I ran repair_settings.php just to double check everything and repair settings says that the paths to both attachments folders are fine

They must be correct because both folders are serving up attachments in the messages just fine

See the screen shot for the error message

This is what is written into the settings table for attachmentUploadDir and that setting appears in the error message.
I blanked out the website name  on the message below and the screen shot

a:2:{i:1;s:58:"C:\Inetpub\vhosts\mywebsite.com\httpdocs\Forum/attachments";i:2;s:59:"C:\Inetpub\vhosts\mywebsite.com\httpdocs\Forum/attachments2";}

Anyone have any idea what is causing this error?
Thanks
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

margarett

Actually I think you are very correct... If you have more than 1 attachments folder, they are serialized into the settings field:
a:2:{i:1;s:32:"C:\xampp\htdocs\smf2/attachments";i:2;s:33:"C:\xampp\htdocs\smf2/attachments2";}
That translates into:
Array
(
    [1] => C:\xampp\htdocs\smf2/attachments
    [2] => C:\xampp\htdocs\smf2/attachments2
)


But in that line, where it's checked if valid:
$context['valid_upload_dir'] = is_dir($modSettings['attachmentUploadDir']) && is_writable($modSettings['attachmentUploadDir']);
Does it take serialized arguments? Seems not :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

EL34

yeah, that seems to be the case
I was looking at that code line in ManageAttachments.php

$context['valid_upload_dir'] = is_dir($modSettings['attachmentUploadDir']) && is_writable($modSettings['attachmentUploadDir']);

If that line needs to be fixed, what would be the correct code?
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

EL34

Now that I think about it Margaret, the only valid upload directory is attachments2
attachments was retired because it has over 21,000 files and now attachments2 is where all the attachments are being uploaded

So, could attachments be removed as a valid upload folder leaving only attachments2?
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

margarett

Well, the thing is... It's only relevant when there is only one attachment folder...

So it would be something like:
if (empty($modSettings['currentAttachmentUploadDir']))
$context['valid_upload_dir'] = is_dir($modSettings['attachmentUploadDir']) && is_writable($modSettings['attachmentUploadDir']);
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

EL34

don't know if you saw my post right above yours as you were typing
Is that code line still relevant being as attachments2 is the only valid upload folder?

looks to me like attachments should be removed as a valid upload folder in settings?
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

margarett

I did see it.

There is always just one upload folder in each moment in SMF. You can't (as a user) choose here is your upload going ;)

If you remove /atttachments, you will remove any connection from SMF to it, meaning you will not be having the attachments inside available anymore.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

EL34

I guess that the database table settings entry is a list of all valid attachments folders, but only one is the valid upload folder.

So entry #2 in that settings array is my valid upload folder.

should I give your code line a try and see what happens?
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

margarett

I did try it. It only serves to show a red text if the path is invalid.
BUT if you use multiple folders, it does nothing really :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Kays

$modSettings['attachmentUploadDir'] can be either an array or a string. Usually before it's used there's a check performed to make sure that it's a string. That check seems to be missing here. ???

Before line 155 where the problem is occuring add the following:


if (!empty($modSettings['currentAttachmentUploadDir']))
{
if (!is_array($modSettings['attachmentUploadDir']))
{
$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
$modSettings['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
}
}

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

EL34

#10
will do, be right back......

Back,
All seems well
No errors in the log when I visit the attachments settings page in admin
Attachments display correctly in messages from both attachment folders

I also did a test post where I uploaded a small attachment and then checked the attachments table
It was uploaded into the correct folder and it shows 2 in the id_folder column in the attachments table .  ;D

Thanks!

I guess this patch will be in the next release?
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

Kays

Cool, I'm suprised that no one has noticed this before. ::)

Now,you do have open_basedir in effect for the temp folder which affects how SMF handles any uploaded files. Which might be the reason.

For SMF 2.1 $modSettings['attachmentUploadDir'] is an array by default and that check is handled correctly there.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

EL34

Quote from: Kays on April 19, 2014, 02:43:34 PM
Cool, I'm suprised that no one has noticed this before. ::)

Me too
I just upgraded from 1.1.19 a week or so ago
I have been chasing down several gremlins such as is since the upgrade

The upgrade from 1.1.19 had allot of surprises that a clean install of 2.0.7 that I did, did not have

The attachment error thing just popped up after I added the 2nd attachments folder a few days ago

one more off the list.  :)
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

Advertisement: