Omnimaga
General Discussion => Technology and Development => Web Programming and Design => Topic started by: SirCmpwn on August 28, 2010, 10:17:20 am
-
Hello,
I am not very good at web development, but have a simple request. Could someone code for me a server (assuming it is at example.com) that will be given a request like this:'
GET http://www.example.com/?http://www.google.com/
and will GET google, and return the response. This should work for every protocol - GET, POST, PUT, DELETE, all of em. All it needs to do is replicate and perform the request, then return the response.
Thanks!
-
i am not sure what you mean. Do you want to download the contents of Google.com?
-
From what I can tell, he wants a pr0xy.
Sadly, I have no experience here, or I would help.
-
This isn't too hard if you are just redirecting requests only and returning the output.
However, if you are trying to code a full blown pr0xy, then you should probably just use
PHProxy or other existing software.
I assume you are using PHP?
-
I don't really care what it is written in. It *is* a proxy, but the way I plan on implementing it wouldn't work with PHProxy. It would be extremely effective the way I'm using it to simply redirect the requests as alberthrocks was talking about. Trust me on this - it would be really cool the way I'm doing it.
-
So you just want a file that returns the code for a website when given the url in any request format?
-
Well, it should perform the request, then return the response it gets.
-
hmm thats a very interesting request sadly i have no clue on ow to do it :/ as i have never used php but i have hosting for it if its ever completed ^_^
-
Sweet! Once this was finished, my next request was going to be hosting ;)
-
I'm just kinda confused by your first explanation I guess... since 1. You said "GET *" then the link had no variable being set, just the value... =P and 2. You're asking for a web server to be set up for this when it seems like you just need a page... And I still don't exactly get the "request" and "response" you are asking for, is it just the url and the page, or are you performing a request to THAT page, or what?
-
well i have 2 hosts i can use..err 3 actually lol
i have my house computer
57o9.org
and themuncher
so yeah they all have php so thats not an issue on 57o9.org im admin its linux so if its not php and bash/something else linuxy i can host that
and my desktop is windows again im admin so if it can be run as a service i can do that as well if its not php :P
-
Well, think of it this way. A page is what I need, and by request/response, I basically have a way of replicating all traffic going through a system, redirect it, and change the response. This way, the proxy would just have to accept any form of traffic, be it GET, POST, PUT, whatever, and replicate it. I would pass the url of the server in the request url.
-
Have you tried contacting {AP} about any of this yet? He might know.
-
I should get ahold of him.
-
I don't think he does server hosting stuff such as those, though. He uses 1and1 like I do for all his stuff.
Unless SirCmpwn doesn't need a dedicated connection?
-
*bump*
-
Good luck on this Sir. I wish I could help :/
-
Thanks. My bump proved ineffectual, though.
The current state of things is that two people are coding it, and I have secured hosting. \o/
-
Yeah I noticed :/
My guess is that people may not be experienced in that stuff very much over here. Some on IRC are, but they never check the forums and IRC is blocked for you.
-
Out of curiosity, why do you want/need this?
-
To mess around :P
-
To get around filters. That's the honest answer.
-
<?php
$url = "";
//Try to fetch the url
foreach ( $_GET as $key => $value )
{
//I know this method isn't entirely secure, but it gets the job done ;)
if ( eregi("http://", $key) )
{
$url = $key;
}
}
//Do what you want with the url?
$contents = file_get_contents($url); //GET
$contents = http_post_data($url, Array("key" => "value")); //POST, sending $_POST["key"] = "value";
?>
That should work.
Edit: Using eregi & file_get_contents instead
-
HOLY NECROPOST BATMAN! O.O
However, I wonder what that script does exactly? Does it just acts like a proxy and can it be used anywhere that supports PHP? I'm not experienced with that stuff.
-
Sorry about the necropost, but I felt the urge to help him :P
Anyway, this script gets the last (didn't check if it was already found) found variable in the $_GET that contains http://
It then stores the url in the $url var and below it does whatever Sir wants to do with it.
Url format should then be: http://www.mysite.com/?http://www.google.com/
Which then sends a GET request (or POST) to google.com
-
Cool. Now I wish 1and1 allowed proxies so I could load this on my other webspace. I doubt my current webspace allows proxies either. Maybe one day, if I ever get a dedicated server...
-
^_^ Thank you so much! Now that we have the code, would someone be willing to offer hosting? I can start working on the client side code.
EDIT: It got uploaded, but upon GETting http://www.davidgom.co.cc/free.php?http://www.google.com, it gave the following errors:
Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/a6670055/public_html/free.php on line 9
Fatal error: Call to undefined function http_get() in /home/a6670055/public_html/free.php on line 16
-
Maybe http_get() is not supported on his server?
Also I would give hosting but I don't want to get my 1and1 account suspended for hosting proxies. I would need to check if my aspiration account allows it, but it would be pointless to do a proxy to access Omni there, since it would be the same IP. If parents blocked the entire IP instead of just the domain, the proxy would get blocked too...
-
Ok, seems your current server doesn't have some default PHP libs installed. (Safemode=true? Never know those blocked 'm)
Instead of preg_match, you can use eregi. The parameters stay the same.
And for http_get, you can use file_get_contents. Again, the parameters stay the same.
That should work ;)
Edit: Edited original code to an alternative
-
It appears to be a free hosting provider. Most free hosts got extremly limited PHP support, if they have PHP support at all. Even some paid hosts, most notoriously oversellers like 1and1, Surpasshosting, HostGator and DreamHost, will have some PHP functions disabled or even disable them without notice (which killed one of our anti-spam until we moved). In Omnimaga case, I think file_get_contents and fetch_web_data wouldn't work properly anymore.
-
*bump*
The errors were never resolved.
-
Well, is my server working well? I don't think so:
www.davidgom.co.cc/free.php (http://www.davidgom.co.cc/free.php)
-
No, I don't think you have the updated code:
<?php
$url = "";
//Try to fetch the url
foreach ( $_GET as $key => $value )
{
//I know this method isn't entirely secure, but it gets the job done ;)
if ( eregi("http://", $key) )
{
$url = $key;
}
}
//Do what you want with the url?
$contents = file_get_contents($url); //GET
$contents = http_post_data($url, Array("key" => "value")); //POST, sending $_POST["key"] = "value";
?>
New errors:
Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/a6670055/public_html/free.php on line 16
PHP Error Message
Warning: file_get_contents(http://www_google_com) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/a6670055/public_html/free.php on line 16
PHP Error Message
Fatal error: Call to undefined function http_post_data() in /home/a6670055/public_html/free.php on line 17
-
No, I don't think you have the updated code:
<?php
$url = "";
//Try to fetch the url
foreach ( $_GET as $key => $value )
{
//I know this method isn't entirely secure, but it gets the job done ;)
if ( eregi("http://", $key) )
{
$url = $key;
}
}
//Do what you want with the url?
$contents = file_get_contents($url); //GET
$contents = http_post_data($url, Array("key" => "value")); //POST, sending $_POST["key"] = "value";
?>
New errors:
Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/a6670055/public_html/free.php on line 16
PHP Error Message
Warning: file_get_contents(http://www_google_com) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/a6670055/public_html/free.php on line 16
PHP Error Message
Fatal error: Call to undefined function http_post_data() in /home/a6670055/public_html/free.php on line 17
In my website I'm getting all types of errors :(
-
Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/a6670055/public_html/free.php on line 16
Never got this one before, any chance you have safe mode activated for some reason?
If not, there's something wrong with your server (heavily outdated?)
http_post_data.. dunno what's happening there...
Edit: Doesn't seem to work on my server, either, edited the code a bit since it seems to have the urge to replace the dots with _'s
Fixed:
<?php
$url = "";
//Try to fetch the url
foreach ( $_GET as $key => $value )
{
//I know this method isn't entirely secure, but it gets the job done ;)
if ( eregi("http://", $key) )
{
$url = $key;
}
}
//Do what you want with the url?
$contents = file_get_contents(str_replace('_', '.', $url)); //GET
echo $contents;
?>
-
Do we know if this works?
-
Idk, but if there are file get content server errors, this means this needs to be hosted on a different host.
-
That last code works on my own server, which runs on PHP 4.3.0
Unless your host as safemode enabled, which blocks external connections.
Consider looking for another host? (I believe www.freehostia.com works fine)
-
Don't try 1and1, that's for sure. For odd reasons, file_get_contents worked with OmnomIRC but not for some other stuff. It actually used to work perfectly but then 1and1 restricted it, killing Omnimaga forum's anti-spam.
You could always ask your OS, though. Also keep in mind Freehostia is slow sometimes, so you might not be able to access your site from time to time.
-
That last code works on my own server, which runs on PHP 4.3.0
Unless your host as safemode enabled, which blocks external connections.
Consider looking for another host? (I believe www.freehostia.com works fine)
I am using 000webhost with PHP allowed (I have PHP stuff in my website), maybe an outdated version. Need to check that
-
Or you could try out the code using localhost ( http://www.uwamp.com/ or http://www.wampserver.com/ are the most popular )
-
What if a website is blocked at his home, though? (Example, Omnimaga) Would running this code as localhost still bypass this?
-
I will eventually release the protocol for this in the hope that as many people as possible will host it.
Also, I have uploaded the file to http://fnproxy.sourceforge.net/ (http://fnproxy.sourceforge.net/), but it still doesn't work. Any ideas?
-
Sir, I'd like you to check your PM Inbox.
Sent you a message.
-
Checked :)
Thanks.