Файл: billing/admin.php
Строк: 4431
<?php
session_start( );
require( "./_rootconfig.php" );
if ( $_GET['do'] == "logout" && !isset( $_POST['pass'] ) )
{
adminlogout( );
header( "Location: admin.php" );
exit( );
}
mconnect( );
include( "./_rootinc/adminhead.inc" );
if ( isset( $_POST['pass'] ) && !adminlogon( $_POST['login'], $_POST['pass'] ) )
{
print "<BR><center><font color=red>Не правильно введён логин или пароль.</font></center>";
}
if ( !isset( $_SESSION['adminLogin'] ) )
{
if ( !getsetting( "admin_login" ) )
{
$admin_exists = False;
if ( $do == "createadmin" )
{
print "<BR>";
if ( $new_login == "" )
{
print "Не указан логин.<BR>";
}
else if ( $new_pass == "" )
{
print "Не указан пароль.<BR>";
}
else if ( $new_pass2 == "" )
{
print "Не подтверждён пароль.<BR>";
}
else if ( $new_pass != $new_pass2 )
{
print "Пароль подтверждён неправильно.<BR>";
}
else if ( strlen( $new_pass ) < 6 )
{
print "Пароль не может быть короче 6 символов.<BR>";
}
else
{
setsetting( "admin_login", $new_login );
setsetting( "admin_password", crypt( $new_pass ) );
$admin_exists = True;
print "Логин и пароль администратора успешно созданы.<BR>Вам необходимо пройти авторизацию.<BR><BR>";
}
}
if ( !$admin_exists )
{
echo " tt<center><BR>rn ttПеред началом работы необходимо создать логин и пароль администратора.<BR><BR>rn tt<B>Создание логина и пароля администратора:</b><BR><BR>rn tt<form method=post>rn tt<input type=hidden name=do value=createadmin>rn tt<table>rn tt<tr><td>Логин:</td><td><input type=text name=new_login value="";
echo $new_login;
echo ""></tr></td>rn tt<tr><td>Пароль:</td><td><input type=password name=new_pass></td></tr>rn tt<tr><td>Ещё раз пароль:</td><td><input type=password name=new_pass2></td></tr>rn tt</table>rn tt";
echo "<s";
echo "cript>document.forms[0].new_login.focus();</script>rn tt<br><input type=submit value=Создать><BR><BR>rn tt* Длина пароля должна быть не менее 6 символов.rn tt</form>rntttt";
}
}
else
{
$admin_exists = True;
}
if ( $admin_exists )
{
echo " t<center><BR>rn t<B>Введите логин и пароль:</b><BR><BR>rn t<form method=post>rn t<table>rn t<tr><td>Логин:</td><td><input type=text name=login></tr></td>rn t<tr><td>Пароль:</td><td><input type=password name=pass></td></tr>rn t</table>rn t";
echo "<s";
echo "cript>document.forms[0].login.focus();</script>rn t<br><input type=submit value=Войти>rn t</form>rn t";
}
include( "./_rootinc/adminfoot.inc" );
mclose( );
exit( );
}
if ( !$do )
{
getfont( );
echo "tt<table border=0>rntt<tr>rntt<td>rnttrntt<form method=post>rntt<input type=hidden name=do value=editbill>rntt<table>rntt<tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Редактировать счет</b></td></tr>rntt<tr><td bgcolor=";
echo $font_row;
echo ">Счет № <input type=text name=id size=2> <input type=submit value=OK></td></tr>rntt</table>rntt</form>rnttrntt</td>rntt<td width=20></td>rntt<td>rnrntt<form method=post>rntt<input type=hidden name=do value=fullinfo>rntt<table>rntt<tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Информация по клиенту</b></td></tr>rntt<tr><td bgcolor=";
echo $font_row;
echo ">ID/Логин клиента <input type=text name=id size=5> <input type=submit value=OK></td></tr>rntt</table>rntt</form>rnttrntt</td>rntt<td width=20></td>rntt<td>rnrntt<form method=post>rntt<input type=hidden name=do value=profile>rntt<table>rntt<tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Профайл клиента</b></td></tr>rntt<tr><td bgcolor=";
echo $font_row;
echo ">ID/Логин клиента <input type=text name=id size=5> <input type=submit value=OK></td></tr>rntt</table>rntt</form>rnttrntt</td>rntt<td width=20></td>rntt<td>rnrntt<form method=post>rntt<input type=hidden name=do value=history>rntt<table>rntt<tr><td align=center bgcolor=";
echo $font_head;
echo "><B>История клиента</b></td></tr>rntt<tr><td bgcolor=";
echo $font_row;
echo ">ID/Логин клиента <input type=text name=uid size=5> <input type=submit value=OK></td></tr>rntt</table>rntt</form>rnttrntt</td>rntt</tr>rntt</table><BR><BR>rnttrnrnttrntt<table border=0>rntt<tr>rntt<td>rnttrntt<form method=post>rntt<input type=hidden name=do value=orders>rntt<input type=hidden name=show value=all>rntt<table>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Поиск по заказам</b></td></tr>rntt<tr><td bgcolor=";
echo $font_row;
echo ">";
echo "<s";
echo "elect name=param><option value=domain selected>Домен:</select> <input type=text name=search size=15> <input type=submit value=OK></td></tr>rntt</table>rntt</form>rnrntt</td>rntt<td width=20></td>rntt<td>rnrntt<form method=post>rntt<input type=hidden name=do value=domains>rntt<input type=hidden name=show value=all>rntt<table>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Поиск по доменам</b></td></tr>rntt<tr><td bgcolor=";
echo $font_row;
echo ">";
echo "<s";
echo "elect name=param><option value=domain selected>Домен:</select> <input type=text name=search size=15> <input type=submit value=OK></td></tr>rntt</table>rntt</form>rnttrntt</td>rntt<td width=20></td>rntt<td>rnttrntt<form method=post>rntt<input type=hidden name=do value=clients>rntt<table>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Поиск по клиентам</b></td></tr>rn <tr><td bgcolor=";
echo $font_row;
echo ">";
echo "<s";
echo "elect name=param><option value=id>ID:<option value=login selected>Логин:<option value=email>E-Mail:</select> <input type=text name=search size=15> <input type=submit value=OK></td></tr>rn </table>rn </form>rn rn </td>rntt</tr>rntt</table><BR><BR>ttrnrnttrnttrntt<table border=0>rntt<tr>rntt<td>rnrntt";
if ( !( $r = @mysql_query( "select SUM(money_host) as mhost, SUM(money_domain) as mdomain, SUM(money_addons) as maddons from bills where NOT(payed='0000-00-00') and status='1'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
$r = mysql_fetch_object( $r );
$mhost = round( $r->mhost, 2 );
$mdomain = round( $r->mdomain, 2 );
$maddons = round( $r->maddons, 2 );
}
if ( !$mhost )
{
$mhost = 0;
}
if ( !$mdomain )
{
$mdomain = 0;
}
if ( !$maddons )
{
$maddons = 0;
}
echo "tt<table>rntt<tr><td colspan=3 bgcolor=";
echo $font_head;
echo " align=center><B>Финансы (общая статистика)</b></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo ">rntt <td>rntttОплачено за хостинг:<BR>rntttОплачено за домены:<BR>rntttОплачено за доп. услуги:<BR>rntttОплачено всего:rntt </td>rntt <td width=5></td>rntt <td>rnttt";
echo $mhost;
echo "$<BR>rnttt";
echo $mdomain;
echo "$<BR>rnttt";
echo $maddons;
echo "$<BR>rnttt<B>";
echo $mhost + $mdomain + $maddons;
echo "$</b>rntt </td>rntt</tr>rntt</table>rnttrntt</td>rntt<td width=20></td>rntt<td>rnrntt";
$mhost = "";
$mdomain = "";
$maddons = "";
$thisMonthFirstDayDate = date( "Y-m" )."-01";
if ( !( $r = @mysql_query( @"select SUM(money_host) as mhost, SUM(money_domain) as mdomain, SUM(money_addons) as maddons from bills where NOT(payed='0000-00-00') and status='1' and payed >= DATE_SUB('{$thisMonthFirstDayDate}', INTERVAL 1 MONTH) and payed < '{$thisMonthFirstDayDate}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
$r = mysql_fetch_object( $r );
$mhost = round( $r->mhost, 2 );
$mdomain = round( $r->mdomain, 2 );
$maddons = round( $r->maddons, 2 );
}
if ( !$mhost )
{
$mhost = 0;
}
if ( !$mdomain )
{
$mdomain = 0;
}
if ( !$maddons )
{
$maddons = 0;
}
echo "tt<table>rntt<tr><td colspan=3 bgcolor=";
echo $font_head;
echo " align=center><B>Финансы (предыдущий месяц)</b></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo ">rntt <td>rntttОплачено за хостинг:<BR>rntttОплачено за домены:<BR>rntttОплачено за доп. услуги:<BR>rntttОплачено всего:rntt </td>rntt <td width=5></td>rntt <td>rnttt";
echo $mhost;
echo "$<BR>rnttt";
echo $mdomain;
echo "$<BR>rnttt";
echo $maddons;
echo "$<BR>rnttt<B>";
echo $mhost + $mdomain + $maddons;
echo "$</b>rntt </td>rntt</tr>rntt</table>rnrntt</td>rntt<td width=20></td>rntt<td>rnrntt";
$mhost = "";
$mdomain = "";
$maddons = "";
$thisMonthFirstDayDate = date( "Y-m" )."-01";
if ( !( $r = @mysql_query( @"select SUM(money_host) as mhost, SUM(money_domain) as mdomain, SUM(money_addons) as maddons from bills where NOT(payed='0000-00-00') and status='1' and payed >= '{$thisMonthFirstDayDate}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
$r = mysql_fetch_object( $r );
$mhost = round( $r->mhost, 2 );
$mdomain = round( $r->mdomain, 2 );
$maddons = round( $r->maddons, 2 );
}
if ( !$mhost )
{
$mhost = 0;
}
if ( !$mdomain )
{
$mdomain = 0;
}
if ( !$maddons )
{
$maddons = 0;
}
echo "tt<table>rntt<tr><td colspan=3 bgcolor=";
echo $font_head;
echo " align=center><B>Финансы (текущий месяц)</b></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo ">rntt <td>rntttОплачено за хостинг:<BR>rntttОплачено за домены:<BR>rntttОплачено за доп. услуги:<BR>rntttОплачено всего:rntt </td>rntt <td width=5></td>rntt <td>rnttt";
echo $mhost;
echo "$<BR>rnttt";
echo $mdomain;
echo "$<BR>rnttt";
echo $maddons;
echo "$<BR>rnttt<B>";
echo $mhost + $mdomain + $maddons;
echo "$</b>rntt </td>rntt</tr>rntt</table>rnttrn </td>rntt</tr>rntt</table><BR><BR>ttrnrntt";
}
if ( $do == "zones" )
{
print "[ <B><A href=?do={$do}&sub=list>текущие доменные зоны</a></B> - <B><A href=?do={$do}&sub=add>добавить доменную зону</a></B> ]<BR><BR>";
if ( !$sub )
{
$sub = "list";
}
if ( $sub == "add2" || $sub == "edit2" )
{
if ( $sub == "add2" )
{
$sub2 = "add";
}
if ( $sub == "edit2" )
{
$sub2 = "edit";
}
if ( !$zone )
{
print "Не указана доменная зона.";
}
else if ( eregi( "^\.", $zone ) )
{
print "Доменная зона не должна начинаться с точки.";
}
else if ( $minsrok != 12 && $minsrok != 24 )
{
print "Минимальный срок регистрации должен составлять 12 или 24 месяцев.";
}
else if ( $minsrok_renew != 12 && $minsrok_renew != 24 )
{
print "Минимальный срок продления должен составлять 12 или 24 месяцев.";
}
else if ( $cost_if_not_host == "" )
{
print "Не указана цена регистрации.";
}
else if ( $cost_if_host == "" )
{
print "Не указана цена регистрации при покупке хостинга.";
}
else if ( $renew_if_not_host == "" )
{
print "Не указана цена продления.";
}
else if ( $renew_if_host == "" )
{
print "Не указана цена продления при продлении хостинга.";
}
else if ( $sub == "add2" )
{
if ( !( $r = @mysql_query( @"select * from zones where zone='{$zone}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
print "Доменная зона <B>{$zone}</b> уже присутствует в базе.";
}
else
{
$domain = new domain( "test.".$zone );
$whois = $domain->get_whois_server( );
$notFoundString = $domain->get_notfound_string( );
if ( !@mysql_query( @"insert into zones (zone,cost_if_host,cost_if_not_host,renew_if_host,renew_if_not_host,minsrok,minsrok_renew,active,comment,whois,notfoundstring,useinwhois) values('{$zone}','{$cost_if_host}','{$cost_if_not_host}','{$renew_if_host}','{$renew_if_not_host}','{$minsrok}','{$minsrok_renew}','{$active}','{$comment}','{$whois}','{$notFoundString}','{$useInWhois}')" ) )
{
exit( mysql_error( ) );
}
print "Доменная зона <B>{$zone}</b> успешно добавлена.";
$sub2 = "";
}
}
else if ( $sub == "edit2" )
{
if ( $id )
{
if ( !@mysql_query( @"update zones set cost_if_host='{$cost_if_host}',cost_if_not_host='{$cost_if_not_host}',renew_if_host='{$renew_if_host}',renew_if_not_host='{$renew_if_not_host}',minsrok='{$minsrok}',minsrok_renew='{$minsrok_renew}',active='{$active}',comment='{$comment}',whois='{$whois}',notfoundstring='{$notFoundString}',useinwhois='{$useInWhois}' where id={$id}" ) )
{
exit( mysql_error( ) );
}
print "Доменная зона <B>{$zone}</b> успешно изменена.";
$sub2 = "";
}
else
{
print "Утерян идентификатор зоны.";
$sub2 = "";
}
}
if ( $sub2 )
{
print "<BR><BR>";
$sub = $sub2;
}
else
{
$sub = "";
}
}
if ( $sub == "delete" )
{
if ( $id )
{
if ( iszoneinuse( $id ) )
{
print "Вы не можете удалить доменную зону <B>{$zone}</b>, т.к. она используется в заказах. Вы можете сделать зону не активной.";
}
else
{
if ( !@mysql_query( @"delete from zones where id='{$id}'" ) )
{
exit( mysql_error( ) );
}
print "Доменна зона <B>{$zone}</b> успешно удалена.";
}
}
else
{
print "Утерян идентификатор.";
}
print "<BR><BR>";
$sub = "list";
}
if ( $sub == "add" || $sub == "edit" )
{
$button = "Добавить";
$title = "Добавление";
if ( $sub == "edit" )
{
if ( !( $r = @mysql_query( @"select * from zones where id={$id}" ) ) )
{
exit( mysql_error( ) );
}
$r = mysql_fetch_object( $r );
$zone = $r->zone;
$cost_if_host = $r->cost_if_host;
$cost_if_not_host = $r->cost_if_not_host;
$renew_if_host = $r->renew_if_host;
$renew_if_not_host = $r->renew_if_not_host;
$minsrok = $r->minsrok;
$minsrok_renew = $r->minsrok_renew;
$active = $r->active;
$comment = $r->comment;
$whois = $r->whois;
$notFoundString = $r->notfoundstring;
$useInWhois = $r->useinwhois;
$button = "Изменить";
$title = "Редактирование";
$readonly = "readonly";
}
echo " <form method=post>rn <input type=hidden name=do value=";
echo $do;
echo ">rn <input type=hidden name=sub value=";
echo $sub;
echo "2>rn <input type=hidden name=id value=";
echo $id;
echo ">rn <table>rn <tr><td colspan=2 align=center bgcolor=#EAEAEA><B>";
echo $title;
echo " доменной зоны</b></td></tr>rn <tr bgcolor=";
echo $font_row1;
echo "><td>Доменная зона:</td><td><input type=text size=15 name=zone value=";
echo $zone;
echo " ";
echo $readonly;
echo "> без точки в начале (ru, net.ru, com)</td></tr>rn <tr><td>Минимальный срок регистрации:</td><td><input type=text size=5 name=minsrok value=";
echo $minsrok;
echo "> в месяцах (12, 24)</td></tr>rn <tr><td>Минимальный срок продления:</td><td><input type=text size=5 name=minsrok_renew value=";
echo $minsrok_renew;
echo "> в месяцах (12, 24)</td></tr>rn <tr><td>Цена регистрации:</td><td><input type=text size=5 name=cost_if_not_host value=";
echo $cost_if_not_host;
echo "> $, за год</td></tr>rn <tr><td>Цена регистрации при покупке хостинга:</td><td><input type=text size=5 name=cost_if_host value=";
echo $cost_if_host;
echo "> $, за год</td></tr>rn <tr><td>Цена продления:</td><td><input type=text size=5 name=renew_if_not_host value=";
echo $renew_if_not_host;
echo "> $, за год</td></tr>rn <tr><td>Цена продления при продлении хостинга:</td><td><input type=text size=5 name=renew_if_host value=";
echo $renew_if_host;
echo "> $, за год</td></tr>rn <tr><td>Зона активна:</td><td><input type=checkbox name=active ";
if ( $active )
{
print "checked";
}
echo " value=1> клиент может заказать домен только в активной зоне</td></tr>rn <tr><td>Зона используется в whois:</td><td><input type=checkbox name=useInWhois ";
if ( $useInWhois )
{
print "checked";
}
echo " value=1> отметить, если нужно отображать зону на whois-странице</td></tr>rn <tr><td><BR>Комментарий:</td><td><BR><input type=text size=60 name=comment value=";
echo $comment;
echo "></td></tr>rn ";
if ( $sub == "edit" )
{
echo " <tr><td><BR>WHOIS-сервер:</td><td><BR><input type=text size=25 name=whois value=";
echo $whois;
echo "></td></tr>rn <tr><td>Строка Not Found:</td><td><input type=text size=25 name=notFoundString value="";
echo $notFoundString;
echo ""> часть ответа сервера, если домен не найден</td></tr>rntttt";
}
echo " <tr><Td colspan=2 align=center><BR><input type=submit value=";
echo $button;
echo "></td></tr>rn </table>rn </form>rn ";
}
if ( $sub == "list" )
{
if ( !( $r = @mysql_query( "select * from zones order by zone" ) ) )
{
exit( mysql_error( ) );
}
echo " <table cellpadding=3 width=95%>rn <tr><td colspan=8 align=center bgcolor=";
echo $font_head;
echo "><B>Доменные зоны</b></td></tr>rn <tr bgcolor=";
echo $font_head;
echo "><td align=center>зона</td><td align=center>регистрация<BR>(продление), $</td><td align=center>регистрация (продление), $<BR>при покупке хостинга</td><Td align=center>минимальный срок<BR>регистрации (продления)</td><Td align=center>активность</td><Td align=center>whois</td><Td align=center>комментарий</td><td></td></tr>rn ";
$cnt = 0;
while ( $rr = mysql_fetch_object( $r ) )
{
getfont( );
print "rn <tr bgcolor={$font_row}>rn <td>{$rr->zone}</td>rn <td align=center>{$rr->cost_if_not_host} ({$rr->renew_if_not_host})</td>rn <Td align=center>{$rr->cost_if_host} ({$rr->renew_if_host})</td>rn <td align=center>{$rr->minsrok} ({$rr->minsrok_renew})</td>rn <td align=center>".$_yes[$rr->active]."</td>rn <td align=center>".$_yes[$rr->useinwhois]."</td>rn <td>{$rr->comment}</td>rn <Td align=center><A href=?do={$do}&sub=edit&id={$rr->id}><img src=./_rootimages/edit.gif alt=Изменить title=Изменить border=0></a><A href=?do={$do}&sub=delete&id={$rr->id}&zone={$rr->zone} onclick="javascript: return confirm('Вы уверены, что хотите удалить доменную зону?');"><img src=./_rootimages/del.gif alt=Удалить title=Удалить border=0></a></td>rn </tr>";
++$cnt;
}
echo " <tr bgcolor=";
echo $font_head;
echo "><Td colspan=8>Всего доменных зон: ";
echo $cnt;
echo "</td></tr>rn </table>rn ";
}
}
if ( $do == "tarifs" )
{
print "[ <B><A href=?do={$do}&sub=list>текущие тарифные планы</a></B> - <B><A href=?do={$do}&sub=add>добавить тарифный план</a></B> ]<BR><BR>";
if ( !$sub )
{
$sub = "list";
}
if ( $sub == "add2" || $sub == "edit2" )
{
if ( $sub == "add2" )
{
$sub2 = "add";
}
if ( $sub == "edit2" )
{
$sub2 = "edit";
}
if ( !$name )
{
print "Не указано название тарифного плана.";
}
else if ( !$vid )
{
print "Не указан тип тарифного плана.";
}
else if ( $cost == "" )
{
print "Не указана цена тарифного плана.";
}
else if ( $cost_setup == "" )
{
print "Не указана цена установки.";
}
else if ( $sub == "add2" )
{
if ( !( $r = @mysql_query( @"select * from tarifs where name='{$name}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
print "Тарифный план <B>{$name}</b> уже присутствует в базе.";
}
else
{
if ( !@mysql_query( @"insert into tarifs (name,vid,cost,cost_setup,active,daname,cpanelname,autocreate,autodelete,autosuspend,autocreatecpanel,autodeletecpanel,autosuspendcpanel,quota,cgi,shell,frontpage,ftp,email,emaillists,sql,subdomains,parkdomains,addondomains,bandwidth,theme) values('{$name}','{$vid}','{$cost}','{$cost_setup}','{$active}','{$daname}','{$cpanelname}','{$autocreate}','{$autodelete}','{$autosuspend}','{$autocreatecpanel}','{$autodeletecpanel}','{$autosuspendcpanel}','{$quota}','{$cgi}','{$shell}','{$frontpage}','{$ftp}','{$email}','{$emaillists}','{$sql}','{$subdomains}','{$parkdomains}','{$addondomains}','{$bandwidth}','{$theme}')" ) )
{
exit( mysql_error( ) );
}
$id = mysql_insert_id( );
print "Тарифный план <B>{$name}</b> успешно добавлен.<BR>Вам необходимо указать <A href=?do={$do}&sub=sroki&id={$id}>доступные сроки заказа тарифного плана</a>.";
$sub2 = "";
}
}
else if ( $sub == "edit2" )
{
if ( $id )
{
if ( !@mysql_query( @"update tarifs set name='{$name}',vid='{$vid}',cost='{$cost}',cost_setup='{$cost_setup}',active='{$active}',daname='{$daname}',cpanelname='{$cpanelname}',autocreate='{$autocreate}',autodelete='{$autodelete}',autosuspend='{$autosuspend}',autocreatecpanel='{$autocreatecpanel}',autodeletecpanel='{$autodeletecpanel}',autosuspendcpanel='{$autosuspendcpanel}',quota='{$quota}',cgi='{$cgi}',shell='{$shell}',frontpage='{$frontpage}',ftp='{$ftp}',email='{$email}',emaillists='{$emaillists}',sql='{$sql}',subdomains='{$subdomains}',parkdomains='{$parkdomains}',addondomains='{$addondomains}',bandwidth='{$bandwidth}',theme='{$theme}' where id={$id}" ) )
{
exit( mysql_error( ) );
}
print "Тарифный план <B>{$name}</b> успешно изменен.";
$sub2 = "";
}
else
{
print "Утерян идентификатор тарифного плана.";
$sub2 = "";
}
}
if ( $sub2 )
{
print "<BR><BR>";
$sub = $sub2;
}
else
{
$sub = "";
}
}
if ( $sub == "add" || $sub == "edit" )
{
if ( $sub == "edit" )
{
if ( !( $r = @mysql_query( @"select * from tarifs where id={$id}" ) ) )
{
exit( mysql_error( ) );
}
$r = mysql_fetch_object( $r );
$vid = $r->vid;
$name = $r->name;
$cost = $r->cost;
$cost_setup = $r->cost_setup;
$active = $r->active;
$daname = $r->daname;
$autocreate = $r->autocreate;
$autodelete = $r->autodelete;
$autosuspend = $r->autosuspend;
$autocreatecpanel = $r->autocreatecpanel;
$autodeletecpanel = $r->autodeletecpanel;
$autosuspendcpanel = $r->autosuspendcpanel;
$cpanelname = $r->cpanelname;
$quota = $r->quota;
$cgi = $r->cgi;
$shell = $r->shell;
$frontpage = $r->frontpage;
$ftp = $r->ftp;
$email = $r->email;
$emaillists = $r->emaillists;
$sql = $r->sql;
$subdomains = $r->subdomains;
$parkdomains = $r->parkdomains;
$addondomains = $r->addondomains;
$bandwidth = $r->bandwidth;
$theme = $r->theme;
$button = "Изменить";
}
else
{
$quota = "100";
$cgi = "1";
$shell = "0";
$frontpage = "0";
$ftp = "unlimited";
$email = "unlimited";
$emaillists = "unlimited";
$sql = "unlimited";
$subdomains = "unlimited";
$parkdomains = "0";
$addondomains = "0";
$bandwidth = "1000";
$theme = "rvblue";
$button = "Добавить";
}
if ( $vid == "hosting" )
{
$type1 = "selected";
}
if ( $vid == "reseller" )
{
$type2 = "selected";
}
if ( $vid == "vds" )
{
$type3 = "selected";
}
if ( $vid == "dedicated" )
{
$type4 = "selected";
}
echo " <form method=post>rn <input type=hidden name=do value=";
echo $do;
echo ">rn <input type=hidden name=sub value=";
echo $sub;
echo "2>rn <input type=hidden name=id value=";
echo $id;
echo ">rn <table>rn <tr><td colspan=3 align=center bgcolor=#EAEAEA><B>Добавление тарифного плана</b></td></tr>rn <tr><td>Название:</td><td><input type=text size=15 name=name value="";
echo $name;
echo ""></td><td></td></tr>rn <tr><td>Тип тарифного плана:</td><td>";
echo "<s";
echo "elect name=vid><option><option value=hosting ";
echo $type1;
echo ">Хостинг<option value=reseller ";
echo $type2;
echo ">Реселлинг<option value=vds ";
echo $type3;
echo ">Виртуальный выделенный сервер<option value=dedicated ";
echo $type4;
echo ">Выделенный сервер</select></td><td></td></tr>rn <tr><td>Цена, $:</td><td><input type=text size=5 name=cost value=";
echo $cost;
echo "></td><td>за месяц</td></tr>rn <tr><td>Цена установки, $:</td><td><input type=text size=5 name=cost_setup value=";
echo $cost_setup;
echo "></td><td>разово</td></tr>rn <tr><td>Тариф активен:</td><td><input type=checkbox name=active ";
if ( $active )
{
print "checked";
}
echo " value=1></td><td>клиент может заказать только активный тариф</td></tr>rn <tr><td colspan=3 align=center bgcolor=#EAEAEA><B>Интеграция с DirectAdmin</b></td></tr>rn <tr><td>Название в DA:</td><td><input type=text size=15 name=daname value="";
echo $daname;
echo ""></td><td>название тарифного плана в DirectAdmin</td></tr>rn <tr><td>Автосоздание в DA:</td><td><input type=checkbox onclick="javascript: this.form.autocreatecpanel.checked=false" name=autocreate ";
if ( $autocreate )
{
print "checked";
}
echo " value=1></td><td>автоматически создавать аккаунты в DirectAdmin для этого тарифного плана</td></tr>rn <tr><td>Автоудаление в DA:</td><td><input type=checkbox name=autodelete ";
if ( $autodelete )
{
print "checked";
}
echo " value=1></td><td>автоматически удалять аккаунты в DirectAdmin для этого тарифного плана</td></tr>rn <tr><td>Автосуспенд в DA:</td><td><input type=checkbox name=autosuspend ";
if ( $autosuspend )
{
print "checked";
}
echo " value=1></td><td>автоматически останавливать аккаунты в DirectAdmin для этого тарифного плана</td></tr>rntttt<tr><td colspan=3 align=center bgcolor=#EAEAEA><B>Интеграция с cPanel</b></td></tr>rn <tr><td>Автосоздание в cPanel:</td><td><input type=checkbox onclick="javascript: this.form.autocreate.checked=false" name=autocreatecpanel ";
if ( $autocreatecpanel )
{
print "checked";
}
echo " value=1></td><td>автоматически создавать аккаунты в cPanel для этого тарифного плана</td></tr>rn <tr><td>Автоудаление в cPanel:</td><td><input type=checkbox name=autodeletecpanel ";
if ( $autodeletecpanel )
{
print "checked";
}
echo " value=1></td><td>автоматически удалять аккаунты в cPanel для этого тарифного плана</td></tr>rn <tr><td>Автосуспенд в cPanel:</td><td><input type=checkbox name=autosuspendcpanel ";
if ( $autosuspendcpanel )
{
print "checked";
}
echo " value=1></td><td>автоматически останавливать аккаунты в cPanel для этого тарифного плана</td></tr>rn <tr><td>Название в cPanel:</td><td><input type=text size=15 name=cpanelname value="";
echo $cpanelname;
echo ""></td><td>название тарифного плана в cPanel</td></tr>rn <tr><td>Quota (MB):</td><td><input type=text size=15 name=quota value="";
echo $quota;
echo ""></td><td></td></tr>rntttt<tr><td>Bandwidth Limit (MB):</td><td><input type=text size=15 name=bandwidth value="";
echo $bandwidth;
echo ""></td><td></td></tr>rntttt<tr><td>CGI access:</td><td><input type=checkbox name=cgi ";
if ( $cgi )
{
print "checked";
}
echo " value=1></td><td></td></tr>rn <tr><td>Shell access:</td><td><input type=checkbox name=shell ";
if ( $shell )
{
print "checked";
}
echo " value=1></td><td></td></tr>rn <tr><td>Frontpage Extentions:</td><td><input type=checkbox name=frontpage ";
if ( $frontpage )
{
print "checked";
}
echo " value=1></td><td></td></tr>rntttt<tr><td>Max Ftp Accounts:</td><td><input type=text size=15 name=ftp value="";
echo $ftp;
echo ""></td><td></td></tr>rntttt<tr><td>Max Email Accounts:</td><td><input type=text size=15 name=email value="";
echo $email;
echo ""></td><td></td></tr>rntttt<tr><td>Max Email Lists:</td><td><input type=text size=15 name=emaillists value="";
echo $emaillists;
echo ""></td><td></td></tr>rntttt<tr><td>Max SQL Databases:</td><td><input type=text size=15 name=sql value="";
echo $sql;
echo ""></td><td></td></tr>rntttt<tr><td>Max Sub Domains:</td><td><input type=text size=15 name=subdomains value="";
echo $subdomains;
echo ""></td><td></td></tr>rntttt<tr><td>Max Park Domains:</td><td><input type=text size=15 name=parkdomains value="";
echo $parkdomains;
echo ""></td><td></td></tr>rntttt<tr><td>Max Addon Domains:</td><td><input type=text size=15 name=addondomains value="";
echo $addondomains;
echo ""></td><td></td></tr>rntttt<tr><td>cPanel Theme:</td><td><input type=text size=15 name=theme value="";
echo $theme;
echo ""></td><td></td></tr>rn <tr><Td colspan=3 align=center><BR><input type=submit value=";
echo $button;
echo "></td></tr>rn </table>rn </form>rn ";
}
if ( $sub == "delete" )
{
if ( $id )
{
if ( istarifinuse( $id ) )
{
print "Вы не можете удалить тарифный план <B>{$name}</b>, т.к. он используется в заказах.<BR>Вы можете сделать тарифный план не активным.";
}
else
{
if ( !@mysql_query( @"delete from tarifs where id={$id}" ) )
{
exit( mysql_error( ) );
}
print "Тарифный план <B>{$name}</b> успешно удален.";
}
}
else
{
print "Утерян идентификатор.";
}
print "<BR><BR>";
$sub = "list";
}
if ( $sub == "deletesrok" )
{
if ( $id )
{
if ( !@mysql_query( @"delete from tarifs_sroki where id={$id}" ) )
{
exit( mysql_error( ) );
}
print "Срок для тарифного плана <B>{$name}</b> успешно удален.";
}
else
{
print "Утерян идентификатор.";
}
print "<BR><BR>";
$sub = sroki;
$id = $tarif_id;
}
if ( $sub == "addsrok" )
{
if ( !$months )
{
print "Не указан срок заказа.";
if ( !( $r = @mysql_query( @"select * from tarifs_sroki where months='{$months}' and tarif_id='{$id}'" ) ) )
{
exit( mysql_error( ) );
}
}
else if ( 0 < mysql_num_rows( $r ) )
{
print "Срок заказа для данного тарифного плана уже присутствует в базе.";
}
else
{
if ( !@mysql_query( @"insert into tarifs_sroki (tarif_id,months,discount) values('{$id}','{$months}','{$discount}')" ) )
{
exit( mysql_error( ) );
}
print "Срок заказа успешно добавлен.";
$months = "";
$discount = "";
}
print "<BR><BR>";
$sub = "sroki";
}
if ( $sub == "sroki" )
{
if ( !( $k = @mysql_query( @"select name from tarifs where id={$id}" ) ) )
{
exit( mysql_error( ) );
}
$k = mysql_fetch_object( $k );
if ( !( $r = @mysql_query( @"select * from tarifs_sroki where tarif_id={$id} order by months" ) ) )
{
exit( mysql_error( ) );
}
echo " <table cellpadding=3>rn <tr><td colspan=4 align=center bgcolor=";
echo $font_head;
echo "><B>Доступные сроки заказа тарифного плана ";
echo $k->name;
echo "</b></td></tr>rn <tr bgcolor=";
echo $font_head;
echo "><td align=center>срок, месяцев</td><td align=center>скидка, %</td><td></td></tr>rn ";
$cnt = 0;
while ( $rr = mysql_fetch_object( $r ) )
{
getfont( );
print "rn <tr bgcolor={$font_row}>rn <td align=center>{$rr->months}</td>rn <td align=center>{$rr->discount}</td>rn <Td align=center><A href=?do={$do}&sub=deletesrok&id={$rr->id}&tarif_id={$rr->tarif_id}&name={$k->name} onclick="javascript: return confirm('Вы уверены, что хотите удалить срок для тарифного плана?');"><img src=./_rootimages/del.gif alt=Удалить title=Удалить border=0></a></td>rn </tr>";
++$cnt;
}
echo " <tr bgcolor=";
echo $font_head;
echo "><Td colspan=8>Всего доступных сроков заказа: ";
echo $cnt;
echo "</td></tr>rn </table><BR><BR>rnrn <form method=post>rn <input type=hidden name=do value=";
echo $do;
echo ">rn <input type=hidden name=sub value=addsrok>rn <input type=hidden name=id value=";
echo $id;
echo ">rn <table>rn <tr><td colspan=3 align=center bgcolor=#EAEAEA><B>Добавление срока зказа для тарифного плана ";
echo $k->name;
echo "</b></td></tr>rn <tr><td>Срок заказа:</td><td><input type=text size=5 name=months value=";
echo $months;
echo "></td><td>в месяцах</td></tr>rn <tr><td>Скидка:</td><td><input type=text size=5 name=discount value=";
echo $discount;
echo "></td><td>скидка в % при заказе на данный срок</td></tr>rn <tr><Td colspan=3 align=center><BR><input type=submit value=Добавить></td></tr>rn </table>rn </form>rnrnrn ";
}
if ( $sub == "deletefreedomain" )
{
if ( $id && $tarif_id )
{
if ( !@mysql_query( @"delete from tarifs_freedomains where id={$id}" ) )
{
exit( mysql_error( ) );
}
print "Бесплатная доменная зона для данного тарифного плана успешно удалена.";
}
else
{
print "Утерян идентификатор.";
}
print "<BR><BR>";
$sub = "freedomains";
$tarif_id = $tarif_id;
}
if ( $sub == "addfreedomain" )
{
if ( !$zone )
{
print "Не указана доменная зона.";
}
else
{
if ( count( $hostmonths ) == 0 )
{
print "Не указаны сроки заказа тарифного плана при котором домен в зоне <B>{$zone}</b> будет бесплатным.";
}
else
{
$hostmonth = each( $hostmonths )[1];
$k = each( $hostmonths )[0];
while ( each( $hostmonths ) )
{
if ( !( $r = @mysql_query( @"select * from tarifs_freedomains where (hostmonths='{$hostmonth}' and zone='{$zone}' and tarif_id='{$tarif_id}')" ) ) )
{
exit( mysql_error( ) );
}
if ( mysql_num_rows( $r ) == 0 )
{
if ( !@mysql_query( @"insert into tarifs_freedomains (tarif_id,hostmonths,zone) values('{$tarif_id}','{$hostmonth}','{$zone}')" ) )
{
exit( mysql_error( ) );
}
print "Доменная зона <B>{$zone}</b> успешно сделана бесплатной при заказе данного тарифного плана на {$hostmonth} мес.<BR>";
}
}
$zone = "";
$hostmonths = "";
}
}
$sub = "freedomains";
print "<BR><BR>";
}
if ( $sub == "freedomains" )
{
if ( !( $k = @mysql_query( @"select name from tarifs where id='{$tarif_id}'" ) ) )
{
exit( mysql_error( ) );
}
$k = mysql_fetch_object( $k );
if ( !( $r = @mysql_query( @"select * from tarifs_freedomains where tarif_id='{$tarif_id}' order by zone,hostmonths" ) ) )
{
exit( mysql_error( ) );
}
echo " <table cellpadding=3>rn <tr><td colspan=3 align=center bgcolor=";
echo $font_head;
echo "><B>Бесплатные доменные зоны для тарифного плана ";
echo $k->name;
echo "</b></td></tr>rn <tr bgcolor=";
echo $font_head;
echo "><td align=center>доменная зона</td><td align=center>срок заказа<BR>тарифного плана, месяцев</td><td></td></tr>rn ";
$cnt = 0;
while ( $rr = mysql_fetch_object( $r ) )
{
getfont( );
print "rn <tr bgcolor={$font_row}>rn <td>{$rr->zone}</td>rn <td align=center>{$rr->hostmonths}</td>rn <Td><A href=?do={$do}&sub=deletefreedomain&id={$rr->id}&tarif_id={$tarif_id} onclick="javascript: return confirm('Вы уверены, что хотите удалить бесплатную доменную зону для тарифного плана?');"><img src=./_rootimages/del.gif alt=Удалить title=Удалить border=0></a></td>rn </tr>rn ";
++$cnt;
}
echo " <tr bgcolor=";
echo $font_head;
echo "><Td colspan=8>Всего записей: ";
echo $cnt;
echo "</td></tr>rn </table><BR><BR>rn ";
echo " <form method=post>rn <input type=hidden name=do value=";
echo $do;
echo ">rn <input type=hidden name=sub value=addfreedomain>rn <input type=hidden name=tarif_id value=";
echo $tarif_id;
echo ">rn <table>rn <tr><td colspan=3 align=center bgcolor=#EAEAEA><B>Добавить бесплатную доменную зону</b></td></tr>rn <tr><td>Сроки заказа:</td><td>";
echo "<s";
echo "elect name=hostmonths[] multiple="multiple">rn ";
if ( !( $r = mysql_query( "select months from tarifs_sroki where tarif_id='{$tarif_id}' order by months" ) ) )
{
exit( mysql_error( ) );
}
while ( $rr = mysql_fetch_object( $r ) )
{
if ( $rr->months == $hostmonths )
{
$addon = "selected";
}
else
{
$addon = "";
}
print "<option value='{$rr->months}' {$addon}>{$rr->months}";
}
echo " </td><td rowspan=2 valign=middle>домен в указанной зоне будет бесплатным при заказе данного<BR> тарифного плана на указанные сроки в месяцах</td></tr>rn <tr><td>Доменная зона:</td><td>";
echo "<s";
echo "elect name=zone><option>rn ";
if ( !( $r = mysql_query( "select zone from zones 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 " </td></tr>rn <tr><Td colspan=3 align=center><BR><input type=submit value=Добавить></td></tr>rn </table>rn </form>rn ";
}
if ( $sub == "saveaddons" )
{
if ( $tarif_id )
{
$addons = "";
@$v = @each( @$checkedaddons )[1];
@$k = @each( @$checkedaddons )[0];
while ( @each( @$checkedaddons ) )
{
if ( $v )
{
$addons = "{$addons}:x:{$v}";
}
}
if ( !@mysql_query( @"update tarifs set addons='{$addons}' where id='{$tarif_id}'" ) )
{
exit( mysql_error( ) );
}
print "Доступные дополнительные услуги успешно обновлены.<BR><BR>";
}
$sub = "addons";
}
if ( $sub == "addons" )
{
if ( !( $r = @mysql_query( @"select * from tarifs where id='{$tarif_id}'" ) ) )
{
exit( mysql_error( ) );
}
$r = mysql_fetch_object( $r );
$alladdons = split( ":x:", $r->addons );
echo " <form method=post>rn <input type=hidden name=do value=";
echo $do;
echo ">rn <input type=hidden name=sub value=saveaddons>rn <input type=hidden name=tarif_id value=";
echo $tarif_id;
echo ">rn <table cellpadding=3 width=400>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Доступные дополнительные услуги для тарифного плана ";
echo $r->name;
echo "</b></td></tr>rn ";
if ( !( $q = @mysql_query( "select * from addons order by textid" ) ) )
{
exit( mysql_error( ) );
}
while ( $qq = mysql_fetch_object( $q ) )
{
getfont( );
if ( in_array( $qq->id, $alladdons ) )
{
$checked = "checked";
}
else
{
$checked = "";
}
print "<tr bgcolor={$font_row}><td><input type=checkbox name=checkedaddons[] value={$qq->id} {$checked}> {$qq->name} ({$qq->textid})</td></tr>";
}
echo " <tr bgcolor=";
echo $font_head;
echo "><td align=center><input type=submit value=Сохранить></td></tr>rn </table>rn </form><BR><BR>rn ";
}
if ( $sub == "list" )
{
if ( !( $r = @mysql_query( "select * from tarifs order by vid,cost" ) ) )
{
exit( mysql_error( ) );
}
echo " <table cellpadding=3 width=95%>rn <tr><td colspan=8 align=center bgcolor=";
echo $font_head;
echo "><B>Тарифные планы</b></td></tr>rn <tr bgcolor=";
echo $font_head;
echo "><td align=center>название</td><td align=center>тип</td><td align=center>цена, $</td><Td align=center>доступные сроки заказа</td><Td align=center>доступные доп. услуги</td><Td align=center>бесплатные домены</td><Td align=center>активность</td><td></td></tr>rn ";
$cnt = 0;
while ( $rr = mysql_fetch_object( $r ) )
{
getfont( );
print "rn <tr bgcolor={$font_row}>rn <td>{$rr->name}</td>rn <td align=center>{$rr->vid}</td>rn <Td align=center>{$rr->cost}</td>rn <td align=center><A href=?do={$do}&sub=sroki&id={$rr->id}>настроить</a></td>rn <td align=center><A href=?do={$do}&sub=addons&tarif_id={$rr->id}>настроить</a></td>rn <td align=center><A href=?do={$do}&sub=freedomains&tarif_id={$rr->id}>настроить</a></td>rn <td align=center>".$_yes[$rr->active]."</td>rn <Td align=center><A href=?do={$do}&sub=edit&id={$rr->id}><img src=./_rootimages/edit.gif alt=Изменить title=Изменить border=0></a><A href=?do={$do}&sub=delete&id={$rr->id}&name={$rr->name} onclick="javascript: return confirm('Вы уверены, что хотите удалить тарифный план?');"><img src=./_rootimages/del.gif alt=Удалить title=Удалить border=0></a></td>rn </tr>rn ";
++$cnt;
}
echo " <tr bgcolor=";
echo $font_head;
echo "><Td colspan=8>Всего тарифных планов: ";
echo $cnt;
echo "</td></tr>rn </table>rn ";
}
}
if ( $do == "clients" )
{
if ( $sub == "delete" && $uid )
{
if ( !( $orders = @mysql_query( @"select * from orders where uid='{$uid}'" ) ) )
{
exit( mysql_error( ) );
}
while ( $order = mysql_fetch_object( $orders ) )
{
if ( $order->dalogin )
{
$tarif = gettarifbyid( $order->tarif );
if ( $tarif->autodelete )
{
if ( dadeleteuser( $order->id ) )
{
print "Аккаунт <b>{$order->dalogin}</b> автоматически удален в DA.<BR>";
}
else
{
print "Аккаунт <b>{$order->dalogin}</b> не удален в DA ({$DAerror}).<BR>";
}
}
else
{
print "Аккаунт <b>{$order->dalogin}</b> не удалён в DA (эта возможность отключена для тарифного плана).<BR>";
}
}
else if ( $order->cpanellogin )
{
$tarif = gettarifbyid( $order->tarif );
if ( $tarif->autodeletecpanel )
{
if ( cpaneldeleteuser( $order->id ) )
{
print "Аккаунт <b>{$order->cpanellogin}</b> автоматически удален в cPanel.<BR>";
}
else
{
print "Аккаунт <b>{$order->cpanellogin}</b> не удален в cPanel ({$CPANELerror}).<BR>";
}
}
else
{
print "Аккаунт <b>{$order->cpanellogin}</b> не удалён в cPanel (эта возможность отключена для тарифного плана).<BR>";
}
}
else
{
print "Аккаунт для заказа <B>ID #{$order->id} ({$order->domain})</b> не был удалён в DA/cPanel (не указан логин в DA/cPanel).<BR>";
}
}
if ( !@mysql_query( @"delete from users where id='{$uid}'" ) )
{
exit( mysql_error( ) );
}
if ( !@mysql_query( @"delete from users_profile where uid='{$uid}'" ) )
{
exit( mysql_error( ) );
}
if ( !@mysql_query( @"delete from orders where uid='{$uid}'" ) )
{
exit( mysql_error( ) );
}
if ( !@mysql_query( @"delete from orders_domains where uid='{$uid}'" ) )
{
exit( mysql_error( ) );
}
if ( !@mysql_query( @"delete from bills where uid='{$uid}'" ) )
{
exit( mysql_error( ) );
}
if ( !@mysql_query( @"delete from users_logs where uid='{$uid}'" ) )
{
exit( mysql_error( ) );
}
print "Клиент, а так же все его заказы и счета успешно удалены.<BR><BR>";
}
if ( $search )
{
if ( $param == "id" )
{
$operat = "{$param} = '{$search}'";
}
else
{
$operat = "{$param} LIKE '%{$search}%'";
}
$addon = "where {$operat}";
}
if ( !( $r = @mysql_query( @"select * from users {$addon} order by id desc" ) ) )
{
exit( mysql_error( ) );
}
$rows = mysql_num_rows( $r );
$txt = makepages( $page, $rows )[2];
$perPage = makepages( $page, $rows )[1];
$start = makepages( $page, $rows )[0];
getfont( );
echo " <table>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Поиск</b></td></tr>rn <tr><td bgcolor=";
echo $font_row;
echo "><form method=post>";
echo "<s";
echo "elect name=param><option value=id>ID:<option value=login selected>Логин:<option value=email>E-Mail:</select> <input type=text name=search size=20> <input type=submit value=Найти></form></td></tr>rn </table><br>rnrn <table cellpadding=3 width=99%>rn <tr><td colspan=7 align=right>";
echo $txt;
echo "</td></tr>rn <tr><td colspan=7 align=center bgcolor=";
echo $font_head;
echo "><B>Клиенты</b></td></tr>rn <tr bgcolor=";
echo $font_head;
echo "><td></td><td align=center>ID</td><td align=center>Логин</td><td align=center>E-mail</td><td align=center>Зарегистрирован</td><td align=center>Подписка на новости</td><td align=center></td></tr>rn ";
if ( !( $r = @mysql_query( @"select * from users {$addon} order by id desc LIMIT {$start},{$perPage}" ) ) )
{
exit( mysql_error( ) );
}
$cnt = 0;
while ( $rr = mysql_fetch_object( $r ) )
{
getfont( );
getfont( );
$orders = mysql_query( "select * from orders where uid = {$rr->id}" );
$orders = mysql_num_rows( $orders );
$domains = mysql_query( "select * from orders_domains where uid = {$rr->id} and host_id = '0'" );
$domains = mysql_num_rows( $domains );
$bills = mysql_query( "select * from bills where uid = {$rr->id}" );
$bills = mysql_num_rows( $bills );
print "rn <tr bgcolor={$font_row}>rn <td align=center><a href=?do=profile&id={$rr->id}><img src=./_rootimages/profile.gif border=0 alt='Профайл' title='Редактировать профайл'></a><a href=?do={$do}&sub=delete&uid={$rr->id} onclick="javascript: return confirm('Будет удален клиент, а так же все заказы и счета, относящиесу к нему. Вы уверены, что хотите удалить клиента?');"><img src=./_rootimages/del.gif border=0 alt='Удалить клиента' title='Удалить клиента'></a></td>rn <td align=center>{$rr->id}</td>rn <td><A href=?do=fullinfo&id={$rr->id}>{$rr->login}</a></td>rn <td><a href=mailto:{$rr->email}>{$rr->email}</a></td>rn <td align=center>".mydate( $rr->datareg )."</td>rn <td align=center>".$_yes[$rr->news]."</td>rn <td align=center><a href=?do=bills¶m=uid&search={$rr->id}><img src=./_rootimages/bills.gif alt='Счета: {$bills}' title='Счета: {$bills}' border=0></a><a href=?do=orders¶m=uid&search={$rr->id}><img src=./_rootimages/orders.gif border=0 alt='Заказы: {$orders}' title='Заказы: {$orders}'></a><a href=?do=domains¶m=uid&search={$rr->id}><img src=./_rootimages/domain.gif border=0 alt='Домены: {$domains}' title='Домены: {$domains}'></a> <a href=?do=history&uid={$rr->id}><img src=./_rootimages/history.gif border=0 alt='История' title='История'></a></td>rn </tr>";
++$cnt;
}
echo " <tr bgcolor=";
echo $font_head;
echo "><td colspan=7>Всего клиентов: ";
echo $rows;
echo ", клиентов на странице: ";
echo $cnt;
echo "</td></tr>rn <tr><td colspan=7 align=right>";
echo $txt;
echo "</td></tr>rn </table>rn ";
}
if ( $do == "profile" )
{
$user = getuserbyid( $id );
if ( !$user )
{
$user = getuserbylogin( $id );
}
if ( $user )
{
print menu_admin_client( $user->id );
if ( $sub == "edit" )
{
if ( !@mysql_query( @"UPDATE users_profile SET icq='{$icq}',name='{$name}',otchestvo='{$otchestvo}',phone='{$phone}',country='{$country}',city='{$city}',post='{$post}',street='{$street}',pasport_seriya='{$seriya}',pasport_by='{$by}',ripn='{$ripn}',ripe='{$ripe}',uanic='{$uanic}',surname='{$surname}',pasport_date='".@frommydate( @$date )."',birthday='".@frommydate( @$birthday ).@"' WHERE uid='{$user->id}'" ) )
{
exit( mysql_error( ) );
}
if ( $passwd )
{
if ( !@mysql_query( @"UPDATE users SET password='".@crypt( @$passwd ).@"' WHERE id='{$user->id}'" ) )
{
exit( mysql_error( ) );
}
}
if ( $email || $news )
{
if ( $news )
{
$newstomysql = 1;
}
else
{
$newstomysql = 0;
}
$user->news = $newstomysql;
$user->email = $email;
if ( !@mysql_query( @"UPDATE users SET email='{$email}', news = '{$newstomysql}' WHERE id='{$user->id}'" ) )
{
exit( mysql_error( ) );
}
}
print "Профайл успешно изменен.<BR><BR>";
}
if ( !( $profile = mysql_query( "select * from users_profile where uid='{$user->id}'" ) ) )
{
exit( mysql_error( ) );
}
$profile = mysql_fetch_object( $profile );
if ( $user->news )
{
$newscheckbox = "checked";
}
else
{
$newscheckbox = "";
}
echo " <table border=0><form method=post>rn <tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Профайл клиента ";
echo $user->login;
echo "</b></td></tr>rn <input type=hidden name=do value=";
echo $do;
echo ">rn <input type=hidden name=sub value=edit>rn <input type=hidden name=id value=";
echo $user->id;
echo ">rn <tr><td>Фамилия:</td><td><input type=text name=surname value="";
echo $profile->surname;
echo "" size=40></td></tr>rn <tr><td>Имя:</td><td><input type=text name=name value="";
echo $profile->name;
echo "" size=40></td></tr>rn <tr><td>Отчество:</td><td><input type=text name=otchestvo value="";
echo $profile->otchestvo;
echo "" size=40></td></tr>rnrn <tr><td><BR>Страна:</td><td><BR><input type=text name=country value="";
echo $profile->country;
echo "" size=40></td></tr>rn <tr><td>Индекс:</td><td><input type=text name=post value="";
echo $profile->post;
echo "" size=40></td></tr>rn <tr><td>Город:</td><td><input type=text name=city value="";
echo $profile->city;
echo "" size=40></td></tr>rn <tr><td>Адрес:</td><td><input type=text name=street value="";
echo $profile->street;
echo "" size=40></td></tr>rn <tr><td>Телефон:</td><td><input type=text name=phone value="";
echo $profile->phone;
echo "" size=40></td></tr>rn <tr><td>E-mail:</td><td><input type=text name=email value="";
echo $user->email;
echo "" size=40></td></tr>rn <tr><td>Icq:</td><td><input type=text name=icq value="";
echo $profile->icq;
echo "" size=40></td></tr>rnrn <tr><td><BR>Паспорт:</td><td><BR><input type=text name=seriya value="";
echo $profile->pasport_seriya;
echo "" size=40></td></tr>rn <tr><td>Кем выдан:</td><td><input type=text name=by value="";
echo $profile->pasport_by;
echo "" size=40></td></tr>rn <tr><td>Дата выдачи:</td><td><input type=text name=date value="";
echo mydate( $profile->pasport_date );
echo "" size=40></td></tr>rn <tr><td>Дата рождения:</td><td><input type=text name=birthday value="";
echo mydate( $profile->birthday );
echo "" size=40></td></tr>rnrnrn <tr><td><BR>Пароль (изменить):</td><td><BR><input type=text name=passwd size=40></td></tr>rnrn <tr><td><BR>Подписка на новости:</td><td><BR><input type=checkbox ";
echo $newscheckbox;
echo " name=news size=40> да</td></tr>rn rn <tr><td colspan=2 align=center><BR><input type=Submit value=Изменить></td></tr></table><BR></form>rn ";
}
else
{
print "Клиент не найден.";
}
}
if ( $do == "domains" )
{
if ( $sub == "delete" && $id )
{
if ( !@mysql_query( @"delete from orders_domains where id='{$id}'" ) )
{
exit( mysql_error( ) );
}
if ( !@mysql_query( @"delete from bills where domain_id='{$id}'" ) )
{
exit( mysql_error( ) );
}
print "Домен и все счета, относящиеся к нему, успешно удалены.<BR><BR>";
}
$myShow = $_SESSION['domainShow'];
if ( !$myShow )
{
$myShow = "all";
}
if ( $show && $show != $myShow )
{
$myShow = $show;
$_SESSION['domainShow'] = $myShow;
}
$mySort = $_SESSION['domainSort'];
if ( $myShow == "all" )
{
$where = "";
}
else if ( $myShow == "obrab" )
{
$where = "where status=1";
}
else if ( $myShow == "noobrab" )
{
$where = "where status=0";
}
else if ( $myShow == "suspended" )
{
$where = "where status=2";
}
else if ( $myShow == "toexpire" )
{
$where = "where TO_DAYS(todate)-TO_DAYS(NOW())>=0 and TO_DAYS(todate)-TO_DAYS(NOW())<=30";
}
else if ( $myShow == "expired" )
{
$where = "where TO_DAYS(todate)-TO_DAYS(NOW())<0";
}
if ( $param == "uid" )
{
$operat = "{$param} = '{$search}'";
}
else
{
$operat = "{$param} LIKE '%{$search}%'";
}
if ( $search )
{
if ( $where )
{
$where .= " and {$operat}";
}
else
{
$where = "where {$operat}";
}
}
if ( !$mySort )
{
$mySort = "id";
}
if ( $sort && $sort != $mySort )
{
$mySort = $sort;
}
$_SESSION['domainSort'] = $mySort;
if ( !$_SESSION['domainDesc'] )
{
$_SESSION['domainDesc'] = "desc";
}
if ( $desc && $desc != $_SESSION['domainDesc'] )
{
$_SESSION['domainDesc'] = $desc;
}
if ( !$desc && $_SESSION['domainDesc'] )
{
$desc = $_SESSION['domainDesc'];
}
if ( $desc == "desc" )
{
$desc = "asc";
}
else
{
$desc = "desc";
}
$myDesc = $_SESSION['domainDesc'];
getfont( );
echo " <table width=99%>rn <tr>rn <Td valign=top>rn <table width=270>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Фильтр</b></td></tr>rn <tr><td bgcolor=";
echo $font_row;
echo " align=center>rn <form method=post>rn ";
echo "<s";
echo "elect name=show>rn <option value=all ";
if ( $myShow == "all" )
{
print "selected";
}
echo ">Все доменыrn <option value=obrab ";
if ( $myShow == "obrab" )
{
print "selected";
}
echo ">Обработанныеrn <option value=noobrab ";
if ( $myShow == "noobrab" )
{
print "selected";
}
echo ">Не обработанныеrn <option value=suspended ";
if ( $myShow == "suspended" )
{
print "selected";
}
echo ">Приостановленныеrn <option value=toexpire ";
if ( $myShow == "toexpire" )
{
print "selected";
}
echo ">Заканчивающиесяrn <option value=expired ";
if ( $myShow == "expired" )
{
print "selected";
}
echo ">Закончившиесяrn </select>rn <input type=submit value=Показать>rn </form>rn </td></tr>rn </table>rn </td>rn <td width=50> </td>rn <Td valign=top>rn <table width=300>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Поиск</b></td></tr>rn <tr><td bgcolor=";
echo $font_row;
echo "><form method=post><input type=hidden name=show value=all>";
echo "<s";
echo "elect name=param><option value=domain selected>Домен:</select> <input type=text name=search size=20> <input type=submit value=Найти></form></td></tr>rn </table>rn </td>rn <td width=100%></td>rn </tr>rn </table><BR>rn ";
if ( !( $r = @mysql_query( @"select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders_domains {$where} order by {$mySort} {$myDesc}" ) ) )
{
exit( mysql_error( ) );
}
$rows = mysql_num_rows( $r );
$txt = makepages( $page, $rows )[2];
$perPage = makepages( $page, $rows )[1];
$start = makepages( $page, $rows )[0];
echo " <table cellpadding=3 width=99%>rn <tr><td colspan=8 align=right>";
echo $txt;
echo "</td></tr>rn <tr><td colspan=8 align=center bgcolor=";
echo $font_head;
echo "><B>Домены</b></td></tr>rn <tr bgcolor=";
echo $font_head;
echo " align=center>rn <td></td>rn <td><a href=?do=";
echo $do;
echo "&sort=orderdate&desc=";
echo $desc;
echo ">Дата ";
if ( $mySort == "orderdate" )
{
print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."' title='".$_sort[$myDesc]."'>";
}
echo "</a></td>rn <td align=center>Логин</td>rn <td><a href=?do=";
echo $do;
echo "&sort=domain&desc=";
echo $desc;
echo ">Домен ";
if ( $mySort == "domain" )
{
print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."' title='".$_sort[$myDesc]."'>";
}
echo "</a></td>rn <td><a href=?do=";
echo $do;
echo "&sort=todate&desc=";
echo $desc;
echo "><img src=./_rootimages/domain.gif border=0 alt='Домен' title='Домен'> Конец ";
if ( $mySort == "todate" )
{
print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."' title='".$_sort[$myDesc]."'>";
}
echo "</a></td>rn <td><a href=?do=";
echo $do;
echo "&sort=status&desc=";
echo $desc;
echo "><img src=./_rootimages/domain.gif border=0 alt='Домен' title='Домен'> Статус ";
if ( $mySort == "status" )
{
print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."' title='".$_sort[$myDesc]."'>";
}
echo "</a></td>rn <td></td>rn </tr>rn ";
if ( !( $r = @mysql_query( @"select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders_domains {$where} order by {$mySort} {$myDesc} LIMIT {$start},{$perPage}" ) ) )
{
exit( mysql_error( ) );
}
$cnt = 0;
getfont( );
while ( $rr = mysql_fetch_object( $r ) )
{
getfont( );
$u = mysql_query( "select * from users where id = '{$rr->uid}'" );
$u = mysql_fetch_object( $u );
if ( !( $b = mysql_query( "select * from bills where domain_id = '{$rr->id}'" ) ) )
{
exit( mysql_error( ) );
}
$bills = mysql_num_rows( $b );
$b = mysql_fetch_object( $b );
if ( $rr->leftdays == "" )
{
$rr->leftdays = 0;
}
if ( $rr->leftdays <= 30 && $rr->startdate != "0000-00-00" )
{
$rr->leftdays = "<font color=red>".$rr->leftdays."</font>";
}
$statusDomain = "<img src=./_rootimages/obrabotan_".$rr->status."_small.gif border=0 alt='".$_status[$rr->status]."' title='".$_status[$rr->status]."'>";
$toDateDomain = mydate( $rr->todate );
$leftDaysDomain = "<label alt='осталось дней' title='осталось дней'>[{$rr->leftdays}]</label>";
if ( $rr->startdate != "0000-00-00" )
{
$toDateDomainTxt = "{$toDateDomain} {$leftDaysDomain}";
}
else
{
$toDateDomainTxt = "-";
}
if ( $rr->host_id )
{
$edit_link = "host_id={$rr->host_id}";
}
else
{
$edit_link = "domain_id={$rr->id}";
}
print "rn <tr bgcolor={$font_row} height=30>rn <td align=center>rn <a href=?do=editorder&{$edit_link}><img src=./_rootimages/edit.gif border=0 alt='Редактировать заказ' title='Редактировать заказ'></a><a href=?do={$do}&sub=delete&id={$rr->id} onclick="javascript: return confirm('Будет удален домен, а так же все счета, относящиесу к нему. Вы уверены, что хотите удалить домен?');"><img src=./_rootimages/del.gif border=0 alt='Удалить заказ' title='Удалить заказ'></a>rn </td>rn <td align=center>".mydate( $rr->orderdate )."</td>rn <td align=center><a href=?do=fullinfo&id={$u->id}>{$u->login}</a></td>rn <td><B>{$rr->domain}</b></td>rn <td align=center>{$toDateDomainTxt}</td>rn <td align=center>{$statusDomain}</font></td>rn <td align=center>rn <A href=?do=bills¶m=domain_id&search={$rr->id}><img src=./_rootimages/bills.gif border=0 alt='Счета: {$bills}' title='Счета по данному заказу: {$bills}'></a>rn </td>rn </tr>rn ";
++$cnt;
}
echo " <tr bgcolor=";
echo $font_head;
echo "><Td colspan=8>Всего доменов: ";
echo $rows;
echo ", доменов на странице: ";
echo $cnt;
echo "</td></tr>rn <tr><td colspan=8 align=right>";
echo $txt;
echo "</td></tr>rn </table>rn ";
}
if ( $do == "orders" )
{
if ( $sub == "delete" && $id )
{
$order = getorderbyid( $id );
if ( $order->dalogin )
{
$tarif = gettarifbyid( $order->tarif );
if ( $tarif->autodelete )
{
if ( dadeleteuser( $id ) )
{
print "Аккаунт <B>{$order->dalogin}</b> автоматически удален в DA.<BR>";
}
else
{
print "Аккаунт <B>{$order->dalogin}</b> не удален в DA ({$DAerror}).<BR>";
}
}
else
{
print "Аккаунт <b>{$order->dalogin}</b> не удалён в DA (эта возможность отключена для тарифного плана).<BR>";
}
}
else if ( $order->cpanellogin )
{
$tarif = gettarifbyid( $order->tarif );
if ( $tarif->autodeletecpanel )
{
if ( cpaneldeleteuser( $id ) )
{
print "Аккаунт <B>{$order->cpanellogin}</b> автоматически удален в cPanel.<BR>";
}
else
{
print "Аккаунт <B>{$order->cpanellogin}</b> не удален в cPanel ({$CPANELerror}).<BR>";
}
}
else
{
print "Аккаунт <b>{$order->cpanellogin}</b> не удалён в cPanel (эта возможность отключена для тарифного плана).<BR>";
}
}
else
{
print "Аккаунт для заказа <B>ID #{$order->id} ({$order->domain})</b> не удалён в DA/cPanel (не указан логин в cPanel).<BR>";
}
if ( !@mysql_query( @"delete from orders where id='{$id}'" ) )
{
exit( mysql_error( ) );
}
if ( !@mysql_query( @"delete from orders_domains where host_id='{$id}'" ) )
{
exit( mysql_error( ) );
}
if ( !@mysql_query( @"delete from bills where host_id='{$id}'" ) )
{
exit( mysql_error( ) );
}
print "Заказ и все счета, относящиеся к нему, успешно удалены.<BR><BR>";
}
$myShow = $_SESSION['orderShow'];
if ( !$myShow )
{
$myShow = "all";
}
if ( $show && $show != $myShow )
{
$myShow = $show;
$_SESSION['orderShow'] = $myShow;
}
$mySort = $_SESSION['orderSort'];
if ( $myShow == "all" )
{
$where = "where 1";
}
else if ( $myShow == "obrab" )
{
$where = "where status=1";
}
else if ( $myShow == "noobrab" )
{
$where = "where status=0";
}
else if ( $myShow == "suspended" )
{
$where = "where status=2";
}
else if ( $myShow == "toexpire" )
{
$where = "where TO_DAYS(todate)-TO_DAYS(NOW())>=0 and TO_DAYS(todate)-TO_DAYS(NOW())<=10";
}
else if ( $myShow == "expired" )
{
$where = "where TO_DAYS(todate)-TO_DAYS(NOW())<0";
}
if ( $param == "uid" )
{
$operat = "{$param} = '{$search}'";
}
else
{
$operat = "{$param} LIKE '%{$search}%'";
}
if ( $search )
{
$where .= " and {$operat}";
}
if ( !$mySort )
{
$mySort = "id";
}
if ( $sort && $sort != $mySort )
{
$mySort = $sort;
}
$_SESSION['orderSort'] = $mySort;
if ( !$_SESSION['orderDesc'] )
{
$_SESSION['orderDesc'] = "desc";
}
if ( $desc && $desc != $_SESSION['orderDesc'] )
{
$_SESSION['orderDesc'] = $desc;
}
if ( !$desc && $_SESSION['orderDesc'] )
{
$desc = $_SESSION['orderDesc'];
}
if ( $desc == "desc" )
{
$desc = "asc";
}
else
{
$desc = "desc";
}
$myDesc = $_SESSION['orderDesc'];
getfont( );
echo " <table width=99%>rn <tr>rn <Td valign=top>rn <table width=270>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Фильтр</b></td></tr>rn <tr><td bgcolor=";
echo $font_row;
echo " align=center>rn <form method=post>rn ";
echo "<s";
echo "elect name=show>rn <option value=all ";
if ( $myShow == "all" )
{
print "selected";
}
echo ">Все заказыrn <option value=obrab ";
if ( $myShow == "obrab" )
{
print "selected";
}
echo ">Обработанныеrn <option value=noobrab ";
if ( $myShow == "noobrab" )
{
print "selected";
}
echo ">Не обработанныеrn <option value=suspended ";
if ( $myShow == "suspended" )
{
print "selected";
}
echo ">Приостановленныеrn <option value=toexpire ";
if ( $myShow == "toexpire" )
{
print "selected";
}
echo ">Заканчивающиесяrn <option value=expired ";
if ( $myShow == "expired" )
{
print "selected";
}
echo ">Закончившиесяrn </select>rn <input type=submit value=Показать>rn </form>rn </td></tr>rn </table>rn </td>rn <td width=50> </td>rn <Td valign=top>rn <table width=300>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Поиск</b></td></tr>rn <tr><td bgcolor=";
echo $font_row;
echo "><form method=post><input type=hidden name=show value=all>";
echo "<s";
echo "elect name=param><option value=domain selected>Домен:</select> <input type=text name=search size=20> <input type=submit value=Найти></form></td></tr>rn </table>rn </td>rn <td width=100%></td>rn </tr>rn </table><BR>rn ";
if ( !( $r = @mysql_query( @"select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays{$select} from orders {$where} order by {$mySort} {$myDesc}" ) ) )
{
exit( mysql_error( ) );
}
$rows = mysql_num_rows( $r );
$txt = makepages( $page, $rows )[2];
$perPage = makepages( $page, $rows )[1];
$start = makepages( $page, $rows )[0];
echo " <table cellpadding=3 width=99%>rn <tr><td colspan=11 align=right>";
echo $txt;
echo "</td></tr>rn <tr><td colspan=11 align=center bgcolor=";
echo $font_head;
echo "><B>Заказы</b></td></tr>rn <tr bgcolor=";
echo $font_head;
echo " align=center>rn <td></td>rn <td><a href=?do=";
echo $do;
echo "&sort=orderdate&desc=";
echo $desc;
echo ">Дата ";
if ( $mySort == "orderdate" )
{
print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."' title='".$_sort[$myDesc]."'>";
}
echo "</a></td>rn <Td>Логин</Td>rn <td><a href=?do=";
echo $do;
echo "&sort=domain&desc=";
echo $desc;
echo ">Домен ";
if ( $mySort == "domain" )
{
print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."' title='".$_sort[$myDesc]."'>";
}
echo "</a></td>rn <td><a href=?do=";
echo $do;
echo "&sort=tarif&desc=";
echo $desc;
echo ">Тариф ";
if ( $mySort == "tarif" )
{
print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."' title='".$_sort[$myDesc]."'>";
}
echo "</a></td>rn <td><a href=?do=";
echo $do;
echo "&sort=todate&desc=";
echo $desc;
echo "><img src=./_rootimages/hosting.gif border=0 alt='Хостинг' title='Хостинг'> Конец ";
if ( $mySort == "todate" )
{
print "<img src=./_rootimages/s_".$myDesc.".png border=0 width=11 height=9 alt='".$_sort[$myDesc]."' title='".$_sort[$myDesc]."'>";
}
echo "</a></td>rn <td><img src=./_rootimages/domain.gif border=0 alt='Домен' title='Домен'> Конец</td>rn <td><img src=./_rootimages/hosting.gif border=0 alt='Хостинг' title='Хостинг'> Статус</td>rn <td><img src=./_rootimages/domain.gif border=0 alt='Домен' title='Домен'> Статус</td>rn <td></td>rn </tr>rn ";
if ( !( $r = @mysql_query( @"select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays{$select} from orders {$where} order by {$mySort} {$myDesc} LIMIT {$start},{$perPage}" ) ) )
{
exit( mysql_error( ) );
}
$cnt = 0;
getfont( );
while ( $rr = mysql_fetch_object( $r ) )
{
getfont( );
$u = mysql_query( "select * from users where id = '{$rr->uid}'" );
$u = mysql_fetch_object( $u );
$t = mysql_query( "select * from tarifs where id = '{$rr->tarif}'" );
$t = mysql_fetch_object( $t );
if ( !( $b = mysql_query( "select * from bills where host_id = '{$rr->id}'" ) ) )
{
exit( mysql_error( ) );
}
$bills = mysql_num_rows( $b );
$b = mysql_fetch_object( $b );
if ( $rr->leftdays == "" )
{
$rr->leftdays = 0;
}
if ( $rr->leftdays <= 10 && $rr->startdate != "0000-00-00" )
{
$rr->leftdays = "<font color=red>".$rr->leftdays."</font>";
}
$statusHosting = "<img src=./_rootimages/obrabotan_".$rr->status."_small.gif border=0 alt='".$_status[$rr->status]."' title='".$_status[$rr->status]."'>";
$toDateHosting = mydate( $rr->todate );
$leftDaysHosting = "<label alt='осталось дней' title='осталось дней'>[{$rr->leftdays}]</label>";
if ( $rr->startdate != "0000-00-00" )
{
$toDateHostingTxt = "{$toDateHosting} {$leftDaysHosting}";
}
else
{
$toDateHostingTxt = "-";
}
$statusDomain = "";
$toDateDomain = "";
$leftDaysDomain = "";
$toDateDomainTxt = "";
if ( $rr->domain_reg )
{
if ( !( $d = @mysql_query( @"select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders_domains where host_id='{$rr->id}'" ) ) )
{
exit( mysql_error( ) );
}
$d = mysql_fetch_object( $d );
if ( $d->leftdays == "" )
{
$d->leftdays = 0;
}
if ( $d->leftdays <= 30 && $d->startdate != "0000-00-00" )
{
$d->leftdays = "<font color=red>".$d->leftdays."</font>";
}
$statusDomain = "<img src=./_rootimages/obrabotan_".$d->status."_small.gif border=0 alt='".$_status[$d->status]."' title='".$_status[$d->status]."'>";
$toDateDomain = mydate( $d->todate );
$leftDaysDomain = "<label alt='осталось дней' title='осталось дней'>[{$d->leftdays}]</label>";
if ( $d->startdate != "0000-00-00" )
{
$toDateDomainTxt = "{$toDateDomain} {$leftDaysDomain}";
}
else
{
$toDateDomainTxt = "-";
}
}
print "rn <tr bgcolor={$font_row} height=30>rn <td align=center>rn <a href=?do=editorder&host_id={$rr->id}><img src=./_rootimages/edit.gif border=0 alt='Редактировать заказ' title='Редактировать заказ'></a><a href=?do={$do}&sub=delete&id={$rr->id} onclick="javascript: return confirm('Будет удален заказ, а так же все счета, относящиесу к нему. Вы уверены, что хотите удалить заказ?');"><img src=./_rootimages/del.gif border=0 alt='Удалить заказ' title='Удалить заказ'></a>rn </td>rn <td align=center>".mydate( $rr->orderdate )."</td>rn <td align=center><a href=?do=fullinfo&id={$u->id}>{$u->login}</a></td>rn <td><B>{$rr->domain}</b><BR>[".$_newregmin[$rr->domain_reg]."]</td>rn <td align=center>{$t->name}</td>rn <td align=center nowrap>{$toDateHostingTxt}</td>rn <td align=center nowrap>{$toDateDomainTxt}</td>rn <td align=center>{$statusHosting}</font></td>rn <td align=center>{$statusDomain}</font></td>rn <td align=center>rn <A href=?do=bills¶m=host_id&search={$rr->id}><img src=./_rootimages/bills.gif border=0 alt='Счета по данному заказу: {$bills}' title='Счета по данному заказу: {$bills}'></a>rn </td>rn </tr>rn ";
++$cnt;
}
echo " <tr bgcolor=";
echo $font_head;
echo "><Td colspan=11>Всего заказов: ";
echo $rows;
echo ", заказов на странице: ";
echo $cnt;
echo "</td></tr>rn <tr><td colspan=11 align=right>";
echo $txt;
echo "</td></tr>rn </table>rn ";
}
if ( $do == "editorder" && ( $host_id || $domain_id ) )
{
if ( $uid )
{
print menu_admin_client( $uid );
}
if ( $sub == "edit" && $host_id && !$domain_id )
{
$selectedAddons = @join( ":x:", @$selectedAddons );
if ( !( $order = @mysql_query( @"select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders where id='{$host_id}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $order ) )
{
$order = mysql_fetch_object( $order );
if ( $order->tarif != $tarif_id )
{
if ( 0 < $order->leftdays )
{
$oldTarif = gettarifbyid( $order->tarif );
$newTarif = gettarifbyid( $tarif_id );
if ( $oldTarif->id && $newTarif->id )
{
$money = $order->leftdays * ( $newTarif->cost - $oldTarif->cost ) / 30;
$money = round( $money, 2 );
if ( 0 < $money )
{
if ( !@mysql_query( @"insert into bills (uid,host_id,money_host,created) values('{$order->uid}','{$order->id}','{$money}',NOW())" ) )
{
exit( mysql_error( ) );
}
print "Клиенту выставлен счет на сумму {$money}$<BR>";
$forLog = ", счет на сумму {$money}$";
}
else
{
if ( $money < 0 )
{
print "Необходимо возвратить клиенту ".( 0 - $money )."$<BR>";
$forLog = ", возврат средств на сумму ".( 0 - $money )."$";
}
}
}
else
{
print "Не возможно сделать перерасчет, т.к. отсутствует информация о тарифном плане.<BR>";
}
}
adduserlog( $order->uid, "changetarif", "С {$oldTarif->name} на {$newTarif->name}{$forLog}" );
}
if ( !@mysql_query( @"update orders set tarif='{$tarif_id}',domain='{$domain}',orderdate='{$orderdate}',startdate='{$startdate}',todate='{$todate}',discount='{$discount}',status='{$status}',addons='{$selectedAddons}',dalogin='{$dalogin}',cpanellogin='{$cpanellogin}' where id='{$host_id}'" ) )
{
exit( mysql_error( ) );
}
if ( $oldStatus != $status && $status == "2" )
{
if ( $order->dalogin )
{
if ( dasuspenduser( $host_id, 1, 0 ) )
{
print "Аккаунт в DA успешно остановлен.<BR>";
}
else
{
print "Не удалось остановить аккаунт в DA ({$DAerror}).<BR>";
}
}
else if ( $order->cpanellogin )
{
if ( cpanelsuspenduser( $host_id, 1, 0 ) )
{
print "Аккаунт в cPanel успешно остановлен.<BR>";
}
else
{
print "Не удалось остановить аккаунт в cPanel ({$CPANELerror}).<BR>";
}
}
else
{
print "Не удалось остановить аккаунт в DA/cPanel (не указан логин в DA/cPanel для данного заказа.)";
}
}
if ( $oldStatus != $status && $oldStatus == "2" && $status == "1" )
{
if ( $order->dalogin )
{
if ( dasuspenduser( $host_id, 0, 0 ) )
{
print "Аккаунт в DA успешно запущен.<BR>";
}
else
{
print "Не удалось запустить аккаунт в DA ({$DAerror})<BR>";
}
}
else if ( $order->cpanellogin )
{
if ( cpanelsuspenduser( $host_id, 0, 0 ) )
{
print "Аккаунт в cPanel успешно запущен.<BR>";
}
else
{
print "Не удалось запустить аккаунт в cPanel ({$CPANELerror})<BR>";
}
}
else
{
print "Не удалось запустить аккаунт в DA/cPanel (не указан логин в DA/cPanel для данного заказа.)";
}
}
print "Данные успешно изменены.<BR><BR>";
}
}
if ( $sub == "edit" && $domain_id )
{
$fulldomain = $domain.".".$zone;
if ( !( $z = @mysql_query( @"select * from zones where zone='{$zone}'" ) ) )
{
exit( mysql_error( ) );
}
$z = mysql_fetch_object( $z );
if ( !@mysql_query( @"update orders_domains set zone_id='{$z->id}',domain='{$fulldomain}',orderdate='{$orderdate}',startdate='{$startdate}',todate='{$todate}',discount='{$discount}',status='{$status}' where id='{$domain_id}'" ) )
{
exit( mysql_error( ) );
}
if ( !@mysql_query( @"update orders set domain='{$fulldomain}' where id='{$host_id}'" ) )
{
exit( mysql_error( ) );
}
print "Данные успешно изменены.<BR><BR>";
}
if ( $sub == "DAcreate" && $host_id )
{
if ( dacreateuser( $host_id, 0 ) )
{
print "Аккаунт в DA успешно создан.<BR><BR>";
}
else
{
print "Не удалось создать аккаунт в DA ({$DAerror})<BR><BR>";
}
}
if ( $sub == "CPANELcreate" && $host_id )
{
if ( cpanelcreateuser( $host_id, 0 ) )
{
print "Аккаунт в cPanel успешно создан.<BR><BR>";
}
else
{
print "Не удалось создать аккаунт в cPanel ({$CPANELerror})<BR><BR>";
}
}
if ( $host_id )
{
if ( !( $r = @mysql_query( @"select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders where id='{$host_id}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
$r = mysql_fetch_object( $r );
if ( !$uid )
{
print menu_admin_client( $r->uid );
}
if ( $r->domain_reg )
{
$check2 = "checked";
$domain_readonly = "readonly";
if ( !( $d = @mysql_query( @"select * from orders_domains where domain='{$r->domain}'" ) ) )
{
exit( mysql_error( ) );
}
$d = mysql_fetch_object( $d );
$domain_id = $d->id;
}
else
{
$check1 = "checked";
}
if ( 0 < $r->leftdays )
{
$r->leftdays = "(осталось дней: {$r->leftdays})";
}
else
{
$r->leftdays = "";
}
echo " <form method=post>rn <input type=hidden name=do value=";
echo $do;
echo ">rn <input type=hidden name=sub value=edit>rn <input type=hidden name=host_id value=";
echo $host_id;
echo ">rn <input type=hidden name=uid value=";
echo $r->uid;
echo ">rn <input type=hidden name=oldStatus value=";
echo $r->status;
echo ">rn <table width=400>rn <tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Редактирование заказа (хостинг)</b></td></tr>rn <tr><td>Логин в DA:</td><TD><input type=text name=dalogin size=16 value=";
echo $r->dalogin;
echo "></td></tr>rn <tr><td>Логин в cPanel:</td><TD><input type=text name=cpanellogin size=16 value=";
echo $r->cpanellogin;
echo "></td></tr>rn <tr><Td>Тарифный план:</td><Td>";
echo "<s";
echo "elect name=tarif_id>rn ";
if ( !( $q = @mysql_query( "select * from tarifs order by vid,cost" ) ) )
{
exit( mysql_error( ) );
}
$paneltype = "";
while ( $qq = mysql_fetch_object( $q ) )
{
if ( $qq->id == $r->tarif )
{
$addon = "selected";
if ( $qq->autocreate )
{
$paneltype = "da";
}
else
{
if ( $qq->autocreatecpanel )
{
$paneltype = "cpanel";
}
}
}
else
{
$addon = "";
}
print "<option value={$qq->id} {$addon}>{$qq->name} ({$qq->cost} $/мес)";
}
echo " </select></td></tr>rn <tr><Td>Домен:</td><td><input type=text name=domain size=30 value="";
echo $r->domain;
echo "" ";
echo $domain_readonly;
echo "></td></tr>rn <tr><td valign=top>Хостинг:</td><td><input type=radio name=domain_reg value=0 ";
echo $check1;
echo " disabled>с переносом домена<BR><input type=radio name=domain_reg value=1 ";
echo $check2;
echo " disabled>с регистрацией нового</td></tr>rn <tr><td>Дата заказа:</td><TD><input type=text name=orderdate size=16 value=";
echo $r->orderdate;
echo "></td></tr>rn <tr><td>Начало периода:</td><TD><input type=text name=startdate size=16 value=";
echo $r->startdate;
echo "></td></tr>rn <tr><td>Конец периода:</td><TD><input type=text name=todate size=16 value=";
echo $r->todate;
echo "> ";
echo $r->leftdays;
echo "</td></tr>rn <tr><td>Скидка:</td><TD><input type=text name=discount size=2 value=";
echo $r->discount;
echo "> %</td></tr>rn <tr><td>Статус:</td><TD>";
echo "<s";
echo "elect name=status>rn ";
$v = each( $_status )[1];
$k = each( $_status )[0];
while ( each( $_status ) )
{
if ( $k == $r->status )
{
$addon = "selected";
}
else
{
$addon = "";
}
print "<option value={$k} {$addon}>{$v}";
}
echo " </select>rn ";
if ( !$r->dalogin && $r->status == "0" && $paneltype == "da" )
{
print "[ <A href=?do={$do}&host_id={$host_id}&sub=DAcreate&uid={$r->uid}>создать аккаунт в DA</a> ]";
}
if ( !$r->cpanellogin && $r->status == "0" && $paneltype == "cpanel" )
{
print "[ <A href=?do={$do}&host_id={$host_id}&sub=CPANELcreate&uid={$r->uid}>создать аккаунт в cPanel</a> ]";
}
echo " </td></tr>rn ";
$orderAddons = split( ":x:", $r->addons );
if ( 0 < getarraynotnullcount( $orderAddons ) )
{
echo " <tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Дополнительные услуги</b></td></tr>rn ";
do
{
$v = each( $orderAddons )[1];
$k = each( $orderAddons )[0];
if ( each( $orderAddons ) )
{
}
else if ( $v )
{
$oneAddon = getaddonbyid( $v );
print "<tr><td colspan=2><input type=checkbox name=selectedAddons[] value={$oneAddon->id} checked>{$oneAddon->name}</td></tr>";
}
} while ( 1 );
}
if ( $r->paymethod || $r->comment )
{
print "<tr><td colspan=2 align=center bgcolor={$font_head}><B>Дополнительная информация</b></td></tr>";
}
if ( $r->paymethod )
{
print "<tr><td>Способ оплаты:</td><Td><input type=text readonly size=40 value='{$r->paymethod}'></td></tr>";
}
if ( $r->comment )
{
print "<tr><Td valign=top>Комментарий:</tD><Td><textarea cols=30 rows=3 readonly>".stripslashes( $r->comment )."</textarea></td></tr>";
}
echo " <tr><td colspan=2 align=center><BR><input type=submit value=Изменить></td></tr>rn </table>rnrn </form><BR>rn ";
}
}
if ( $domain_id )
{
if ( !( $r = @mysql_query( @"select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders_domains where id='{$domain_id}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
$r = mysql_fetch_object( $r );
if ( !$uid && !$host_id )
{
print menu_admin_client( $r->uid );
}
$domain = split( "\.", $r->domain );
$domain = $domain[0];
if ( 0 < $r->leftdays )
{
$r->leftdays = "(осталось дней: {$r->leftdays})";
}
else
{
$r->leftdays = "";
}
echo " <form method=post>rn <input type=hidden name=do value=";
echo $do;
echo ">rn <input type=hidden name=sub value=edit>rn <input type=hidden name=host_id value=";
echo $host_id;
echo ">rn <input type=hidden name=domain_id value=";
echo $domain_id;
echo ">rn <input type=hidden name=uid value=";
echo $r->uid;
echo ">rn <table width=400>rn <tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Редактирование заказа (домен)</b></td></tr>rn <tr><td>Домен:</td><td><input type="text" name="domain" value="";
echo $domain;
echo ""> ";
echo "<s";
echo "elect name="zone">rn ";
if ( !( $q = @mysql_query( "select * from zones order by zone" ) ) )
{
exit( mysql_error( ) );
}
while ( $qq = mysql_fetch_object( $q ) )
{
if ( $qq->id == $r->zone_id )
{
$addon = "selected";
}
else
{
$addon = "";
}
print "<option value={$qq->zone} {$addon}>{$qq->zone}";
}
echo " </select></td></tr>rn <tr><td>Дата заказа:</td><TD><input type=text name=orderdate size=16 value=";
echo $r->orderdate;
echo "></td></tr>rn <tr><td>Начало периода:</td><TD><input type=text name=startdate size=16 value=";
echo $r->startdate;
echo "></td></tr>rn <tr><td>Конец периода:</td><TD><input type=text name=todate size=16 value=";
echo $r->todate;
echo "> ";
echo $r->leftdays;
echo "</td></tr>rn <tr><td>Скидка:</td><TD><input type=text name=discount size=2 value=";
echo $r->discount;
echo "> %</td></tr>rn <tr><td>Статус:</td><TD>";
echo "<s";
echo "elect name=status>rn ";
reset( $_status );
$v = each( $_status )[1];
$k = each( $_status )[0];
while ( each( $_status ) )
{
if ( $k == $r->status )
{
$addon = "selected";
}
else
{
$addon = "";
}
print "<option value={$k} {$addon}>{$v}";
}
echo " </select>rn </td></tr>rntttttt";
if ( $r->paymethod || $r->comment || $r->ns1 || $r->ns2 )
{
print "<tr><td colspan=2 align=center bgcolor={$font_head}><B>Дополнительная информация</b></td></tr>";
}
if ( $r->ns1 )
{
print "<tr><td>NS1:</td><Td><input type=text readonly size=40 value="{$r->ns1}"></td></tr>";
}
if ( $r->ns2 )
{
print "<tr><td>NS2:</td><Td><input type=text readonly size=40 value="{$r->ns2}"></td></tr>";
}
if ( $r->paymethod )
{
print "<tr><td>Способ оплаты:</td><Td><input type=text readonly size=40 value="{$r->paymethod}"></td></tr>";
}
if ( $r->comment )
{
print "<tr><Td valign=top>Комментарий:</tD><Td><textarea cols=30 rows=3 readonly>".stripslashes( $r->comment )."</textarea></td></tr>";
}
echo " <tr><td colspan=2 align=center><BR><input type=submit value=Изменить></td></tr>rn </table>rn </form>rn ";
}
}
}
if ( $do == "bills" )
{
if ( $sub == "delete" && $id )
{
if ( !@mysql_query( @"delete from bills where id='{$id}'" ) )
{
exit( mysql_error( ) );
}
print "Счет успешно удален.<BR><BR>";
}
$myShow = $_SESSION['billsShow'];
if ( !$myShow )
{
$myShow = "all";
}
if ( $show && $show != $myShow )
{
$myShow = $show;
$_SESSION['billsShow'] = $myShow;
}
if ( $myShow == "all" )
{
$where = "where 1";
}
else if ( $myShow == "payed" )
{
$where = "where status=1";
}
else if ( $myShow == "nonpayed" )
{
$where = "where status=0";
}
else if ( $myShow == "nonpayed20" )
{
$where = "where status=0 and (TO_DAYS(NOW())-TO_DAYS(created))>20";
}
else if ( $myShow == "uslpayed" )
{
$where = "where status=2";
}
if ( $search )
{
if ( $param == "id" || $param == "uid" )
{
$where .= " and {$param}='{$search}'";
}
else
{
$where .= " and {$param} LIKE '%{$search}%'";
}
}
getfont( );
echo " <table width=99%>rn <tr>rn <Td valign=top>rn <table width=330>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Фильтр</b></td></tr>rn <tr><td bgcolor=";
echo $font_row;
echo " align=center>rn <form method=post>rn ";
echo "<s";
echo "elect name=show>rn <option value=all ";
if ( $myShow == "all" )
{
print "selected";
}
echo ">Все счетаrn <option value=payed ";
if ( $myShow == "payed" )
{
print "selected";
}
echo ">Оплаченныеrn <option value=uslpayed ";
if ( $myShow == "uslpayed" )
{
print "selected";
}
echo ">Условно опплаченныеrn <option value=nonpayed ";
if ( $myShow == "nonpayed" )
{
print "selected";
}
echo ">Не оплаченныеrn <option value=nonpayed20 ";
if ( $myShow == "nonpayed20" )
{
print "selected";
}
echo ">Не оплаченные более 20 днейrn </select>rn <input type=submit value=Показать>rn </form>rn </td></tr>rn </table>rn </td>rn <td width=50> </td>rn <Td valign=top>rn <table width=320>rn <tr><td align=center bgcolor=";
echo $font_head;
echo "><B>Поиск</b></td></tr>rn <tr><td bgcolor=";
echo $font_row;
echo "><form method=post>";
echo "<s";
echo "elect name=param><option value=id selected>№ счета:</select> <input type=text name=search size=20> <input type=submit value=Найти></form></td></tr>rn </table>rn </td>rn <td width=100%></td>rn </tr>rn </table><BR>rn ";
if ( !( $r = @mysql_query( @"select * from bills {$where} order by id desc" ) ) )
{
exit( mysql_error( ) );
}
$rows = mysql_num_rows( $r );
$txt = makepages( $page, $rows )[2];
$perPage = makepages( $page, $rows )[1];
$start = makepages( $page, $rows )[0];
echo " <table cellpadding=3 width=99%>rn <tr><td colspan=10 align=right>";
echo $txt;
echo "</td></tr>rn <tr><td colspan=10 align=center bgcolor=";
echo $font_head;
echo "><B>Счета</b></td></tr>rn <tr bgcolor=";
echo $font_head;
echo " align=center><td></td><td>Дата</td><td>№ счета</td><td>Логин</td><td>Тариф</td><td>Домен</td><td>Стоимость</td><td>Сумма</td><td>Статус</td><td></td></tr>rn ";
if ( !( $r = @mysql_query( @"select * from bills {$where} order by id desc LIMIT {$start},{$perPage}" ) ) )
{
exit( mysql_error( ) );
}
$cnt = 0;
getfont( );
while ( $rr = mysql_fetch_object( $r ) )
{
$tarifTxt = "";
$domainTxt = "";
$cost = "";
$t = @mysql_query( @"select t1.*, t2.name from orders as t1, tarifs as t2 where t1.id='{$rr->host_id}' and t1.tarif=t2.id" );
if ( 0 < mysql_num_rows( $t ) )
{
$t = mysql_fetch_object( $t );
$cost = "<img src=./_rootimages/hosting.gif border=0 alt='Хостинг' title='Хостинг'> {$rr->money_host}$";
$newreg = "";
$domain_srok = "";
$tarifTxt = "<B>{$t->name}</b><BR>[{$rr->host_srok} мес]";
if ( $t->domain_reg )
{
if ( $rr->renew )
{
if ( $rr->domain_id )
{
$newreg = $_renewmin[1];
$domain_srok = " [{$rr->domain_srok} мес]";
}
else
{
$newreg = $_renewmin[0];
}
}
else
{
$newreg = $_newregmin[1];
$domain_srok = " [{$rr->domain_srok} мес]";
}
}
else
{
if ( $rr->renew )
{
$newreg = "";
}
else
{
$newreg = $_newregmin[0];
}
}
if ( $newreg )
{
$newreg = "[".$newreg."]";
}
$domainTxt = "<B>{$t->domain}</b><BR>".$newreg.$domain_srok;
}
if ( !( $d = @mysql_query( @"select * from orders_domains domains where id='{$rr->domain_id}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $d ) )
{
$d = mysql_fetch_object( $d );
$cost = $cost." <img src=./_rootimages/domain.gif border=0 alt='Домен' title='Домен'> {$rr->money_domain}$";
if ( !$rr->host_id )
{
$domainTxt = "<B>".$d->domain."</b><BR>";
if ( $rr->renew )
{
$domainTxt .= "[продление] ";
}
else
{
$domainTxt .= "[новый] ";
}
$domainTxt .= "[{$rr->domain_srok} мес]";
}
}
if ( 0 < $rr->money_addons )
{
$cost = $cost." <img src=./_rootimages/addons.gif border=0 alt='Доп. услуги' title='Доп. услуги'> {$rr->money_addons}$";
}
if ( !( $u = @mysql_query( @"select * from users where id='{$rr->uid}'" ) ) )
{
exit( mysql_error( ) );
}
$u = mysql_fetch_object( $u );
if ( $rr->status != 0 )
{
$statusAddOn = " ".mydate( $rr->payed );
}
else
{
$statusAddOn = "";
}
getfont( );
echo " <tr bgcolor="";
echo $font_row;
echo "" height=30>rn <td align=center>rn <a href=?do=editbill&id=";
echo $rr->id;
echo "><img src=./_rootimages/edit.gif border=0 alt="Редактировать счет" title="Редактировать счет"></a><a href=?do=";
echo $do;
echo "&sub=delete&id=";
echo $rr->id;
echo " onclick="javascript: return confirm('Вы уверены, что хотите удалить счет?');"><img src=./_rootimages/del.gif border=0 alt="Удалить счет" title="Удалить счет"></a>rn </td>rn <td align=center>";
echo mydate( $rr->created );
echo "</td>rn <td align=center><B>";
echo sprintf( "%04d", $rr->id );
echo "</b></td>rn <td align=center><a href=?do=fullinfo&id=";
echo $u->id;
echo ">";
echo $u->login;
echo "</a></td>rn <td>";
echo $tarifTxt;
echo "</td>rn <td>";
echo $domainTxt;
echo "</td>rn <td align=center>";
echo $cost;
echo "</td>rn <td align=center><B>";
echo $rr->money_host + $rr->money_domain + $rr->money_addons;
echo "$</b></td>rn <td align=center><img src=./_rootimages/payed_";
echo $rr->status;
echo "_small.gif border=0 alt="";
echo $_statusBill[$rr->status].$statusAddOn;
echo "" title="";
echo $_statusBill[$rr->status].$statusAddOn;
echo ""></td>rn <td align=center>rn <a href=?do=editorder&";
if ( $t->id )
{
print "host_id={$t->id}";
}
else
{
print "domain_id={$d->id}";
}
echo "><img src=./_rootimages/orders.gif border=0 alt='Редактировать заказ' title='Редактировать заказ'></a>rn </td>rn </tr>rn ";
++$cnt;
}
echo " <tr bgcolor=";
echo $font_head;
echo "><Td colspan=10>Всего счетов: ";
echo $rows;
echo ", счетов на странице: ";
echo $cnt;
echo "</td></tr>rn <tr><td colspan=10 align=right>";
echo $txt;
echo "</td></tr>rn </table>rn ";
}
if ( $do == "editbill" )
{
if ( !( $r = @mysql_query( @"select * from bills where id='{$id}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
$r = mysql_fetch_object( $r );
print menu_admin_client( $r->uid );
if ( $sub == "edit" )
{
if ( $r->host_id )
{
if ( !@mysql_query( @"update bills set host_srok='{$host_srok}',money_host='{$money_host}',money_addons='{$money_addons}' where id='{$id}'" ) )
{
exit( mysql_error( ) );
}
}
if ( $r->domain_id )
{
if ( !@mysql_query( @"update bills set domain_srok='{$domain_srok}',money_domain='{$money_domain}' where id='{$id}'" ) )
{
exit( mysql_error( ) );
}
}
if ( $status != $r->status )
{
if ( $status )
{
makebillpayed( $id, $status );
}
else if ( !$status )
{
if ( !@mysql_query( @"update bills set payed='0000-00-00',status='{$status}' where id='{$id}'" ) )
{
exit( mysql_error( ) );
}
if ( $r->host_id )
{
if ( !@mysql_query( @"update orders set todate=DATE_SUB(todate,INTERVAL {$host_srok} MONTH) where id='{$r->host_id}'" ) )
{
exit( mysql_error( ) );
}
if ( !( $q = @mysql_query( @"select * from orders where startdate>=todate and id='{$r->host_id}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $q ) )
{
if ( !@mysql_query( @"update orders set startdate='0000-00-00',todate='0000-00-00' where id='{$r->host_id}'" ) )
{
exit( mysql_error( ) );
}
}
}
if ( $r->domain_id )
{
if ( !@mysql_query( @"update orders_domains set todate=DATE_SUB(todate,INTERVAL {$domain_srok} MONTH) where id='{$r->domain_id}'" ) )
{
exit( mysql_error( ) );
}
if ( !( $q = @mysql_query( @"select * from orders_domains where startdate>=todate and id='{$r->domain_id}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $q ) )
{
if ( !@mysql_query( @"update orders_domains set startdate='0000-00-00',todate='0000-00-00' where id='{$r->domain_id}'" ) )
{
exit( mysql_error( ) );
}
}
}
}
}
print "Данные успешно изменены.<BR><BR>";
if ( !( $r = @mysql_query( @"select * from bills where id='{$id}'" ) ) )
{
exit( mysql_error( ) );
}
$r = mysql_fetch_object( $r );
}
echo " <form method=post>rn <input type=hidden name=do value=";
echo $do;
echo ">rn <input type=hidden name=sub value=edit>rn <input type=hidden name=id value=";
echo $id;
echo ">rn <table width=400>rn <tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Редактирование счета</b></td></tr>rn <tr><Td>Номер счета:</td><Td><input type=text size=30 value='";
echo sprintf( "%04d", $r->id );
echo "' readonly></td></tr>rn <tr><td>Дата создания:</td><Td><input type=text size=30 value='";
echo $r->created;
echo "' readonly></td></tr>rn ";
if ( $r->host_id )
{
echo "<tr><Td>Срок (хостинг):</td><Td><input type=text name=host_srok size=2 value='";
echo $r->host_srok;
echo "'> мес.</td></tr>";
}
echo " ";
if ( $r->domain_id )
{
echo "<tr><Td>Срок (домен):</td><Td><input type=text name=domain_srok size=2 value='";
echo $r->domain_srok;
echo "'> мес.</td></tr>";
}
echo " ";
if ( $r->host_id )
{
echo "<tr><Td>Цена (хостинг):</td><Td><input type=text name=money_host size=2 value='";
echo $r->money_host;
echo "'> $</td></tr>";
echo "<tr><Td>Цена (доп. услуги):</td><Td><input type=text name=money_addons size=2 value='";
echo $r->money_addons;
echo "'> $</td></tr>";
}
if ( $r->domain_id )
{
echo "<tr><Td>Цена (домен):</td><Td><input type=text name=money_domain size=2 value='";
echo $r->money_domain;
echo "'> $</td></tr>";
}
echo " <tr><td>Статус:</td><TD>";
echo "<s";
echo "elect name=status>rn ";
reset( $_statusBill );
$v = each( $_statusBill )[1];
$k = each( $_statusBill )[0];
while ( each( $_statusBill ) )
{
if ( $k == $r->status )
{
$addon = "selected";
}
else
{
$addon = "";
}
print "<option value={$k} {$addon}>{$v}";
}
echo " </select>rn </td></tr>rn <tr><td>Дата оплаты:</td><Td><input type=text size=30 value='";
echo $r->payed;
echo "' readonly></td></tr>rn <tr><td colspan=2 align=center><BR><input type=submit value="Изменить"></td></tr>rn </table><BR>rn <A href=?do=editorder&";
if ( $r->host_id )
{
print "host_id={$r->host_id}";
}
else
{
print "domain_id={$r->domain_id}";
}
echo "><img src=./_rootimages/edit.gif border=0>перейти к редактированию заказа</a>rn ";
}
else
{
print "Счет № ".sprintf( "%04d", $id )." не найден.";
}
}
if ( $do == "addons" )
{
print "[ <B><A href=?do={$do}&sub=list>текущие дополнительные услуги</a></B> - <B><A href=?do={$do}&sub=add>добавить дополнительную услугу</a></B> ]<BR><BR>";
if ( !$sub )
{
$sub = "list";
}
if ( $sub == "add2" || $sub == "edit2" )
{
if ( $sub == "add2" )
{
$sub2 = "add";
}
if ( $sub == "edit2" )
{
$sub2 = "edit";
}
if ( !$name )
{
print "Не указано название.";
}
else if ( !$textid )
{
print "Не указан идентификатор.";
}
else if ( $sub == "add2" )
{
if ( !( $r = @mysql_query( @"select * from addons where name='{$name}' or textid='{$textid}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
print "Дополнительная услуга уже присутствует в базе.";
}
else
{
if ( !@mysql_query( @"insert into addons (name,textid,cost_start,cost_monthly,unlimforoneorder,active) values('{$name}','{$textid}','{$cost_start}','{$cost_monthly}','{$unlimforoneorder}','{$active}')" ) )
{
exit( mysql_error( ) );
}
print "Дополнительная услуга <B>{$textid}</b> успешно добавлена.";
$sub2 = "";
}
}
else if ( $sub == "edit2" )
{
if ( $id )
{
if ( !@mysql_query( @"update addons set name='{$name}',textid='{$textid}',cost_start='{$cost_start}',cost_monthly='{$cost_monthly}',unlimforoneorder='{$unlimforoneorder}',active='{$active}' where id='{$id}'" ) )
{
exit( mysql_error( ) );
}
print "Допонлительная услуга <B>{$textid}</b> успешно изменена.";
$sub2 = "";
}
else
{
print "Утерян идентификатор.";
$sub2 = "";
}
}
if ( $sub2 )
{
print "<BR><BR>";
$sub = $sub2;
}
else
{
$sub = "";
}
}
if ( $sub == "delete" )
{
if ( $id )
{
if ( !@mysql_query( @"delete from addons where id='{$id}'" ) )
{
exit( mysql_error( ) );
}
print "Дополнительная услуга успешно удалена.";
}
else
{
print "Утерян идентификатор.";
}
}
if ( $sub == "add" || $sub == "edit" )
{
$button = "Добавить";
if ( $sub == "edit" )
{
if ( !( $r = @mysql_query( @"select * from addons where id='{$id}'" ) ) )
{
exit( mysql_error( ) );
}
$r = mysql_fetch_object( $r );
$name = $r->name;
$textid = $r->textid;
$cost_start = $r->cost_start;
$cost_monthly = $r->cost_monthly;
$unlimforoneorder = $r->unlimforoneorder;
$active = $r->active;
$button = "Изменить";
}
echo " <form method=post>rn <input type=hidden name=do value=";
echo $do;
echo ">rn <input type=hidden name=sub value=";
echo $sub;
echo "2>rn <input type=hidden name=id value=";
echo $id;
echo ">rn <table>rn <tr><td colspan=3 align=center bgcolor=#EAEAEA><B>Добавление дополнительной услуги</b></td></tr>rn <tr><td>Название:</td><td colspan=2><input type=text size=30 name=name value="";
echo $name;
echo ""></td></tr>rn <tr><td>Идентификатор:</td><td><input type=text size=15 name=textid value="";
echo $textid;
echo ""></td><td>идентификатор будет отображаться на странице заказов</td></tr>rn <tr><td><nobr>Цена, $ (разовая):</nobr></td><td><input type=text size=5 name=cost_start value=";
echo $cost_start;
echo "></td><td>данная сумма взымается при первичном заказе услуги. Если так же указана ежемесячная цена, то при первичном заказе они будут просуммированы.</td></tr>rn <tr><td><nobr>Цена, $ (ежемесячная):</nobr></td><td><input type=text size=5 name=cost_monthly value=";
echo $cost_monthly;
echo "></td><td>данная сумма взымается ежемесячно.</td></tr>rn <tr><td>Неограничено:</td><td><input type=checkbox name=unlimforoneorder ";
if ( $unlimforoneorder )
{
print "checked";
}
echo " value=1></td><td>если выбрано, то можно заказывать услугу неограниченное количество раз для одного заказа. Иначе только один раз.</td></tr>rn <tr><td>Услуга активна:</td><td><input type=checkbox name=active ";
if ( $active )
{
print "checked";
}
echo " value=1></td><td>клиент может заказать услугу только если она активна</td></tr>rn <tr><Td colspan=3 align=center><BR><input type=submit value=";
echo $button;
echo "></td></tr>rn </table>rn </form>rn ";
}
if ( $sub == "list" )
{
if ( !( $r = @mysql_query( "select * from addons order by textid" ) ) )
{
exit( mysql_error( ) );
}
echo " <table cellpadding=3 width=95%>rn <tr><td colspan=7 align=center bgcolor=";
echo $font_head;
echo "><B>Дополнительные услуги</b></td></tr>rn <tr bgcolor=";
echo $font_head;
echo "><td align=center>ID</td><td align=center>Название</td><td align=center>Цена, $<BR>(разовая)</td><Td align=center>Цена, $<BR>(ежемесячная)</td><Td align=center>Неограничено</td><Td align=center>Активность</td><td></td></tr>rn ";
$cnt = 0;
while ( $rr = mysql_fetch_object( $r ) )
{
getfont( );
print "rn <tr bgcolor={$font_row}>rn <td>{$rr->textid}</td>rn <td>{$rr->name}</td>rn <Td align=center>{$rr->cost_start}</td>rn <td align=center>{$rr->cost_monthly}</td>rn <td align=center>".$_yes[$rr->unlimforoneorder]."</td>rn <td align=center>".$_yes[$rr->active]."</td>rn <Td align=center><A href=?do={$do}&sub=edit&id={$rr->id}><img src=./_rootimages/edit.gif alt=Изменить title=Изменить border=0></a><A href=?do={$do}&sub=delete&id={$rr->id}&zone={$rr->zone} onclick="javascript: return confirm('Вы уверены, что хотите удалить дополнительную услугу?');"><img src=./_rootimages/del.gif alt=Удалить title=Удалить border=0></a></td>rn </tr>rn ";
++$cnt;
}
echo " <tr bgcolor=";
echo $font_head;
echo "><Td colspan=7>Всего дополнительных услуг: ";
echo $cnt;
echo "</td></tr>rn </table>rn ";
}
}
if ( $do == "settings" )
{
if ( !$sub )
{
$sub = "params";
}
if ( $sub == "saveparams" )
{
setsetting( "company_name", $company_name );
setsetting( "company_url", $company_url );
setsetting( "billing_url", $billing_url );
setsetting( "support_url", $support_url );
setsetting( "manager_email", $manager_email );
setsetting( "perpage_bills", $perpage_bills );
setsetting( "perpage_orders", $perpage_orders );
setsetting( "perpage_clients", $perpage_clients );
setsetting( "whoistype", $whoistype );
setsetting( "da_user", $da_user );
setsetting( "da_password", $da_password );
setsetting( "da_ip", $da_ip );
setsetting( "da_user_ip", $da_user_ip );
setsetting( "cpanel_user", $cpanel_user );
setsetting( "cpanel_password", $cpanel_password );
setsetting( "cpanel_ip", $cpanel_ip );
setsetting( "cpanel_ns1", $cpanel_ns1 );
setsetting( "cpanel_ns2", $cpanel_ns2 );
print "Данные успешно сохранены.<BR><BR>";
$sub = "params";
}
if ( $sub == "params" )
{
$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" );
$perpage_bills = getsetting( "perpage_bills" );
$perpage_orders = getsetting( "perpage_orders" );
$perpage_clients = getsetting( "perpage_clients" );
$whoistype = getsetting( "whoistype" );
$da_user = getsetting( "da_user" );
$da_password = getsetting( "da_password" );
$da_ip = getsetting( "da_ip" );
$da_user_ip = getsetting( "da_user_ip" );
$cpanel_user = getsetting( "cpanel_user" );
$cpanel_password = getsetting( "cpanel_password" );
$cpanel_ip = getsetting( "cpanel_ip" );
$cpanel_ns1 = getsetting( "cpanel_ns1" );
$cpanel_ns2 = getsetting( "cpanel_ns2" );
echo "tt<form method=post>rntt<input type=hidden name=do value=";
echo $do;
echo ">rntt<input type=hidden name=sub value=saveparams>rntt<table>rntt<tr><Td valign=top>rnttt<table>rnttt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Ваши данные</b></td></tr>rnttt<tr><td>Название компании:</td><Td><input type=text name=company_name size=40 value="";
echo $company_name;
echo ""></td></tr>rnttt<tr><td>Адрес сайта:</td><Td><input type=text name=company_url size=40 value="";
echo $company_url;
echo ""></td></tr>rnttt<tr><td>Адрес биллинга:</td><Td><input type=text name=billing_url size=40 value="";
echo $billing_url;
echo ""></td></tr>rnttt<tr><td>Адрес службы поддержки:</td><Td><input type=text name=support_url size=40 value="";
echo $support_url;
echo ""></td></tr>rnttt<tr><td>E-Mail менеджера:</td><Td><input type=text name=manager_email size=40 value="";
echo $manager_email;
echo ""></td></tr>rnttt</table>rntt</td><td width=20> </td><Td valign=top>rnttt<table>rnttt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Визуальные настройки</b></td></tr>rnttt<tr><td>Записей на странице счетов:</td><Td align=left><input type=text name=perpage_bills size=5 value="";
echo $perpage_bills;
echo ""></td></tr>rnttt<tr><td>Записей на странице заказов:</td><Td align=left><input type=text name=perpage_orders size=5 value="";
echo $perpage_orders;
echo ""></td></tr>rnttt<tr><td>Записей на странице клиентов:</td><Td align=left><input type=text name=perpage_clients size=5 value="";
echo $perpage_clients;
echo ""></td></tr>rnttt<tr><td>Вид WHOIS:</td><Td align=left>";
echo "<s";
echo "elect name=whoistype><option value=check ";
if ( $whoistype == "check" )
{
print "selected";
}
echo ">Чекбоксы<option value=select ";
if ( $whoistype == "select" )
{
print "selected";
}
echo ">Выпадающий список</select></td></tr>rnttt</table>rntt</td></tr>rntt<tr><td valign=top>rnttrntt</td><td></td><td valign=top>rnttt<table>rnttt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Настройки DirectAdmin</b></td></tr>rnttt<tr><td>DA ip:</td><Td align=left><input type=text name=da_ip size=20 value="";
echo $da_ip;
echo ""></td></tr>rnttt<tr><td>DA user:</td><Td align=left><input type=text name=da_user size=20 value="";
echo $da_user;
echo ""></td></tr>rnttt<tr><td>DA password:</td><Td align=left><input type=text name=da_password size=20 value="";
echo $da_password;
echo ""></td></tr>rnttt<tr><td>IP для новых пользователей:</td><Td align=left><input type=text name=da_user_ip size=20 value="";
echo $da_user_ip;
echo ""></td></tr>rnttt</table><br><br>rntttrnttt<table>rnttt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Настройки cPanel</b></td></tr>rnttt<tr><td>cPanel ip:</td><Td align=left><input type=text name=cpanel_ip size=20 value="";
echo $cpanel_ip;
echo ""></td></tr>rnttt<tr><td>cPanel user:</td><Td align=left><input type=text name=cpanel_user size=20 value="";
echo $cpanel_user;
echo ""></td></tr>rnttt<tr><td>cPanel password:</td><Td align=left><input type=text name=cpanel_password size=20 value="";
echo $cpanel_password;
echo ""></td></tr>rnttt<tr><td>cPanel NS1:</td><Td align=left><input type=text name=cpanel_ns1 size=20 value="";
echo $cpanel_ns1;
echo ""></td></tr>rnttt<tr><td>cPanel NS2:</td><Td align=left><input type=text name=cpanel_ns2 size=20 value="";
echo $cpanel_ns2;
echo ""></td></tr>rnttt</table>rnrntt</td></tr>rntt<tr><Td colspan=3 align=center><BR><input type=submit value=Сохранить></td></tr>rntt</table>rntt</form>rntt";
}
if ( $sub == "savemoney" )
{
setsetting( "wmz", $wmz );
setsetting( "wmr", $wmr );
setsetting( "wme", $wme );
setsetting( "yandex", $yandex );
setsetting( "egold", $egold );
setsetting( "egold_pass", $egold_pass );
setsetting( "rupay", $rupay );
setsetting( "rupayschet", $rupayschet );
setsetting( "rupaysecret", $rupaysecret );
setsetting( "kurs_rur", $kurs_rur );
setsetting( "kurs_uah", $kurs_uah );
setsetting( "kurs_eur", $kurs_eur );
setsetting( "payment_url", $payment_url );
setsetting( "nopayment_url", $nopayment_url );
print "Данные успешно сохранены.<BR><BR>";
$sub = "money";
}
if ( $sub == "money" )
{
$wmz = getsetting( "wmz" );
$wmr = getsetting( "wmr" );
$wme = getsetting( "wme" );
$yandex = getsetting( "yandex" );
$egold = getsetting( "egold" );
$egold_pass = getsetting( "egold_pass" );
$rupay = getsetting( "rupay" );
$rupayschet = getsetting( "rupayschet" );
$rupaysecret = getsetting( "rupaysecret" );
$kurs_rur = getsetting( "kurs_rur" );
$kurs_uah = getsetting( "kurs_uah" );
$kurs_eur = getsetting( "kurs_eur" );
$payment_url = getsetting( "payment_url" );
$nopayment_url = getsetting( "nopayment_url" );
echo "tt<form method=post>rntt<input type=hidden name=do value=";
echo $do;
echo ">rntt<input type=hidden name=sub value=savemoney>rntt<table>rntt<tr><Td valign=top>rnttt<table width=470>rnttt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Настройки приема он-лайн платежей</b></td></tr>rnttt<tr><td>WebMoney (WMZ):</td><Td align=right><input type=text name=wmz size=40 value="";
echo $wmz;
echo ""></td></tr>rnttt<tr><td>WebMoney (WMR):</td><Td align=right><input type=text name=wmr size=40 value="";
echo $wmr;
echo ""></td></tr>rnttt<tr><td>WebMoney (WME):</td><Td align=right><input type=text name=wme size=40 value="";
echo $wme;
echo ""></td></tr>rnttt<tr><td>Яndex.Деньги (счет):</td><Td align=right><input type=text name=yandex size=40 value="";
echo $yandex;
echo ""></td></tr>rnttt<tr><td>E-gold (аккаунт):</td><Td align=right><input type=text name=egold size=40 value="";
echo $egold;
echo ""></td></tr>rnttt<tr><td>E-gold (alternate passphrase):</td><Td align=right><input type=text name=egold_pass size=40 value="";
echo $egold_pass;
echo ""></td></tr>rnttt<tr><td>RuPay (счет):</td><Td align=right><input type=text name=rupayschet size=40 value="";
echo $rupayschet;
echo ""></td></tr>rnttt<tr><td>RuPay (ID сайта):</td><Td align=right><input type=text name=rupay size=40 value="";
echo $rupay;
echo ""></td></tr>rnttt<tr><td>RuPay (секретный ключ):</td><Td align=right><input type=text name=rupaysecret size=40 value="";
echo $rupaysecret;
echo ""></td></tr>rnttt<tr><td><BR>Адрес при удачной оплате:</td><Td align=right><BR><input type=text name=payment_url size=40 value="";
echo $payment_url;
echo ""></td></tr>rnttt<tr><td>Адрес при неудачной оплате:</td><Td align=right><input type=text name=nopayment_url size=40 value="";
echo $nopayment_url;
echo ""></td></tr>rnttt</table>rntt</td><td width=20> </td><Td valign=top>rnttt<table>rnttt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Курсы валют за 1$</b></td></tr>rnttt<tr><td>Рубли:</td><Td align=left><input type=text name=kurs_rur size=10 value="";
echo $kurs_rur;
echo ""></td></tr>rnttt<tr><td>Гривны:</td><Td align=left><input type=text name=kurs_uah size=10 value="";
echo $kurs_uah;
echo ""></td></tr>rnttt<tr><td>Евро:</td><Td align=left><input type=text name=kurs_eur size=10 value="";
echo $kurs_eur;
echo ""></td></tr>rnttt</table>rntt</td></tr>rntt<tr><Td colspan=3 align=center><BR><input type=submit value=Сохранить></td></tr>rntt</table>rntt</form>rntt";
}
if ( $sub == "savetemplate" )
{
if ( !$id )
{
print "Утерян идентификатор шаблона.";
}
else
{
$template = addslashes( $template );
if ( !@mysql_query( @"update templates set template='{$template}' where param='{$id}'" ) )
{
exit( mysql_error( ) );
}
print "Шаблон успешно сохранен.";
}
print "<BR><BR>";
$sub = "templates";
}
if ( $sub == "templates" )
{
if ( $id )
{
if ( !( $r = @mysql_query( @"select * from templates where param='{$id}'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
$rr = mysql_fetch_object( $r );
$rr->description = stripslashes( $rr->description );
print "rntttt<form method=post>rntttt<input type=hidden name=do value={$do}>rntttt<input type=hidden name=sub value=savetemplate>rntttt<input type=hidden name=id value={$rr->param}>rntttt<table width=80%>rntttt<tr><td colspan=2 bgcolor={$font_head} align=left><B>{$rr->description}</b></td></tr>rntttt<tr bgcolor={$font_row}>rntttt<td width=100%><textarea name=template style='width: 100%; height: 250'>{$rr->template}</textarea></td>rntttt<td valign=middle><input type=submit value=Сохранить></td>rntttt</tr>rntttt</table>rntttt</form>rntttt<BR>rntttt";
}
}
else
{
if ( !( $r = @mysql_query( "select * from templates order by param" ) ) )
{
exit( mysql_error( ) );
}
print "<table><tr><td><B>Выберите шаблон, который Вы хотите отредактировать:</b><BR><BR>";
$i = 0;
while ( $rr = mysql_fetch_object( $r ) )
{
++$i;
print "{$i}. <A href=?do={$do}&sub=templates&id={$rr->param}>{$rr->description}</a><BR>";
}
print "</td></tr></table>";
}
}
if ( $sub == "savepassword" )
{
$adminCryptPassword = getsetting( "admin_password" );
if ( $old_pass == "" )
{
print "Не указан старый пароль.<BR><BR>";
$sub = "password";
}
else if ( crypt( $old_pass, $adminCryptPassword ) != $adminCryptPassword )
{
print "Старый пароль указан неверно.<BR><BR>";
$sub = "password";
}
else if ( $new_pass == "" )
{
print "Не указан новый пароль.<BR><BR>";
$sub = "password";
}
else if ( $new_pass2 == "" )
{
print "Не подтверждён пароль.<BR><BR>";
$sub = "password";
}
else if ( $new_pass != $new_pass2 )
{
print "Пароль подтверждён неправильно.<BR><BR>";
$sub = "password";
}
else if ( strlen( $new_pass ) < 6 )
{
print "Парольне не может быть короче 6 символов.<BR><BR>";
$sub = "password";
}
else
{
setsetting( "admin_password", crypt( $new_pass ) );
print "Пароль администратора успешно изменён.<BR>Необходимо будет повторно пройти аутентификацию.";
adminlogout( );
}
}
if ( $sub == "password" )
{
echo "tt<form method=post>rntt<input type=hidden name=do value=";
echo $do;
echo ">rntt<input type=hidden name=sub value=savepassword>rntt<table>rntt<tr><td colspan=2 bgcolor=";
echo $font_head;
echo " align=center><B>Изменение пароля администратора</b></td></tr>rntt<tr><td>Логин:</td><td><input type=text value=";
echo getsetting( "admin_login" );
echo " readonly size=30></td></tr>rntt<tr><td>Старый пароль:</td><td><input type=password name=old_pass size=30></td></tr>rntt<tr><td><BR>Новый пароль:</td><td><BR><input type=password name=new_pass size=30></td></tr>rntt<tr><td>Еще раз пароль:</td><td><input type=password name=new_pass2 size=30></td></tr>rntt<tr><td align=center colspan=2><BR><input type=submit value=Сохранить></td></tr>rntt<tr><td colspan=2><BR>* Длина пароля должна б";
echo "ыть не менее 6 символов.</td></tr>rntt</tr>rntt</table>rntt</form>rntt";
}
}
if ( $do == "utils" )
{
if ( $sub == "saveorder" )
{
if ( $newUser && !$newLogin )
{
$error = "Не указан логин.";
}
else if ( $newUser && eregi( "^[0-9]", $newLogin ) )
{
$error = "Логин должен начинаться с a-z";
}
else if ( $newUser && eregi( "[^a-z,0-9]", $newLogin ) )
{
$error = "Логин должен состоять из сиволов a-z,0-9";
}
else if ( $newUser && ( strlen( $newLogin ) < 3 || 10 < strlen( $newLogin ) ) )
{
$error = "Длина логина должна быть от 3 до 10 символов.";
}
else if ( $newUser && isloginexists( $newLogin ) )
{
$error = "Указанный логин уже существует.";
}
else if ( $newUser && !$newPassword )
{
$error = "Не указан пароль.";
}
else if ( $newUser && strlen( $newPassword ) < 6 )
{
$error = "Длина пароля не должна быть менее 6 символов.";
}
else if ( $newUser && !valid_email( $newEmail ) )
{
$error = "Указан неправильный e-mail адрес.";
}
else if ( !$newUser && !$userName )
{
$error = "Не указан логин.";
}
else if ( ( $domain_reg == "0" || $domain_reg == "1" ) && !$tarif_id )
{
$error = "Не выбран тарифный план.";
}
else if ( ( !$domain || !$zone ) && !$otherdomain )
{
$error = "Не указано доменное имя.";
}
else if ( !$orderDate )
{
$error = "Не указана дата оформления заказа.";
}
else if ( ( $domain_reg == "0" || $domain_reg == "1" ) && !$hostToDate )
{
$error = "Не указано до когда оплачен хостинг.";
}
else
{
if ( ( $domain_reg == "1" || $domain_reg == "2" ) && !$domainToDate )
{
$error = "Не указано до когда оплачен домен.";
}
else
{
if ( $domain && $zone )
{
$fulldomain = $domain.".".$zone;
}
else
{
$fulldomain = $otherdomain;
}
if ( !( $r = @mysql_query( @"select * from orders where domain='{$fulldomain}' and domain_reg='0' and todate>NOW()" ) ) )
{
exit( mysql_error( ) );
}
if ( !( $k = @mysql_query( @"select * from orders_domains where domain='{$fulldomain}' and todate>NOW()" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
$error = "Тарифный план для указанного доменного имени уже заказан другим клиентом.";
$do = "";
}
else
{
if ( 0 < mysql_num_rows( $k ) )
{
$error = "Указанное доменное имя уже заказано другим клиентом.";
$do = "";
}
else
{
if ( $newUser )
{
if ( !mysql_query( "insert into users (login,password,email,datareg) values('{$newLogin}','".crypt( $newPassword )."','{$newEmail}',NOW())" ) )
{
exit( mysql_error( ) );
}
$userId = mysql_insert_id( );
if ( !mysql_query( "insert into users_profile (uid) values('{$userId}')" ) )
{
exit( mysql_error( ) );
}
}
else
{
if ( !( $r = @mysql_query( @"select * from users where login='{$userName}'" ) ) )
{
exit( mysql_error( ) );
}
$r = mysql_fetch_object( $r );
$userId = $r->id;
}
$host_id = 0;
if ( $domain_reg == "0" || $domain_reg == "1" )
{
$addonsToSave = "";
$v = each( @$addons )[1];
$k = each( @$addons )[0];
while ( @each( @$addons ) )
{
if ( $v )
{
$selectedAddon = getaddonbyid( $v );
$addonsToSave = $addonsToSave.":x:{$selectedAddon->id}";
}
}
if ( !@mysql_query( @"insert into orders (uid,tarif,domain,domain_reg,addons,orderdate,startdate,todate,status) values('{$userId}','{$tarif_id}','{$fulldomain}','{$domain_reg}','{$addonsToSave}','".@frommydate( @$orderDate )."','".@frommydate( @$orderDate )."','".@frommydate( @$hostToDate )."','1')" ) )
{
exit( mysql_error( ) );
}
$host_id = mysql_insert_id( );
}
if ( $domain_reg == "1" || $domain_reg == "2" )
{
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,host_id,domain,orderdate,startdate,todate,status) values ('{$userId}','{$zid}','{$host_id}','{$fulldomain}','".@frommydate( @$orderDate )."','".@frommydate( @$orderDate )."','".@frommydate( @$domainToDate )."','1')" ) )
{
exit( mysql_error( ) );
}
}
print "Данные успешно добавлены.<BR><BR><A href=?do=utils&sub=addorder>Добавить ещё</a>";
}
}
}
}
if ( $error )
{
$sub = "addorder";
}
}
if ( $sub == "addorder" )
{
if ( $error )
{
print "<font color=red><B>Ошибка:</b> {$error}</font><BR><BR>";
}
if ( !$domain_reg )
{
$domain_reg = 0;
}
echo "ttrntt";
echo "<s";
echo "cript language=javascript type='text/javascript'>rntrnttfunction showdiv(divid) {rntttif (document.getElementById) { // DOM3 = IE5, NS6rnttttdocument.getElementById(divid).style.display = 'block';rnttt}rntttelse {rnttttif (document.layers) { // Netscape 4rntttttdocument.divid.display = 'block';rntttt}rnttttelse { // IE 4rntttttdocument.all.divid.style.display = 'block';rntttt}rnttt}rntt}rnrnttfunc";
echo "tion hidediv(divid) {rntttif (document.getElementById) { // DOM3 = IE5, NS6rnttttdocument.getElementById(divid).style.display = 'none';rnttt}rntttelse {rnttttif (document.layers) { // Netscape 4rntttttdocument.divid.display = 'none';rntttt}rnttttelse { // IE 4rntttttdocument.all.divid.style.display = 'none';rntttt}rnttt}rntt}rntt</script>rntrnttrntt<form method=post>rntt<input type=hidden name=do val";
echo "ue=";
echo $do;
echo ">rntt<input type=hidden name=sub value=saveorder>rntt<table border=0>rntt<tr><td colspan=2 bgcolor=";
echo $font_head;
echo " align=center><B>Добавление заказа</b></td></tr>rntt<tr><td width=130>Клиент:</td><td nowrap><input type=radio name=newUser value=0 ";
if ( !$newUser )
{
print "checked";
}
echo " onclick="hidediv('newuserdiv'); showdiv('olduserdiv');"> существующий клиент <input type=radio name=newUser value=1 ";
if ( $newUser )
{
print "checked";
}
echo " onclick="hidediv('olduserdiv'); showdiv('newuserdiv');"> новый клиент</td></tr>rntt<tr>rntt <td> </td>rntt <td>rntt <div id="olduserdiv" style="display: ";
if ( !$newUser )
{
print "block;";
}
else
{
print "none;";
}
echo "">логин: rntt ";
$usersLogins = getuserslogins( );
if ( 0 < count( $usersLogins ) )
{
print "<select name=userName><option>";
$value = each( $usersLogins )[1];
$key = each( $usersLogins )[0];
while ( each( $usersLogins ) )
{
if ( $userName == $value )
{
$userSelected = "selected";
}
else
{
$userSelected = "";
}
print "<option value={$value} {$userSelected}>{$value}";
}
print "</select>";
}
else
{
print "нет зарегистрированных клиентов";
}
echo "tt </div>rntt <div id="newuserdiv" style="display: ";
if ( $newUser )
{
print "block;";
}
else
{
print "none;";
}
echo "">rntt <table>rntt <tr><td>логин:</td><td><input type=text name=newLogin value="";
echo $newLogin;
echo "" size=30></td></tr>rntt <tr><td>пароль:</td><td><input type=text name=newPassword value="";
echo $newPassword;
echo "" size=30></td></tr>rntt <tr><td>e-mail:</td><td><input type=text name=newEmail value="";
echo $newEmail;
echo "" size=30></td></tr>rntt </table>rntt </div>rntt </td>rntt</tr>rntt<tr>rntt <td valign=top><BR>Хостинг:</td>rntt <Td>rntt <BR><input type=radio onclick="this.form.otherdomain.disabled=0; this.form.tarif_id.disabled=0; this.form.hostToDate.disabled=0; this.form.domainToDate.disabled=1;" name=domain_reg value=0 ";
if ( !$domain_reg )
{
print "checked";
}
echo ">с переносом домена<BR>rntt <input type=radio onclick="this.form.otherdomain.disabled=1; this.form.tarif_id.disabled=0; this.form.hostToDate.disabled=0; this.form.domainToDate.disabled=0;" name=domain_reg value=1 ";
if ( $domain_reg == "1" )
{
print "checked";
}
echo ">с регистрацией нового<BR>rntt <input type=radio onclick="this.form.otherdomain.disabled=1; this.form.tarif_id.disabled=1; this.form.hostToDate.disabled=1; this.form.domainToDate.disabled=0;" name=domain_reg value=2 ";
if ( $domain_reg == "2" )
{
print "checked";
}
echo ">только домен<BR>rntt </td>rntt</tr>rntt<tr>rntt <td valign=top><BR>Тарифный план:</td>rntt <td>rntt <BR>";
echo "<s";
echo "elect name=tarif_id><option>rntt ";
if ( !( $r = @mysql_query( "select * from tarifs order by id" ) ) )
{
exit( mysql_error( ) );
}
while ( $rr = mysql_fetch_object( $r ) )
{
if ( $tarif_id == $rr->id )
{
$tarifSelected = "selected";
}
else
{
$tarifSelected = "";
}
print "<option value={$rr->id} {$tarifSelected}>{$rr->name}<BR>";
}
echo "tt </select>rntt </td>rntt</tr>rntt<tr>rntt <td><BR>Домен:</td>rntt <td>rntt <BR><input type="text" name="domain" value="";
echo $domain;
echo ""> ";
echo "<s";
echo "elect name="zone"><option>rntt ";
if ( !( $r = @mysql_query( "select * from zones order by zone" ) ) )
{
exit( mysql_error( ) );
}
while ( $rr = mysql_fetch_object( $r ) )
{
if ( $rr->zone == $zone )
{
$zoneSelected = "selected";
}
else
{
$zoneSelected = "";
}
print "<option value={$rr->zone} {$zoneSelected}>.{$rr->zone}";
}
echo "tt </select>rntt </td>rntt</tr>rntt<tr id="otherdomaindiv"><td> </td><td>домен в другой зоне (example.com):<BR><input type="text" name="otherdomain" value="";
echo $otherdomain;
echo "" size=30></td></tr>rntt<tr><td><BR>Дата заказа:</td><td><BR><input type=text name=orderDate size=10 value="";
if ( !$orderDate )
{
print datenow( );
}
else
{
print $orderDate;
}
echo ""></td></tr>rntt<tr><td>Хостинг оплачен до:</td><td><input type=text name=hostToDate size=10 value="";
if ( !$hostToDate )
{
print datenow( );
}
else
{
print $hostToDate;
}
echo ""></td></tr>rntt<tr><td>Домен оплачен до:</td><td><input type=text name=domainToDate size=10 value="";
if ( !$domainToDate )
{
print datenow( );
}
else
{
print $domainToDate;
}
echo "" disabled></td></tr>rntt<tr><td><BR>Доп. услуги:</td><Td><BR>rntt";
$alladdons = getaddons( );
if ( 0 < @mysql_num_rows( @$alladdons ) )
{
$i = 0;
while ( $addon = mysql_fetch_object( $alladdons ) )
{
if ( $addons[$i] == $addon->id )
{
$addonSelected = "checked";
}
else
{
$addonSelected = "";
}
print "<input type=checkbox name=addons[] value={$addon->id} {$addonSelected}>{$addon->name}<BR>";
++$i;
}
}
else
{
print "нет";
}
echo "tt</td></tr>rntt<tr><td colspan=2 align=center><BR><input type=submit value=Добавить></td></tr>rntt</table>rntt</form>rntt";
echo "<s";
echo "cript>rntteval(document.forms[0].domain_reg[";
echo $domain_reg;
echo "].onclick());rntt</script>rntt";
}
}
if ( $do == "history" )
{
$user = getuserbyid( $uid );
if ( !$user )
{
$user = getuserbylogin( $uid );
}
if ( $user )
{
print menu_admin_client( $user->id );
if ( !( $r = @mysql_query( @"select * from users_logs where uid='{$user->id}' order by dt" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
echo " t<table cellpadding=3 width=95%>rn t<tr><td colspan=3 align=center bgcolor=";
echo $font_head;
echo "><B>История клиента [";
echo $user->login;
echo "]</b></td></tr>rn <tr bgcolor=";
echo $font_head;
echo "><td align=center>дата</td><td align=center>операция</td><td align=center>комментарий</td></tr>rn ";
$cnt = 0;
while ( $rr = mysql_fetch_object( $r ) )
{
getfont( );
print "rn <tr bgcolor={$font_row}>rn <td align=center>{$rr->dt}</td>rn <td align=center>{$rr->operation}</td>rn <Td>{$rr->comment}</td>rn </tr>rn ";
++$cnt;
}
echo " <tr bgcolor=";
echo $font_head;
echo "><Td colspan=8>Всего записей: ";
echo $cnt;
echo "</td></tr>rn </table>rn ";
}
else
{
print "Нет записей для клиента {$user->login}";
}
}
else
{
print "Клиент не найден.";
}
}
if ( $do == "news" )
{
print "[ <B><A href=?do={$do}&sub=list>список новостей</a></B> - <B><A href=?do={$do}&sub=add>добавить новость</a></B> ]<BR><BR>";
if ( !$sub )
{
$sub = "list";
}
if ( $sub == "delete" && $id )
{
if ( !@mysql_query( @"delete from news where id='{$id}'" ) )
{
exit( mysql_error( ) );
}
print "Новость успешно удалена.<BR><BR>";
$sub = "list";
}
if ( $sub == "add2" || $sub == "edit2" )
{
if ( $sub == "add2" )
{
$sub2 = "add";
}
if ( $sub == "edit2" )
{
$sub2 = "edit";
}
if ( !$title )
{
print "Не указан заголовок новости.";
}
else if ( !$content )
{
print "Не указан текст новости.";
}
else
{
if ( $sub == "edit2" && !$data )
{
print "Не указана дата.";
}
else
{
if ( $sub == "add2" )
{
if ( !@mysql_query( @"insert into news (data,title,content) values(NOW(),'".@addslashes( @$title )."','".@addslashes( @$content )."')" ) )
{
exit( mysql_error( ) );
}
print "Новость успешно добавлена.";
$sub2 = "";
}
else if ( $sub == "edit2" )
{
if ( $id )
{
if ( !@mysql_query( @"update news set data='".@frommydate( @$data )."',title='".@addslashes( @$title )."',content='".@addslashes( @$content ).@"' where id={$id}" ) )
{
exit( mysql_error( ) );
}
print "Новость успешно изменена.<BR><BR>";
$sub2 = "list";
}
else
{
print "Утерян идентификатор новости.<BR><BR>";
$sub2 = "list";
}
}
if ( $sub2 )
{
print "<BR><BR>";
$sub = $sub2;
}
else
{
$sub = "";
}
}
}
}
if ( $sub == "add" || $sub == "edit" )
{
$button = "Добавить";
$text = "Добавление";
if ( $sub == "edit" )
{
if ( !( $r = @mysql_query( @"select * from news where id={$id}" ) ) )
{
exit( mysql_error( ) );
}
$r = mysql_fetch_object( $r );
$data = $r->data;
$title = stripslashes( $r->title );
$content = stripslashes( $r->content );
$button = "Изменить";
$text = "Редактирование";
}
echo "tt<form method=post>rntt<input type=hidden name=do value=";
echo $do;
echo ">rntt<input type=hidden name=sub value=";
echo $sub;
echo "2>rntt<input type=hidden name=id value=";
echo $id;
echo ">rntt<table>rntt<tr><td colspan=2 align=center bgcolor=#EAEAEA><B>";
echo $text;
echo " новости</b></td></tr>rntt";
if ( $sub == "edit" )
{
print "<tr><td>Дата:</td><td><input type=text size=20 name=data value='".mydate( $data )."'></td></tr>";
}
echo "tt<tr><td>Заголовок:</td><td><input type=text size=53 name=title value="";
echo $title;
echo ""></td></tr>rntt<tr><td valign=top>Новость:</td><td><textarea name=content cols=40 rows=5>";
echo $content;
echo "</textarea></td></tr>rntt<tr><Td colspan=2 align=center><BR><input type=submit value=";
echo $button;
echo "></td></tr>rntt</table>rntt</form>rntt";
}
if ( $sub == "list" )
{
$r = getnews( );
echo "tt<table cellpadding=3 width=95%>rntt<tr><td colspan=3 align=center bgcolor=";
echo $font_head;
echo "><B>Новости</b></td></tr>rntt<tr bgcolor=";
echo $font_head;
echo "><td align=center width=120>Дата</td><td align=center>Заголовок</td><td width=100 align=center>Операция</td></tr>rntt";
$cnt = 0;
while ( $rr = @mysql_fetch_object( @$r ) )
{
getfont( );
print "rnttt<tr bgcolor={$font_row}>rnttt<td align=center>".mydate( $rr->data )."</td>rnttt<td>{$rr->title}</td>rnttt<Td align=center><A href=?do={$do}&sub=edit&id={$rr->id}><img src=./_rootimages/edit.gif alt=Изменить title=Изменить border=0></a><A href=?do={$do}&sub=delete&id={$rr->id} onclick="javascript: return confirm('Вы уверены, что хотите удалить новость?');"><img src=./_rootimages/del.gif alt=Удалить title=Удалить border=0></a></td>rnttt</tr>rnttt";
++$cnt;
}
echo "tt<tr bgcolor=";
echo $font_head;
echo "><Td colspan=3>Всего новостей: ";
echo $cnt;
echo "</td></tr>rntt</table>rntt";
}
}
if ( $do == "fullinfo" )
{
$u = getuserbyid( $id );
if ( !$u )
{
$u = getuserbylogin( $id );
}
if ( $u )
{
print menu_admin_client( $u->id );
if ( $sub == "savepassword" && $newpassword )
{
if ( !@mysql_query( @"UPDATE users SET password = '".@crypt( @$newpassword ).@"' WHERE id='{$id}'" ) )
{
exit( mysql_error( ) );
}
print "Пароль успешно изменён.<BR><BR>";
}
if ( $sub == "makebill" && 0 < $money )
{
if ( !@mysql_query( @"insert into bills (uid,host_id,domain_id,host_srok,domain_srok,money_host,money_domain,money_addons,created) values('".$id.@"','0','0','0','0','0','0','{$money}',NOW())" ) )
{
exit( mysql_error( ) );
}
print "Счет успешно выставлен.<BR><BR>";
}
getfont( );
if ( !( $o = @mysql_query( @"select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders where uid='{$u->id}'" ) ) )
{
exit( mysql_error( ) );
}
if ( !( $od = @mysql_query( @"select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders_domains where uid='{$u->id}'" ) ) )
{
exit( mysql_error( ) );
}
echo "tt<table width=80%>rnttrntt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Информация по клиенту</B></td></tr>rntt<tr width=50% bgcolor=";
echo $font_row;
echo "><td align=right>ID клиента: </td><td width=50%><input type=text readonly size=6 value=";
echo $u->id;
echo "></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo "><td align=right>Логин: </td><td><input type=text readonly size=25 value=";
echo $u->login;
echo "></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo "><td align=right>Пароль: </td><td><form method=post><input type=hidden name=id value=";
echo $u->id;
echo "><input type=hidden name=do value=fullinfo><input type=hidden name=sub value=savepassword><input type=password name=newpassword size=25> <input type=submit value="изменить"></form></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo "><td align=right><A href="mailto:";
echo $u->email;
echo "">E-Mail</a>: </td><td><input type=text readonly size=25 value=";
echo $u->email;
echo "></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo "><td colspan=2> </td></tr>rnrntt<tr bgcolor=";
echo $font_head;
echo "><td align=right><A href=?do=profile&id=";
echo $u->id;
echo " target=_blank><img src=./_rootimages/profile.gif border=0></a>Профайл клиента: </td><td><form method=post action=?do=profile&id=";
echo $u->id;
echo " target=_blank><input type=submit value=редактировать></form></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo "><td colspan=2> </td></tr>rnrntt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Заказы</B></td></tr>rntt";
if ( 0 < mysql_num_rows( $o ) )
{
echo "ttt<tr bgcolor=";
echo $font_row;
echo ">rnttt<td align=center colspan=2>rnttt<table border=0 cellpadding=0 cellspacing=0 width=100%>rnttt";
while ( $oo = mysql_fetch_object( $o ) )
{
$tarif = gettarifbyid( $oo->tarif );
echo "tttt<tr>rntttt<td><input type=text readonly size=20 value="";
echo $oo->domain;
echo ""></td>rntttt<td align=center>";
echo "<s";
echo "elect disabled><option>";
echo $tarif->name;
echo "</select></td>rntttt<Td align=center>rntttt";
if ( $oo->leftdays )
{
print "{$oo->leftdays} дн.";
if ( 0 < $oo->leftdays )
{
$moneyBack = round( $oo->leftdays * ( $tarif->cost / 31 ), 2 );
$moneyBackRu = getsetting( "kurs_rur" ) * $moneyBack;
print ", {$moneyBack}$, {$moneyBackRu} руб.";
}
}
else
{
print "-";
}
echo "tttt</td><td align=right>rntttt<form action=?do=editorder&host_id=";
echo $oo->id;
echo " method=post target=_blank><input type=submit value=подробнее></form>rntttt</td></tr>rntttt";
}
echo "ttt</table>rnttt</td>rnttt</tr>rnttt";
}
echo "tt<tr bgcolor=";
echo $font_row;
echo "><td colspan=2> </td></tr>rnrntt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Домены</B></td></tr>rntt";
if ( 0 < mysql_num_rows( $od ) )
{
echo "ttt<tr bgcolor=";
echo $font_row;
echo ">rnttt<td align=center colspan=2>rnttt<table cellpadding=0 cellspacing=0 width=100%>rnttt";
while ( $odd = mysql_fetch_object( $od ) )
{
echo "tttt<tr>rntttt<Td><input type=text readonly size=20 value="";
echo $odd->domain;
echo ""></td>rntttt<Td> рег. до (";
echo mydate( $odd->todate );
echo ")</td>rntttt<td align=center>rnttttrntttt";
if ( $odd->leftdays )
{
print "(осталось {$odd->leftdays} дн.)";
}
else
{
print "-";
}
echo "tttt</td>rnttttrntttt<td align=right>rntttt<form action=?do=editorder&domain_id=";
echo $odd->id;
echo " method=post target=_blank><input type=submit value=подробнее></form>rntttt</td></tr>rntttt";
}
echo "ttt</table>rnttt</td>rnttt</tr>rnttt";
}
echo "tt<tr bgcolor=";
echo $font_row;
echo "><td colspan=2> </td></tr>rnrntt";
if ( !( $r = @mysql_query( @"select SUM(money_host) as mhost, SUM(money_domain) as mdomain, SUM(money_addons) as maddons from bills where uid='{$u->id}' and NOT(payed='0000-00-00') and status='1'" ) ) )
{
exit( mysql_error( ) );
}
if ( 0 < mysql_num_rows( $r ) )
{
$r = mysql_fetch_object( $r );
$mhost = round( $r->mhost, 2 );
$mdomain = round( $r->mdomain, 2 );
$maddons = round( $r->maddons, 2 );
}
if ( !$mhost )
{
$mhost = 0;
}
if ( !$mdomain )
{
$mdomain = 0;
}
if ( !$maddons )
{
$maddons = 0;
}
echo "tt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Финансы</B></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo "><td colspan=2 align=center>Оплачено за хостинг: ";
echo $mhost;
echo "$ Оплачено за домены: ";
echo $mdomain;
echo "$ Оплачено за доп. услуги: ";
echo $maddons;
echo "$ Оплачено всего: <B>";
echo $mhost + $mdomain + $maddons;
echo "$</b></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo "><td colspan=2 align=center><form method=post>Сумма в у.е.: <input type=hidden name=do value=";
echo $do;
echo "><input type=hidden name=sub value=makebill><input type=hidden name=id value=";
echo $id;
echo "><input type=text size=3 name=money value=0.0><input type=submit value='Выставить счет'></form></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo "><td colspan=2> </td></tr>rnttrntt<tr bgcolor=";
echo $font_head;
echo "><td align=right><A href=?do=history&uid=";
echo $u->id;
echo " target=_blank><img src=./_rootimages/history.gif border=0></a> История клиента: </td><td><form action="?do=history&uid=";
echo $u->id;
echo "" method=post target=_blank><input type=submit value=просмотреть></form></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo "><td colspan=2> </td></tr>rnrntt<tr bgcolor=";
echo $font_head;
echo "><td align=right>Удалить клиента: </td><td> <a href=?do=clients&sub=delete&uid=";
echo $u->id;
echo " onclick="javascript: return confirm('Будет удален клиент, а так же все заказы и счета, относящиесу к нему. Вы уверены, что хотите удалить клиента?');"><img src=./_rootimages/del.gif border=0 alt='Удалить клиента' title='Удалить клиента'>удалить</a></td></tr>rntt<tr bgcolor=";
echo $font_row;
echo "><td colspan=2> </td></tr>rnttrntt</table>rntt";
}
else
{
print "Клиент не найден.";
}
}
if ( $do == "mailsend" )
{
if ( $sub == "send" )
{
if ( !$subject )
{
$error = "Не указана тема сообщения.";
}
else if ( !$to )
{
$error = "Не указан адресат сообщения. ";
}
else
{
if ( !$message )
{
$error = "Не указан тект сообщения.";
}
else
{
if ( $to == "all" )
{
$users = getusersall( );
}
else
{
$users = getusersbyordertype( $to );
}
if ( $users )
{
$manager_email = getsetting( "manager_email" );
while ( $user = mysql_fetch_object( $users ) )
{
if ( $user->news || $ignore )
{
sendmail( $user->email, $manager_email, $subject, $message );
}
}
print "Сообщение успешно отправлено.<BR><BR>";
$to = "";
$subject = "";
$message = "";
$ignore = "";
}
else
{
$error = "Нет ни одного клиента данного типа.";
}
}
}
}
if ( $error )
{
print "<font color=red>Ошибка: {$error}</font><BR><BR>";
}
echo "t<form method=post>rnt<input type=hidden name=do value=mailsend>rnt<input type=hidden name=sub value=send>rnt<table>rnt<tr><td colspan=2 align=center bgcolor=";
echo $font_head;
echo "><B>Рассылка</b></td></tr>rnt<tr><td>Кому: </td><td>";
echo "<s";
echo "elect name=to><option value=all ";
if ( $to == "all" )
{
print "selected";
}
echo ">Всем клиентам<option value=hosting ";
if ( $to == "hosting" )
{
print "selected";
}
echo ">Клиентам на хостинг<option value=reseller ";
if ( $to == "reseller" )
{
print "selected";
}
echo ">Клиентам на реселлинг<option value=vds ";
if ( $to == "vds" )
{
print "selected";
}
echo ">Клиентам на виртуальный выделенный сервер<option value=dedicated ";
if ( $to == "dedicated" )
{
print "selected";
}
echo ">Клиентам на выделенный сервер<option value=domains ";
if ( $to == "domains" )
{
print "selected";
}
echo ">Клиентам на регистрацию доменов</select></td></tr>rnt<tr><td>Тема: </td><Td><input type=text name=subject value="";
echo $subject;
echo "" size=52></td></tr>rnt<tr><td valign=top>Письмо: </td><td><textarea name=message cols=50 rows=10>";
echo $message;
echo "</textarea></td></tr>rnt<tr><Td></td><Td><input type=checkbox name=ignore ";
if ( $ignore )
{
print "checked";
}
echo "> отправить, даже если клиент отказался от подписки на новости</td></tr>rnt<tr><td colspan=2 align=center><BR><input type=submit value=Отправить> <input type=reset value=Очистить></td></tr>rnt</table>rnt</form>rnt";
}
include( "./_rootinc/adminfoot.inc" );
mclose( );
?>