Hi there,
I cam across your proxy script. Great job :)
I spent like 3 hours jacking around with it, because my local server at work is super complicated, and I wanted to be able to access all of the sites our company builds. I kept running into CSS/JS and dependency issues on my end that weren't resolving through your script, and I realized, your script can't catch everything.
So, I added to your script a .htaccess file, and placed code to process those requests and 302 them into ?q=xxx
Here's the code I used...
At the very top of the script, start a session, to establish the base directory. You might have a better way of doing this, but for example, if a site requests /images/test.jpg it's missing the whole domain, and is instead using http://myproxy.com/images/test.jpg, instead of: https://companysite.com/images/test.jpg.
Around line 1085, I added this code:
Since the .htaccess file will talk directly to the "index.php" AKA "proxy script you wrote", it can now receive all of those "rogue" requests...
I know, I could have done this cleaner but it's midnight and I got it working, so you are welcome to clean it up for your next version to complete the puzzle..
You could fix this code up to support folders better, this one is just supporting the root folder:
$uri = $_SERVER["REQUEST_URI"];
if (!stristr($uri, "/index.php") && $uri!="/" && !$_GET["q"] && !$_POST["url"]) {
/
URL is trying to use the last used domain to access a resource...
/
$url_explodes = explode("/",str_replace("//","^^",$_SESSION["base_url"]));
$base_url = str_replace("^^","//",$url_explodes[0]);
$url = encrypt_url($base_url.$uri);
header("Location: /index.php?q=".$url);
die();
}
if(isset($_POST['url'])){
$_SESSION["base_url"] = $_POST["url"];
$url = $_POST['url'];
$url = add_http($url);
$q = encrypt_url($url); header("HTTP/1.1 302 Found"); header('Location: '.SCRIPT_BASE.'?q='.$q); exit;
Great job, I would love to see this script in a class object!
You saved me from more work!
-Nathan
Oh I also ran into this bug:
$('#current_results').html('Non-Fasting').css('background','url('http://ssh-nhuebner.pagekite.me/index.php?q=aHR0cHM6Ly9kZW1vZ290b3RhbHdlbGxuZXNzLnRlc3QvaW1hZ2VzL25vbi1mYXN0aW5nLWFsZXJ0LmdpZg') no-repeat left').attr('title','You did not fast before your screening, therefore your results may be skewed.');
If you notice, url() is already encapsulated by '', so double-encapsulating is causing a JS error.