Welcome Guest, Not a member yet? Register   Sign In
Restrict direct image viewing
#11

[eluser]Aquillyne[/eluser]
I'm trying to do something similar (the same?) here.

I want images to display when they're part of one of my pages, but not if accessed directly by URL.

For instance: index.php has an image on it, with src = "./images/foo.jpg". I want it to show for everyone on index.php. But if they try to go to the URL ./images/foo.jpg directly it shouldn't deliver them anything.

The standard way to approach this is to deliver the image by a function. Thus, the image src = "image.php?=foo", or in CI something like "image/foo". The image is now delivered through a controller. And the function, whatever it is, only delivers the image if it's being accessed through one of the site's normal pages.

But the problem is the following. In normal PHP you can just hard-code the image PHP file to do what you want. If you want to use a CI controller to do the trick, you can't. Because: every controller is run through the core CI files (index, etc.) - in other words, your image-delivery function is automatically a normal page of your site - there's no way to distinguish it from any other page. Any way of disabling access to it will disable the images in your normal pages too.

The only real way I can see to get around this is to, manually in each and every "normal" page, set a session variable. If that variable is present, images are shown. Eventually it will run out and images won't be shown by directly accessing the image controller anymore. But this is very clumsy. Anyone got a better way?


Messages In This Thread
Restrict direct image viewing - by El Forum - 06-05-2008, 06:11 PM
Restrict direct image viewing - by El Forum - 06-06-2008, 12:28 AM
Restrict direct image viewing - by El Forum - 06-06-2008, 12:40 AM
Restrict direct image viewing - by El Forum - 06-06-2008, 01:05 AM
Restrict direct image viewing - by El Forum - 06-06-2008, 01:50 AM
Restrict direct image viewing - by El Forum - 06-06-2008, 01:14 PM
Restrict direct image viewing - by El Forum - 06-07-2008, 12:41 PM
Restrict direct image viewing - by El Forum - 06-07-2008, 06:18 PM
Restrict direct image viewing - by El Forum - 06-08-2008, 02:06 AM
Restrict direct image viewing - by El Forum - 06-09-2008, 02:17 AM
Restrict direct image viewing - by El Forum - 06-09-2008, 06:52 PM
Restrict direct image viewing - by El Forum - 06-09-2008, 08:09 PM
Restrict direct image viewing - by El Forum - 06-10-2008, 09:03 AM
Restrict direct image viewing - by El Forum - 06-10-2008, 10:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB