d.shankar Posted September 22, 2007 Share Posted September 22, 2007 Given a hostname i need to find the webserver,OS,etc... running on tht domain an example is here http://www.hscripts.com/tools/HVLT/index.php are there any inbuilt functions ? Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/ Share on other sites More sharing options...
BlueSkyIS Posted September 22, 2007 Share Posted September 22, 2007 all you need to do is call the home page of the domain (assuming it's a web server). Included in the headers sent back is the info you are looking for. I'd use curl functions, but you may get away with file functions to just pull a page back and parse the headers. Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-352853 Share on other sites More sharing options...
d.shankar Posted September 23, 2007 Author Share Posted September 23, 2007 Yea i too use cURL. i dont know what functions to be used to achieve this. :'( Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353178 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 a few options here 1) GeoIP (its a add on function that has a fee, but can be useful) 2) cURL (Tricky, but will work) 3) fOepn/cURL samspade with the given ip and return the info as needed Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353188 Share on other sites More sharing options...
d.shankar Posted September 23, 2007 Author Share Posted September 23, 2007 I dont need GEo. Can u help me with cURL or Fopen ? Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353191 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 <?php $server = "google.com"; $get_date = "http://samspade.org/whois/".$server; $data = fopen($get_data, 'r'); $data = file_get_content($data); //Find in $data the stuff you want based on byte location. ?> Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353194 Share on other sites More sharing options...
d.shankar Posted September 23, 2007 Author Share Posted September 23, 2007 I think it file_get_contents though the code doesnt show anything :'( :'( Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353196 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 I did this a while ago, and found my old code and it was like this (It was to get a weather part of weather.com), yours will be simpler probably <?php if($content=file_get_contents("http://www.weather.com/outlook/recreation/outdoors/fishing/28911:21")){ $content = substr_replace($content,"",0,2000);//Strips out the first css idderation $css_start = strpos($content,"<style type=\"text/css\">")-1; $css_end = strpos($content,"</style>"); $css_length = $css_end-$css_start; $css = substr($content,$css_start,$css_length); echo $css."</style>"; $start = strpos($content,"<!-- main module -->")-1; $end = strpos($content,"<!-- end today / tonight -->"); $length = $end-$start; $data = substr($content,$start,$length); } ?> I broke apart the source code to what I wanted. Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353198 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 Yours will be like <?php $server = ""; if($content=file_get_contents("http://samspade.org/whois/".$server)){ $content = explode("<div class=\"set\"", $content); //This breaks it up at the start of the raw data $data = explode("</div>",$content[1]); //This gets the end chopped off echo $data[0]; } ?> Then just do what you want with $data[0] to get what you want Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353204 Share on other sites More sharing options...
d.shankar Posted September 23, 2007 Author Share Posted September 23, 2007 Probably yes.. I just need to find the server name whether it is running Apache ,.. and also want to know what OS it is running.. Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353205 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 This is actually a function I think i'll build because I see uses for it, i'll respot my finding in the end. Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353208 Share on other sites More sharing options...
d.shankar Posted September 23, 2007 Author Share Posted September 23, 2007 Your code really helped in other aspects. Thanks cooldude! Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353209 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 this is what i've hashed out in a few minutes using the samspade result (it only does the first box, but can be modified for the second box) it returns this array of each of the heading names so you could just pull what you need out of that <?php $server = "google.com"; if($content=file_get_contents("http://samspade.org/whois/".$server)){ $content = explode("<div class=\"set\"", $content); //This breaks it up at the start of the raw data $data = explode("</div>",$content[1]); //This gets the end chopped off $fields = array( "Registrant", "Domain Name", "Registrar Name", "Registrar Whois", "Registrar Homepage", "Administrative Contact", "Technical Contact Zone", "Created On", "Expires On", "Record last updated on", "Domain servers in listed order" ); $data_2 = array(); $i = 0; $field_count = count($fields)-1; while(!empty($fields[$i])){ $j = $i+1; $tempdata = explode($fields[$i],$data[0]); if($j <$field_count){ $tempdata_2 = explode($fields[$j],$tempdata[1]); $temp = trim(nl2br(str_replace(": ", "", $tempdata_2[0]))); $data_2[$fields[$i]] = $temp; } else{ $temp = trim(nl2br(str_replace(": ", "", $tempdata[1]))); $data_2[$fields[$i]] = $temp; } $i++; } foreach($data_2 as $key => $value){ echo $key.": ".$value."<br/>"; } } else{ echo "failed to open stream"; } ?> Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353214 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 I found a few small issues in the fields array causing a bit of issues which i fixed <?php $server = "google.com"; if($content=file_get_contents("http://samspade.org/whois/".$server)){ $content = explode("<div class=\"set\"", $content); //This breaks it up at the start of the raw data $data = explode("</div>",$content[1]); //This gets the end chopped off $fields = array( "Registrant", "Domain Name", "Registrar Name", "Registrar Whois", "Registrar Homepage", "Administrative Contact", "Technical Contact Zone Contact", "Created ", "Expires ", "Record last updated ", "Domain servers in listed order" ); $data_2 = array(); $i = 0; $field_count = count($fields)-1; while(!empty($fields[$i])){ $j = $i+1; $tempdata = explode($fields[$i],$data[0]); if($j <=$field_count){ $tempdata_2 = explode($fields[$j],$tempdata[1]); $temp = trim(nl2br(str_replace(": ", "", $tempdata_2[0]))); $data_2[$fields[$i]] = $temp; } else{ $temp = trim(nl2br(str_replace(": ", "", $tempdata[1]))); $data_2[$fields[$i]] = $temp; } $i++; } foreach($data_2 as $key => $value){ echo $key.": ".$value."<br/>"; } } else{ echo "failed to open stream"; } ?> It still needs some work like cleaning up the created on register on modified on fields, and the nameserves to remove the ad space, and also it needs to be turned into a function rather than the static code, but I think u got the idea. Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353215 Share on other sites More sharing options...
d.shankar Posted September 23, 2007 Author Share Posted September 23, 2007 Yea yea i will.. I hope that you will help me in finding the Webserver name, OS name ... not now but later Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353221 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 well os isn't broadcasted (Browsers send it, but servers dont', at least I dont' know that they do) Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353223 Share on other sites More sharing options...
d.shankar Posted September 23, 2007 Author Share Posted September 23, 2007 Btw , did you checkout the flink in the first post i did in the current thread ? How could they have done that ? Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353224 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 There is another site out there like samspade.org that grabs info use that with the method i used for samspade Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353227 Share on other sites More sharing options...
d.shankar Posted September 23, 2007 Author Share Posted September 23, 2007 oh fine will chk that out. Link to comment https://forums.phpfreaks.com/topic/70244-php-code-to-find-server-details/#findComment-353241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.