URLencoding content
I wrote a long message about what I'm using this for, what I've already tried and what I've thought of but that damned referer thing prevented me from posting it and I lost the whole text so here's the question just shortly:
Is there a way to dynamically urlencode the whole content of a page? With PHP or Apache or something.
Javascript does not work for this one… Maybe I should explain more (as I did before my message got lost).
I have a navigation system that uses AJAX to retrieve pages. I have to urlencode the content that goes through XMLHttpRequest because it uses UTF-8 character encoding which messes everything up. I have tried to make it so that the requested page loads itself with file_get_contents(), urlencodes and echoes the result and then die(), but this breaks the POST and GET variables, so it's not very good solution (well I could pass the POST and GET variables to the page, but that would require making a request with fsockopen() and heaps of other code; I'm looking for a simpler solution if there is one). I've also thought about making custom echo function for PHP which would urlencode everything if needed, but then I would have to put all non PHP contet through echo also. Not that good one either.
I realised that the fsockopen is not an option either. It would bypass all IP specific things as the requesting IP will be the IP of the server :S
Would it be possible to create some kind of filter for apache maybe that would urlencode content if there is a certain request header?
Or is there any way to do this with PHP?
Mouzi wrote: I have tried to make it so that the requested page loads itself with file_get_contents(), urlencodes and echoes the result and then die(), but this breaks the POST and GET variables
I already have. I also tried fsockopen which can send the POST and GET to the requested page, but it has problems too. And no I'm not looking for html entities… just a way to urlencode the whole page.