Fehler bei einem Script, mit dem ich domains teste ob sie frei sind.

Muckel86

Grünschnabel
Liebe Community,
habe unter anlehnung an ein anderes Script versucht, eines zu schreiben, mit dem ich testen kann, welche Internetadressen (Domians) noch cniht vergeben sind bzw. ob sie es schon sind.
Code:
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?><?php
##    art-core.org domaincheck-script v. 0.7
##        copyright 2003-2004
##        Florian Anderiasch
##                (http://munich.art-core.org)
##            thanks:    dee (http://deesigns.de)
##                    #php.de on IRCNet
##
##
## Usage
##    invoke with GET or POST
##    - for normal query
##        ?domain=foo.com or
##        ?domain=foo&tld=com
##    - for details
##        ?info=all&domain=foo.com or
##        ?info=all&domain=foo&tld=com
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>domaincheck.art-core.org</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body link="#000000" vlink="#000000" alink="#000000">
<font color="#000000"> 
<?php

##    customize these variables
############################################
$version = "0.7";
$logging = "yes"; # (yes/no)
$timer     = "no"; # (yes/no)
$logfile = "log.txt"; # (must be writable by webserver - chmod o+w log.txt)
############################################
##    these are the whois-servers
############################################
$data = array
(
    "de"    => array( 0 => "whois.denic.de",    1 => "free"),
    "com"    => array( 0 => "whois.corenic.net",    1 => "is available"),
    "net"    => array( 0 => "whois.corenic.net",    1 => "is available"),
    "org"    => array( 0 => "whois.corenic.net",    1 => "is available"),
    "info"    => array( 0 => "whois.afilias.info",    1 => "NOT FOUND"),
    "biz"    => array( 0 => "whois.nic.biz",        1 => "Not found"),
    "ag"    => array( 0 => "whois.nic.ag",        1 => "NOT FOUND"),
#    "am"    => array( 0 => "whois.amnic.net",        1 => "No match"),
#    "as"    => array( 0 => "whois.nic.as",        1 => "Domain Not Found"),
    "at"    => array( 0 => "whois.nic.at",        1 => "nothing found"),
    "be"    => array( 0 => "whois.dns.be",        1 => "No such domain"),
#    "cd"    => array( 0 => "whois.nic.cd",        1 => "No match"),
    "ch"    => array( 0 => "whois.nic.ch",        1 => "We do not have an entry in our database"),
#    "cx"    => array( 0 => "whois.nic.cx",        1 => "No match"),
#    "cz"    => array( 0 => "whois.nic.cz",        1 => "No data found"),
#    "dk"    => array( 0 => "whois.dk-hostmaster.dk",    1 => "No entries found"),
#broken    "fm"    => array( 0 => "fm01.fm",    1 => "No entries found"),
    "it"    => array( 0 => "whois.nic.it",        1 => "No entries found"),
    "li"    => array( 0 => "whois.nic.li",        1 => "We do not have an entry in our database"),
#    "lu"    => array( 0 => "whois.dns.lu",        1 => "No such domain"),
    "nu"    => array( 0 => "whois.nic.nu",        1 => "NO MATCH"),
#    "ru"    =E?A†?†††?††††††††††††?††††††?›†<?†††††††††(?††?†?†††?†††?†††††?††††••?•††?•?•?†=?†?=•?†††?•?†?:?††:•††?•†††?††††††††?†††?††††††††?†††?††††††††?†††?††††††††?†††?††††††††?†††?††††††††?†††?††††††††?†††?††††††††?†††?††††††††?†††?††††††††?††?††††††?E? array( 0 => "whois.nic.uk",        1 => "No match"),
#    "org.uk"=> array( 0 => "whois.nic.uk",        1 => "No match"),
#    "uk.com"=> array( 0 => "whois.centralnic.net",    1 => "No match"),
#    "eu.com"=> array( 0 => "whois.centralnic.net",    1 => "No match"),
    
#    "ws"    => array( 0 => "whois.nic.ws",        1 => "No match")
);

$data2 = $data;
#######################################################################
############################################
##    interface
############################################
if ($_REQUEST['info'] != "all") {
?>
</font> 
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" leftmargin="0">
  <tr> 
    <td width="47" align="right" valign="bottom"><font color="#000000"><img src="box_forum_panel_left.gif" width="47" height="28"></font></td>
    <td width="706" height="28" background="box_login_panel_fill.jpg">&nbsp;</td>
    <td width="66"><font color="#000000"><img src="box_forum_panel_right.gif" width="47" height="28"></font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EFEFEF"> 
    <td colspan="3"><table width="800" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td bgcolor="#EFEFEF"><font color="#000000"><strong>Regestrierung (Schtitt 
            1 von 4)</strong></font></td>
        </tr>
        <tr> 
          <td bgcolor="#EFEFEF"><font color="#000000">(Regestrierung noch au&szlig;er 
            Betrieb! Bitte schreiben Sie uns eine E-Mail!)</font></td>
        </tr>
        <tr> 
          <td bgcolor="#EFEFEF"><font color="#000000"><a href="<?php echo $_SERVER['PHP_SELF'];?>">domaincheck<?php echo $version;?></a></font></td>
        </tr>
        <tr> 
          <td bgcolor="#EFEFEF"> <p><font color="#000000"><strong>Domain- Check</strong></font></p>
            <p><font color="#000000">Geben Sie beispielsweise http://www.test.de 
              ein, um zu testen, ob Ihre Wunschdomain noch zu Verf&uuml;gung steht. 
              <br />
              <br />
              Die Überprüfung dauert einen Moment, bitte haben Sie etwas Geduld.</font></p>
            <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
              <p> <font color="#000000"> 
                <input type="text" name="domain" size="30" value="<?php echo $_REQUEST['domain']; ?>" />
                &nbsp; 
                <select name="tld">
                  <option value="all">Alle</option>
                  <?php
							while (list($dom) = each ($data)) {
								if ($dom == $_REQUEST['tld']) {
									$sel = " selected";
								} else {
									$sel = "";
								}
								echo '                <option'.$sel.' value="'.$dom.'">.'.$dom."</option>\n";
							}
							?>
                </select>
                <input type="submit" name="button" value="Prüfen" />
                </font></p>
            </form>
            <font color="#000000"> 
            <?php
		}
		#######################################################################
		function get_table_row($pos, $domain, $tld) {
			$output .= '         <tr>';
			if ($pos === false) {
				$output .= "
				  <td>&nbsp;</td>
				  <td class='center'><span class='redtext'>".$domain.".".$tld."</span></td>
				  <td class='center'><a href=\"#\"
				  onClick=\"java script:window.open('".$_SERVER['PHP_SELF']."?info=all&amp;tld=".$tld."&amp;domain=".$domain."',
				  'details','scrollbars=1,copyhistory=0,directories=0,status=0,resizable=yes,width=650,height=400')\">Details</a></td>
				  <td class='center'><a href='http://www.".$domain.".".$tld."' target='_blank'>Anzeigen</a></td>\n";
			} else {
				$output .= '
				  <td class="center"><span class="greentext">'.$domain.".".$tld."</span></td>
				  <td>&nbsp;</td>
				  <td>&nbsp;</td>
				  <td>&nbsp;</td>\n";
					}
			$output .= "         </tr>\n";
			return $output;
		}
		function query_server($server, $dom, $tld) {
			# the query string
			$query = $dom.".".$tld."\r\n";
			
			# open connection to the whois server
			$fp = fsockopen($server,43);
			socket_set_blocking($fp, false);
			fputs($fp, $query);
			while(!feof($fp)) $result .= fgets($fp,128);
			fclose($fp);
			
			return $result;
		}
		function writelog($logfile, $domain, $tld, $time) {
			$ip = $_SERVER['REMOTE_ADDR'];
			$date = date("d.m.y H:i", time());
			if (file_exists($logfile) AND is_writeable($logfile)) {
				$fp = fopen($logfile,"a+");
				$contents = 'Datum: '.$date."\tIP: ".$ip."\t\tDomain: ".$domain.".".$tld."\tExectime: ".$time." sec\n";
				fputs($fp, $contents);
				fclose($fp);
			}
		}
		function simple($domain) {
				$what = split("\.", $domain);
				$x = count($what);
				$tld = $what[$x-1];
				$dom = $what[$x-2];
				# Check the name for bad characters
				if(strlen($dom) < 3) {
					$msg = "Der eingegebene Domainname ist zu kurz - Mindestens 3 Zeichen";
				}
				if(strlen($dom) > 63) {
					$msg = "Der eingegebene Domainname ist zu lang - Höchstens 63 Zeichen";
				}
				if(ereg("^-|--|-$",$domain)) {
					$msg = "Domainnamen könenn nicht mit einem Bindestrich beginnen, enden oder 2 Bindestriche enthalten";
				}
				if(!ereg("([a-z]|[A-Z]|[0-9]|-|\.){".strlen($domain)."}",$domain)) {
					$msg = "Domainnamen können nur alphanumerische Zeichen, Punkte und Bindestriche enthalten";
				}
			$ret['msg'] = $msg;
			$ret['dom'] = $dom;
			$ret['tld'] = $tld;
			return $ret;
		}
		############################################
		##    detailed view
		############################################
		if ($_REQUEST['info'] == "all") {
			if (strpos($_REQUEST['domain'], ".") === false) {
					# variables for better readability
					$dom = $_REQUEST['domain'];
					$tld = $_REQUEST['tld'];
					# Check the name for bad characters
					if(strlen($_REQUEST['domain']) < 3) {
						$msg = "Der eingegebene Domainname ist zu kurz - Mindestens 3 Zeichen";
					}
					if(strlen($_REQUEST['domain']) > 63) {
						$msg = "Der eingegebene Domainname ist zu lang - Höchstens 63 Zeichen";
					}
					if(ereg("^-|--|-$",$_REQUEST['domain'])) {
						$msg = "Domainnamen könenn nicht mit einem Bindestrich beginnen, enden oder 2 Bindestriche enthalten";
					}
					if(!ereg("([a-z]|[A-Z]|[0-9]|-){".strlen($_REQUEST['domain'])."}",$_REQUEST['domain'])) {
						$msg = "Domainnamen können nur alphanumerische Zeichen und Bindestriche enthalten";
					}    
				} else {
					$ret = simple($_REQUEST['domain']);
					$msg = $ret['msg'];
					$dom = $ret['dom'];
					$tld = $ret['tld'];
				}
			
			if (isset($data[$tld]['0'])) {
				# get whois info
				$details = query_server($data[$tld]['0'], $dom, $tld);
			
		        # generate output
				echo "<pre>".$details."</pre>";
				echo "<p align=center><a href=java script:window.close()>Fenster schliessen</a>";
		
			}
			else echo '<div align="center"><br />TLD nicht verf&uuml;gbar.<br /></div>';
			
		}
		############################################
		##    normal whois output
		############################################
		elseif (isset($_REQUEST['domain'])) {
		/*    if ($_REQUEST['go'] == "simple") {
				$ret = simple($_REQUEST['domain']);
				$msg = $ret['msg'];
				$dom = $ret['dom'];
				$tld = $ret['tld'];
			}
			else {
		*/
				if (strpos($_REQUEST['domain'], ".") === false) {
					# variables for better readability
					$dom = $_REQUEST['domain'];
					$tld = $_REQUEST['tld'];
					# Check the name for bad characters
					if(strlen($_REQUEST['domain']) < 3) {
						$msg = "Der eingegebene Domainname ist zu kurz - Mindestens 3 Zeichen";
					}
					if(strlen($_REQUEST['domain']) > 63) {
						$msg = "Der eingegebene Domainname ist zu lang - Höchstens 63 Zeichen";
					}
					if(ereg("^-|--|-$",$_REQUEST['domain'])) {
						$msg = "Domainnamen könenn nicht mit einem Bindestrich beginnen, enden oder 2 Bindestriche enthalten";
					}
					if(!ereg("([a-z]|[A-Z]|[0-9]|-){".strlen($_REQUEST['domain'])."}",$_REQUEST['domain'])) {
						$msg = "Domainnamen können nur alphanumerische Zeichen und Bindestriche enthalten";
					}    
				} else {
					$ret = simple($_REQUEST['domain']);
					$msg = $ret['msg'];
					$dom = $ret['dom'];
					$tld = $ret['tld'];
				}
		#    }
			if ( isset($tld) ) {
			 if (isset($msg)) {
				 # print error message
				 echo $msg;
			 } else {
				 # starting stopwatch
				$timeparts = explode(" ",microtime());
				$starttime = $timeparts[1].substr($timeparts[0],1);
				$tbl = '<table width="100%" border="0" align="center" cellspacing="0" cellpadding="1">
					 <tr>
					  <td width="200" class="center"><span class="bold">frei</span></td>
					  <td width="200" class="center"><span class="bold">belegt</span></td>
					  <td width="100"></td>
					  <td width="100"></td>
					 </tr>';
				
				if ($tld == "all") {
					$output .= $tbl;
					while (list($key) = each ($data2)) {    
						# get whois info
						$result[$key] = query_server($data[$key]['0'], $dom, $key);
						
						# generate output
						$pos = strpos($result[$key],$data[$key]['1']);
						$output .= get_table_row($pos, $dom, $key);
					}
					$output .= '</table>';
				} else {
					# get whois info
					if (isset($data[$tld]['0'])) {
						$result[$tld] = query_server($data[$tld]['0'], $dom, $tld);
			
						# generate output
						$pos = strpos($result[$tld],$data[$tld]['1']);
						$output .= $tbl;
						$output .= get_table_row($pos, $dom, $tld).'</table>';
					}
					else $output = '<div align="center"><br />TLD nicht verf&uuml;gbar.<br /></div>';
				
					
				}
		############################################
		##    whois output
		############################################
		?>
            </font> <table align="center" width="600" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="100%" bgstyle="color: 000000"> <table width="600" border="0" cellspacing="1" cellpadding="2">
                    <tr bgstyle="color: DDDDDD"> 
                      <td> <font color="#000000"><?php echo $output;?> 
                        <?php
				$timeparts = explode(" ",microtime());
				$stoptime = $timeparts[1].substr($timeparts[0],1);
				$time = $stoptime - $starttime;
				if ($timer == "yes")    echo '<br /><div align="center" class="text">execution time: '.$time.' sec</div>';
				if ($logging == "yes")    writelog($logfile, $_REQUEST['domain'], $_REQUEST['tld'], $time);
				?>
                        </font></td>
                    </tr>
                  </table></td>
              </tr>
            </table>
            <div align="center"></div>
            <font color="#000000"> 
            <?php
			 }
			}
		}
		?>
            </font></td>
        </tr>
      </table></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EFEFEF"> 
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

Das ist der ganze Quellcode. Mein Problem ist, dass ich einmal, wenn ich es in der index.php includen möchte, dass er dann bei dem ausführen immer auf die index.php geht.

Zum anderen, dass wenn ich eine domain getestet habe, und er eine belegte anzeigt, dass der Link mit Details nicht mehr funktioniert.

Sehen könnt ihr das ganze hier: http://www.magicweaver.de/greenhosting/new/regestrierung.php

Ich würde mich sehr freuen, wenn ihr mir helfen könnt.
Gruß Muckel
 
Hey mülla alte socke xD


also erstens mach aus dem:
PHP:
 <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">

mal ein:
PHP:
 <form method="post" action="<?php $PHP_SELF ?>">

und dann aus:
PHP:
<td class='center'><a href=\"#\"  onClick=\"java script:window.open('".$_SERVER['PHP_SELF']."?info=all&amp;tld=".$tld."&amp;domain=".$domain."',  'details','scrollbars=1,copyhistory=0,directories=0,status=0,resizable=yes,width=650,height=400')\">Details</a></td>

ein

PHP:
<td class='center'><a href=\"#\"  onClick=\"window.open('regestrieren.php?info=all&amp;tld=".$tld."&amp;domain=".$domain."',  'details','scrollbars=1,copyhistory=0,directories=0,status=0,resizable=yes,width=650,height=400')\">Details</a></td>


MfG dein Schulfreund xD de Ulf
 
Benutz lieber Folgendes:
HTML:
<td class="center"><a href="regestrieren.php?info=all&amp;tld=' . rawurlencode($tld) . '&amp;domain=' . rawurlencode($domain) . '" onclick="return !window.open(this.href,  'details', 'scrollbars=yes,copyhistory=no,directories=yes,status=no,resizable=yes,width=650,height=400')">Details</a></td>
… ist zugänglicher.
 
Zurück