Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Unset() messes up video object
Old 02-14-2009, 12:58 PM Unset() messes up video object
Junior Talker

Posts: 3
Name: Xander
Trades: 0
Dear people,

My first forum post here, and I'm from The Netherlands, so please bare with me.
I'm trying to show some QuickTime movies (.mov) on my website, but prevent direct access.

Therefore I load a php file instead of a .mov file in my player, and pass on session variables to check if the player requested the video (instead of some user directly requesting it)

The player looks something like this:

Code:
<? $_SESSION["videorequestfile"] = "test.mov"; $_SESSION["videorequest"]  = true; $_SESSION["playerrequest"] = true; ?>
<object name="video-big-quicktime" height="380" width="471" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" >
         <param name="src" value="../test/movobject.php" />
In this movobject.php file, the actual mov file is loaded, and the session variables are checked and unset.
The file is this:

Code:
<?php

    @session_start();
    if (isset($_SESSION["videorequest"]) && isset($_SESSION["videorequestfile"])) { 
      unset($_SESSION["videorequest"]);
      $_SESSION["videosubrequest"] = true;
    }
    if (! isset($_SESSION["videosubrequest"]) || ! isset($_SESSION["videorequestfile"])) { 
      unset($_SESSION["videosubrequest"]);
      unset($_SESSION["videorequestfile"]);
      die ("Direct access to video is prohibited");
    }
   
    $mov = $_SERVER["DOCUMENT_ROOT"]."/upload/videos/".$_SESSION["videorequestfile"];
  
    header('Content-type: video/quicktime');
    header('Content-Length: '.filesize($mov));
    $content = file_get_contents($mov);
    print $content;
    @unset($_SESSION["videosubrequest"]);
    
?>
The problem is, that I want the $_SESSION["videosubrequest"] variable to be unset, because if it stays in the user's session, the direct access check doesn't work.
When removing the @unset($_SESSION["videosubrequest"]); the player works fine, displays the movie perfectly. But with it, the movie is not played.
Can anyone tell me what I can do to fix this?
Any help is greatly appreciated!
xl2000 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-14-2009, 01:39 PM Re: Unset() messes up video object
Junior Talker

Posts: 3
Name: Xander
Trades: 0
I also added error_reporting(E_ALL); ini_set('display_errors',TRUE); just to be sure. Strangely, no errors appear

BTW: I tried the same script for Flash movie (.flv) using an flash player, and that works OK, even with the unset.
I don't know why (or if) there is any difference between mov and flv
xl2000 is offline
Reply With Quote
View Public Profile
 
Old 02-14-2009, 04:05 PM Re: Unset() messes up video object
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Try this, I've removed the error suppression (the @'s). See if an error occurs.

PHP Code:
<?php

    session_start
(); // Removed @
    
if (isset($_SESSION["videorequest"]) && isset($_SESSION["videorequestfile"])) { 
      unset(
$_SESSION["videorequest"]);
      
$_SESSION["videosubrequest"] = true;
    }
    if (! isset(
$_SESSION["videosubrequest"]) || ! isset($_SESSION["videorequestfile"])) { 
      unset(
$_SESSION["videosubrequest"]);
      unset(
$_SESSION["videorequestfile"]);
      die (
"Direct access to video is prohibited");
    }
   
    
$mov $_SERVER["DOCUMENT_ROOT"]."/upload/videos/".$_SESSION["videorequestfile"];
  
    
header('Content-type: video/quicktime');
    
header('Content-Length: '.filesize($mov));
    
$content file_get_contents($mov);
    print 
$content;
    unset(
$_SESSION["videosubrequest"]); // removed the @, which suppresses errors on this line.
    
?>
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 02-15-2009, 03:47 AM Re: Unset() messes up video object
Junior Talker

Posts: 3
Name: Xander
Trades: 0
Nope that doesn't work either.
I've added a sleep() function (sleep(10)), and it seems to solve the problem for non-IE browsers. Adds to the strangeness of this problem
xl2000 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Unset() messes up video object
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13505 seconds with 12 queries