Question

Php include("movie.mov") Error syntax error, unexpected '@'

Asked by: chris_petey

I am trying to make video pages that allow you to view the video but not directly link to the video for download.  I did this same kind of deal with a photo gallery and it works like a charm, I assume its because of the way it reads the image in.  Ill take out all non essential html so its easier to read. Heres my code

video_viewer.php
------------------------------------

<script language="javascript">QT_WriteOBJECT('get_video.php?video=<?php echo $_REQUEST['video']; ?>' , width , height , '', 'kioskmode', 'true', 'scale', 'tofit');</script>

------------------------------------


get_video.php
------------------------------------

$path = "videos/";
ini_set('display_errors', 1);
  $from_name = $path . urldecode($_REQUEST['video']);
  include($from_name);
  break;
  return;

------------------------------------

Theoretically, atleast the way it worked with the image pages, is that when the viewer page calls the get_video page it reads the filename back in without showing it in the source code, but what appears to be happening is when it pulls it in it pulls it as reading the file and not the actual name of the file.

Any ideas????

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-10-14 at 10:24:06ID22892268
Tags

php

,

qt_writeobject

,

error

,

include

Topics

PHP Scripting Language

,

JavaScript

Participating Experts
2
Points
250
Comments
18

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ini_set ignored in ISAPI version of PHP?
    I have a php file that starts with ini_set('upload_max_filesize','100M'); ini_set('max_post_size','100M'); ini_set('memory_limit',100M'); Calling these seems to have no effect at all. If I make the change directly to my php.ini file, everything works fine. if not, I get w...
  2. photo editor in php
    Hello ,Experts I need a script in php, that will work as photo editor....Means i will have a photo. so by this editor i can do "crop image, briteness, zoom, colour" etc... so if u experts have that code. than please help me for that. thanx, Nitin Makvna.
  3. PHP Photo Album help
    I'm trying to use the PHP Photo Album from dynamicdrive.com, but instead of the output displaying the photos with the label "Photo 1", "Photo 2", etc... I want to display the filename without the extension (i.e., for "This is a photo.jpg" I would...
  4. PHP% and MySQL
    I have read posts of this until I'm crossed-eyed, but I am missing something. PHP 5 loads fine, except it does not start the MySQL module. Here's the PHP.ini code to call for it. extension_dir=c:/program files/PHP/ext [PHP_MYSQL] extension=php_mysql.dll libmysql.dll is in ...
  5. Effect of PHP ini_set on other scripts?
    I'm using ini_set to alter the include_path of one of my PHP scripts. What I'm trying to figure out is if it will affect other scripts. The description of it on php.net says that after the script ends, the original values are reset. But what happens if two scripts run at t...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: kiranvjPosted on 2007-10-14 at 11:02:34ID: 20074411

try this in video_viewer.php

<?php
// We'll be outputting a MOV file
$path = "videos/";
$from_name = $path . urldecode($_REQUEST['video']);
header('Content-type: video/quicktime');

header('Content-Disposition: attachment; filename='.$from_name);

readfile($from_name);
?>

 

by: kiranvjPosted on 2007-10-14 at 11:08:43ID: 20074419

 

by: DiscoNovaPosted on 2007-10-14 at 16:40:48ID: 20075181

In PHP, include() "includes _and_ evaluates the specified file". That means that the file is attempted to evaluate as PHP which - of course - it isn't.

As kiranvj said, you should use readfile() instead (with the suitable Content-type header as he's explaining). But you should *not* use the Content-disposition -header he suggested (since you *want* the file to be used in the browser and *not* have the browser show you a "Save as..."-dialog).

 

by: chris_peteyPosted on 2007-10-14 at 16:52:06ID: 20075204

It looks like this code pulls in the video but how do i pull in just the filename?  I'm using the QT_WriteOBJECT method to write out the code in the page, will this method work without having to use this?

 

by: DiscoNovaPosted on 2007-10-14 at 17:00:43ID: 20075230

Assuming the first argument for QT_WriteOBJECT is the URL of the video, for the thing to work in the first place, you don't want to return the filename from get_video.php (instead you want to return the actual contents of the video file).

 

by: DiscoNovaPosted on 2007-10-14 at 17:02:21ID: 20075237

As to "how do i pull in just the filename", it's just like this:

<?php
$path = "videos/";
  $from_name = $path . urldecode($_REQUEST['video']);
  print($from_name);
?>

But I really think that is not what you want to do :)

 

by: DiscoNovaPosted on 2007-10-14 at 17:04:54ID: 20075242

Furthermore, using something like that in a live environment would be something short of shooting yourself in the foot.

Consider get_video.php?video=../../../../../../../../../../../etc/passwd

 

by: chris_peteyPosted on 2007-10-14 at 17:08:27ID: 20075252

No its prolly not such a good idea after seeing that :-)  I'm just trying to load in a quicktime movie without actually showing the direct link to the movie.  For leeching purposes.

 

by: DiscoNovaPosted on 2007-10-14 at 17:34:59ID: 20075327

I would suggest using some sort of translation matrix, where you only provide and if to get_video.php which will, based on the id, return the contents of the video. Something like this (not tested, prone to typos):

<?php

$matrix = Array(
  "abc" => "my_little_pony.mov",
  "def" => "teletubbies.mov",
  "ghi" => "debbie_does_dallas.mov",
);

$path = 'videos/';
if (!array_key_exists($_GET["v"])) {
  // Default if the user requests a video not in the translation matrix
  $file = $path.'goatse.mov';
} else {
  $file = $path.$matrix[$_GET["v"]];
}

header('Content-type: video/quicktime');
readfile($file);

?>

And this would be called like:

<script language="javascript">
  QT_WriteOBJECT('get_video.php?video=ghi' , width , height , '', 'kioskmode', 'true', 'scale', 'tofit');
</script>

...because no-one's really interested in My little pony or teletubbies, right :)

 

by: DiscoNovaPosted on 2007-10-14 at 17:35:42ID: 20075328

"where you only provide and if to" = "where you only provide an id to"

 

by: chris_peteyPosted on 2007-10-15 at 11:50:24ID: 20080496

I like that idea, would something like this work?
I was playing around with this but when I put the if in the get_video page is shows a broken video link


video_viewer.php
--------------------------------
<?php
$authorized = "shonuff";
$video = urldecode($_REQUEST['video']);
?>

<script language="javascript">QT_WriteOBJECT('get_video.php?video=<?php echo urldecode($_REQUEST['video']); ?>' , width , height , '', 'kioskmode', 'true', 'scale', 'tofit');</script>
--------------------------------



get_video.php
--------------------------------
if ($authorized)
{
$path = "videos/";
$from_name = $path . $_REQUEST['video'];
header('Content-type: video/quicktime');
readfile($from_name);
break;
} else {
echo "You Cannot Link To The Video In This Way...";
}
--------------------------------

 

by: DiscoNovaPosted on 2007-10-15 at 12:04:49ID: 20080639

Basically yes. However, I think the thing you're actually trying to do is not possible.

See, you will need to pass the variable $authorized to get_video.php (and anyone with a browser who knows to look into the source will see that. Currently the mentioned variable is only present in video_viewer.php ... you need to realise that the browser is going to be doing two distinct GETs; one for video_viewer.php and another for get_video.php ... there's no way you can "include" a file directly into the page.

It needs to be understood, that whatever the user is able to see on their screen, they will be able to leach to their computer. Some methods of doing this are easier than other, but still - everything can be downloaded one way or another.

 

by: chris_peteyPosted on 2007-10-15 at 12:12:54ID: 20080711

If i do this

if ($authorized)
{
echo "yes";
} else {
echo "No";
}

Then include the file it gets the variable from the viewer page and works fine.  Is this (get_video.php?video=<?php echo urldecode($_REQUEST['video']); ?>) and include not basically the same thing, it acceses the page and spits the code back out?

I know its impossible to keep everyone from taking things but im hoping to cut down on the amount of stealing.

I'm baseing this on a code i used for thumbnails that streams an image back to the browser and when the page was directly accessed would show an error type of message to the user.

 

by: DiscoNovaPosted on 2007-10-15 at 12:35:05ID: 20080884

> Is this (get_video.php?video=<?php echo urldecode($_REQUEST['video']); ?>) and
> include not basically the same thing, it acceses the page and spits the code back out?

No. With "include" ("readfile" actually, but "include" is so much easier to visualise mentally), you put the contents of the mov-file into the page. With the latter approach, you are instantianing an object that will require whatever is coming from the provided URL. If it is not a video file, it will not be able to render it. If it is, it will. Unfortunately (well, not really- if it weren't like this the net wouldn't work) anyone who requests data from the exact same URL and is able to generate the same environment (pass the same variables, send the same cookies, write out headers same request headers) will get the exact same result. And there is nothing anyone can do about it. Sorry.

To counter what I've just said, there are ways to include the actual data directly within the page itself. These ways are by no way standard, and are supported by only certain versions of certain browsers. Perhaps you'd be better of with some sort of Flash-gizmo that'd have the video requester built into the code (nothing passed through variables)? That wouldn't be foolproof either, but would add the certain amount of skill required (well, youtube uses that sort of thing, and how far has that gotten them? youtubex.com, anyone?)

 

by: kiranvjPosted on 2007-10-15 at 21:19:41ID: 20083171

@chris_petey
>>I'm just trying to load in a quicktime movie without actually showing the direct link to the movie.  For leeching purposes.

Deny direct access to the mov file from other site/server

create a file .htaccess and write this

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://yoursite.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://yoursite.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yoursite.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yoursite.com$      [NC]
RewriteRule .*\.(mov)$ http://www.yoursite.com [R,NC]

check this http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/Q_22748528.html

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...