Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2008-05-06, 09:10 PM   #1
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
.htaccess
Code:
RewriteEngine on
RewriteRule vids/(.*) /video.php?video=$1 [L]
video.php
Code:
<?php
  $filename = "/var/www/domain.com/" . $_REQUEST['video'];
  if ( (preg_match("/[a-z0-9\-_]+.(mp4|wmv|mp4a)/i",$_REQUEST['video'])) && 
       (file_exists($filename)) ) {
  header("Content-Type: " . mime_content_type($filename));
  header('Content-Disposition: attachment; filename="' . $_REQUEST['video'] . '"');
  $file=fopen($filename,"rb");
  fpassthru($file);
  close($file);
  } else {
    print "error retrieving file";
  }
?>
Not a lot of error checking in it, file paths will need to be changed, but, this is probably the basics of what you're looking for. Mimetype detection will help, you can fix the preg_match to match the extensions you want to allow. filenames cannot contain more than one . and must be comprised of all letters, numbers, - and _.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Reply


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

Forum Jump


All times are GMT -4. The time now is 12:49 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc