Файл: RootPanel 1.7.0 FreeCode/RootPanel 1.7.0 FreeCode/_rootinc/functions.inc.php
Строк: 6794
<?
###########################################
# >> Служебные переменные и константы #
###########################################
$_registrators[directi] = "directI";
$_registrators[ficora] = "ficora.fi";
$_registrators[freehost] = "freehost.com.ua";
$_registrators[hostmaster] = "hostmaster.net.ua";
$_registrators[internetx] = "internetx.de";
$_registrators[naunet] = "naunet.ru";
$_registrators[nicru] = "nic.ru";
$_registrators[onlinenic] = "onlinenic.com";
$_registrators[r01] = "r01.ru & centrohost.ru";
$_registrators[regru] = "reg.ru & 2domains.ru";
$_registrators[started] = "started.ru";
$_registrators[todaynic] = "todaynic.com";
$_registrators[ukrnames] = "ukrnames.com";
$_registrators[webnames] = "webnames.ru";
$_registrators[mail] = "e-mail";
function valid_email($eemail) {
if (@preg_match("/^([0-9a-z][_.0-9a-z-]*[0-9a-z])@([0-9a-z][0-9a-z.-]*).([a-z]{2,4})$/ui", $eemail, $check) or @preg_match("/^([0-9a-z])@([0-9a-z][0-9a-z.-]*).([a-z]{2,4})$/ui", $eemail, $check)) {
return 1;
} else {
return 0;
}
}
function sendmail($msgto='',$msgfromname,$msgfrom,$msgsubj,$msgtext,$attachfile='',$encoding='utf-8',$contenttype='text') {
if ($msgto) {
$mail = new PHPMailer();
$mail->CharSet = $encoding;
if ($contenttype == 'html') { $mail->IsHTML(true); } else { $mail->IsHTML(false); }
$mailType = GetSetting('mailType');
if ($mailType == "sendmail") {
$mail->IsSendmail();
$mail->Sendmail = GetSetting('mailSendmailPath');
}
if ($mailType == "smtp") {
$mail->IsSMTP();
$mail->Host = GetSetting('mailSMTPServer');
$mail->Port = GetSetting('mailSMTPPort');
$mail->SMTPSecure = GetSetting('mailSMTPSecure');
$mailSMTPAuth = GetSetting('mailSMTPAuth');
if ($mailSMTPAuth == "POPbeforeSMTP") {
$mailPOPServer = GetSetting('mailPOPServer');
$mailPOPPort = GetSetting('mailPOPPort');
$mailPOPUser = GetSetting('mailPOPUser');
$mailPOPPassword = GetSetting('mailPOPPassword');
$pop = new POP3();
$pop->Authorise($mailPOPServer, $mailPOPPort, 30, $mailPOPUser, $mailPOPPassword, 0);
}
if ($mailSMTPAuth == "SMTP") {
$mail->SMTPAuth = true;
$mail->Username = GetSetting('mailSMTPUser');
$mail->Password = GetSetting('mailSMTPPassword');
}
}
$mail->From = $msgfrom;
$mail->FromName = htmlDecode($msgfromname);
$mail->AddAddress($msgto);
$mail->Subject = htmlDecode($msgsubj);
$mail->Body = htmlDecode($msgtext);
if ($attachfile and @file_exists($attachfile)) {
$mail->AddAttachment($attachfile);
}
if($mail->Send()) {
return 1;
} else {
return 0;
}
} else {
return 0;
}
}
function generatePassword($length = 8, $withSpec = 0) {
// start with a blank password
$password = "";
// define possible characters
$possible = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
// define possible numbers
$possible_numbers = "0123456789";
// define possible special characters
$possible_special = "!%()*-";
// set up a counter
$i = 0;
// add random characters to $password until $length is reached
while ($i < $length) {
if (($length-$i) == 2 and $withSpec) {
$char = substr($possible_special, mt_rand(0, strlen($possible_special)-1), 1);
} else if (($length-$i) == 1) {
$char = substr($possible_numbers, mt_rand(0, strlen($possible_numbers)-1), 1);
} else {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
}
// we don't want this character if it's already in the password
if (!strstr($password, $char)) {
$password .= $char;
$i++;
}
}
// done!
return $password;
}
function GenSid() {
$schet=md5(uniqid(rand()));
$schet=substr($schet,0,8);
$schet=strtoupper($schet);
return $schet;
}
function GetUsersByOrderType($orderType) {
if ($orderType == "hosting" or $orderType == "reseller" or $orderType == "vds" or $orderType == "dedicated" or $orderType == "vpn") {
$r = @mysql_query("select DISTINCT t2.login, t2.* from orders as t1, users as t2, tarifs as t3 where t1.tarif=t3.id and t3.vid='$orderType' and t2.id=t1.uid order by t2.login") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
else if ($orderType == "domains") {
$r = @mysql_query("select DISTINCT t2.login, t2.* from orders_domains as t1, users as t2 where t2.id=t1.uid order by t2.login") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
else if ($orderType == "shop") {
$r = @mysql_query("select DISTINCT t2.login, t2.* from orders_shop as t1, users as t2 where t2.id=t1.uid order by t2.login") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
if (mysql_num_rows($r) > 0) {
return $r;
}
}
function GetUsersByServerId($serverid) {
$r = @mysql_query("select DISTINCT t2.login, t2.* from orders as t1, users as t2, servers as t3 where t1.serverid=t3.id and t2.id=t1.uid order by t2.login") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($r) > 0) {
return $r;
}
}
function MakePages($page, $rows, $urladdon='') {
global $_SESSION, $do, $_lang;
$perPage = GetSetting("perpage_".$do);
$pages = ceil($rows/$perPage);
if (!$page) {
if ($_SESSION[$do."Page"]) {
$page = $_SESSION[$do."Page"];
} else {
$page = 1;
}
}
if ($page > $pages) { $page = 1; }
$start = ($page - 1) * $perPage;
$_SESSION[$do."Page"] = $page;
if ($pages) { $txt = $_lang[Pages]; }
if ($page > 1) { $txt .= " <A class=rootlinkpages title='".$_lang[PagesBegin]."' href=?do=$do&page=1&".$urladdon."><<</a> "; } else if ($pages > 0) { $txt .= " << "; }
if ($page > 1) { $txt .= " <A class=rootlinkpages title='".$_lang[PagesPrev]."' href=?do=$do&page=".($page - 1)."&".$urladdon."><</a>"; } else if ($pages > 0) { $txt .= " < "; }
if ($pages > 10 ) {
$startFor = $page - 5;
if ($startFor <= 0) { $startFor = 1; }
$endFor = $startFor + 10;
if ($endFor > $pages) { $endFor = $pages; $startFor = $pages-10; }
} else {
$startFor = 1;
$endFor = $pages;
}
for ($i=$startFor; $i<=$endFor; $i++) {
if ($page != $i) { $newTxt = " <A class=rootlinkpages title='".$_lang[PagesNum]."$i' href=?do=$do&page=$i&$urladdon>$i</a>"; }
else { $newTxt = " <B>$i</B>"; }
$txt = $txt.$newTxt;
}
if ($page < $pages) { $txt .= " <A class=rootlinkpages title='".$_lang[PagesNext]."' href=?do=$do&page=".($page + 1)."&".$urladdon.">></a>"; } else if ($pages > 0) { $txt .= " >"; }
if ($page < $pages) { $txt .= " <A class=rootlinkpages title='".$_lang[PagesEnd]."' href=?do=$do&page=".$pages."&".$urladdon.">>></a>"; } else if ($pages > 0) { $txt .= " >>"; }
return array($start,$perPage,$txt);
}
function addUserLog($uid, $operation, $comment) {
@mysql_query("INSERT INTO users_logs (uid,dt,operation,comment) values('$uid',NOW(),'$operation', '$comment')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
function MakeBillPayed($id, $status = 1, $merchant = '') {
global $full_home_path, $full_www_path;
$bill = GetBillById($id);
if ($bill and $bill->status == "2" and $status == "1") {
@mysql_query("update bills set payed=NOW(),status='$status' where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
else if ($bill and !$bill->status) {
$partnerEnable=GetSetting("partnerEnable");
@mysql_query("update bills set payed=NOW(),status='$status' where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($bill->host_id and !$bill->newtarif and !$bill->newaddons) {
$order = GetOrderById($bill->host_id);
$tarif = GetTarifById($order->tarif);
if ($order->startdate == '0000-00-00' and !$order->testPeriod) {
@mysql_query("update orders set startdate=NOW(), todate=DATE_ADD(NOW(),INTERVAL ".($bill->host_srok*30)." DAY) where id='$bill->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($tarif->autocreate and !$order->status) {
createUser($bill->host_id);
}
} else if ($order->startdate == '0000-00-00' and $order->testPeriod) {
if (GetSetting("testPeriodAddDays")) {
if ($order->todate != "0000-00-00") {
@mysql_query("update orders set startdate=NOW(), todate=DATE_ADD(todate,INTERVAL ".($bill->host_srok*30)." DAY),testPeriod='0' where id='$bill->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$testDays=GetSetting("testPeriodDays");
@mysql_query("update orders set startdate=NOW(), todate=DATE_ADD(NOW(),INTERVAL ".($bill->host_srok*30+$testDays)." DAY),testPeriod='0' where id='$bill->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
} else {
@mysql_query("update orders set startdate=NOW(), todate=DATE_ADD(NOW(),INTERVAL ".($bill->host_srok*30)." DAY),testPeriod='0' where id='$bill->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
if ($tarif->autocreate and $tarif->testPeriod == "2" and !$order->status and $order->serverlogin) {
if (changePackage($order->id, $tarif->id)) {
@mysql_query("update orders set status=1 where id='$bill->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
} else if ($tarif->autocreate and $tarif->testPeriod == "1" and !$order->status and $order->serverlogin) {
@mysql_query("update orders set status=1 where id='$bill->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
} else {
if ($order->status == "1") {
@mysql_query("update orders set todate=DATE_ADD(todate,INTERVAL ".($bill->host_srok*30)." DAY) where id='$bill->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else if ($order->status == "2") {
@mysql_query("update orders set todate=DATE_ADD(NOW(),INTERVAL ".($bill->host_srok*30)." DAY) where id='$bill->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
if ($order->status == "2" and $tarif->autosuspend) {
if (suspendUser($bill->host_id, 0)) {
@mysql_query("update orders set status='1' where id='$bill->host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
}
}
} else if ($bill->host_id and $bill->newtarif) {
$order = GetOrderById($bill->host_id);
if (IsAccessibleChangeTarifForHostingOrder($order->id,$bill->newtarif)) {
$oldTarif = GetTarifById($order->tarif);
$newTarif = GetTarifById($bill->newtarif);
addUserLog($order->uid,'changetarif',"Для заказа ID #$order->id, $order->domain, с $oldTarif->name на $newTarif->name");
@mysql_query("update orders set tarif='$bill->newtarif' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
changePackage($order->id, $bill->newtarif);
}
} else if ($bill->host_id and $bill->newaddons) {
$order = GetOrderById($bill->host_id);
$currAddons = GetAddonsIdsByTxt($order->addons);
$newAddons = GetAddonsIdsByTxt($bill->newaddons);
while (list($k,$v) = each($newAddons)) {
$currAddons[] = $v;
}
$currAddons=@join(":x:",$currAddons);
@mysql_query("update orders set addons='$currAddons' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
if ($bill->domain_id and !$bill->status) {
$d=@mysql_query("select * from orders_domains where id='$bill->domain_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$d=mysql_fetch_object($d);
if ($d->startdate == '0000-00-00') {
@mysql_query("update orders_domains set startdate=NOW(), todate=DATE_ADD(NOW(),INTERVAL ".$bill->domain_srok." MONTH) where id='$bill->domain_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$zone=GetZoneByDomainOrderId($d->id);
if ($zone->autoreg and !$d->status) {
$period = $bill->domain_srok/12;
regDomain($d->id, $period);
}
}
else {
@mysql_query("update orders_domains set todate=DATE_ADD(todate,INTERVAL ".$bill->domain_srok." MONTH) where id='$bill->domain_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$zone=GetZoneByDomainOrderId($d->id);
if ($zone->autoreg) {
$period = $bill->domain_srok/12;
renewDomain($d->id, $period);
}
}
}
if ($bill->shop_id and !$bill->status) {
$orderShop = GetOrderShopById($bill->shop_id);
$shopItem = GetShopItemById($orderShop->item);
if ($shopItem->costtype != "one") {
if ($orderShop->startdate == '0000-00-00') {
@mysql_query("update orders_shop set startdate=NOW(), todate=DATE_ADD(NOW(),INTERVAL ".$bill->shop_srok." MONTH) where id='$bill->shop_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($shopItem->type == "avdesk" and !$orderShop->status) {
createShopOrder($orderShop->id);
}
} else {
if ($orderShop->status == "1") {
@mysql_query("update orders_shop set todate=DATE_ADD(todate,INTERVAL ".$bill->shop_srok." MONTH) where id='$bill->shop_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else if ($orderShop->status == "2") {
@mysql_query("update orders_shop set todate=DATE_ADD(NOW(),INTERVAL ".$bill->shop_srok." MONTH) where id='$bill->shop_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
if ($shopItem->type == "avdesk") {
if ($orderShop->status == "2") {
@mysql_query("update orders_shop set status='1' where id='$bill->shop_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
renewShopOrder($bill->shop_id, 0);
}
}
} else {
@mysql_query("update orders_shop set startdate=NOW() where id='$bill->shop_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($shopItem->type == "avdesk" and !$orderShop->status) {
createShopOrder($orderShop->id);
}
}
}
if ($bill->addfunds) {
@mysql_query("update users set money=money+$bill->money where id='$bill->uid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
if ($partnerEnable and $status == '1' and ($bill->domain_id or $bill->host_id or $bill->shop_id) and !$bill->newaddons and !$bill->newtarif) {
$partnerProcentAllOrders=GetSetting("partnerProcentAllOrders");
if ($partnerProcentAllOrders or (!$partnerProcentAllOrders and GetBillPayedCountByUserId($bill->uid) == 1)) {
$userReferal=GetUserById($bill->uid);
$userForMoney=GetUserById($userReferal->referal);
if ($userForMoney->id) {
if ($tarif->vid == 'hosting') { if (!$userForMoney->specPartnerEnable) { $partnerHostProcent = GetSetting("partnerProcentHosting"); } else { $partnerHostProcent = $userForMoney->partnerProcentHosting; }}
else if ($tarif->vid == 'reseller') { if (!$userForMoney->specPartnerEnable) { $partnerHostProcent = GetSetting("partnerProcentResseler"); } else { $partnerHostProcent = $userForMoney->partnerProcentResseler; }}
else if ($tarif->vid == 'dedicated') { if (!$userForMoney->specPartnerEnable) { $partnerHostProcent = GetSetting("partnerProcentDedicated"); } else { $partnerHostProcent = $userForMoney->partnerProcentDedicated; }}
else if ($tarif->vid == 'vds') {if (!$userForMoney->specPartnerEnable) { $partnerHostProcent = GetSetting("partnerProcentVds"); } else { $partnerHostProcent = $userForMoney->partnerProcentVds; }}
else if ($tarif->vid == 'vpn') {if (!$userForMoney->specPartnerEnable) { $partnerHostProcent = GetSetting("partnerProcentVpn"); } else { $partnerHostProcent = $userForMoney->partnerProcentVpn; }}
if (!$userForMoney->specPartnerEnable) { $partnerProcentDomains=GetSetting("partnerProcentDomains"); } else { $partnerProcentDomains = $userForMoney->partnerProcentDomains; }
if (!$userForMoney->specPartnerEnable) { $partnerProcentAddons=GetSetting("partnerProcentAddons"); } else { $partnerProcentAddons = $userForMoney->partnerProcentAddons; }
if (!$userForMoney->specPartnerEnable) { $partnerProcentShop=GetSetting("partnerProcentShop"); } else { $partnerProcentShop = $userForMoney->partnerProcentShop; }
$moneyFromReferal = ($bill->money_host/100)*$partnerHostProcent + ($bill->money_domain/100)*$partnerProcentDomains + ($bill->money_addons/100)*$partnerProcentAddons + ($bill->money_shop/100)*$partnerProcentShop;
if ($moneyFromReferal > 0) {
GetCurrentAdminCurrency();
@mysql_query("update users set partnerMoney=partnerMoney+$moneyFromReferal where id='".$userForMoney->id."'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
addUserLog($userForMoney->id, "moneyIn", "Referal procent (level 1) (user id #$userReferal->id): $moneyFromReferal".CURAS." (bill id #$id)");
################### level 2 ###################################
$userForMoney2=GetUserById($userForMoney->referal);
if ($userForMoney2->id) {
if ($tarif->vid == 'hosting') { if (!$userForMoney2->specPartnerEnable) { $partnerHostProcent2 = GetSetting("partnerProcentHosting2"); } else { $partnerHostProcent2 = $userForMoney2->partnerProcentHosting2; }}
else if ($tarif->vid == 'reseller') { if (!$userForMoney2->specPartnerEnable) { $partnerHostProcent2 = GetSetting("partnerProcentResseler2"); } else { $partnerHostProcent2 = $userForMoney2->partnerProcentResseler2; }}
else if ($tarif->vid == 'dedicated') { if (!$userForMoney2->specPartnerEnable) { $partnerHostProcent2 = GetSetting("partnerProcentDedicated2"); } else { $partnerHostProcent2 = $userForMoney2->partnerProcentDedicated2; }}
else if ($tarif->vid == 'vds') {if (!$userForMoney2->specPartnerEnable) { $partnerHostProcent2 = GetSetting("partnerProcentVds2"); } else { $partnerHostProcent2 = $userForMoney2->partnerProcentVds2; }}
else if ($tarif->vid == 'vpn') {if (!$userForMoney2->specPartnerEnable) { $partnerHostProcent2 = GetSetting("partnerProcentVpn2"); } else { $partnerHostProcent2 = $userForMoney2->partnerProcentVpn2; }}
if (!$userForMoney2->specPartnerEnable) { $partnerProcentDomains2=GetSetting("partnerProcentDomains2"); } else { $partnerProcentDomains2 = $userForMoney2->partnerProcentDomains2; }
if (!$userForMoney2->specPartnerEnable) { $partnerProcentAddons2=GetSetting("partnerProcentAddons2"); } else { $partnerProcentAddons2 = $userForMoney2->partnerProcentAddons2; }
if (!$userForMoney2->specPartnerEnable) { $partnerProcentShop2=GetSetting("partnerProcentShop2"); } else { $partnerProcentShop2 = $userForMoney2->partnerProcentShop2; }
$moneyFromReferal2 = ($bill->money_host/100)*$partnerHostProcent2 + ($bill->money_domain/100)*$partnerProcentDomains2 + ($bill->money_addons/100)*$partnerProcentAddons2 + ($bill->money_shop/100)*$partnerProcentShop2;
if ($moneyFromReferal2 > 0) {
@mysql_query("update users set partnerMoney=partnerMoney+$moneyFromReferal2 where id='".$userForMoney2->id."'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
addUserLog($userForMoney2->id, "moneyIn", "Referal procent (level 2) (user id #$userReferal->id from user id #$userForMoney->id): $moneyFromReferal2".CURAS." (bill id #$id)");
}
}
################### level 2 ###################################
}
} else {
@mysql_query("update users set referal=0 where id='$bill->uid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
}
}
if ($status) {
$user = GetUserById($bill->uid);
$tpl=GetTpl("pay_bill", $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
$sid=sprintf("%04d", $id);
addUserLog("$user->id", "pay", "Bill № $sid via $merchant");
if ($subject and $template) {
$company_name=GetSetting('company_name');
$company_url=GetSetting('company_url');
$support_url=GetSetting('support_url');
$manager_email=GetSetting("manager_email");
$subject = str_replace('{id}',$sid,$subject);
$template = str_replace('{company_name}',$company_name,$template);
$template = str_replace('{company_url}',$company_url,$template);
$template = str_replace('{support_url}',$support_url,$template);
$template = str_replace('{schet}',$sid,$template);
$template = str_replace('{bill_date}',mydate($bill->created),$template);
$template = str_replace('{pay_method}',"$merchant",$template);
WriteMailLog($subject,$template,$user->id);
sendmail($user->email, $company_name, $manager_email, $subject, $template);
sendmail($user->email2, $company_name, $manager_email, $subject, $template);
$subject = "Duplicate: ".$subject;
$admEmails=GetAdminEmailsWhereTrueParam("sendpaybill");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
sendmail($manager_email, '', $user->email, $subject, $template);
}
}
return true;
}
return false;
}
function _menu($enc = 'windows-1251')
{
global $_lang, $languages, $_SESSION;
include("_menu_user.php");
if (GetSetting("userBalanceEnable")) { print "<B class='menu_category'>".$_lang[BillingMenuBalance].":</b> <span class='menu_text'>".round(GetUserMoney($_SESSION["userId"])*CURK,2)." ".CURS."</span> [<A href=billing.php?do=addfunds class='menu_link'>".$_lang[BillingMenuAddFunds]."</a>] "; }
if (GetSetting("partnerEnable")) { print "<B class='menu_category'>".$_lang[PartnerPartnerSchet].":</b> <span class='menu_text'>".round(GetUserPartnerMoney($_SESSION["userId"])*CURK,2)." ".CURS."</span><BR>";}
$r=@mysql_query("select * from tickets where newforuser='1' and userid='$_SESSION[userId]'") or die(mysql_error());
$cnt=0;
while ($rr = mysql_fetch_object($r)){$cnt++;}
if ($cnt >0){print " <b>$_lang[rfc1] $cnt</b><br>";}
$r=@mysql_query("select * from tickets where newforuser='1' and userid='$_SESSION[userId]'") or die(mysql_error());
while ($rr = mysql_fetch_object($r)){print "<b>$_lang[rfc2] <a href=billing.php?do=tickets&sub=view&id={$rr->id}>$rr->subject</a></b><br>";}
print "<hr size='1'>";
}
function _menu_admin($enc = 'windows-1251'){global $ticketslink, $_lang, $languages, $_SESSION;include('_menu_admin.php');}
function menu($enc = 'windows-1251') {
global $_lang, $languages, $_SESSION;
$resPrint = "";
// $resPrint .= "<H1 class=pagetitle>".$_lang[BillingTitle]."</H1><hr class=hr>";
$weSalesTypes = GetSetting("weSalesTypes");
$weSalesTypes = @split("::",$weSalesTypes);
$resPrint .= "<b class='menu_category'>".$_lang[BillingMenu].":</b> ";
$resPrint .= "<a href=billing.php?do=bills class='menu_link'>".$_lang[BillingMenuBills]."</a>, ";
if (@in_array("hosting",$weSalesTypes) or @in_array("reseller",$weSalesTypes) or @in_array("vds",$weSalesTypes) or @in_array("dedicated",$weSalesTypes) or @in_array("vpn",$weSalesTypes)) {
$resPrint .= "<a href=billing.php?do=orders class='menu_link'>".$_lang[BillingMenuOrders]."</a>, ";
}
if (@in_array("domains",$weSalesTypes)) {
$resPrint .= "<a href=billing.php?do=domains class='menu_link'>".$_lang[BillingMenuDomains]."</a>, ";
}
if (@in_array("shop",$weSalesTypes)) {
$resPrint .= "<a href=billing.php?do=shop class='menu_link'>".$_lang[BillingMenuShop]."</a>, ";
}
if (GetSetting("partnerEnable")) { $resPrint .= "<A href=billing.php?do=partner class='menu_link'>".$_lang[BillingMenuPartner]."</a>, "; }
if (IsNewTicketsForUser($_SESSION["userId"])) { $tickets_class="menu_link_highlight"; } else { $tickets_class="menu_link"; }
if (GetSetting("ticketsEnable")) { $resPrint .= "<A href=billing.php?do=tickets class='$tickets_class'>".$_lang[BillingMenuTickets]."</a>, "; }
$resPrint .= "<a href=billing.php?do=profile class='menu_link'>".$_lang[BillingMenuProfile]."</a>, ";
$resPrint .= "<a href=billing.php?do=settings class='menu_link'>".$_lang[BillingMenuSettings]."</a>, ";
if (GetSetting('mailLogUserEnable')) { $resPrint .= "<A href=billing.php?do=maillogs class='menu_link'>".$_lang[BillingMenuMail]."</a>, "; }
if (GetSetting("catalog_enable")) { $resPrint .= "<A href=billing.php?do=catalog class='menu_link'>".$_lang[BillingMenuCatalog]."</a>, "; }
if (@in_array("domains",$weSalesTypes)) {
$resPrint .= "<A href=whois.php class='menu_link'>".$_lang[BillingMenuWhois]."</a>, ";
}
$r=GetUsersMenu();
while ($rr = @mysql_fetch_object($r)) {
$name=array();
$link=array();
if ($rr->active) {
$names=mb_split(":xxx:",$rr->name);
while (list($k,$name_one) = @each($names)) {
$name_one = mb_split(":xx:",$name_one);
$lang = $name_one[0];
$name[$lang] = $name_one[1];
}
$links=mb_split(":xxx:",$rr->link);
while (list($k,$link_one) = @each($links)) {
$link_one = mb_split(":xx:",$link_one);
$lang = $link_one[0];
$link[$lang] = $link_one[1];
}
$lngUser = $_SESSION["userLang"];
$lngDefault = GetSetting("lngDefault");
if ($lngUser and $languages[$lngUser] and $name[$lngUser] and $link[$lngUser]) {
$resPrint .= "<a href=".$link[$lngUser]." class='menu_link'>".$name[$lngUser]."</a>, ";
} else if ($lngDefault and $languages[$lngDefault] and $name[$lngDefault] and $link[$lngDefault]) {
$resPrint .= "<a href=".$link[$lngDefault]." class='menu_link'>".$name[$lngDefault]."</a>, ";
} else {
$resPrint .= "<a href=".$link["russian"]." class='menu_link'>".$name["russian"]."</a>, ";
}
}
}
$resPrint .= "<a href=billing.php?do=logout class='menu_link'>".$_lang[BillingMenuLogout]."</a>.<BR>";
$cnt=count($weSalesTypes); $i=0;
$resPrint .= "<B class='menu_category'>".$_lang[BillingMenuOrder].":</b> ";
if (@in_array("hosting",$weSalesTypes)) { $resPrint .= "<A href=order.php class='menu_link'>".$_lang[OrderType]["hosting"]."</a>"; $i++; if ($i < $cnt) {$resPrint .= ", ";}}
if (@in_array("reseller",$weSalesTypes)) { $resPrint .= "<A href=order.php?vid=reseller class='menu_link'>".$_lang[OrderType]["reseller"]."</a>"; $i++; if ($i < $cnt) {$resPrint .= ", ";}}
if (@in_array("vds",$weSalesTypes)) { $resPrint .= "<A href=order.php?vid=vds class='menu_link'>".$_lang[OrderType]["vds"]."</a>"; $i++; if ($i < $cnt) {$resPrint .= ", ";}}
if (@in_array("dedicated",$weSalesTypes)) { $resPrint .= "<A href=order.php?vid=dedicated class='menu_link'> ".$_lang[OrderType]["dedicated"]."</a>"; $i++; if ($i < $cnt) {$resPrint .= ", ";}}
if (@in_array("vpn",$weSalesTypes)) { $resPrint .= "<A href=order.php?vid=vpn class='menu_link'>".$_lang[OrderType]["vpn"]."</a>"; $i++; if ($i < $cnt) {$resPrint .= ", ";}}
if (@in_array("domains",$weSalesTypes)) { $resPrint .= "<A href=order.php?type=d class='menu_link'>".$_lang[Domain]."</a> / <A href=order.php?type=dopt class='menu_link'>".$_lang[DomainOpt]."</a>"; $i++; if ($i < $cnt) {$resPrint .= ", ";}}
if (@in_array("shop",$weSalesTypes)) { $resPrint .= "<A href=order.php?type=shop class='menu_link'>".$_lang[OrderItem]."</a>"; $i++; if ($i < $cnt) {$resPrint .= ", ";}}
$resPrint .= "<BR>";
if (GetSetting("userBalanceEnable")) { $resPrint .= "<B class='menu_category'>".$_lang[BillingMenuBalance].":</b> <span class='menu_text'>".round(GetUserMoney($_SESSION["userId"])*CURK,2)." ".CURS."</span> [<A href=billing.php?do=addfunds class='menu_link'>".$_lang[BillingMenuAddFunds]."</a>]<BR>"; }
$resPrint .= "<BR>";
if ($enc == "utf-8") {
} else if ($enc == "koi8-r") {
$resPrint = iconv("utf-8", "koi8-r", $resPrint);
} else if ($enc == "windows-1251") {
$resPrint = iconv("utf-8", "windows-1251", $resPrint);
}
print $resPrint;
}
function menu_vertical() {
global $_lang;
if (GetSetting("userBalanceEnable")) {
print "<B>".$_lang[BillingMenuBalance].":</b> ".round(GetUserMoney($_SESSION["userId"])*CURK,2)." ".CURS."<BR>";
print "[<A href=billing.php?do=addfunds>".$_lang[BillingMenuAddFunds]."</a>]<BR><BR>";
}
print "<a href=billing.php?do=bills>".$_lang[BillingMenuBills]."</a><BR>";
print "<a href=billing.php?do=orders>".$_lang[BillingMenuOrders]."</a><BR>";
print "<a href=billing.php?do=domains>".$_lang[BillingMenuDomains]."</a><BR>";
print "<a href=billing.php?do=profile>".$_lang[BillingMenuProfile]."</a><BR>";
if (GetSetting("ticketsEnable")) { print "<a href=billing.php?do=tickets>".$_lang[BillingMenuTickets]."</a><BR>"; }
if (GetSetting("partnerEnable")) { print "<a href=billing.php?do=partner>".$_lang[BillingMenuPartner]."</a><BR>"; }
if (GetSetting("catalog_enable")) { print "<a href=billing.php?do=catalog>".$_lang[BillingMenuCatalog]."</a><BR>"; }
print "<a href=billing.php?do=logout>".$_lang[BillingMenuLogout]."</a><BR><BR>";
}
function menu_admin_client($uid) {
$user = GetUserById($uid);
print "[ <B>$user->login</B> ] : [ <B><A href=?do=bills¶m=uid&search=$uid>счета</a></B> - <B><a href=?do=orders¶m=uid&search=$uid>заказы</a></B> - <B><a href=?do=domains¶m=uid&search=$uid>домены</a></B> - <B><a href=?do=shop¶m=uid&search=$uid>товары</a></B> - <B><a href=?do=specialcosts&uid=$uid>спец. цены</a></B> - <B><a href=?do=tickets&uid=$uid>тикеты</a></B> - <B><a href=?do=profile&id=$uid>профайл</a></B> - <B><a href=?do=usersettings&id=$uid>настройки</a></B> - <B><a href=?do=history&uid=$uid>история</a></B> - <B><A href=?do=fullinfo&id=$uid>полное инфо</a></b> ]<BR><BR>";
}
function printWhoisForm($url = "", $rowsCnt = "", $enc = "windows-1251") {
global $domain, $checkedzones, $zone, $_lang;
if (!$url) { $url = $do; }
if (!$rowsCnt) { $rowsCnt = 6; }
$result = "<form action='$url' method='post'>";
$result .= "<table class='rpTableBlank' border='1'><tr><Td>";
$result .= $_lang[WhoisDomainName].": <input class=input type=text name=domain value='$domain' size=15> ";
$whoistype = GetSetting("whoistype");
$zones = GetZonesNamesForWhois();
if ($whoistype == "check") {
$result .= "<select class=input disabled><option value=''>".$_lang[WhoisSelectZones].":</option></select><BR><BR>";
$cnt = 0;
if ($zone and !$checkedzones) { $checkedzones[$zone] = "$zone"; }
$result .= "<table class='rpTableBlank'>";
while (list($k, $v) = @each($zones)) {
$cnt++;
if ($cnt == 1) { $result .= "<tr><td>"; }
else { $result .= "<td>"; }
if ($checkedzones and @in_array($v, $checkedzones)) { $addon = "checked"; } else { $addon = ""; }
$result .= "<input class=input type=checkbox name=checkedzones[$v] value='$v' $addon>.$v";
if ($cnt == $rowsCnt) { $cnt=0; $result .= "</td></tr>"; }
else { $result .= "</td>";}
}
$result .= "</table>";
$result .= "</td></tr><tr><td align=right>";
}
else if ($whoistype == "select") {
$result .= "<select class=input name=zone><option value=''>".$_lang[WhoisSelectZone].":</option>";
while (list($k, $v) = @each($zones)) {
if ($zone == $v) {$addon="selected";} else {$addon="";}
$result .= "<option value='$v' $addon>.$v</option>";
}
$result .= "</select>";
$result .= "</td><td>";
}
$result .= "<input class=button type=submit value='".$_lang[WhoisCheckButton]."'></Td></tr></table>";
$result .= "</form>";
if ($enc == "utf-8") {
} else if ($enc == "koi8-r") {
$result = iconv("utf-8", "koi8-r", $result);
} else if ($enc == "windows-1251") {
$result = iconv("utf-8", "windows-1251", $result);
}
print $result;
}
function printTarifsSelect() {
print "<select class=input name=tarif_id><option></option>";
$r = @mysql_query("select * from tarifs order by cost") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
while ($rr = @mysql_fetch_object($r)) {
print "<option value=$rr->id>$rr->name</option>";
}
print "</select>";
}
function printZonesSelect() {
print "<select class=input name=zone_id><option></option>";
$r = @mysql_query("select * from zones group by zone order by zone") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
while ($rr = @mysql_fetch_object($r)) {
print "<option value=$rr->id>.$rr->zone</option>";
}
print "</select>";
}
function printAddonsSelect() {
print "<select class=input name=addon_id><option></option>";
$r = @mysql_query("select * from addons order by name") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
while ($rr = @mysql_fetch_object($r)) {
print "<option value=$rr->id>$rr->name</option>";
}
print "</select>";
}
function printLanguagesSelet($lng = '') {
global $languages;
print "<select class=input name=newlang><option></option>";
reset($languages);
while (list($i,$v) = each($languages)) {
if ($lng == $i) {$addon = "selected";} else {$addon = "";}
print "<option value=$i $addon>$v</option>";
}
print "</select>";
}
function printPayMethodsSelect($isPartnerPage = 0) {
global $_lang;
print "<select class=input name=paymethod><option></option>";
if (GetSetting("wmz") or GetSetting("wmr") or GetSetting("wmu") or GetSetting("wme") or GetSetting("wmb")) {print "<option>".$_lang[payWebMoney]."</option>";}
if (GetSetting("yandex")) {print "<option>".$_lang[payYandex]."</option>";}
if (GetSetting("egold")) {print "<option>".$_lang[payEgold]."</option>";}
if (GetSetting("rupayschet")) {print "<option>".$_lang[payRBKMoney]."</option>";}
if (GetSetting("zpay")) {print "<option>".$_lang[payZPayment]."</option>";}
# if (GetSetting("robox")) {print "<option>".$_lang[payRoboxchange]."</option>";}
# if (GetSetting("ikass_id")) {print "<option>".$_lang[payInterkassa]."</option>";}
if (GetSetting("easypay_merno")) {print "<option>".$_lang[payEasyPay]."</option>";}
# if (GetSetting("partnerEnable") and GetSetting("partnerEnablePayOrders") and !$isPartnerPage) {print "<option>".$_lang[payPartner]."</option>";}
#
# $r=GetPayMethods();
# while ($rr = @mysql_fetch_object($r)) {
# print "<option>$rr->name</option>";
# }
print "</select>";
}
function printAboutUsFromSelect($id = '') {
print "<select class=input name=aboutusfromid><option></option>";
$r = GetAboutUsFromAll();
while ($rr = @mysql_fetch_object($r)) {
if ($id == $rr->id) {$addon='selected';} else {$addon='';}
print "<option value=$rr->id $addon>$rr->name</option>";
}
print "</select>";
}
function printTarifsGroupsSelect($id = '') {
print "<select class=input name=tarifsgroup><option></option>";
$r = GetTarifsGroups();
while ($rr = @mysql_fetch_object($r)) {
if ($id == $rr->id) {$addon='selected';} else {$addon='';}
print "<option value=$rr->id $addon>$rr->name</option>";
}
print "</select>";
}
function printShopItemGroupsSelect($id = '') {
print "<select class=input name=itemgroup><option></option>";
$r = GetShopItemGroups();
while ($rr = @mysql_fetch_object($r)) {
if ($id == $rr->id) {$addon='selected';} else {$addon='';}
print "<option value=$rr->id $addon>$rr->name</option>";
}
print "</select>";
}
function createShopOrder($orderid, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path;
$orderShop = GetOrderShopById($orderid);
$shopItem = GetShopItemById($orderShop->item);
$user = GetUserById($orderShop->uid);
if ($orderShop->id) {
if ($shopItem->id) {
if ($user->id) {
if ($shopItem->type != "") {
if ($shopItem->type == "avdesk") {
if ($shopItem->field1 and $shopItem->field2 and $shopItem->field3 and $shopItem->field4) {
$pwd=generatePassword();
$login_addon=rand();
$login_addon=substr($login_addon,0,3);
$login = substr($user->login, 0, 5) . $login_addon;
if ($shopItem->costtype == "one") {
$year = ""; $month = ""; $day = "";
} else {
$toDate = split("-",$orderShop->todate);
$year = $toDate[0]; $month = $toDate[1]; $day = $toDate[2];
}
$avdesk = new AVDESK();
$avdesk->init($shopItem->field1,$shopItem->field2,$shopItem->field3);
$url = $avdesk->createUser($login,$pwd,$shopItem->field4,$year,$month,$day,"yes");
if ($url) {
mconnect();
@mysql_query("update orders_shop set field1='$login',field2='$pwd',field3='$url',status='1' where id='$orderShop->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $avdesk->error;
}
mconnect();
}
else { $error = "Не указан путь к AV-Desk, логин администратора, пароль администратора или ID группы."; }
}
else { $error = "Не известный тип товара $shopItem->type";}
if (!$error and $shopItem->tplsubj and $shopItem->tplmsg) {
$subject=htmlDecode($shopItem->tplsubj); $template=htmlDecode($shopItem->tplmsg);
if ($subject and $template) {
$company_name=GetSetting('company_name');
$company_url=GetSetting('company_url');
$support_url=GetSetting('support_url');
$manager_email=GetSetting('manager_email');
$template = str_replace('{company_name}',$company_name,$template);
$template = str_replace('{company_url}',$company_url,$template);
$template = str_replace('{support_url}',$support_url,$template);
$template = str_replace('{login}',$login,$template);
$template = str_replace('{password}',$pwd,$template);
$template = str_replace('{url}',$url,$template);
WriteMailLog($subject,$template,$user->id);
sendmail($user->email,$company_name,$manager_email,$subject,$template);
sendmail($user->email2,$company_name,$manager_email,$subject,$template);
$subject = "Duplicate: ".$subject;
$admEmails=GetAdminEmailsWhereTrueParam("sendcreateactmsg");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
sendmail($manager_email, '', $user->email, $subject, $template);
}
}
}
else { $error = "Не указан тип товара для товара ID #$shopItem->id, $shopItem->name."; }
} else { $error = "Не найден пользователь ID #$orderShop->uid."; }
} else { $error = "Не найден товар ID #$orderShop->item."; }
} else { $error = "Не найден заказ на товар ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически обработать заказ на товар ID #$orderid ($shopItem->name) по следующей причине:nn$errornnВам необходимо сделать эту вручную, а затем заполнить необходимые поля в редактировании заказа на товар!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка обработки заказа на товар";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
}
return false;
} else {
return true;
}
}
function renewShopOrder($orderid, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path;
$orderShop = GetOrderShopById($orderid);
$shopItem = GetShopItemById($orderShop->item);
$user = GetUserById($orderShop->uid);
if ($orderShop->id) {
if ($shopItem->id) {
if ($user->id) {
if ($shopItem->type != "") {
if ($shopItem->type == "avdesk") {
if ($orderShop->field1) {
if ($shopItem->field1 and $shopItem->field2 and $shopItem->field3 and $shopItem->field4) {
if ($shopItem->costtype == "one") {
$year = ""; $month = ""; $day = "";
} else {
$toDate = split("-",$orderShop->todate);
$year = $toDate[0]; $month = $toDate[1]; $day = $toDate[2];
}
$avdesk = new AVDESK();
$avdesk->init($shopItem->field1,$shopItem->field2,$shopItem->field3);
$result = $avdesk->renewUser($orderShop->field1,$year,$month,$day);
if (!$result) {
$error = $avdesk->error;
}
mconnect();
}
else { $error = "Не указан путь к AV-Desk, логин администратора, пароль администратора или ID группы."; }
}
else { $error = "Не указан логин клиента на сервере для заказа ID # $orderShop->id, $shopItem->name."; }
}
else { $error = "Не известный тип товара $shopItem->type";}
}
else { $error = "Не указан тип товара для товара ID #$shopItem->id, $shopItem->name."; }
} else { $error = "Не найден пользователь ID #$orderShop->uid."; }
} else { $error = "Не найден товар ID #$orderShop->item."; }
} else { $error = "Не найден заказ на товар ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически продлить заказ на товар ID #$orderid ($shopItem->name) по следующей причине:nn$errornnВам необходимо сделать эту вручную, а затем заполнить необходимые поля в редактировании заказа на товар!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка продления заказа на товар";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
}
return false;
} else {
return true;
}
}
function deleteShopOrder($orderid, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path;
$orderShop = GetOrderShopById($orderid);
$shopItem = GetShopItemById($orderShop->item);
$user = GetUserById($orderShop->uid);
if ($orderShop->id) {
if ($shopItem->id) {
if ($user->id) {
if ($shopItem->type != "") {
if ($shopItem->type == "avdesk") {
if ($orderShop->field1) {
if ($shopItem->field1 and $shopItem->field2 and $shopItem->field3 and $shopItem->field4) {
$avdesk = new AVDESK();
$avdesk->init($shopItem->field1,$shopItem->field2,$shopItem->field3);
$result = $avdesk->deleteUser($orderShop->field1,$year,$month,$day);
if (!$result) {
$error = $avdesk->error;
}
mconnect();
}
else { $error = "Не указан путь к AV-Desk, логин администратора, пароль администратора или ID группы."; }
}
else { $error = "Не указан логин клиента на сервере для заказа ID # $orderShop->id, $shopItem->name."; }
}
else { $error = "Не известный тип товара $shopItem->type";}
}
else { $error = "Не указан тип товара для товара ID #$shopItem->id, $shopItem->name."; }
} else { $error = "Не найден пользователь ID #$orderShop->uid."; }
} else { $error = "Не найден товар ID #$orderShop->item."; }
} else { $error = "Не найден заказ на товар ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически удалить заказ на товар ID #$orderid ($shopItem->name) по следующей причине:nn$errornnВам необходимо сделать эту вручную, а затем заполнить необходимые поля в редактировании заказа на товар!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка удаления заказа на товар";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
}
return false;
} else {
return true;
}
}
function updateCourses($sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path;
$coursesAutoUpdate = GetSetting("coursesAutoUpdate");
if ($coursesAutoUpdate) {
if ($coursesAutoUpdate == "privat24") {
$coursesPrivat24Type = GetSetting("coursesPrivat24Type");
$coursesAddProcent = GetSetting("coursesAddProcent");
if ($coursesPrivat24Type == "buy" or $coursesPrivat24Type == "sale" or $coursesPrivat24Type == "nbu" or $coursesPrivat24Type == "cbrf") {
$type = $coursesPrivat24Type;
$privatapi = new PRIVATAPI();
if ($coursesPrivat24Type == "buy" or $coursesPrivat24Type == "sale") { $result = $privatapi->getCourses(); }
if ($coursesPrivat24Type == "nbu" or $coursesPrivat24Type == "cbrf") { $result = $privatapi->getCoursesOfficial($coursesPrivat24Type); }
mconnect();
if ($result) {
$maincurrency = @mysql_query("select * from currency where koeficient='1'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$maincurrency = mysql_fetch_object($maincurrency);
$maincurrency = $maincurrency->code;
$currencys = GetCurrencys();
while ($currency = @mysql_fetch_object($currencys)) {
if ($currency->koeficient != "1") {
$code = $currency->code;
if ($coursesPrivat24Type == "buy" or $coursesPrivat24Type == "sale") {
$kurs = array();
if ($result[$maincurrency][buy] and $result[$maincurrency][sale] and $result[$code][buy] and $result[$code][sale]) {
$buy1 = $result[$maincurrency][buy];
$buy2 = $result[$code][buy];
$kurs[buy] = round($buy1/$buy2, 2);
$sale1 = $result[$maincurrency][sale];
$sale2 = $result[$code][sale];
$kurs[sale] = round($sale1/$sale2, 2);
if ($kurs[buy] > $kurs[sale]) {
$tmp = $kurs[buy];
$kurs[buy] = $kurs[sale];
$kurs[sale] = $tmp;
}
$kurs = $kurs[$type];
$kurs = $kurs + ($kurs/100)*$coursesAddProcent;
$kurs = round($kurs, 2);
@mysql_query("update currency set koeficient='$kurs' where id='$currency->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error .= "Не удалось получить курс валют для $currency->name. ";
}
}
else if ($coursesPrivat24Type == "nbu" or $coursesPrivat24Type == "cbrf") {
$kurs = "";
if ($result[$maincurrency] and $result[$code]) {
$kurs = $result[$maincurrency]/$result[$code];
$kurs = $kurs + ($kurs/100)*$coursesAddProcent;
$kurs = round($kurs, 2);
@mysql_query("update currency set koeficient='$kurs' where id='$currency->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error .= "Не удалось получить курс валют для $currency->name. ";
}
}
}
}
if ($error) { $error = $error."Остальные валюты успешно обновлены.";}
}
else {
$error = $privatapi->error;
}
} else { $error = "Не указано какой курс (покупка или продажа) использовать."; }
}
else { $error = "Неизвестный тип сервиса для получения курсов валют."; }
} else { $error = "Автоматическое получение курсов валют отключено."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически получить курсы валют по следующей причине:nn$errornnВам необходимо обновить курсы валют вручную!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка поулчения курсов валют";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
}
return false;
} else {
return true;
}
}
function createUser($orderid, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $full_www_path;
$order = GetOrderById($orderid);
if ($order->id) {
$tarif = GetTarifById($order->tarif);
if ($order->serverid) { $server = GetServers($order->serverid); } else { $server = GetServers($tarif->serverid); }
if ($tarif->id) {
if (($tarif->servername and $tarif->serverid) or ($tarif->serverid and $server->type == "shellscript")) {
if ($server->id) {
if (($server->type and $server->ip and $server->user and $server->password and $server->userip) or ($server->type == "ventrilo")) {
if (!$tarif->onlyDedicatedIP or ($tarif->onlyDedicatedIP and GetFreeServerIP($server->id))) {
$user = GetUserById($order->uid);
if ($user->id) {
if ($tarif->onlyDedicatedIP) {
$userip=GetFreeServerIP($server->id);
$useripid=$userip->id;
$userip=$userip->ip;
} else {
$userip=$server->userip;
}
$pwd=generatePassword();
$login_addon=rand();
$login_addon=substr($login_addon,0,3);
$login = substr($user->login, 0, 5) . $login_addon;
if ($order->testPeriod) {
$testdomain = $login.".".$tarif->testPeriodDomain;
$testDays = GetSetting("testPeriodDays");
$sqlAddDays = ",todate=DATE_ADD(NOW(),INTERVAL $testDays DAY)";
if ($tarif->testPeriod == "2" and $tarif->testPeriodTarif) {
$tarifServerName = $tarif->testPeriodTarif;
} else {
$tarifServerName = $tarif->servername;
}
$status = 0;
} else {
$testdomain = "-";
$tarifServerName = $tarif->servername;
$status = 1;
}
if ($server->type == "ventrilo") {
$login = $user->email;
$ventrilo = new Ventrilo($server->user,$server->password,$server->ventrilo_resid);
$result = $ventrilo->createAccount($tarifServerName, $server->ventrilo_placeid, $order->id, $login, $pwd);
if ($result) {
$remarkUser = "IP/Port: ".$result."nURL: ".$server->ventrilo_url;
@mysql_query("update orders set serverlogin='$user->email',serverpassword='$pwd',serverid='$server->id',remarkUser='$remarkUser',status='$status'$sqlAddDays where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $ventrilo->error;
}
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,$server->password);
if (!$da->error) {
if ($tarif->vid == "hosting") {
$result = $da->createAccount($login, $user->email, $pwd, $order->domain, $tarifServerName, $userip);
} else if ($tarif->vid == "reseller") {
$result = $da->createResellerAccount($login, $user->email, $pwd, $order->domain, $tarifServerName);
}
if ($result) {
mconnect();
if ($order->testPeriod) { $status='0'; } else { $status='1'; }
@mysql_query("update orders set serverlogin='$login',serverpassword='$pwd',serverid='$server->id',status='$status'$sqlAddDays where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
if ($server->setrulanguage) { $da->set_language($login,"ru"); }
if ($order->testPeriod and $tarif->testPeriodDomain) {
$da->logOut();
$da2 = new DirectAdmin($server->protocol,$server->ip,$login,$pwd);
$parkResult = $da2->add_domain_pointer($order->domain,$testdomain);
if (!$parkResult) { $parkError = $da2->error; }
}
} else {
$error = $da->error;
}
} else {
$error = $da->error;
}
$da->logOut();
mconnect();
}
else if ($server->type == "cpanel") {
$autowhm = new whm;
$autowhm->init($server->protocol,$server->ip,$server->user,$server->password);
if ($tarif->onlyDedicatedIP) {
$cpaneluserip = $userip;
} else {
$cpaneluserip = "";
}
if ($tarif->vid == "hosting") {
$result=$autowhm->createAccount($order->domain,$login,$pwd,$tarifServerName,"",$user->email,$cpaneluserip,0);
} else if ($tarif->vid == "reseller") {
$result=$autowhm->createAccount($order->domain,$login,$pwd,$tarifServerName,"",$user->email,$cpaneluserip,1);
}
if ($result) {
mconnect();
if ($order->testPeriod) { $status='0'; } else { $status='1'; }
@mysql_query("update orders set serverlogin='$login',serverpassword='$pwd',serverid='$server->id',status='$status'$sqlAddDays where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
if ($server->setrulanguage) { $autowhm->changelanguage($login,"russian"); }
if ($order->testPeriod and $tarif->testPeriodDomain) { $parkResult = $autowhm->parkDomain($order->domain,$testdomain); }
}
else {
$error = $autowhm->errors[0];
}
mconnect();
}
else if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,$server->password,$server->folder);
if ($tarif->vid == "hosting") {
$result=$autoisp->createAccount($order->domain,$login,$pwd,$tarifServerName,$userip,$user->email);
} else if ($tarif->vid == "reseller") {
$result=$autoisp->createResellerAccount($login,$pwd,$tarifServerName,$userip,$user->email);
}
mconnect();
if ($result) {
if ($order->testPeriod) { $status='0'; } else { $status='1'; }
@mysql_query("update orders set serverlogin='$login',serverpassword='$pwd',serverid='$server->id',status='$status'$sqlAddDays where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if ($order->testPeriod and $tarif->testPeriodDomain) {
$parkResult = $autoisp->addDomain($testdomain,$userip,"$server->ns1.%20$server->ns2.","mail","$login","","");
if (!$parkResult) { $parkError = $autoisp->errors[0]; }
else {
$parkResult = $autoisp->addAlias($order->domain,$testdomain);
if (!$parkResult) { $parkError = $autoisp->errors[0]; }
}
}
$error = "";
}
else {
$error = $autoisp->errors[0];
}
mconnect();
}
else if ($server->type == "shellscript") {
$command = $tarif->scriptCreate;
$reply = $tarif->scriptCreateReply;
if ($command) {
$command = preg_replace("/{login}/ui","$login",$command);
$command = preg_replace("/{password}/ui","$pwd",$command);
$command = preg_replace("/{domain}/ui","$order->domain",$command);
$command = preg_replace("/{serverip}/ui","$server->ip",$command);
$command = preg_replace("/{userip}/ui","$userip",$command);
exec("$command", $result, $resultstatus);
mconnect();
if ($resultstatus) { $error = "Не удалось выполнить команду $command"; }
else {
$result = @join("",$result);
if (!$reply or preg_match("/".$reply."/ui",$result)) {
@mysql_query("update orders set serverlogin='$login',serverpassword='$pwd',serverid='$server->id',status='1' where id='$order->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
}
else { $error = "Билилнгом был получен неудовлетворительный ответ для команды $command"; }
}
}
else { $error = "В тарифном плане ID # $tarif->id, $tarif->name не указан скрипт для создания аккаунтов."; }
}
if (!$error and $useripid) {
@mysql_query("update servers_ips set order_id='$order->id',isMain='1' where id='$useripid'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
if ($order->testPeriod and $tarif->testPeriodDomain and !$parkResult) {
if ($parkError) {$parkError = " (".$parkError.")"; }
$subject = "Ошибка парковки домена";
$template = "Не удалось припарковать домен $testdomain к домену $order->domain на сервере $server->name для заказа ID # $order->id в рамках тестового периода$parkError. Сделайте это вручную.";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
sendmail($user->email, '', $user->email, $subject, $template);
}
if (!$error and $server->sendmsg) {
$tpl=GetTpl('msg_'.$server->type, $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$company_name=GetSetting('company_name');
$company_url=GetSetting('company_url');
$support_url=GetSetting('support_url');
$manager_email=GetSetting('manager_email');
$subject = str_replace('{domain}',$order->domain,$subject);
$template = str_replace('{company_name}',$company_name,$template);
$template = str_replace('{company_url}',$company_url,$template);
$template = str_replace('{support_url}',$support_url,$template);
$template = str_replace('{domain}',$order->domain,$template);
$template = str_replace('{testdomain}',$testdomain,$template);
$template = str_replace('{panelurl}',$server->ventrilo_url,$template);
$template = str_replace('{ip}',$userip,$template);
$template = str_replace('{login}',$login,$template);
$template = str_replace('{password}',$pwd,$template);
$template = str_replace('{ns1}',$server->ns1,$template);
if ($server->ns3 or $server->ns4) { $template = str_replace('{ns2}',$server->ns2."rnThird NameServer: $server->ns3rnFourth NameServer: $server->ns4",$template); } else { $template = str_replace('{ns2}',$server->ns2,$template); }
WriteMailLog($subject,$template,$user->id);
sendmail($user->email,$company_name,$manager_email,$subject,$template);
sendmail($user->email2,$company_name,$manager_email,$subject,$template);
$subject = "Duplicate: ".$subject;
$admEmails=GetAdminEmailsWhereTrueParam("sendcreateactmsg");
if (count($admEmails) > 0) {
WriteMailLog($subject,$template);
}
sendmail($manager_email, '', $user->email, $subject, $template);
}
}
if (!$error and ($tarif->vid == "hosting" or $tarif->vid == "reseller")) {
$addons = GetAddonsIdsByTxt($order->addons);
if ($addons) {
while (list($k,$v) = each($addons)) {
$addon = GetAddonById($v);
if ($addon->type == "uploaddir" and @is_dir($addon->field1)) {
if ($server->type == "isp") {
$uploadto = "/www/".$order->domain."/";
} else if ($server->type == "cpanel") {
$uploadto = "/public_html/";
} else if ($server->type == "da") {
$uploadto = "/domains/".$order->domain."/public_html/";
} else {
$uploadto = "";
}
if ($uploadto) {
$conn_id = @ftp_connect($server->ip);
$login_result = @ftp_login($conn_id, $login, $pwd);
if ($conn_id and $login_result) {
ftpUploadDir($conn_id,$addon->field1,$uploadto);
@ftp_close($conn_id);
}
}
}
}
}
}
} else { $error = "Не найден пользователь ID #$order->uid."; }
} else { $error = "Нет ни одного свободного выделенного IP для сервера ID # $server->id, $server->name"; }
} else { $error = "Сервер настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Не найден сервер ID #".$tarif->serverid."/".$order->serverid; }
} else { $error = "В настройках тарифного плана $tarif->name не указано название тарифа на сервере или не выбран сервер."; }
} else { $error = "Не найден тарифный план ID #$order->tarif."; }
} else { $error = "Не найден заказ ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически создать аккаунт на сервере для заказа ID #$orderid ($order->domain) по следующей причине:nn$errornnВам необходимо создать аккаунт вручную, а затем заполнить поле 'Логин на сервере' и выбрать сервер в редактировании заказа!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка создания аккаунта";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
}
return false;
} else {
return true;
}
}
function deleteUser($orderid, $sendErrorEmail = 1) {
global $GLOBALerror;
$order = GetOrderById($orderid);
if ($order->id) {
if ($order->serverlogin and $order->serverid) {
$tarif = GetTarifById($order->tarif);
if ($tarif->id) {
if ($tarif->autodelete) {
$server = GetServers($order->serverid);
if ($server->id) {
if (($server->type and $server->ip and $server->user and $server->password) or $server->type == "ventrilo") {
if ($server->type == "ventrilo") {
$ventrilo = new Ventrilo($server->user,$server->password,$server->ventrilo_resid);
$result = $ventrilo->terminateAccount($order->id);
if ($result) {
$error = "";
} else {
$error = $ventrilo->error;
}
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,$server->password);
if (!$da->error) {
$result = $da->delete_user($order->serverlogin);
if (!$result) {
$error = $da->error;
}
$da->logOut();
} else {
$error = $da->error;
$da->logOut();
}
mconnect();
}
else if ($server->type == "cpanel") {
$autowhm = new whm;
$autowhm->init($server->protocol,$server->ip,$server->user,$server->password);
if ($tarif->vid == "hosting") {
$result=$autowhm->terminate($order->serverlogin);
} else if ($tarif->vid == "reseller") {
$result=$autowhm->terminateReseller($order->serverlogin);
}
if ($result) {
$error = '';
} else {
$error = $autowhm->errors[0];
}
mconnect();
}
else if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,$server->password,$server->folder);
if ($tarif->vid == "hosting") {
$result=$autoisp->terminate($order->serverlogin);
} else if ($tarif->vid == "reseller") {
$result=$autoisp->terminateReseller($order->serverlogin);
}
if ($result) {
$error = '';
} else {
$error = $autowhm->errors[0];
}
mconnect();
}
else if ($server->type == "shellscript") {
$command = $tarif->scriptDelete;
$reply = $tarif->scriptDeleteReply;
if ($command) {
$command = preg_replace("/{login}/ui","$order->serverlogin",$command);
$command = preg_replace("/{password}/ui","$order->serverpassword",$command);
$command = preg_replace("/{domain}/ui","$order->domain",$command);
$command = preg_replace("/{serverip}/ui","$server->ip",$command);
$command = preg_replace("/{userip}/ui",GetOrderIpByOrderId($order->id),$command);
exec("$command", $result, $resultstatus);
mconnect();
if ($resultstatus) { $error = "Не удалось выполнить команду $command"; }
else {
$result = @join("",$result);
if (!$reply or preg_match("/".$reply."/ui",$result)) { $error = ""; }
else { $error = "Билилнгом был получен неудовлетворительный ответ для команды $command"; }
}
}
else { $error = "В тарифном плане ID # $tarif->id, $tarif->name не указан скрипт для удаления аккаунтов."; }
}
} else { $error = "Сервер настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Не найден сервер ID #$order->serverid."; }
} else { $error = "Возможность автоматического удаления аккаунтов на сервере для данного тарифного плана отключена."; }
} else { $error = "Не найден тарифный план ID #$order->tarif."; }
} else { $error = "Не указан логин на сервере или не выбран сервер для данного заказа."; }
} else { $error = "Не найден заказ ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически удалить аккаунт $order->serverlogin на сервере для заказа ID #$orderid ($order->domain) по следующей причине:nn$errornnВам необходимо удалить аккаунт вручную!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка при попытке удалить аккаунт";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
}
return false;
} else {
return true;
}
}
function suspendUser($orderid, $suspend = 1, $sendErrorEmail = 1) {
global $GLOBALerror;
$order = GetOrderById($orderid);
if ($order->id) {
if ($order->serverlogin and $order->serverid) {
$tarif = GetTarifById($order->tarif);
if ($tarif->id) {
if ($tarif->autosuspend) {
$server = GetServers($order->serverid);
if ($server->id) {
if (($server->type and $server->ip and $server->user and $server->password) or $server->type == "ventrilo") {
if ($server->type == "ventrilo") {
$ventrilo = new Ventrilo($server->user,$server->password,$server->ventrilo_resid);
if (!$suspend) {
$result = $ventrilo->unSuspendAccount($tarif->servername,$order->id);
}
else if ($suspend) {
$result = $ventrilo->suspendAccount($order->id);
}
if ($result) {
$error = "";
} else {
$error = $ventrilo->error;
}
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,$server->password);
if (!$da->error) {
if ($suspend) {
$result = $da->suspend_user($order->serverlogin);
if (!$result) {
$error = $da->error;
}
} else {
$result = $da->activate_user($order->serverlogin);
if (!$result) {
$error = $da->error;
}
}
$da->logOut();
} else {
$error = $da->error;
$da->logOut();
}
mconnect();
}
else if ($server->type == "cpanel") {
$autowhm = new whm;
$autowhm->init($server->protocol,$server->ip,$server->user,$server->password);
if (!$suspend) {
if ($tarif->vid == "hosting") {
$result=$autowhm->unsuspend($order->serverlogin);
} else if ($tarif->vid == "reseller") {
$result=$autowhm->unsuspendReseller($order->serverlogin);
}
}
else if ($suspend) {
if ($tarif->vid == "hosting") {
$result=$autowhm->suspend($order->serverlogin, "AutoSuspendByRootPanel");
} else if ($tarif->vid == "reseller") {
$result=$autowhm->suspendReseller($order->serverlogin, "AutoSuspendByRootPanel");
}
}
if ($result) {
$error = '';
} else {
$error = $autowhm->errors[0];
}
mconnect();
}
else if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,$server->password,$server->folder);
if (!$suspend) {
if ($tarif->vid == "hosting") {
$result=$autoisp->unsuspend($order->serverlogin);
} else if ($tarif->vid == "reseller") {
$result=$autoisp->unsuspendReseller($order->serverlogin);
}
}
else if ($suspend) {
if ($tarif->vid == "hosting") {
$result=$autoisp->suspend($order->serverlogin);
} else if ($tarif->vid == "reseller") {
$result=$autoisp->suspendReseller($order->serverlogin);
}
}
if ($result) {
$error = '';
} else {
$error = $autoisp->errors[0];
}
mconnect();
}
else if ($server->type == "shellscript") {
if ($suspend) {
$command = $tarif->scriptSuspend;
$reply = $tarif->scriptSuspendReply;
} else if (!$suspend) {
$command = $tarif->scriptUnSuspend;
$reply = $tarif->scriptUnSuspendReply;
}
if ($command) {
$command = preg_replace("/{login}/ui","$order->serverlogin",$command);
$command = preg_replace("/{password}/ui","$order->serverpassword",$command);
$command = preg_replace("/{domain}/ui","$order->domain",$command);
$command = preg_replace("/{serverip}/ui","$server->ip",$command);
$command = preg_replace("/{userip}/ui",GetOrderIpByOrderId($order->id),$command);
exec("$command", $result, $resultstatus);
mconnect();
if ($resultstatus) { $error = "Не удалось выполнить команду $command"; }
else {
$result = @join("",$result);
if (!$reply or preg_match("/".$reply."/ui",$result)) { $error = ""; }
else { $error = "Билилнгом был получен неудовлетворительный ответ для команды $command"; }
}
}
else { $error = "В тарифном плане ID # $tarif->id, $tarif->name не указан скрипт для остановки или запуска аккаунтов."; }
mconnect();
}
} else { $error = "Сервер настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Не найден сервер ID #$order->serverid."; }
} else { $error = "Возможность автоматической остановки/запуска аккаунтов на сервере для данного тарифного плана отключена."; }
} else { $error = "Не найден тарифный план ID #$order->tarif."; }
} else { $error = "Не указан логин на сервере или не выбран сервер для данного заказа."; }
} else { $error = "Не найден заказ ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
if ($suspend) {$act="остановить";} else {$act="запустить";}
$errormsg = "RootPanel не смог автоматически $act аккаунт $order->serverlogin на сервере для заказа ID #$orderid ($order->domain) по следующей причине:nn$errornnВам необходимо $act аккаунт вручную!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка при попытке $act аккаунт";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
}
return false;
} else {
return true;
}
}
function changePackage($orderid, $newTarifId, $sendErrorEmail = 1) {
global $GLOBALerror;
$order = GetOrderById($orderid);
$server = GetServers($order->serverid);
if ($order->id) {
if ($order->serverlogin and $order->serverid) {
$tarif = GetTarifById($order->tarif);
$newTarif = GetTarifById($newTarifId);
if ($tarif->id) {
if ($newTarif->id) {
if ($newTarif->servername or $server->type == "shellscript") {
if (($order->serverid == $newTarif->serverid) or GetSetting("changetarif_trycurrentserver")) {
if ($server->id) {
if (($server->type and $server->ip and $server->user and $server->password) or $server->type == "ventrilo") {
if ($server->type == "ventrilo") {
$ventrilo = new Ventrilo($server->user,$server->password,$server->ventrilo_resid);
$result = $ventrilo->adjustSlotsCount($newTarif->servername, $order->id);
if ($result) {
$error = "";
} else {
$error = $ventrilo->error;
}
}
else if ($server->type == "da") {
$da = new DirectAdmin($server->protocol,$server->ip,$server->user,$server->password);
if (!$da->error) {
if ($order->serverid != $newTarif->serverid) {
$tarifs_at_server = $da->get_packages();
}
if (($order->serverid == $newTarif->serverid) or @in_array($newTarif->servername,$tarifs_at_server)) {
$result = $da->set_package_user($order->serverlogin,$newTarif->servername);
if ($result) {
$error = "";
} else {
$error = $da->error;
}
} else {
$error = "На сервере отсутствует тарифный план $newTarif->servername.";
}
$da->logOut();
} else {
$error = $da->error;
$da->logOut();
}
mconnect();
}
else if ($server->type == "cpanel") {
$autowhm = new whm;
$autowhm->init($server->protocol,$server->ip,$server->user,$server->password);
if ($order->serverid != $newTarif->serverid) {
$tarifs_at_server = $autowhm->listPkgs();
$error = $autowhm->errors[0];
}
if (!$error) {
if (($order->serverid == $newTarif->serverid) or @in_array($newTarif->servername,$tarifs_at_server)) {
$result=$autowhm->changepackage($order->serverlogin,$newTarif->servername);
if ($result) {
$error = '';
} else {
$error = $autowhm->errors[0];
}
} else {
$error = "На сервере отсутствует тарифный план $newTarif->servername.";
}
}
mconnect();
}
else if ($server->type == "isp") {
$autoisp = new ISPManager;
$autoisp->init($server->protocol,$server->ip,$server->user,$server->password,$server->folder);
if ($order->serverid != $newTarif->serverid) {
$tarifs_at_server = $autoisp->getPackages();
$error = $autoisp->errors[0];
}
if (!$error) {
if (($order->serverid == $newTarif->serverid) or @in_array($newTarif->servername,$tarifs_at_server)) {
if ($tarif->vid == "hosting") {
$result=$autoisp->changePackage($order->serverlogin,$newTarif->servername);
} else if ($tarif->vid == "reseller") {
$result=$autoisp->changeResellerPackage($order->serverlogin,$newTarif->servername);
}
if ($result) {
$error = '';
} else {
$error = $autoisp->errors[0];
}
} else {
$error = "На сервере отсутствует тарифный план $newTarif->servername.";
}
}
mconnect();
}
else if ($server->type == "shellscript") {
$command = $newTarif->scriptChange;
$reply = $newTarif->scriptChangeReply;
if ($command) {
$command = preg_replace("/{login}/ui","$order->serverlogin",$command);
$command = preg_replace("/{password}/ui","$order->serverpassword",$command);
$command = preg_replace("/{domain}/ui","$order->domain",$command);
$command = preg_replace("/{serverip}/ui","$server->ip",$command);
$command = preg_replace("/{userip}/ui",GetOrderIpByOrderId($order->id),$command);
exec("$command", $result, $resultstatus);
mconnect();
if ($resultstatus) { $error = "Не удалось выполнить команду $command"; }
else {
$result = @join("",$result);
if (!$reply or preg_match("/".$reply."/ui",$result)) { $error = ""; }
else { $error = "Билилнгом был получен неудовлетворительный ответ для команды $command"; }
}
}
else { $error = "В тарифном плане ID # $newTarif->id, $newTarif->name не указан скрипт для смены тарифного плана."; }
}
} else { $error = "Сервер настроен неправильно (отсутствуют некоторые настройки)."; }
} else { $error = "Не найден сервер ID #$order->serverid."; }
} else { $error = "Смена тарифного плана возможна только в пределах одного сервера."; }
} else { $error = "Не указано название на сервере для тарифного плана $newTarif->name"; }
} else { $error = "Не найден тарифный план ID #$newTarifId."; }
} else { $error = "Не найден тарифный план ID #$order->tarif."; }
} else { $error = "Не указан логин на сервере или не выбран сервер для данного заказа."; }
} else { $error = "Не найден заказ ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически сменить тарифный план для аккаунта $order->serverlogin на сервере для заказа ID #$orderid ($order->domain) по следующей причине:nn$errornnВам необходимо сменить тарифный план на сервере вручную! В биллинге все необходимые изменения уже произведены!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка при попытке сменить тарифный план";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
}
return false;
} else {
return true;
}
}
function GetPrioritySelect($priority = "0") {
global $_priority;
print "<select class=input name=priority>";
while (list($index,$value) = each($_priority)) {
if ($priority == $index) {$addon="selected";} else {$addon="";}
print "<option value=$index $addon>$value</option>";
}
print "</select>";
}
function printCountrySelect($id = '',$isReadOnly = '0') {
global $_lang;
if ($isReadOnly) {$isReadOnly = "disabled"; print "<input type=hidden name=country value=$id>"; } else { $isReadOnly = "";}
print "<select class=input name=country $isReadOnly><option></option>";
while (list($k,$v) = each($_lang[Country])) {
if ($id == $k) {$addon='selected';} else {$addon='';}
print "<option value=$k $addon>$v</option>";
}
print "</select>";
}
function printOblastSelect($country, $obl = '', $isReadOnly = '0') {
global $_lang, $styleHelp;
if (count($_lang[Oblast][$country]) > 0) {
if ($isReadOnly) {$isReadOnly = "disabled"; print "<input type=hidden name=oblast value='$obl'>";} else { $isReadOnly = "";}
print "<select class=input name=oblast $isReadOnly><option></option>";
while (list($k,$v) = each($_lang[Oblast][$country])) {
if ($obl == $v) {$addon='selected';} else {$addon='';}
print "<option value='$v' $addon>$v</option>";
}
print "</select>";
} else {
if ($isReadOnly) {$isReadOnly = "readonly";} else { $isReadOnly = "";}
print "<input class=input type=text name=oblast $isReadOnly value="$obl" size=40><p style="$styleHelp">".$_lang[ProfileOblastComment]."";
}
}
function printAutoregSelect($registr = '') {
print "<select class=input name=autoreg><option></option>";
$r = GetRegistrators();
if ($r) {
while ($rr = mysql_fetch_object($r)) {
print "<option value=$rr->id "; if ($registr == $rr->id) { print "selected"; } print ">$rr->name</option>";
}
}
print "</select>";
}
function printProfileSelect($userid,$profileId,$withCreateNew='0',$selectName='profileId',$isReadOnly='0') {
global $_lang;
if ($isReadOnly) {$isReadOnly = "disabled";} else { $isReadOnly = "";}
print "<select class=input name=$selectName $isReadOnly>";
if ($withCreateNew and GetSetting("profileMultiEnable")) { print "<option value=new> ".$_lang[ProfileCreateNewProfile];}
$r = @mysql_query("select * from users_profile where uid='$userid' order by id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($r) > 0) {
while ($rr = mysql_fetch_object($r)) {
$profileName = "[$rr->id]";
if ($rr->org == "1" or $rr->org == "2") {
if ($rr->surname or $rr->name or $rr->otchestvo) { $profileName=$profileName." $rr->surname $rr->name $rr->otchestvo";}
} else if ($rr->org == "3") {
if ($rr->firma) { $profileName=$profileName." $rr->firma";}
}
print "<option value=$rr->id "; if ($profileId == $rr->id) { print "selected"; } print ">$profileName</option>";
}
}
print "</select>";
}
function checkProfileByAdmin($userid, $profileid='') {
global $isR, $isD, $full_www_path, $admin_script;
$type=GetSetting("profileCheckByAdmin");
if ($type == "not") {
return true;
} else {
$object=GetUserProfileByUserId($userid,$profileid);
$isError = false;
if (!$object->profileChecked) {
if ($type == "ru" and $isR) { $isError = true; }
else if ($type == "domains" and ($isR or $isD)) { $isError = true; }
else if ($type == "max") { $isError = true; }
} else {
return true;
}
if ($isError) {
if (!$object->profileCheckSent) {
$user=GetUserById($userid);
$manager_email=GetSetting('manager_email');
$subject = "Проверка профайла ID # ".$object->id." [".$user->login."]";
$errormsg = "Внимание! Вам необходимо проверить профайл ID # $object->id у клиента ID # $user->id, $user->loginnnСсылка для проверки: ".$full_www_path.$admin_script."?do=profile&id=$user->id&profileId=$object->idnn--nRootPanel";
$admEmails=GetAdminEmailsWhereTrueParam("sendprofilecheck");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
@mysql_query("update users_profile set profileCheckSent='1' where uid='$user->id' and id='$object->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
return false;
}
return false;
} else {
return true;
}
}
}
function checkProfile($type, $userid='', $profileid='') {
# $type:
# not - не проверяем ничего, кроме email
# min - проверка минимального кол-ва полей, необходимых для регистрации com/net/org и т.п.
# max - проверка всех полей, включая паспортные данные, необходимых для регистрации ru/su
global $GLOBALerror, $_lang, $isR, $isD, $org, $surname, $name, $otchestvo, $firma, $firmaeng, $country, $oblast, $post, $city, $street, $komu, $address_org, $phone, $fax, $email, $seriya, $by, $date, $birthday, $inn, $kpp, $okonh, $bank, $bank_schet, $bank_bik, $edrpou, $passportFiles, $socstrahnumber, $ogrn;
if ($userid) {
$object=GetUserProfileByUserId($userid,$profileid);
if ($object->org and $object->country) { $org = $object->org; }
$surname = $object->surname;
$name = $object->name;
$otchestvo = $object->otchestvo;
$firma = $object->firma;
$firmaeng = $object->firmaeng;
$seriya = $object->pasport_seriya;
$by = $object->pasport_by;
$date = mydate($object->pasport_date);
$birthday = mydate($object->birthday);
$inn = $object->inn;
$kpp = $object->kpp;
if ($object->org and $object->country) { $country = $object->country; }
$oblast = $object->oblast;
$post = $object->post;
$city = $object->city;
$street = $object->street;
$address_org = $object->address_org;
$komu = $object->komu;
$phone = $object->phone;
$fax = $object->fax;
$email = $object->email;
$icq = $object->icq;
$ripn = $object->ripn;
$ripe = $object->ripe;
$uanic = $object->uanic;
$okonh = $object->okonh;
$bank = $object->bank;
$bank_schet = $object->bank_schet;
$bank_bik = $object->bik;
$edrpou = $object->edrpou;
$passportFiles = $object->passportFiles;
$socstrahnumber = $object->socstrahnumber;
$ogrn = $object->ogrn;
}
$profilePassportDisabled = GetSetting("profilePassportDisabled");
if ($firma) { $firma = preg_replace("/[x{AB},x{BB}]/u","",$firma); }
if ($firmaeng) { $firmaeng = preg_replace("/[x{AB},x{BB}]/u","",$firmaeng); }
if ($by) { $by = preg_replace("/[x{AB},x{BB}]/u","",$by); }
if ($street) { $street = preg_replace("/[x{AB},x{BB}]/u","",$street); }
if ($address_org) { $address_org = preg_replace("/[x{AB},x{BB}]/u","",$address_org); }
if ($komu) { $komu = preg_replace("/[x{AB},x{BB}]/u","",$komu); }
if ($bank) { $bank = preg_replace("/[x{AB},x{BB}]/u","",$bank); }
$GLOBALerror = "";
$f = array();
if ($type != "not" and !$org) { $f[] = $_lang[ProfileUserType]; }
if ($type != "not" and (strlen($country) != 2 or $_lang[Country][$country] == "")) { $f[] = $_lang[ProfileCountry]; }
# Проверка общих полей
if ($type != "not" and mb_strlen($surname) < 3) { $f[] = $_lang[ProfileSurname]; $surname="";}
if ($type != "not" and mb_strlen($name) < 2) { $f[] = $_lang[ProfileName]; $name="";}
if ($type != "not" and mb_strlen($otchestvo) < 3) { $f[] = $_lang[ProfileOtchestvo]; $otchestvo="";}
# Проверка полей частного лица и частного предпринимателя
if (($org == "1" or $org == "2") and $country != "FI") {
if (!$profilePassportDisabled) {
if ($type == "max" and $country == "RU" and !preg_match("/^d{2} d{2} d{6}$/u",$seriya) and !preg_match("/^d{2} d{7}$/u",$seriya)) { $f[] = $_lang[ProfilePassportSeriya]; $seriya="";}
else if ($type == "max" and $country == "UA" and !preg_match("/^D{2} d{6}$/u",$seriya)) { $f[] = $_lang[ProfilePassportSeriya]; $seriya="";}
else if ($type == "max" and $country == "BY" and !preg_match("/^D{2} d{7}$/u",$seriya)) { $f[] = $_lang[ProfilePassportSeriya]; $seriya="";}
else if ($type == "max" and (mb_strlen($seriya) < 8 or preg_match("/№/ui", $seriya) or !preg_match("/S+s{1}.+/u",$seriya))) { $f[] = $_lang[ProfilePassportSeriya]; $seriya="";}
if ($type == "max" and mb_strlen($by) < 10) { $f[] = $_lang[ProfilePassportVidan]; $by="";}
if ($type == "max" and (!preg_match("/^d{2}.d{2}.d{4}$/u",$date) or $date == "00.00.0000")) { $f[] = $_lang[ProfilePassportVidanData]; $date="00.00.0000";}
if ($type == "max" and (!preg_match("/^d{2}.d{2}.d{4}$/u",$birthday) or $birthday == "00.00.0000")) { $f[] = $_lang[ProfileBirthDate]; $birthday="00.00.0000";}
}
if ($org == "2" and $country == "UA") {
if ($type != "not" and (preg_match("/[D]+/u",$edrpou) or strlen($edrpou) != 10)) { $f[] = $_lang[ProfileEdrpou]; $edrpou="";}
} else if ($org == "2" and $country == "BY") {
if ($type != "not" and (preg_match("/[D]+/u",$inn) or strlen($inn) != 9)) { $f[] = $_lang[ProfileInn]; $edrpou="";}
} else if ($org == "2" and $country == "RU") {
if ($type != "not" and ((preg_match("/[D]+/u",$inn) or (strlen($inn) != 10 and strlen($inn) != 12)))) { $f[] = $_lang[ProfileInn]; $inn="";}
}
if ($country == "FI" and $org == "1") {
if ($type != "not" and !preg_match("/^d{6}-d{3}w{1}$/u",$socstrahnumber)) { $f[] = $_lang[ProfileSocStrahNumber]; $socstrahnumber="";}
}
if ($country == "HU" and $org == "2") {
if ($type != "not" and !$ogrn) { $f[] = $_lang[ProfileRegNumberPP]; $ogrn="";}
}
}
$passportFilesEnable = GetSetting("passportFilesEnable");
$passportFilesRequired = GetSetting("passportFilesRequired");
if ($passportFilesEnable and !$profilePassportDisabled) {
if (!$passportFiles) {
if (($passportFilesRequired == "ru" and $isR) or ($passportFilesRequired == "domains" and ($isD or $isR)) or ($passportFilesRequired == "max" and $type == "max")) { $f[] =$_lang[ProfilePassportFiles]; }
}
}
# Проверка полей организации
if ($org == "3" or ($org == "2" and $country == "FI")) {
if ($type != "not" and mb_strlen($firma) < 6) { $f[] = $_lang[ProfileOrg]; $firma="";}
if ($country != "FI") { if ($type != "not" and strlen($firmaeng) < 6) { $f[] = $_lang[ProfileOrgEng]; $firmaeng="";} }
if ($type != "not" and mb_strlen($address_org) < 15) { $f[] = $_lang[ProfileYuridAddress]; $address_org="";}
if ($country == "UA" or $country == "RU") {
if ($type != "not" and $inn and ((preg_match("/[D]+/u",$inn) or (strlen($inn) != 10 and strlen($inn) != 12)))) { $f[] = $_lang[ProfileInn]; $inn="";}
} else if ($country == "BY") {
if ($type != "not" and $inn and ((preg_match("/[D]+/u",$inn) or strlen($inn) != 9))) { $f[] = $_lang[ProfileInn]; $inn="";}
}
if ($country == "RU") {
if ($type != "not" and ((preg_match("/[D]+/u",$kpp) or strlen($kpp) != 9))) { $f[] = $_lang[ProfileKpp]; $kpp="";}
if ($type != "not" and $okonh and ((preg_match("/[D]+/u",$okonh) or mb_strlen($okonh) < 3))) { $f[] = $_lang[ProfileOkonh]; $okonh="";}
}
if ($country == "FI") {
if ($type != "not" and !preg_match("/d{7}-d{1}/u",$ogrn)) { $f[] = $_lang[ProfileOgrn]; $ogrn="";}
} else if ($country == "HU") {
if ($type != "not" and !$ogrn) { $f[] = $_lang[ProfileOgrn]; $ogrn="";}
}
}
# Проверка общих полей
if ($type != "not" and ($country == "RU" or $country == "UA" or $country == "BY" or $country == "KZ") and !$oblast) { $f[] = $_lang[ProfileOblast]; $oblast="";}
if ($type != "not" and mb_strlen($post) < 4) { $f[] = $_lang[ProfileIndex]; $post="";}
if ($type != "not" and mb_strlen($city) < 3) { $f[] = $_lang[ProfileCity]; $city="";}
else if ($type != "not" and (preg_match("/^г /iu", $city) or preg_match("/^г./iu", $city) or preg_match("/^город /iu", $city))) { $f[] = $_lang[ProfileCity]; $city="";}
if ($type != "not" and mb_strlen($street) < 5) { $f[] = $_lang[ProfileAddress]; $street="";}
if ($type != "not" and $country != "FI" and !$komu) { $f[] = $_lang[ProfileKomu]; $komu="";}
if ($type != "not" and (!preg_match("/^+d+s{1}d+s{1}d+$/u",$phone) or strlen($phone) < 8)) { $f[] = $_lang[ProfilePhone]; $phone="";}
if ($type != "not" and $fax and (!preg_match("/^+d+s{1}d+s{1}d+$/u",$fax) or strlen($fax) < 8)) { $f[] = $_lang[ProfileFax]; $fax="";}
if (!valid_email($email)) { $f[] = $_lang[ProfileEmail]; $email="";}
if (count($f) > 0) { $GLOBALerror = $_lang[ProfileErrorFields].": ".@join(", ",$f);}
if ($GLOBALerror) { return false; }
else {return true;}
}
function regDomain($domain_id, $period, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $onlinenicDomainTypes, $nicruService, $startedRegion;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($zone->autoreg) {
$registrator = GetRegistratorById($zone->autoreg);
if ($registrator->active) {
$registratorId = $registrator->id;
$user = GetUserById($domain->uid);
if ($user->id) {
if (strtolower($zone->zone) == "ru" or strtolower($zone->zone) == "su") { $isR = 1; $chkProfile = "max"; } else { $isD = 1; $chkProfile = GetSetting("checkprofiletype"); }
if (checkProfile($chkProfile, $user->id, $domain->profileId)) {
if (strtolower($zone->zone) == "ru") { $isR = 1; $isD=""; } else { $isD = 1; $isR="";}
if (checkProfileByAdmin($user->id, $domain->profileId)) {
$profile = GetUserProfileByUserId($user->id, $domain->profileId);
if ($registrator->type != "started" and $registrator->type != "r01") {
$profile->oblast = preg_replace("/область/ui","",$profile->oblast);
$profile->oblast = preg_replace("/обл./ui","",$profile->oblast);
$profile->oblast = preg_replace("/обл$/ui","",$profile->oblast);
$profile->oblast = preg_replace("/^обл/ui","",$profile->oblast);
}
if ($domain->host_id) {
$order=GetOrderById($domain->host_id);
if ($order->serverid) {
$server=GetServers($order->serverid);
if ($server->ns1 and $server->ns2) {
$ns1=trim($server->ns1);
$ns2=trim($server->ns2);
$ns3=trim($server->ns3);
$ns4=trim($server->ns4);
}
}
} else {
$ns1=trim($domain->ns1);
$ns2=trim($domain->ns2);
$ns3=trim($domain->ns3);
$ns4=trim($domain->ns4);
}
if ($ns1 and $ns2) {
if ($registrator->type == "regru") {
$regru_url = $registrator->url;
$regru_user = $registrator->text1;
$regru_password = $registrator->text2;
if ($regru_url and $regru_user and $regru_password) {
$regru_fail_if_no_money = $registrator->check1;
$regru_no_bill_notify = $registrator->check2;
$regru = new REGRU;
$regru->init($regru_url,$regru_user,$regru_password);
if (strtolower($zone->zone) == "ru" or strtolower($zone->zone) == "su") {
$p_addr = $profile->post.", ".$profile->city.", ".$profile->street; if ($profile->komu) { $p_addr .= ", ".$profile->komu;}
if ($profile->org == "1" or $profile->org == "2") {
$otchestvo = $profile->otchestvo;
$person = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($otchestvo,0,1))." ".GotoTranslit($profile->surname);
$person_r = $profile->surname." ".$profile->name." ".$profile->otchestvo;
$passport = $profile->pasport_seriya." выдан ".$profile->pasport_by." ".mydate($profile->pasport_date);
$birth_date = mydate($profile->birthday);
$result=$regru->regRuDomainPerson($domain->domain,$period,$regru_fail_if_no_money,$regru_no_bill_notify,$ns1,$ns2,$ns3,$ns4,$person,0,$person_r,$passport,$birth_date,$profile->country,$p_addr,$profile->phone,$profile->fax,$profile->email,$profile->inn);
} else if ($profile->org == 3) {
$result=$regru->regRuDomainOrg($domain->domain,$period,$regru_fail_if_no_money,$regru_no_bill_notify,$ns1,$ns2,$ns3,$ns4,$profile->firmaeng,$profile->firma,$profile->inn,$profile->kpp,$profile->country,$profile->address_org,$p_addr,$profile->phone,$profile->fax,$profile->email);
}
} else {
if ($profile->org == "1" or $profile->org == "2") {
$o_company = "Private Person";
} else {
if ($profile->firmaeng) { $o_company = $profile->firmaeng; }
else if ($profile->firma) { $o_company = GotoTranslit($profile->firma); }
else { $o_company = "Private Person"; }
}
$o_first_name = GotoTranslit($profile->name);
$o_last_name = GotoTranslit($profile->surname);
list($telNoCc,$telNo1,$telNo2) = split(" ", $profile->phone);
$o_phone = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) {
list($faxNoCc,$faxNo1,$faxNo2) = split(" ", $profile->fax);
$o_fax = $faxNoCc.".".$faxNo1."".$faxNo2;
}
$o_addr = GotoTranslit($profile->street);
$o_city = GotoTranslit($profile->city);
$o_state = "NA";
$result=$regru->regEtcDomain($domain->domain,$period,$regru_fail_if_no_money,$regru_no_bill_notify,$ns1,$ns2,$ns3,$ns4,$o_company,$o_first_name,$o_last_name,$profile->email,$o_phone,$o_fax,$o_addr,$o_city,$o_state,$profile->post,$profile->country);
}
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $regru->errors[0];
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "webnames") {
$webnames_url = $registrator->url;
$webnames_user = $registrator->text1;
$webnames_password = $registrator->text2;
if ($webnames_url and $webnames_user and $webnames_password) {
$webnames = new WEBNAMES;
$webnames->init($webnames_url,$webnames_user,$webnames_password);
if (strtolower($zone->zone) == "ru" or strtolower($zone->zone) == "su") {
$p_addr = $profile->post.", ".$profile->city.", ".$profile->street; if ($profile->komu) { $p_addr .= ", ".$profile->komu;}
if ($profile->org == "1" or $profile->org == "2") {
$otchestvo = $profile->otchestvo;
$person = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($otchestvo,0,1))." ".GotoTranslit($profile->surname);
$person_r = $profile->surname." ".$profile->name." ".$profile->otchestvo;
$passport = $profile->pasport_seriya." выдан ".$profile->pasport_by." ".mydate($profile->pasport_date);
$birth_date = mydate($profile->birthday);
$result=$webnames->regRuDomainPerson($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$person,0,$person_r,$passport,$birth_date,$profile->country,$p_addr,$profile->phone,$profile->fax,$profile->email,$profile->inn);
} else if ($profile->org == "3") {
$result=$webnames->regRuDomainOrg($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$profile->firmaeng,$profile->firma,$profile->inn,$profile->kpp,$profile->country,$profile->address_org,$p_addr,$profile->phone,$profile->fax,$profile->email);
}
} else if (strtolower($zone->zone) == "kz" or strtolower($zone->zone) == "uz" or strtolower($zone->zone) == "tj") {
if ($profile->org == 3) {
$o_company_ru=$profile->firma;
$o_company_en=$profile->firmaeng;
$o_code=$profile->inn;
$o_bank=$profile->bank;
$o_bank_account=$profile->bank_schet;
$o_mfo=$profile->bank_bik;
$o_okonh=$profile->okonh;
}
$o_name_ru = $profile->name." ".$profile->surname;
$o_name_en = GotoTranslit($o_name_ru);
$nick = GotoTranslit($profile->name.$profile->surname);
$o_addr_ru = $profile->street;
$o_addr_en = GotoTranslit($o_addr_ru);
$o_city_ru = $profile->city;
$o_city_en = GotoTranslit($o_city_ru);
$o_state_ru = $profile->oblast;
$o_state_en = GotoTranslit($o_state_ru);
list($telNoCc,$telNo1,$telNo2) = split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; }
$result=$webnames->regKzUzTjDomain($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$o_name_ru,$o_name_en,$nick,$profile->email,$telNo,$faxNo,$o_addr_ru,$o_addr_en,$o_city_ru,$o_city_en,$o_state_ru,$o_state_en,$profile->post,$profile->country,$o_company_ru,$o_company_en,$o_code,$o_bank,$o_bank_account,$o_mfo,$o_okonh);
} else {
if ($profile->org == "3") {
$o_company = $profile->firmaeng;
} else {
$o_company = "Private Person";
}
$o_first_name = GotoTranslit($profile->name);
$o_last_name = GotoTranslit($profile->surname);
list($telNoCc,$telNo1,$telNo2) = split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; }
$o_addr = GotoTranslit($profile->street);
$o_city = GotoTranslit($profile->city);
$o_state = GotoTranslit($profile->oblast);
if (strtolower($zone->zone) == "asia") { $default_ced = "1"; } else { $default_ced = ""; }
$result=$webnames->regOtherDomain($domain->domain,$period,$ns1,$ns2,$ns3,$ns4,$o_company,$o_first_name,$o_last_name,$profile->email,$telNo,$faxNo,$o_addr,$o_city,$o_state,$profile->post,$profile->country,$default_ced);
}
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $webnames->errors[0];
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "naunet") {
if (strtolower($zone->zone) == "ru" or strtolower($zone->zone) == "su") {
$naunet_url = $registrator->url;
$naunet_user = $registrator->text1;
$naunet_password = $registrator->text2;
if ($naunet_url and $naunet_user and $naunet_password) {
$naunet = new NAUNET;
$naunet->init($naunet_url,$naunet_user,$naunet_password);
$p_addr = $profile->post.", ".$profile->city.", ".$profile->street; if ($profile->komu) { $address_r = $p_addr; $p_addr .= ", ".$profile->komu;}
if ($profile->org == "1" or $profile->org == "2") {
$otchestvo = $profile->otchestvo;
$person = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($otchestvo,0,1))." ".GotoTranslit($profile->surname);
$person_r = $profile->surname." ".$profile->name." ".$profile->otchestvo;
$passport = $profile->pasport_seriya." выдан ".$profile->pasport_by." ".mydate($profile->pasport_date);
$birth_date = mydate($profile->birthday);
if (!$profile->naunetLogin) {
$result=$naunet->regDomainNewPerson($domain->domain,$ns1,$ns2,$ns3,$ns4,$person,$person_r,$passport,$birth_date,$address_r,$p_addr,$profile->phone,$profile->fax,$profile->email,$profile->inn,"no");
} else {
$result=$naunet->regDomainExistsPerson($domain->domain,$ns1,$ns2,$ns3,$ns4,$profile->naunetLogin,"no");
}
} else if ($profile->org == "3") {
if (!$profile->naunetLogin) {
$result=$naunet->regDomainNewOrg($domain->domain,$ns1,$ns2,$ns3,$ns4,$profile->firmaeng,$profile->firma,$profile->inn,$profile->address_org,$p_addr,$profile->phone,$profile->fax,$profile->email);
} else {
$result=$naunet->regDomainExistsOrg($domain->domain,$ns1,$ns2,$ns3,$ns4,$profile->naunetLogin);
}
}
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
if (!$profile->naunetLogin) {
@mysql_query("update users_profile set naunetLogin='$profile->email' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
}
$error = "";
} else {
$error = $naunet->error;
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
} else { $error = "Авторегистрация не возможна, т.к. через $registrator->name поддерживается регистрация только RU/SU доменов."; }
}
else if ($registrator->type == "nicru") {
$nicru_url = $registrator->url;
$nicru_user = $registrator->text1;
$nicru_password = $registrator->text2;
if ($nicru_url and $nicru_user and $nicru_password) {
$nicru = new NICRU;
$nicru->init($nicru_url,$nicru_user,$nicru_password);
$anketaId = $profile->nicruAnketaId;
if (!$anketaId) {
$p_addr = $profile->post.", ".$profile->city.", ".$profile->street; if ($profile->komu) {$p_addr .= ", ".$profile->komu;}
$pw = generatePassword(8);
if ($profile->org == "1" or $profile->org == "2") {
$otchestvo = $profile->otchestvo;
$person = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($otchestvo,0,1))." ".GotoTranslit($profile->surname);
$person_r = $profile->surname." ".$profile->name." ".$profile->otchestvo;
$passport = $profile->pasport_seriya." выдан ".$profile->pasport_by." ".mydate($profile->pasport_date);
$birth_date = mydate($profile->birthday);
$anketaId=$nicru->regAnketaPerson($pw,$pw,$person,$person_r,$profile->country,$passport,$birth_date,$p_addr,$profile->phone,$profile->fax,$profile->email,$mnt);
} else if ($profile->org == "3") {
$anketaId=$nicru->regAnketaOrg($pw,$pw,$profile->firmaeng,$profile->firma,$profile->inn,$profile->kpp,$profile->country,$profile->address_org,$p_addr,$d_addr,$profile->phone,$profile->fax,$profile->email,$mnt);
}
mconnect();
if ($anketaId) {
@mysql_query("update users_profile set nicruAnketaId='$anketaId' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $nicru->error;
}
}
if ($anketaId) {
$zidx = strtolower($zone->zone);
$service = $nicruService[$zidx];
if ($service) {
$private_person = "OFF";
if (strtolower($zone->zone) == "ru" or strtolower($zone->zone) == "su") {
$orderId = $nicru->regRuDomain($anketaId,$service,$domain->domain,$ns1,$ns2,$ns3,$ns4,"Private Domain",$private_person,$profile->email,$profile->phone,$profile->fax);
} else {
$contactId = $profile->nicruContactId;
if (!$contactId) {
if ($profile->org == "3") { $company = $profile->firmaeng; } else if ($profile->firma) { $company = GotoTranslit($profile->firma); } else { $company = "Private Person"; }
$person = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($otchestvo,0,1))." ".GotoTranslit($profile->surname);
$city = GotoTranslit($profile->city);
if ($profile->oblast) { $region = GotoTranslit($profile->oblast); } else { $region = $city; }
$street = GotoTranslit($profile->street);
$contactId = $nicru->regContact($anketaId,$company,$person,$profile->country,$region,$city,$street,$profile->post,$profile->phone,$profile->fax,$profile->email);
mconnect();
if ($contactId) {
@mysql_query("update users_profile set nicruContactId='$contactId' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $nicru->error;
}
}
if ($contactId) {
$orderId = $nicru->regDomain($anketaId,$contactId,$service,$domain->domain,$period,$ns1,$ns2,$ns3,$ns4);
}
}
mconnect();
if ($orderId) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='',nicruOrderId='$orderId',panel_url='https://www.nic.ru/manager/',panel_user='$anketaId',panel_pwd='$pw' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $nicru->error;
}
}
else { $error = "Авторегистрация не возможна, т.к. через $registrator->name не поддерживается регистрация доменов в зоне ".$zone->zone."."; }
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, номер договора или пароль для $registrator->name"; }
}
else if ($registrator->type == "freehost") {
$freehost_url = $registrator->url;
$freehost_port = $registrator->port;
$freehost_user = $registrator->text1;
$freehost_password = $registrator->text2;
$freehost_nichandle = $registrator->text3;
if ($freehost_url and $freehost_port and $freehost_user and $freehost_password) {
$nichandle = $profile->uanic;
if (!$nichandle) { $nichandle = $freehost_nichandle; }
if ($nichandle) {
$freehost = new FREEHOST;
$freehost->init($freehost_url,$freehost_port,$freehost_user,$freehost_password);
$result=$freehost->registerDomain($domain->domain,$ns1,$ns2,$ns3,$ns4,$nichandle);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $freehost->error;
}
}
else { $error = "Авторегистрация домена не возможна, т.к. у клиента не заполнено поле UANIC и не указан Nic-handle по умолчанию для $registrator->name"; }
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "hostmaster") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = $registrator->text2;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$nichandle = $profile->uanic;
$hostmaster = new HOSTMASTER;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password);
if (!$nichandle) {
if ($profile->org == "1" or $profile->org == "2") {
$otchestvo = $profile->otchestvo;
$person = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($otchestvo,0,1))." ".GotoTranslit($profile->surname);
$org = "";
}
else if ($profile->org == "3") {
$person = "";
$org = $profile->firmaeng;
}
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$nichandle = $hostmaster->createNichandle($person,$org,$address,$city,$profile->country,$profile->phone,$profile->fax,$profile->email);
mconnect();
if ($nichandle) {
@mysql_query("update users_profile set uanic='$nichandle' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $hostmaster->error;
}
}
if (!$error) {
$result=$hostmaster->registerDomain($domain->domain,$ns1,$ns2,$ns3,$ns4,$nichandle);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $hostmaster->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "onlinenic") {
$onlinenic_url = $registrator->url;
$onlinenic_port = $registrator->port;
$onlinenic_user = $registrator->text1;
$onlinenic_password = $registrator->text2;
if ($onlinenic_url and $onlinenic_port and $onlinenic_user and $onlinenic_password) {
$zidx = strtolower($zone->zone);
$domaintype = $onlinenicDomainTypes[$zidx];
if ($domaintype >= 0) {
$onlinenic = new ONLINENIC;
$onlinenic->init($onlinenic_url,$onlinenic_port,$onlinenic_user,$onlinenic_password);
$otchestvo = $profile->otchestvo;
$name = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($otchestvo,0,1))." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $company = $profile->firmaeng; } else if ($profile->firma) { $company = GotoTranslit($profile->firma); } else { $company = "Private Person"; }
$street1 = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
list($telNoCc,$telNo1,$telNo2) = split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; } else { $faxNo = $telNo; }
$pw = generatePassword(8,1);
$contactId = $onlinenic->regDomain($domain->domain,$period,$ns1,$ns2,$domaintype,$name,$company,$street1,"",$city,"NA",$profile->post,$profile->country,$telNo,$faxNo,$profile->email,$pw);
mconnect();
if ($contactId) {
@mysql_query("update orders_domains set onlinenicContactId='$contactId',status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='',panel_url='https://www.onlinenic.com/cgi-bin/english/correct_domain_new.cgi',panel_user='$domain->domain',panel_pwd='$pw' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $onlinenic->error;
}
}
else { $error = "Авторегистрация не возможна, т.к. через $registrator->name не поддерживается регистрация доменов в зоне ".$zone->zone."."; }
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "directi") {
$est_url = $registrator->url;
$est_user = $registrator->text1;
$est_password = $registrator->text2;
$est_parentid = $registrator->text3;
if ($est_url and $est_user and $est_password and $est_parentid) {
#$SERVICE_URL = $est_url;
$estdomains = new ESTDOMAINS;
$estdomains->init($est_user,$est_password,$est_parentid,$full_home_path."/_rootinc/estdomains/wsdl/");
$customerIdArray = parseRPStrArray($profile->estCustomerId,":x:",":");
$customerId = $customerIdArray[$registratorId];
if (!$customerId) {
$otchestvo = $profile->otchestvo;
$name = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($otchestvo,0,1))." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $company = $profile->firmaeng; } else if ($profile->firma) { $company = GotoTranslit($profile->firma); } else { $company = "Private Person"; }
$address1 = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
list($telNoCc,$telNo1,$telNo2) = split(" ", $profile->phone); $telNoCc = preg_replace("/+/ui","",$telNoCc); $telNo = $telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = split(" ", $profile->fax); $faxNoCc = preg_replace("/+/ui","",$faxNoCc); $faxNo = $faxNo1."".$faxNo2; }
$langPref = "ru";
$customerId=$estdomains->signUp($profile->email, generatePassword(8,1), $name, $company, $address1, "", "", $city, "", $profile->country, $profile->post, $telNoCc, $telNo, "", "", $faxNoCc, $faxNo, $langPref, "", "");
mconnect();
if ($customerId) {
$customerIdArray[$registratorId] = $customerId;
$customerIdString = parseRPArrayStr($customerIdArray,":x:",":");
@mysql_query("update users_profile set estCustomerId='$customerIdString' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $estdomains->error;
}
}
if ($customerId) {
if (preg_match("/.uk$/ui",$domain->domain)) {
$contactType = "UkContact";
} else if (preg_match("/.eu$/ui",$domain->domain)) {
$contactType = "EuContact";
} else {
$contactType = "Contact";
}
$contactIdArray = parseRPStrArray($profile->estContactId,":x:",":");
$arrElem = $registratorId.$contactType;
$contactId = $contactIdArray[$arrElem];
if (!$contactId) {
$contactId=$estdomains->addDefaultContacts($customerId,$contactType);
mconnect();
if ($contactId) {
$contactIdArray[$arrElem] = $contactId;
$contactIdString = parseRPArrayStr($contactIdArray,":x:",":");
@mysql_query("update users_profile set estContactId='$contactIdString' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $estdomains->error;
}
}
if ($contactId) {
$invoiceOption = "NoInvoice";
$enablePrivacyProtection = false;
$orderId=$estdomains->registerDomain($domain->domain, $period, $contactId, $ns1, $ns2, $ns3, $ns4, $customerId, $invoiceOption, $enablePrivacyProtection);
mconnect();
if ($orderId) {
@mysql_query("update orders_domains set estOrderId='$orderId',status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $estdomains->error;
}
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин, пароль или parentid для $registrator->name"; }
}
else if ($registrator->type == "todaynic") {
$todaynic_url = $registrator->url;
$todaynic_user = $registrator->text1;
$todaynic_password = $registrator->text2;
if ($todaynic_url and $todaynic_user and $todaynic_password) {
$todaynic = new TODAYNIC;
$todaynic->init($todaynic_url,$todaynic_user,$todaynic_password);
$otchestvo = $profile->otchestvo;
$name = GotoTranslit($profile->name)." ".GotoTranslit(mb_substr($otchestvo,0,1))." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $company = $profile->firmaeng; } else if ($profile->firma) { $company = GotoTranslit($profile->firma); } else { $company = "Private Person"; }
$address1 = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
list($telNoCc,$telNo1,$telNo2) = split(" ", $profile->phone); $telNo = $telNoCc.".".$telNo1."".$telNo2;
if ($profile->fax) { list($faxNoCc,$faxNo1,$faxNo2) = split(" ", $profile->fax); $faxNo = $faxNoCc.".".$faxNo1."".$faxNo2; }
$result=$todaynic->registerDomain($domain->domain, $period, $ns1, $ns2, $ns3, $ns4, $name, $company, $profile->country, "", $profile->post, $city, $address1, $telNo, $faxNo, "", $profile->email);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $todaynic->error;
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "mail") {
$mail_to = $registrator->text3;
$mail_from = $registrator->text1;
$mail_nichandle = $registrator->text4;
$mail_subject = $registrator->tplsubj1;
$mail_body = $registrator->tpl1;
$usekoi8 = $registrator->check1;
$usekoi8u = $registrator->check2;
if ($mail_to and $mail_from and $mail_subject and $mail_body) {
$needHandle = 0;
if (preg_match("/{uanic}/ui",$mail_body)) { $nichandle = $profile->uanic; $needHandle = 1;}
else if (preg_match("/{ripn}/ui",$mail_body)) { $nichandle = $profile->ripn; $needHandle = 1;}
if (!$nichandle) { $nichandle = $mail_nichandle; }
if ($nichandle or !$needHandle) {
$nslistcode = "nserver: $ns1rnnserver: $ns2"; if ($ns3) {$nslistcode = $nslistcode."rnnserver: $ns3"; } if ($ns4) {$nslistcode = $nslistcode."rnnserver: $ns4"; }
$mail_subject = str_replace('{domain}',$domain->domain,$mail_subject);
$mail_body = str_replace('{domain}',$domain->domain,$mail_body);
$mail_body = str_replace('{ns}',$nslistcode,$mail_body);
$mail_body = str_replace('{uanic}',$nichandle,$mail_body);
$mail_body = str_replace('{ripn}',$nichandle,$mail_body);
$mail_body = str_replace('{senderemail}',$mail_from,$mail_body);
$mail_body = str_replace('{yyyy}',date("Y"),$mail_body);
$mail_body = str_replace('{mm}',date("m"),$mail_body);
$mail_body = str_replace('{dd}',date("d"),$mail_body);
$mail_body = str_replace('{hh}',date("H"),$mail_body);
$mail_body = str_replace('{min}',date("i"),$mail_body);
$mail_body = str_replace('{ss}',date("s"),$mail_body);
if ($usekoi8) {
$encoding = "KOI8-R";
$mail_subject = iconv("UTF-8", "KOI8-R", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-R", $mail_body);
} else if ($usekoi8u) {
$encoding = "KOI8-U";
$mail_subject = iconv("UTF-8", "KOI8-U", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-U", $mail_body);
} else {
$encoding="WINDOWS-1251";
$mail_subject = iconv("UTF-8", "WINDOWS-1251", $mail_subject);
$mail_body = iconv("UTF-8", "WINDOWS-1251", $mail_body);
}
sendmail($mail_to,'',$mail_from,$mail_subject,$mail_body,'',$encoding);
mconnect();
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='$ns1',ns2='$ns2',ns3='$ns3',ns4='$ns4' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
}
else { $error = "Авторегистрация домена не возможна, т.к. у клиента не заполнено поле UANIC и не указан Nic-handle по умолчанию для $registrator->name"; }
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны все необходимые настройки для $registrator->name"; }
} else if ($registrator->type == "started") {
$started_url = $registrator->url;
$started_user = $registrator->text1;
$started_password = $registrator->text2;
if ($started_url and $started_user and $started_password) {
$started = new STARTED;
$started->init($started_url,$started_user,$started_password);
if (!$profile->startedUserId) {
$pw = generatePassword(8);
if ($profile->org == "1" or $profile->org == "2") { $type = "person"; } else if ($profile->org == "3") { $type = "organization"; }
$donot_send_any_mail = 1;
if ($profile->org == "3") {
$org = $profile->firma;
if ($profile->country == "RU") {
$o_inn = $profile->inn;
$kpp = $profile->kpp;
}
}
if ($profile->org == "2" and $profile->country == "RU") {
$p_inn = $profile->inn;
}
if ($profile->org == "1" or $profile->org == "2") {
$seriya = mb_split(" ",$profile->pasport_seriya);
if ($profile->country == "RU") {
$doc_serial = $seriya[0].$seriya[1];
$doc_number = $seriya[2];
} else {
$doc_serial = $seriya[0];
$doc_number = $seriya[1].$seriya[2].$seriya[3];
}
$doc_issued = $profile->pasport_by;
$doc_date = mydate($profile->pasport_date);
$birth_date = mydate($profile->birthday);
}
$country = $profile->country;
if ($profile->oblast and count($startedRegion[$country]) > 0) {
while (list($i,$v) = @each($startedRegion[$country])) {
if ($v == $profile->oblast) {
$state = $i;
$pstate = $i;
break;
}
}
}
$city_type = "city";
$pcity_type = "city";
if (preg_match("/пер./ui",$profile->street) or preg_match("/переулок/ui",$profile->street)) { $addr_type = "alleyway"; $profile->street = preg_replace("/пер./ui","",$profile->street); $profile->street = preg_replace("/переулок/ui","",$profile->street); }
else if (preg_match("/проезд/ui",$profile->street)) { $addr_type = "thoroughfare"; $profile->street = preg_replace("/проезд/ui","",$profile->street); }
else if (preg_match("/ал./ui",$profile->street) or preg_match("/аллея/ui",$profile->street)) { $addr_type = "alley"; $profile->street = preg_replace("/ал./ui","",$profile->street); $profile->street = preg_replace("/аллея/ui","",$profile->street); }
else if (preg_match("/пл./ui",$profile->street) or preg_match("/площадь/ui",$profile->street)) { $addr_type = "square"; $profile->street = preg_replace("/пл./ui","",$profile->street); $profile->street = preg_replace("/площадь/ui","",$profile->street); }
else if (preg_match("/пр./ui",$profile->street) or preg_match("/проспект/ui",$profile->street)) { $addr_type = "avenue"; $profile->street = preg_replace("/пр./ui","",$profile->street); $profile->street = preg_replace("/проспект/ui","",$profile->street); }
else if (preg_match("/бул./ui",$profile->street) or preg_match("/бульвар/ui",$profile->street)) { $addr_type = "boulevard"; $profile->street = preg_replace("/бул./ui","",$profile->street); $profile->street = preg_replace("/бульвар/ui","",$profile->street); }
else if (preg_match("/наб./ui",$profile->street) or preg_match("/набережная/ui",$profile->street)) { $addr_type = "wharf"; $profile->street = preg_replace("/наб./ui","",$profile->street); $profile->street = preg_replace("/набережная/ui","",$profile->street); }
else if (preg_match("/ш./ui",$profile->street) or preg_match("/шоссе/ui",$profile->street) or preg_match("/шосе/ui",$profile->street)) { $addr_type = "highway"; $profile->street = preg_replace("/ш./ui","",$profile->street); $profile->street = preg_replace("/шоссе/ui","",$profile->street); $profile->street = preg_replace("/шосе/ui","",$profile->street);}
else { $addr_type = "street"; $profile->street = preg_replace("/ул./ui","",$profile->street); $profile->street = preg_replace("/улица/ui","",$profile->street); }
$phone = split(" ",$profile->phone); $phone = $phone[1]." ".$phone[2];
$fax = split(" ",$profile->fax); $fax = $fax[1]." ".$fax[2];
$startedUserId = $started->createUser($profile->email,$pw,$type,$donot_send_any_mail,$profile->name,$profile->surname,$profile->otchestvo,$org,$o_inn,$p_inn,$kpp,$doc_serial,$doc_number,$doc_issued,$doc_date,$birth_date,$profile->country,$state,$pstate,$city_type,$pcity_type,$profile->city,$profile->city,$addr_type,$addr_type,$profile->street,$profile->street,$profile->post,$profile->post,$profile->komu,$phone,$fax);
mconnect();
if ($startedUserId) {
@mysql_query("update users_profile set startedUserId='$startedUserId' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $started->error;
}
} else {
$startedUserId = $profile->startedUserId;
}
if (!$error) {
$requestId=$started->regDomain($startedUserId,$domain->domain,$ns1,$ns2,$ns3,$ns4);
mconnect();
if ($requestId) {
@mysql_query("update orders_domains set startedRequestId='$requestId',status=0,autoregby='$zone->autoreg',panel_url='http://www.started.ru/',panel_user='$profile->email',panel_pwd='$pw' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $started->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "internetx") {
$internetx_url = $registrator->url;
$internetx_user = $registrator->text1;
$internetx_password = $registrator->text2;
$internetx_context = $registrator->text3;
if ($internetx_url and $internetx_user and $internetx_password and $internetx_context) {
$internetx = new INTERNETX;
$internetx->init($internetx_url,$internetx_user,$internetx_password,$internetx_context);
$manager_email=GetSetting("manager_email");
$contactId = $profile->internetxContactId;
if (!$contactId) {
if ($profile->org == "1" or $profile->org == "2") { $type = "PERSON"; } else if ($profile->org == "3") { $type="ORG"; }
$fname = GotoTranslit($profile->name);
$lname = GotoTranslit($profile->surname);
if ($profile->org == "3") { $organization = $profile->firmaeng; }
$address = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$state = GotoTranslit($profile->oblast);
$phone = split(" ",$profile->phone); $phone = $phone[0]."-".$phone[1]."-".$phone[2];
if ($profile->fax) { $fax = split(" ",$profile->fax); $fax = $fax[0]."-".$fax[1]."-".$fax[2]; } else { $fax = $phone; }
$protection = "A";
$contactId=$internetx->createContact($type,$fname,$lname,$organization,$address,$profile->post,$city,$state,$profile->country,$phone,$fax,$profile->email,$protection,$manager_email);
mconnect();
if ($contactId) {
@mysql_query("update users_profile set internetxContactId='$contactId' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $internetx->error;
}
}
if ($contactId) {
$result=$internetx->regDomain($domain->domain,$profile->email,$contactId,$ns1,$ns2,$ns3,$ns4,$manager_email);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $internetx->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, логин, пароль или contextid для $registrator->name"; }
}
else if ($registrator->type == "ukrnames") {
$ukrnames_url = $registrator->url;
$ukrnames_port = $registrator->port;
$ukrnames_user = $registrator->text1;
$ukrnames_password = $registrator->text2;
if ($ukrnames_url and $ukrnames_port and $ukrnames_user and $ukrnames_password) {
$pw = generatePassword(8,1);
$ukrnames = new UKRNAMES;
$ukrnames->init($ukrnames_url,$ukrnames_port,$ukrnames_user,$ukrnames_password);
$name = GotoTranslit($profile->name)." ".GotoTranslit($profile->surname);
if ($profile->org == "3") { $org = $profile->firmaeng;}
$street = GotoTranslit($profile->street);
$city = GotoTranslit($profile->city);
$oblast = GotoTranslit($profile->oblast);
$phone = split(" ",$profile->phone); $phone = $phone[0].".".$phone[1].$phone[2];
$contactId[0]=$ukrnames->createContact($name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$profile->email,$pw);
if (!$ukrnames->error) { $contactId[1]=$ukrnames->createContact($name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$profile->email,$pw); }
if (!$ukrnames->error) { $contactId[2]=$ukrnames->createContact($name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$profile->email,$pw); }
if (!$ukrnames->error) { $contactId[3]=$ukrnames->createContact($name,$org,$street,$city,$oblast,$profile->post,$profile->country,$phone,$profile->email,$pw); }
mconnect();
if ($contactId[0] and $contactId[1] and $contactId[2] and $contactId[3]) {
@mysql_query("update orders_domains set ukrnamesContactId='".$contactId[0].",".$contactId[1].",".$contactId[2].",".$contactId[3]."' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $ukrnames->error;
}
if ($contactId[0] and $contactId[1] and $contactId[2] and $contactId[3]) {
$result=$ukrnames->registerDomain($domain->domain,$ns1,$ns2,$ns3,$ns4,$contactId[0],$contactId[1],$contactId[2],$contactId[3],$pw);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='',panel_pwd='$pw' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $ukrnames->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "r01") {
$r01_url = $registrator->url;
$r01_port = $registrator->port;
$r01_user = $registrator->text1;
$r01_password = $registrator->text2;
if ($r01_url and $r01_port and $r01_user and $r01_password) {
$r01 = new R01;
$r01->init($r01_url,$r01_port,$r01_user,$r01_password);
if ($r01_url == "cp.centrohost.ru") {
$nichndlAddon = "-CTH";
} else {
$nichndlAddon = "-GPT";
}
$nicHandle = $profile->r01NicHandle;
if (!$nicHandle) {
$langLoad = LoadLanguageToVariable("russian");
$country = $profile->country;
if ($profile->oblast) {$oblast = $profile->oblast.", "; }
$postal_addr = $langLoad[Country][$country].", ".$profile->post.", ".$oblast.$profile->city."n".$profile->street;
$fiorus = $profile->surname." ".$profile->name." ".$profile->otchestvo;
$isprotected = 0;
if ($profile->country == "RU") { $isresident = 1; } else { $isresident = 0; }
if ($profile->org == "1" or $profile->org == "2") {
$nic_hdl = "RPL_".$user->id."_".$profile->id.$nichndlAddon;
$passport_date = split("-", $profile->pasport_date); $passport_date = $passport_date[2]."-".$passport_date[1]."-".$passport_date[0];
$passport = $profile->pasport_seriya."n".$profile->pasport_by."n"."$passport_date";
$birth_date = split("-", $profile->birthday); $birth_date = $birth_date[2]."-".$birth_date[1]."-".$birth_date[0];
$nicHandle=$r01->createContactPerson($nic_hdl, $fiorus, GotoTranslit($fiorus), $passport, $birth_date, $postal_addr, $profile->phone, $profile->fax, $profile->email, $isprotected, $isresident);
} else if ($profile->org == "3") {
$nic_hdl = "RPL_".$user->id."_".$profile->id."-ORG".$nichndlAddon;
$nicHandle=$r01->createContactOrg($nic_hdl, $profile->firma, $profile->firmaeng, $profile->inn, $profile->kpp, $ogrn, $profile->address_org, $postal_addr, $profile->phone, $profile->fax, $profile->email, $fiorus, $profile->bank, $profile->bank_schet, $kor_schet, $profile->bank_bik, $isresident);
}
if ($nicHandle) {
mconnect();
@mysql_query("update users_profile set r01NicHandle='$nicHandle' where id='$profile->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
} else {
$error = $r01->error;
}
}
if ($nicHandle) {
$result=$r01->registerDomain($domain->domain,$ns1,$ns2,$ns3,$ns4,$nicHandle,'');
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $r01->error;
}
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "ficora") {
$ficora_url = $registrator->url;
$ficora_user = $registrator->text1;
$ficora_password = $registrator->text2;
if ($ficora_url and $ficora_user and $ficora_password) {
$ficora = new FICORA;
$ficora->init($ficora_url,$ficora_user,$ficora_password);
$validity_period = $period*12;
if ($profile->org == "1") {
if (preg_match("/$profile->surname/ui",$domain->domain) and preg_match("/$profile->name/ui",$domain->domain)) {
$based_on_person_name = true;
} else {
$based_on_person_name = false;
}
} else {
$based_on_person_name = false;
}
$person_name_registration_id = 0;
if ($profile->org == "1") {
$domain_name_holder_company_type = 0;
$domain_name_holder_person_id = $profile->socstrahnumber;
$data_publishing_approval = true;
$type = 4;
$first_name = $profile->name;
$last_name = $profile->surname;
} else {
$domain_name_holder_company_type = 1;
$domain_name_holder_business_id = $profile->ogrn;
$type = 0;
$company = $profile->firma;
$department = "Domain Department";
}
$electronic_notification_approval = true;
$result=$ficora->regDomain($domain->domain, $validity_period, $based_on_person_name, $person_name_registration_id, $domain_name_holder_person_id, $domain_name_holder_company_type, $domain_name_holder_business_id, $electronic_notification_approval, $data_publishing_approval, $ns1, $ns2, $ns3, $ns4, $type, $company, $department, $first_name, $last_name, $profile->street, $profile->post, $profile->city, $profile->phone, $profile->email);
mconnect();
if ($result) {
@mysql_query("update orders_domains set status=1,autoregby='$zone->autoreg',ns1='',ns2='',ns3='',ns4='' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $ficora->error;
}
}
else { $error = "Авторегистрация домена не возможна, т.к. не указаны API URL, User Name или Encryption Key для $registrator->name"; }
}
else { $error = "Авторегистрация домена не возможна, т.к. $registrator->type - неизвестный тип регистратора"; }
if (!$error and $registrator->type != "started") {
$domain = GetDomainById($domain_id);
$tpl=GetTpl('email_touser_domain_create', $user->lang);
$subject=$tpl[subject]; $template=$tpl[template];
if ($subject and $template) {
$company_name=GetSetting('company_name');
$company_url=GetSetting('company_url');
$manager_email=GetSetting("manager_email");
$support_url=GetSetting("support_url");
$subject = str_replace('{domain}',$domain->domain,$subject);
$template = str_replace('{company_name}',$company_name,$template);
$template = str_replace('{company_url}',$company_url,$template);
$template = str_replace('{support_url}',$support_url,$template);
$template = str_replace('{domain}',$domain->domain,$template);
if ($domain->panel_url and $domain->panel_user) {
$template = str_replace('{panel}',"Control Panel:rnrnURL: $domain->panel_urlrnLogin: $domain->panel_userrnPassword: $domain->panel_pwdrnrn",$template);
} else {
$template = str_replace('{panel}',"",$template);
}
WriteMailLog($subject,$template,$user->id);
sendmail($user->email,$company_name,$manager_email,$subject,$template);
sendmail($user->email2,$company_name,$manager_email,$subject,$template);
}
}
} else { $error = "Авторегистрация домена не возможна, т.к. не удалось получить днс-сервера для домена. Возможно из-за ошибки при создании аккаунта."; }
} else { $error = "Авторегистрация домена не возможна, т.к. профайл не проверен администрацией."; }
} else { $error = "Авторегистрация домена не возможна, т.к. профайл не заполнен всеми нужными данными."; }
} else { $error = "Пользователь ID #".$domain->uid." не найден."; }
} else { $error = "Авторегистрация не возможна, т.к. регистратор $registrator->name не активен."; }
} else { $error = "Авторегистрация доменов для доменной зоны $zone->zone отключена."; }
} else { $error = "Не найдена доменная зона."; }
} else { $error = "Не найден заказ на домен ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически зарегистрировать домен $domain->domain через $registrator->name по следующей причине:nn$errornnВам необходимо зарегистрировать домен вручную, а затем поставить статус Обработан в редактировании заказа!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка регистрации домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
}
return false;
} else {
return true;
}
}
function renewDomain($domain_id, $period, $sendErrorEmail = 1) {
global $GLOBALerror, $full_home_path, $onlinenicDomainTypes, $nicruService;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($zone->autoreg) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->id) {
$user = GetUserById($domain->uid);
if ($user->id) {
$profile = GetUserProfileByUserId($user->id, $domain->profileId);
if ($registrator->type == "regru") {
$regru_url = $registrator->url;
$regru_user = $registrator->text1;
$regru_password = $registrator->text2;
if ($regru_url and $regru_user and $regru_password) {
$regru_fail_if_no_money = $registrator->check1;
$regru_no_bill_notify = $registrator->check2;
$regru = new REGRU;
$regru->init($regru_url,$regru_user,$regru_password);
$result=$regru->renewDomain($domain->domain,$period,$regru_fail_if_no_money,$regru_no_bill_notify);
if ($result) {
$error = "";
} else {
$error = $regru->errors[0];
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "webnames") {
$webnames_url = $registrator->url;
$webnames_user = $registrator->text1;
$webnames_password = $registrator->text2;
if ($webnames_url and $webnames_user and $webnames_password) {
$webnames = new WEBNAMES;
$webnames->init($webnames_url,$webnames_user,$webnames_password);
$result=$webnames->renewDomain($domain->domain,$period);
if ($result) {
$error = "";
} else {
$error = $webnames->errors[0];
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "naunet") {
if (strtolower($zone->zone) == "ru" or strtolower($zone->zone) == "su") {
$naunet_url = $registrator->url;
$naunet_user = $registrator->text1;
$naunet_password = $registrator->text2;
if ($naunet_url and $naunet_user and $naunet_password) {
$naunet = new NAUNET;
$naunet->init($naunet_url,$naunet_user,$naunet_password);
$result=$naunet->renewDomain($domain->domain);
if ($result) {
$error = "";
} else {
$error = $naunet->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
} else { $error = "Автопродление домена не возможно, т.к. через $registrator->name поддерживается продление только RU/SU доменов."; }
}
else if ($registrator->type == "nicru") {
$nicru_url = $registrator->url;
$nicru_user = $registrator->text1;
$nicru_password = $registrator->text2;
if ($nicru_url and $nicru_user and $nicru_password) {
$nicru = new NICRU;
$nicru->init($nicru_url,$nicru_user,$nicru_password);
$anketaId = $profile->nicruAnketaId;
$zidx = strtolower($zone->zone);
$service = $nicruService[$zidx];
if ($service) {
$result = $nicru->renewDomain($anketaId,$service,$domain->domain,$period);
if ($result) {
$error = "";
} else {
$error = $nicru->error;
}
}
else { $error = "Автопродление не возможно, т.к. через $registrator->name не поддерживается регистрация доменов в зоне ".$zone->zone."."; }
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, номер договора или пароль для $registrator->name"; }
}
else if ($registrator->type == "freehost") {
$freehost_url = $registrator->url;
$freehost_port = $registrator->port;
$freehost_user = $registrator->text1;
$freehost_password = $registrator->text2;
$freehost_nichandle = $registrator->text3;
if ($freehost_url and $freehost_port and $freehost_user and $freehost_password) {
$freehost = new FREEHOST;
$freehost->init($freehost_url,$freehost_port,$freehost_user,$freehost_password);
$result=$freehost->renewDomain($domain->domain,$period);
if ($result) {
$error = "";
} else {
$error = $freehost->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "hostmaster") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = $registrator->text2;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTER;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password);
$result=$hostmaster->renewDomain($domain->domain,$period);
if ($result) {
$error = "";
} else {
$error = $hostmaster->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны логин и пароль для $registrator->name"; }
}
else if ($registrator->type == "onlinenic") {
$onlinenic_url = $registrator->url;
$onlinenic_port = $registrator->port;
$onlinenic_user = $registrator->text1;
$onlinenic_password = $registrator->text2;
if ($onlinenic_url and $onlinenic_port and $onlinenic_user and $onlinenic_password) {
$zidx = strtolower($zone->zone);
$domaintype = $onlinenicDomainTypes[$zidx];
if ($domaintype >= 0) {
$onlinenic = new ONLINENIC;
$onlinenic->init($onlinenic_url,$onlinenic_port,$onlinenic_user,$onlinenic_password);
$result = $onlinenic->renewDomain($domain->domain,$domaintype,$period);
if ($result) {
$error = "";
} else {
$error = $onlinenic->error;
}
}
else { $error = "Автопродление не возможно, т.к. через $registrator->name не поддерживается регистрация доменов в зоне ".$zone->zone."."; }
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "directi") {
$est_url = $registrator->url;
$est_user = $registrator->text1;
$est_password = $registrator->text2;
$est_parentid = $registrator->text3;
if ($est_url and $est_user and $est_password and $est_parentid) {
if ($domain->estOrderId) {
#$SERVICE_URL = $est_url;
$estdomains = new ESTDOMAINS;
$estdomains->init($est_user,$est_password,$est_parentid,$full_home_path."/_rootinc/estdomains/wsdl/");
$invoiceOption = "NoInvoice";
$result = $estdomains->renewDomain($domain->domain, $domain->estOrderId, $period, $invoiceOption);
if ($result) {
$error = "";
} else {
$error = $estdomains->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не удалось получить estOrderId для домена."; }
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин, пароль или parentid для $registrator->name"; }
}
else if ($registrator->type == "todaynic") {
$todaynic_url = $registrator->url;
$todaynic_user = $registrator->text1;
$todaynic_password = $registrator->text2;
if ($todaynic_url and $todaynic_user and $todaynic_password) {
$todaynic = new TODAYNIC;
$todaynic->init($todaynic_url,$todaynic_user,$todaynic_password);
$result=$todaynic->renewDomain($domain->domain,$period);
if ($result) {
$error = "";
} else {
$error = $todaynic->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "mail") {
$mail_to = $registrator->text3;
$mail_from = $registrator->text1;
$mail_nichandle = $registrator->text4;
$mail_subject = $registrator->tplsubj2;
$mail_body = $registrator->tpl2;
$usekoi8 = $registrator->check1;
$usekoi8u = $registrator->check2;
if ($mail_to and $mail_from and $mail_subject and $mail_body) {
$profile = GetUserProfileByUserId($user->id);
$needHandle = 0;
if (preg_match("/{uanic}/ui",$mail_body)) { $nichandle = $profile->uanic; $needHandle = 1;}
else if (preg_match("/{ripn}/ui",$mail_body)) { $nichandle = $profile->ripn; $needHandle = 1;}
if (!$nichandle) { $nichandle = $mail_nichandle; }
if ($nichandle or !$needHandle) {
$ns1 = $domain->ns1; $ns2 = $domain->ns2; $ns3 = $domain->ns3; $ns4 = $domain->ns4;
$nslistcode = "nserver: $ns1rnnserver: $ns2"; if ($ns3) {$nslistcode = $nslistcode."rnnserver: $ns3"; } if ($ns4) {$nslistcode = $nslistcode."rnnserver: $ns4"; }
$mail_subject = str_replace('{domain}',$domain->domain,$mail_subject);
$mail_body = str_replace('{domain}',$domain->domain,$mail_body);
$mail_body = str_replace('{ns}',$nslistcode,$mail_body);
$mail_body = str_replace('{uanic}',$nichandle,$mail_body);
$mail_body = str_replace('{ripn}',$nichandle,$mail_body);
$mail_body = str_replace('{senderemail}',$mail_from,$mail_body);
$mail_body = str_replace('{yyyy}',date("Y"),$mail_body);
$mail_body = str_replace('{mm}',date("m"),$mail_body);
$mail_body = str_replace('{dd}',date("d"),$mail_body);
$mail_body = str_replace('{hh}',date("H"),$mail_body);
$mail_body = str_replace('{min}',date("i"),$mail_body);
$mail_body = str_replace('{ss}',date("s"),$mail_body);
if ($usekoi8) {
$encoding = "KOI8-R";
$mail_subject = iconv("UTF-8", "KOI8-R", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-R", $mail_body);
} else if ($usekoi8u) {
$encoding = "KOI8-U";
$mail_subject = iconv("UTF-8", "KOI8-U", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-U", $mail_body);
} else {
$encoding="WINDOWS-1251";
$mail_subject = iconv("UTF-8", "WINDOWS-1251", $mail_subject);
$mail_body = iconv("UTF-8", "WINDOWS-1251", $mail_body);
}
sendmail($mail_to,'',$mail_from,$mail_subject,$mail_body,'',$encoding);
$error = "";
}
else { $error = "Автопродление домена не возможно, т.к. у клиента не заполнено поле UANIC и не указан Nic-handle по умолчанию для $registrator->name"; }
} else { $error = "Автопродление домена не возможно, т.к. не указаны все необходимые настройки для $registrator->name"; }
} else if ($registrator->type == "started") {
$started_url = $registrator->url;
$started_user = $registrator->text1;
$started_password = $registrator->text2;
if ($started_url and $started_user and $started_password) {
if ($domain->startedDomainId) {
$started = new STARTED;
$started->init($started_url,$started_user,$started_password);
$result=$started->renewDomain($domain->startedDomainId,$period);
if ($result) {
$error = "";
} else {
$error = $started->error;
}
} else { $error = "Автопродление домена не возможно, т.к. не указан startedDomainId."; }
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "internetx") {
$internetx_url = $registrator->url;
$internetx_user = $registrator->text1;
$internetx_password = $registrator->text2;
$internetx_context = $registrator->text3;
if ($internetx_url and $internetx_user and $internetx_password and $internetx_context) {
if ($domain->internetxDeleted) {
$internetx = new INTERNETX;
$internetx->init($internetx_url,$internetx_user,$internetx_password,$internetx_context);
$result = $internetx->domainCancelDelete($domain->domain);
mconnect();
if ($result) {
@mysql_query("update orders_domains set internetxDeleted='0' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else {
$error = $internetx->error;
}
}
else { $error = ""; }
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, логин, пароль или parentid для $registrator->name"; }
}
else if ($registrator->type == "ukrnames") {
$ukrnames_url = $registrator->url;
$ukrnames_port = $registrator->port;
$ukrnames_user = $registrator->text1;
$ukrnames_password = $registrator->text2;
if ($ukrnames_url and $ukrnames_port and $ukrnames_user and $ukrnames_password) {
$expDate = split("-",$domain->todate);
$expDate[0] = $expDate[0] - 1;
$expDate = @join("-",$expDate);
$ukrnames = new UKRNAMES;
$ukrnames->init($ukrnames_url,$ukrnames_port,$ukrnames_user,$ukrnames_password);
$result=$ukrnames->renewDomain($domain->domain,$period,$expDate);
if ($result) {
$error = "";
} else {
$error = $ukrnames->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "r01") {
$r01_url = $registrator->url;
$r01_port = $registrator->port;
$r01_user = $registrator->text1;
$r01_password = $registrator->text2;
if ($r01_url and $r01_port and $r01_user and $r01_password) {
$r01 = new R01;
$r01->init($r01_url,$r01_port,$r01_user,$r01_password);
$result=$r01->renewDomain($domain->domain);
if ($result) {
$error = "";
} else {
$error = $r01->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, API порт, логин или пароль для $registrator->name"; }
}
else if ($registrator->type == "ficora") {
$ficora_url = $registrator->url;
$ficora_user = $registrator->text1;
$ficora_password = $registrator->text2;
if ($ficora_url and $ficora_user and $ficora_password) {
$ficora = new FICORA;
$ficora->init($ficora_url,$ficora_user,$ficora_password);
$period = $period*12;
$result=$ficora->renewDomain($domain->domain, $period);
if ($result) {
$error = "";
} else {
$error = $ficora->error;
}
}
else { $error = "Автопродление домена не возможно, т.к. не указаны API URL, User Name или Encryption Key для $registrator->name"; }
}
else { $error = "Автопродление домена не возможно, т.к. $registrator->type - неизвестный тип регистратора"; }
} else { $error = "Пользователь ID #".$domain->uid." не найден."; }
} else { $error = "Автопродление не возможно, т.к. регистратор $registrator->name не найден."; }
} else { $error = "Автопродление доменов для доменной зоны $zone->zone отключено."; }
} else { $error = "Не найдена доменная зона."; }
} else { $error = "Не найден заказ на домен ID #$orderid."; }
$GLOBALerror = $error;
if ($error) {
if ($sendErrorEmail) {
$errormsg = "RootPanel не смог автоматически продлить домен $domain->domain через $registrator->name по следующей причине:nn$errornnВам необходимо продлить домен вручную!";
$manager_email = GetSetting("manager_email");
$subject = "RootPanel: Ошибка продления домена";
$admEmails=GetAdminEmailsWhereTrueParam("senderror");
if (count($admEmails) > 0) {
WriteMailLog($subject,$errormsg);
}
sendmail($manager_email,'',$manager_email,$subject,$errormsg);
}
return false;
} else {
return true;
}
}
function getNS($domain_id) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes;
$domain = GetDomainById($domain_id);
if ($domain->id) {
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($zone->autoreg) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->id) {
$user = GetUserById($domain->uid);
if ($user->id) {
if ($registrator->type == "regru") {
$regru_url = $registrator->url;
$regru_user = $registrator->text1;
$regru_password = $registrator->text2;
if ($regru_url and $regru_user and $regru_password) {
$regru = new REGRU;
$regru->init($regru_url,$regru_user,$regru_password);
$result=$regru->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $regru->errors[0];
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "webnames") {
$webnames_url = $registrator->url;
$webnames_user = $registrator->text1;
$webnames_password = $registrator->text2;
if ($webnames_url and $webnames_user and $webnames_password) {
$webnames = new WEBNAMES;
$webnames->init($webnames_url,$webnames_user,$webnames_password);
$result=$webnames->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $webnames->errors[0];
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "naunet") {
if (strtolower($zone->zone) == "ru" or strtolower($zone->zone) == "su") {
$naunet_url = $registrator->url;
$naunet_user = $registrator->text1;
$naunet_password = $registrator->text2;
if ($naunet_url and $naunet_user and $naunet_password) {
$naunet = new NAUNET;
$naunet->init($naunet_url,$naunet_user,$naunet_password);
$result=$naunet->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $naunet->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
} else { $error = $_lang[DomainsErrorZoneNotSupported]; }
}
else if ($registrator->type == "nicru") {
$nicru_url = $registrator->url;
$nicru_user = $registrator->text1;
$nicru_password = $registrator->text2;
if ($nicru_url and $nicru_user and $nicru_password) {
$nicru = new NICRU;
$nicru->init($nicru_url,$nicru_user,$nicru_password);
$result=$nicru->getNS($domain->nicruOrderId);
if (is_array($result)) {
$error = "";
} else {
$error = $nicru->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "freehost") {
$freehost_url = $registrator->url;
$freehost_port = $registrator->port;
$freehost_user = $registrator->text1;
$freehost_password = $registrator->text2;
$freehost_nichandle = $registrator->text3;
if ($freehost_url and $freehost_port and $freehost_user and $freehost_password) {
$freehost = new FREEHOST;
$freehost->init($freehost_url,$freehost_port,$freehost_user,$freehost_password);
$result=$freehost->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $freehost->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "hostmaster") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = $registrator->text2;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTER;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password);
$result=$hostmaster->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $hostmaster->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "onlinenic") {
$onlinenic_url = $registrator->url;
$onlinenic_port = $registrator->port;
$onlinenic_user = $registrator->text1;
$onlinenic_password = $registrator->text2;
if ($onlinenic_url and $onlinenic_port and $onlinenic_user and $onlinenic_password) {
$zidx = strtolower($zone->zone);
$domaintype = $onlinenicDomainTypes[$zidx];
if ($domaintype >= 0) {
$onlinenic = new ONLINENIC;
$onlinenic->init($onlinenic_url,$onlinenic_port,$onlinenic_user,$onlinenic_password);
$result = $onlinenic->getNS($domain->domain,$domaintype);
if (is_array($result)) {
$error = "";
} else {
$error = $onlinenic->error;
}
}
else { $error = $_lang[DomainsErrorZoneNotSupported]; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "directi") {
$est_url = $registrator->url;
$est_user = $registrator->text1;
$est_password = $registrator->text2;
$est_parentid = $registrator->text3;
if ($est_url and $est_user and $est_password and $est_parentid) {
#$SERVICE_URL = $est_url;
$estdomains = new ESTDOMAINS;
$estdomains->init($est_user,$est_password,$est_parentid,$full_home_path."/_rootinc/estdomains/wsdl/");
$result = $estdomains->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $estdomains->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "todaynic") {
$todaynic_url = $registrator->url;
$todaynic_user = $registrator->text1;
$todaynic_password = $registrator->text2;
if ($todaynic_url and $todaynic_user and $todaynic_password) {
$todaynic = new TODAYNIC;
$todaynic->init($todaynic_url,$todaynic_user,$todaynic_password);
$result=$todaynic->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $todaynic->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "mail") {
$result[] = $domain->ns1;
$result[] = $domain->ns2;
if ($domain->ns3) {$result[] = $domain->ns3;}
if ($domain->ns4) {$result[] = $domain->ns4;}
$error = "";
}
else if ($registrator->type == "started") {
$started_url = $registrator->url;
$started_user = $registrator->text1;
$started_password = $registrator->text2;
if ($started_url and $started_user and $started_password) {
$started = new STARTED;
$started->init($started_url,$started_user,$started_password);
$result=$started->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $started->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "internetx") {
$internetx_url = $registrator->url;
$internetx_user = $registrator->text1;
$internetx_password = $registrator->text2;
$internetx_context = $registrator->text3;
if ($internetx_url and $internetx_user and $internetx_password and $internetx_context) {
$internetx = new INTERNETX;
$internetx->init($internetx_url,$internetx_user,$internetx_password,$internetx_context);
$result = $internetx->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $internetx->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "ukrnames") {
$ukrnames_url = $registrator->url;
$ukrnames_port = $registrator->port;
$ukrnames_user = $registrator->text1;
$ukrnames_password = $registrator->text2;
if ($ukrnames_url and $ukrnames_port and $ukrnames_user and $ukrnames_password) {
$ukrnames = new UKRNAMES;
$ukrnames->init($ukrnames_url,$ukrnames_port,$ukrnames_user,$ukrnames_password);
$result=$ukrnames->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $ukrnames->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "r01") {
$r01_url = $registrator->url;
$r01_port = $registrator->port;
$r01_user = $registrator->text1;
$r01_password = $registrator->text2;
if ($r01_url and $r01_port and $r01_user and $r01_password) {
$r01 = new R01;
$r01->init($r01_url,$r01_port,$r01_user,$r01_password);
$result=$r01->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $r01->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "ficora") {
$ficora_url = $registrator->url;
$ficora_user = $registrator->text1;
$ficora_password = $registrator->text2;
if ($ficora_url and $ficora_user and $ficora_password) {
$ficora = new FICORA;
$ficora->init($ficora_url,$ficora_user,$ficora_password);
$result=$ficora->getNS($domain->domain);
if (is_array($result)) {
$error = "";
} else {
$error = $ficora->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else { $error = $_lang[DomainsErrorNoRegistrator]; }
} else { $error = $_lang[DomainsErrorUserNotFound]; }
} else { $error = $_lang[DomainsErrorRegistratorNotFound]." (".$registrator->name.")"; }
} else { $error = $_lang[DomainsErrorautoregDisable]; }
} else { $error = $_lang[DomainsErrorZoneNotFound]; }
} else { $error = $_lang[DomainsErrorDomainOrdersNotFound]." ID #$domain_id."; }
if ($error) {
$GLOBALerror = $error;
return false;
} else {
$result[0] = preg_replace("/.$/iu","",$result[0]);
$result[1] = preg_replace("/.$/iu","",$result[1]);
$result[2] = preg_replace("/.$/iu","",$result[2]);
$result[3] = preg_replace("/.$/iu","",$result[3]);
return $result;
}
}
function updateNS($domain_id,$ns1,$ns2,$ns3,$ns4) {
global $GLOBALerror, $_lang, $full_home_path, $onlinenicDomainTypes, $nicruService, $authorization_key;
$ns1=trim($ns1);
$ns2=trim($ns2);
$ns3=trim($ns3);
$ns4=trim($ns4);
$domain = GetDomainById($domain_id);
if ($domain->id) {
$zone = GetZoneByDomainOrderId($domain->id);
if ($zone->id) {
if ($zone->autoreg) {
$registrator = GetRegistratorById($domain->autoregby);
if ($registrator->id) {
$user = GetUserById($domain->uid);
if ($user->id) {
$profile = GetUserProfileByUserId($user->id, $domain->profileId);
if ($registrator->type == "regru") {
$regru_url = $registrator->url;
$regru_user = $registrator->text1;
$regru_password = $registrator->text2;
if ($regru_url and $regru_user and $regru_password) {
$regru = new REGRU;
$regru->init($regru_url,$regru_user,$regru_password);
$result=$regru->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4);
if ($result) {
$error = "";
} else {
$error = $regru->errors[0];
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "webnames") {
$webnames_url = $registrator->url;
$webnames_user = $registrator->text1;
$webnames_password = $registrator->text2;
if ($webnames_url and $webnames_user and $webnames_password) {
$webnames = new WEBNAMES;
$webnames->init($webnames_url,$webnames_user,$webnames_password);
$result=$webnames->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4);
if ($result) {
$error = "";
} else {
$error = $webnames->errors[0];
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "naunet") {
if (strtolower($zone->zone) == "ru" or strtolower($zone->zone) == "su") {
$naunet_url = $registrator->url;
$naunet_user = $registrator->text1;
$naunet_password = $registrator->text2;
if ($naunet_url and $naunet_user and $naunet_password) {
$naunet = new NAUNET;
$naunet->init($naunet_url,$naunet_user,$naunet_password);
$result=$naunet->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4);
if ($result) {
$error = "";
} else {
$error = $naunet->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
} else { $error = $_lang[DomainsErrorZoneNotSupported]; }
}
else if ($registrator->type == "nicru") {
$nicru_url = $registrator->url;
$nicru_user = $registrator->text1;
$nicru_password = $registrator->text2;
if ($nicru_url and $nicru_user and $nicru_password) {
$zidx = strtolower($zone->zone);
$service = $nicruService[$zidx];
if ($service) {
$nicru = new NICRU;
$nicru->init($nicru_url,$nicru_user,$nicru_password);
if (strtolower($zone->zone) == "ru" or strtolower($zone->zone) == "su") {
if ($profile->nicruAnketaId) {
$private_person = "OFF";
$orderId=$nicru->updateRuNS($profile->nicruAnketaId,$service,$domain->domain,"Private Domain",$private_person,$ns1,$ns2,$ns3,$ns4);
}
else { $error = $_lang[DomainsErrorCantGetValue]." nicruAnketaId."; }
} else {
if ($profile->nicruAnketaId and $profile->nicruContactId) {
$orderId=$nicru->updateNS($profile->nicruAnketaId,$profile->nicruContactId,$service,$domain->domain,$ns1,$ns2,$ns3,$ns4);
}
else { $error = $_lang[DomainsErrorCantGetValue]." nicruAnketaId / nicruContactId."; }
}
mconnect();
if ($orderId) {
@mysql_query("update orders_domains set nicruOrderId='$orderId' where id='$domain->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
} else if (!$error) {
$error = $nicru->error;
}
}
else { $error = $_lang[DomainsErrorZoneNotSupported]; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "freehost") {
$freehost_url = $registrator->url;
$freehost_port = $registrator->port;
$freehost_user = $registrator->text1;
$freehost_password = $registrator->text2;
$freehost_nichandle = $registrator->text3;
if ($freehost_url and $freehost_port and $freehost_user and $freehost_password) {
$profile = GetUserProfileByUserId($user->id);
$nichandle = $profile->uanic;
if (!$nichandle) { $nichandle = $freehost_nichandle; }
if ($nichandle) {
$freehost = new FREEHOST;
$freehost->init($freehost_url,$freehost_port,$freehost_user,$freehost_password);
$result=$freehost->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4,$nichandle);
if ($result) {
$error = "";
} else {
$error = $freehost->error;
}
}
else { $error = $_lang[DomainsErrorNoUanic]." $registrator->name"; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "hostmaster") {
$hostmaster_url = $registrator->url;
$hostmaster_port = $registrator->port;
$hostmaster_user = $registrator->text1;
$hostmaster_password = $registrator->text2;
if ($hostmaster_url and $hostmaster_port and $hostmaster_user and $hostmaster_password) {
$hostmaster = new HOSTMASTER;
$hostmaster->init($hostmaster_url,$hostmaster_port,$hostmaster_user,$hostmaster_password);
$result=$hostmaster->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4);
if ($result) {
$error = "";
} else {
$error = $hostmaster->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "onlinenic") {
$onlinenic_url = $registrator->url;
$onlinenic_port = $registrator->port;
$onlinenic_user = $registrator->text1;
$onlinenic_password = $registrator->text2;
if ($onlinenic_url and $onlinenic_port and $onlinenic_user and $onlinenic_password) {
$zidx = strtolower($zone->zone);
$domaintype = $onlinenicDomainTypes[$zidx];
if ($domaintype >= 0) {
$onlinenic = new ONLINENIC;
$onlinenic->init($onlinenic_url,$onlinenic_port,$onlinenic_user,$onlinenic_password);
if ($domain->panel_pwd) { $pw = $domain->panel_pwd; } else { $pw = generatePassword(8,1); }
$result = $onlinenic->updateNS($domain->domain,$domaintype,$ns1,$ns2,$pw);
if ($result) {
$error = "";
} else {
$error = $onlinenic->error;
}
}
else { $error = $_lang[DomainsErrorZoneNotSupported]; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "directi") {
$est_url = $registrator->url;
$est_user = $registrator->text1;
$est_password = $registrator->text2;
$est_parentid = $registrator->text3;
if ($est_url and $est_user and $est_password and $est_parentid) {
if ($domain->estOrderId) {
#$SERVICE_URL = $est_url;
$estdomains = new ESTDOMAINS;
$estdomains->init($est_user,$est_password,$est_parentid,$full_home_path."/_rootinc/estdomains/wsdl/");
$result = $estdomains->updateNS($domain->estOrderId, $ns1, $ns2, $ns3, $ns4);
if ($result) {
$error = "";
} else {
$error = $estdomains->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." estOrderId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "todaynic") {
$todaynic_url = $registrator->url;
$todaynic_user = $registrator->text1;
$todaynic_password = $registrator->text2;
if ($todaynic_url and $todaynic_user and $todaynic_password) {
$todaynic = new TODAYNIC;
$todaynic->init($todaynic_url,$todaynic_user,$todaynic_password);
$result=$todaynic->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4);
if ($result) {
$error = "";
} else {
$error = $todaynic->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "mail") {
$mail_to = $registrator->text3;
$mail_from = $registrator->text1;
$mail_nichandle = $registrator->text4;
$mail_subject = $registrator->tplsubj3;
$mail_body = $registrator->tpl3;
$usekoi8 = $registrator->check1;
$usekoi8u = $registrator->check2;
if ($mail_to and $mail_from and $mail_subject and $mail_body) {
$profile = GetUserProfileByUserId($user->id);
$needHandle = 0;
if (preg_match("/{uanic}/ui",$mail_body)) { $nichandle = $profile->uanic; $needHandle = 1;}
else if (preg_match("/{ripn}/ui",$mail_body)) { $nichandle = $profile->ripn; $needHandle = 1;}
if (!$nichandle) { $nichandle = $mail_nichandle; }
if ($nichandle or !$needHandle) {
$nslistcode = "nserver: $ns1rnnserver: $ns2"; if ($ns3) {$nslistcode = $nslistcode."rnnserver: $ns3"; } if ($ns4) {$nslistcode = $nslistcode."rnnserver: $ns4"; }
$mail_subject = str_replace('{domain}',$domain->domain,$mail_subject);
$mail_body = str_replace('{domain}',$domain->domain,$mail_body);
$mail_body = str_replace('{ns}',$nslistcode,$mail_body);
$mail_body = str_replace('{uanic}',$nichandle,$mail_body);
$mail_body = str_replace('{ripn}',$nichandle,$mail_body);
$mail_body = str_replace('{senderemail}',$mail_from,$mail_body);
$mail_body = str_replace('{yyyy}',date("Y"),$mail_body);
$mail_body = str_replace('{mm}',date("m"),$mail_body);
$mail_body = str_replace('{dd}',date("d"),$mail_body);
$mail_body = str_replace('{hh}',date("H"),$mail_body);
$mail_body = str_replace('{min}',date("i"),$mail_body);
$mail_body = str_replace('{ss}',date("s"),$mail_body);
if ($usekoi8) {
$encoding = "KOI8-R";
$mail_subject = iconv("UTF-8", "KOI8-R", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-R", $mail_body);
} else if ($usekoi8u) {
$encoding = "KOI8-U";
$mail_subject = iconv("UTF-8", "KOI8-U", $mail_subject);
$mail_body = iconv("UTF-8", "KOI8-U", $mail_body);
} else {
$encoding="WINDOWS-1251";
$mail_subject = iconv("UTF-8", "WINDOWS-1251", $mail_subject);
$mail_body = iconv("UTF-8", "WINDOWS-1251", $mail_body);
}
sendmail($mail_to,'',$mail_from,$mail_subject,$mail_body,'',$encoding);
mconnect();
@mysql_query("update orders_domains set ns1='$ns1',ns2='$ns2',ns3='$ns3',ns4='$ns4' where id=$domain->id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$error = "";
}
else { $error = $_lang[DomainsErrorNoUanic]." $registrator->name"; }
} else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "started") {
$started_url = $registrator->url;
$started_user = $registrator->text1;
$started_password = $registrator->text2;
if ($started_url and $started_user and $started_password) {
if ($domain->startedDomainId) {
$started = new STARTED;
$started->init($started_url,$started_user,$started_password);
$result = $started->updateNS($domain->startedDomainId, $ns1, $ns2, $ns3, $ns4);
if ($result) {
$error = "";
} else {
$error = $started->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." startedDomainId."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "internetx") {
$internetx_url = $registrator->url;
$internetx_user = $registrator->text1;
$internetx_password = $registrator->text2;
$internetx_context = $registrator->text3;
if ($internetx_url and $internetx_user and $internetx_password and $internetx_context) {
$internetx = new INTERNETX;
$internetx->init($internetx_url,$internetx_user,$internetx_password,$internetx_context);
$manager_email = GetSetting("manager_email");
$result = $internetx->updateNS($domain->domain, $ns1, $ns2, $ns3, $ns4, $manager_email);
if ($result) {
$error = "";
} else {
$error = $internetx->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "ukrnames") {
$ukrnames_url = $registrator->url;
$ukrnames_port = $registrator->port;
$ukrnames_user = $registrator->text1;
$ukrnames_password = $registrator->text2;
if ($ukrnames_url and $ukrnames_port and $ukrnames_user and $ukrnames_password) {
$ukrnames = new UKRNAMES;
$ukrnames->init($ukrnames_url,$ukrnames_port,$ukrnames_user,$ukrnames_password);
$result=$ukrnames->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4);
if ($result) {
$error = "";
} else {
$error = $ukrnames->error;
}
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "r01") {
$r01_url = $registrator->url;
$r01_port = $registrator->port;
$r01_user = $registrator->text1;
$r01_password = $registrator->text2;
if ($r01_url and $r01_port and $r01_user and $r01_password) {
if ($profile->r01NicHandle) {
$r01 = new R01;
$r01->init($r01_url,$r01_port,$r01_user,$r01_password);
$result=$r01->updateNS($domain->domain,$ns1,$ns2,$ns3,$ns4,$profile->r01NicHandle);
if ($result) {
$error = "";
} else {
$error = $r01->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." r01NicHandle."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else if ($registrator->type == "ficora") {
$ficora_url = $registrator->url;
$ficora_user = $registrator->text1;
$ficora_password = $registrator->text2;
if ($ficora_url and $ficora_user and $ficora_password) {
if ($authorization_key) {
$ficora = new FICORA;
$ficora->init($ficora_url,$ficora_user,$ficora_password);
$result=$ficora->updateNS($domain->domain,$authorization_key,$ns1,$ns2,$ns3,$ns4);
if ($result) {
$error = "";
} else {
$error = $ficora->error;
}
}
else { $error = $_lang[DomainsErrorCantGetValue]." Authorization Key."; }
}
else { $error = $_lang[DomainsErrorNoLoginForReg]." $registrator->name"; }
}
else { $error = $_lang[DomainsErrorNoRegistrator]; }
} else { $error = $_lang[DomainsErrorUserNotFound]; }
} else { $error = $_lang[DomainsErrorRegistratorNotFound]." (".$registrator->name.")"; }
} else { $error = $_lang[DomainsErrorautoregDisable]; }
} else { $error = $_lang[DomainsErrorZoneNotFound]; }
} else { $error = $_lang[DomainsErrorDomainOrdersNotFound]." ID #$orderid."; }
if ($error) {
$GLOBALerror = $error;
return false;
} else {
return true;
}
}
function GetBannerCodeByFileName($file,$url='') {
global $full_www_path;
$code_filename = "./_rootimages/banners/".$file.".code";
if (file_exists($code_filename)) {
$handle = fopen($code_filename, "r");
$banner_code = fread($handle, filesize($code_filename));
fclose($handle);
} else {
$company_name=GetSetting("company_name");
$banner_code="<a href='{url}' target='_blank'><img src='{image}' alt='$company_name' border='0'></a>";
}
$banner_code = str_replace("{url}","$url",$banner_code);
$banner_code = str_replace("{image}",$full_www_path."_rootimages/banners/".$file,$banner_code);
return $banner_code;
}
function error($err) {
global $_lang;
head('utf-8',$_lang[Error]);
print "<H1 class=pagetitle>".$_lang[Error]."</H1><hr class=hr>";
print "<font color=red>$err</font>";
foot('utf-8');
}
function createFaktura($fid, $billid, $type, $orgName='', $orgPhone='') {
// $type = 0 - HTML; return HTML
// $type = 1 - PDF, stream; return PDF;
// $type = 2 - PDF, file; return filename with full path
global $full_home_path;
$bill = GetBillById($billid);
$user = GetUserById($bill->uid);
$profile = GetUserProfileByUserId($bill->uid);
if (!$fid) {
$f = @mysql_query("select * from kvitancii_faktura where attachToEmail='1'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$f = @mysql_fetch_object($f);
} else {
$f = GetFakturasById($fid);
}
if ($bill->id and $user->id and $profile->id and $f->id) {
$sid=sprintf("%04d", $bill->id);
$money=$bill->money_host+$bill->money_domain+$bill->money_addons+$bill->money+$bill->money_shop;
$nacenka=GetSetting("nacenka_faktura");
if (!$type) {
if ($f->template) { $faktura = htmlDecode($f->template); } else { $faktura = GetTpl("tpl_faktura", $user->lang); $faktura = $faktura[template]; }
} else {
if ($f->template_pdf) { $faktura = htmlDecode($f->template_pdf); } else { $faktura = GetTpl("tpl_faktura_pdf", $user->lang); $faktura = $faktura[template]; }
}
if ($f->lang) {$kvLang=$f->lang;} else {$kvLang="russian";}
$_lang = LoadLanguageToVariable($kvLang);
$currency = GetCurrencyByCode("$f->currency");
$money_faktura = $money*$currency->koeficient;
$money_faktura = $money_faktura + ($money_faktura/100)*$nacenka;
$money_faktura = round($money_faktura,2);
preg_match("/<!--RowBegin-->(.+)<!--RowEnd-->/isu",$faktura,$arr);
if ($arr[1]) {
$itemsCnt=0;
$rowsToSave = array();
if ($bill->host_id and !$bill->newtarif and !$bill->newaddons) {
$order = GetOrderById($bill->host_id);
$tarif = GetTarifById($order->tarif);
$hostType = $tarif->vid;
$money_one = $bill->money_host*$currency->koeficient / $bill->host_srok; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$money_total = $bill->money_host*$currency->koeficient + (($bill->money_host*$currency->koeficient)/100)*$nacenka; $money_total = round($money_total,2);
$itemsCnt++;
$rowToSave = $arr[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaHost][$hostType]." ".$tarif->name,$rowToSave);
$rowToSave = str_replace("{edinica}",$_lang[OrderSokraschenieMonth],$rowToSave);
$rowToSave = str_replace("{count}",$bill->host_srok,$rowToSave);
$rowToSave = str_replace("{cena}",$money_one,$rowToSave);
$rowToSave = str_replace("{summa_one}",$money_total,$rowToSave);
$rowsToSave[] = $rowToSave;
if ($bill->money_addons) {
$money_one = $bill->money_addons*$currency->koeficient; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$itemsCnt++;
$rowToSave = $arr[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaAddon]." ".$order->id,$rowToSave);
$rowToSave = str_replace("{edinica}",$_lang[FakturaSokraschenieShtuka],$rowToSave);
$rowToSave = str_replace("{count}","1",$rowToSave);
$rowToSave = str_replace("{cena}",$money_one,$rowToSave);
$rowToSave = str_replace("{summa_one}",$money_one,$rowToSave);
$rowsToSave[] = $rowToSave;
}
}
else if ($bill->host_id and $bill->newtarif) {
$order = GetOrderById($bill->host_id);
$money_one = $bill->money_host*$currency->koeficient; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$money_total = $money_one;
$itemsCnt++;
$rowToSave = $arr[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaChangeTarif]." ".$order->id,$rowToSave);
$rowToSave = str_replace("{edinica}",$_lang[FakturaSokraschenieShtuka],$rowToSave);
$rowToSave = str_replace("{count}","1",$rowToSave);
$rowToSave = str_replace("{cena}",$money_one,$rowToSave);
$rowToSave = str_replace("{summa_one}",$money_total,$rowToSave);
$rowsToSave[] = $rowToSave;
} else if ($bill->host_id and $bill->newaddons) {
$order = GetOrderById($bill->host_id);
$money_one = $bill->money_addons*$currency->koeficient; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$itemsCnt++;
$rowToSave = $arr[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaAddon]." ".$order->id,$rowToSave);
$rowToSave = str_replace("{edinica}",$_lang[FakturaSokraschenieShtuka],$rowToSave);
$rowToSave = str_replace("{count}","1",$rowToSave);
$rowToSave = str_replace("{cena}",$money_one,$rowToSave);
$rowToSave = str_replace("{summa_one}",$money_one,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($bill->domain_id) {
$order = GetDomainById($bill->domain_id);
$money_one = $bill->money_domain*$currency->koeficient / ($bill->domain_srok/12); $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$money_total = $bill->money_domain*$currency->koeficient + (($bill->money_domain*$currency->koeficient)/100)*$nacenka; $money_total = round($money_total,2);
$itemsCnt++;
$rowToSave = $arr[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaDomain]." ".$order->domain,$rowToSave);
$rowToSave = str_replace("{edinica}",$_lang[OrderSokraschenieGod],$rowToSave);
$rowToSave = str_replace("{count}",($bill->domain_srok/12),$rowToSave);
$rowToSave = str_replace("{cena}",$money_one,$rowToSave);
$rowToSave = str_replace("{summa_one}",$money_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($bill->shop_id) {
$order=GetOrderShopById($bill->shop_id);
$shopItem=GetShopItemById($order->item);
if ($shopItem->costtype == "one") {
$money_one = $bill->money_shop*$currency->koeficient; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$money_total = $money_one;
} else {
$money_one = $bill->money_shop*$currency->koeficient / $bill->shop_srok; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$money_total = $bill->money_shop*$currency->koeficient + (($bill->money_shop*$currency->koeficient)/100)*$nacenka; $money_total = round($money_total,2);
}
$itemsCnt++;
$rowToSave = $arr[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaShop]." ".$shopItem->name,$rowToSave);
if ($shopItem->costtype == "one") {
$rowToSave = str_replace("{edinica}",$_lang[FakturaSokraschenieShtuka],$rowToSave);
$rowToSave = str_replace("{count}","1",$rowToSave);
} else {
$rowToSave = str_replace("{edinica}",$_lang[OrderSokraschenieMonth],$rowToSave);
$rowToSave = str_replace("{count}",$bill->shop_srok,$rowToSave);
}
$rowToSave = str_replace("{cena}",$money_one,$rowToSave);
$rowToSave = str_replace("{summa_one}",$money_total,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if ($bill->addfunds) {
$user = GetUserById($bill->uid);
$money_one = $bill->money*$currency->koeficient; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$itemsCnt++;
$rowToSave = $arr[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$_lang[FakturaAddFunds]." ".$user->id,$rowToSave);
$rowToSave = str_replace("{edinica}",$_lang[FakturaSokraschenieShtuka],$rowToSave);
$rowToSave = str_replace("{count}","1",$rowToSave);
$rowToSave = str_replace("{cena}",$money_one,$rowToSave);
$rowToSave = str_replace("{summa_one}",$money_one,$rowToSave);
$rowsToSave[] = $rowToSave;
}
if (!$bill->addfunds and $bill->money) {
$user = GetUserById($bill->uid);
$money_one = $bill->money*$currency->koeficient; $money_one = $money_one + ($money_one/100)*$nacenka; $money_one = round($money_one,2);
$itemsCnt++;
$rowToSave = $arr[1];
$rowToSave = str_replace("{pp}",$itemsCnt.".",$rowToSave);
$rowToSave = str_replace("{usluga}",$bill->comment." (UID ".$user->id.")",$rowToSave);
$rowToSave = str_replace("{edinica}",$_lang[FakturaSokraschenieShtuka],$rowToSave);
$rowToSave = str_replace("{count}","1",$rowToSave);
$rowToSave = str_replace("{cena}",$money_one,$rowToSave);
$rowToSave = str_replace("{summa_one}",$money_one,$rowToSave);
$rowsToSave[] = $rowToSave;
}
$rowsToSave = @join("n",$rowsToSave);
# $faktura = str_replace("<!--RowBegin-->","",$faktura);
$faktura = str_replace("<!--RowEnd-->","<!--RowEnd-->".$rowsToSave,$faktura);
$faktura = str_replace("{pp}","-",$faktura);
$faktura = str_replace("{usluga}","<center>-</center>",$faktura);
$faktura = str_replace("{edinica}","-",$faktura);
$faktura = str_replace("{count}","-",$faktura);
$faktura = str_replace("{cena}","-",$faktura);
$faktura = str_replace("{summa_one}","-",$faktura);
$f->rekviziti = preg_replace("/n/ui","<BR>",$f->rekviziti);
$faktura = str_replace("{firma}",$f->orgname,$faktura);
$faktura = str_replace("{phone}",$f->phone,$faktura);
$faktura = str_replace("{rekviziti}",$f->rekviziti,$faktura);
$faktura = str_replace("{img}",$f->shtamp,$faktura);
$faktura = str_replace("{summa}",$money_faktura,$faktura);
$faktura = str_replace("{num}",$sid,$faktura);
if ($orgName) {
$faktura = str_replace("{clientfirma}",$orgName,$faktura);
} else if ($profile->org == "3") {
$faktura = str_replace("{clientfirma}",$profile->firma,$faktura);
} else if ($profile->org == "2") {
if ($profile->country == "UA") {
$faktura = str_replace("{clientfirma}",$_lang[PPUA]." ".$profile->surname." ".$profile->name." ".$profile->otchestvo,$faktura);
} else if ($profile->country == "RU") {
$faktura = str_replace("{clientfirma}",$_lang[PPRU]." ".$profile->surname." ".$profile->name." ".$profile->otchestvo,$faktura);
} else {
$faktura = str_replace("{clientfirma}",$_lang[PPOTHER]." ".$profile->surname." ".$profile->name." ".$profile->otchestvo,$faktura);
}
} else if ($profile->org == "1") {
$faktura = str_replace("{clientfirma}",$profile->surname." ".$profile->name." ".$profile->otchestvo,$faktura);
}
if ($orgPhone) {
$faktura = str_replace("{clientphone}",$orgPhone,$faktura);
} else {
$faktura = str_replace("{clientphone}",$profile->phone,$faktura);
}
if ($f->currency == "BYR") {$f->currency = "RUB";}
$faktura = str_replace("{date}",date("j")." ".$_lang[monthR][date("n")]." ".date("Y")." ".$_lang[FakturaGoda],$faktura);
if ($f->nds > 0) {
$ndssumma = round($money_faktura/100*$f->nds,2);
$faktura = str_replace("{nds}",$_lang[FakturaSNds].":",$faktura);
$faktura = str_replace("{ndssumma}",$ndssumma,$faktura);
$faktura = str_replace("{summapropis}",num2str($money_faktura,$f->currency,$kvLang).", ".$_lang[FakturaVTomChisleNds]." ".$ndssumma." ".$currency->symbol,$faktura);
} else {
$faktura = str_replace("{nds}",$_lang[FakturaBezNds],$faktura);
$faktura = str_replace("{ndssumma}","0",$faktura);
$faktura = str_replace("{summapropis}",num2str($money_faktura,$f->currency,$kvLang),$faktura);
}
$faktura = preg_replace("/(<!--RowBegin-->.+<!--RowEnd-->)/isu","",$faktura);
$html = $faktura;
if ($type) {
$dompdf = new DOMPDF();
$dompdf->set_paper(array(0,0,595,840), 'portrait');
$dompdf->load_html($html);
$dompdf->render();
if ($f->shtamp_pdf and file_exists($full_home_path."/_rootimages/".$f->shtamp_pdf)) {
list($width, $height, $imagetype) = getimagesize($full_home_path."/_rootimages/".$f->shtamp_pdf);
if ($imagetype == "1") { $imagetype = "gif"; }
else if ($imagetype == "2") { $imagetype = "jpg"; }
else if ($imagetype == "3") { $imagetype = "png"; }
else { $imagetype = ""; }
if ($width and $height and $imagetype) {
$pdf = $dompdf->get_canvas();
$footer = $pdf->open_object();
$pdf->image($full_home_path.'/_rootimages/'.$f->shtamp_pdf, $imagetype, 320, 360, $width, $height);
$pdf->close_object();
$pdf->add_object($footer, "all");
}
}
if ($type == "1") {
// return PDF, stream
$dompdf->stream("faktura.pdf", array("Attachment" => 1));
}
else if ($type == "2") {
// return filename
$filename = $full_home_path."/_roottemp/"."faktura_".$bill->uid."_".$bill->id.".pdf";
file_put_contents($filename, $dompdf->output());
return $filename;
}
} else {
// return HTML
return $html;
}
} else {
print "Error: can't find row block in template";
}
}
}
function createKvitanciya($kvid, $billid, $type) {
// $type = 0 - HTML; return HTML
// $type = 1 - PDF, stream; return PDF;
// $type = 2 - PDF, file; return filename with full path
global $full_home_path;
$bill = GetBillById($billid);
$user = GetUserById($bill->uid);
if (!$kvid) {
$kv = @mysql_query("select * from kvitancii where attachToEmail='1'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>Function: ".__FUNCTION__."<BR>MySQL Error: ".mysql_error());
$kv = @mysql_fetch_object($kv);
} else {
$kv = GetKvitanciiById($kvid);
}
if ($bill->id and $user->id and $kv->id) {
$sid=sprintf("%04d", $bill->id);
$money=$bill->money_host+$bill->money_domain+$bill->money_addons+$bill->money+$bill->money_shop;
$nacenka=GetSetting("nacenka_sb");
if (!$type) {
if ($kv->template) { $kvtpl = htmlDecode($kv->template); } else { $kvtpl = GetTpl("tpl_sberbank", $user->lang); $kvtpl = $kvtpl[template]; }
} else {
if ($kv->template_pdf) { $kvtpl = htmlDecode($kv->template_pdf); } else { $kvtpl = GetTpl("tpl_sberbank_pdf", $user->lang); $kvtpl = $kvtpl[template]; }
}
if ($user->lang) {$kvLang=$user->lang;} else {$kvLang="russian";}
$_lang = LoadLanguageToVariable($kvLang);
$currency = GetCurrencyByCode("$kv->currency");
$money_kv = $money*$currency->koeficient;
$money_kv = $money_kv + ($money_kv/100)*$nacenka;
$money_kv = round($money_kv,2);
$kvtpl = preg_replace("/{firma}/u",$kv->orgname,$kvtpl);
$kvtpl = preg_replace("/{inn}/u",$kv->inn,$kvtpl);
$kvtpl = preg_replace("/{kpp}/u",$kv->kpp,$kvtpl);
$kvtpl = preg_replace("/{rs}/u",$kv->schet,$kvtpl);
$kvtpl = preg_replace("/{bank}/u",$kv->bank,$kvtpl);
$kvtpl = preg_replace("/{ks}/u",$kv->korschet,$kvtpl);
$kvtpl = preg_replace("/{bik}/u",$kv->bik,$kvtpl);
$kvtpl = preg_replace("/{schet}/u",$sid,$kvtpl);
$kvtpl = preg_replace("/{summa}/u",$money_kv." ".$currency->symbol,$kvtpl);
if ($kv->nds > 0) {
$ndssumma = round($money_kv/100*$kv->nds,2);
$kvtpl = preg_replace("/{ndssumma}/u",$ndssumma." ".$currency->symbol,$kvtpl);
}
$html = $kvtpl;
if ($type) {
$dompdf = new DOMPDF();
$dompdf->set_paper(array(0,0,595,840), 'portrait');
$dompdf->load_html($html);
$dompdf->render();
if ($type == "1") {
// return PDF, stream
$dompdf->stream("kvitanciya.pdf", array("Attachment" => 1));
}
else if ($type == "2") {
// return filename
$filename = $full_home_path."/_roottemp/"."kvitanciya_".$bill->uid."_".$bill->id.".pdf";
file_put_contents($filename, $dompdf->output());
return $filename;
}
} else {
// return HTML
return $html;
}
}
}
?>