Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mod_rewrite image protection
- function getImageFromOutside ( $homePath, $file )
- {
- if ( file_exists ( $homePath . '/' . $file ) )
- {
- $contents = file_get_contents ( $homePath . '/' . $file );
- return $contents;
- }
- }
- $homePath = 'some_path/img';
- if ( isset ( $_GET['uid'] ) )
- {
- $img = $_GET['uid'] . '.jpeg';
- header ( 'Content-type: image/jpeg' );
- echo getImageFromOutside( $homePath, $img );
- } else {
- print_r ( $_GET );
- echo file_exists ( $homePath . '/' . $file );
- }
- RewriteEngine On
- RewriteCond %{HTTP_REFERER} !^$
- RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/.*$ [NC]
- RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/.*$ [NC]
- RewriteRule ^/PublicFiles/*$ /page-about-direct-links.html
Advertisement
Add Comment
Please, Sign In to add comment