Digital Media on the web

CrashNet

Well-Known Member
Original Poster
Ok, I have a friend with their own server, and they put videos on it. Recently the server has been going down because so many people are directly linking the videos on other pages/forums/etc. Is there a way to set it up so if someone directly links a video (say an mpeg), it will go to a "you cannot access this file directly" page, to the index page of the website, or something?
 

NowInc

Well-Known Member
Find an "anit-leetch" code out there....dont have one off hand.

Another suggestion..is to zip up the movies and PW protect them (make the PW his site URL) so that IF someone steals it..they need the PW to watch...
 

mkt

When a paradise is lost go straight to Disney™
Premium Member
sounds about right...

people leeching images off my site was the reason I shut it down
 

CrashNet

Well-Known Member
Original Poster
Thanks Dan and mkt...

Would either one of you happen to know how to modify this script to protect mpegs (its says it can but I'm not good with php). Also, where do I put it and how do I use it?

PHP:
<?
/*** Let's Roll!
*
*
* Sample Usage:
*
* <img src="image.php?myLogo.gif" />
*
*
* You can freely use this script as long as this header remains intact
*
**/
 

 $allowed = array ( '4arrow.com' , 'montros.org' , 'phportal.org' );
 
 $ref  = $_SERVER['HTTP_REFERER'];
 
 $imagedir = '/HiddenPathTo/MyImages/';
 
 $image  = $argv[0];
 
 if ( $ref != '' && $image != '' ) {
 
  foreach ( $arr as $u ) {
 
   if ( strpos ( $ref , $u ) !== false ) {
 
    $g=1;
   break;
 
   }
 
  }
 
  if ( $g != 1 ){
 
   die ( Header( 'HTTP/1.0 403 Forbidden' ) );
 
  } else {
 
   // load image
 
   $imagepath = $imagedir . $image;
 
   $imageinfo = getimagesize ( $imagepath );
 
   $fp = fopen ( $imagepath , 'rb' );
 
   if ( $imageinfo && $fp ) {
 
      header ( 'Content-Type: ' . $imageinfo['mime'] );
 
      die ( fpassthru ( $fp ) );
 

   } else {
 
    die ( Header ( 'HTTP/1.0 404 Not Found' ) );
 
   }
  
 }
 

 } else {
 
  // direct call redirect to root
 
  die ( header ( 'Location: /' ) );
 
 }
 
 ?>

Thanks in advance!
 

NowInc

Well-Known Member
Simple...basically..THAT code stays the same

but..the way you use it is by doing::

<.img src="image.php?yourMOVIE.mpg"/.>

minus the . of course
 

Bagheera

New Member
Dan,

Shouldn't he also need to change the entries in the $allowed array? Otherwise, he'd only be allowing folks who are linking from 4arrow.com, montros.org, and phportal.org, if I'm reading the code correctly.

Or am I a bit too rusty?

Mark
 

CrashNet

Well-Known Member
Original Poster
Originally posted by Bagheera
Dan,

Shouldn't he also need to change the entries in the $allowed array? Otherwise, he'd only be allowing folks who are linking from 4arrow.com, montros.org, and phportal.org, if I'm reading the code correctly.

Or am I a bit too rusty?

Mark

See thats what I thought Bagheera. I'm pretty sure I have to change that, I just don't know what to. Oh yeah, and can this file be stand alone (like movieProtect.php) or do I need to insert this code in the page itself. I know you can do either with javascript, but I'm just looking for the easiest way.

One other thing, can I change the /HiddenPathTo/MyImages to whatever I need?
 

NowInc

Well-Known Member
Originally posted by Bagheera
Dan,

Shouldn't he also need to change the entries in the $allowed array? Otherwise, he'd only be allowing folks who are linking from 4arrow.com, montros.org, and phportal.org, if I'm reading the code correctly.

Or am I a bit too rusty?

Mark

Very true..I overlooked that (oops)
 

CrashNet

Well-Known Member
Original Poster
Originally posted by NowInc
Very true..I overlooked that (oops)

So basically I just put the URL of the website in the array, meaning that only people who are linking to the file from the website itself will have access to the file.
 

CrashNet

Well-Known Member
Original Poster
Originally posted by Bagheera
Sounds right. And you should, indeed, change the /HiddenPathTo/MyImages to the location of your files.

Thank you both. One final question:

PHP:
<img src="image.php?myLogo.gif" />

is image.php? the name of the file this script is saved into or do I tell him to put the script directly into the webpage file?

Obviously I'm showing just how STUPID I am when it comes to php! :lol:

Thanks again!:D
 

Register on WDWMAGIC. This sidebar will go away, and you'll see fewer ads.

Back
Top Bottom