1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Only allow specific domain to download file

Discussion in 'Programming' started by Drew007, Apr 21, 2008.

  1. #1
    What I need: Script that allows only those subscribing to our service to be able to play a specific flv on their domain. The only way for them to access the flv file for their website is if I allow their domain (website) to access the file. They cannot use same "embed code" on multiple domains.

    Is this possible? How? Thanks in advance!
     
    Drew007, Apr 21, 2008 IP
  2. Randombase

    Randombase Peon

    Messages:
    224
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    A reasonably safe method would be blocking referers that aren't in the allowed list:
    <?php
    $referers = array('alloweddomain1.com','alloweddomain2.com');
    if(!empty($_SERVER['HTTP_REFERER']))
    {
    	$parts = parse_url($_SERVER['HTTP_REFERER']);
    	$parts['host'] = str_replace('www.','',$parts['host']);
    	if(in_array($parts['host'],$referers))
    	{
    	
    	}
    	else
    	{
    		die('Not allowed!');
    	}
    }
    else
    {
    	die('Not allowed!');
    }
    ?>
    PHP:
    This makes it impossible to embed the video's directly :).
     
    Randombase, Apr 21, 2008 IP
    Drew007 likes this.
  3. Drew007

    Drew007 Peon

    Messages:
    310
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks I will give this one a try. Rep added!
     
    Drew007, Apr 21, 2008 IP
  4. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #4
    Change
    $parts['host'] = str_replace('www.','',$parts['host']);

    to

    $parts['host'] = strtolower(str_replace('www.','',$parts['host']));

    To allow capitalization variation.

    Also this method is easy to break with simple PHP.

    Peace,
     
    Barti1987, Apr 21, 2008 IP
  5. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Another way not mentioned is using Flash's allowDomain function, edit your flv player to only allow the domains that are registered.

    
    System.security.allowDomain("www.thesite.com");
    System.security.allowDomain("www.anothersite.com");
    
    Code (markup):
    Might be a bit simpler. . .
     
    ToddMicheau, Apr 21, 2008 IP