Admin Upload Utility


  -----  
Author Message

Jleagle
Member

Tue Nov 21, 2006 6:52 pm   Post subject: Admin Upload Utility
Hi there, ive installed this on a forum hosting site, so forum-admins can upload there own avatars.

I was thinking of giving each forum 1 folder, as a category. eg. images/avatars/gallery/*forum_id*/

If i installed the avatar module as is, it would allow every admin to delete other admins images... so i was wondering is there a way to only let admins have access to the one folder?

The forum ID is simply $_GET['mforum']

Thanks
 

Thoul
Administrator

Tue Nov 21, 2006 8:06 pm   Post subject: re: Admin Upload Utility
It can be done with some changes in module_avagallery.php. Replace the contents of that file with this code:
http://www.phpbbsmith.com/files/module_avagallery.txt
That should handle it. I haven't had a chance to test this yet myself, so you may want to do that before making it available to others.
 

Jleagle
Member

Thu Nov 23, 2006 10:03 am   Post subject:
im sorry i forgot to mention that the forum ID is a string, not an integer so i removed all the intval's and it worked fine.

is there a way to create the images/avatars/gallery/*** folder automaticly because it comes up with errors saying the folder doesnt exist.

Thanks
 

Thoul
Administrator

Sat Nov 25, 2006 7:59 am   Post subject: re: Admin Upload Utility
Sure. Find this line in that file:

Code:

$avatar_dir = opendir($path);


Before it, add:

Code:

if( !file_exists($path) )
{
   mkdir($path);
   chmod($path, 0777);
}
 

Jleagle
Member

Sat Nov 25, 2006 1:40 pm   Post subject: re: Admin Upload Utility
thanks that works great.. do you need to chmod anything for the delete function to work? cos mine doesnt.
 

Thoul
Administrator

Tue Nov 28, 2006 2:27 pm   Post subject: re: Admin Upload Utility
Usually only the directories need to be chmodded. If you have any existing avatars, they may also need to be chmodded individually. Usually that's not necessary, but some server setups require it. Try it and see if it helps.
 

Jleagle
Member

Wed Nov 29, 2006 12:48 pm   Post subject: re: Admin Upload Utility
it wont let me manually chmod any image uploaded from the mod :S, it says they are already 777 too. I can manually delet ebut the mod delete button does nothing :S
 

Thoul
Administrator

Wed Nov 29, 2006 1:59 pm   Post subject: re: Admin Upload Utility
Ok, in the module_avagallery.php, find this line:

Code:

      if( file_exists($path . $subcat . $name) )


Before it, add:

Code:

      $path = ( strrpos($path, '/') !== strlen($path) ) ? $path . '/': $path;
      $path .= $_GET['mforum'];


Then try deleting again. The paths were probably being carried over without the forum id, and hopefully this will correct that.
 

Jleagle
Member

Wed Nov 29, 2006 4:58 pm   Post subject: re: Admin Upload Utility
doesnt seem to make any difference :S
 

Thoul
Administrator

Thu Nov 30, 2006 5:28 pm   Post subject: re: Admin Upload Utility
Hm. Are you at least getting a message that the deletion failed? If so, it's possible that deleting may not work on this server for some reason. Try finding this line in module_avagallery.php:

Code:

         if( @unlink($path . $subcat . $name) )


Remove the @ there. That will cause the page to display any PHP-level error messages. If deleting is disabled, there should be one of those saying something about it.
 

Page 1 of 2
Go to page 1, 2  Next
Display posts from previous: