Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    118
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Hiding FLV path.

    Hello I've been trying to hide my FLV videopath because I don't want the average user to download stuff directly from server or people leeching my bandwidth.

    This is the script that get's video URL based on QueryString ID
    PHP Code:
    <?php
        
    if (isset($_GET['id']) && file_exists('videos/video' str_pad($_GET['ID'], 3'0'STR_PAD_LEFT) . '.flv'))
        {
            
    header('Content-type: flv-application/octet-stream');
            
    readfile('videos/video' str_pad($_GET['ID'], 3'0'STR_PAD_LEFT) . '.flv'); 
        }
        else
        {
            
    header('HTTP/1.0 404 Not Found'); 
        } 
    ?>
    This is the video code:
    Code:
        <script type="text/javascript" src="http://www.site.com/embed/swfobject.js"></script>
    	<div id="player"><p align="center">
    	<img alt="http://www.arunbhatia.com/images/error-icon.jpg" src="http://www.arunbhatia.com/images/error-icon.jpg"><br>
    	It seems you have an outdated Flash player installed. <b>
    	<a href="http://get.adobe.com/flashplayer/">Click here to get the latest Adobe 
    	Flash Player!</a></b></p></div>
     
    	<script type="text/javascript">
    	var so = new SWFObject('http://www.site.com/jw/embed/player.swf','mpl','600','450','9');
    	so.addParam('allowscriptaccess','always');
    	so.addParam('allowfullscreen','true');
    	so.addParam('flashvars','&file=playvideo.php?ID=1');
    	so.write('player');
    	</script>
    It won't work, I get error message that the file is not found. Can anyone please help?

  • #2
    Regular Coder
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    118
    Thanks
    8
    Thanked 2 Times in 2 Posts
    No one can help on this subject?

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Query string variables are case sensitive. You have $_GET['id'] in some places but in your code you are using $_GET['ID'] as well.

    If you did
    PHP Code:
    <?php
    echo $_GET['ID'];
    ?>
    On a url such as test.php?id=blah nothing would get echoed out. However if you did test.php?ID=blah then it would work.

    Also learn to be patient. We are here on our own time. A little research on your own would have solved this problem.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    Regular Coder
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    118
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Yeah, I know that it's case-sensetive. I've tried both, but they won't work.

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    With the code you posted above you will always get the else. If you keep your current html and use this for your php it should work
    PHP Code:
    <?php
        
    if (isset($_GET['ID']) && file_exists('videos/video' str_pad($_GET['ID'], 3'0'STR_PAD_LEFT) . '.flv'))
        {
            
    header('Content-type: flv-application/octet-stream');
            
    readfile('videos/video' str_pad($_GET['ID'], 3'0'STR_PAD_LEFT) . '.flv'); 
        }
        else
        {
            
    header('HTTP/1.0 404 Not Found'); 
        } 
    ?>
    If that does work compare it to your old code and tell me why it works. If it doesn't work then just before your if statement add this
    PHP Code:
    echo file_exists('videos/video' str_pad($_GET['ID'], 3'0'STR_PAD_LEFT) . '.flv'
    Post what you get here. Also at the very top of your php add this
    PHP Code:
    ini_set('display_errors','1');
    error_reporting(E_ALL); 
    Once you have working remove the above two lines.
    Last edited by _Aerospace_Eng_; 03-03-2009 at 02:51 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Does this work with files that are not hosted on your server? I tried using readfile on an external flv before, but it only shows a loading sign forever. Any ideas?

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I don't know if readfile works with files from different servers for security reasons. Why are you worried about hiding files that you are getting from other servers? Do you have permission to use those files?
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •