<commit_before><?php
/*
   MUD4TLD - Martin's User and Domain system for Top Level Domains.
   Written 2012-2014 By <NAME>.
   This software is hereby dedicated to the public domain.
   Made for the OpenNIC Project.
   http://www.mchomenet.info/mud4tld.html
*/
include("conf.php");

function form_check_domain()
{
	global $TLD;
?>
<p>
<form action="domain.php" method="post">
Domain name <input type="text" name="domain">.<?php echo $TLD; ?>&nbsp;<input type="submit" name="check" value="Check">
<input type="hidden" name="action" value="check_domain">
</form>
</p>
<?php
}

function check_domain($domain)
{
    global $TLD, $specialNamesRFC6761, $specialNamesIANA;
	/* sanity check the domain */
	$name=htmlspecialchars(stripslashes($domain));
	$name=preg_replace("/[^a-zA-Z0-9\-]/","", $name); /* replace characters we do not want */
	$name=preg_replace('/^[\-]+/','',$name); /* remove starting hyphens */
	$name=preg_replace('/[\-]+$/','',$name); /* remove ending hyphens */
	$name=str_replace(" ", "", $name); /* remove spaces */
	$name=str_replace("--", "-", $name); /* remove double hyphens */
	$name=strtolower($name); /* all lower case to remove confusion */
	if( (strlen($name)<=2) || (strlen($name)>63))	/* Domain name labels limit=63 and uri limit=253 octects see RFC1035 */
	{
		echo "Sorry, domain names must contain at least 3 characters and be no longer than 253 characters.";	// >2 ISO 3166 reserved for country codes
		echo "Please go back and try again.";
		die();
	}
	if(preg_match($specialNamesRFC6761, $name)) {
		echo "Sorry, domain names must not contain special DNS names as specified in RFC6761.";
		echo "Please go back and try again.";
		die();	
	}
	if(preg_match($specialNamesIANA, $name)) {
		echo "Sorry, we do not want to mess with ICANN or IANA special DNS names."; //http://www.icann.org/en/about/agreements/registries/unsponsored/registry-agmt-appk-26apr01-en.htm
		echo "Please go back and try again.";
		die();	
	}
	if(strlen($name)>2)
	{
		echo "Checking <b>".$name.".".$TLD."</b> for you...";
		if(domain_taken($name))
		{
			echo "<font color=\"#ff0000\"><b>Taken</b></font><BR><BR>Sorry, that name is already taken.";
		} else {
			echo "<font color=\"#008000\"><b>Available!</b></font><BR><BR>Congratulations! <b>".$name.".".$TLD."</b> is available.\n";
			echo "Would you like to register it now?\n<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n<input type=\"hidden\" name=\"domain\" value=\"".$name."\">\n<input type=\"hidden\" name=\"action\" value=\"frm_register_domain\">\n<input type=\"submit\" name=\"submit\" value=\"Yes!\">\n</form>\n";
		}
		echo "You can use the form below to search for another domain if you like.";
	}
	form_check_domain();
}

function frm_register_domain($domain)
{
	global $TLD, $ws_title;
?>
<table width="500" align="center">
<tr><td align="center"><h1><?php echo $ws_title; ?> Registration</h1></td></tr>
<tr><td>
<p>Please fill out the information below. Make sure the details are correct before clicking "Register Domain" as incorrect details may delay the registration process.</p>
</td></tr>
<tr><td align="center">
<p><br>You are registering <font color="#008000"><b><?php echo $domain.".".$TLD; ?></b></font><BR>To register a different domain, please <a href="domain.php">check</a> it first.</p>
<?php
if(!isset($_SESSION['username']))
{
	echo "You must <a href=\"user.php?action=frm_login\">login</a> first before trying to register a domain.";
} else {
?>
<form action="domain.php" method="post">
<table width="450" border=0 cellspacing=1 cellpadding=0>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td width="200" valign="top">Username</td><td><?php echo $_SESSION['username']; ?><BR><font size="-1">(not you? <a href="user.php?action=frm_login">Login</a> as the correct user)</font></td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2"><b>Nameserver Settings</b></td></tr>
<tr><td>NS1 <font size="-1">eg: ns1.mywebhost.com</font></td><td><input type="text" name="ns1" value="enter here"></td></tr>
<tr><td>NS2 <font size="-1">eg: ns2.mywebhost.com</font></td><td><input type="text" name="ns2" value="enter here"></td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2">Custom Nameservers <font size="-1">(Experts only, can be left blank)</font></td></tr>
<tr><td>NS1 <font size="-1">(IPv4 only)</font></td><td><input type="text" name="ns1_ip"></td></tr>
<tr><td>NS2 <font size="-1">(IPv4 only)</font></td><td><input type="text" name="ns2_ip"></td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2" align="center"><input type="hidden" name="action" value="register_domain"><input type="submit" name="submit" value="Register Domain"></tr></tr>
</table>
<?php
echo "<input type=\"hidden\" name=\"domain\" value=\"".$domain."\">\n";
?>
</form>
<?php
}
?>
</td></tr>
</table>
<?php
}

function register_domain($domain, $ns1, $ns2, $ns1_ip, $ns2_ip)
{
	global $TLD, $tld_svr, $user, $userkey;

	$userid=$_SESSION['userid'];
	$username=$_SESSION['username'];
	if(strlen($userid)<1)
	{
		echo "Error validating user session.\n"; die();
	}
	if(strlen($username)<3)
	{
		echo "Error validating user name.\n"; die();
	}
	$ns1=$_POST['ns1'];
	$ns2=$_POST['ns2'];
	if( ($ns1=="enter here") || ($ns2=="enter here") )
	{
		echo "<font color='#ff0000'><b>Error</b></font> Please change the nameservers to your own.\n"; die();
	}
	if( (empty($ns1)) || (empty($ns2)))
	{
		echo "<font color='#ff0000'><b>Error</b></font> Please change the nameservers to your own.\n"; die();
	}
	if( (isset($_POST['ns1_ip'])) && (strlen($_POST['ns1_ip'])>0) )
	{
		$ns1_ip=$_POST['ns1_ip'];
		if(validateIPAddress($ns1_ip)==0)
		{
			echo "<font color='#ff0000'><b>Error</b></font> NS1 Custom Nameserver must be a valid IPv4 address"; die();
		}
	}
	if( (isset($_POST['ns2_ip'])) && (strlen($_POST['ns2_ip'])>0) )
	{
		$ns2_ip=$_POST['ns2_ip'];
		if(validateIPAddress($ns2_ip)==0)
		{
			echo "<font color='#ff0000'><b>Error</b></font> NS2 Custom Nameserver must be a valid IPv4 address"; die();
		}
	}
	if( (strlen($domain)<2) && (strlen($domain)>50) && (strlen($ns1)<5) && (strlen($ns2)<5) )
	{
		echo "<font color='#ff0000'><b>Error</b></font> Domain details must adhere to standard lengths.\n"; die();
	}
	if($ns1 == $ns2)
	{
		echo "<font color='#FF8C00'><b>Please Note:</b></font> We highly recommend that you use two different nameserver values instead of the same one.<BR>\n";
	}
	echo "Processing ".$domain.'.'.$TLD."...";
	if(domain_taken($domain))
	{
		echo "Sorry, this domain has already been submitted for processing. If you believe this to be in error or you would like to dispute the previous registration, please contact us using the domain <a href=\"abuse.php\">abuse</a> page</a>. Thank you.";
		die();
	}
	if( (strlen($ns1_ip)>7) && (strlen($ns2_ip)>7))
	{
		$URL=$tld_svr."?cmd=register&user=".$user."&userkey=".$userkey."&tld=".$tld."&domain=".$domain."&userid=".$userid."&ns1=".$ns1."&ns2=".$ns2."&ns1_ip=".$ns1_ip."&ns2_ip=".$ns2_ip;
	} else {
		$URL=$tld_svr."?cmd=register&user=".$user."&userkey=".$userkey."&tld=".$tld."&domain=".$domain."&userid=".$userid."&ns1=".$ns1."&ns2=".$ns2;
	}
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $URL);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $ret_data = curl_exec($ch);
    curl_close($ch);

	switch($ret_data)
	{
		case "0":
			echo "<font color=\"#800000\"><b>Error</b></font><BR>An error occured during registration. Please try again.";
			break;
		case "1":
			echo "<font color=\"#008000\"><b>Complete</b></font><BR>Congratulations! Your new domain has been registered and should be live within the next 24 hours.";
			break;
		case "255":
			echo "<font color=\"#800000\"><b>Server Error</b></font><BR>A server error has occured. Please contact this site's administrators.";
			break;
	}
}
<commit_msg>correct undefined variable<commit_after><?php
/*
   MUD4TLD - Martin's User and Domain system for Top Level Domains.
   Written 2012-2014 By <NAME>.
   This software is hereby dedicated to the public domain.
   Made for the OpenNIC Project.
   http://www.mchomenet.info/mud4tld.html
*/
include("conf.php");

function form_check_domain()
{
	global $TLD;
?>
<p>
<form action="domain.php" method="post">
Domain name <input type="text" name="domain">.<?php echo $TLD; ?>&nbsp;<input type="submit" name="check" value="Check">
<input type="hidden" name="action" value="check_domain">
</form>
</p>
<?php
}

function check_domain($domain)
{
    global $TLD, $specialNamesRFC6761, $specialNamesIANA;
	/* sanity check the domain */
	$name=htmlspecialchars(stripslashes($domain));
	$name=preg_replace("/[^a-zA-Z0-9\-]/","", $name); /* replace characters we do not want */
	$name=preg_replace('/^[\-]+/','',$name); /* remove starting hyphens */
	$name=preg_replace('/[\-]+$/','',$name); /* remove ending hyphens */
	$name=str_replace(" ", "", $name); /* remove spaces */
	$name=str_replace("--", "-", $name); /* remove double hyphens */
	$name=strtolower($name); /* all lower case to remove confusion */
	if( (strlen($name)<=2) || (strlen($name)>63))	/* Domain name labels limit=63 and uri limit=253 octects see RFC1035 */
	{
		echo "Sorry, domain names must contain at least 3 characters and be no longer than 253 characters.";	// >2 ISO 3166 reserved for country codes
		echo "Please go back and try again.";
		die();
	}
	if(preg_match($specialNamesRFC6761, $name)) {
		echo "Sorry, domain names must not contain special DNS names as specified in RFC6761.";
		echo "Please go back and try again.";
		die();	
	}
	if(preg_match($specialNamesIANA, $name)) {
		echo "Sorry, we do not want to mess with ICANN or IANA special DNS names."; //http://www.icann.org/en/about/agreements/registries/unsponsored/registry-agmt-appk-26apr01-en.htm
		echo "Please go back and try again.";
		die();	
	}
	if(strlen($name)>2)
	{
		echo "Checking <b>".$name.".".$TLD."</b> for you...";
		if(domain_taken($name))
		{
			echo "<font color=\"#ff0000\"><b>Taken</b></font><BR><BR>Sorry, that name is already taken.";
		} else {
			echo "<font color=\"#008000\"><b>Available!</b></font><BR><BR>Congratulations! <b>".$name.".".$TLD."</b> is available.\n";
			echo "Would you like to register it now?\n<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n<input type=\"hidden\" name=\"domain\" value=\"".$name."\">\n<input type=\"hidden\" name=\"action\" value=\"frm_register_domain\">\n<input type=\"submit\" name=\"submit\" value=\"Yes!\">\n</form>\n";
		}
		echo "You can use the form below to search for another domain if you like.";
	}
	form_check_domain();
}

function frm_register_domain($domain)
{
	global $TLD, $ws_title;
?>
<table width="500" align="center">
<tr><td align="center"><h1><?php echo $ws_title; ?> Registration</h1></td></tr>
<tr><td>
<p>Please fill out the information below. Make sure the details are correct before clicking "Register Domain" as incorrect details may delay the registration process.</p>
</td></tr>
<tr><td align="center">
<p><br>You are registering <font color="#008000"><b><?php echo $domain.".".$TLD; ?></b></font><BR>To register a different domain, please <a href="domain.php">check</a> it first.</p>
<?php
if(!isset($_SESSION['username']))
{
	echo "You must <a href=\"user.php?action=frm_login\">login</a> first before trying to register a domain.";
} else {
?>
<form action="domain.php" method="post">
<table width="450" border=0 cellspacing=1 cellpadding=0>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td width="200" valign="top">Username</td><td><?php echo $_SESSION['username']; ?><BR><font size="-1">(not you? <a href="user.php?action=frm_login">Login</a> as the correct user)</font></td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2"><b>Nameserver Settings</b></td></tr>
<tr><td>NS1 <font size="-1">eg: ns1.mywebhost.com</font></td><td><input type="text" name="ns1" value="enter here"></td></tr>
<tr><td>NS2 <font size="-1">eg: ns2.mywebhost.com</font></td><td><input type="text" name="ns2" value="enter here"></td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2">Custom Nameservers <font size="-1">(Experts only, can be left blank)</font></td></tr>
<tr><td>NS1 <font size="-1">(IPv4 only)</font></td><td><input type="text" name="ns1_ip"></td></tr>
<tr><td>NS2 <font size="-1">(IPv4 only)</font></td><td><input type="text" name="ns2_ip"></td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2" align="center"><input type="hidden" name="action" value="register_domain"><input type="submit" name="submit" value="Register Domain"></tr></tr>
</table>
<?php
echo "<input type=\"hidden\" name=\"domain\" value=\"".$domain."\">\n";
?>
</form>
<?php
}
?>
</td></tr>
</table>
<?php
}

function register_domain($domain, $ns1, $ns2, $ns1_ip, $ns2_ip)
{
	global $TLD, $tld_svr, $user, $userkey;

	$userid=$_SESSION['userid'];
	$username=$_SESSION['username'];
	if(strlen($userid)<1)
	{
		echo "Error validating user session.\n"; die();
	}
	if(strlen($username)<3)
	{
		echo "Error validating user name.\n"; die();
	}
	$ns1=$_POST['ns1'];
	$ns2=$_POST['ns2'];
	if( ($ns1=="enter here") || ($ns2=="enter here") )
	{
		echo "<font color='#ff0000'><b>Error</b></font> Please change the nameservers to your own.\n"; die();
	}
	if( (empty($ns1)) || (empty($ns2)))
	{
		echo "<font color='#ff0000'><b>Error</b></font> Please change the nameservers to your own.\n"; die();
	}
	if( (isset($_POST['ns1_ip'])) && (strlen($_POST['ns1_ip'])>0) )
	{
		$ns1_ip=$_POST['ns1_ip'];
		if(validateIPAddress($ns1_ip)==0)
		{
			echo "<font color='#ff0000'><b>Error</b></font> NS1 Custom Nameserver must be a valid IPv4 address"; die();
		}
	}
	if( (isset($_POST['ns2_ip'])) && (strlen($_POST['ns2_ip'])>0) )
	{
		$ns2_ip=$_POST['ns2_ip'];
		if(validateIPAddress($ns2_ip)==0)
		{
			echo "<font color='#ff0000'><b>Error</b></font> NS2 Custom Nameserver must be a valid IPv4 address"; die();
		}
	}
	if( (strlen($domain)<2) && (strlen($domain)>50) && (strlen($ns1)<5) && (strlen($ns2)<5) )
	{
		echo "<font color='#ff0000'><b>Error</b></font> Domain details must adhere to standard lengths.\n"; die();
	}
	if($ns1 == $ns2)
	{
		echo "<font color='#FF8C00'><b>Please Note:</b></font> We highly recommend that you use two different nameserver values instead of the same one.<BR>\n";
	}
	echo "Processing ".$domain.'.'.$TLD."...";
	if(domain_taken($domain))
	{
		echo "Sorry, this domain has already been submitted for processing. If you believe this to be in error or you would like to dispute the previous registration, please contact us using the domain <a href=\"abuse.php\">abuse</a> page</a>. Thank you.";
		die();
	}
	if( (strlen($ns1_ip)>7) && (strlen($ns2_ip)>7))
	{
		$URL=$tld_svr."?cmd=register&user=".$user."&userkey=".$userkey."&tld=".$TLD."&domain=".$domain."&userid=".$userid."&ns1=".$ns1."&ns2=".$ns2."&ns1_ip=".$ns1_ip."&ns2_ip=".$ns2_ip;
	} else {
		$URL=$tld_svr."?cmd=register&user=".$user."&userkey=".$userkey."&tld=".$TLD."&domain=".$domain."&userid=".$userid."&ns1=".$ns1."&ns2=".$ns2;
	}
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $URL);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $ret_data = curl_exec($ch);
    curl_close($ch);

	switch($ret_data)
	{
		case "0":
			echo "<font color=\"#800000\"><b>Error</b></font><BR>An error occured during registration. Please try again.";
			break;
		case "1":
			echo "<font color=\"#008000\"><b>Complete</b></font><BR>Congratulations! Your new domain has been registered and should be live within the next 24 hours.";
			break;
		case "255":
			echo "<font color=\"#800000\"><b>Server Error</b></font><BR>A server error has occured. Please contact this site's administrators.";
			break;
	}
}

{'fraction_non_alphanumeric': 0.22861516871850482, 'fraction_numerical': 0.026918415513172162, 'mean_word_length': 5.093276331130975, 'pattern_counts': {'":': 6, '<': 411, '<?xml version=': 0, '>': 413, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3553774', 'n_tokens_mistral': 6041, 'n_tokens_neox': 5688, 'n_words': 1330}