<?
header("Cache-Control: no-cache");
header("Content-type:text/vnd.wap.wml");
$ref=rand(10000,1000000);
require("conf.inc.php");
$linkk = @mysql_pconnect ($MySQL_Hostname, $MySQL_Username, $MySQL_Password)
or die ("<wml>
<card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">Can not connect to MySQL<br/>".mysql_error()."</p>
</card>
</wml>");
@mysql_select_db($MySQLDatabasename) or die ("<wml>
<card id=\"error\" title=\"error\">
<do type=\"prev\" label=\"Back\"><prev/></do><p align=\"center\">error select the database...<br/>".mysql_error()."</p>
</card>
</wml>");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">\n";
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"index\" title=\"Регистрация\">\n";
echo "<p align=\"left\" mode=\"wrap\">\n";
$q_u_l=@mysql_query("select link,id from users where link='".$link."'");
if(empty($title)) $error = $error."<b>Вы не ввели заголовок в гостевой!!</b><br/>";
if(empty($msgs)) $error = $error."<b>Вы не ввели кол-во сообщений на страницу!</b><br/>";
if(empty($pass)) $error = $error."<b>Вы не ввели пароль!!</b><br/>";
if(empty($link)) $error = $error."<b>Вы не ввели адрес вашего сайта!</b><br/>";
if(empty($razdel)) $error = $error."<b>Вы не ввели разделитель сообщений!!</b><br/>";
if(empty($error))
{
if (@MySQL_affected_rows()==0)
{
$title = htmlspecialchars(stripslashes(trim($title)));
$msgs = htmlspecialchars(stripslashes(trim($msgs)));
$pass = htmlspecialchars(stripslashes(trim($pass)));
$email = htmlspecialchars(stripslashes(trim($email)));
$link = htmlspecialchars(stripslashes(trim($link)));
$razdel = htmlspecialchars(stripslashes(trim($razdel)));
$sitename = htmlspecialchars(stripslashes(trim($sitename)));
$msgearch = array ("'\t'i",
"'([\n])[\s]+'",
"'\s{2,}'",
"'&(nbsp|#160);'i",
"'&#(\d+);'i");
// "'&#(\d+);'e");
$replace = array ("",
"\n",
" ",
" ",
"-");
// "chr(\\1)");
$title = preg_replace ($msgearch, $replace, $title);
$title=str_replace('$','$$',$title);
$title=preg_replace("/\[!\[/","<",$title);
$title=preg_replace("/\]!\]/",">",$title);
$msgs = preg_replace ($msgearch, $replace, $msgs);
$msgs=str_replace('$','$$',$msgs);
$msgs=preg_replace("/\[!\[/","<",$msgs);
$msgs=preg_replace("/\]!\]/",">",$msgs);
$link = preg_replace ($msgearch, $replace, $link);
$link=str_replace('$','$$',$link);
$link=preg_replace("/\[!\[/","<",$link);
$link=preg_replace("/\]!\]/",">",$link);
$razdel = preg_replace ($msgearch, $replace, $razdel);
$razdel=str_replace('$','$$',$razdel);
$razdel=preg_replace("/\[!\[/","<",$razdel);
$razdel=preg_replace("/\]!\]/",">",$razdel);
$sitename = preg_replace ($msgearch, $replace, $sitename);
$sitename=str_replace('$','$$',$sitename);
$sitename=preg_replace("/\[!\[/","<",$sitename);
$sitename=preg_replace("/\]!\]/",">",$sitename);
$now = date("j-m-Y");
if(mysql_query("Insert into users set title='".$title."', msgs='".$msgs."', pass='".$pass."', email='".$email."', link='".$link."', sitename='".$sitename."', date='".$now."', razdel='".$razdel."'")) {
echo "Гостевая успешно зарегистрирована!";
print "Адрес вашей гостевой:<br/>";
$query = mysql_query("select * from users where link='".$link."'");
$data = mysql_fetch_array($query);
echo "http://wap.waup.ru/sgb/index.php?id=".$data['id']."";
echo "<br/><b>Запомните, а лучше запишите! Ваш id: ".$data['id']." , пароль: ".$data['pass']." !</b>";
echo "<br/><a href=\"$link\">→На Ваш сайт</a>";
echo "<br/><a href=\"index.php?id=".$data['id']."\">→В гостевую</a><br/><a href=\"in.php\">→Сервис гостевых</a> ";
}
} else {
$sl= mysql_fetch_array($q_u_l);
echo "Для сайта $link гостевая уже зарегистрирована!<u>Её id=".$sl['id']." </u>";
echo "<br/><a href=\"reg.wml\">←Назад</a>";
echo "<br/><a href=\"http://****\">© ****</a>";
}
}
else
{
print $error;
}
echo "</p>\n";
echo "</card>\n";
echo "</wml>\n";
@mysql_close($linkk);
?>