Skip to content

Instantly share code, notes, and snippets.

@joho
Created April 23, 2009 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joho/100355 to your computer and use it in GitHub Desktop.
Save joho/100355 to your computer and use it in GitHub Desktop.
A sintatra app & php page for proxy scraping tramtracker
<?php
if ($_SERVER['REMOTE_ADDR'] == "127.0.0.1")
{
define ('HOSTNAME', 'http://tramtracker.com/');
$path = $_GET['path'];
$url = HOSTNAME.$path;
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
header("Content-Type: text/html");
echo $response;
curl_close($session);
}
?>
require 'rubygems'
require 'sinatra'
require 'open-uri'
get '/tramtracker' do
halt 403, 'get stuffed!' unless env['REMOTE_ADDR'] == '127.0.0.1'
open("http://tramtracker.com/#{params[:path]}").read
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment