views:

46

answers:

1

so that's a weird thing i'm working on. some of you already helped me with this script:

proxy.php

<?php
if( isset( $_GET['url'] ) ) {
 # Get the Referred URL
  $raw = file_get_contents( $_GET['url'] );
 # RegExp to Strip All Script tags and/or links with Javascript in them.
  $safe = preg_replace( '/<script[^>]*>.*<\/script>|[\"\']javascript:.*[\"\']/im' , '' , $raw );
  echo $safe;
} else {
  echo 'No URL Set';
}

it's a proxy which lets me use the jquery load method with proxy.php?url=http%3A//www.somedomain.com/

that works perfectly. i wonder now if i can pass along ANOTHER query string in that url which http://www.somedomain.com can $_GET from the url?

I think that might me hard to understand what i'm after. i wonder if it's somehow possible to do that:
proxy.php?url=http%3A//www.somedomain.com&query=anewquerywhichsomedomaincanread

if i set another ? as query it ends in a 404 because i can't set two ? in an url.
proxy.php?url=http%3A//www.somedomain.com?query=anewquerywhichsomedomaincanread

so i wonder if theres a trick in doing that so somedomain.com can use the $_GET method to get the second query string from the url. I can't use an & because: this -> proxy.php?url=http%3A//www.somedomain.com&query=anewquerywhichsomedomaincanread would actually look like this -> http://www.somedomain.com&amp;query=anewquerywhichsomedomaincanread for somedomain.com.

do you get me? any ideas?

A: 

You'll have to URI encode the entire URL you're passing in the query string. You can use encodeURIComponent() in JavaScript to do so.

Victor Welling
thank you for the tipp but i don't get it quite. so how this work? I'll use the whole uri-string with two ? in it and encode it! and than i'll decode it on the server side to get the value?$sv.load(http://www.mydomain.com/proxy.php?url=http%3A//www.anydomain.com/some.php?=querystring);
You should apply URI encoding to the whole URL you're trying to retrieve, like this: h t t p ://www.example.com/?uri=http%3A%2F%2Fwww.remote.com%2F%3Ffoo%3Dbar
Victor Welling
and how do i then get the information (query) out there in my www.remothe.com site?
I'm not sure I understand, do you mean how to decode the URL? If so, you probably don't have to. Most platforms will automatically decode it for you. So both the proxy as well as the URL you're requesting through the proxy should work right out of the box.
Victor Welling