Advertisement
jargon

Neinstar Filmz Video Handler 0-00 by Nick

Oct 1st, 2016
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.73 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.     Neinstar Filmz Video Handler 0-00 by Nick
  5.  
  6.     The main purpose of this script is to throttle bandwidth,
  7.     count impressions and validate voucher codes by bottlenecking
  8.     video access.  
  9.  
  10.     Voucher codes come in the form of an account, a clip id and
  11.     a redemption code. If any specific code is in an invalid
  12.     format it is intended to swap in a default in its place.
  13.    
  14.     After the validation step has completed, the script is then
  15.     to stream the requested video-on-demand.
  16. */
  17.  
  18. $ini['acct']=$_GET['acct'];
  19. $acct=preg_match('/(\d10})/',$ini['acct']);
  20. if(is_array($acct))
  21.     $ini['acct']=$acct;
  22. else
  23.     $ini['acct']='0000000000';
  24.  
  25. $ini['clip']=$_GET['clip'];
  26. $clip=preg_match('/(\d{8}[0-9X][0-9X][0-9X][0-9X][0-9X][0-9X][+-]\d{4})/',$ini['clip']);
  27. if(is_array($clip))
  28.     $ini['clip']=$clip;
  29. else
  30.     $ini['clip']='20100917022551-0700';
  31.  
  32. $ini['code']=$_GET['code'];
  33. $code=preg_match('/([0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f])/',$ini['code']);
  34. if(is_array($code))
  35.     $ini['code']=$code;
  36. else
  37.     $ini['code']='000-0000';
  38.  
  39. $ini['buff']=intval($_GET['buff']);
  40. if($ini['buff']<14400)
  41.     $ini['buff']=14400;
  42. if($ini['buff']>2<<10)
  43.     $ini['buff']=2<<10;
  44.  
  45. $fn='./clips/'.$ini['clip'].'.mp4';
  46.  
  47. if($ini['acct']==='0000000000') {
  48.     if(!is_file($fn)) {
  49.         header($_SERVER["SERVER PROTOCOL"].' 404 Not Found');
  50.         header('Content-Typ: video/mpeg');
  51.         header('Cache-Control: no-cache, must-revalidate');
  52.         header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
  53.     }
  54.     elseif($ini['code']==='000-0000') {
  55.         $fh=fopen($fn,'r');
  56.         $sz=filesize($fn);
  57.         $buf='';
  58.         header($_SERVER["SERVER PROTOCOL"].' 200 OK');
  59.         header('Content-Type: video/mpeg');
  60.         header('Content-Disposition: inline; filename="'.$ini['clip'].'.mp4"');
  61.         header('Content-Length: '.$sz);
  62.         header('Cache-Control: no-cache, must-revalidate');
  63.         header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
  64.         ob_start();
  65.         while(!feof($fh)) {
  66.             $length=($sz-ftell($fh));
  67.             if($length>=2<<10);
  68.                 $buf.=fread($fh,2<<10);
  69.             else
  70.                 $buf.=fread($fh,$length);
  71.             if((feof($fh)&&(strlen($buf)>0))||(strlen($buf>=$buffsz)) {
  72.                 echo $buf;
  73.                 $buf='';
  74.                 ob_end_flush();
  75.                 ob_start();
  76.             }
  77.         }
  78.         ob_end_flush();
  79.         fclose($fh);
  80.     }
  81.     else {
  82.         header($_SERVER["SERVER PROTOCOL"].' 503 Forbidden');
  83.         echo '503 Forbidden';
  84.     }
  85. }
  86. else {
  87.         header($_SERVER["SERVER PROTOCOL"].' 503 Forbidden');
  88.         echo '503 Forbidden';
  89. }
  90. /*
  91. echo '<html><body><table border="0px" cellpadding="0px" cellspacing="0px"><tr><td bgcolor="black" width="427px" height="240px" align="middle"><video src="'.$ini['clip'].'.mp4" autoplay="1" controls="" height="240px"></video></td></tr><tr><td align="left" style="font {variation: small-caps; size: +2;}">'.$ini['clip'].'</td></tr></table></body></html>';
  92. */
  93. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement