Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Developers' Forum

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 20th June 2006, 12:04
mxc mxc is offline
Member
 
Join Date: May 2006
Location: South Africa
Posts: 91
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via Skype™ to mxc
Default Changes to whois/index.php

Hi all,

I wanted to add support for the co.za and org.za tlds to the whois form. Both of the providers for these tlds do not have standard whois servers. Instead they have html forms to access the whois info. One of the forms works on the "get" method and the other on the "post" method so I wrote some functionality for this. I also moved some of the existing code around as I found it difficult to follow. I have tested it my side and it seems to work. Including the old code. I test the .com and .pl domains.


The only issue I have is that the whois info is repeated for some strange reason for the co.za resutls. The same is true for the org.za but the dom manipulation extras one entry only. Otherwise it seems to work. I hope that the co.za and org.za support can be included in future releases.

thanks

==================================
<?
/*
Copyright (c) 2005, projektfarm Gmbh, Till Brehm, Falko Timme
All rights reserved.
--removed due to 1000 character restriction on post
*/
include("../../../../lib/config.inc.php");
include("../../../../lib/session.inc.php");

$go_api->content->define( array(
main => "main.htm",
table => "tools_standard.htm",
stylesheet => "style.css"));

$go_api->content->assign( array( TITLE => "$session_site Startseite",
SESSION => $session,
BACKGROUND_GIF => "",
COPYRIGHT => "",
FGCOLOR => "$session_nav_hcolour",
TABLE_H_COLOR => "$session_page_hcolour",
BOXSIZE => "450",
WINDOWTITLE => "<font size=\"2\" face=\"Verdana\" color=\"#FFFFFF\">&nbsp; Whois</font>",
SITENAME => "$session_site",
DESIGNPATH => $session_design_path,
CHARSET => $go_info["theme"]["charset"],
SERVERURL => $go_info["server"]["server_url"],
S => $s
) );

// BEGIN TOOL ################################################## #########################

//$go_api->auth->check_admin(0);

$result = '';
$domain=($domainname."".$endfix."");
if (isset($submit)) {
// Switch von Domain-Endung
switch ($endfix) {
case '.de':
case '.se':
case '.nl':
$result=whois_cli($domain);
break;
case '.com':
case '.net':
case '.org':
$WhoIsServer="whois.crsnic.net";
$result=whois_php ($WhoIsServer,$domain);
break;
case '.lu':
$WhoIsServer="whois.restena.lu";
$result=whois_php ($WhoIsServer,$domain);
break;
case '.fr':
case '.be':
case '.at':
case '.it':
case '.no':
case '.dk':
case '.cz':
case '.is':
case '.sk':
case '.li':
case '.ch':
case '.sk':
case '.lt':
case '.hu':
$WhoIsServer="whois.ripe.net"; //$WhoIsServer zuweisen
$result=whois_php ($WhoIsServer,$domain);
break;
case '.ac':
$WhoIsServer="whois.nic.ac"; //$WhoIsServer zuweisen
$result=whois_php ($WhoIsServer,$domain);
break;
case '.eu.org':
$WhoIsServer="whois.eu.org"; //$WhoIsServer zuweisen
$result=whois_php ($WhoIsServer,$domain);
break;
case '.pl':
$WhoIsServer="dns.pl"; //$WhoIsServer zuweisen
$result=whois_php ($WhoIsServer,$domain);
break;
case '.co.za':
$result=whois_http_get ("http://co.za/cgi-bin/whois.sh?Domain=".$domain."&Enter=Enter");
//Clean up of html to remove submit form
if (stristr($result,"No Matches")) {
$result="Domain not found.";
}
break;
case '.org.za':
$post = "domain=".$domain."&format=full";
$result=whois_http_post ("http://www.org.za/cgi-bin/rwhois",$post);
//Clean up of html response to remove submit form
if (stristr($result,"Domain not registered")) {
$result="Domain not registered";
}
else{
$doc = new DomDocument();
$doc->loadHTML($result);
$nodes=$doc->getElementsByTagName("pre");
$result=$nodes->item(0)->textContent;
}
break;
default:echo("Error!\n");break;
}
}

function whois_php($WhoIsServer,$queryDomain){
$fp = fsockopen ("$WhoIsServer", 43, $errnr, $errstr);
$record="";
set_socket_blocking($fp, 0);
fputs($fp, "$queryDomain\n");
while (!feof($fp)) {
$record .= fgets($fp, 2048);
}
fclose($fp);
return $record;
}

function whois_cli($queryDomain){
$WhoIsServer = '-';
$record ="No Results";
$regex = '/^[a-zA-Z0-9\-\.]{0,63}$/';
if(preg_match($regex,$queryDomain)) {
$queryDomain = escapeshellcmd($queryDomain);
$fp = popen("whois $queryDomain", 'r');
$record = fread($fp, 4096);
if (substr($result,0, 8) == "No match"){$result = "Domain not registered";}
pclose($fp);
}
return $record;

}

function whois_http_get($WhoIsServerURL){
$record="No Results";
$cUrl = curl_init($WhoIsServerURL);
curl_setopt($cUrl, CURLOPT_TIMEOUT, 180);
curl_setopt($cUrl, CURLOPT_HEADER, 0);
curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
$record = trim(curl_exec($cUrl));
curl_close($cUrl);
return $record;
}

function whois_http_post($WhoIsServerURL,$post){
$record="No Results";
$cUrl = curl_init($WhoIsServerURL);
curl_setopt($cUrl, CURLOPT_TIMEOUT, 180);
curl_setopt($cUrl, CURLOPT_HEADER, 0);
curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cUrl, CURLOPT_POST, 1);
curl_setopt($cUrl, CURLOPT_POSTFIELDS, $post);
$record = trim(curl_exec($cUrl));
curl_close($cUrl);
return $record;
}

$result .= "<table border='0' width='100%' align='center'><tr><td><PRE>$result</pre></td></tr></table>";
$html_pre = '&nbsp;<br><form name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" class="t2">www.
<input type="text" name="domainname" size="17">&nbsp;&nbsp;&nbsp;
<select name="endfix" size="1" style="font-family: Verdana; font-size: 10pt; color: #4E566B; font-weight: bold">
<option name="pl" value=".pl">.pl
<option name="de" value=".de">.de
<option name="com" value=".com">.com
<option name="net" value=".net">.net
<option name="org" value=".org">.org
<option name="ac" value=".ac">.ac
<option name="at" value=".at">.at
<option name="be" value=".be">.be
<option name="ch" value=".ch">.ch
<option name="cz" value=".cz">.cz
<option name="dk" value=".dk">.dk
<option name="eu.org" value=".eu.org">.eu.org
<option name="fr" value=".fr">.fr
<option name="it" value=".it">.it
<option name="is" value=".is">.is
<option name="hu" value=".hu">.hu
<option name="li" value=".li">.li
<option name="lt" value=".lt">.lt
<option name="lu" value=".lu">.lu
<option name="no" value=".no">.no
<option name="sk" value=".sk">.sk
<option name="se" value=".se">.se
<option name="nl" value=".nl">.nl
<option name="co.za" value=".co.za">.co.za
<option name="org.za" value=".org.za">.org.za
</select>&nbsp;
<input type="submit" name="submit" value="Search &gt;&gt;" class="button"> </td>
</tr>
</table>
</form><br>&nbsp;<br>';
$html_show = $html_pre . $result;
// END TOOL ################################################## ###########################
$go_api->content->assign( array( TOOL => $html_show));
$go_api->content->parse(STYLESHEET, stylesheet);
$go_api->content->parse(MAIN, array("table","main"));
$go_api->content->FastPrint();
exit;
?>
Reply With Quote
Sponsored Links
  #2  
Old 20th June 2006, 12:07
mxc mxc is offline
Member
 
Join Date: May 2006
Location: South Africa
Posts: 91
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via Skype™ to mxc
Default

i forgot to say i needed to change the compile.sh file to include --with-curl and remove the disable xml statements for the ./configure command for php and recompiled ispconfig
Reply With Quote
  #3  
Old 20th June 2006, 13:25
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,424
Thanks: 812
Thanked 5,205 Times in 4,081 Posts
Default

Quote:
Originally Posted by mxc
i forgot to say i needed to change the compile.sh file to include --with-curl and remove the disable xml statements for the ./configure command for php and recompiled ispconfig
Hi, thanks for enhancing the whois script. Please send me the file to dev at ispconfig dot org, i will include it then to the development branch for further testing.

I think it can not be included in the stable branch yet as removing the disable xml statements in the configure stamenet breaks most current installations due to the lack of the libxml2-dev pacakge installed.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #4  
Old 22nd June 2006, 21:06
mxc mxc is offline
Member
 
Join Date: May 2006
Location: South Africa
Posts: 91
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via Skype™ to mxc
 
Default

will do. I will send it tomorrow.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:45.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.