Advertisement:

Author Topic: Attachment Download Permission  (Read 55604 times)

Offline Bounda

  • Newbie
  • *
  • Posts: 6
Attachment Download Permission
« on: July 23, 2006, 12:51:27 PM »
When i allowed guests to view downloads, they were allowed to download them too. When i used to be on 1.0.7 it would only let them view the download, if they clicked it they were redirected to a login page. I want to be able to do this on 1.1RC2, and its really been annoying me. If i knew what file to look in, i could try to do it myself, but i have absolutely no knowledge of php. Just a quick overview.

What i want:

Guests view attachments, but when clicked, redirected to a login page.

What 1.1RC2 Has

Guests view attachments, and can download them if View Attachments is enabled through permissions. I want them to see them, but be redirected to a login page like i said before.

Please Reply Back
~Bounda

EDIT:  This is now a mod
http://mods.simplemachines.org/index.php?mod=406
« Last Edit: August 02, 2006, 01:46:23 PM by Jay The Code Monkey »

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,561
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: Guests 'View Attachments' Problem
« Reply #1 on: July 23, 2006, 07:44:06 PM »
Ok this should work.

In Display.php
Code: (find) [Select]
if (!empty($modSettings['attachmentEnable']) && allowedTo('view_attachments'))
Replace
Code: (replace) [Select]
if (!empty($modSettings['attachmentEnable']) && (allowedTo('view_attachments') || allowedTo('view_attachments2')))

In ManagePermissions.php
Code: (find) [Select]
'attachment' => array(
'view_attachments' => false,
'post_attachment' => false,
)
Replace
Code: (replace) [Select]
'attachment' => array(
'view_attachments' => false,
'view_attachments2' => false,
'post_attachment' => false,
)

In ManagePermissions.english.php
Code: (find) [Select]
$txt['permissionname_view_attachments'] = 'View attachments';
$txt['permissionhelp_view_attachments'] = 'Attachments are files that are attached to posted messages. This feature can be enabled and configured in \'Edit Features and Options\'. Since attachments are not directly accessed, you can protect them from being downloaded by users that don\'t have this permission.';
Replace
Code: (replace) [Select]
$txt['permissionname_view_attachments'] = 'Download attachments';
$txt['permissionhelp_view_attachments'] = 'Download Attachments';
$txt['permissionname_view_attachments2'] = 'View attachments';
$txt['permissionhelp_view_attachments2'] = 'Attachments are files that are attached to posted messages. This feature can be enabled and configured in \'Edit Features and Options\'. Since attachments are not directly accessed, you can protect them from being downloaded by users that don\'t have this permission.';
« Last Edit: July 24, 2006, 02:25:53 PM by Jay The Code Monkey »
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Bounda

  • Newbie
  • *
  • Posts: 6
Re: Guests 'View Attachments' Problem
« Reply #2 on: July 24, 2006, 12:41:52 PM »
im working on it right now, and if it does then i love u =D ill edit this post when finished
/edit  :'( everything else worked but when i entered the forum, i got this

Parse error: syntax error, unexpected '{' in /home/bnews/public_html/Sources/Display.php on line 716

is it because im using tinyportal?
« Last Edit: July 24, 2006, 12:57:26 PM by Bounda »

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,561
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: Guests 'View Attachments' Problem
« Reply #3 on: July 24, 2006, 02:25:26 PM »
Sorry I missed a ) in the Display.php changes.

Change
(allowedTo('view_attachments') || allowedTo('view_attachments2'))
to
(allowedTo('view_attachments') || allowedTo('view_attachments2')))
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Bounda

  • Newbie
  • *
  • Posts: 6
Re: Guests 'View Attachments' Problem
« Reply #4 on: July 24, 2006, 03:02:49 PM »
I love u monkey  :-* lol =D it works =D

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,561
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: Guests 'View Attachments' Problem
« Reply #5 on: July 24, 2006, 03:09:29 PM »
Glad to hear it worked.

* Jay The Code Monkey moves this to [[tips and tricks]].
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline WifiGamer

  • Newbie
  • *
  • Posts: 7
Re: Attachment Download Permission
« Reply #6 on: March 06, 2007, 05:42:43 AM »
I tried this mod on version 1.1.2 and it installed without a hitch however the problem arose when I tested it.

it created the 2 different permissions but if I allow them to view the attachment but disallow to download then if it's a picture it doesn't show up.  But if I allow them to download then it's like the mod doesn't exist.

What I wanted was to remove the download link below the picture.  Not sure if this mod is the one I need?

Offline coffeejunkie

  • Newbie
  • *
  • Posts: 1
Re: Attachment Download Permission
« Reply #7 on: March 30, 2007, 03:39:46 PM »
A related question: I have a registered-only site and need to be sure that posts and attachments are not accessible to the public.  Does the above solution prevent access to attachments even if the direct link is known?

The SMF feature list says the following on attachments (http://www.simplemachines.org/about/features.php)

Quote
Ability to restrict such that only registered members can view them (disables hotlinking, mostly.)

But this seems to suggest that someone who's not registered but knows the link can still get the attachment?

Thanks for advice and pointers!


Offline DELHI_BOY

  • Jr. Member
  • **
  • Posts: 106
Re: Attachment Download Permission
« Reply #9 on: June 30, 2009, 05:43:05 AM »
i am using smf 1.1.9. I could not found display.php file, where is this located? I want this feature.

Offline bradcapo1

  • Newbie
  • *
  • Posts: 1
Re: Attachment Download Permission
« Reply #10 on: July 22, 2009, 11:32:25 PM »
Thanks everyone for your support, you're the best!!



hxxp:pret-auto.org [nonactive] - taux pret auto differe selon la rise en compte ... calculent automatiquement le taux pour un prêt automobile donne.

Offline Nityananda Maity

  • Semi-Newbie
  • *
  • Posts: 36
  • Gender: Male
  • Old/lost days inspire me
Re: Guests 'View Attachments' Problem
« Reply #11 on: August 06, 2012, 01:15:56 AM »
Glad to hear it worked.

* Jay The Code Monkey moves this to Tips and Tricks.
How I can use it on SMF 2.0.2?
Thanks
« Last Edit: August 06, 2012, 08:35:26 AM by Nityananda Maity »