Omnimaga

General Discussion => Technology and Development => Web Programming and Design => Topic started by: SirCmpwn on August 28, 2010, 10:17:20 am

Title: Simple Server Needed
Post 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!
Title: Re: Simple Server Needed
Post by: souvik1997 on August 28, 2010, 12:23:00 pm
i am not sure what you mean. Do you want to download the contents of Google.com?
Title: Re: Simple Server Needed
Post by: calcdude84se on August 28, 2010, 12:25:23 pm
From what I can tell, he wants a pr0xy.
Sadly, I have no experience here, or I would help.
Title: Re: Simple Server Needed
Post by: alberthrocks on August 28, 2010, 12:58:11 pm
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?
Title: Re: Simple Server Needed
Post by: SirCmpwn on August 28, 2010, 06:38:32 pm
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.
Title: Re: Simple Server Needed
Post by: cooliojazz on August 28, 2010, 10:08:02 pm
So you just want a file that returns the code for a website when given the url in any request format?
Title: Re: Simple Server Needed
Post by: SirCmpwn on August 28, 2010, 10:10:43 pm
Well, it should perform the request, then return the response it gets.
Title: Re: Simple Server Needed
Post by: Geekboy1011 on August 28, 2010, 10:15:06 pm
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 ^_^
Title: Re: Simple Server Needed
Post by: SirCmpwn on August 28, 2010, 10:16:18 pm
Sweet!  Once this was finished, my next request was going to be hosting ;)
Title: Re: Simple Server Needed
Post by: cooliojazz on August 28, 2010, 10:17:43 pm
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?
Title: Re: Simple Server Needed
Post by: Geekboy1011 on August 28, 2010, 10:20:02 pm
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
Title: Re: Simple Server Needed
Post by: SirCmpwn on August 28, 2010, 10:20:13 pm
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.
Title: Re: Simple Server Needed
Post by: meishe91 on August 28, 2010, 10:20:21 pm
Have you tried contacting {AP} about any of this yet? He might know.
Title: Re: Simple Server Needed
Post by: SirCmpwn on August 28, 2010, 10:21:34 pm
I should get ahold of him.
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on August 28, 2010, 10:22:04 pm
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?
Title: Re: Simple Server Needed
Post by: SirCmpwn on August 29, 2010, 10:11:33 pm
*bump*
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on August 30, 2010, 01:02:53 am
Good luck on this Sir. I wish I could help :/
Title: Re: Simple Server Needed
Post by: SirCmpwn on August 30, 2010, 08:38:46 am
Thanks.  My bump proved ineffectual, though.
The current state of things is that two people are coding it, and I have secured hosting.  \o/
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on August 30, 2010, 02:02:40 pm
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.
Title: Re: Simple Server Needed
Post by: Builderboy on August 30, 2010, 02:43:23 pm
Out of curiosity, why do you want/need this?
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on August 30, 2010, 04:00:28 pm
To mess around :P
Title: Re: Simple Server Needed
Post by: SirCmpwn on August 30, 2010, 04:43:23 pm
To get around filters.  That's the honest answer.
Title: Re: Simple Server Needed
Post by: Ikkerens on December 01, 2010, 01:55:59 pm
Code: (php) [Select]
<?php

$url 
"";

//Try to fetch the url
foreach ( $_GET as $key => $value )
{
//I know this method isn&#39;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
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on December 01, 2010, 02:00:05 pm
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.
Title: Re: Simple Server Needed
Post by: Ikkerens on December 01, 2010, 02:02:51 pm
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
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on December 01, 2010, 02:05:15 pm
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...
Title: Re: Simple Server Needed
Post by: SirCmpwn on December 01, 2010, 05:06:52 pm
^_^ 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
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on December 01, 2010, 11:41:24 pm
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...
Title: Re: Simple Server Needed
Post by: Ikkerens on December 02, 2010, 01:23:18 am
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
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on December 02, 2010, 04:04:46 am
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.
Title: Re: Simple Server Needed
Post by: SirCmpwn on December 07, 2010, 05:12:59 pm
*bump*
The errors were never resolved.
Title: Re: Simple Server Needed
Post by: Munchor on December 07, 2010, 05:13:59 pm
Well, is my server working well? I don't think so:

www.davidgom.co.cc/free.php (http://www.davidgom.co.cc/free.php)
Title: Re: Simple Server Needed
Post by: SirCmpwn on December 07, 2010, 05:15:38 pm
No, I don't think you have the updated code:
Code: [Select]
<?php

$url 
"";

//Try to fetch the url
foreach ( $_GET as $key => $value )
{
//I know this method isn&#39;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
Title: Re: Simple Server Needed
Post by: Munchor on December 07, 2010, 06:16:32 pm
No, I don't think you have the updated code:
Code: [Select]
<?php

$url 
"";

//Try to fetch the url
foreach ( $_GET as $key => $value )
{
//I know this method isn&#39;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 :(
Title: Re: Simple Server Needed
Post by: Ikkerens on December 08, 2010, 01:26:07 am
Quote
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:
Code: (php) [Select]
<?php

$url 
"";

//Try to fetch the url
foreach ( $_GET as $key => $value )
{
//I know this method isn&#39;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(&#39;_&#39;, &#39;.&#39;, $url)); //GET
echo $contents;

?>

Title: Re: Simple Server Needed
Post by: SirCmpwn on December 08, 2010, 02:24:43 am
Do we know if this works?
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on December 08, 2010, 03:05:02 am
Idk, but if there are file get content server errors, this means this needs to be hosted on a different host.
Title: Re: Simple Server Needed
Post by: Ikkerens on December 08, 2010, 03:30:47 am
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)
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on December 08, 2010, 03:33:34 am
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.
Title: Re: Simple Server Needed
Post by: Munchor on December 08, 2010, 11:58:34 am
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
Title: Re: Simple Server Needed
Post by: Ikkerens on December 08, 2010, 01:49:28 pm
Or you could try out the code using localhost ( http://www.uwamp.com/ or http://www.wampserver.com/ are the most popular )
Title: Re: Simple Server Needed
Post by: DJ Omnimaga on December 08, 2010, 03:57:42 pm
What if a website is blocked at his home, though? (Example, Omnimaga) Would running this code as localhost still bypass this?
Title: Re: Simple Server Needed
Post by: SirCmpwn on December 08, 2010, 05:08:20 pm
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?
Title: Re: Simple Server Needed
Post by: Ikkerens on December 09, 2010, 02:29:46 am
Sir, I'd like you to check your PM Inbox.
Sent you a message.
Title: Re: Simple Server Needed
Post by: SirCmpwn on December 09, 2010, 07:18:16 pm
Checked :)
Thanks.