Guest User

Untitled

a guest
Jun 26th, 2012
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. mod_rewrite image protection
  2. function getImageFromOutside ( $homePath, $file )
  3. {
  4. if ( file_exists ( $homePath . '/' . $file ) )
  5. {
  6. $contents = file_get_contents ( $homePath . '/' . $file );
  7. return $contents;
  8. }
  9. }
  10. $homePath = 'some_path/img';
  11.  
  12. if ( isset ( $_GET['uid'] ) )
  13. {
  14. $img = $_GET['uid'] . '.jpeg';
  15. header ( 'Content-type: image/jpeg' );
  16. echo getImageFromOutside( $homePath, $img );
  17. } else {
  18. print_r ( $_GET );
  19. echo file_exists ( $homePath . '/' . $file );
  20. }
  21.  
  22. RewriteEngine On
  23. RewriteCond %{HTTP_REFERER} !^$
  24. RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/.*$ [NC]
  25. RewriteCond %{HTTP_REFERER} !^http://yourdomain.com/.*$ [NC]
  26. RewriteRule ^/PublicFiles/*$ /page-about-direct-links.html
Advertisement
Add Comment
Please, Sign In to add comment