Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

URLencoding content


Mouzi's Avatar
Member
0 0

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.


mido's Avatar
Member
0 0

Try Javascript…?


spyware's Avatar
Banned
0 0

Try PHP.

$fh = fopen($ourFileName, 'X') or die("Couldn't open file");
$encfile = urlencode($fh);
fclose($fh);```

Haven't tested this but it should work. 

Mouzi's Avatar
Member
0 0

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.


Mouzi's Avatar
Member
0 0

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?


Mr_Cheese's Avatar
0 1

if your apache is set to read remote files, try this.

$data = file_get_contents("http://www.yourwebsite.com/yourfile.php");
echo urlencode($data);
?>```

although i think possibly your looking for htmlentities?

Mouzi's Avatar
Member
0 0

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.


Mr_Cheese's Avatar
0 1

file_get_contents can send GET, obvioulsy.

but if you want to send POST, then use cURL and then just echo the result in urlencode. that will work.


Mouzi's Avatar
Member
0 0

I know it can :P Also I can't use cURL, only fsockopen (my server doesn't have cURL lib). And I have tried that one too.

Mouzi wrote: 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