Advertisement
ihatetonyy

ngx authorize.php

Jan 10th, 2014
1,676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <?php
  2. // Example stream authentication
  3.  
  4. if ( !empty($_POST) ) {
  5.     switch ( $_POST['call'] ) {
  6.         case "publish":
  7.             $publisher_ip = $_POST['addr'];
  8.  
  9.             if ( isset($_POST['passphrase']) && $_POST['passphrase'] != NULL ) {
  10.                 // Check to see if this is a correct passphrase
  11.                 if ($_POST['passphrase'] = "uniquepasswordhere") {
  12.                     header("HTTP/1.1 202 Accepted"); // 2xx responses will keep session going
  13.                 } else {
  14.                     header("HTTP/1.1 403 Forbidden"); // Drop the session - incorrect passphrase
  15.                 }
  16.             } else {
  17.                 header("HTTP/1.1 403 Forbidden"); // Drop the session - no passphrase
  18.             }
  19.         break;
  20.         case "play":
  21.             // The same parameters - name, addr, etc. also work for playing streams over RTMP
  22.             // You could use the on_play parameter to authorize plays against this same file
  23.             // and perhaps limit plays to an IP address in a database, etc.
  24.             // to enforce a paywall or to track visits
  25.         break;
  26.     }
  27. }
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement