Jump to content


Photo

Determine Host site to be php, asp or aspx


  • Please log in to reply
5 replies to this topic

#1 kir10s

kir10s
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 16 May 2006 - 06:20 PM

I have a site where customers may download a sample page for their website. They are given the option of asp, php or aspx... my client wants a form button which when clicked, will go to the hostsite of the customers and determine which technology is being supported, so it can sugguest the correct format.

Any suggestions on how to do this?

Thank you in advance


#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 16 May 2006 - 08:01 PM

Your client, is on crack. And possibly heroin too.

There is no real accurate way of doing this, short of having the user provide the info themselves. Quite simply put, there are far too many variables involved to accomplish this without a hitch.

Rethink the approach.
PHP Ninja

#3 kir10s

kir10s
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 16 May 2006 - 08:11 PM

Thank you! This was what I was feeling too but appriated the validation.

The closest thing I got to this was:

function get_server_software($domain) {
$fp = fsockopen($domain, 80, $errno, $errstr, 1);

if (!$fp) {
return("");
}

else {
fputs($fp, "HEAD / HTTP/1.1\r\nHost: " . $domain . "\r\n\r\n");

while (!feof($fp)) {
if (preg_match("/\bServer:/", $server = fgets($fp, 256))) {
fclose($fp);
return(substr($server, 8, -2));
}
}

fclose($fp);
}
}

Which returns the software the server is using, but this can be ambiguous because if I am not mistaken Windows can run all three...?? or at least for sure aspx and asp..

Kind of a funny side note.. if you use this code and send it to a site hosted by hostica.com, you will be returned 'NOYB' which I believe to be an acronym of None of your business. Try using using aaadiving.com if you want to try it.

Thanks for your support!
Kirsten

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 16 May 2006 - 08:21 PM

That's not entirely accurate ... (ripping off a line from "Independence Day")

You should be able to use CURL or raw sockets to get the information from the webserver on the remote host. Just ask for the default home page and request all headers be returned. In the headers returned, there should be a line (third line in the non-PHP test I ran) that starts with the word "Server:". This line should tell your what is supported by the server, although it can be turned off.

Ken


#5 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 16 May 2006 - 08:25 PM

[!--quoteo(post=374416:date=May 16 2006, 03:21 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ May 16 2006, 03:21 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
This line should tell your what is supported by the server, although it can be turned off.
[/quote]

Exactly. [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]

And I imagine your client would not be happy if the script didn't always do what he wanted it to do. Unless the guy can be reasoned with.

P.S Jeff Goldbloom!!

PHP Ninja

#6 kir10s

kir10s
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 16 May 2006 - 08:26 PM

Would you be able to post the code so I can run it?

Thank you!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users