Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

New images get wrong permissions... how to change?


charsoft

Recommended Posts

Posted

Hi, this is an ongoing problem I cannot seem to find an answer for:

I upload an image through the Admin section, and as long as I stay logged in as admin, I can see my catalog just fine. But if I go to the catalog as another user, the user sees a login box because the new picture is protected!!!

 

The catalog/images folder has permissions equiv to 777 (but I am in windows so it's the "everyone" user with RWX). But since the Admin user placed the image in the folder, you can't see the new image as a regular user. I dig around on the file system and find that, for this new image, the "everyone" user doesn't exist on the permissions set, and I have to go in and manually modify the catalog/images folder using the cascade option for all files.

 

This is a pain in the butt!! I have hunted around enough to find this code in the general.php file under catalog/admin/includes/functions ... this must be where it's happening.

-----------------------------

 

function tep_get_file_permissions($mode) {
// determine type
if ( ($mode & 0xC000) == 0xC000) { // unix domain socket
  $type = 's';
} elseif ( ($mode & 0x4000) == 0x4000) { // directory
  $type = 'd';
} elseif ( ($mode & 0xA000) == 0xA000) { // symbolic link
  $type = 'l';
} elseif ( ($mode & 0x8000) == 0x8000) { // regular file
  $type = '-';
} elseif ( ($mode & 0x6000) == 0x6000) { //bBlock special file
  $type = 'b';
} elseif ( ($mode & 0x2000) == 0x2000) { // character special file
  $type = 'c';
} elseif ( ($mode & 0x1000) == 0x1000) { // named pipe
  $type = 'p';
} else { // unknown
  $type = '?';
}

// determine permissions
$owner['read']	= ($mode & 00400) ? 'r' : '-';
$owner['write']   = ($mode & 00200) ? 'w' : '-';
$owner['execute'] = ($mode & 00100) ? 'x' : '-';
$group['read']	= ($mode & 00040) ? 'r' : '-';
$group['write']   = ($mode & 00020) ? 'w' : '-';
$group['execute'] = ($mode & 00010) ? 'x' : '-';
$world['read']	= ($mode & 00004) ? 'r' : '-';
$world['write']   = ($mode & 00002) ? 'w' : '-';
$world['execute'] = ($mode & 00001) ? 'x' : '-';

// adjust for SUID, SGID and sticky bit
if ($mode & 0x800 ) $owner['execute'] = ($owner['execute'] == 'x') ? 's' : 'S';
if ($mode & 0x400 ) $group['execute'] = ($group['execute'] == 'x') ? 's' : 'S';
if ($mode & 0x200 ) $world['execute'] = ($world['execute'] == 'x') ? 't' : 'T';

return $type .
	   $owner['read'] . $owner['write'] . $owner['execute'] .
	   $group['read'] . $group['write'] . $group['execute'] .
	   $world['read'] . $world['write'] . $world['execute'];
 }

 

 

How do I change the $mode?

 

Thanks in advance...

 

Char

Posted
Download FileZilla. It is a free ftp client then follow these instructions on how to set file permissions.

 

http://www.download.com/FileZilla/3000-2160_4-10308966.html

 

http://www.interspire.com/content/articles...ile-Permissions

 

 

Thanks, but my system is hosted on Windows so that won't work for me... the help document says:

Please note: This permissions tutorial applies to UNIX/Linux based servers only and although Windows does have a permission system, it's different and cannot be set by anyone using an FTP client.

 

Does anyone have any ideas on how to modify the script (in my original post above) so it sets the right permissions upon saving the file? My client (whose site I am trying to configure) uses the Admin function to upload images, so it really needs to be done server side, through the script.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...