Jump to content

Help!... how can i prevent the direct viewing of an image or php file


MrMuler

Recommended Posts

hi.

 

How can i prevent the direct viewing of an image or php file.

 

I tried to resolve it with that:

 

if ( $PHP_SELF == "../../index.php" ) {

displayContent();

} else {

displayError();

}

but it doesnt work....

 

if somebody knows how i can restrict the direct access to files or images with .htaccess or php to restrict direct access to the file.... please let me know!!

I always use the joomla solution

 

<?PHP
// main page
define('_CONSTANT', 0x0001); // fancy way for setting something to true

// page which should not be accessed directly but is included on the main page
defined('_CONSTANT') or exit('FATAL ERROR: You are not authorized to access this file directly.');

?>

direct view, is when you see the file or image directly....

 

for example: an image...


Indirect view is like this:

 

<html>
......
......
<body>
<img scr="Smileys/default/shocked.gif">
</body>
</html>

You'll see the image in the page! just like this  :o


a Direct view is when you want to access to an image like this:

 

<html>
......
......
<body>
<a href="Smileys/default/shocked.gif">Direct Image</a>
</body>
</html>

so if you click http://www.phpfreaks.com/forums/Smileys/default/shocked.gif, you'll view the image directly


With php is the same concept, Indirect is when you see the page in a iframe, or its included in another page... and Direct is when you see the original file!

With php is the same concept, Indirect is when you see the page in a iframe, or its included in another page... and Direct is when you see the original file!
No its also direct access.

Indirect Access is not that what you want.

when a php scripts outputs the image with MIME Type image/png or image/jpeg or image/gif or others then it may be called as an indirect access.Cause access to that image can be controled by that php script.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.