Просмотр файла MyLounge/myred/signup.php

Размер файла: 8.14Kb
<?php
include("include/vars.php");
require("include/functions.php");
$lang=setlanguage();
require("language/$lang");
$menu=setmenu();

if (!$do) {
	$do = "lookup";
	}

if ($do == 'lookup') {
$main="<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"500\" align=\"center\">
<tr>
<td>$text_8</td>
</tr>
</table>
<form action = \"signup.php\" method=\"post\">
<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"500\" align=\"center\">
<tr>
<td>$text_10</td>
<td>$text_11 <input type=\"text\" name=\"dom\" maxlength=\"100\">.
<select name=\"ext\">";

// The difficult query :-)
$tld_query = mysql_query("SELECT * FROM $domain_table ORDER BY domain ASC");
while ($tlds = mysql_fetch_array($tld_query)) {	
	$main.="<option>$tlds[0]</option>";
}

$main.="</select>
</td>
</tr>
<tr>
<td>$text_12</td>
<td>(<a href=\"javascript:openwindow('help.php?do=target_signup');\">$text_13</a>) <input type=\"text\" name=\"url\" value=\"http://\" size=\"30\" maxlength=\"100\">
</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">
<input type=\"hidden\" name=\"do\" value=\"do_signup\">
<input type=\"submit\" name=\"sent\" value=\"$text_9\">
<input type=\"reset\" value=\"reset\">
</td>
</tr>
</table>
</form>";

$template = new MyredTemplate("template/template.html");
$template->assign("TITLE", $pagetitle);
$template->assign("MENU", $menu);
$template->assign("MAIN", $main);
$template->myred_print() or die($template->error);
exit;
}

if ($do == 'do_signup') {
	$errortxt="";
	if($dom=="") {
		$errortxt.="<br>$text_16";
		}
	if ($dom=="www") {
		$errortxt.="<br>$text_17";
		}
	// Search for unwanted special characters
	if(ereg("[^a-zA-Z0-9-]",$dom)) { 
		$errortxt.="<br>$text_18";
	}
	$dom=strtolower($dom);
	$new_domain="$dom.$ext";
	$checkdom=mysql_num_rows(mysql_query("select * from $redir_table where host='$new_domain'"));
	if($checkdom!="0") {
		$errortxt.="<br>$text_19";
		}
	if($errortxt!="") {
		errormsg($errortxt);
		exit;
		}
	if ($url!="http://" && $url!="") {
		$meta=spider($url);
		$title=$meta[0];
		$description=$meta[1];
		$keywords=$meta[2];
		$revisit=$meta[3];
		}

$main="<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"400\" align=\"center\">
<tr>
<td>$text_22</td>
</tr>
<tr>
<td>$text_23</td>
</tr>
</table>
<form action=\"signup.php\" method=\"post\">
<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"400\" align=\"center\">
<tr>
<td>$text_10</td>
<td><b>http://www.$new_domain</b></td>
</tr>
<tr>
<td><br><br><b>$text_24</b></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>$text_25</td>
<td><input type=\"text\" name=\"name\" maxlength=\"25\"></td>
</tr>
<tr>
<td>$text_26</td>
<td><input type=\"text\" name=\"firstname\" maxlength=\"25\"></td>
</tr>
<tr>
<td>$text_27</td>
<td><input type=\"text\" name=\"mail\" maxlength=\"100\"></td>
</tr>
<tr>
<td colspan=\"2\">$text_28</td>
</tr>
<tr>
<td><br><br><b>$text_29</b></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>$text_30 (<a href=\"javascript:openwindow('help.php?do=title');\">$text_13</a>):</td>
<td><input type=\"text\" name=\"title\" value=\"$title\" maxlength=\"100\"></td>
</tr>
<tr>
<td>$text_31 (<a href=\"javascript:openwindow('help.php?do=description');\">$text_13</a>):</td>
<td><input type=\"text\" name=\"description\" value=\"$description\" maxlength=\"270\"></td>
</tr>
<tr>
<td>$text_32 (<a href=\"javascript:openwindow('help.php?do=keywords');\">$text_13</a>):</td>
<td><input type=\"text\" name=\"keywords\" value=\"$keywords\" maxlength=\"270\"></td>
</tr>
<tr>
<td>$text_33 (<a href=\"javascript:openwindow('help.php?do=cat');\">$text_13</a>):</td>
<td>
<select name=\"cat\">";

// Another difficult query :-)
	$cat_query = mysql_query("SELECT * FROM $category_table ORDER BY category ASC");
	while ($cats = mysql_fetch_array($cat_query)) {	
		$main.="<option>$cats[0]</option>";
	}
$main.="</select>
</td>
</tr>
<tr>
<td>* $text_12 (<a href=\"javascript:openwindow('help.php?do=target');\">$text_13</a>):</td>
<td><input type=\"text\" name=\"url\" value=\"";

if ($url=="http://" || $url=="") {
	$main.="http://";
	}
else {
	$main.="$url";
	}

$main.="\" maxlength=\"100\"></td>
</tr>
<tr>
<td>$text_34 (<a href=\"javascript:openwindow('help.php?do=revisit');\">$text_13</a>):</td>
<td><input type=\"text\" name=\"revisit\" value=\"";

if ($revisit) {
	$main.=$revisit;
	}
else {
	$main.="10 days";
	}
$main.="\"></td>
</tr>
<tr>
<td>$text_35 (<a href=\"javascript:openwindow('help.php?do=robots');\">$text_13</a>):</td>
<td><select name=\"robot\">
<option value=\"INDEX, FOLLOW\">INDEX, FOLLOW</option>
<option value=\"NOINDEX, FOLLOW\">NOINDEX, FOLLOW</option>
<option value=\"NOINDEX\">NOINDEX</option>
<option value=\"INDEX\">INDEX</option>
<option value=\"FOLLOW\">FOLLOW</option>
<option value=\"ALL\">ALL</option>
</select></td>
</tr>
<tr>
<td colspan=\"2\"><input type=\"checkbox\" name=\"newsletter\" checked style=\"border:none\"> $text_36</td>
</tr>
<tr>
<td colspan=\"2\"><input type=\"checkbox\" name=\"terms\" style=\"border:none\"> $text_37</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">
<input type=\"hidden\" name=\"do\" value=\"signup\">
<input type=\"hidden\" name=\"new_domain\" value=\"$new_domain\">
<input type=\"submit\" name=\"sent\" value=\"$text_38\">
<input type=\"reset\" value=\"reset\">
</td>
</tr>
</table>
</form>";

$template = new MyredTemplate("template/template.html");
$template->assign("TITLE", $pagetitle);
$template->assign("MENU", $menu);
$template->assign("MAIN", $main);
$template->myred_print() or die($template->error);
exit;
}

if ($do == 'signup') {
	if (!$firstname) {
		$login_error="$text_39<br>";
	}
	if (!$name) {
		$login_error.="$text_40<br>";
	}
	if (!$mail || verify_email($mail)!=1) {
		$login_error.="$text_41<br>";
	}
	if (!$title) {
		$login_error.="$text_42<br>";
	}
	if($url=="http://" || $url=="") {
		$login_error.="$text_43<br>";
	}
	if ($terms != "on") {
		$login_error.="$text_44<br>";
	}

	// Search for unwanted special characters
//	if(ereg("[^a-zA-Z0-9_-]",$firstname) || ereg("[^a-zA-Z0-9_-]",$name) || ereg("[^a-zA-Z0-9_-]",$title) || ereg("[^a-zA-Z0-9_-]",$revisit) || ereg("[^a-zA-Z0-9_-]",$keywords) || ereg("[^a-zA-Z0-9_-]",$description)) { 
//		errormsg("Sorry, but you used special characters in one ore more fields and they are not allowed.");
//	}

	if (!$login_error) {
	// Do a second check of the domain. Someone could manipulate the htmlcode.
	$checkdom=mysql_num_rows(mysql_query("select * from $redir_table where host='$new_domain'"));
	if($checkdom!="0") {
		errormsg("$text_19");
		exit;
		}
	$password = randomstring(12);
	$date = time();
	$ip = getenv("REMOTE_ADDR");
	mysql_query("INSERT INTO $redir_table (host, name, vname, passwd, email, url, title, descr, keyw, counter, robots, news, revisit, time, ip, cat, lasttime) VALUES ('$new_domain', '$name', '$firstname', '$password', '$mail', '$url', '$title', '$description', '$keywords', '0', '$robot', '$newsletter', '$revisit', '$date', '$ip','$cat','$date')") or die (mysql_error()); 

// Send the mail
	$subject = "$text_45, $firstname $name!";
	$message = "$text_46

$text_47

$text_48 $new_domain
$text_49 $password

$text_50
";
	mail($mail,$subject,$message,"From: $adminmail\nReply-To: $adminmail"); 
// Send a second mail to the webmaster
	$subject1 = "Someone has registered at your website!";
	$message1 = "Someone has registered at your website!

Here is the data we got from him:

Domain: $new_domain
Name: $firstname $name
Email: $mail
Target URL: $url
Registrants ip: $ip";
	mail($adminmail,$subject1,$message1,"From: $adminmail\nReply-To: $adminmail"); 

$main="<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"400\" align=\"center\">
<tr>
<td>
<p>$text_56</p>
<p><b>http://www.$new_domain</b><br></p>
<p>$text_57</p>
<p>$text_46</p>
</td>
</tr>
</table>";
$template = new MyredTemplate("template/template.html");
$template->assign("TITLE", $pagetitle);
$template->assign("MENU", $menu);
$template->assign("MAIN", $main);
$template->myred_print() or die($template->error);
exit;
	}
	else {
		errormsg($login_error);	
		exit;
	}
}
?>