Файл: billing/reg_domain.php
Строк: 395
<?php
require_once( "./_rootconfig.php" );
session_start( );
mconnect( );
validateuser( );
if ( $do == "whois" )
{
head( );
$d = new domain( $_GET['d'] );
print "<B>Информация о домене:</b><BR><BR>";
echo $d->html_info( );
foot( );
mclose( );
exit( );
}
if ( $do == "order" )
{
if ( !$domain || !$zone )
{
$error = "Не указано доменное имя.";
$do = "";
}
else if ( !$paymethod )
{
$error = "Не указан способ оплаты.";
$do = "";
}
else
{
$fulldomain = $domain.".".$zone;
$dom = new domain( $fulldomain );
if ( !$dom->is_available( ) )
{
$error = "Доменное имя <B>{$fulldomain}</b> уже зарегистрировано.<BR>Вы можете <a href=?d={$fulldomain}&do=whois target=_blank>просмотреть whois-информацию</a> о домене";
$do = "";
}
else
{
if ( !( $k = @mysql_query( @"select * from orders_domains where domain='{$fulldomain}' and todate>NOW()" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $k ) )
{
$error = "Указанное доменное имя уже заказано другим пользователем.";
$do = "";
}
else
{
if ( !$_SESSION['userId'] && $elogin && $epassword )
{
$auth = userlogon( $elogin, $epassword );
if ( $auth == "-1" )
{
$error = "Введено несуществующее имя пользователя.";
$do = "";
}
else
{
if ( !$auth )
{
$error = "Указан неверный пароль.";
$do = "";
}
}
}
else if ( !$_SESSION['userId'] )
{
$login = strtolower( $login );
if ( !$login )
{
$error = "Не указан логин.";
$do = "";
}
else if ( eregi( "^[0-9]", $login ) )
{
$error = "Логин должен начинаться с a-z";
$do = "";
}
else if ( eregi( "[^a-z,0-9]", $login ) )
{
$error = "Логин должен состоять из сиволов a-z,0-9";
$do = "";
}
else if ( strlen( $login ) < 3 || 10 < strlen( $login ) )
{
$error = "Длина логина должна быть от 3 до 10 символов.";
$do = "";
}
else if ( !$password )
{
$error = "Не указан пароль.";
$do = "";
}
else if ( !$repassword )
{
$error = "Не подтверждён пароль.";
$do = "";
}
else if ( strlen( $password ) < 6 )
{
$error = "Длина пароля не должна быть менее 6 символов.";
$do = "";
}
else if ( $password != $repassword )
{
$error = "Неправильно подтверждён пароль.";
$do = "";
}
else if ( !valid_email( $email ) )
{
$error = "Указан неправильный e-mail адрес.";
$do = "";
if ( !( $r = @mysql_query( @"select * from users where login='{$login}'" ) ) )
{
exit( mysql_error( ) );
}
}
else if ( 0 < mysql_num_rows( $r ) )
{
print "Пользователь с таким логином уже зарегистрирован.";
$do = "";
}
else
{
if ( !mysql_query( "insert into users (login,password,email,datareg) values('{$login}','".crypt( $password )."','{$email}',NOW())" ) )
{
exit( mysql_error( ) );
}
userlogon( "{$login}", "{$password}" );
if ( !mysql_query( "insert into users_profile (uid) values('".$_SESSION['userId']."')" ) )
{
exit( mysql_error( ) );
}
}
}
if ( $_SESSION['userId'] )
{
if ( !( $zid = @mysql_query( @"select * from zones where zone='{$zone}'" ) ) )
{
exit( mysql_error( ) );
}
$zid = mysql_fetch_object( $zid );
$zid = $zid->id;
if ( !@mysql_query( @"insert into orders_domains (uid,zone_id,domain,orderdate,paymethod,comment,ns1,ns2) values ('".@$_SESSION['userId'].@"','{$zid}','{$fulldomain}',NOW(),'{$paymethod}','".@addslashes( @$comment ).@"','{$ns1}','{$ns2}')" ) )
{
exit( mysql_error( ) );
}
$domain_id = mysql_insert_id( );
if ( !( $tzones = @mysql_query( @"select cost_if_not_host,minsrok from zones where zone='{$zone}'" ) ) )
{
exit( mysql_error( ) );
}
$tzones = mysql_fetch_object( $tzones );
$domainCost = $tzones->cost_if_not_host;
$domainMinSrok = $tzones->minsrok;
$domainCost = $domainCost * ( $domainMinSrok / 12 );
if ( !@mysql_query( @"insert into bills (uid,domain_id,domain_srok,money_domain,created) values('".@$_SESSION['userId'].@"','{$domain_id}','{$domainMinSrok}','{$domainCost}',NOW())" ) )
{
exit( mysql_error( ) );
}
$bill_id = mysql_insert_id( );
$sid = sprintf( "%04d", $bill_id );
$template = gettpl( "email_touser_domain_order" );
$company_name = getsetting( "company_name" );
$company_url = getsetting( "company_url" );
$billing_url = getsetting( "billing_url" );
$support_url = getsetting( "support_url" );
$manager_email = getsetting( "manager_email" );
if ( $elogin && $epassword )
{
$tl = strtolower( $elogin );
$tp = $epassword;
}
else if ( $login && $password )
{
$tl = strtolower( $login );
$tp = $password;
}
else
{
$tl = $_SESSION['userLogin'];
$tp = "******";
}
$template = str_replace( "{company_name}", $company_name, $template );
$template = str_replace( "{company_url}", $company_url, $template );
$template = str_replace( "{billing_url}", $billing_url, $template );
$template = str_replace( "{support_url}", $support_url, $template );
$template = str_replace( "{domain}", $fulldomain, $template );
$template = str_replace( "{login}", $tl, $template );
$template = str_replace( "{password}", $tp, $template );
$template = str_replace( "{schet}", $sid, $template );
$template = str_replace( "{domaincost}", $domainCost, $template );
$template = str_replace( "{cost}", $domainCost, $template );
$template = str_replace( "{srok}", $domainMinSrok / 12, $template );
$template = str_replace( "{paymethod}", $paymethod, $template );
if ( $comment )
{
$comment = "Комментарий:n".$comment;
}
$template = str_replace( "{comment}", $comment, $template );
if ( $ns1 || $ns2 )
{
$ns = "NS1: {$ns1}nNS2: {$ns2}nn";
}
$template = str_replace( "{ns}", $ns, $template );
$template = str_replace( "{userid}", $_SESSION['userId'], $template );
adduserlog( $_SESSION['userId'], "orderdomain", "{$fulldomain}, ".$domainMinSrok / 12." г." );
sendmail( $_SESSION['userEmail'], $manager_email, "Оформление заказа [domain]", $template );
sendmail( $manager_email, $_SESSION['userEmail'], "Duplicate: Оформление заказа [domain]", $template );
header( "Location: billing.php?do=profile&fromreg=1&bill_id={$bill_id}" );
mclose( );
exit( );
}
}
}
}
}
if ( !$do )
{
head( );
print "<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td><font size=5><b><font size=3>Оформление заказа</font></b></font><hr size=1></td></tr></table>";
if ( $error )
{
print "<font color=red>Ошибка: {$error}</font><BR><BR>";
}
echo "rnt";
echo "<s";
echo "cript language=javascript type='text/javascript'>rnrntfunction showblankdiv(divid) {rnttif (document.getElementById) { // DOM3 = IE5, NS6rntttdocument.getElementById(divid).style.display = 'block';rntt}rnttelse {rntttif (document.layers) { // Netscape 4rnttttdocument.divid.display = 'block';rnttt}rntttelse { // IE 4rnttttdocument.all.divid.style.display = 'block';rnttt}rntt}rnt}rntrntfunction hide";
echo "blankdiv(divid) {rnttif (document.getElementById) { // DOM3 = IE5, NS6rntttdocument.getElementById(divid).style.display = 'none';rntt}rnttelse {rntttif (document.layers) { // Netscape 4rnttttdocument.divid.display = 'none';rnttt}rntttelse { // IE 4rnttttdocument.all.divid.style.display = 'none';rnttt}rntt}rnt}rnt</script>rnrnt<form method=post name=order>rnt<input type=hidden name=do value=order>rn";
if ( !isset( $_SESSION['userId'] ) )
{
echo "t<B>Выбор типа клиента:</B><BR>rnt<table border=0><tr><td>rnt<input type=radio name=usertype value=exists ";
if ( $usertype != "new" )
{
print "checked";
}
echo " onclick="hideblankdiv('tablereg'); showblankdiv('tablelogin')">Зарегистрированный клиент<BR>rnt<input type=radio name=usertype value=new ";
if ( $usertype == "new" )
{
print "checked";
}
echo " onclick="hideblankdiv('tablelogin'); showblankdiv('tablereg')">Новый клиент<BR><BR>rnt</td></tr></table>rnrnt";
if ( $usertype != "new" )
{
$style = "style='display: block;'";
}
else
{
$style = "style='display: none;'";
}
echo "trnt<div id=tablelogin ";
echo $style;
echo ">rnt<B>Введите Ваши логин и пароль:</b><br>rnt<table border=0>rnt<tr><td colspan=2></td></tr>rnt<tr><td>* Логин в системе:</td><td><input type="text" name="elogin" value="";
echo $elogin;
echo "" maxlength=10 size=20></td></tr>rnt<tr><td>* Пароль:<BR><BR></td><td><input type="password" name="epassword" size=20><BR><BR></td></tr>rnt</table>rnt</div>rntrnt";
if ( $usertype == "new" )
{
$style = "style='display: block;'";
}
else
{
$style = "style='display: none;'";
}
echo "rnt<div id=tablereg ";
echo $style;
echo ">rnt<table border=0>rnt<tr><td colspan=3><B>Заполните нижеследующую форму:</b><br><br></td></tr>rnt<tr><td align=right>* Логин в системе:</td><td><input type="text" name="login" value="";
echo $login;
echo "" maxlength=10 size=20> от 3 до 10 символов a-z,0-9</td><td></td></tr>rnt<tr><td align=right>* Пароль:</td><td><input type="password" name="password" size=20> не менее 6 символов</td><Td></td></tr>rnt<tr><td valign=middle align=right>* Повтор пароля:</td><td colspan="2"><input type="password" name="repassword" size=20></td></tr>rnt<tr><td valign=middle align=right>* Ваш e-mail:<BR><BR></td><td colspan="2"><input type="text"";
echo " name="email" value="";
echo $email;
echo ""><BR><BR></td></tr>rnt</table>rnt</div>rn";
}
echo "t<table border=0>rnt<tr><td colspan=3><B>Выбор домена и оформление заказа:</b><br><br></td></tr>rnt<tr><td align=right>* Домен:</td><td><input type="text" name="domain" value="";
echo $domain;
echo ""> ";
echo "<s";
echo "elect name="zone"><option>rnt";
if ( !( $r = @mysql_query( "select * from zones where active=1 order by zone" ) ) )
{
exit( mysql_error( ) );
}
while ( $rr = mysql_fetch_object( $r ) )
{
if ( $rr->zone == $zone )
{
$addon = "selected";
}
else
{
$addon = "";
}
print "<option value={$rr->zone} {$addon}>.{$rr->zone}";
}
echo "t</select></td></tr>rnt<tr><td valign=top align=right><BR>NS1:</td><Td><BR><input type=text name=ns1 value="";
echo $ns1;
echo "" size=20> первичный DNS-сервер</td></tr>rnt<tr><td valign=top align=right>NS2:</td><Td><input type=text name=ns2 value="";
echo $ns2;
echo "" size=20> вторичный DNS-сервер</td></tr>rnt<tr><td align=right><BR>* Способ оплаты:</td><Td><BR>";
echo "<s";
echo "elect name=paymethod><option>rnt";
if ( getsetting( "wmz" ) || getsetting( "wmr" ) || getsetting( "wme" ) )
{
print "<option>WebMoney</option>";
}
echo "t";
if ( getsetting( "yandex" ) )
{
print "<option>Яндекс.Деньги</option>";
}
echo "t";
if ( getsetting( "egold" ) )
{
print "<option>E-Gold</option>";
}
echo "t";
if ( getsetting( "rupayschet" ) )
{
print "<option>RuPay</option>";
}
echo "t</select></td></tr>rnt<tr><td valign=top align=right>Комментарий:</td><Td><textarea name=comment cols=25 rows=3></textarea></td></tr>rnt<tr><td> </td><td colspan="2"><BR><input type="submit" name="Submit" value="Заказать"></td></tr>rnt</table>rnt</form>rnrnt<br>Поля, отмеченные знаком *, обязательны для заполнения.rnrnt";
foot( );
}
mclose( );
?>