0

I have a webserver with Apache.

For security reasons my customer wants to access files (.jpg/.pdf/.png/.gif) in another folder.

The root layout is as follows:

  • backup
  • data
  • etc
  • htdocs
  • logs
  • tmp

In the htdocs folder the Joomla website resides. I use flexicode to add PHP code to the site.

Is there a way I can show for example a photo in .jpg from the data folder? example. /data/werknemers/80111/pasfoto.jpg

There is a little snag. Everybody uses a pin number to log into Joomla. In this case pin 80111. Pin 80111 is added to the users table, the field is called pin.

Is it possible to use a variable to retrieve the data? So only user 80111 can access his or her folder and not another one?

The photo is shown in a module on the website after login.

Cheers,

Steve

Steve
  • 49
  • 1
  • 7

2 Answers2

1

You'll have to write a php script in joomla (for the authorisation), and give apache access to the external folder. Then deliver your files using this script.

veelen
  • 1,916
  • 19
  • 26
  • Hi veelen, thanks for your comment. The login is changed to connect to a LDAP server so I have PIN, username and password. This works. So once users login I only want to show them their photograph. Do you have an example of a PHP script I can work with? Cheers, Steve – Steve Dec 12 '13 at 11:37
  • Hi veelen, how can this be done? I mean give access to the external folder? – Steve Dec 12 '13 at 12:59
  • You can just call your img as you would normally, but not using a http request, but including it from with php – veelen Dec 12 '13 at 13:01
  • Ok but how would the script look like? I understand you can't access it via http request. Since we are logged in we can access the system but I'm not a "hardcore" programmer. I need a little bit of input on this. – Steve Dec 12 '13 at 13:06
  • 1
    look here: http://stackoverflow.com/questions/258365/php-link-to-image-file-outside-default-web-directory – veelen Dec 12 '13 at 13:10
  • Ok, this is more like it. I'll take a look Veelen. Thank you. – Steve Dec 12 '13 at 13:12
1

I'm not a Joomla user, but my first chance will be to look for some plugin to manage the uploads, I saw some plugins to manage uploads per user doing a quick google search, for example this one.

In the case that no one works for you I think the next option will be try to implement an asset proxy.

  • Write an script in htdocs to validate the PIN and if it is ok read the file content from the data directory and provide the output from that script.

  • An rewrite rule to redirect all .jpg/.pdf/.png/.gif request for that proxy will be need.

  • Be aware to serve the non secure content (theme images for example) as well.

Hope this help

casivaagustin
  • 558
  • 5
  • 7