fluxusx

Simple PHP proxy script for tinyurl.com

Mar 14th, 2012
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  * tinyurl.php
  5.  *
  6.  * A simple PHP proxy script for tinyurl.com
  7.  *
  8.  * USAGE:
  9.  *
  10.  * Load
  11.  *   http://yourdomain.com/tinyurl.php?37o68u6
  12.  * as replacement for
  13.  *   http://tinyurl.com/37o68u6
  14.  *
  15.  * You may also create a subdomain and use URL rewriting and the following rule:
  16.  *  RewriteEngine on
  17.  *  RewriteBase /
  18.  *  RewriteCond %{REQUEST_FILENAME} !-f
  19.  *  RewriteCond %{REQUEST_FILENAME} !tinyurl.php
  20.  *  RewriteRule (.*) tinyurl.php?$1
  21.  * to allow usage like this: http://tinyurl.yourdomain.com/37o68u6
  22.  *
  23.  */
  24.  
  25. $qs = @$_SERVER['QUERY_STRING'];
  26. if ($qs){
  27.     $headers = get_headers('http://tinyurl.com/'.$qs, 1);  
  28.     if (@$headers['Location']){
  29.         $url = is_array($headers['Location'])?$headers['Location'][0]:$headers['Location'];
  30.         header('Location: '.$url);
  31.         exit;
  32.     }
  33. }
  34.  
  35. ?>
Add Comment
Please, Sign In to add comment